From 6f4d283b39c871170e29ba071a756ec27d64cf71 Mon Sep 17 00:00:00 2001 From: Grzegorz {NineX} Krzystek Date: Sun, 26 Feb 2023 12:50:30 +0100 Subject: [PATCH] rtl8188fu Driver update --- .../net/wireless/realtek/rtl8188fu/Makefile | 50 +- .../realtek/rtl8188fu/core/efuse/rtw_efuse.c | 14 - .../wireless/realtek/rtl8188fu/core/rtw_ap.c | 4 - .../realtek/rtl8188fu/core/rtw_br_ext.c | 285 - .../realtek/rtl8188fu/core/rtw_btcoex.c | 1743 ----- .../wireless/realtek/rtl8188fu/core/rtw_cmd.c | 353 -- .../realtek/rtl8188fu/core/rtw_debug.c | 132 - .../realtek/rtl8188fu/core/rtw_ieee80211.c | 4 +- .../realtek/rtl8188fu/core/rtw_ioctl_set.c | 8 - .../realtek/rtl8188fu/core/rtw_mlme.c | 10 - .../realtek/rtl8188fu/core/rtw_mlme_ext.c | 31 +- .../wireless/realtek/rtl8188fu/core/rtw_mp.c | 118 - .../realtek/rtl8188fu/core/rtw_mp_ioctl.c | 4 +- .../realtek/rtl8188fu/core/rtw_pwrctrl.c | 152 +- .../realtek/rtl8188fu/core/rtw_recv.c | 21 - .../realtek/rtl8188fu/core/rtw_security.c | 318 - .../realtek/rtl8188fu/core/rtw_sta_mgt.c | 3 +- .../realtek/rtl8188fu/core/rtw_wlan_util.c | 6 - .../realtek/rtl8188fu/core/rtw_xmit.c | 4 +- .../rtl8188fu/hal/btc/HalBtc8188c2Ant.c | 1988 ------ .../rtl8188fu/hal/btc/HalBtc8188c2Ant.h | 150 - .../rtl8188fu/hal/btc/HalBtc8192d2Ant.c | 1993 ------ .../rtl8188fu/hal/btc/HalBtc8192d2Ant.h | 171 - .../rtl8188fu/hal/btc/HalBtc8192e1Ant.c | 3739 ----------- .../rtl8188fu/hal/btc/HalBtc8192e1Ant.h | 255 - .../rtl8188fu/hal/btc/HalBtc8192e2Ant.c | 5028 --------------- .../rtl8188fu/hal/btc/HalBtc8192e2Ant.h | 232 - .../rtl8188fu/hal/btc/HalBtc8703b1Ant.c | 5239 --------------- .../rtl8188fu/hal/btc/HalBtc8703b1Ant.h | 387 -- .../rtl8188fu/hal/btc/HalBtc8703b2Ant.c | 4865 -------------- .../rtl8188fu/hal/btc/HalBtc8703b2Ant.h | 229 - .../rtl8188fu/hal/btc/HalBtc8723a1Ant.c | 1545 ----- .../rtl8188fu/hal/btc/HalBtc8723a1Ant.h | 172 - .../rtl8188fu/hal/btc/HalBtc8723a2Ant.c | 3747 ----------- .../rtl8188fu/hal/btc/HalBtc8723a2Ant.h | 185 - .../rtl8188fu/hal/btc/HalBtc8723b1Ant.c | 5639 ----------------- .../rtl8188fu/hal/btc/HalBtc8723b1Ant.h | 338 - .../rtl8188fu/hal/btc/HalBtc8723b2Ant.c | 4934 -------------- .../rtl8188fu/hal/btc/HalBtc8723b2Ant.h | 235 - .../rtl8188fu/hal/btc/HalBtc8812a1Ant.c | 3718 ----------- .../rtl8188fu/hal/btc/HalBtc8812a1Ant.h | 259 - .../rtl8188fu/hal/btc/HalBtc8812a2Ant.c | 5435 ---------------- .../rtl8188fu/hal/btc/HalBtc8812a2Ant.h | 250 - .../rtl8188fu/hal/btc/HalBtc8821a1Ant.c | 3434 ---------- .../rtl8188fu/hal/btc/HalBtc8821a1Ant.h | 214 - .../rtl8188fu/hal/btc/HalBtc8821a2Ant.c | 4859 -------------- .../rtl8188fu/hal/btc/HalBtc8821a2Ant.h | 227 - .../rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.c | 4344 ------------- .../rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.h | 208 - .../realtek/rtl8188fu/hal/btc/HalBtcOutSrc.h | 748 --- .../realtek/rtl8188fu/hal/btc/Mp_Precomp.h | 89 - .../realtek/rtl8188fu/hal/hal_btcoex.c | 3690 ----------- .../wireless/realtek/rtl8188fu/hal/hal_com.c | 40 +- .../realtek/rtl8188fu/hal/hal_com_phycfg.c | 1546 ----- .../wireless/realtek/rtl8188fu/hal/hal_dm.c | 3 - .../realtek/rtl8188fu/hal/hal_hci/hal_usb.c | 30 +- .../wireless/realtek/rtl8188fu/hal/hal_intf.c | 26 +- .../realtek/rtl8188fu/hal/led/hal_usb_led.c | 5 - .../realtek/rtl8188fu/hal/phydm/halphyrf_ap.c | 2504 -------- .../realtek/rtl8188fu/hal/phydm/halphyrf_ap.h | 162 - .../realtek/rtl8188fu/hal/phydm/halphyrf_ce.c | 12 - .../rtl8188fu/hal/phydm/halphyrf_win.c | 716 --- .../rtl8188fu/hal/phydm/halphyrf_win.h | 108 - .../realtek/rtl8188fu/hal/phydm/phydm.c | 5 - .../realtek/rtl8188fu/hal/phydm/phydm.h | 1 - .../rtl8188fu/hal/phydm/phydm_adaptivity.c | 2 +- .../rtl8188fu/hal/phydm/phydm_antdiv.c | 4 - .../realtek/rtl8188fu/hal/phydm/phydm_debug.c | 58 +- .../realtek/rtl8188fu/hal/phydm/phydm_dig.c | 2 +- .../hal/phydm/phydm_edcaturbocheck.c | 9 - .../rtl8188fu/hal/phydm/phydm_hwconfig.c | 14 +- .../hal/phydm/phydm_powertracking_ce.c | 9 +- .../hal/phydm/phydm_powertracking_ce.h | 18 - .../rtl8188fu/hal/phydm/phydm_pre_define.h | 10 - .../realtek/rtl8188fu/hal/phydm/phydm_types.h | 12 - .../hal/phydm/rtl8188f/halhwimg8188f_rf.c | 151 - .../hal/phydm/rtl8188f/halphyrf_8188f.c | 75 +- .../hal/phydm/rtl8188f/halphyrf_8188f.h | 11 - .../rtl8188fu/hal/rtl8188f/rtl8188f_cmd.c | 288 - .../rtl8188fu/hal/rtl8188f/rtl8188f_dm.c | 16 - .../hal/rtl8188f/rtl8188f_hal_init.c | 188 - .../rtl8188fu/hal/rtl8188f/rtl8188f_phycfg.c | 32 - .../rtl8188fu/hal/rtl8188f/rtl8188f_rf6052.c | 9 - .../hal/rtl8188f/usb/rtl8188fu_xmit.c | 2 +- .../rtl8188fu/hal/rtl8188f/usb/usb_halinit.c | 118 +- .../rtl8188fu/hal/rtl8188f/usb/usb_ops.c | 111 +- .../realtek/rtl8188fu/include/autoconf.h | 22 - .../realtek/rtl8188fu/include/drv_types.h | 25 - .../realtek/rtl8188fu/include/hal_btcoex.h | 4 - .../realtek/rtl8188fu/include/hal_com.h | 6 - .../rtl8188fu/include/hal_com_phycfg.h | 47 - .../realtek/rtl8188fu/include/hal_data.h | 30 - .../realtek/rtl8188fu/include/hal_intf.h | 10 - .../realtek/rtl8188fu/include/ieee80211.h | 13 +- .../realtek/rtl8188fu/include/osdep_intf.h | 2 - .../realtek/rtl8188fu/include/osdep_service.h | 1 + .../rtl8188fu/include/osdep_service_linux.h | 12 +- .../realtek/rtl8188fu/include/rtl8188f_cmd.h | 3 - .../realtek/rtl8188fu/include/rtl8188f_hal.h | 7 - .../realtek/rtl8188fu/include/rtw_btcoex.h | 436 -- .../realtek/rtl8188fu/include/rtw_cmd.h | 4 - .../realtek/rtl8188fu/include/rtw_debug.h | 6 - .../realtek/rtl8188fu/include/rtw_pwrctrl.h | 7 - .../realtek/rtl8188fu/include/rtw_recv.h | 8 - .../realtek/rtl8188fu/include/rtw_security.h | 7 +- .../realtek/rtl8188fu/include/rtw_wifi_regd.h | 4 +- .../realtek/rtl8188fu/include/usb_ops.h | 21 - .../realtek/rtl8188fu/include/usb_ops_linux.h | 4 - .../os_dep/linux/custom_gpio_linux.c | 356 -- .../rtl8188fu/os_dep/linux/ioctl_cfg80211.c | 125 +- .../rtl8188fu/os_dep/linux/ioctl_linux.c | 601 +- .../realtek/rtl8188fu/os_dep/linux/ioctl_mp.c | 2334 ------- .../rtl8188fu/os_dep/linux/mlme_linux.c | 14 +- .../realtek/rtl8188fu/os_dep/linux/os_intfs.c | 161 +- .../realtek/rtl8188fu/os_dep/linux/rtw_proc.c | 2194 ------- .../realtek/rtl8188fu/os_dep/linux/rtw_proc.h | 52 - .../realtek/rtl8188fu/os_dep/linux/usb_intf.c | 104 - .../rtl8188fu/os_dep/linux/usb_ops_linux.c | 90 - .../rtl8188fu/os_dep/linux/wifi_regd.c | 27 +- .../rtl8188fu/os_dep/linux/xmit_linux.c | 5 - .../realtek/rtl8188fu/os_dep/osdep_service.c | 217 +- 121 files changed, 174 insertions(+), 84888 deletions(-) delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/core/rtw_btcoex.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtcOutSrc.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/btc/Mp_Precomp.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/hal_btcoex.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/include/rtw_btcoex.h delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/custom_gpio_linux.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_mp.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.c delete mode 100644 drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.h diff --git a/drivers/net/wireless/realtek/rtl8188fu/Makefile b/drivers/net/wireless/realtek/rtl8188fu/Makefile index 1bc300e30..044f5da8f 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/Makefile +++ b/drivers/net/wireless/realtek/rtl8188fu/Makefile @@ -1,10 +1,10 @@ # SPDX-License-Identifier: GPL-2.0 EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) -EXTRA_CFLAGS += -O1 -Wno-vla +EXTRA_CFLAGS += -O1 #EXTRA_CFLAGS += -O3 #EXTRA_CFLAGS += -Wall #EXTRA_CFLAGS += -Wextra -EXTRA_CFLAGS += -Wno-error +#EXTRA_CFLAGS += -Werror #EXTRA_CFLAGS += -pedantic #EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes @@ -17,8 +17,8 @@ EXTRA_CFLAGS += -Wno-unused #EXTRA_CFLAGS += -Wno-uninitialized #EXTRA_CFLAGS += -Wno-error=date-time # Fix compile error on gcc 4.9 and later -EXTRA_CFLAGS += -I$(srctree)/$(src)/include -EXTRA_CFLAGS += -I$(srctree)/$(src)/hal/phydm +EXTRA_CFLAGS += -I$(src)/include +EXTRA_CFLAGS += -I$(src)/hal/phydm EXTRA_LDFLAGS += --strip-debug @@ -41,13 +41,11 @@ CONFIG_POWER_SAVING = y CONFIG_USB_AUTOSUSPEND = n CONFIG_HW_PWRP_DETECTION = n CONFIG_WIFI_TEST = n -CONFIG_BT_COEXIST = n CONFIG_INTEL_WIDI = n CONFIG_WAPI_SUPPORT = n CONFIG_EFUSE_CONFIG_FILE = n CONFIG_EXT_CLK = n CONFIG_TRAFFIC_PROTECT = y -CONFIG_LOAD_PHY_PARA_FROM_FILE = y CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY = n CONFIG_CALIBRATE_TX_POWER_TO_MAX = y CONFIG_RTW_ADAPTIVITY_EN = disable @@ -132,19 +130,13 @@ _OS_INTFS_FILES := os_dep/osdep_service.o \ os_dep/linux/mlme_linux.o \ os_dep/linux/recv_linux.o \ os_dep/linux/ioctl_cfg80211.o \ - os_dep/linux/wifi_regd.o \ - os_dep/linux/rtw_proc.o - -ifeq ($(CONFIG_MP_INCLUDED), y) -_OS_INTFS_FILES += os_dep/linux/ioctl_mp.o -endif + os_dep/linux/wifi_regd.o _HAL_INTFS_FILES := hal/hal_intf.o \ hal/hal_com.o \ hal/hal_com_phycfg.o \ hal/hal_phy.o \ hal/hal_dm.o \ - hal/hal_btcoex.o \ hal/hal_mp.o \ hal/hal_hci/hal_usb.o \ hal/led/hal_usb_led.o @@ -172,21 +164,6 @@ _OUTSRC_FILES := hal/phydm/phydm_debug.o \ hal/phydm/txbf/halcomtxbf.o\ hal/phydm/txbf/haltxbfinterface.o -ifeq ($(CONFIG_BT_COEXIST), y) -EXTRA_CFLAGS += -I$(srctree)/$(src)/hal/btc -_OUTSRC_FILES += hal/btc/HalBtc8192e1Ant.o \ - hal/btc/HalBtc8192e2Ant.o \ - hal/btc/HalBtc8723b1Ant.o \ - hal/btc/HalBtc8723b2Ant.o \ - hal/btc/HalBtc8812a1Ant.o \ - hal/btc/HalBtc8812a2Ant.o \ - hal/btc/HalBtc8821a1Ant.o \ - hal/btc/HalBtc8821a2Ant.o \ - hal/btc/HalBtc8821aCsr2Ant.o \ - hal/btc/HalBtc8703b1Ant.o \ - hal/btc/HalBtc8703b2Ant.o -endif - ########### HAL_RTL8188F ################################# ifeq ($(CONFIG_RTL8188F), y) @@ -256,10 +233,6 @@ ifeq ($(CONFIG_WIFI_TEST), y) EXTRA_CFLAGS += -DCONFIG_WIFI_TEST endif -ifeq ($(CONFIG_BT_COEXIST), y) -EXTRA_CFLAGS += -DCONFIG_BT_COEXIST -endif - ifeq ($(CONFIG_INTEL_WIDI), y) EXTRA_CFLAGS += -DCONFIG_INTEL_WIDI endif @@ -302,13 +275,6 @@ ifeq ($(CONFIG_TRAFFIC_PROTECT), y) EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT endif -ifeq ($(CONFIG_LOAD_PHY_PARA_FROM_FILE), y) -EXTRA_CFLAGS += -DCONFIG_LOAD_PHY_PARA_FROM_FILE -#EXTRA_CFLAGS += -DREALTEK_CONFIG_PATH_WITH_IC_NAME_FOLDER -#EXTRA_CFLAGS += -DREALTEK_CONFIG_PATH=\"/lib/firmware/\" -EXTRA_CFLAGS += -DREALTEK_CONFIG_PATH=\"\" -endif - ifeq ($(CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY), y) EXTRA_CFLAGS += -DCONFIG_CALIBRATE_TX_POWER_BY_REGULATORY endif @@ -395,13 +361,13 @@ else EXTRA_CFLAGS += -mfloat-abi=hard endif endif - +## ULLI set DM_ODM_SUPPORT_TYPE to ODM_CE EXTRA_CFLAGS += -DDM_ODM_SUPPORT_TYPE=0x04 ifeq ($(CONFIG_PLATFORM_I386_PC), y) EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT -SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ | sed -e s/armv6l/arm/) +SUBARCH := $(shell uname -m | sed -e s/i.86/i386/) ARCH ?= $(SUBARCH) CROSS_COMPILE ?= KVER := $(shell uname -r) @@ -434,7 +400,6 @@ rtk_core := core/rtw_cmd.o \ core/rtw_br_ext.o \ core/rtw_iol.o \ core/rtw_sreset.o \ - core/rtw_btcoex.o \ core/rtw_beamforming.o \ core/rtw_odm.o \ core/efuse/rtw_efuse.o @@ -506,3 +471,4 @@ clean: rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~ rm -fr .tmp_versions endif + diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/efuse/rtw_efuse.c b/drivers/net/wireless/realtek/rtl8188fu/core/efuse/rtw_efuse.c index 6e6c034e1..e9a46fd6f 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/efuse/rtw_efuse.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/efuse/rtw_efuse.c @@ -1481,11 +1481,7 @@ EFUSE_ShadowWrite( IN u16 Offset, IN OUT u32 Value) { -#if (MP_DRIVER == 0) return; -#endif - if ( pAdapter->registrypriv.mp_mode == 0) - return; if (Type == 1) @@ -1590,9 +1586,7 @@ int storeAdaptorInfoFile(char *path, u8* efuse_data) int retriveAdaptorInfoFile(char *path, u8* efuse_data) { int ret = _SUCCESS; -#ifdef set_fs mm_segment_t oldfs; -#endif struct file *fp; if(path && efuse_data) { @@ -1628,9 +1622,7 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf) u32 ret = _FAIL; struct file *fp; -#ifdef set_fs mm_segment_t fs; -#endif loff_t pos = 0; fp = filp_open(path, O_RDONLY, 0); @@ -1647,10 +1639,8 @@ u32 rtw_read_efuse_from_file(const char *path, u8 *buf) temp[2] = 0; /* add end of string '\0' */ -#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); -#endif for (i = 0 ; i < HWSET_MAX_SIZE ; i++) { vfs_read(fp, temp, 2, &pos); @@ -1696,9 +1686,7 @@ exit: u32 rtw_read_macaddr_from_file(const char *path, u8 *buf) { struct file *fp; -#ifdef set_fs mm_segment_t fs; -#endif loff_t pos = 0; u8 source_addr[18]; @@ -1720,10 +1708,8 @@ u32 rtw_read_macaddr_from_file(const char *path, u8 *buf) goto exit; } -#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); -#endif vfs_read(fp, source_addr, 18, &pos); source_addr[17] = ':'; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ap.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ap.c index 6fd0be96b..0e70c3d92 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ap.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ap.c @@ -3894,10 +3894,6 @@ void stop_ap_mode(_adapter *padapter) rtw_free_mlme_priv_ie_data(pmlmepriv); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_MediaStatusNotify(padapter, 0); //disconnect -#endif - } #endif //CONFIG_NATIVEAP_MLME diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_br_ext.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_br_ext.c index 21f5f14c7..4ce669eba 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_br_ext.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_br_ext.c @@ -22,7 +22,6 @@ #ifdef __KERNEL__ #include #include -#include #include #include #endif @@ -72,29 +71,6 @@ #define MAGIC_CODE_LEN 2 #define WAIT_TIME_PPPOE 5 // waiting time for pppoe server in sec -#define IPX_NODE_LEN 6 -struct ipx_address { - __be32 net; - __u8 node[IPX_NODE_LEN]; - __be16 sock; -}; - -struct ipxhdr { - __be16 ipx_checksum __packed; -#define IPX_NO_CHECKSUM cpu_to_be16(0xFFFF) - __be16 ipx_pktsize __packed; - __u8 ipx_tctrl; - __u8 ipx_type; -#define IPX_TYPE_UNKNOWN 0x00 -#define IPX_TYPE_RIP 0x01 /* may also be 0 */ -#define IPX_TYPE_SAP 0x04 /* may also be 0 */ -#define IPX_TYPE_SPX 0x05 /* SPX protocol */ -#define IPX_TYPE_NCP 0x11 /* $lots for docs on this (SPIT) */ -#define IPX_TYPE_PPROP 0x14 /* complicated flood fill brdcast */ - struct ipx_address ipx_dest __packed; - struct ipx_address ipx_source __packed; -}; - /*----------------------------------------------------------------- How database records network address: 0 1 2 3 4 5 6 7 8 9 10 @@ -953,267 +929,6 @@ int nat25_db_handle(_adapter *priv, struct sk_buff *skb, int method) } } - /*---------------------------------------------------*/ - /* Handle IPX and Apple Talk frame */ - /*---------------------------------------------------*/ - else if((protocol == __constant_htons(ETH_P_IPX)) || - (protocol == __constant_htons(ETH_P_ATALK)) || - (protocol == __constant_htons(ETH_P_AARP))) - { - unsigned char ipx_header[2] = {0xFF, 0xFF}; - struct ipxhdr *ipx = NULL; - struct elapaarp *ea = NULL; - struct ddpehdr *ddp = NULL; - unsigned char *framePtr = skb->data + ETH_HLEN; - - if(protocol == __constant_htons(ETH_P_IPX)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet II)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else //if(protocol <= __constant_htons(ETH_FRAME_LEN)) - { - if(!memcmp(ipx_header, framePtr, 2)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet 802.3)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else - { - unsigned char ipx_8022_type = 0xE0; - unsigned char snap_8022_type = 0xAA; - - if(*framePtr == snap_8022_type) - { - unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; // IPX SNAP ID - unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; // Apple Talk AARP SNAP ID - unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; // Apple Talk DDP SNAP ID - - framePtr += 3; // eliminate the 802.2 header - - if(!memcmp(ipx_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - DBG_871X("NAT25: Protocol=IPX (Ethernet SNAP)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else if(!memcmp(aarp_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - ea = (struct elapaarp *)framePtr; - } - else if(!memcmp(ddp_snap_id, framePtr, 5)) - { - framePtr += 5; // eliminate the SNAP header - - ddp = (struct ddpehdr *)framePtr; - } - else - { - DEBUG_WARN("NAT25: Protocol=Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], - framePtr[1], framePtr[2], framePtr[3], framePtr[4]); - return -1; - } - } - else if(*framePtr == ipx_8022_type) - { - framePtr += 3; // eliminate the 802.2 header - - if(!memcmp(ipx_header, framePtr, 2)) - { - DBG_871X("NAT25: Protocol=IPX (Ethernet 802.2)\n"); - ipx = (struct ipxhdr *)framePtr; - } - else - return -1; - } - } - } - - /* IPX */ - if(ipx != NULL) - { - switch(method) - { - case NAT25_CHECK: - if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - { - DBG_871X("NAT25: Check IPX skb_copy\n"); - return 0; - } - return -1; - - case NAT25_INSERT: - { - DBG_871X("NAT25: Insert IPX, Dest=%08x,%02x%02x%02x%02x%02x%02x,%04x Source=%08x,%02x%02x%02x%02x%02x%02x,%04x\n", - ipx->ipx_dest.net, - ipx->ipx_dest.node[0], - ipx->ipx_dest.node[1], - ipx->ipx_dest.node[2], - ipx->ipx_dest.node[3], - ipx->ipx_dest.node[4], - ipx->ipx_dest.node[5], - ipx->ipx_dest.sock, - ipx->ipx_source.net, - ipx->ipx_source.node[0], - ipx->ipx_source.node[1], - ipx->ipx_source.node[2], - ipx->ipx_source.node[3], - ipx->ipx_source.node[4], - ipx->ipx_source.node[5], - ipx->ipx_source.sock); - - if(!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - { - DBG_871X("NAT25: Use IPX Net, and Socket as network addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); - - // change IPX source node addr to wlan STA address - memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); - } - else - { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); - } - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - } - return 0; - - case NAT25_LOOKUP: - { - if(!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) - { - DBG_871X("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - // replace IPX destination node addr with Lookup destination MAC addr - memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); - } - else - { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - } - } - return 0; - - default: - return -1; - } - } - - /* AARP */ - else if(ea != NULL) - { - /* Sanity check fields. */ - if(ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) - { - DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); - return -1; - } - - switch(method) - { - case NAT25_CHECK: - return 0; - - case NAT25_INSERT: - { - // change to AARP source mac address to wlan STA address - memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); - - DBG_871X("NAT25: Insert AARP, Source=%d,%d Destination=%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - } - return 0; - - case NAT25_LOOKUP: - { - DBG_871X("NAT25: Lookup AARP, Source=%d,%d Destination=%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - // change to AARP destination mac address to Lookup result - memcpy(ea->hw_dst, skb->data, ETH_ALEN); - } - return 0; - - default: - return -1; - } - } - - /* DDP */ - else if(ddp != NULL) - { - switch(method) - { - case NAT25_CHECK: - return -1; - - case NAT25_INSERT: - { - DBG_871X("NAT25: Insert DDP, Source=%d,%d Destination=%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - } - return 0; - - case NAT25_LOOKUP: - { - DBG_871X("NAT25: Lookup DDP, Source=%d,%d Destination=%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - } - return 0; - - default: - return -1; - } - } - - return -1; - } - /*---------------------------------------------------*/ /* Handle PPPoE frame */ /*---------------------------------------------------*/ diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_btcoex.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_btcoex.c deleted file mode 100644 index a3d249fbf..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_btcoex.c +++ /dev/null @@ -1,1743 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifdef CONFIG_BT_COEXIST - -#include -#include -#include - - -void rtw_btcoex_Initialize(PADAPTER padapter) -{ - hal_btcoex_Initialize(padapter); -} - -void rtw_btcoex_PowerOnSetting(PADAPTER padapter) -{ - hal_btcoex_PowerOnSetting(padapter); -} - -void rtw_btcoex_PreLoadFirmware(PADAPTER padapter) -{ - hal_btcoex_PreLoadFirmware(padapter); -} - -void rtw_btcoex_HAL_Initialize(PADAPTER padapter, u8 bWifiOnly) -{ - hal_btcoex_InitHwConfig(padapter, bWifiOnly); -} - -void rtw_btcoex_IpsNotify(PADAPTER padapter, u8 type) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_IpsNotify(padapter, type); -} - -void rtw_btcoex_LpsNotify(PADAPTER padapter, u8 type) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_LpsNotify(padapter, type); -} - -void rtw_btcoex_ScanNotify(PADAPTER padapter, u8 type) -{ - PHAL_DATA_TYPE pHalData; -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - struct bt_coex_info *pcoex_info = &padapter->coex_info; - PBT_MGNT pBtMgnt=&pcoex_info->BtMgnt; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == type) && (padapter->pbuddy_adapter)) - { - PADAPTER pbuddy = padapter->pbuddy_adapter; - if (check_fwstate(&pbuddy->mlmepriv, WIFI_SITE_MONITOR) == _TRUE) - return; - } -#endif - -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - if(pBtMgnt->ExtConfig.bEnableWifiScanNotify) - rtw_btcoex_SendScanNotify(padapter, type); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - - hal_btcoex_ScanNotify(padapter, type); -} - -void rtw_btcoex_ConnectNotify(PADAPTER padapter, u8 action) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - -#ifdef DBG_CONFIG_ERROR_RESET - if (_TRUE == rtw_hal_sreset_inprogress(padapter)) - { - DBG_8192C(FUNC_ADPT_FMT ": [BTCoex] under reset, skip notify!\n", - FUNC_ADPT_ARG(padapter)); - return; - } -#endif // DBG_CONFIG_ERROR_RESET - -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == action) && (padapter->pbuddy_adapter)) - { - PADAPTER pbuddy = padapter->pbuddy_adapter; - if (check_fwstate(&pbuddy->mlmepriv, WIFI_UNDER_LINKING) == _TRUE) - return; - } -#endif - - hal_btcoex_ConnectNotify(padapter, action); -} - -void rtw_btcoex_MediaStatusNotify(PADAPTER padapter, u8 mediaStatus) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - -#ifdef DBG_CONFIG_ERROR_RESET - if (_TRUE == rtw_hal_sreset_inprogress(padapter)) - { - DBG_8192C(FUNC_ADPT_FMT ": [BTCoex] under reset, skip notify!\n", - FUNC_ADPT_ARG(padapter)); - return; - } -#endif // DBG_CONFIG_ERROR_RESET - -#ifdef CONFIG_CONCURRENT_MODE - if ((RT_MEDIA_DISCONNECT == mediaStatus) && (padapter->pbuddy_adapter)) - { - PADAPTER pbuddy = padapter->pbuddy_adapter; - if (check_fwstate(&pbuddy->mlmepriv, WIFI_ASOC_STATE) == _TRUE) - return; - } -#endif // CONFIG_CONCURRENT_MODE - - if ((RT_MEDIA_CONNECT == mediaStatus) - && (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE)) - { - rtw_hal_set_hwreg(padapter, HW_VAR_DL_RSVD_PAGE, NULL); - } - - hal_btcoex_MediaStatusNotify(padapter, mediaStatus); -} - -void rtw_btcoex_SpecialPacketNotify(PADAPTER padapter, u8 pktType) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_SpecialPacketNotify(padapter, pktType); -} - -void rtw_btcoex_IQKNotify(PADAPTER padapter, u8 state) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_IQKNotify(padapter, state); -} - -void rtw_btcoex_BtInfoNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_BtInfoNotify(padapter, length, tmpBuf); -} - -void rtw_btcoex_BtMpRptNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - if (padapter->registrypriv.mp_mode == 1) - return; - - hal_btcoex_BtMpRptNotify(padapter, length, tmpBuf); -} - -void rtw_btcoex_SuspendNotify(PADAPTER padapter, u8 state) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_SuspendNotify(padapter, state); -} - -void rtw_btcoex_HaltNotify(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - if (_FALSE == padapter->bup) - { - DBG_871X(FUNC_ADPT_FMT ": bup=%d Skip!\n", - FUNC_ADPT_ARG(padapter), padapter->bup); - - return; - } - - if (rtw_is_surprise_removed(padapter)) { - DBG_871X(FUNC_ADPT_FMT ": bSurpriseRemoved=%s Skip!\n", - FUNC_ADPT_ARG(padapter), rtw_is_surprise_removed(padapter)?"True":"False"); - - return; - } - - hal_btcoex_HaltNotify(padapter); -} - -void rtw_btcoex_ScoreBoardStatusNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - - hal_btcoex_ScoreBoardStatusNotify(padapter, length, tmpBuf); -} - -void rtw_btcoex_SwitchBtTRxMask(PADAPTER padapter) -{ - hal_btcoex_SwitchBtTRxMask(padapter); -} - -void rtw_btcoex_Switch(PADAPTER padapter, u8 enable) -{ - hal_btcoex_SetBTCoexist(padapter, enable); -} - -u8 rtw_btcoex_IsBtDisabled(PADAPTER padapter) -{ - return hal_btcoex_IsBtDisabled(padapter); -} - -void rtw_btcoex_Handler(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - - pHalData = GET_HAL_DATA(padapter); - - if (_FALSE == pHalData->EEPROMBluetoothCoexist) - return; - -#if defined(CONFIG_CONCURRENT_MODE) - if (padapter->adapter_type != PRIMARY_ADAPTER) - return; -#endif - - - - hal_btcoex_Hanlder(padapter); -} - -s32 rtw_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter) -{ - s32 coexctrl; - - coexctrl = hal_btcoex_IsBTCoexRejectAMPDU(padapter); - - return coexctrl; -} - -s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER padapter) -{ - s32 coexctrl; - - coexctrl = hal_btcoex_IsBTCoexCtrlAMPDUSize(padapter); - - return coexctrl; -} - -u32 rtw_btcoex_GetAMPDUSize(PADAPTER padapter) -{ - u32 size; - - size = hal_btcoex_GetAMPDUSize(padapter); - - return size; -} - -void rtw_btcoex_SetManualControl(PADAPTER padapter, u8 manual) -{ - if (_TRUE == manual) - { - hal_btcoex_SetManualControl(padapter, _TRUE); - } - else - { - hal_btcoex_SetManualControl(padapter, _FALSE); - } -} - -u8 rtw_btcoex_1Ant(PADAPTER padapter) -{ - return hal_btcoex_1Ant(padapter); -} - -u8 rtw_btcoex_IsBtControlLps(PADAPTER padapter) -{ - return hal_btcoex_IsBtControlLps(padapter); -} - -u8 rtw_btcoex_IsLpsOn(PADAPTER padapter) -{ - return hal_btcoex_IsLpsOn(padapter); -} - -u8 rtw_btcoex_RpwmVal(PADAPTER padapter) -{ - return hal_btcoex_RpwmVal(padapter); -} - -u8 rtw_btcoex_LpsVal(PADAPTER padapter) -{ - return hal_btcoex_LpsVal(padapter); -} - -void rtw_btcoex_SetBTCoexist(PADAPTER padapter, u8 bBtExist) -{ - hal_btcoex_SetBTCoexist(padapter, bBtExist); -} - -void rtw_btcoex_SetChipType(PADAPTER padapter, u8 chipType) -{ - hal_btcoex_SetChipType(padapter, chipType); -} - -void rtw_btcoex_SetPGAntNum(PADAPTER padapter, u8 antNum) -{ - hal_btcoex_SetPgAntNum(padapter, antNum); -} - -u8 rtw_btcoex_GetPGAntNum(PADAPTER padapter) -{ - return hal_btcoex_GetPgAntNum(padapter); -} - -void rtw_btcoex_SetSingleAntPath(PADAPTER padapter, u8 singleAntPath) -{ - hal_btcoex_SetSingleAntPath(padapter, singleAntPath); -} - -u32 rtw_btcoex_GetRaMask(PADAPTER padapter) -{ - return hal_btcoex_GetRaMask(padapter); -} - -void rtw_btcoex_RecordPwrMode(PADAPTER padapter, u8 *pCmdBuf, u8 cmdLen) -{ - hal_btcoex_RecordPwrMode(padapter, pCmdBuf, cmdLen); -} - -void rtw_btcoex_DisplayBtCoexInfo(PADAPTER padapter, u8 *pbuf, u32 bufsize) -{ - hal_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); -} - -void rtw_btcoex_SetDBG(PADAPTER padapter, u32 *pDbgModule) -{ - hal_btcoex_SetDBG(padapter, pDbgModule); -} - -u32 rtw_btcoex_GetDBG(PADAPTER padapter, u8 *pStrBuf, u32 bufSize) -{ - return hal_btcoex_GetDBG(padapter, pStrBuf, bufSize); -} - -u8 rtw_btcoex_IncreaseScanDeviceNum(PADAPTER padapter) -{ - return hal_btcoex_IncreaseScanDeviceNum(padapter); -} - -u8 rtw_btcoex_IsBtLinkExist(PADAPTER padapter) -{ - return hal_btcoex_IsBtLinkExist(padapter); -} - -void rtw_btcoex_SetBtPatchVersion(PADAPTER padapter,u16 btHciVer, u16 btPatchVer) -{ - hal_btcoex_SetBtPatchVersion(padapter,btHciVer,btPatchVer); -} - -void rtw_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion) -{ - hal_btcoex_SetHciVersion(padapter, hciVersion); -} - -void rtw_btcoex_StackUpdateProfileInfo(void) -{ - hal_btcoex_StackUpdateProfileInfo(); -} - -void rtw_btcoex_BTOffOnNotify(PADAPTER padapter, u8 bBTON) -{ - hal_btcoex_BTOffOnNotify(padapter, bBTON); -} - -// ================================================== -// Below Functions are called by BT-Coex -// ================================================== -void rtw_btcoex_rx_ampdu_apply(PADAPTER padapter) -{ - rtw_rx_ampdu_apply(padapter); -} - -void rtw_btcoex_LPS_Enter(PADAPTER padapter) -{ - struct pwrctrl_priv *pwrpriv; - u8 lpsVal; - - - pwrpriv = adapter_to_pwrctl(padapter); - - pwrpriv->bpower_saving = _TRUE; - lpsVal = rtw_btcoex_LpsVal(padapter); - rtw_set_ps_mode(padapter, PS_MODE_MIN, 0, lpsVal, "BTCOEX"); -} - -void rtw_btcoex_LPS_Leave(PADAPTER padapter) -{ - struct pwrctrl_priv *pwrpriv; - - - pwrpriv = adapter_to_pwrctl(padapter); - - if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) - { - rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0, "BTCOEX"); - LPS_RF_ON_check(padapter, 100); - pwrpriv->bpower_saving = _FALSE; - } -} - -u16 rtw_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data) -{ - return hal_btcoex_btreg_read(padapter, type, addr, data); -} - -u16 rtw_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val) -{ - return hal_btcoex_btreg_write(padapter, type, addr, val); -} - - -// ================================================== -// Below Functions are BT-Coex socket related function -// ================================================== - -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX -_adapter *pbtcoexadapter = NULL; -u8 rtw_btcoex_btinfo_cmd(_adapter *adapter, u8 *buf, u16 len) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - u8 *btinfo; - struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { - rtw_mfree((u8*)ph2c, sizeof(struct cmd_obj)); - res = _FAIL; - goto exit; - } - - btinfo = rtw_zmalloc(len); - if (btinfo == NULL) { - rtw_mfree((u8*)ph2c, sizeof(struct cmd_obj)); - rtw_mfree((u8*)pdrvextra_cmd_parm, sizeof(struct drvextra_cmd_parm)); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = BTINFO_WK_CID; - pdrvextra_cmd_parm->type = 0; - pdrvextra_cmd_parm->size = len; - pdrvextra_cmd_parm->pbuf = btinfo; - - _rtw_memcpy(btinfo, buf, len); - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - return res; -} - -u8 rtw_btcoex_send_event_to_BT(_adapter *padapter, u8 status, u8 event_code, u8 opcode_low, u8 opcode_high,u8 *dbg_msg) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0,tx_event_length = 0; - rtw_HCI_event *pEvent; - - pEvent = (rtw_HCI_event*)(&localBuf[0]); - - pEvent->EventCode = event_code; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = opcode_low; - pEvent->Data[2] = opcode_high; - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length, dbg_msg); -#endif - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - - return status; -} - -/* -Ref: -Realtek Wi-Fi Driver -Host Controller Interface for -Bluetooth 3.0 + HS V1.4 2013/02/07 - -Window team code & BT team code - */ - - -u8 rtw_btcoex_parse_BT_info_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - #define BT_INFO_LENGTH 8 - - u8 curPollEnable = pcmd[0]; - u8 curPollTime = pcmd[1]; - u8 btInfoReason = pcmd[2]; - u8 btInfoLen = pcmd[3]; - u8 btinfo[BT_INFO_LENGTH]; - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0,tx_event_length = 0; - RTW_HCI_STATUS status = HCI_STATUS_SUCCESS; - rtw_HCI_event *pEvent; - - /* DBG_871X("%s\n",__func__); - DBG_871X("current Poll Enable: %d, currrent Poll Time: %d\n",curPollEnable,curPollTime); - DBG_871X("BT Info reason: %d, BT Info length: %d\n",btInfoReason,btInfoLen); - DBG_871X("%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x\n" - ,pcmd[4],pcmd[5],pcmd[6],pcmd[7],pcmd[8],pcmd[9],pcmd[10],pcmd[11]);*/ - - _rtw_memset(btinfo, 0, BT_INFO_LENGTH); - -#if 1 - if(BT_INFO_LENGTH != btInfoLen) - { - status = HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE; - DBG_871X("Error BT Info Length: %d\n",btInfoLen); - //return _FAIL; - } - else -#endif - { - if(0x1 == btInfoReason || 0x2 == btInfoReason) - { - _rtw_memcpy(btinfo, &pcmd[4], btInfoLen); - btinfo[0] = btInfoReason; - rtw_btcoex_btinfo_cmd(padapter,btinfo,btInfoLen); - } - else - { - DBG_871X("Other BT info reason\n"); - } - } - - //send complete event to BT - { - - pEvent = (rtw_HCI_event*)(&localBuf[0]); - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_INFO_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_INFO_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length,"BT_info_event"); -#endif - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_BT_patch_ver_info_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - u16 btPatchVer=0x0, btHciVer=0x0; - //u16 *pU2tmp; - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - - btHciVer = pcmd[0] | pcmd[1]<<8; - btPatchVer = pcmd[2] | pcmd[3]<<8; - - - DBG_871X("%s, cmd:%02x %02x %02x %02x\n",__func__, pcmd[0] ,pcmd[1] ,pcmd[2] ,pcmd[3]); - DBG_871X("%s, HCI Ver:%d, Patch Ver:%d\n",__func__, btHciVer,btPatchVer); - - rtw_btcoex_SetBtPatchVersion(padapter,btHciVer,btPatchVer); - - - //send complete event to BT - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_PATCH_VERSION_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_PATCH_VERSION_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length,"BT_patch_event"); -#endif - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_HCI_Ver_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - u16 hciver = pcmd[0] | pcmd[1] <<8; - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - - struct bt_coex_info *pcoex_info = &padapter->coex_info; - PBT_MGNT pBtMgnt=&pcoex_info->BtMgnt; - pBtMgnt->ExtConfig.HCIExtensionVer = hciver; - DBG_871X("%s, HCI Version: %d\n",__func__,pBtMgnt->ExtConfig.HCIExtensionVer); - if(pBtMgnt->ExtConfig.HCIExtensionVer < 4) - { - status = HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE; - DBG_871X("%s, Version = %d, HCI Version < 4\n",__func__,pBtMgnt->ExtConfig.HCIExtensionVer ); - } - else - { - rtw_btcoex_SetHciVersion(padapter,hciver); - } - //send complete event to BT - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_EXTENSION_VERSION_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_EXTENSION_VERSION_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } - -} - -u8 rtw_btcoex_parse_WIFI_scan_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - - struct bt_coex_info *pcoex_info = &padapter->coex_info; - PBT_MGNT pBtMgnt=&pcoex_info->BtMgnt; - pBtMgnt->ExtConfig.bEnableWifiScanNotify= pcmd[0]; - DBG_871X("%s, bEnableWifiScanNotify: %d\n",__func__,pBtMgnt->ExtConfig.bEnableWifiScanNotify); - - //send complete event to BT - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_ENABLE_WIFI_SCAN_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_ENABLE_WIFI_SCAN_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_HCI_link_status_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - struct bt_coex_info *pcoex_info=&padapter->coex_info; - PBT_MGNT pBtMgnt=&pcoex_info->BtMgnt; - //PBT_DBG pBtDbg=&padapter->MgntInfo.BtInfo.BtDbg; - u8 i, numOfHandle=0, numOfAcl=0; - u16 conHandle; - u8 btProfile, btCoreSpec, linkRole; - u8 *pTriple; - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - - //pBtDbg->dbgHciInfo.hciCmdCntLinkStatusNotify++; - //RT_DISP_DATA(FIOCTL, IOCTL_BT_HCICMD_EXT, "LinkStatusNotify, Hex Data :\n", - // &pHciCmd->Data[0], pHciCmd->Length); - - DBG_871X("BTLinkStatusNotify\n"); - - // Current only RTL8723 support this command. - //pBtMgnt->bSupportProfile = TRUE; - pBtMgnt->bSupportProfile = _FALSE; - - pBtMgnt->ExtConfig.NumberOfACL = 0; - pBtMgnt->ExtConfig.NumberOfSCO = 0; - - numOfHandle = pcmd[0]; - //RT_DISP(FIOCTL, IOCTL_BT_HCICMD_EXT, ("numOfHandle = 0x%x\n", numOfHandle)); - //RT_DISP(FIOCTL, IOCTL_BT_HCICMD_EXT, ("HCIExtensionVer = %d\n", pBtMgnt->ExtConfig.HCIExtensionVer)); - DBG_871X("numOfHandle = 0x%x\n", numOfHandle); - DBG_871X("HCIExtensionVer = %d\n", pBtMgnt->ExtConfig.HCIExtensionVer); - - pTriple = &pcmd[1]; - for(i=0; iExtConfig.HCIExtensionVer < 1) - { - conHandle = *((u8 *)&pTriple[0]); - btProfile = pTriple[2]; - btCoreSpec = pTriple[3]; - if(BT_PROFILE_SCO == btProfile) - { - pBtMgnt->ExtConfig.NumberOfSCO++; - } - else - { - pBtMgnt->ExtConfig.NumberOfACL++; - pBtMgnt->ExtConfig.aclLink[i].ConnectHandle = conHandle; - pBtMgnt->ExtConfig.aclLink[i].BTProfile = btProfile; - pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec = btCoreSpec; - } - //RT_DISP(FIOCTL, IOCTL_BT_HCICMD_EXT, - // ("Connection_Handle=0x%x, BTProfile=%d, BTSpec=%d\n", - // conHandle, btProfile, btCoreSpec)); - DBG_871X("Connection_Handle=0x%x, BTProfile=%d, BTSpec=%d\n", conHandle, btProfile, btCoreSpec); - pTriple += 4; - } - else if(pBtMgnt->ExtConfig.HCIExtensionVer >= 1) - { - conHandle = *((pu2Byte)&pTriple[0]); - btProfile = pTriple[2]; - btCoreSpec = pTriple[3]; - linkRole = pTriple[4]; - if(BT_PROFILE_SCO == btProfile) - { - pBtMgnt->ExtConfig.NumberOfSCO++; - } - else - { - pBtMgnt->ExtConfig.NumberOfACL++; - pBtMgnt->ExtConfig.aclLink[i].ConnectHandle = conHandle; - pBtMgnt->ExtConfig.aclLink[i].BTProfile = btProfile; - pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec = btCoreSpec; - pBtMgnt->ExtConfig.aclLink[i].linkRole = linkRole; - } - //RT_DISP(FIOCTL, IOCTL_BT_HCICMD_EXT, - DBG_871X("Connection_Handle=0x%x, BTProfile=%d, BTSpec=%d, LinkRole=%d\n", - conHandle, btProfile, btCoreSpec, linkRole); - pTriple += 5; - } - } - rtw_btcoex_StackUpdateProfileInfo(); - - //send complete event to BT - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_LINK_STATUS_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_LINK_STATUS_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } - - -} - -u8 rtw_btcoex_parse_HCI_BT_coex_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_COEX_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_COEX_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_HCI_BT_operation_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - DBG_871X("%s, OP code: %d\n",__func__,pcmd[0]); - - switch(pcmd[0]) - { - case HCI_BT_OP_NONE: - DBG_871X("[bt operation] : Operation None!!\n"); - break; - case HCI_BT_OP_INQUIRY_START: - DBG_871X("[bt operation] : Inquiry start!!\n"); - break; - case HCI_BT_OP_INQUIRY_FINISH: - DBG_871X("[bt operation] : Inquiry finished!!\n"); - break; - case HCI_BT_OP_PAGING_START: - DBG_871X("[bt operation] : Paging is started!!\n"); - break; - case HCI_BT_OP_PAGING_SUCCESS: - DBG_871X("[bt operation] : Paging complete successfully!!\n"); - break; - case HCI_BT_OP_PAGING_UNSUCCESS: - DBG_871X("[bt operation] : Paging complete unsuccessfully!!\n"); - break; - case HCI_BT_OP_PAIRING_START: - DBG_871X("[bt operation] : Pairing start!!\n"); - break; - case HCI_BT_OP_PAIRING_FINISH: - DBG_871X("[bt operation] : Pairing finished!!\n"); - break; - case HCI_BT_OP_BT_DEV_ENABLE: - DBG_871X("[bt operation] : BT Device is enabled!!\n"); - break; - case HCI_BT_OP_BT_DEV_DISABLE: - DBG_871X("[bt operation] : BT Device is disabled!!\n"); - break; - default: - DBG_871X("[bt operation] : Unknown, error!!\n"); - break; - } - - //send complete event to BT - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_OPERATION_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_OPERATION_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_BT_AFH_MAP_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_AFH_MAP_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_AFH_MAP_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_BT_register_val_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_REGISTER_VALUE_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_REGISTER_VALUE_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_HCI_BT_abnormal_notify_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_BT_ABNORMAL_NOTIFY, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_BT_ABNORMAL_NOTIFY, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -u8 rtw_btcoex_parse_HCI_query_RF_status_cmd(_adapter *padapter, u8 *pcmd, u16 cmdlen) -{ - u8 localBuf[6] = ""; - u8 *pRetPar; - u8 len=0, tx_event_length =0; - rtw_HCI_event *pEvent; - RTW_HCI_STATUS status=HCI_STATUS_SUCCESS; - - { - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - - pEvent->EventCode = HCI_EVENT_COMMAND_COMPLETE; - pEvent->Data[0] = 0x1; //packet # - pEvent->Data[1] = HCIOPCODELOW(HCI_QUERY_RF_STATUS, OGF_EXTENSION); - pEvent->Data[2] = HCIOPCODEHIGHT(HCI_QUERY_RF_STATUS, OGF_EXTENSION); - len = len + 3; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - pRetPar[0] = status; //status - - len++; - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; - - status = rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - return status; - //bthci_IndicateEvent(Adapter, PPacketIrpEvent, len+2); - } -} - -/***************************************** -* HCI cmd format : -*| 15 - 0 | -*| OPcode (OCF|OGF<<10) | -*| 15 - 8 |7 - 0 | -*|Cmd para |Cmd para Length | -*|Cmd para...... | -******************************************/ - -//bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 -// | OCF | OGF | -void rtw_btcoex_parse_hci_extend_cmd(_adapter *padapter, u8 *pcmd, u16 len,const u16 hci_OCF) -{ - - DBG_871X("%s: OCF: %x\n",__func__,hci_OCF); - switch(hci_OCF) - { - case HCI_EXTENSION_VERSION_NOTIFY: - DBG_871X("HCI_EXTENSION_VERSION_NOTIFY\n"); - rtw_btcoex_parse_HCI_Ver_notify_cmd(padapter,pcmd, len); - break; - case HCI_LINK_STATUS_NOTIFY: - DBG_871X("HCI_LINK_STATUS_NOTIFY\n"); - rtw_btcoex_parse_HCI_link_status_notify_cmd(padapter,pcmd, len); - break; - case HCI_BT_OPERATION_NOTIFY: - // only for 8723a 2ant - DBG_871X("HCI_BT_OPERATION_NOTIFY\n"); - rtw_btcoex_parse_HCI_BT_operation_notify_cmd(padapter,pcmd, len); - // - break; - case HCI_ENABLE_WIFI_SCAN_NOTIFY: - DBG_871X("HCI_ENABLE_WIFI_SCAN_NOTIFY\n"); - rtw_btcoex_parse_WIFI_scan_notify_cmd(padapter,pcmd, len); - break; - case HCI_QUERY_RF_STATUS: - // only for 8723b 2ant - DBG_871X("HCI_QUERY_RF_STATUS\n"); - rtw_btcoex_parse_HCI_query_RF_status_cmd(padapter,pcmd, len); - break; - case HCI_BT_ABNORMAL_NOTIFY: - DBG_871X("HCI_BT_ABNORMAL_NOTIFY\n"); - rtw_btcoex_parse_HCI_BT_abnormal_notify_cmd(padapter,pcmd, len); - break; - case HCI_BT_INFO_NOTIFY: - DBG_871X("HCI_BT_INFO_NOTIFY\n"); - rtw_btcoex_parse_BT_info_notify_cmd(padapter,pcmd, len); - break; - case HCI_BT_COEX_NOTIFY: - DBG_871X("HCI_BT_COEX_NOTIFY\n"); - rtw_btcoex_parse_HCI_BT_coex_notify_cmd(padapter,pcmd, len); - break; - case HCI_BT_PATCH_VERSION_NOTIFY: - DBG_871X("HCI_BT_PATCH_VERSION_NOTIFY\n"); - rtw_btcoex_parse_BT_patch_ver_info_cmd(padapter,pcmd, len); - break; - case HCI_BT_AFH_MAP_NOTIFY: - DBG_871X("HCI_BT_AFH_MAP_NOTIFY\n"); - rtw_btcoex_parse_BT_AFH_MAP_notify_cmd(padapter,pcmd, len); - break; - case HCI_BT_REGISTER_VALUE_NOTIFY: - DBG_871X("HCI_BT_REGISTER_VALUE_NOTIFY\n"); - rtw_btcoex_parse_BT_register_val_notify_cmd(padapter,pcmd, len); - break; - default: - DBG_871X("ERROR!!! Unknown OCF: %x\n",hci_OCF); - break; - - } -} - -void rtw_btcoex_parse_hci_cmd(_adapter *padapter, u8 *pcmd, u16 len) -{ - u16 opcode = pcmd[0] | pcmd[1]<<8; - u16 hci_OGF = HCI_OGF(opcode); - u16 hci_OCF = HCI_OCF(opcode); - u8 cmdlen = len -3; - u8 pare_len = pcmd[2]; - - DBG_871X("%s OGF: %x,OCF: %x\n", __func__, hci_OGF, hci_OCF); - switch(hci_OGF) - { - case OGF_EXTENSION: - DBG_871X("HCI_EXTENSION_CMD_OGF\n"); - rtw_btcoex_parse_hci_extend_cmd(padapter, &pcmd[3], cmdlen, hci_OCF); - break; - default: - DBG_871X("Other OGF: %x\n",hci_OGF); - break; - } -} - -u16 rtw_btcoex_parse_recv_data(u8 *msg, u8 msg_size) -{ - u8 cmp_msg1[32] = attend_ack; - u8 cmp_msg2[32] = leave_ack; - u8 cmp_msg3[32] = bt_leave; - u8 cmp_msg4[32] = invite_req; - u8 cmp_msg5[32] = attend_req; - u8 cmp_msg6[32] = invite_rsp; - u8 res = OTHER; - - if (_rtw_memcmp(cmp_msg1, msg, msg_size) == _TRUE) { - /*DBG_871X("%s, msg:%s\n",__func__,msg);*/ - res = RX_ATTEND_ACK; - } else if (_rtw_memcmp(cmp_msg2, msg, msg_size) == _TRUE) { - /*DBG_871X("%s, msg:%s\n",__func__,msg);*/ - res = RX_LEAVE_ACK; - } else if (_rtw_memcmp(cmp_msg3, msg, msg_size) == _TRUE) { - /*DBG_871X("%s, msg:%s\n",__func__,msg);*/ - res = RX_BT_LEAVE; - } else if (_rtw_memcmp(cmp_msg4, msg, msg_size) == _TRUE) { - /*DBG_871X("%s, msg:%s\n",__func__,msg);*/ - res = RX_INVITE_REQ; - } else if (_rtw_memcmp(cmp_msg5, msg, msg_size) == _TRUE) { - res = RX_ATTEND_REQ; - } else if (_rtw_memcmp(cmp_msg6, msg, msg_size) == _TRUE) { - res = RX_INVITE_RSP; - } else { - /*DBG_871X("%s, %s\n", __func__, msg);*/ - res = OTHER; - } - - /*DBG_871X("%s, res:%d\n", __func__, res);*/ - - return res; -} - -void rtw_btcoex_recvmsgbysocket(void *data) -{ - u8 recv_data[255]; - u8 tx_msg[255] = leave_ack; - u32 len = 0; - u16 recv_length = 0; - u16 parse_res = 0; -#if 0 - u8 para_len = 0, polling_enable = 0, poling_interval = 0, reason = 0, btinfo_len = 0; - u8 btinfo[BT_INFO_LEN] = {0}; -#endif - - struct bt_coex_info *pcoex_info = NULL; - struct sock *sk = NULL; - struct sk_buff *skb = NULL; - - /*DBG_871X("%s\n",__func__);*/ - - if (pbtcoexadapter == NULL) { - DBG_871X("%s: btcoexadapter NULL!\n", __func__); - return; - } - - pcoex_info = &pbtcoexadapter->coex_info; - sk = pcoex_info->sk_store; - - if (sk == NULL) { - DBG_871X("%s: critical error when receive socket data!\n", __func__); - return; - } - - len = skb_queue_len(&sk->sk_receive_queue); - while (len > 0) { - skb = skb_dequeue(&sk->sk_receive_queue); - - /*important: cut the udp header from skb->data! header length is 8 byte*/ - recv_length = skb->len-8; - _rtw_memset(recv_data, 0, sizeof(recv_data)); - _rtw_memcpy(recv_data, skb->data+8, recv_length); - - parse_res = rtw_btcoex_parse_recv_data(recv_data, recv_length); -/* - if (RX_ATTEND_ACK == parse_res) { - //attend ack - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_ATTEND_ACK!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - } else if (RX_ATTEND_REQ == parse_res) { - //attend req from BT - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_BT_ATTEND_REQ!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, attend_ack, sizeof(attend_ack), _FALSE); - } else if (RX_INVITE_REQ == parse_res) { - //invite req from BT - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_INVITE_REQ!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, invite_rsp, sizeof(invite_rsp), _FALSE); - } else if (RX_INVITE_RSP == parse_res) { - //invite rsp - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_INVITE_RSP!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - } else if (RX_LEAVE_ACK == parse_res) { - //mean BT know wifi will leave - pcoex_info->BT_attend = _FALSE; - DBG_871X("RX_LEAVE_ACK!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - } else if (RX_BT_LEAVE == parse_res) { - //BT leave - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, leave_ack, sizeof(leave_ack), _FALSE); // no ack - pcoex_info->BT_attend = _FALSE; - DBG_871X("RX_BT_LEAVE!sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - } else { - //todo: check if recv data are really hci cmds - if (_TRUE == pcoex_info->BT_attend) - rtw_btcoex_parse_hci_cmd(pbtcoexadapter, recv_data, recv_length); - } -*/ - switch (parse_res) { - case RX_ATTEND_ACK: - /* attend ack */ - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_ATTEND_ACK!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - case RX_ATTEND_REQ: - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_BT_ATTEND_REQ!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, attend_ack, sizeof(attend_ack), _FALSE); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - case RX_INVITE_REQ: - /* invite req from BT */ - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_INVITE_REQ!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, invite_rsp, sizeof(invite_rsp), _FALSE); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - case RX_INVITE_RSP: - /*invite rsp*/ - pcoex_info->BT_attend = _TRUE; - DBG_871X("RX_INVITE_RSP!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - case RX_LEAVE_ACK: - /* mean BT know wifi will leave */ - pcoex_info->BT_attend = _FALSE; - DBG_871X("RX_LEAVE_ACK!,sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - case RX_BT_LEAVE: - /* BT leave */ - rtw_btcoex_sendmsgbysocket(pbtcoexadapter, leave_ack, sizeof(leave_ack), _FALSE); /* no ack */ - pcoex_info->BT_attend = _FALSE; - DBG_871X("RX_BT_LEAVE!sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, pcoex_info->BT_attend); - break; - - default: - if (_TRUE == pcoex_info->BT_attend) - rtw_btcoex_parse_hci_cmd(pbtcoexadapter, recv_data, recv_length); - else - DBG_871X("ERROR!! BT is UP\n"); - break; - - } - - len--; - kfree_skb(skb); - } -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)) -void rtw_btcoex_recvmsg_init(struct sock *sk_in, s32 bytes) -#else -void rtw_btcoex_recvmsg_init(struct sock *sk_in) -#endif -{ - struct bt_coex_info *pcoex_info = NULL; - - if (pbtcoexadapter == NULL) { - DBG_871X("%s: btcoexadapter NULL\n", __func__); - return; - } - pcoex_info = &pbtcoexadapter->coex_info; - pcoex_info->sk_store = sk_in; - if (pcoex_info->btcoex_wq != NULL) - queue_delayed_work(pcoex_info->btcoex_wq, &pcoex_info->recvmsg_work, 0); - else - DBG_871X("%s: BTCOEX workqueue NULL\n", __func__); -} - -u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool force) -{ - u8 error; - struct msghdr udpmsg; -#ifdef set_fs - mm_segment_t oldfs; -#endif - struct iovec iov; - struct bt_coex_info *pcoex_info = &padapter->coex_info; - - /* DBG_871X("%s: msg:%s, force:%s\n", __func__, msg, force == _TRUE?"TRUE":"FALSE"); */ - if (_FALSE == force) { - if (_FALSE == pcoex_info->BT_attend) { - DBG_871X("TX Blocked: WiFi-BT disconnected\n"); - return _FAIL; - } - } - - iov.iov_base = (void *)msg; - iov.iov_len = msg_size; - udpmsg.msg_name = &pcoex_info->bt_sockaddr; - udpmsg.msg_namelen = sizeof(struct sockaddr_in); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) - /* referece:sock_xmit in kernel code - * WRITE for sock_sendmsg, READ for sock_recvmsg - * third parameter for msg_iovlen - * last parameter for iov_len - */ - iov_iter_init(&udpmsg.msg_iter, WRITE, &iov, 1, msg_size); -#else - udpmsg.msg_iov = &iov; - udpmsg.msg_iovlen = 1; -#endif - udpmsg.msg_control = NULL; - udpmsg.msg_controllen = 0; - udpmsg.msg_flags = MSG_DONTWAIT | MSG_NOSIGNAL; -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); -#endif - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) - error = sock_sendmsg(pcoex_info->udpsock, &udpmsg); -#else - error = sock_sendmsg(pcoex_info->udpsock, &udpmsg, msg_size); -#endif -#ifdef set_fs - set_fs(oldfs); -#endif - if (error < 0) { - DBG_871X("Error when sendimg msg, error:%d\n", error); - return _FAIL; - } else - return _SUCCESS; -} - -u8 rtw_btcoex_create_kernel_socket(_adapter *padapter) -{ - s8 kernel_socket_err; - u8 tx_msg[255] = attend_req; - struct bt_coex_info *pcoex_info = &padapter->coex_info; - s32 sock_reuse = 1; - u8 status = _FAIL; - - DBG_871X("%s CONNECT_PORT %d\n", __func__, CONNECT_PORT); - - if (NULL == pcoex_info) { - DBG_871X("coex_info: NULL\n"); - status = _FAIL; - } - - kernel_socket_err = sock_create(PF_INET, SOCK_DGRAM, 0, &pcoex_info->udpsock); - - if (kernel_socket_err < 0) { - DBG_871X("Error during creation of socket error:%d\n", kernel_socket_err); - status = _FAIL; - } else { - _rtw_memset(&(pcoex_info->wifi_sockaddr), 0, sizeof(pcoex_info->wifi_sockaddr)); - pcoex_info->wifi_sockaddr.sin_family = AF_INET; - pcoex_info->wifi_sockaddr.sin_port = htons(CONNECT_PORT); - pcoex_info->wifi_sockaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - _rtw_memset(&(pcoex_info->bt_sockaddr), 0, sizeof(pcoex_info->bt_sockaddr)); - pcoex_info->bt_sockaddr.sin_family = AF_INET; - pcoex_info->bt_sockaddr.sin_port = htons(CONNECT_PORT_BT); - pcoex_info->bt_sockaddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); - - pcoex_info->sk_store = NULL; - kernel_socket_err = pcoex_info->udpsock->ops->bind(pcoex_info->udpsock, (struct sockaddr *)&pcoex_info->wifi_sockaddr, - sizeof(pcoex_info->wifi_sockaddr)); - if (kernel_socket_err == 0) { - DBG_871X("binding socket success\n"); - pcoex_info->udpsock->sk->sk_data_ready = rtw_btcoex_recvmsg_init; - pcoex_info->sock_open |= KERNEL_SOCKET_OK; - pcoex_info->BT_attend = _FALSE; - DBG_871X("WIFI sending attend_req\n"); - rtw_btcoex_sendmsgbysocket(padapter, attend_req, sizeof(attend_req), _TRUE); - status = _SUCCESS; - } else { - pcoex_info->BT_attend = _FALSE; - sock_release(pcoex_info->udpsock); /* bind fail release socket */ - DBG_871X("Error binding socket: %d\n", kernel_socket_err); - status = _FAIL; - } - - } - - return status; -} - -void rtw_btcoex_close_kernel_socket(_adapter *padapter) -{ - struct bt_coex_info *pcoex_info = &padapter->coex_info; - if (pcoex_info->sock_open & KERNEL_SOCKET_OK) { - DBG_871X("release kernel socket\n"); - sock_release(pcoex_info->udpsock); - pcoex_info->sock_open &= ~(KERNEL_SOCKET_OK); - if (_TRUE == pcoex_info->BT_attend) - pcoex_info->BT_attend = _FALSE; - - DBG_871X("sock_open:%d, BT_attend:%d\n", pcoex_info->sock_open, pcoex_info->BT_attend); - } -} - -void rtw_btcoex_init_socket(_adapter *padapter) -{ - - u8 is_invite = _FALSE; - struct bt_coex_info *pcoex_info = &padapter->coex_info; - DBG_871X("%s\n", __func__); - if (_FALSE == pcoex_info->is_exist) { - _rtw_memset(pcoex_info,0,sizeof(struct bt_coex_info)); - pcoex_info->btcoex_wq = create_workqueue("BTCOEX"); - INIT_DELAYED_WORK(&pcoex_info->recvmsg_work, - (void *)rtw_btcoex_recvmsgbysocket); - pbtcoexadapter = padapter; - /* We expect BT is off if BT don't send ack to wifi */ - DBG_871X("We expect BT is off if BT send ack to wifi\n"); - rtw_btcoex_BTOffOnNotify(pbtcoexadapter, _FALSE); - if (rtw_btcoex_create_kernel_socket(padapter) == _SUCCESS) { - pcoex_info->is_exist = _TRUE; - } else { - pcoex_info->is_exist = _FALSE; - pbtcoexadapter = NULL; - } - - DBG_871X("%s: pbtcoexadapter:%p, coex_info->is_exist: %s\n" - , __func__, pbtcoexadapter, pcoex_info->is_exist == _TRUE?"TRUE":"FALSE"); - } -} - -void rtw_btcoex_close_socket(_adapter *padapter) -{ - struct bt_coex_info *pcoex_info = &padapter->coex_info; - - DBG_871X("%s--coex_info->is_exist: %s, pcoex_info->BT_attend:%s\n" - , __func__, pcoex_info->is_exist == _TRUE?"TRUE":"FALSE", pcoex_info->BT_attend == _TRUE?"TRUE":"FALSE"); - - if (_TRUE == pcoex_info->is_exist) { - if (_TRUE == pcoex_info->BT_attend) { - /*inform BT wifi leave*/ - rtw_btcoex_sendmsgbysocket(padapter, wifi_leave, sizeof(wifi_leave), _FALSE); - msleep(50); - } - rtw_btcoex_close_kernel_socket(padapter); - pbtcoexadapter = NULL; - pcoex_info->is_exist = _FALSE; - } - if (pcoex_info->btcoex_wq != NULL) { - flush_workqueue(pcoex_info->btcoex_wq); - destroy_workqueue(pcoex_info->btcoex_wq); - } -} - -void rtw_btcoex_dump_tx_msg(u8 *tx_msg, u8 len, u8 *msg_name) -{ - u8 i = 0; - DBG_871X("======> Msg name: %s\n", msg_name); - for(i=0;iEventCode = HCI_EVENT_EXTENSION_RTK; - pEvent->Data[0] = HCI_EVENT_EXT_BT_COEX_CONTROL; //extension event code - len ++; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - _rtw_memcpy(&pRetPar[0], pData, dataLen); - - len += dataLen; - - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length, "BT COEX CONTROL", _FALSE); -#endif - rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - -} - -/* Porting from Windows team */ -void rtw_btcoex_SendEventExtBtInfoControl(PADAPTER padapter, u8 dataLen, void *pData) -{ - rtw_HCI_event *pEvent; - u8 *pRetPar; - u8 len=0, tx_event_length = 0; - u8 localBuf[32] = ""; - - struct bt_coex_info *pcoex_info = &padapter->coex_info; - PBT_MGNT pBtMgnt = &pcoex_info->BtMgnt; - - /* DBG_871X("%s\n",__func__);*/ - if(pBtMgnt->ExtConfig.HCIExtensionVer < 4) //not support - { - DBG_871X("ERROR: HCIExtensionVer = %d, HCIExtensionVer<4 !!!!\n",pBtMgnt->ExtConfig.HCIExtensionVer); - return; - } - - pEvent = (rtw_HCI_event *)(&localBuf[0]); - - //len += bthci_ExtensionEventHeaderRtk(&localBuf[0], - // HCI_EVENT_EXT_BT_INFO_CONTROL); - pEvent->EventCode = HCI_EVENT_EXTENSION_RTK; - pEvent->Data[0] = HCI_EVENT_EXT_BT_INFO_CONTROL; //extension event code - len ++; - - // Return parameters starts from here - pRetPar = &pEvent->Data[len]; - _rtw_memcpy(&pRetPar[0], pData, dataLen); - - len += dataLen; - - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length, "BT INFO CONTROL"); -#endif - rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); - -} - -void rtw_btcoex_SendScanNotify(PADAPTER padapter, u8 scanType) -{ - u8 len=0, tx_event_length=0; - u8 localBuf[7] = ""; - u8 *pRetPar; - u8 *pu1Temp; - rtw_HCI_event *pEvent; - struct bt_coex_info *pcoex_info = &padapter->coex_info; - PBT_MGNT pBtMgnt = &pcoex_info->BtMgnt; - -// if(!pBtMgnt->BtOperationOn) -// return; - - pEvent = (rtw_HCI_event *)(&localBuf[0]); - -// len += bthci_ExtensionEventHeaderRtk(&localBuf[0], -// HCI_EVENT_EXT_WIFI_SCAN_NOTIFY); - - pEvent->EventCode = HCI_EVENT_EXTENSION_RTK; - pEvent->Data[0] = HCI_EVENT_EXT_WIFI_SCAN_NOTIFY; //extension event code - len ++; - - // Return parameters starts from here - //pRetPar = &PPacketIrpEvent->Data[len]; - //pu1Temp = (u8 *)&pRetPar[0]; - //*pu1Temp = scanType; - pEvent->Data[len] = scanType; - len += 1; - - pEvent->Length = len; - - //total tx event length + EventCode length + sizeof(length) - tx_event_length = pEvent->Length + 2; -#if 0 - rtw_btcoex_dump_tx_msg((u8 *)pEvent, tx_event_length, "WIFI SCAN OPERATION"); -#endif - rtw_btcoex_sendmsgbysocket(padapter, (u8 *)pEvent, tx_event_length, _FALSE); -} -#endif //CONFIG_BT_COEXIST_SOCKET_TRX -#endif // CONFIG_BT_COEXIST - diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_cmd.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_cmd.c index 1dfb22ced..87672129a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_cmd.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_cmd.c @@ -1287,10 +1287,6 @@ void rtw_getbbrfreg_cmdrsp_callback(_adapter* padapter, struct cmd_obj *pcmd) rtw_mfree((unsigned char*) pcmd->parmbuf, pcmd->cmdsz); rtw_mfree((unsigned char*) pcmd, sizeof(struct cmd_obj)); -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted= _TRUE; -#endif _func_exit_; } @@ -1301,10 +1297,6 @@ void rtw_readtssi_cmdrsp_callback(_adapter* padapter, struct cmd_obj *pcmd) rtw_mfree((unsigned char*) pcmd->parmbuf, pcmd->cmdsz); rtw_mfree((unsigned char*) pcmd, sizeof(struct cmd_obj)); -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted= _TRUE; -#endif _func_exit_; } @@ -2545,12 +2537,6 @@ u8 traffic_status_watchdog(_adapter *padapter, u8 from_timer) RT_LINK_DETECT_T * link_detect = &pmlmepriv->LinkDetectInfo; -#ifdef CONFIG_BT_COEXIST - if (padapter->registrypriv.wifi_spec != 1) { - BusyThresholdHigh = 25; - BusyThresholdLow = 10; - } else -#endif /* CONFIG_BT_COEXIST */ { BusyThresholdHigh = 100; BusyThresholdLow = 75; @@ -2809,14 +2795,6 @@ void dynamic_chk_wk_hdl(_adapter *padapter) //check_hw_pbc(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type); -#ifdef CONFIG_BT_COEXIST - // - // BT-Coexist - // - rtw_btcoex_Handler(padapter); -#endif - - #ifdef CONFIG_IPS_CHECK_IN_WD //always call rtw_ps_processor() at last one. if (is_primary_adapter(padapter)) @@ -2845,9 +2823,6 @@ _func_enter_; { case LPS_CTRL_SCAN: //DBG_871X("LPS_CTRL_SCAN \n"); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_ScanNotify(padapter, _TRUE); -#endif // CONFIG_BT_COEXIST if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { // connect @@ -2864,25 +2839,16 @@ _func_enter_; // Reset LPS Setting pwrpriv->LpsIdleCount = 0; rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_MediaStatusNotify(padapter, mstatus); -#endif // CONFIG_BT_COEXIST break; case LPS_CTRL_DISCONNECT: //DBG_871X("LPS_CTRL_DISCONNECT \n"); mstatus = 0;//disconnect -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_MediaStatusNotify(padapter, mstatus); -#endif // CONFIG_BT_COEXIST LPS_Leave(padapter, "LPS_CTRL_DISCONNECT"); rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); break; case LPS_CTRL_SPECIAL_PACKET: //DBG_871X("LPS_CTRL_SPECIAL_PACKET \n"); pwrpriv->DelayLPSLastTimeStamp = rtw_get_current_time(); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_SpecialPacketNotify(padapter, PACKET_DHCP); -#endif // CONFIG_BT_COEXIST LPS_Leave(padapter, "LPS_CTRL_SPECIAL_PACKET"); break; case LPS_CTRL_LEAVE: @@ -3008,10 +2974,6 @@ void rtw_lps_change_dtim_hdl(_adapter *padapter, u8 dtim) if(dtim <=0 || dtim > 16) return; -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBtControlLps(padapter) == _TRUE) - return; -#endif #ifdef CONFIG_LPS_LCLK _enter_pwrlock(&pwrpriv->lock); @@ -3683,160 +3645,6 @@ apply: #endif /* CONFIG_AP_MODE */ -#ifdef CONFIG_BT_COEXIST -struct btinfo { - u8 cid; - u8 len; - - u8 bConnection:1; - u8 bSCOeSCO:1; - u8 bInQPage:1; - u8 bACLBusy:1; - u8 bSCOBusy:1; - u8 bHID:1; - u8 bA2DP:1; - u8 bFTP:1; - - u8 retry_cnt:4; - u8 rsvd_34:1; - u8 rsvd_35:1; - u8 rsvd_36:1; - u8 rsvd_37:1; - - u8 rssi; - - u8 rsvd_50:1; - u8 rsvd_51:1; - u8 rsvd_52:1; - u8 rsvd_53:1; - u8 rsvd_54:1; - u8 rsvd_55:1; - u8 eSCO_SCO:1; - u8 Master_Slave:1; - - u8 rsvd_6; - u8 rsvd_7; -}; - -void btinfo_evt_dump(void *sel, void *buf) -{ - struct btinfo *info = (struct btinfo *)buf; - - DBG_871X_SEL_NL(sel, "cid:0x%02x, len:%u\n", info->cid, info->len); - - if (info->len > 2) - DBG_871X_SEL_NL(sel, "byte2:%s%s%s%s%s%s%s%s\n" - , info->bConnection?"bConnection ":"" - , info->bSCOeSCO?"bSCOeSCO ":"" - , info->bInQPage?"bInQPage ":"" - , info->bACLBusy?"bACLBusy ":"" - , info->bSCOBusy?"bSCOBusy ":"" - , info->bHID?"bHID ":"" - , info->bA2DP?"bA2DP ":"" - , info->bFTP?"bFTP":"" - ); - - if (info->len > 3) - DBG_871X_SEL_NL(sel, "retry_cnt:%u\n", info->retry_cnt); - - if (info->len > 4) - DBG_871X_SEL_NL(sel, "rssi:%u\n", info->rssi); - - if (info->len > 5) - DBG_871X_SEL_NL(sel, "byte5:%s%s\n" - , info->eSCO_SCO?"eSCO_SCO ":"" - , info->Master_Slave?"Master_Slave ":"" - ); -} - -static void rtw_btinfo_hdl(_adapter *adapter, u8 *buf, u16 buf_len) -{ - #define BTINFO_WIFI_FETCH 0x23 - #define BTINFO_BT_AUTO_RPT 0x27 -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - struct btinfo_8761ATV *info = (struct btinfo_8761ATV *)buf; -#else //!CONFIG_BT_COEXIST_SOCKET_TRX - struct btinfo *info = (struct btinfo *)buf; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - u8 cmd_idx; - u8 len; - - cmd_idx = info->cid; - - if (info->len > buf_len-2) { - rtw_warn_on(1); - len = buf_len-2; - } else { - len = info->len; - } - -//#define DBG_PROC_SET_BTINFO_EVT -#ifdef DBG_PROC_SET_BTINFO_EVT -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - DBG_871X("%s: btinfo[0]=%x,btinfo[1]=%x,btinfo[2]=%x,btinfo[3]=%x btinfo[4]=%x,btinfo[5]=%x,btinfo[6]=%x,btinfo[7]=%x\n" - , __func__, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7]); -#else//!CONFIG_BT_COEXIST_SOCKET_TRX - btinfo_evt_dump(RTW_DBGDUMP, info); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX -#endif // DBG_PROC_SET_BTINFO_EVT - - /* transform BT-FW btinfo to WiFI-FW C2H format and notify */ - if (cmd_idx == BTINFO_WIFI_FETCH) - buf[1] = 0; - else if (cmd_idx == BTINFO_BT_AUTO_RPT) - buf[1] = 2; -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - else if(0x01 == cmd_idx || 0x02 == cmd_idx) - buf[1] = buf[0]; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - rtw_btcoex_BtInfoNotify(adapter ,len+1, &buf[1]); -} - -u8 rtw_btinfo_cmd(_adapter *adapter, u8 *buf, u16 len) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - u8 *btinfo; - struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = (struct cmd_obj*)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = (struct drvextra_cmd_parm*)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { - rtw_mfree((u8*)ph2c, sizeof(struct cmd_obj)); - res = _FAIL; - goto exit; - } - - btinfo = rtw_zmalloc(len); - if (btinfo == NULL) { - rtw_mfree((u8*)ph2c, sizeof(struct cmd_obj)); - rtw_mfree((u8*)pdrvextra_cmd_parm, sizeof(struct drvextra_cmd_parm)); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = BTINFO_WK_CID; - pdrvextra_cmd_parm->type = 0; - pdrvextra_cmd_parm->size = len; - pdrvextra_cmd_parm->pbuf = btinfo; - - _rtw_memcpy(btinfo, buf, len); - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - return res; -} -#endif //CONFIG_BT_COEXIST - //#ifdef CONFIG_C2H_PACKET_EN u8 rtw_c2h_packet_wk_cmd(PADAPTER padapter, u8 *pbuf, u16 length) { @@ -3881,149 +3689,6 @@ exit: return res; } -static s32 rtw_mp_cmd_hdl(_adapter *padapter, u8 mp_cmd_id) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - int ret = H2C_SUCCESS; - u8 rfreg0; - - if (mp_cmd_id == MP_START) { - if (padapter->registrypriv.mp_mode == 0) { - rtw_hal_deinit(padapter); - padapter->registrypriv.mp_mode = 1; -#ifdef CONFIG_RF_POWER_TRIM - if (!IS_HARDWARE_TYPE_8814A(padapter) && !IS_HARDWARE_TYPE_8822B(padapter)) { - padapter->registrypriv.RegPwrTrimEnable = 1; - rtw_hal_read_chip_info(padapter); - } -#endif /*CONFIG_RF_POWER_TRIM*/ - rtw_hal_init(padapter); - } - - if (padapter->registrypriv.mp_mode == 0) { - ret = H2C_REJECTED; - goto exit; - } - - if (padapter->mppriv.mode == MP_OFF) { - if (mp_start_test(padapter) == _FAIL) { - ret = H2C_REJECTED; - goto exit; - } - padapter->mppriv.mode = MP_ON; - MPT_PwrCtlDM(padapter, 0); - } - padapter->mppriv.bmac_filter = _FALSE; -#ifdef CONFIG_RTL8723B -#ifdef CONFIG_USB_HCI - rtw_write32(padapter, 0x765, 0x0000); - rtw_write32(padapter, 0x948, 0x0280); -#else - rtw_write32(padapter, 0x765, 0x0000); - rtw_write32(padapter, 0x948, 0x0000); -#endif -#ifdef CONFIG_FOR_RTL8723BS_VQ0 - rtw_write32(padapter, 0x765, 0x0000); - rtw_write32(padapter, 0x948, 0x0280); -#endif - rtw_write8(padapter, 0x66, 0x27); /*Open BT uart Log*/ - rtw_write8(padapter, 0xc50, 0x20); /*for RX init Gain*/ -#endif - ODM_Write_DIG(&pHalData->odmpriv, 0x20); - -#ifdef CONFIG_RTL8188F - DBG_871X("Set reg 0x88c, 0x58, 0x00\n"); - rfreg0 = PHY_QueryRFReg(padapter, RF_PATH_A, 0x0, 0x1f); - PHY_SetBBReg(padapter, 0x88c, BIT21|BIT20, 0x3); - PHY_SetRFReg(padapter, RF_PATH_A, 0x58, BIT1, 0x1); - PHY_SetRFReg(padapter, RF_PATH_A, 0x0, 0xF001f, 0x2001f); - rtw_msleep_os(200); - PHY_SetRFReg(padapter, RF_PATH_A, 0x0, 0xF001f, 0x30000 | rfreg0); - PHY_SetRFReg(padapter, RF_PATH_A, 0x58, BIT1, 0x0); - PHY_SetBBReg(padapter, 0x88c, BIT21|BIT20, 0x0); - rtw_msleep_os(1000); -#endif - - } else if (mp_cmd_id == MP_STOP) { - if (padapter->registrypriv.mp_mode == 1) { - MPT_DeInitAdapter(padapter); - rtw_hal_deinit(padapter); - padapter->registrypriv.mp_mode = 0; - rtw_hal_init(padapter); - } - - if (padapter->mppriv.mode != MP_OFF) { - mp_stop_test(padapter); - padapter->mppriv.mode = MP_OFF; - } - - } else { - DBG_871X(FUNC_ADPT_FMT"invalid id:%d\n", FUNC_ADPT_ARG(padapter), mp_cmd_id); - ret = H2C_PARAMETERS_ERROR; - rtw_warn_on(1); - } - -exit: - return ret; -} - -u8 rtw_mp_cmd(_adapter *adapter, u8 mp_cmd_id, u8 flags) -{ - struct cmd_obj *cmdobj; - struct drvextra_cmd_parm *parm; - struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - struct submit_ctx sctx; - u8 res = _SUCCESS; - - parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (parm == NULL) { - res = _FAIL; - goto exit; - } - - parm->ec_id = MP_CMD_WK_CID; - parm->type = mp_cmd_id; - parm->size = 0; - parm->pbuf = NULL; - - if (flags & RTW_CMDF_DIRECTLY) { - /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (H2C_SUCCESS != rtw_mp_cmd_hdl(adapter, mp_cmd_id)) - res = _FAIL; - rtw_mfree((u8 *)parm, sizeof(*parm)); - } else { - /* need enqueue, prepare cmd_obj and enqueue */ - cmdobj = (struct cmd_obj *)rtw_zmalloc(sizeof(*cmdobj)); - if (cmdobj == NULL) { - res = _FAIL; - rtw_mfree((u8 *)parm, sizeof(*parm)); - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(cmdobj, parm, GEN_CMD_CODE(_Set_Drv_Extra)); - - if (flags & RTW_CMDF_WAIT_ACK) { - cmdobj->sctx = &sctx; - rtw_sctx_init(&sctx, 10 * 1000); - } - - res = rtw_enqueue_cmd(pcmdpriv, cmdobj); - - if (res == _SUCCESS && (flags & RTW_CMDF_WAIT_ACK)) { - rtw_sctx_wait(&sctx, __func__); - _enter_critical_mutex(&pcmdpriv->sctx_mutex, NULL); - if (sctx.status == RTW_SCTX_SUBMITTED) - cmdobj->sctx = NULL; - _exit_critical_mutex(&pcmdpriv->sctx_mutex, NULL); - if (sctx.status != RTW_SCTX_DONE_SUCCESS) - res = _FAIL; - } - } - -exit: - return res; -} - #ifdef CONFIG_RTW_CUSTOMER_STR static s32 rtw_customer_str_cmd_hdl(_adapter *adapter, u8 write, const u8 *cstr) { @@ -4630,11 +4295,6 @@ u8 rtw_drvextra_cmd_hdl(_adapter *padapter, unsigned char *pbuf) case DM_RA_MSK_WK_CID: rtw_dm_ra_mask_hdl(padapter, (struct sta_info *)pdrvextra_cmd->pbuf); break; -#ifdef CONFIG_BT_COEXIST - case BTINFO_WK_CID: - rtw_btinfo_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->size); - break; -#endif #ifdef CONFIG_DFS_MASTER case DFS_MASTER_WK_CID: rtw_dfs_master_hdl(padapter); @@ -4648,15 +4308,6 @@ u8 rtw_drvextra_cmd_hdl(_adapter *padapter, unsigned char *pbuf) rtw_hal_set_hwreg(padapter, HW_VAR_EN_HW_UPDATE_TSF, NULL); break; - case MP_CMD_WK_CID: - ret = rtw_mp_cmd_hdl(padapter, pdrvextra_cmd->type); - break; -#ifdef CONFIG_RTW_CUSTOMER_STR - case CUSTOMER_STR_WK_CID: - ret = rtw_customer_str_cmd_hdl(padapter, pdrvextra_cmd->type, pdrvextra_cmd->pbuf); - break; -#endif - default: break; } @@ -4877,10 +4528,6 @@ void rtw_getrttbl_cmd_cmdrsp_callback(_adapter* padapter, struct cmd_obj *pcmd) _func_enter_; rtw_free_cmd_obj(pcmd); -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.workparam.bcompleted=_TRUE; -#endif _func_exit_; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_debug.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_debug.c index b7d8b18fb..b32585df2 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_debug.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_debug.c @@ -100,19 +100,6 @@ void dump_drv_cfg(void *sel) DBG_871X_SEL_NL(sel, "CONFIG_POWER_SAVING\n"); #endif -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - DBG_871X_SEL_NL(sel, "LOAD_PHY_PARA_FROM_FILE - REALTEK_CONFIG_PATH=%s\n", REALTEK_CONFIG_PATH); - #if defined(CONFIG_MULTIDRV) || defined(REALTEK_CONFIG_PATH_WITH_IC_NAME_FOLDER) - DBG_871X_SEL_NL(sel, "LOAD_PHY_PARA_FROM_FILE - REALTEK_CONFIG_PATH_WITH_IC_NAME_FOLDER\n"); - #endif - #ifdef CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY - DBG_871X_SEL_NL(sel, "CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY\n"); - #endif - #ifdef CONFIG_CALIBRATE_TX_POWER_TO_MAX - DBG_871X_SEL_NL(sel, "CONFIG_CALIBRATE_TX_POWER_TO_MAX\n"); - #endif -#endif - #ifdef CONFIG_DISABLE_ODM DBG_871X_SEL_NL(sel, "CONFIG_DISABLE_ODM\n"); #endif @@ -131,12 +118,6 @@ void dump_drv_cfg(void *sel) #endif #ifdef CONFIG_USB_HCI - #ifdef CONFIG_SUPPORT_USB_INT - DBG_871X_SEL_NL(sel, "CONFIG_SUPPORT_USB_INT\n"); - #endif - #ifdef CONFIG_USB_INTERRUPT_IN_PIPE - DBG_871X_SEL_NL(sel, "CONFIG_USB_INTERRUPT_IN_PIPE\n"); - #endif #ifdef CONFIG_USB_TX_AGGREGATION DBG_871X_SEL_NL(sel, "CONFIG_USB_TX_AGGREGATION\n"); #endif @@ -1111,16 +1092,6 @@ ssize_t proc_set_survey_info(struct file *file, const char __user *buffer, size_ if (count < 1) return -EFAULT; -#ifdef CONFIG_MP_INCLUDED - if ((padapter->registrypriv.mp_mode == 1) -#ifdef CONFIG_CONCURRENT_MODE - || ((padapter->pbuddy_adapter) && (padapter->pbuddy_adapter->registrypriv.mp_mode == 1)) -#endif - ){ - DBG_871X(FUNC_ADPT_FMT ": MP mode block Scan request\n", FUNC_ADPT_ARG(padapter)); - goto exit; - } -#endif rtw_ps_deny(padapter, PS_DENY_SCAN); if (_FAIL == rtw_pwr_wakeup(padapter)) goto exit; @@ -2662,109 +2633,6 @@ ssize_t proc_set_best_channel(struct file *file, const char __user *buffer, size } #endif /* CONFIG_FIND_BEST_CHANNEL */ -#ifdef CONFIG_BT_COEXIST -int proc_get_btcoex_dbg(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - PADAPTER padapter; - char buf[512] = {0}; - padapter = (PADAPTER)rtw_netdev_priv(dev); - - rtw_btcoex_GetDBG(padapter, buf, 512); - - DBG_871X_SEL(m, "%s", buf); - - return 0; -} - -ssize_t proc_set_btcoex_dbg(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - PADAPTER padapter; - u8 tmp[80] = {0}; - u32 module[2] = {0}; - u32 num; - - padapter = (PADAPTER)rtw_netdev_priv(dev); - -// DBG_871X("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); - - if (NULL == buffer) - { - DBG_871X(FUNC_ADPT_FMT ": input buffer is NULL!\n", - FUNC_ADPT_ARG(padapter)); - - return -EFAULT; - } - - if (count < 1) - { - DBG_871X(FUNC_ADPT_FMT ": input length is 0!\n", - FUNC_ADPT_ARG(padapter)); - - return -EFAULT; - } - - num = count; - if (num > (sizeof(tmp) - 1)) - num = (sizeof(tmp) - 1); - - if (copy_from_user(tmp, buffer, num)) - { - DBG_871X(FUNC_ADPT_FMT ": copy buffer from user space FAIL!\n", - FUNC_ADPT_ARG(padapter)); - - return -EFAULT; - } - - num = sscanf(tmp, "%x %x", module, module+1); - if (1 == num) - { - if (0 == module[0]) - _rtw_memset(module, 0, sizeof(module)); - else - _rtw_memset(module, 0xFF, sizeof(module)); - } - else if (2 != num) - { - DBG_871X(FUNC_ADPT_FMT ": input(\"%s\") format incorrect!\n", - FUNC_ADPT_ARG(padapter), tmp); - - if (0 == num) - return -EFAULT; - } - - DBG_871X(FUNC_ADPT_FMT ": input 0x%08X 0x%08X\n", - FUNC_ADPT_ARG(padapter), module[0], module[1]); - rtw_btcoex_SetDBG(padapter, module); - - return count; -} - -int proc_get_btcoex_info(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - PADAPTER padapter; - const u32 bufsize = 30*100; - u8 *pbuf = NULL; - - padapter = (PADAPTER)rtw_netdev_priv(dev); - - pbuf = rtw_zmalloc(bufsize); - if (NULL == pbuf) { - return -ENOMEM; - } - - rtw_btcoex_DisplayBtCoexInfo(padapter, pbuf, bufsize); - - DBG_871X_SEL(m, "%s\n", pbuf); - - rtw_mfree(pbuf, bufsize); - - return 0; -} -#endif /* CONFIG_BT_COEXIST */ - #if defined(DBG_CONFIG_ERROR_DETECT) int proc_get_sreset(struct seq_file *m, void *v) { diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ieee80211.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ieee80211.c index ded4e1629..893be78fb 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ieee80211.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ieee80211.c @@ -1406,9 +1406,7 @@ int rtw_get_mac_addr_intel(unsigned char *buf) int ret = 0; int i; struct file *fp = NULL; -#ifdef set_fs - mm_segment_t oldfs; -#endif + mm_segment_t oldfs; unsigned char c_mac[MAC_ADDRESS_LEN]; char fname[]="/config/wifi/mac.txt"; int jj,kk; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ioctl_set.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ioctl_set.c index 25b168762..8bddff996 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ioctl_set.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_ioctl_set.c @@ -1356,14 +1356,6 @@ u16 rtw_get_cur_max_rate(_adapter *adapter) u8 rf_type = 0; #endif -#ifdef CONFIG_MP_INCLUDED - if (adapter->registrypriv.mp_mode == 1) - { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == _TRUE) - return 0; - } -#endif - if((check_fwstate(pmlmepriv, _FW_LINKED) != _TRUE) && (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != _TRUE)) return 0; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme.c index 2e48bcf9c..66f721524 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme.c @@ -3050,18 +3050,8 @@ void rtw_dynamic_check_timer_handlder(_adapter *adapter) return; } -#ifdef CONFIG_BT_COEXIST - if (is_primary_adapter(adapter)) { - if (GET_HAL_DATA(adapter)->EEPROMBluetoothCoexist == 1) - DBG_871X("IsBtDisabled=%d, IsBtControlLps=%d\n" , rtw_btcoex_IsBtDisabled(adapter) , rtw_btcoex_IsBtControlLps(adapter)); - } -#endif - #ifdef CONFIG_LPS_LCLK_WD_TIMER /* to avoid leaving lps 32k frequently*/ if ((adapter_to_pwrctl(adapter)->bFwCurrentInPSMode ==_TRUE ) -#ifdef CONFIG_BT_COEXIST - && (rtw_btcoex_IsBtControlLps(adapter) == _FALSE) -#endif ) { u8 bEnterPS; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme_ext.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme_ext.c index c8b488729..fdbebc324 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme_ext.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mlme_ext.c @@ -1188,7 +1188,9 @@ void mgt_dispatcher(_adapter *padapter, union recv_frame *precv_frame) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; +#if defined(fallthrough) fallthrough; +#endif case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: _mgt_dispatcher(padapter, ptable, precv_frame); @@ -3339,13 +3341,6 @@ u8 rtw_rx_ampdu_size(_adapter *adapter) goto exit; } -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBTCoexCtrlAMPDUSize(adapter) == _TRUE) { - size = rtw_btcoex_GetAMPDUSize(adapter); - goto exit; - } -#endif - /* for scan */ if (!mlmeext_chk_scan_state(&adapter->mlmeextpriv, SCAN_DISABLE) && !mlmeext_chk_scan_state(&adapter->mlmeextpriv, SCAN_COMPLETE) @@ -3395,13 +3390,6 @@ bool rtw_rx_ampdu_is_accept(_adapter *adapter) goto exit; } -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBTCoexRejectAMPDU(adapter) == _TRUE) { - accept = _FALSE; - goto exit; - } -#endif - /* for scan */ if (!mlmeext_chk_scan_state(&adapter->mlmeextpriv, SCAN_DISABLE) && !mlmeext_chk_scan_state(&adapter->mlmeextpriv, SCAN_COMPLETE) @@ -13007,15 +12995,6 @@ u8 setopmode_hdl(_adapter *padapter, u8 *pbuf) } } -#ifdef CONFIG_BT_COEXIST - if (psetop->mode == Ndis802_11APMode) - { - // Do this after port switch to - // prevent from downloading rsvd page to wrong port - rtw_btcoex_MediaStatusNotify(padapter, 1); //connect - } -#endif // CONFIG_BT_COEXIST - return H2C_SUCCESS; } @@ -14724,10 +14703,7 @@ u8 chk_bmc_sleepq_hdl(_adapter *padapter, unsigned char *pbuf) //_exit_critical_bh(&psta_bmc->sleep_q.lock, &irqL); _exit_critical_bh(&pxmitpriv->lock, &irqL); - if (rtw_get_intf_type(padapter) != RTW_PCIE) { - /* check hi queue and bmc_sleepq */ rtw_chk_hi_queue_cmd(padapter); - } } #endif @@ -15274,8 +15250,7 @@ u8 set_chplan_hdl(_adapter *padapter, unsigned char *pbuf) rtw_hal_set_odm_var(padapter,HAL_ODM_REGULATION,NULL,_TRUE); #ifdef CONFIG_IOCTL_CFG80211 - if (padapter->rtw_wdev != NULL) - rtw_reg_notify_by_driver(padapter->rtw_wdev->wiphy); + rtw_reg_notify_by_driver(padapter); #endif //CONFIG_IOCTL_CFG80211 return H2C_SUCCESS; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp.c index e1a91cf8b..818bf67a1 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp.c @@ -682,9 +682,6 @@ static void disable_dm(PADAPTER padapter) pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = _FALSE; rtw_phydm_func_set(padapter, ODM_RF_CALIBRATION); -//#ifdef CONFIG_BT_COEXIST -// rtw_btcoex_Switch(padapter, 0); //remove for BT MP Down. -//#endif } @@ -839,122 +836,7 @@ end_of_mp_start_test: return res; } -//This function initializes the DUT to the MP test mode -s32 mp_start_test(PADAPTER padapter) -{ - struct mp_priv *pmppriv = &padapter->mppriv; - s32 res = _SUCCESS; - padapter->registrypriv.mp_mode = 1; - - //3 disable dynamic mechanism - disable_dm(padapter); - #ifdef CONFIG_RTL8814A - rtl8814_InitHalDm(padapter); - #endif /* CONFIG_RTL8814A */ - #ifdef CONFIG_RTL8812A - rtl8812_InitHalDm(padapter); - #endif /* CONFIG_RTL8812A */ - #ifdef CONFIG_RTL8723B - rtl8723b_InitHalDm(padapter); - #endif /* CONFIG_RTL8723B */ - #ifdef CONFIG_RTL8703B - rtl8703b_InitHalDm(padapter); - #endif /* CONFIG_RTL8703B */ - #ifdef CONFIG_RTL8192E - rtl8192e_InitHalDm(padapter); - #endif - #ifdef CONFIG_RTL8188F - rtl8188f_InitHalDm(padapter); - #endif - - //3 0. update mp_priv - - if (padapter->registrypriv.rf_config == RF_MAX_TYPE) { -// switch (phal->rf_type) { - switch (GET_RF_TYPE(padapter)) { - case RF_1T1R: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_A; - break; - case RF_1T2R: - default: - pmppriv->antenna_tx = ANTENNA_A; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T2R: - case RF_2T2R_GREEN: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_AB; - break; - case RF_2T4R: - pmppriv->antenna_tx = ANTENNA_AB; - pmppriv->antenna_rx = ANTENNA_ABCD; - break; - } - } - - mpt_ProStartTest(padapter); - - mp_join(padapter,WIFI_FW_ADHOC_STATE); - - return res; -} -//------------------------------------------------------------------------------ -//This function change the DUT from the MP test mode into normal mode -void mp_stop_test(PADAPTER padapter) -{ - struct mp_priv *pmppriv = &padapter->mppriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - struct sta_info *psta; - - _irqL irqL; - - if(pmppriv->mode==MP_ON) - { - pmppriv->bSetTxPower=0; - _enter_critical_bh(&pmlmepriv->lock, &irqL); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == _FALSE) - goto end_of_mp_stop_test; - - //3 1. disconnect psudo AdHoc - rtw_indicate_disconnect(padapter, 0, _FALSE); - - //3 2. clear psta used in mp test mode. -// rtw_free_assoc_resources(padapter, 1); - psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); - if (psta) rtw_free_stainfo(padapter, psta); - - //3 3. return to normal state (default:station mode) - pmlmepriv->fw_state = pmppriv->prev_fw_state; // WIFI_STATION_STATE; - - //flush the cur_network - _rtw_memset(tgt_network, 0, sizeof(struct wlan_network)); - - _clr_fwstate_(pmlmepriv, WIFI_MP_STATE); - -end_of_mp_stop_test: - - _exit_critical_bh(&pmlmepriv->lock, &irqL); - - #ifdef CONFIG_RTL8812A - rtl8812_InitHalDm(padapter); - #endif - #ifdef CONFIG_RTL8723B - rtl8723b_InitHalDm(padapter); - #endif - #ifdef CONFIG_RTL8703B - rtl8703b_InitHalDm(padapter); - #endif - #ifdef CONFIG_RTL8192E - rtl8192e_InitHalDm(padapter); - #endif - #ifdef CONFIG_RTL8188F - rtl8188f_InitHalDm(padapter); - #endif - } -} /*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ #if 0 //#ifdef CONFIG_USB_HCI diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp_ioctl.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp_ioctl.c index ff0c66b38..18562b31a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp_ioctl.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_mp_ioctl.c @@ -282,8 +282,7 @@ _func_enter_; RT_TRACE(_module_mp_, _drv_notice_, ("+oid_rt_pro_start_test_hdl\n")); - if (Adapter->registrypriv.mp_mode == 0) - return NDIS_STATUS_NOT_ACCEPTED; + return NDIS_STATUS_NOT_ACCEPTED; if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -326,7 +325,6 @@ _func_enter_; return NDIS_STATUS_NOT_ACCEPTED; _irqlevel_changed_(&oldirql, LOWER); - mp_stop_test(Adapter); _irqlevel_changed_(&oldirql, RAISE); RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_pwrctrl.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_pwrctrl.c index e6715afae..a0b1bea88 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_pwrctrl.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_pwrctrl.c @@ -104,10 +104,6 @@ void ips_enter(_adapter * padapter) struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); -#endif // CONFIG_BT_COEXIST - _enter_pwrlock(&pwrpriv->lock); _ips_enter(padapter); _exit_pwrlock(&pwrpriv->lock); @@ -164,11 +160,6 @@ int ips_leave(_adapter * padapter) if (_SUCCESS == ret) ODM_DMReset(&GET_HAL_DATA(padapter)->odmpriv); -#ifdef CONFIG_BT_COEXIST - if (_SUCCESS == ret) - rtw_btcoex_IpsNotify(padapter, IPS_NONE); -#endif // CONFIG_BT_COEXIST - return ret; } #endif /* CONFIG_IPS */ @@ -252,11 +243,6 @@ bool rtw_pwr_unassociated_idle(_adapter *adapter) } } -#if (MP_DRIVER == 1) - if (adapter->registrypriv.mp_mode == 1) - goto exit; -#endif - #ifdef CONFIG_INTEL_PROXIM if(adapter->proximity.proxim_on==_TRUE){ return; @@ -380,10 +366,7 @@ void rtw_ps_processor(_adapter*padapter) if((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4)==0)) { DBG_871X("==>%s .fw_state(%x)\n",__FUNCTION__,get_fwstate(pmlmepriv)); - #if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - #else pwrpriv->change_rfpwrstate = rf_off; - #endif #ifdef CONFIG_AUTOSUSPEND if(padapter->registrypriv.usbss_enable) { @@ -393,17 +376,7 @@ void rtw_ps_processor(_adapter*padapter) if(padapter->net_closed == _TRUE) pwrpriv->ps_flag = _TRUE; - #if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - if (_TRUE==pwrpriv->bInternalAutoSuspend) { - DBG_871X("<==%s .pwrpriv->bInternalAutoSuspend)(%x)\n",__FUNCTION__,pwrpriv->bInternalAutoSuspend); - } else { - pwrpriv->change_rfpwrstate = rf_off; - DBG_871X("<==%s .pwrpriv->bInternalAutoSuspend)(%x) call autosuspend_enter\n",__FUNCTION__,pwrpriv->bInternalAutoSuspend); - autosuspend_enter(padapter); - } - #else autosuspend_enter(padapter); - #endif //if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) } else if(pwrpriv->bHWPwrPindetect) { @@ -411,10 +384,6 @@ void rtw_ps_processor(_adapter*padapter) else #endif //CONFIG_AUTOSUSPEND { - #if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - pwrpriv->change_rfpwrstate = rf_off; - #endif //defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - #ifdef CONFIG_IPS ips_enter(padapter); #endif @@ -459,9 +428,6 @@ void traffic_check_for_leave_lps(PADAPTER padapter, u8 tx, u32 tx_packets) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) -#ifdef CONFIG_BT_COEXIST - && (rtw_btcoex_IsBtControlLps(padapter) == _FALSE) -#endif ) { //DBG_871X("leave lps via Tx = %d\n", xmit_cnt); @@ -480,9 +446,6 @@ void traffic_check_for_leave_lps(PADAPTER padapter, u8 tx, u32 tx_packets) { if ((adapter_to_pwrctl(padapter)->bLeisurePs) && (adapter_to_pwrctl(padapter)->pwr_mode != PS_MODE_ACTIVE) -#ifdef CONFIG_BT_COEXIST - && (rtw_btcoex_IsBtControlLps(padapter) == _FALSE) -#endif ) { //DBG_871X("leave lps via Rx = %d\n", pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod); @@ -724,9 +687,6 @@ void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable) //u8 cmd_param; //BIT0:enable, BIT1:NoConnect32k if (enable) { -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IpsNotify(padapter, pwrpriv->ips_mode_req); -#endif //Enter IPS DBG_871X("%s: issue H2C to FW when entering IPS\n", __func__); @@ -817,9 +777,6 @@ void rtw_set_fw_in_ips_mode(PADAPTER padapter, u8 enable) parm[2] = 0x0; rtw_hal_fill_h2c_cmd(padapter, H2C_INACTIVE_PS_, H2C_INACTIVE_PS_LEN, parm); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IpsNotify(padapter, IPS_NONE); -#endif } } #endif //CONFIG_PNO_SUPPORT @@ -855,13 +812,11 @@ _func_enter_; { if (PS_MODE_ACTIVE == ps_mode) return; -#ifndef CONFIG_BT_COEXIST if ((pwrpriv->smart_ps == smart_ps) && (pwrpriv->bcn_ant_mode == bcn_ant_mode)) { return; } -#endif // !CONFIG_BT_COEXIST } #ifdef CONFIG_LPS_LCLK @@ -872,20 +827,9 @@ _func_enter_; if(ps_mode == PS_MODE_ACTIVE) { if (1 -#ifdef CONFIG_BT_COEXIST - && (((rtw_btcoex_IsBtControlLps(padapter) == _FALSE) -#ifdef CONFIG_P2P_PS - && (pwdinfo->opp_ps == 0) -#endif // CONFIG_P2P_PS - ) - || ((rtw_btcoex_IsBtControlLps(padapter) == _TRUE) - && (rtw_btcoex_IsLpsOn(padapter) == _FALSE)) - ) -#else // !CONFIG_BT_COEXIST #ifdef CONFIG_P2P_PS && (pwdinfo->opp_ps == 0) #endif // CONFIG_P2P_PS -#endif // !CONFIG_BT_COEXIST ) { DBG_871X(FUNC_ADPT_FMT" Leave 802.11 power save - %s\n", @@ -918,18 +862,11 @@ _func_enter_; rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); pwrpriv->bFwCurrentInPSMode = _FALSE; -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_LpsNotify(padapter, ps_mode); -#endif // CONFIG_BT_COEXIST } } else { if ((PS_RDY_CHECK(padapter) && check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE)) -#ifdef CONFIG_BT_COEXIST - || ((rtw_btcoex_IsBtControlLps(padapter) == _TRUE) - && (rtw_btcoex_IsLpsOn(padapter) == _TRUE)) -#endif ) { u8 pslv; @@ -958,10 +895,6 @@ _func_enter_; } #endif //CONFIG_TDLS -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_LpsNotify(padapter, ps_mode); -#endif // CONFIG_BT_COEXIST - pwrpriv->bFwCurrentInPSMode = _TRUE; pwrpriv->pwr_mode = ps_mode; pwrpriv->smart_ps = smart_ps; @@ -980,19 +913,6 @@ _func_enter_; pslv = PS_STATE_S0; #endif // CONFIG_LPS_LCLK -#ifdef CONFIG_BT_COEXIST - if ((rtw_btcoex_IsBtDisabled(padapter) == _FALSE) - && (rtw_btcoex_IsBtControlLps(padapter) == _TRUE)) - { - u8 val8; - - val8 = rtw_btcoex_LpsVal(padapter); - if (val8 & BIT(4)) - pslv = PS_STATE_S2; - - } -#endif // CONFIG_BT_COEXIST - rtw_set_rpwm(padapter, pslv); } } @@ -1060,11 +980,6 @@ _func_enter_; // DBG_871X("+LeisurePSEnter\n"); -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBtControlLps(padapter) == _TRUE) - return; -#endif - /* Skip lps enter request if number of assocated adapters is not 1 */ for (i = 0; i < dvobj->iface_nums; i++) { if (check_fwstate(&(dvobj->padapters[i]->mlmepriv), WIFI_ASOC_STATE)) @@ -1129,10 +1044,6 @@ _func_enter_; // DBG_871X("+LeisurePSLeave\n"); -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBtControlLps(padapter) == _TRUE) - return; -#endif if (pwrpriv->bLeisurePs) { @@ -1650,19 +1561,6 @@ _func_enter_; pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; -#ifdef CONFIG_BT_COEXIST - if ((rtw_btcoex_IsBtDisabled(padapter) == _FALSE) - && (rtw_btcoex_IsBtControlLps(padapter) == _TRUE)) - { - u8 val8; - - val8 = rtw_btcoex_LpsVal(padapter); - if (val8 & BIT(4)) - pslv = PS_STATE_S2; - - } -#endif // CONFIG_BT_COEXIST - _enter_pwrlock(&pwrctrl->lock); unregister_task_alive(pwrctrl, task); @@ -1883,19 +1781,6 @@ _func_enter_; pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; -#ifdef CONFIG_BT_COEXIST - if ((rtw_btcoex_IsBtDisabled(padapter) == _FALSE) - && (rtw_btcoex_IsBtControlLps(padapter) == _TRUE)) - { - u8 val8; - - val8 = rtw_btcoex_LpsVal(padapter); - if (val8 & BIT(4)) - pslv = PS_STATE_S2; - - } -#endif // CONFIG_BT_COEXIST - #ifdef CONFIG_P2P_PS if(padapter->wdinfo.p2p_ps_mode > P2P_PS_NONE) { @@ -1950,19 +1835,6 @@ _func_enter_; pwrctrl = adapter_to_pwrctl(padapter); pslv = PS_STATE_S0; -#ifdef CONFIG_BT_COEXIST - if ((rtw_btcoex_IsBtDisabled(padapter) == _FALSE) - && (rtw_btcoex_IsBtControlLps(padapter) == _TRUE)) - { - u8 val8; - - val8 = rtw_btcoex_LpsVal(padapter); - if (val8 & BIT(4)) - pslv = PS_STATE_S2; - - } -#endif // CONFIG_BT_COEXIST - #ifdef CONFIG_P2P_PS if(padapter->wdinfo.p2p_ps_mode > P2P_PS_NONE) { @@ -2091,10 +1963,7 @@ _func_enter_; pwrctrlpriv->LpsIdleCount = 0; //pwrctrlpriv->FWCtrlPSMode =padapter->registrypriv.power_mgnt;// PS_MODE_MIN; - if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt =PS_MODE_ACTIVE ; - else - pwrctrlpriv->power_mgnt =padapter->registrypriv.power_mgnt;// PS_MODE_MIN; + pwrctrlpriv->power_mgnt =padapter->registrypriv.power_mgnt;// PS_MODE_MIN; pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt)?_TRUE:_FALSE; pwrctrlpriv->bFwCurrentInPSMode = _FALSE; @@ -2427,27 +2296,8 @@ int _rtw_pwr_wakeup(_adapter *padapter, u32 ips_deffer_ms, const char *caller) //I think this should be check in IPS, LPS, autosuspend functions... if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { -#if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - if(_TRUE==pwrpriv->bInternalAutoSuspend){ - if(0==pwrpriv->autopm_cnt){ - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,33)) - if (usb_autopm_get_interface(adapter_to_dvobj(padapter)->pusbintf) < 0) - { - DBG_871X( "can't get autopm: \n"); - } - #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,20)) - usb_autopm_disable(adapter_to_dvobj(padapter)->pusbintf); - #else - usb_autoresume_device(adapter_to_dvobj(padapter)->pusbdev, 1); - #endif - pwrpriv->autopm_cnt++; - } -#endif //#if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) ret = _SUCCESS; goto exit; -#if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) - } -#endif //#if defined (CONFIG_BT_COEXIST)&& defined (CONFIG_AUTOSUSPEND) } if(rf_off == pwrpriv->rf_pwrstate ) diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_recv.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_recv.c index 43d5e5bf0..5258d411b 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_recv.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_recv.c @@ -1378,13 +1378,6 @@ _func_enter_; if (*psta == NULL) { RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("can't get psta under sta2sta_data_frame ; drop pkt\n")); -#ifdef CONFIG_MP_INCLUDED - if (adapter->registrypriv.mp_mode == 1) - { - if(check_fwstate(pmlmepriv, WIFI_MP_STATE) == _TRUE) - adapter->mppriv.rx_pktloss++; - } -#endif ret= _FAIL; goto exit; } @@ -4328,15 +4321,6 @@ int recv_func_prehandle(_adapter *padapter, union recv_frame *rframe) } #endif -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1 || padapter->mppriv.bRTWSmbCfg ==_TRUE) - { - mp_recv_frame(padapter,rframe); - ret = _FAIL; - goto exit; - } - else -#endif { //check the frame crtl field and decache ret = validate_recv_frame(padapter, rframe); @@ -4614,11 +4598,6 @@ _func_exit_; _recv_entry_drop: -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) - padapter->mppriv.rx_pktloss = precvpriv->rx_drop; -#endif - //RT_TRACE(_module_rtl871x_recv_c_,_drv_err_,("_recv_entry_drop\n")); _func_exit_; diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_security.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_security.c index ed5e9aff5..bc0ee03ae 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_security.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_security.c @@ -2279,324 +2279,6 @@ BIP_exit: } #endif //CONFIG_IEEE80211W -#ifndef PLATFORM_FREEBSD -/* compress 512-bits */ -static int sha256_compress(struct rtw_sha256_state *md, unsigned char *buf) -{ - u32 S[8], W[64], t0, t1; - u32 t; - int i; - - /* copy state into S */ - for (i = 0; i < 8; i++) { - S[i] = md->state[i]; - } - - /* copy the state into 512-bits into W[0..15] */ - for (i = 0; i < 16; i++) - W[i] = WPA_GET_BE32(buf + (4 * i)); - - /* fill W[16..63] */ - for (i = 16; i < 64; i++) { - W[i] = Gamma1(W[i - 2]) + W[i - 7] + Gamma0(W[i - 15]) + - W[i - 16]; - } - - /* Compress */ -#define RND(a,b,c,d,e,f,g,h,i) \ - t0 = h + Sigma1(e) + Ch(e, f, g) + K[i] + W[i]; \ - t1 = Sigma0(a) + Maj(a, b, c); \ - d += t0; \ - h = t0 + t1; - - for (i = 0; i < 64; ++i) { - RND(S[0], S[1], S[2], S[3], S[4], S[5], S[6], S[7], i); - t = S[7]; S[7] = S[6]; S[6] = S[5]; S[5] = S[4]; - S[4] = S[3]; S[3] = S[2]; S[2] = S[1]; S[1] = S[0]; S[0] = t; - } - - /* feedback */ - for (i = 0; i < 8; i++) { - md->state[i] = md->state[i] + S[i]; - } - return 0; -} - -/* Initialize the hash state */ -static void sha256_init(struct rtw_sha256_state *md) -{ - md->curlen = 0; - md->length = 0; - md->state[0] = 0x6A09E667UL; - md->state[1] = 0xBB67AE85UL; - md->state[2] = 0x3C6EF372UL; - md->state[3] = 0xA54FF53AUL; - md->state[4] = 0x510E527FUL; - md->state[5] = 0x9B05688CUL; - md->state[6] = 0x1F83D9ABUL; - md->state[7] = 0x5BE0CD19UL; -} - -/** - Process a block of memory though the hash - @param md The hash state - @param in The data to hash - @param inlen The length of the data (octets) - @return CRYPT_OK if successful -*/ -static int sha256_process(struct rtw_sha256_state *md, unsigned char *in, - unsigned long inlen) -{ - unsigned long n; -#define block_size 64 - - if (md->curlen > sizeof(md->buf)) - return -1; - - while (inlen > 0) { - if (md->curlen == 0 && inlen >= block_size) { - if (sha256_compress(md, (unsigned char *) in) < 0) - return -1; - md->length += block_size * 8; - in += block_size; - inlen -= block_size; - } else { - n = MIN(inlen, (block_size - md->curlen)); - _rtw_memcpy(md->buf + md->curlen, in, n); - md->curlen += n; - in += n; - inlen -= n; - if (md->curlen == block_size) { - if (sha256_compress(md, md->buf) < 0) - return -1; - md->length += 8 * block_size; - md->curlen = 0; - } - } - } - - return 0; -} - - -/** - Terminate the hash to get the digest - @param md The hash state - @param out [out] The destination of the hash (32 bytes) - @return CRYPT_OK if successful -*/ -static int sha256_done(struct rtw_sha256_state *md, unsigned char *out) -{ - int i; - - if (md->curlen >= sizeof(md->buf)) - return -1; - - /* increase the length of the message */ - md->length += md->curlen * 8; - - /* append the '1' bit */ - md->buf[md->curlen++] = (unsigned char) 0x80; - - /* if the length is currently above 56 bytes we append zeros - * then compress. Then we can fall back to padding zeros and length - * encoding like normal. - */ - if (md->curlen > 56) { - while (md->curlen < 64) { - md->buf[md->curlen++] = (unsigned char) 0; - } - sha256_compress(md, md->buf); - md->curlen = 0; - } - - /* pad upto 56 bytes of zeroes */ - while (md->curlen < 56) { - md->buf[md->curlen++] = (unsigned char) 0; - } - - /* store length */ - WPA_PUT_BE64(md->buf + 56, md->length); - sha256_compress(md, md->buf); - - /* copy output */ - for (i = 0; i < 8; i++) - WPA_PUT_BE32(out + (4 * i), md->state[i]); - - return 0; -} - -/** - * sha256_vector - SHA256 hash for data vector - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash - * Returns: 0 on success, -1 of failure - */ -static int sha256_vector(size_t num_elem, u8 *addr[], size_t *len, - u8 *mac) -{ - struct rtw_sha256_state ctx; - size_t i; - - sha256_init(&ctx); - for (i = 0; i < num_elem; i++) - if (sha256_process(&ctx, addr[i], len[i])) - return -1; - if (sha256_done(&ctx, mac)) - return -1; - return 0; -} - -static u8 os_strlen(const char *s) -{ - const char *p = s; - while (*p) - p++; - return p - s; -} - -static int os_memcmp(void *s1, void *s2, u8 n) -{ - unsigned char *p1 = s1, *p2 = s2; - - if (n == 0) - return 0; - - while (*p1 == *p2) { - p1++; - p2++; - n--; - if (n == 0) - return 0; - } - - return *p1 - *p2; -} - -/** - * hmac_sha256_vector - HMAC-SHA256 over data vector (RFC 2104) - * @key: Key for HMAC operations - * @key_len: Length of the key in bytes - * @num_elem: Number of elements in the data vector - * @addr: Pointers to the data areas - * @len: Lengths of the data blocks - * @mac: Buffer for the hash (32 bytes) - */ -static void hmac_sha256_vector(u8 *key, size_t key_len, size_t num_elem, - u8 *addr[], size_t *len, u8 *mac) -{ - unsigned char k_pad[64]; /* padding - key XORd with ipad/opad */ - unsigned char tk[32]; - u8 *_addr[6]; - size_t _len[6], i; - - if (num_elem > 5) { - /* - * Fixed limit on the number of fragments to avoid having to - * allocate memory (which could fail). - */ - return; - } - - /* if key is longer than 64 bytes reset it to key = SHA256(key) */ - if (key_len > 64) { - sha256_vector(1, &key, &key_len, tk); - key = tk; - key_len = 32; - } - - /* the HMAC_SHA256 transform looks like: - * - * SHA256(K XOR opad, SHA256(K XOR ipad, text)) - * - * where K is an n byte key - * ipad is the byte 0x36 repeated 64 times - * opad is the byte 0x5c repeated 64 times - * and text is the data being protected */ - - /* start out by storing key in ipad */ - _rtw_memset(k_pad, 0, sizeof(k_pad)); - _rtw_memcpy(k_pad, key, key_len); - /* XOR key with ipad values */ - for (i = 0; i < 64; i++) - k_pad[i] ^= 0x36; - - /* perform inner SHA256 */ - _addr[0] = k_pad; - _len[0] = 64; - for (i = 0; i < num_elem; i++) { - _addr[i + 1] = addr[i]; - _len[i + 1] = len[i]; - } - sha256_vector(1 + num_elem, _addr, _len, mac); - - _rtw_memset(k_pad, 0, sizeof(k_pad)); - _rtw_memcpy(k_pad, key, key_len); - /* XOR key with opad values */ - for (i = 0; i < 64; i++) - k_pad[i] ^= 0x5c; - - /* perform outer SHA256 */ - _addr[0] = k_pad; - _len[0] = 64; - _addr[1] = mac; - _len[1] = 32; - sha256_vector(2, _addr, _len, mac); -} -#endif //PLATFORM_FREEBSD -/** - * sha256_prf - SHA256-based Pseudo-Random Function (IEEE 802.11r, 8.5.1.5.2) - * @key: Key for PRF - * @key_len: Length of the key in bytes - * @label: A unique label for each purpose of the PRF - * @data: Extra data to bind into the key - * @data_len: Length of the data - * @buf: Buffer for the generated pseudo-random key - * @buf_len: Number of bytes of key to generate - * - * This function is used to derive new, cryptographically separate keys from a - * given key. - */ -#ifndef PLATFORM_FREEBSD //Baron -static void sha256_prf(u8 *key, size_t key_len, char *label, - u8 *data, size_t data_len, u8 *buf, size_t buf_len) -{ - u16 counter = 1; - size_t pos, plen; - u8 hash[SHA256_MAC_LEN]; - u8 *addr[4]; - size_t len[4]; - u8 counter_le[2], length_le[2]; - - addr[0] = counter_le; - len[0] = 2; - addr[1] = (u8 *) label; - len[1] = os_strlen(label); - addr[2] = data; - len[2] = data_len; - addr[3] = length_le; - len[3] = sizeof(length_le); - - WPA_PUT_LE16(length_le, buf_len * 8); - pos = 0; - while (pos < buf_len) { - plen = buf_len - pos; - WPA_PUT_LE16(counter_le, counter); - if (plen >= SHA256_MAC_LEN) { - hmac_sha256_vector(key, key_len, 4, addr, len, - &buf[pos]); - pos += SHA256_MAC_LEN; - } else { - hmac_sha256_vector(key, key_len, 4, addr, len, hash); - _rtw_memcpy(&buf[pos], hash, plen); - break; - } - counter++; - } -} -#endif //PLATFORM_FREEBSD Baron /* AES tables*/ const u32 Te0[256] = { diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_sta_mgt.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_sta_mgt.c index 68eda779d..c5f0285bc 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_sta_mgt.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_sta_mgt.c @@ -345,8 +345,7 @@ void rtw_mfree_stainfo(struct sta_info *psta) { _func_enter_; - if(&psta->lock != NULL) - _rtw_spinlock_free(&psta->lock); + _rtw_spinlock_free(&psta->lock); _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_wlan_util.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_wlan_util.c index 7ddbb1a22..b73ae4a90 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_wlan_util.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_wlan_util.c @@ -4169,9 +4169,7 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, int i = 0; struct file *fp; -#ifdef set_fs mm_segment_t fs; -#endif loff_t pos = 0; u8 *source = NULL; long len = 0; @@ -4208,10 +4206,8 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, return 0; } -#ifdef set_fs fs = get_fs(); set_fs(KERNEL_DS); -#endif source = rtw_zmalloc(2048); @@ -4221,9 +4217,7 @@ int rtw_dev_nlo_info_set(struct pno_nlo_info *nlo_info, pno_ssid_t* ssid, rtw_mfree(source, 2048); } -#ifdef set_fs set_fs(fs); -#endif filp_close(fp, NULL); DBG_871X("-%s-\n", __func__); diff --git a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_xmit.c b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_xmit.c index c7f7f797d..1da61cc37 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/core/rtw_xmit.c +++ b/drivers/net/wireless/realtek/rtl8188fu/core/rtw_xmit.c @@ -4103,8 +4103,6 @@ inline bool xmitframe_hiq_filter(struct xmit_frame *xmitframe) _adapter *adapter = xmitframe->padapter; struct registry_priv *registry = &adapter->registrypriv; -if (rtw_get_intf_type(adapter) != RTW_PCIE) { - if (adapter->registrypriv.wifi_spec == 1) { allow = _TRUE; } else if (registry->hiq_filter == RTW_HIQ_FILTER_ALLOW_SPECIAL) { @@ -4132,7 +4130,7 @@ if (rtw_get_intf_type(adapter) != RTW_PCIE) { else { rtw_warn_on(1); } -} + return allow; } diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.c deleted file mode 100644 index fb9139538..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.c +++ /dev/null @@ -1,1988 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for 92CE/92CU BT 1 Antenna Co-exist mechanism -// -// By cosa 02/11/2011 -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8188c2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8188C_2ANT GLCoexDm8188c2Ant; -static PCOEX_DM_8188C_2ANT pCoexDm=&GLCoexDm8188c2Ant; -static COEX_STA_8188C_2ANT GLCoexSta8188c2Ant; -static PCOEX_STA_8188C_2ANT pCoexSta=&GLCoexSta8188c2Ant; - -//============================================================ -// local function start with btdm_ -//============================================================ -u1Byte -halbtc8188c2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -u1Byte -halbtc8188c2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - u1Byte algorithm=BT_8188C_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - if(!pStackInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n")); - return algorithm; - } - - if(pStackInfo->bScoExist) - numOfDiffProfile++; - if(pStackInfo->bHidExist) - numOfDiffProfile++; - if(pStackInfo->bPanExist) - numOfDiffProfile++; - if(pStackInfo->bA2dpExist) - numOfDiffProfile++; - - if(pStackInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO algorithm\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_SCO; - } - else - { - if(numOfDiffProfile == 1) - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_A2DP; - } - else if(pStackInfo->bPanExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN only\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_PAN; - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_HID_A2DP; - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_HID_PAN; - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN + A2DP\n")); - algorithm = BT_8188C_2ANT_COEX_ALGO_PAN_A2DP; - } - } - } - return algorithm; -} - -VOID -halbtc8188c2ant_SetFwBalance( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBalanceOn, - IN u1Byte ms0, - IN u1Byte ms1 - ) -{ - u1Byte H2C_Parameter[3] ={0}; - - if(bBalanceOn) - { - H2C_Parameter[2] = 1; - H2C_Parameter[1] = ms1; - H2C_Parameter[0] = ms0; - } - else - { - H2C_Parameter[2] = 0; - H2C_Parameter[1] = 0; - H2C_Parameter[0] = 0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Balance=[%s:%dms:%dms], write 0xc=0x%x\n", - bBalanceOn?"ON":"OFF", ms0, ms1, - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0xc, 3, H2C_Parameter); -} - -VOID -halbtc8188c2ant_Balance( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bBalanceOn, - IN u1Byte ms0, - IN u1Byte ms1 - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Balance %s\n", - (bForceExec? "force to":""), (bBalanceOn? "ON":"OFF"))); - pCoexDm->bCurBalanceOn = bBalanceOn; - - if(!bForceExec) - { - if(pCoexDm->bPreBalanceOn == pCoexDm->bCurBalanceOn) - return; - } - halbtc8188c2ant_SetFwBalance(pBtCoexist, bBalanceOn, ms0, ms1); - - pCoexDm->bPreBalanceOn = pCoexDm->bCurBalanceOn; -} - -VOID -halbtc8188c2ant_SetFwDiminishWifi( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bDacOn, - IN BOOLEAN bInterruptOn, - IN u1Byte fwDacSwingLvl, - IN BOOLEAN bNavOn - ) -{ - u1Byte H2C_Parameter[3] ={0}; - - if((pBtCoexist->stackInfo.minBtRssi <= -5) && (fwDacSwingLvl == 0x20)) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], DiminishWiFi 0x20 original, but set 0x18 for Low RSSI!\n")); - fwDacSwingLvl = 0x18; - } - - H2C_Parameter[2] = 0; - H2C_Parameter[1] = fwDacSwingLvl; - H2C_Parameter[0] = 0; - if(bDacOn) - { - H2C_Parameter[2] |= 0x01; //BIT0 - if(bInterruptOn) - { - H2C_Parameter[2] |= 0x02; //BIT1 - } - } - if(bNavOn) - { - H2C_Parameter[2] |= 0x08; //BIT3 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bDacOn=%s, bInterruptOn=%s, bNavOn=%s, write 0xe=0x%x\n", - (bDacOn?"ON":"OFF"), (bInterruptOn?"ON":"OFF"), (bNavOn?"ON":"OFF"), - (H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]))); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0xe, 3, H2C_Parameter); -} - -VOID -halbtc8188c2ant_DiminishWifi( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacOn, - IN BOOLEAN bInterruptOn, - IN u1Byte fwDacSwingLvl, - IN BOOLEAN bNavOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set Diminish Wifi, bDacOn=%s, bInterruptOn=%s, fwDacSwingLvl=%d, bNavOn=%s\n", - (bForceExec? "force to":""), (bDacOn? "ON":"OFF"), (bInterruptOn? "ON":"OFF"), fwDacSwingLvl, (bNavOn? "ON":"OFF"))); - - pCoexDm->bCurDacOn = bDacOn; - pCoexDm->bCurInterruptOn = bInterruptOn; - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - pCoexDm->bCurNavOn = bNavOn; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacOn==pCoexDm->bCurDacOn) && - (pCoexDm->bPreInterruptOn==pCoexDm->bCurInterruptOn) && - (pCoexDm->preFwDacSwingLvl==pCoexDm->curFwDacSwingLvl) && - (pCoexDm->bPreNavOn==pCoexDm->bCurNavOn) ) - return; - } - halbtc8188c2ant_SetFwDiminishWifi(pBtCoexist, bDacOn, bInterruptOn, fwDacSwingLvl, bNavOn); - - pCoexDm->bPreDacOn = pCoexDm->bCurDacOn; - pCoexDm->bPreInterruptOn = pCoexDm->bCurInterruptOn; - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; - pCoexDm->bPreNavOn = pCoexDm->bCurNavOn; -} - -VOID -halbtc8188c2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, 0xf); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8188c2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8188c2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8188c2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8188c2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8188c2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8188c2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - u4Byte dacSwingLvl; - - if(bSwDacSwingOn) - { - if((pBtCoexist->stackInfo.minBtRssi <= -5) && (swDacSwingLvl == 0x20)) - { - dacSwingLvl = 0x18; - } - else - { - dacSwingLvl = swDacSwingLvl; - } - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, dacSwingLvl); - } - else - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, 0x30); - } -} - -VOID -halbtc8188c2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8188c2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8188c2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611); - } -} - -VOID -halbtc8188c2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8188c2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8188c2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4e1c0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4d1d0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4c1e0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4b1f0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4a200001); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00255); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x641c0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x631d0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x621e0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x611f0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x60200001); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x10255); - } - - // set rssiAdjustVal for wifi module. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - - -VOID -halbtc8188c2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8188c2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8188c2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u4Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8188c2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u4Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8188c2ant_SetCoexTable(pBtCoexist, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8188c2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} -VOID -halbtc8188c2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - - -VOID -halbtc8188c2ant_MonitorBtState( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN stateChange=FALSE; - u4Byte BT_Polling, Ratio_Act, Ratio_STA; - u4Byte BT_Active, BT_State; - u4Byte regBTActive=0, regBTState=0, regBTPolling=0; - u4Byte btBusyThresh=0; - u4Byte fwVer=0; - static BOOLEAN bBtBusyTraffic=FALSE; - BOOLEAN bRejApAggPkt=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FirmwareVersion = 0x%x(%d)\n", fwVer, fwVer)); - if(fwVer < 62) - { - regBTActive = 0x488; - regBTState = 0x48c; - regBTPolling = 0x490; - } - else - { - regBTActive = 0x444; - regBTState = 0x448; - if(fwVer >= 74) - regBTPolling = 0x44c; - else - regBTPolling = 0x700; - } - btBusyThresh = 60; - - BT_Active = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTActive); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Active(0x%x)=0x%x\n", regBTActive, BT_Active)); - BT_Active = BT_Active & 0x00ffffff; - - BT_State = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTState); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_State(0x%x)=0x%x\n", regBTState, BT_State)); - BT_State = BT_State & 0x00ffffff; - - BT_Polling = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTPolling); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Polling(0x%x)=0x%x\n", regBTPolling, BT_Polling)); - - if(BT_Active==0xffffffff && BT_State==0xffffffff && BT_Polling==0xffffffff ) - return; - - // 2011/05/04 MH For Slim combo test meet a problem. Surprise remove and WLAN is running - // DHCP process. At the same time, the register read value might be zero. And cause BSOD 0x7f - // EXCEPTION_DIVIDED_BY_ZERO. In This case, the stack content may always be wrong due to - // HW divide trap. - if (BT_Polling==0) - return; - - Ratio_Act = BT_Active*1000/BT_Polling; - Ratio_STA = BT_State*1000/BT_Polling; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_Act=%d\n", Ratio_Act)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_STA=%d\n", Ratio_STA)); - - if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_STA < 60) // BT PAN idle - { - } - else - { - // Check if BT PAN (under BT 2.1) is uplink or downlink - if((Ratio_Act/Ratio_STA) < 2) - { // BT PAN Uplink - pCoexSta->bBtUplink = TRUE; - } - else - { // BT PAN downlink - pCoexSta->bBtUplink = FALSE; - } - } - } - - // Check BT is idle or not - if(!pBtCoexist->stackInfo.bBtLinkExist) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_Act<20) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - pCoexSta->bBtBusy = TRUE; - } - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_STA < btBusyThresh) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - pCoexSta->bBtBusy = TRUE; - } - - if( (Ratio_STA < btBusyThresh) || - (Ratio_Act<180 && Ratio_STA<130) ) - { - pCoexSta->bA2dpBusy = FALSE; - } - else - { - pCoexSta->bA2dpBusy = TRUE; - } - } - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &pCoexSta->bBtBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &pCoexSta->bBtBusy); - - if(bBtBusyTraffic != pCoexSta->bBtBusy) - { // BT idle or BT non-idle - bBtBusyTraffic = pCoexSta->bBtBusy; - stateChange = TRUE; - } - - if(stateChange) - { - if(!pCoexSta->bBtBusy) - { - halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_CoexAllOff(pBtCoexist); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - } - else - { - halbtc8188c2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - } - } - - if(stateChange) - { - bRejApAggPkt = pCoexSta->bBtBusy; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - } -} - -VOID -halbtc8188c2ant_ActionA2dpBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - - if(pCoexSta->bBtBusy) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - } - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionA2dpBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - BOOLEAN bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - if(pCoexSta->bA2dpBusy && bWifiBusy) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x18); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - } - else if(pCoexSta->bA2dpBusy) - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, TRUE, 0x18, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionA2dpBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionA2dpBc8(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionPanBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - if(bBtHsOn) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - else - { - if(pCoexSta->bBtBusy && bWifiBusy) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - } - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} - -VOID -halbtc8188c2ant_ActionPanBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - s4Byte wifiRssi; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(bBtHsOn) - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - else - { - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 3, 25, 50); - - if(pCoexSta->bBtBusy && bWifiBusy) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - if(pCoexSta->bBtUplink) - { - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - } - else if( (wifiRssiState == BTC_RSSI_STATE_MEDIUM) || - (wifiRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ) - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON); - else - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - if(pCoexSta->bBtUplink) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON); - } - else - { - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - } - else - { - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - } - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else if(pCoexSta->bBtBusy && !bWifiBusy && (wifiRssi < 30)) - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x0a, 0x20); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - } -} - -VOID -halbtc8188c2ant_ActionPan( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionPanBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionPanBc8(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte wifiBw, wifiTrafficDir; - BOOLEAN bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(!bWifiBusy) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} - - -VOID -halbtc8188c2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw; - - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - } -} - -VOID -halbtc8188c2ant_ActionHidA2dpBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - - if(pCoexSta->bBtBusy) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x7, 0x20); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - } - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } -} -VOID -halbtc8188c2ant_ActionHidA2dpBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw; - - if(pCoexSta->bBtBusy) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - } - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionHidA2dpBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionHidA2dpBc8(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionHidPanBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(bBtHsOn) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(!bWifiBusy) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - } - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} -VOID -halbtc8188c2ant_ActionHidPanBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!bBtHsOn) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0); - if((pCoexSta->bBtBusy && bWifiBusy)) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20); - } - else - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20); - } - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - } - else - { - if(BTC_INTF_USB == pBtCoexist->chipInterface) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8188c2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - } - else - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - } -} - -VOID -halbtc8188c2ant_ActionHidPan( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionHidPanBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionHidPanBc8(pBtCoexist); - } -} - -VOID -halbtc8188c2ant_ActionPanA2dpBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - if(bBtHsOn) - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - } - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - if(pCoexSta->bBtBusy && bWifiBusy) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } -} -VOID -halbtc8188c2ant_ActionPanA2dpBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!bBtHsOn) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - wifiRssiState = halbtc8188c2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0); - if((pCoexSta->bBtBusy && bWifiBusy)) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20); - } - else - { - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20); - } - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - } - else - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8188c2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8188c2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8188c2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8188c2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } -} - -VOID -halbtc8188c2ant_ActionPanA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionPanA2dpBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8188c2ant_ActionPanA2dpBc8(pBtCoexist); - } -} - -//============================================================ -// extern function start with EXhalbtc8188c2ant_ -//============================================================ -VOID -EXhalbtc8188c2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8188c2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xf0); - - if( (BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) || - (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) ) - { - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd) & BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, u1Tmp); - - halbtc8188c2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0xaaaa9aaa, 0xffbd0040, 0x40000010); - } -} - -VOID -EXhalbtc8188c2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8188c2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8188c2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!"); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - if(pStackInfo->bProfileNotified) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8188c2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - //halbtc8188c2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8188c2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - halbtc8188c2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - halbtc8188c2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8188c2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } -} - -VOID -EXhalbtc8188c2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8188c2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - -} - -VOID -EXhalbtc8188c2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8188c2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ -} - -VOID -EXhalbtc8188c2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - EXhalbtc8188c2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8188c2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Periodical!!\n")); - - // NOTE: - // sw mechanism must be done after fw mechanism - // - - if((BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) || - (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) ) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_GET_BT_RSSI, NULL); - - halbtc8188c2ant_MonitorBtState(pBtCoexist); - algorithm = halbtc8188c2ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - switch(pCoexDm->curAlgorithm) - { - case BT_8188C_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO\n")); - halbtc8188c2ant_ActionSco(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID\n")); - halbtc8188c2ant_ActionHid(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP\n")); - halbtc8188c2ant_ActionA2dp(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_PAN: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN\n")); - halbtc8188c2ant_ActionPan(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n")); - halbtc8188c2ant_ActionHidA2dp(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_HID_PAN: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+HID\n")); - halbtc8188c2ant_ActionHidPan(pBtCoexist); - break; - case BT_8188C_2ANT_COEX_ALGO_PAN_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n")); - halbtc8188c2ant_ActionPanA2dp(pBtCoexist); - break; - default: - break; - } - } -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.h deleted file mode 100644 index 79d0ebc35..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8188c2Ant.h +++ /dev/null @@ -1,150 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8188C 2Ant BT Co-exist definition -//=========================================== -#define BTC_RSSI_COEX_THRESH_TOL_8188C_2ANT 6 - -typedef enum _BT_INFO_SRC_8188C_2ANT{ - BT_INFO_SRC_8188C_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8188C_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8188C_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8188C_2ANT_MAX -}BT_INFO_SRC_8188C_2ANT,*PBT_INFO_SRC_8188C_2ANT; - -typedef enum _BT_8188C_2ANT_BT_STATUS{ - BT_8188C_2ANT_BT_STATUS_IDLE = 0x0, - BT_8188C_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8188C_2ANT_BT_STATUS_NON_IDLE = 0x2, - BT_8188C_2ANT_BT_STATUS_MAX -}BT_8188C_2ANT_BT_STATUS,*PBT_8188C_2ANT_BT_STATUS; - -typedef enum _BT_8188C_2ANT_COEX_ALGO{ - BT_8188C_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8188C_2ANT_COEX_ALGO_SCO = 0x1, - BT_8188C_2ANT_COEX_ALGO_HID = 0x2, - BT_8188C_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8188C_2ANT_COEX_ALGO_PAN = 0x4, - BT_8188C_2ANT_COEX_ALGO_HID_A2DP = 0x5, - BT_8188C_2ANT_COEX_ALGO_HID_PAN = 0x6, - BT_8188C_2ANT_COEX_ALGO_PAN_A2DP = 0x7, - BT_8188C_2ANT_COEX_ALGO_MAX -}BT_8188C_2ANT_COEX_ALGO,*PBT_8188C_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8188C_2ANT{ - // fw mechanism - BOOLEAN bPreBalanceOn; - BOOLEAN bCurBalanceOn; - - // diminishWifi - BOOLEAN bPreDacOn; - BOOLEAN bCurDacOn; - BOOLEAN bPreInterruptOn; - BOOLEAN bCurInterruptOn; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bPreNavOn; - BOOLEAN bCurNavOn; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - //u4Byte preVal0x6c0; - //u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u4Byte preVal0x6cc; - u4Byte curVal0x6cc; - //BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - //u1Byte btStatus; - //u1Byte wifiChnlInfo[3]; -} COEX_DM_8188C_2ANT, *PCOEX_DM_8188C_2ANT; - -typedef struct _COEX_STA_8188C_2ANT{ - u1Byte preWifiRssiState[4]; - BOOLEAN bBtBusy; - BOOLEAN bBtUplink; - BOOLEAN bBtDownLink; - BOOLEAN bA2dpBusy; -}COEX_STA_8188C_2ANT, *PCOEX_STA_8188C_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8188c2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8188c2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8188c2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8188c2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8188c2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8188c2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8188c2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8188c2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.c deleted file mode 100644 index c81127756..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.c +++ /dev/null @@ -1,1993 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for 92D BT 2 Antenna Co-exist mechanism -// -// By cosa 02/11/2011 -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8192d2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8192D_2ANT GLCoexDm8192d2Ant; -static PCOEX_DM_8192D_2ANT pCoexDm=&GLCoexDm8192d2Ant; -static COEX_STA_8192D_2ANT GLCoexSta8192d2Ant; -static PCOEX_STA_8192D_2ANT pCoexSta=&GLCoexSta8192d2Ant; - -//============================================================ -// local function start with btdm_ -//============================================================ -u1Byte -halbtc8192d2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192D_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192D_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192D_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -u1Byte -halbtc8192d2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8192D_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pStackInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n")); - return algorithm; - } - - if(pStackInfo->bScoExist) - numOfDiffProfile++; - if(pStackInfo->bHidExist) - numOfDiffProfile++; - if(pStackInfo->bPanExist) - numOfDiffProfile++; - if(pStackInfo->bA2dpExist) - numOfDiffProfile++; - - if(pStackInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO algorithm\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_SCO; - } - else - { - if(numOfDiffProfile == 1) - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_A2DP; - } - else if(pStackInfo->bPanExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN only\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_PAN; - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_HID_A2DP; - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_HID_PAN; - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN + A2DP\n")); - algorithm = BT_8192D_2ANT_COEX_ALGO_PAN_A2DP; - } - } - } - return algorithm; -} - -VOID -halbtc8192d2ant_SetFwBalance( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBalanceOn, - IN u1Byte ms0, - IN u1Byte ms1 - ) -{ - u1Byte H2C_Parameter[3] ={0}; - - if(bBalanceOn) - { - H2C_Parameter[2] = 1; - H2C_Parameter[1] = ms1; - H2C_Parameter[0] = ms0; - } - else - { - H2C_Parameter[2] = 0; - H2C_Parameter[1] = 0; - H2C_Parameter[0] = 0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Balance=[%s:%dms:%dms], write 0xc=0x%x\n", - bBalanceOn?"ON":"OFF", ms0, ms1, - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0xc, 3, H2C_Parameter); -} - -VOID -halbtc8192d2ant_Balance( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bBalanceOn, - IN u1Byte ms0, - IN u1Byte ms1 - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Balance %s\n", - (bForceExec? "force to":""), (bBalanceOn? "ON":"OFF"))); - pCoexDm->bCurBalanceOn = bBalanceOn; - - if(!bForceExec) - { - if(pCoexDm->bPreBalanceOn == pCoexDm->bCurBalanceOn) - return; - } - halbtc8192d2ant_SetFwBalance(pBtCoexist, bBalanceOn, ms0, ms1); - - pCoexDm->bPreBalanceOn = pCoexDm->bCurBalanceOn; -} - -VOID -halbtc8192d2ant_SetFwDiminishWifi( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bDacOn, - IN BOOLEAN bInterruptOn, - IN u1Byte fwDacSwingLvl, - IN BOOLEAN bNavOn - ) -{ - u1Byte H2C_Parameter[3] ={0}; - - if((pBtCoexist->stackInfo.minBtRssi <= -5) && (fwDacSwingLvl == 0x20)) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], DiminishWiFi 0x20 original, but set 0x18 for Low RSSI!\n")); - fwDacSwingLvl = 0x18; - } - - H2C_Parameter[2] = 0; - H2C_Parameter[1] = fwDacSwingLvl; - H2C_Parameter[0] = 0; - if(bDacOn) - { - H2C_Parameter[2] |= 0x01; //BIT0 - if(bInterruptOn) - { - H2C_Parameter[2] |= 0x02; //BIT1 - } - } - if(bNavOn) - { - H2C_Parameter[2] |= 0x08; //BIT3 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bDacOn=%s, bInterruptOn=%s, bNavOn=%s, write 0x12=0x%x\n", - (bDacOn?"ON":"OFF"), (bInterruptOn?"ON":"OFF"), (bNavOn?"ON":"OFF"), - (H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2]))); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x12, 3, H2C_Parameter); -} - - -VOID -halbtc8192d2ant_DiminishWifi( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacOn, - IN BOOLEAN bInterruptOn, - IN u1Byte fwDacSwingLvl, - IN BOOLEAN bNavOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set Diminish Wifi, bDacOn=%s, bInterruptOn=%s, fwDacSwingLvl=%d, bNavOn=%s\n", - (bForceExec? "force to":""), (bDacOn? "ON":"OFF"), (bInterruptOn? "ON":"OFF"), fwDacSwingLvl, (bNavOn? "ON":"OFF"))); - - pCoexDm->bCurDacOn = bDacOn; - pCoexDm->bCurInterruptOn = bInterruptOn; - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - pCoexDm->bCurNavOn = bNavOn; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacOn==pCoexDm->bCurDacOn) && - (pCoexDm->bPreInterruptOn==pCoexDm->bCurInterruptOn) && - (pCoexDm->preFwDacSwingLvl==pCoexDm->curFwDacSwingLvl) && - (pCoexDm->bPreNavOn==pCoexDm->bCurNavOn) ) - return; - } - halbtc8192d2ant_SetFwDiminishWifi(pBtCoexist, bDacOn, bInterruptOn, fwDacSwingLvl, bNavOn); - - pCoexDm->bPreDacOn = pCoexDm->bCurDacOn; - pCoexDm->bPreInterruptOn = pCoexDm->bCurInterruptOn; - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; - pCoexDm->bPreNavOn = pCoexDm->bCurNavOn; -} - -VOID -halbtc8192d2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf2ff7); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - - -VOID -halbtc8192d2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8192d2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8192d2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8192d2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8192d2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8192d2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - u4Byte dacSwingLvl; - - if(bSwDacSwingOn) - { - if((pBtCoexist->stackInfo.minBtRssi <= -5) && (swDacSwingLvl == 0x20)) - { - dacSwingLvl = 0x18; - } - else - { - dacSwingLvl = swDacSwingLvl; - } - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, dacSwingLvl); - } - else - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xfc000000, 0x30); - } -} - -VOID -halbtc8192d2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8192d2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8192d2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611); - } -} - -VOID -halbtc8192d2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8192d2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8192d2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0xa99); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xd4000); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b000001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b010001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b020001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b030001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b040001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b050001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b060001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b070001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b080001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b090001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b0A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7b0B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7a0C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x790D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x780E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x770F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x76100001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x75110001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x74120001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x73130001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x72140001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x71150001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x70160001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6f170001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e180001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d190001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4f1E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4e1F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4d200001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4c210001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4b220001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x4a230001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x49240001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x48250001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x47260001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x46270001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x45280001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x44290001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x432A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x422B0001); - - rssiAdjustVal = 12; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x30a99); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B000001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B010001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B020001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B030001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B040001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B050001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7B060001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x7A070001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x79080001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x78090001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x770A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x760B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x750C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x740D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x730E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x720F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x71100001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x70110001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6F120001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6E130001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6D140001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6C150001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6B160001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6A170001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x69180001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68190001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x671A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x661B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x651C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x641D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x631E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x621F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x61200001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x60210001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x49220001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x48230001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x47240001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x46250001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x45260001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x44270001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x43280001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x42290001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x412A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x402B0001); - } - - // set rssiAdjustVal for wifi module. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - - - -VOID -halbtc8192d2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8192d2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8192d2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u4Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8192d2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u4Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8192d2ant_SetCoexTable(pBtCoexist, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8192d2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw mechanism - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} -VOID -halbtc8192d2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -halbtc8192d2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte btActive - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtDisabled=FALSE, bForceToRoam=FALSE; - u4Byte u4Tmp=0; - - // This function check if bt is disabled - if(btActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - - bForceToRoam = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_FORCE_TO_ROAM, &bForceToRoam); - - bPreBtDisabled = bBtDisabled; - } -} - -VOID -halbtc8192d2ant_MonitorBtState( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN stateChange=FALSE; - u4Byte BT_Polling, Ratio_Act, Ratio_STA; - u4Byte BT_Active, BT_State; - u4Byte regBTActive=0, regBTState=0, regBTPolling=0; - u4Byte btBusyThresh=0; - u4Byte fwVer=0; - static BOOLEAN bBtBusyTraffic=FALSE; - BOOLEAN bRejApAggPkt=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FirmwareVersion = 0x%x(%d)\n", fwVer, fwVer)); - - regBTActive = 0x444; - regBTState = 0x448; - regBTPolling = 0x44c; - - btBusyThresh = 40; - - BT_Active = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTActive); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Active(0x%x)=0x%x\n", regBTActive, BT_Active)); - BT_Active = BT_Active & 0x00ffffff; - - BT_State = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTState); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_State(0x%x)=0x%x\n", regBTState, BT_State)); - BT_State = BT_State & 0x00ffffff; - - BT_Polling = pBtCoexist->fBtcRead4Byte(pBtCoexist, regBTPolling); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT_Polling(0x%x)=0x%x\n", regBTPolling, BT_Polling)); - - if(BT_Active==0xffffffff && BT_State==0xffffffff && BT_Polling==0xffffffff ) - return; - - // 2011/05/04 MH For Slim combo test meet a problem. Surprise remove and WLAN is running - // DHCP process. At the same time, the register read value might be zero. And cause BSOD 0x7f - // EXCEPTION_DIVIDED_BY_ZERO. In This case, the stack content may always be wrong due to - // HW divide trap. - if (BT_Polling==0) - return; - - halbtc8192d2ant_MonitorBtEnableDisable(pBtCoexist, BT_Active); - - Ratio_Act = BT_Active*1000/BT_Polling; - Ratio_STA = BT_State*1000/BT_Polling; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_Act=%d\n", Ratio_Act)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ratio_STA=%d\n", Ratio_STA)); - - if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_STA < 60) // BT PAN idle - { - } - else - { - // Check if BT PAN (under BT 2.1) is uplink or downlink - if((Ratio_Act/Ratio_STA) < 2) - { // BT PAN Uplink - pCoexSta->bBtUplink = TRUE; - } - else - { // BT PAN downlink - pCoexSta->bBtUplink = FALSE; - } - } - } - - // Check BT is idle or not - if(!pBtCoexist->stackInfo.bBtLinkExist) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_Act<20) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - pCoexSta->bBtBusy = TRUE; - } - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - if(Ratio_STA < btBusyThresh) - { - pCoexSta->bBtBusy = FALSE; - } - else - { - pCoexSta->bBtBusy = TRUE; - } - - if( (Ratio_STA < btBusyThresh) || - (Ratio_Act<180 && Ratio_STA<130) ) - { - pCoexSta->bA2dpBusy = FALSE; - } - else - { - pCoexSta->bA2dpBusy = TRUE; - } - } - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &pCoexSta->bBtBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &pCoexSta->bBtBusy); - - if(bBtBusyTraffic != pCoexSta->bBtBusy) - { // BT idle or BT non-idle - bBtBusyTraffic = pCoexSta->bBtBusy; - stateChange = TRUE; - } - - if(stateChange) - { - if(!pCoexSta->bBtBusy) - { - halbtc8192d2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_CoexAllOff(pBtCoexist); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - } - else - { - halbtc8192d2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - } - } - - if(stateChange) - { - bRejApAggPkt = pCoexSta->bBtBusy; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejApAggPkt); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - } -} - -VOID -halbtc8192d2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw, wifiTrafficDir; - BOOLEAN bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - if(pCoexSta->bA2dpBusy && bWifiBusy) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - } - else - { - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 25, 0); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 40, 0); - } - } - - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0xc, 0x18); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x18); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - } - else if(pCoexSta->bA2dpBusy) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, TRUE, 0x18, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } -} - -VOID -halbtc8192d2ant_ActionPan( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState, wifiRssiState1; - u4Byte wifiBw, wifiTrafficDir; - s4Byte wifiRssi; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(bBtHsOn) - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - else - { - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 3, 25, 50); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - } - else - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 25, 0); - } - - if(pCoexSta->bBtBusy && bWifiBusy) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - } - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - if(pCoexSta->bBtUplink) - { - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - } - else if( (wifiRssiState == BTC_RSSI_STATE_MEDIUM) || - (wifiRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON); - else - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x20); - - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - if(pCoexSta->bBtUplink) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE);//BT_FW_NAV_ON); - } - else - { - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - } - else - { - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - } - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else if(pCoexSta->bBtBusy && - !bWifiBusy && - (wifiRssi < 30)) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x0a, 0x20); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - } -} - - -VOID -halbtc8192d2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiTrafficDir; - BOOLEAN bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 45, 0); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 20, 0); - } - - if(pCoexSta->bBtBusy && bWifiBusy) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - // fw mechanism first - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, TRUE, 0x18, FALSE); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x15); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x30, FALSE); - } - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } -} - - - -VOID -halbtc8192d2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } -} - -VOID -halbtc8192d2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1; - u4Byte wifiBw; - - if(pCoexSta->bBtBusy) - { - wifiRssiState1 = halbtc8192d2ant_WifiRssiState(pBtCoexist, 1, 2, 35, 0); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism first - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - // fw mechanism - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - } - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else - { - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - } - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } -} - - -VOID -halbtc8192d2ant_ActionHidPanBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(bBtHsOn) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8192d2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8192d2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8192d2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else if(!bWifiBusy) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - } - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); -} -VOID -halbtc8192d2ant_ActionHidPanBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - u4Byte wifiBw, wifiTrafficDir; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!bBtHsOn) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0); - if((pCoexSta->bBtBusy && bWifiBusy)) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20); - } - else - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20); - } - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - } - else - { - if(BTC_INTF_USB == pBtCoexist->chipInterface) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - if(BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - - halbtc8192d2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x000000f0, 0x40000010); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0xa0); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - else if(BTC_WIFI_TRAFFIC_RX == wifiTrafficDir) - { - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - } - } - else - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - } -} - -VOID -halbtc8192d2ant_ActionHidPan( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8192d2ant_ActionHidPanBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8192d2ant_ActionHidPanBc8(pBtCoexist); - } -} - -VOID -halbtc8192d2ant_ActionPanA2dpBc4( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x0); - if(bBtHsOn) - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - } - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - if(pCoexSta->bBtBusy && bWifiBusy) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x20, 0x10); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - } - else - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x0, FALSE); - } - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } -} -VOID -halbtc8192d2ant_ActionPanA2dpBc8( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bBtHsOn=FALSE, bWifiBusy=FALSE; - u1Byte wifiRssiState; - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!bBtHsOn) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - wifiRssiState = halbtc8192d2ant_WifiRssiState(pBtCoexist, 0, 2, 25, 0); - if((pCoexSta->bBtBusy && bWifiBusy)) - { - // fw mechanism first - if(pCoexSta->bBtUplink) - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x15, 0x20); - } - else - { - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, TRUE, 0x10, 0x20); - } - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x20, FALSE); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } - else - { - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - } - else - { - if(pCoexSta->bBtBusy) - { - // fw mechanism - halbtc8192d2ant_Balance(pBtCoexist, NORMAL_EXEC, FALSE, 0, 0); - halbtc8192d2ant_DiminishWifi(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0, FALSE); - - // sw mechanism - halbtc8192d2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x20); - } - else - { - halbtc8192d2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0x30); - } - } -} - -VOID -halbtc8192d2ant_ActionPanA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - if(BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) - { - halbtc8192d2ant_ActionPanA2dpBc4(pBtCoexist); - } - else if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - halbtc8192d2ant_ActionPanA2dpBc8(pBtCoexist); - } -} - -BOOLEAN -halbtc8192d2ant_IsBtCoexistEnter( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte macPhyMode; - BOOLEAN bRet=TRUE; - BOOLEAN bWifiUnder5G=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_MAC_PHY_MODE, &macPhyMode); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - if(BTC_SMSP != macPhyMode) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Only support single mac single phy!!\n")); - bRet = FALSE; - } - - if(bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under 5G or A band\n")); - halbtc8192d2ant_CoexAllOff(pBtCoexist); - bRet = FALSE; - } - - return bRet; -} - -//============================================================ -// extern function start with EXhalbtc8192d2ant_ -//============================================================ -VOID -EXhalbtc8192d2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8192d2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - if( (BTC_CHIP_CSR_BC4 == pBtCoexist->boardInfo.btChipType) || - (BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) ) - { - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd) & BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, u1Tmp); - - halbtc8192d2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0xaaaa9aaa, 0xffbd0040, 0x40000010); - - // switch control, here we set pathA to control - // 0x878[13] = 1, 0:pathB, 1:pathA(default) - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x878, BIT13, 0x1); - - // antsel control, here we use phy0 and enable antsel. - // 0x87c[16:15] = b'11, enable antsel, antsel output pin - // 0x87c[30] = 0, 0: phy0, 1:phy 1 - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x87c, bMaskDWord, 0x1fff8); - - // antsel to Bt or Wifi, it depends Bt on/off. - // 0x860[9:8] = 'b10, b10:Bt On, WL2G off(default), b01:Bt off, WL2G on. - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x860, BIT9|BIT8, 0x2); - - // sw/hw control switch, here we set sw control - // 0x870[9:8] = 'b11 sw control, 'b00 hw control - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x870, BIT9|BIT8, 0x3); - } -} - -VOID -EXhalbtc8192d2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8192d2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8192d2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!"); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - if(pStackInfo->bProfileNotified) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8192d2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - //halbtc8192d2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8192d2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - halbtc8192d2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - halbtc8192d2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8192d2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } -} - -VOID -EXhalbtc8192d2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8192d2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } -} - -VOID -EXhalbtc8192d2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8192d2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ -} - -VOID -EXhalbtc8192d2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - EXhalbtc8192d2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8192d2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Periodical!!\n")); - - // NOTE: - // sw mechanism must be done after fw mechanism - // - if(!halbtc8192d2ant_IsBtCoexistEnter(pBtCoexist)) - return; - - if(BTC_CHIP_CSR_BC8 == pBtCoexist->boardInfo.btChipType) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_GET_BT_RSSI, NULL); - - halbtc8192d2ant_MonitorBtState(pBtCoexist); - algorithm = halbtc8192d2ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - switch(pCoexDm->curAlgorithm) - { - case BT_8192D_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO\n")); - halbtc8192d2ant_ActionSco(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID\n")); - halbtc8192d2ant_ActionHid(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP\n")); - halbtc8192d2ant_ActionA2dp(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_PAN: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN\n")); - halbtc8192d2ant_ActionPan(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP\n")); - halbtc8192d2ant_ActionHidA2dp(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_HID_PAN: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+HID\n")); - halbtc8192d2ant_ActionHidPan(pBtCoexist); - break; - case BT_8192D_2ANT_COEX_ALGO_PAN_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP\n")); - halbtc8192d2ant_ActionPanA2dp(pBtCoexist); - break; - default: - break; - } - } -} - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.h deleted file mode 100644 index 459c22d75..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192d2Ant.h +++ /dev/null @@ -1,171 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8192D 2Ant BT Co-exist definition -//=========================================== -#define BTC_RSSI_COEX_THRESH_TOL_8192D_2ANT 6 - -typedef enum _BT_INFO_SRC_8192D_2ANT{ - BT_INFO_SRC_8192D_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8192D_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8192D_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8192D_2ANT_MAX -}BT_INFO_SRC_8192D_2ANT,*PBT_INFO_SRC_8192D_2ANT; - -typedef enum _BT_8192D_2ANT_BT_STATUS{ - BT_8192D_2ANT_BT_STATUS_IDLE = 0x0, - BT_8192D_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8192D_2ANT_BT_STATUS_NON_IDLE = 0x2, - BT_8192D_2ANT_BT_STATUS_MAX -}BT_8192D_2ANT_BT_STATUS,*PBT_8192D_2ANT_BT_STATUS; - -typedef enum _BT_8192D_2ANT_COEX_ALGO{ - BT_8192D_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8192D_2ANT_COEX_ALGO_SCO = 0x1, - BT_8192D_2ANT_COEX_ALGO_HID = 0x2, - BT_8192D_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8192D_2ANT_COEX_ALGO_PAN = 0x4, - BT_8192D_2ANT_COEX_ALGO_HID_A2DP = 0x5, - BT_8192D_2ANT_COEX_ALGO_HID_PAN = 0x6, - BT_8192D_2ANT_COEX_ALGO_PAN_A2DP = 0x7, - BT_8192D_2ANT_COEX_ALGO_MAX -}BT_8192D_2ANT_COEX_ALGO,*PBT_8192D_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8192D_2ANT{ - // fw mechanism - BOOLEAN bPreBalanceOn; - BOOLEAN bCurBalanceOn; - - // diminishWifi - BOOLEAN bPreDacOn; - BOOLEAN bCurDacOn; - BOOLEAN bPreInterruptOn; - BOOLEAN bCurInterruptOn; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bPreNavOn; - BOOLEAN bCurNavOn; - - - - - - //BOOLEAN bPreDecBtPwr; - //BOOLEAN bCurDecBtPwr; - - //u1Byte preFwDacSwingLvl; - //u1Byte curFwDacSwingLvl; - //BOOLEAN bCurIgnoreWlanAct; - //BOOLEAN bPreIgnoreWlanAct; - //u1Byte prePsTdma; - //u1Byte curPsTdma; - //u1Byte psTdmaPara[5]; - //u1Byte psTdmaDuAdjType; - //BOOLEAN bResetTdmaAdjust; - //BOOLEAN bPrePsTdmaOn; - //BOOLEAN bCurPsTdmaOn; - //BOOLEAN bPreBtAutoReport; - //BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - //u4Byte preVal0x6c0; - //u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u4Byte preVal0x6cc; - u4Byte curVal0x6cc; - //BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - //u1Byte btStatus; - //u1Byte wifiChnlInfo[3]; -} COEX_DM_8192D_2ANT, *PCOEX_DM_8192D_2ANT; - -typedef struct _COEX_STA_8192D_2ANT{ - u1Byte preWifiRssiState[4]; - BOOLEAN bBtBusy; - BOOLEAN bBtUplink; - BOOLEAN bBtDownLink; - BOOLEAN bA2dpBusy; -}COEX_STA_8192D_2ANT, *PCOEX_STA_8192D_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8192d2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192d2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8192d2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192d2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192d2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192d2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192d2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8192d2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.c deleted file mode 100644 index e3ebe3a4b..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.c +++ /dev/null @@ -1,3739 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8192E Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8192e1Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8192E_1ANT GLCoexDm8192e1Ant; -static PCOEX_DM_8192E_1ANT pCoexDm=&GLCoexDm8192e1Ant; -static COEX_STA_8192E_1ANT GLCoexSta8192e1Ant; -static PCOEX_STA_8192E_1ANT pCoexSta=&GLCoexSta8192e1Ant; - -const char *const GLBtInfoSrc8192e1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8192e1Ant=20140527; -u4Byte GLCoexVer8192e1Ant=0x4f; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8192e1ant_ -//============================================================ -u1Byte -halbtc8192e1ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8192e1ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8192e1ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8192e1ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8192e1ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8192e1ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8192e1ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8192e1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8192e1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8192e1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8192e1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8192e1ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8192e1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -VOID -halbtc8192e1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp, u1Tmp1; - s4Byte wifiRssi; - static u1Byte NumOfBtCounterChk = 0; - - //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS - //if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) ) - - if (pCoexSta->bUnderIps) - { - pCoexSta->highPriorityTx = 65535; - pCoexSta->highPriorityRx = 65535; - pCoexSta->lowPriorityTx = 65535; - pCoexSta->lowPriorityRx = 65535; - return; - } - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if( (pCoexSta->lowPriorityTx >= 1050) && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->popEventCnt++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", - regHPRx, regHPTx, regLPRx, regLPTx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); - - if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0)) - { - NumOfBtCounterChk++; - if (NumOfBtCounterChk >= 3) - { - halbtc8192e1ant_QueryBtInfo(pBtCoexist); - NumOfBtCounterChk = 0; - } - } -} - - -VOID -halbtc8192e1ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); - - if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode)) - { - if ( (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_ACL_BUSY) || - (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY) || - (pCoexDm->btStatus == BT_8192E_1ANT_BT_STATUS_SCO_BUSY) ) - { - if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + - pCoexSta->nCRCOK_11nAgg) ) - { - if (nCCKLockCounter < 5) - nCCKLockCounter++; - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - if (!pCoexSta->bPreCCKLock) - { - - if (nCCKLockCounter >= 5) - pCoexSta->bCCKLock = TRUE; - else - pCoexSta->bCCKLock = FALSE; - } - else - { - if (nCCKLockCounter == 0) - pCoexSta->bCCKLock = FALSE; - else - pCoexSta->bCCKLock = TRUE; - } - - pCoexSta->bPreCCKLock = pCoexSta->bCCKLock; - - -} - -BOOLEAN -halbtc8192e1ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - } - - return FALSE; -} - -VOID -halbtc8192e1ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8192e1ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8192E_1ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8192E_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8192e1ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8192e1ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8192e1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8192e1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!") )); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8192e1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8192e1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8192e1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8192e1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8192e1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8192e1ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); - - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 3: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 4: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3); - break; - case 5: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaa5a5a5a, 0xffffff, 0x3); - break; - case 6: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 7: - halbtc8192e1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8192e1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8192e1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8192e1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8192e1ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8192e1ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8192e1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8192e1ant_SwMechanism( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRA - ) -{ - halbtc8192e1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8192e1ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - u4Byte u4Tmp=0; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x944, 0x24); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x930, 0x700700); - if(pBtCoexist->chipInterface == BTC_INTF_USB) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004); - - // 0x4c[27][24]='00', Set Antenna to BB - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &= ~BIT24; - u4Tmp &= ~BIT27; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - else if(bWifiOff) - { - if(pBtCoexist->chipInterface == BTC_INTF_USB) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004); - - // 0x4c[27][24]='11', Set Antenna to BT, 0x64[8:7]=0, 0x64[2]=1 - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp |= BIT24; - u4Tmp |= BIT27; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4); - break; - case BTC_ANT_PATH_BT: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x20); - break; - default: - case BTC_ANT_PATH_PTA: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4); - break; - } -} - -VOID -halbtc8192e1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - - -VOID -halbtc8192e1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE; - u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0; - u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; - s1Byte nWiFiDurationAdjust = 0x0; - - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if (pCoexDm->bCurPsTdmaOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum <= 5) - nWiFiDurationAdjust = 5; - else if (pCoexSta->nScanAPNum >= 40) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nScanAPNum >= 20) - nWiFiDurationAdjust = -10; - - if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle - } - - if ( (type == 3) || (type == 13) || (type == 14) ) - psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile - - if (pBtLinkInfo->bSlaveRole == TRUE) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - - if(bTurnOn) - { - switch(type) - { - default: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val); - break; - case 1: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 2: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 3: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val); - break; - case 4: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0); - break; - case 5: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x11); - break; - case 6: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11); - break; - case 7: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); - break; - case 8: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 9: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 10: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 12: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); - break; - case 13: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val); - break; - case 14: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val); - break; - case 15: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); - break; - case 16: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); - break; - case 18: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 20: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10); - break; - case 21: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); - break; - case 22: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10); - break; - case 23: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); - break; - case 24: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); - break; - case 25: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 26: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 27: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); - break; - case 28: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); - break; - case 29: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); - break; - case 30: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); - break; - case 31: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); - break; - case 32: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11); - break; - case 33: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90); - break; - case 34: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); - break; - case 35: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); - break; - case 36: - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); - break; - case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving - /* here softap mode screen off will cost 70-80mA for phone */ - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); - break; - } - } - else - { - - // disable PS tdma - switch(type) - { - case 8: //PTA Control - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE); - break; - case 0: - default: //Software control, Antenna at BT side - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE); - break; - case 9: //Software control, Antenna at WiFi side - halbtc8192e1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE); - break; - } - } - rssiAdjustVal =0; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67))); - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8192e1ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // sw all off - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - // hw all off - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -BOOLEAN -halbtc8192e1ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); - - //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); - - //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - - //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); - - //halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else - { - if (bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - } - - bCommon = FALSE; - } - - return bCommon; -} - - -VOID -halbtc8192e1ant_TdmaDurationAdjustForAcl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - static BOOLEAN bPreWifiBusy=FALSE; - BOOLEAN bWifiBusy = FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); - - if(BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) - bWifiBusy = TRUE; - else - bWifiBusy = FALSE; - - if( (BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 3 && - pCoexDm->curPsTdma != 9 ) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { - if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if(result == 1) - { - if( (BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - else //no change - { - /* Bryant Modify - if(bWifiBusy != bPreWifiBusy) //if busy / idle change - { - bPreWifiBusy = bWifiBusy; - halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma); - } - */ - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 9 && - pCoexDm->curPsTdma != 11 ) - { - // recover to previous adjust type - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8192e1ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8192e1ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8192e1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8192e1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - -VOID -halbtc8192e1ant_ActionWifiOnly( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); -} - -VOID -halbtc8192e1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - halbtc8192e1ant_ActionWifiOnly(pBtCoexist); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -//============================================= -// -// Software Coex Mechanism start -// -//============================================= - -// SCO only or SCO+PAN(HS) - -/* -VOID -halbtc8192e1ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); -} - - -VOID -halbtc8192e1ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8192e1ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8192e1ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8192e1ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(HS) only -VOID -halbtc8192e1ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(EDR)+A2DP -VOID -halbtc8192e1ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8192e1ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8192e1ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8192e1ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); -} - -*/ - -//============================================= -// -// Non-Software Coex Mechanism start -// -//============================================= -VOID -halbtc8192e1ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8192e1ant_ActionHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8192e1ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask)) - { - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - // SCO/HID/A2DP busy - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if ((pBtLinkInfo->bPanExist) || (bWifiBusy)) - { - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } -} - -VOID -halbtc8192e1ant_ActionBtScoHidOnlyBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // tdma and coex table - - if(pBtLinkInfo->bScoExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else //HID - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } -} - -VOID -halbtc8192e1ant_ActionWifiConnectedBtAclBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - u1Byte btRssiState; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - btRssiState = halbtc8192e1ant_BtRssiState(2, 28, 0); - - if ( (pCoexSta->lowPriorityRx >= 1000) && (pCoexSta->lowPriorityRx != 65535) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - if(pBtLinkInfo->bHidOnly) //HID - { - halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); - pCoexDm->bAutoTdmaAdjust = FALSE; - return; - } - else if(pBtLinkInfo->bA2dpOnly) //A2DP - { - if(BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - halbtc8192e1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); -#if 0 - if (pCoexSta->bCCKLock) - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else -#endif - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = TRUE; - } - } - else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || - (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->bAutoTdmaAdjust = FALSE; - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - //BT no-profile busy (0x9) - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } -} - -VOID -halbtc8192e1ant_ActionWifiNotConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8192e1ant_ActionWifiNotConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8192e1ant_ActionWifiNotConnectedAssoAuth( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bPanExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8192e1ant_ActionWifiConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8192e1ant_ActionWifiConnectedSpecialPacket( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if(pBtLinkInfo->bPanExist) - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8192e1ant_ActionWifiConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiBusy=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - BOOLEAN bUnder4way=FALSE, bApEnable=FALSE; - u4Byte wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - if(bUnder4way) - { - halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - if(bScan || bLink || bRoam) - { - if(bScan) - halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist); - else - halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - // power save state - if(!bApEnable && BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) - { - if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP - { - if(!bWifiBusy) - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else //busy - { - if (pCoexSta->nScanAPNum >= BT_8192E_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA - { - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - } - } - else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE)) - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - else - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(!bWifiBusy) - { - if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else - { - if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8192e1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else if( (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8192e1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else - { - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } -} - -VOID -halbtc8192e1ant_RunSwCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm=0; - - algorithm = halbtc8192e1ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - - if(halbtc8192e1ant_IsCommonAction(pBtCoexist)) - { - - } - else - { - switch(pCoexDm->curAlgorithm) - { - case BT_8192E_1ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n")); - //halbtc8192e1ant_ActionSco(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n")); - //halbtc8192e1ant_ActionHid(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n")); - //halbtc8192e1ant_ActionA2dp(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); - //halbtc8192e1ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n")); - //halbtc8192e1ant_ActionPanEdr(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n")); - //halbtc8192e1ant_ActionPanHs(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); - //halbtc8192e1ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); - //halbtc8192e1ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); - //halbtc8192e1ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8192E_1ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n")); - //halbtc8192e1ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n")); - //halbtc8192e1ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8192e1ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - BOOLEAN bIncreaseScanDevNum=FALSE; - BOOLEAN bBtCtrlAggBufSize=FALSE; - BOOLEAN bMiracastPlusBt=FALSE; - u1Byte aggBufSize=5; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bIncreaseScanDevNum = TRUE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - bMiracastPlusBt = TRUE; - } - else - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - bMiracastPlusBt = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - - if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8192e1ant_ActionBtInquiry(pBtCoexist); - } - else - halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) ) - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - - if(pBtLinkInfo->bScoExist) - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5); - else - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - halbtc8192e1ant_SwMechanism(pBtCoexist, TRUE); - halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message - } - else - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - halbtc8192e1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8192e1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8192e1ant_ActionHs(pBtCoexist); - return; - } - - - if(!bWifiConnected) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - if (bScan) - halbtc8192e1ant_ActionWifiNotConnectedScan(pBtCoexist); - else - halbtc8192e1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else - halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist); - } - else // wifi LPS/Busy - { - halbtc8192e1ant_ActionWifiConnected(pBtCoexist); - } -} - -VOID -halbtc8192e1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - // sw all off - halbtc8192e1ant_SwMechanism(pBtCoexist, FALSE); - - //halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - pCoexSta->popEventCnt = 0; -} - -VOID -halbtc8192e1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - // antenna sw ctrl to bt - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE); - - halbtc8192e1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // antenna switch control parameter - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0x55555555); - - // coex parameters - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - // enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // enable PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); - // enable mailbox interface - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x40); - u2Tmp |= BIT9; - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x40, u2Tmp); - - // enable PTA I2C mailbox - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x101); - u1Tmp |= BIT4; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x101, u1Tmp); - - // enable bt clock when wifi is disabled. - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x93); - u1Tmp |= BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x93, u1Tmp); - // enable bt clock when suspend. - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7); - u1Tmp |= BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp); -} - - -/* -VOID -halbtc8192e1ant_WifiOffHwCfg( - IN PBTC_COEXIST pBtCoexist - ) -{ - // set wlan_act to low - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); -} -*/ - -//============================================================ -// work around function start with wa_halbtc8192e1ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8192e1ant_ -//============================================================ -VOID -EXhalbtc8192e1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -#if 0 - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x0; - u2Byte u2Tmp=0x0; - - pBtCoexist->bStopCoexDm = TRUE; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20); - - // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1); - - // set GRAN_BT = 1 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - // set WLAN_ACT = 0 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - // set to S1 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - u1Tmp |= 0x1; // antenna inverse - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } -#endif -} - -VOID -EXhalbtc8192e1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8192e1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8192e1ant_InitHwConfig(pBtCoexist, bWifiOnly); - pBtCoexist->bStopCoexDm = FALSE; -} - -VOID -EXhalbtc8192e1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - pBtCoexist->bStopCoexDm = FALSE; - - halbtc8192e1ant_InitCoexDm(pBtCoexist); - - halbtc8192e1ant_QueryBtInfo(pBtCoexist); -} - -VOID -EXhalbtc8192e1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - if(pBtCoexist->bStopCoexDm) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - if(!pBtCoexist->bManualControl) - { - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ - (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), - pBtCoexist->btInfo.aggBufSize); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \ - pCoexDm->errorCondition); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \ - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc04); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xd04); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x90c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x92c); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \ - (u1Tmp[0]), u4Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4f); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \ - u1Tmp[0], u1Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 1) - halbtc8192e1ant_MonitorBtCtr(pBtCoexist); -#endif - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - -VOID -EXhalbtc8192e1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp=0; - - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - - halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8192e1ant_InitCoexDm(pBtCoexist); - halbtc8192e1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8192e1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8192e1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - u1Byte u1Tmpa, u1Tmpb; - u4Byte u4Tmp; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm ) - return; - - if(BTC_SCAN_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - - halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } - - if(pBtCoexist->btInfo.bBtDisabled) - return; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - halbtc8192e1ant_QueryBtInfo(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8192e1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8192e1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_SCAN_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8192e1ant_ActionWifiNotConnectedScan(pBtCoexist); - } - else // wifi is connected - { - halbtc8192e1ant_ActionWifiConnectedScan(pBtCoexist); - } - } - else if(BTC_SCAN_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8192e1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8192e1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_ASSOCIATE_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - pCoexDm->nArpCnt = 0; - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - //pCoexDm->nArpCnt = 0; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8192e1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8192e1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_ASSOCIATE_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - halbtc8192e1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8192e1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8192e1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8192e1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - BOOLEAN bWifiUnderBMode = FALSE; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - //Set CCK Tx/Rx high Pri except 11b mode - if (bWifiUnderBMode) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx - } - - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - pCoexDm->nArpCnt = 0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - //H2C_Parameter[0] = 0x1; - H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8192e1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - if(BTC_PACKET_ARP == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n")); - - pCoexDm->nArpCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); - - if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type)); - } - - pCoexSta->specialPktPeriodCnt = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8192e1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8192e1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8192e1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8192e1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8192e1ant_ActionHs(pBtCoexist); - return; - } - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) ) - { - halbtc8192e1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - } -} - -VOID -EXhalbtc8192e1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bBtBusy=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8192E_1ANT_MAX) - rspSource = BT_INFO_SRC_8192E_1ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8192E_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btRetryCnt >= 1) - pCoexSta->popEventCnt++; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtPage = TRUE; - else - pCoexSta->bC2hBtPage = FALSE; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2-90; - //pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if(!pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if(pCoexSta->btInfoExt & BIT1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if(pCoexSta->btInfoExt & BIT3) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8192e1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8192E_1ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8192E_1ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8192E_1ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8192E_1ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8192E_1ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - } - - halbtc8192e1ant_UpdateBtLinkInfo(pBtCoexist); - - btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) - - if(!(btInfo&BT_INFO_8192E_1ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8192E_1ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8192E_1ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8192E_1ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8192E_1ANT_B_ACL_BUSY) - { - if(BT_8192E_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8192E_1ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8192E_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - bBtBusy = TRUE; - else - bBtBusy = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - halbtc8192e1ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8192e1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa,u1Tmpb, u1Tmpc; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n")); - - if(BTC_RF_ON == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n")); - pBtCoexist->bStopCoexDm = FALSE; - } - else if(BTC_RF_OFF == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n")); - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - - halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - pBtCoexist->bStopCoexDm = TRUE; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u1Tmpc = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb, u1Tmpc)); - - } -} - -VOID -EXhalbtc8192e1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - - halbtc8192e1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - pBtCoexist->bStopCoexDm = TRUE; -} - -VOID -EXhalbtc8192e1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8192e1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8192e1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - - pBtCoexist->bStopCoexDm = TRUE; - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - pBtCoexist->bStopCoexDm = FALSE; - halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8192e1ant_InitCoexDm(pBtCoexist); - halbtc8192e1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8192e1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n")); - - halbtc8192e1ant_InitHwConfig(pBtCoexist, FALSE); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0); - halbtc8192e1ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8192e1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8192e1Ant, GLCoexVer8192e1Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8192E_1ANT == 0) - halbtc8192e1ant_QueryBtInfo(pBtCoexist); - halbtc8192e1ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8192e1ant_MonitorBtCtr(pBtCoexist); - halbtc8192e1ant_MonitorWiFiCtr(pBtCoexist); - - if( halbtc8192e1ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust ) - { - - halbtc8192e1ant_RunCoexistMechanism(pBtCoexist); - } - - pCoexSta->specialPktPeriodCnt++; -#endif -} - - -VOID -EXhalbtc8192e1ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ) -{ - switch(opCode) - { - case BTC_DBG_SET_COEX_NORMAL: - pBtCoexist->bManualControl = FALSE; - halbtc8192e1ant_InitCoexDm(pBtCoexist); - break; - case BTC_DBG_SET_COEX_WIFI_ONLY: - pBtCoexist->bManualControl = TRUE; - halbtc8192e1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - break; - case BTC_DBG_SET_COEX_BT_ONLY: - // todo - break; - default: - break; - } -} - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.h deleted file mode 100644 index 8c06cff12..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e1Ant.h +++ /dev/null @@ -1,255 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8192E 1ANT BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8192E_1ANT 1 - -#define BT_INFO_8192E_1ANT_B_FTP BIT7 -#define BT_INFO_8192E_1ANT_B_A2DP BIT6 -#define BT_INFO_8192E_1ANT_B_HID BIT5 -#define BT_INFO_8192E_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8192E_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8192E_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8192E_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8192E_1ANT_B_CONNECTION BIT0 - -#define BT_INFO_8192E_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8192E_1ANT 2 - -#define BT_8192E_1ANT_WIFI_NOISY_THRESH 30 //max: 255 - -typedef enum _BT_INFO_SRC_8192E_1ANT{ - BT_INFO_SRC_8192E_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8192E_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8192E_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8192E_1ANT_MAX -}BT_INFO_SRC_8192E_1ANT,*PBT_INFO_SRC_8192E_1ANT; - -typedef enum _BT_8192E_1ANT_BT_STATUS{ - BT_8192E_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8192E_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8192E_1ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8192E_1ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8192E_1ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8192E_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8192E_1ANT_BT_STATUS_MAX -}BT_8192E_1ANT_BT_STATUS,*PBT_8192E_1ANT_BT_STATUS; - -typedef enum _BT_8192E_1ANT_WIFI_STATUS{ - BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8192E_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, - BT_8192E_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, - BT_8192E_1ANT_WIFI_STATUS_MAX -}BT_8192E_1ANT_WIFI_STATUS,*PBT_8192E_1ANT_WIFI_STATUS; - -typedef enum _BT_8192E_1ANT_COEX_ALGO{ - BT_8192E_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8192E_1ANT_COEX_ALGO_SCO = 0x1, - BT_8192E_1ANT_COEX_ALGO_HID = 0x2, - BT_8192E_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8192E_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8192E_1ANT_COEX_ALGO_PANEDR = 0x5, - BT_8192E_1ANT_COEX_ALGO_PANHS = 0x6, - BT_8192E_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8192E_1ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8192E_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8192E_1ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8192E_1ANT_COEX_ALGO_MAX = 0xb, -}BT_8192E_1ANT_COEX_ALGO,*PBT_8192E_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8192E_1ANT{ - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; - u4Byte nArpCnt; - - u1Byte errorCondition; -} COEX_DM_8192E_1ANT, *PCOEX_DM_8192E_1ANT; - -typedef struct _COEX_STA_8192E_1ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte specialPktPeriodCnt; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - s1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8192E_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8192E_1ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtPage; //Add for win8.1 page out issue - BOOLEAN bWiFiIsHighPriTask; //Add for win8.1 page out issue - u1Byte btRetryCnt; - u1Byte btInfoExt; - u4Byte popEventCnt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - BOOLEAN bCCKLock; - BOOLEAN bPreCCKLock; - u1Byte nCoexTableType; - - BOOLEAN bForceLpsOn; -}COEX_STA_8192E_1ANT, *PCOEX_STA_8192E_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8192e1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8192e1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8192e1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8192e1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e1ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.c deleted file mode 100644 index 481e87768..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.c +++ /dev/null @@ -1,5028 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8192E Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8192E_2ANT GLCoexDm8192e2Ant; -static PCOEX_DM_8192E_2ANT pCoexDm=&GLCoexDm8192e2Ant; -static COEX_STA_8192E_2ANT GLCoexSta8192e2Ant; -static PCOEX_STA_8192E_2ANT pCoexSta=&GLCoexSta8192e2Ant; - -const char *const GLBtInfoSrc8192e2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8192e2Ant=20150615; -u4Byte GLCoexVer8192e2Ant=0x41; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8192e2ant_ -//============================================================ -u1Byte -halbtc8192e2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8192e2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8192e2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - } - } -} - -u4Byte -halbtc8192e2ant_DecideRaMask( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte ssType, - IN u4Byte raMaskType - ) -{ - u4Byte disRaMask=0x0; - - switch(raMaskType) - { - case 0: // normal mode - if(ssType == 2) - disRaMask = 0x0; // enable 2ss - else - disRaMask = 0xfff00000; // disable 2ss - break; - case 1: // disable cck 1/2 - if(ssType == 2) - disRaMask = 0x00000003; // enable 2ss - else - disRaMask = 0xfff00003; // disable 2ss - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - if(ssType == 2) - disRaMask = 0x0001f1f7; // enable 2ss - else - disRaMask = 0xfff1f1f7; // disable 2ss - break; - default: - break; - } - - return disRaMask; -} - -VOID -halbtc8192e2ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8192e2ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8192e2ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8192e2ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8192e2ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - u4Byte disRaMask=0x0; - - pCoexDm->curRaMaskType = raMaskType; - disRaMask = halbtc8192e2ant_DecideRaMask(pBtCoexist, pCoexDm->curSsType, raMaskType); - halbtc8192e2ant_UpdateRaMask(pBtCoexist, bForceExec, disRaMask); - - halbtc8192e2ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8192e2ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8192e2ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8192e2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8192e2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8192e2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -BOOLEAN -halbtc8192e2ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist,3, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - - if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState )) - { - return TRUE; - } - - } - - return FALSE; -} - -VOID -halbtc8192e2ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8192e2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8192E_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO_PAN; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO_PAN; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8192E_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8192e2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8192e2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte decBtPwrLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = decBtPwrLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n", - decBtPwrLvl, H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); -} - -VOID -halbtc8192e2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte decBtPwrLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n", - (bForceExec? "force to":""), decBtPwrLvl)); - pCoexDm->curBtDecPwrLvl = decBtPwrLvl; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preBtDecPwrLvl=%d, curBtDecPwrLvl=%d\n", - pCoexDm->preBtDecPwrLvl, pCoexDm->curBtDecPwrLvl)); -#if 0 // work around, avoid h2c command fail. - if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) - return; -#endif - } - halbtc8192e2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl); - - pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; -} - -VOID -halbtc8192e2ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8192e2ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreBtAutoReport=%d, bCurBtAutoReport=%d\n", - pCoexDm->bPreBtAutoReport, pCoexDm->bCurBtAutoReport)); - - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8192e2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8192e2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preFwDacSwingLvl=%d, curFwDacSwingLvl=%d\n", - pCoexDm->preFwDacSwingLvl, pCoexDm->curFwDacSwingLvl)); - - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8192e2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8192e2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8192e2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreRfRxLpfShrink=%d, bCurRfRxLpfShrink=%d\n", - pCoexDm->bPreRfRxLpfShrink, pCoexDm->bCurRfRxLpfShrink)); - - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8192e2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8192e2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!")) ); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8192e2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - //return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreLowPenaltyRa=%d, bCurLowPenaltyRa=%d\n", - pCoexDm->bPreLowPenaltyRa, pCoexDm->bCurLowPenaltyRa)); - - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8192e2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8192e2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val); -} - -VOID -halbtc8192e2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8192e2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8192e2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8192e2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreDacSwingOn=%d, preDacSwingLvl=0x%x, bCurDacSwingOn=%d, curDacSwingLvl=0x%x\n", - pCoexDm->bPreDacSwingOn, pCoexDm->preDacSwingLvl, - pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl)); - - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8192e2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8192e2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x1); - } -} - -VOID -halbtc8192e2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreAdcBackOff=%d, bCurAdcBackOff=%d\n", - pCoexDm->bPreAdcBackOff, pCoexDm->bCurAdcBackOff)); - - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8192e2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8192e2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - //=================BB AGC Gain Table - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x0a1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x091B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x081C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x071D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x061E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x051F0001); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001); - } - -#if 0 - //=================RF Gain - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - if(bAgcTableEn) - { - rssiAdjustVal = 8; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -#endif - -} - -VOID -halbtc8192e2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreAgcTableEn=%d, bCurAgcTableEn=%d\n", - pCoexDm->bPreAgcTableEn, pCoexDm->bCurAgcTableEn)); - - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8192e2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8192e2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8192e2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preVal0x6c0=0x%x, preVal0x6c4=0x%x, preVal0x6c8=0x%x, preVal0x6cc=0x%x !!\n", - pCoexDm->preVal0x6c0, pCoexDm->preVal0x6c4, pCoexDm->preVal0x6c8, pCoexDm->preVal0x6cc)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], curVal0x6c0=0x%x, curVal0x6c4=0x%x, curVal0x6c8=0x%x, curVal0x6cc=0x%x !!\n", - pCoexDm->curVal0x6c0, pCoexDm->curVal0x6c4, pCoexDm->curVal0x6c8, pCoexDm->curVal0x6cc)); - - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8192e2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8192e2ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 1: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5ffb5ffb, 0xffffff, 0x3); - break; - case 3: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 4: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xdfffdfff, 0x5ffb5ffb, 0xffffff, 0x3); - break; - case 5: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5ddd5ddd, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 6: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 7: - if(pCoexSta->nScanAPNum <= NOISY_AP_NUM_THRESH) - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xfafafafa, 0xffffff, 0x3); - else - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 8: - halbtc8192e2ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5a5a5a5a, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8192e2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - - -VOID -halbtc8192e2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPreIgnoreWlanAct = %d, bCurIgnoreWlanAct = %d!!\n", - pCoexDm->bPreIgnoreWlanAct, pCoexDm->bCurIgnoreWlanAct)); - - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8192e2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - - -VOID -halbtc8192e2ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - - -VOID -halbtc8192e2ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], preLps/curLps=0x%x/0x%x, preRpwm/curRpwm=0x%x/0x%x!!\n", - pCoexDm->preLps, pCoexDm->curLps, pCoexDm->preRpwm, pCoexDm->curRpwm)); - - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], LPS-RPWM_Last=0x%x , LPS-RPWM_Now=0x%x!!\n", - pCoexDm->preRpwm, pCoexDm->curRpwm)); - - return; - } - } - halbtc8192e2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - - - -VOID -halbtc8192e2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - - -VOID -halbtc8192e2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - /* - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - */ - - halbtc8192e2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - //halbtc8192e2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8192e2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - halbtc8192e2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - //halbtc8192e2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - halbtc8192e2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8192e2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - u4Byte u4Tmp=0; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x944, 0x24); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x930, 0x700700); - if(pBtCoexist->chipInterface == BTC_INTF_USB) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004); - - // 0x4c[27][24]='00', Set Antenna to BB - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &= ~BIT24; - u4Tmp &= ~BIT27; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - else if(bWifiOff) - { - if(pBtCoexist->chipInterface == BTC_INTF_USB) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30430004); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x64, 0x30030004); - - // 0x4c[27][24]='11', Set Antenna to BT, 0x64[8:7]=0, 0x64[2]=1 - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp |= BIT24; - u4Tmp |= BIT27; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4); - break; - case BTC_ANT_PATH_BT: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x20); - break; - default: - case BTC_ANT_PATH_PTA: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x92c, 0x4); - break; - } -} - -VOID -halbtc8192e2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - s1Byte nWiFiDurationAdjust = 0x0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", - pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", - pCoexDm->prePsTdma, pCoexDm->curPsTdma)); - - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum >= 40) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nScanAPNum >= 20) - nWiFiDurationAdjust = -10; - -/* - if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle - } - - - if ( (type == 3) || (type == 13) || (type == 14) ) - { - psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile - - if (!bWifiBusy) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - } - - if (pBtLinkInfo->bSlaveRole == TRUE) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - -*/ - if(bTurnOn) - { - switch(type) - { - case 1: - default: //d1,wb - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x11, 0x10); - break; - case 2: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x11, 0x10); - break; - case 3: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x11, 0x10); - break; - case 4: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x11, 0x10); - break; - case 5: //d1,pb,TXpause - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x3c, 0x03, 0x90, 0x10); - break; - case 6: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x32, 0x03, 0x90, 0x10); - break; - case 7: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x28, 0x03, 0x90, 0x10); - break; - case 8: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x63, 0x1e, 0x03, 0x90, 0x10); - break; - case 9: //d1,bb - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x31, 0x10); - break; - case 10: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x31, 0x10); - break; - case 11: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x31, 0x10); - break; - case 12: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x31, 0x10); - break; - case 13: //d1,bb,TXpause - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x30, 0x10); - break; - case 14: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x30, 0x10); - break; - case 15: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x30, 0x10); - break; - case 16: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x30, 0x10); - break; - case 17: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x03, 0x10, 0x10); - break; - case 18: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x03, 0x11, 0x11); - break; - case 71: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - break; - - // following cases is for wifi rssi low // bad antenna isolation, started from 81 - case 80: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3c, 0x3, 0x90, 0x50); - break; - case 81: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3a+nWiFiDurationAdjust, 0x3, 0x90, 0x50); - break; - case 82: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x30+nWiFiDurationAdjust, 0x03, 0x90, 0x50); - break; - case 83: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x21, 0x03, 0x90, 0x50); - break; - case 84: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x15, 0x3, 0x90, 0x50); - break; - case 85: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3a, 0x03, 0x90, 0x50); - break; - case 86: - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x53, 0x21, 0x03, 0x90, 0x50); - break; - - } - } - else - { - // disable PS tdma - switch(type) - { - default: - case 0: //ANT2PTA, 0x778=1 - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE); - break; - case 1: //ANT2BT, 0x778=3 - halbtc8192e2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - delay_ms(5); - halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE); - break; - - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8192e2ant_SetSwitchSsType( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte ssType - ) -{ - u1Byte mimoPs=BTC_MIMO_PS_DYNAMIC; - u4Byte disRaMask=0x0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], REAL set SS Type = %d\n", ssType)); - - disRaMask = halbtc8192e2ant_DecideRaMask(pBtCoexist, ssType, pCoexDm->curRaMaskType); - halbtc8192e2ant_UpdateRaMask(pBtCoexist, FORCE_EXEC, disRaMask); - - if(ssType == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - // switch ofdm path - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x11); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81111111); - // switch cck patch - //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x1); - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x81); - mimoPs=BTC_MIMO_PS_STATIC; - } - else if(ssType == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xc04, 0x33); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xd04, 0x3); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x90c, 0x81121313); - // remove, if 0xe77[2]=0x0 then CCK will fail, advised by Jenyu - //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xe77, 0x4, 0x0); - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xa07, 0x41); - mimoPs=BTC_MIMO_PS_DYNAMIC; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_SEND_MIMO_PS, &mimoPs); // set rx 1ss or 2ss -} - -VOID -halbtc8192e2ant_SwitchSsType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte newSsType - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], %s Switch SS Type = %d\n", - (bForceExec? "force to":""), newSsType)); - pCoexDm->curSsType = newSsType; - - if(!bForceExec) - { - if(pCoexDm->preSsType == pCoexDm->curSsType) - return; - } - halbtc8192e2ant_SetSwitchSsType(pBtCoexist, pCoexDm->curSsType); - - pCoexDm->preSsType = pCoexDm->curSsType; -} - -VOID -halbtc8192e2ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8192e2ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - psType = BTC_PS_WIFI_NATIVE; - lpsVal = 0x0; - rpwmVal = 0x0; - } - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8192e2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8192e2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8192e2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - - -VOID -halbtc8192e2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8192e2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0); - - halbtc8192e2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - halbtc8192e2ant_SwitchSsType(pBtCoexist, FORCE_EXEC, 2); - - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ -// BOOLEAN bLowPwrDisable=TRUE; - -// pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1); - - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 21); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionWiFiLinkProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - -} - -BOOLEAN -halbtc8192e2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist) - { - halbtc8192e2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 0, 0, 0); - } - else - { - halbtc8192e2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - } - - if(!bWifiConnected) - { -// bLowPwrDisable = FALSE; -// pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n")); - - if( (BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) || - (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { -// bLowPwrDisable = FALSE; -// pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else if(BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) - { -// bLowPwrDisable = TRUE; -// pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bBtHsOn) - return FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8192e2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { -// bLowPwrDisable = TRUE; -// pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - bCommon = FALSE; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 21); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - bCommon = TRUE; - } - } - } - - return bCommon; -} - - -VOID -halbtc8192e2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -VOID -halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow( - IN PBTC_COEXIST pBtCoexist//, - //IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow()\n")); -#if 0 - if( (BT_8192E_2ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8192E_2ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8192E_2ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 81 && - pCoexDm->curPsTdma != 82 && - pCoexDm->curPsTdma != 83 && - pCoexDm->curPsTdma != 84 ) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } -#endif - pCoexDm->bAutoTdmaAdjust = FALSE; - - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if(!pCoexDm->bAutoTdmaAdjustLowRssi) - { - pCoexDm->bAutoTdmaAdjustLowRssi = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjustForWifiRssiLow()!!\n")); - -/* - if(BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else -*/ - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81); - pCoexDm->psTdmaDuAdjType = 81; - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 -// retryCount = pCoexSta->btRetryCnt; -// btInfoExt = pCoexSta->btInfoExt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { -/* - if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) ) - if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) ) - - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84); - pCoexDm->psTdmaDuAdjType = 84; - } -*/ - if(pCoexDm->curPsTdma == 80) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81); - pCoexDm->psTdmaDuAdjType = 81; - } - else if(pCoexDm->curPsTdma == 81) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - else if(pCoexDm->curPsTdma == 82) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else if(pCoexDm->curPsTdma == 83) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84); - pCoexDm->psTdmaDuAdjType = 84; - } - } - else if(result == 1) - { -/* - if( (BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) ) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } -*/ - if(pCoexDm->curPsTdma == 84) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else if(pCoexDm->curPsTdma == 83) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - else if(pCoexDm->curPsTdma == 82) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81); - pCoexDm->psTdmaDuAdjType = 81; - } - else if((pCoexDm->curPsTdma == 81)&&((pCoexSta->nScanAPNum <= NOISY_AP_NUM_THRESH))) - { - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 80); - pCoexDm->psTdmaDuAdjType = 80; - } - - } - - if( pCoexDm->curPsTdma != 80 && - pCoexDm->curPsTdma != 81 && - pCoexDm->curPsTdma != 82 && - pCoexDm->curPsTdma != 83 && - pCoexDm->curPsTdma != 84 ) - { - // recover to previous adjust type - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8192e2ant_GetBtRssiThreshold( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte pThres0, - IN pu1Byte pThres1 - ) -{ - u1Byte antType, btThreshold=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &antType); - - switch(antType) - { - case BTC_ANT_TYPE_0: // 92E with SPDT - *pThres0 = 100; - *pThres1 = 100; - break; - case BTC_ANT_TYPE_1: //92E without SPDT, poor antenna isolation - *pThres0 = 34; - *pThres1 = 42; - break; - case BTC_ANT_TYPE_2: //92E without SPDT, normal antenna isolation - *pThres0 = 34; //92E with coupler, goodl antenna isolation - *pThres1 = 42; - break; - case BTC_ANT_TYPE_3: - *pThres0 = 34; - *pThres1 = 42; - break; - case BTC_ANT_TYPE_4: - *pThres0 = 34; - *pThres1 = 42; - break; - default: - break; - } -} - - -//undefined -VOID -halbtc8192e2ant_ActionUndefined( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // decrease BT power - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - - -// SCO only or SCO+PAN(HS) -VOID -halbtc8192e2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - // halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, TRUE, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - else - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // decrease BT power - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionScoPan( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - - // pstdm - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //shielding room - else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 10); //open space //antenna at BT - else //low RSSI - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); - - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte anttype=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype); - -// halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); -// btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - // power save state & pstdma & coex table - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - - // power save state - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // decrease BT power - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8192e2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte anttype=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype); - -// halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); -// btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - -// anttype = 4; - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); //shielding room - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x06); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - - if( (btRssiState == BTC_RSSI_STATE_LOW) || - (btRssiState == BTC_RSSI_STATE_STAY_LOW) ) - { - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) || - (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ) - { - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 2); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - } - else if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 2); - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); //shielding room - else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); //open space //antenna at BT - else //low RSSI - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 85); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -//PAN(HS) only -VOID -halbtc8192e2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - -// halbtc8192e2ant_SwitchSsType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - - if( (btRssiState == BTC_RSSI_STATE_LOW) || - (btRssiState == BTC_RSSI_STATE_STAY_LOW) ) - { - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - else if( (btRssiState == BTC_RSSI_STATE_MEDIUM) || - (btRssiState == BTC_RSSI_STATE_STAY_MEDIUM) ) - { - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - } - else if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - } - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -//PAN(EDR)+A2DP -VOID -halbtc8192e2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); //shielding room - else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); //open space //antenna at BT - else //low RSSI -{ - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); -} - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdm - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //shielding room - else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); //open space //antenna at BT - else //low RSSI - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8192e2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - // btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - // power save state - if((BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); //6 - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); //shielding room - else if (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); //open space //antenna at BT - else //low RSSI - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); - } - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0, anttype=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &anttype); - - // halbtc8192e2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - // btRssiState = halbtc8192e2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8192e2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8192e2ant_BtRssiState(3, 34, 42); - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8192e2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8192e2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8192e2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8192e2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH) // BT HIGH RSSI & shielding room - halbtc8192e2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - - // limited Rx - halbtc8192e2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8192e2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - // sw mechanism - halbtc8192e2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); //shielding room - else if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH)) - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x06); //open space - else //low RSSI - halbtc8192e2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8192e2ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - -} - -VOID -halbtc8192e2ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - -} - -VOID -halbtc8192e2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiUnder5G=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - algorithm = halbtc8192e2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8192E_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8192e2ant_ActionBtInquiry(pBtCoexist); - return; - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8192e2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8192E_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8192e2ant_ActionSco(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_SCO_PAN: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO+PAN(EDR).\n")); - halbtc8192e2ant_ActionScoPan(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8192e2ant_ActionHid(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8192e2ant_ActionA2dp(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8192e2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8192e2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8192e2ant_ActionPanHs(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8192e2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8192e2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8192e2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8192E_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8192e2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = undefined!!\n")); - halbtc8192e2ant_ActionUndefined(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8192e2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp - ) -{ - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - if(bBackUp) - { - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - - // antenna sw ctrl to bt - halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE); - - halbtc8192e2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // antenna switch control parameter - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0x55555555); - - // coex parameters - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - // enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // enable PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); - // enable mailbox interface - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x40); - u2Tmp |= BIT9; - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x40, u2Tmp); - - // enable PTA I2C mailbox - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x101); - u1Tmp |= BIT4; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x101, u1Tmp); - - // enable bt clock when wifi is disabled. - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x93); - u1Tmp |= BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x93, u1Tmp); - // enable bt clock when suspend. - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7); - u1Tmp |= BIT0; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp); -} - -//============================================================ -// work around function start with wa_halbtc8192e2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8192e2ant_ -//============================================================ -VOID -EXhalbtc8192e2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8192e2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8192e2ant_InitHwConfig(pBtCoexist, TRUE); -} - -VOID -EXhalbtc8192e2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8192e2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8192e2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u2Byte u2Tmp[4]; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Antenna type:", \ - pBoardInfo->antType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8192e2Ant, GLCoexVer8192e2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8192e2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } -/* - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "SS Type", \ - pCoexDm->curSsType); - CL_PRINTF(cliBuf); -*/ - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \ - pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \ - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc04); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xd04); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x90c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xc04/ 0xd04/ 0x90c", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x92c); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x92c/ 0x930", \ - (u1Tmp[0]), u4Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4f); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x40/ 0x4f", \ - u1Tmp[0], u1Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 1) - halbtc8192e2ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8192e2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8192e2ant_CoexAllOff(pBtCoexist); - halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - } -} - -VOID -EXhalbtc8192e2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8192e2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - - } -} - -VOID -EXhalbtc8192e2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8192e2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8192e2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8192e2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8192E_2ANT_MAX) - rspSource = BT_INFO_SRC_8192E_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8192E_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - if(bWifiConnected) - { - EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if( (pCoexSta->btInfoExt & BIT3) ) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8192e2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } - -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8192e2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8192E_2ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8192E_2ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8192E_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8192E_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8192E_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8192E_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - } - - halbtc8192e2ant_UpdateBtLinkInfo(pBtCoexist); - - if(!(btInfo&BT_INFO_8192E_2ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8192E_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8192E_2ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8192E_2ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8192E_2ANT_B_ACL_BUSY) - { - pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8192E_2ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8192E_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8192E_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bBtBusy = TRUE; - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8192e2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8192e2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8192e2ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - halbtc8192e2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8192e2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8192e2Ant, GLCoexVer8192e2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8192E_2ANT == 0) - halbtc8192e2ant_QueryBtInfo(pBtCoexist); - halbtc8192e2ant_MonitorBtCtr(pBtCoexist); - halbtc8192e2ant_MonitorBtEnableDisable(pBtCoexist); -#else - if( halbtc8192e2ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust) - { - halbtc8192e2ant_RunCoexistMechanism(pBtCoexist); - } -#endif -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.h deleted file mode 100644 index d8e66140e..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8192e2Ant.h +++ /dev/null @@ -1,232 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8192E 2Ant BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8192E_2ANT 0 - -#define BT_INFO_8192E_2ANT_B_FTP BIT7 -#define BT_INFO_8192E_2ANT_B_A2DP BIT6 -#define BT_INFO_8192E_2ANT_B_HID BIT5 -#define BT_INFO_8192E_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8192E_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8192E_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8192E_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8192E_2ANT_B_CONNECTION BIT0 - -#define BT_INFO_8192E_2ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8192E_2ANT 2 -#define NOISY_AP_NUM_THRESH 5 - -typedef enum _BT_INFO_SRC_8192E_2ANT{ - BT_INFO_SRC_8192E_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8192E_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8192E_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8192E_2ANT_MAX -}BT_INFO_SRC_8192E_2ANT,*PBT_INFO_SRC_8192E_2ANT; - -typedef enum _BT_8192E_2ANT_BT_STATUS{ - BT_8192E_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8192E_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8192E_2ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8192E_2ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8192E_2ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8192E_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8192E_2ANT_BT_STATUS_MAX -}BT_8192E_2ANT_BT_STATUS,*PBT_8192E_2ANT_BT_STATUS; - -typedef enum _BT_8192E_2ANT_COEX_ALGO{ - BT_8192E_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8192E_2ANT_COEX_ALGO_SCO = 0x1, - BT_8192E_2ANT_COEX_ALGO_SCO_PAN = 0x2, - BT_8192E_2ANT_COEX_ALGO_HID = 0x3, - BT_8192E_2ANT_COEX_ALGO_A2DP = 0x4, - BT_8192E_2ANT_COEX_ALGO_A2DP_PANHS = 0x5, - BT_8192E_2ANT_COEX_ALGO_PANEDR = 0x6, - BT_8192E_2ANT_COEX_ALGO_PANHS = 0x7, - BT_8192E_2ANT_COEX_ALGO_PANEDR_A2DP = 0x8, - BT_8192E_2ANT_COEX_ALGO_PANEDR_HID = 0x9, - BT_8192E_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0xa, - BT_8192E_2ANT_COEX_ALGO_HID_A2DP = 0xb, - BT_8192E_2ANT_COEX_ALGO_MAX = 0xc -}BT_8192E_2ANT_COEX_ALGO,*PBT_8192E_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8192E_2ANT{ - // fw mechanism - u1Byte preBtDecPwrLvl; - u1Byte curBtDecPwrLvl; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bAutoTdmaAdjustLowRssi; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u1Byte preSsType; - u1Byte curSsType; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte curRaMaskType; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; -} COEX_DM_8192E_2ANT, *PCOEX_DM_8192E_2ANT; - -typedef struct _COEX_STA_8192E_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8192E_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8192E_2ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - u1Byte nCoexTableType; - BOOLEAN bForceLpsOn; - - u1Byte disVerInfoCnt; -}COEX_STA_8192E_2ANT, *PCOEX_STA_8192E_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8192e2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8192e2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8192e2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8192e2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8192e2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.c deleted file mode 100644 index 766da8ac9..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.c +++ /dev/null @@ -1,5239 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8703B Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8703b1Ant.tmh" -#endif - -#if (RTL8703B_SUPPORT == 1) - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8703B_1ANT GLCoexDm8703b1Ant; -static PCOEX_DM_8703B_1ANT pCoexDm=&GLCoexDm8703b1Ant; -static COEX_STA_8703B_1ANT GLCoexSta8703b1Ant; -static PCOEX_STA_8703B_1ANT pCoexSta=&GLCoexSta8703b1Ant; -static PSDSCAN_STA_8703B_1ANT GLPsdScan8703b1Ant; -static PPSDSCAN_STA_8703B_1ANT pPsdScan = &GLPsdScan8703b1Ant; - - -const char *const GLBtInfoSrc8703b1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8703b1Ant=20150904; -u4Byte GLCoexVer8703b1Ant=0x04; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8703b1ant_ -//============================================================ -u1Byte -halbtc8703b1ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8703b1ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8703b1ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8703b1ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8703b1ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8703b1ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8703b1ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8703b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8703b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8703b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8703b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8703b1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8703b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8703b1ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8703b1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -VOID -halbtc8703b1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp, u1Tmp1; - s4Byte wifiRssi; - static u1Byte NumOfBtCounterChk = 0; - - //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS - //if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) ) - - if (pCoexSta->bUnderIps) - { - //pCoexSta->highPriorityTx = 65535; - //pCoexSta->highPriorityRx = 65535; - //pCoexSta->lowPriorityTx = 65535; - //pCoexSta->lowPriorityRx = 65535; - //return; - } - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if( (pCoexSta->lowPriorityTx > 1150) && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->popEventCnt++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", - regHPRx, regHPTx, regLPRx, regLPTx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); - - if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0)) - { - NumOfBtCounterChk++; - if (NumOfBtCounterChk >= 3) - { - halbtc8703b1ant_QueryBtInfo(pBtCoexist); - NumOfBtCounterChk = 0; - } - } -} - - -VOID -halbtc8703b1ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - u4Byte TotalCnt; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); - - if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode)) - { - TotalCnt = pCoexSta->nCRCOK_CCK + pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + - pCoexSta->nCRCOK_11nAgg; - - if ( (pCoexDm->btStatus == BT_8703B_1ANT_BT_STATUS_ACL_BUSY) || - (pCoexDm->btStatus == BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY) || - (pCoexDm->btStatus == BT_8703B_1ANT_BT_STATUS_SCO_BUSY) ) - { - if (pCoexSta->nCRCOK_CCK >(TotalCnt -pCoexSta->nCRCOK_CCK)) - { - if (nCCKLockCounter < 3) - nCCKLockCounter++; - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - if (!pCoexSta->bPreCCKLock) - { - - if (nCCKLockCounter >= 3) - pCoexSta->bCCKLock = TRUE; - else - pCoexSta->bCCKLock = FALSE; - } - else - { - if (nCCKLockCounter == 0) - pCoexSta->bCCKLock = FALSE; - else - pCoexSta->bCCKLock = TRUE; - } - - if (pCoexSta->bCCKLock) - pCoexSta->bCCKEverLock = TRUE; - - pCoexSta->bPreCCKLock = pCoexSta->bCCKLock; - - -} - -BOOLEAN -halbtc8703b1ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - } - - return FALSE; -} - -VOID -halbtc8703b1ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - pBtLinkInfo->bBtHiPriLinkExist = pCoexSta->bBtHiPriLinkExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -VOID -halbtc8703b1ant_UpdateWifiChannelInfo( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - BOOLEAN bWifiUnderBMode = FALSE; - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; //enable BT AFH skip WL channel for 8703b because BT Rx LO interference - //H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); - -} - -u1Byte -halbtc8703b1ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8703B_1ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID_A2DP; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8703B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8703b1ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8703b1ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8703b1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID halbtc8703b1ant_WriteScoreBoard( - IN PBTC_COEXIST pBtCoexist, - IN u2Byte scoreboardval - ) -{ - u2Byte val; - - val = (scoreboardval & 0x7fff) | 0x8000; - - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0xaa, val); - -#if 0 - u1Byte H2C_Parameter[3] ={0,0,0}; - - - // write "Set Status" - H2C_Parameter[0] = 0x2; - - // write score board 15-bit value to H2C parameter - H2C_Parameter[1] = scoreboardval & 0xff; - H2C_Parameter[2] = (scoreboardval & 0x7f00) >> 8; - - // Set Interrupt to BT - H2C_Parameter[2] = H2C_Parameter[2] | 0x80; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Write BT Scoreboard: H2C 0x71[1:0]= %02x%02x\n", - H2C_Parameter[2], H2C_Parameter[1])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x71, 3, H2C_Parameter); - -#endif -} - -VOID halbtc8703b1ant_ReadScoreBoard( - IN PBTC_COEXIST pBtCoexist, - IN u2Byte* uScoreBoardVal - ) -{ - - *uScoreBoardVal = (pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xaa)) & 0x7fff; - - - -#if 0 - u1Byte H2C_Parameter[3] ={0,0,0}; - - // write "Get Status" - H2C_Parameter[0] = 0x1; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Read BT Scoreboard!!\n")); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x71, 3, H2C_Parameter); - - //the BT Scoreboard will be returned by C2H from EXhalbtc8703b1ant_ScoreBoardStatusNotify() -#endif -} - -VOID halbtc8703b1ant_PostActiveStateToBT( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiActive - ) -{ - - if(bWifiActive) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Post WL = Active in Scoreboard!!\n")); - halbtc8703b1ant_WriteScoreBoard(pBtCoexist, 0x0001); - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Post WL = Non-Active in Scoreboard!!\n")); - halbtc8703b1ant_WriteScoreBoard(pBtCoexist, 0x0000); - } - - // The BT should set "No Shunt-down" mode if WL = Active for BT Synthesizer on/off interference WL Lo issue at 8703b b-cut. - -} - -VOID -halbtc8703b1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!") )); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8703b1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8703b1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -u4Byte -halbtc8703b1ant_LTECoex_InDirectReadReg( -IN PBTC_COEXIST pBtCoexist, -IN u2Byte RegAddr -) -{ - u4Byte j =0; - - - //wait for ready bit before access 0x7c0 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x7c0, 0x800F0000|RegAddr); - - do - { - j++; - }while( ((pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7c3) & BIT5) ==0) && (j fBtcRead4Byte(pBtCoexist, 0x7c8)); //get read data - -} - -VOID -halbtc8703b1ant_LTECoex_InDirectWriteReg( -IN PBTC_COEXIST pBtCoexist, -IN u2Byte RegAddr, -IN u4Byte BitMask, -IN u4Byte RegValue -) -{ - u4Byte val, i=0, j=0, bitpos = 0; - - - if (BitMask == 0x0) - return; - if (BitMask == 0xffffffff) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x7c4, RegValue); //put write data - - //wait for ready bit before access 0x7c0 - do - { - j++; - }while( ((pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7c3) & BIT5) ==0) && (j fBtcWrite4Byte(pBtCoexist, 0x7c0, 0xc00F0000|RegAddr); - } - else - { - for(i=0; i<=31; i++) - { - if ( ((BitMask >> i) & 0x1) == 0x1) - { - bitpos = i; - break; - } - } - - //read back register value before write - val = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, RegAddr); - val = (val & (~BitMask)) | (RegValue << bitpos); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x7c4, val); //put write data - - //wait for ready bit before access 0x7c0 - do - { - j++; - }while( ((pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7c3) & BIT5) ==0) && (j fBtcWrite4Byte(pBtCoexist, 0x7c0, 0xc00F0000|RegAddr); - - } - -} - -void -halbtc8703b1ant_LTECoex_Enable( -IN PBTC_COEXIST pBtCoexist, -IN BOOLEAN bEnable -) -{ - u1Byte val; - - val = (bEnable)? 1 : 0; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, 0x80, val); //0x38[7] - -} - -void -halbtc8703b1ant_LTECoex_PathControlOwner( -IN PBTC_COEXIST pBtCoexist, -IN BOOLEAN bWiFiControl -) -{ - u1Byte val; - - val = (bWiFiControl)? 1 : 0; - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x73, 0x4, val); //0x70[26] - -} - -void -halbtc8703b1ant_LTECoex_Set_GNT_BT( -IN PBTC_COEXIST pBtCoexist, -IN u1Byte nControlBlock, -IN BOOLEAN bSWControl, -IN u1Byte nState -) -{ - u4Byte val=0, BitMask; - - nState = nState & 0x1; - val = (bSWControl)? ((nState<<1) | 0x1) : 0; - - switch(nControlBlock) - { - case BT_8703B_1ANT_GNT_BLOCK_RFC_BB: - default: - BitMask = 0xc000; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[15:14] - BitMask = 0x0c00; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[11:10] - break; - case BT_8703B_1ANT_GNT_BLOCK_RFC: - BitMask = 0xc000; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[15:14] - break; - case BT_8703B_1ANT_GNT_BLOCK_BB: - BitMask = 0x0c00; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[11:10] - break; - - } - -} - -void -halbtc8703b1ant_LTECoex_Set_GNT_WL( -IN PBTC_COEXIST pBtCoexist, -IN u1Byte nControlBlock, -IN BOOLEAN bSWControl, -IN u1Byte nState -) -{ - u4Byte val=0, BitMask; - - nState = nState & 0x1; - val = (bSWControl)? ((nState<<1) | 0x1) : 0; - - switch(nControlBlock) - { - case BT_8703B_1ANT_GNT_BLOCK_RFC_BB: - default: - BitMask = 0x3000; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[13:12] - BitMask = 0x0300; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[9:8] - break; - case BT_8703B_1ANT_GNT_BLOCK_RFC: - BitMask = 0x3000; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[13:12] - break; - case BT_8703B_1ANT_GNT_BLOCK_BB: - BitMask = 0x0300; - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, 0x38, BitMask, val); // 0x38[9:8] - break; - - } - -} - -void -halbtc8703b1ant_LTECoex_Set_CoexTable( -IN PBTC_COEXIST pBtCoexist, -IN u1Byte nTableType, -IN u2Byte nTableContent -) -{ - u2Byte RegAddr = 0x0000; - - switch(nTableType) - { - case BT_8703B_1ANT_CTT_WL_VS_LTE: - RegAddr = 0xa0; - break; - case BT_8703B_1ANT_CTT_BT_VS_LTE: - RegAddr = 0xa4; - break; - } - - if (RegAddr != 0x0000) - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, RegAddr, 0xffff, nTableContent); // 0xa0[15:0] or 0xa4[15:0] - - -} - - -void -halbtc8703b1ant_LTECoex_Set_BreakTable( -IN PBTC_COEXIST pBtCoexist, -IN u1Byte nTableType, -IN u1Byte nTableContent -) -{ - u2Byte RegAddr = 0x0000; - - switch(nTableType) - { - case BT_8703B_1ANT_LBTT_WL_BREAK_LTE: - RegAddr = 0xa8; - break; - case BT_8703B_1ANT_LBTT_BT_BREAK_LTE: - RegAddr = 0xac; - break; - case BT_8703B_1ANT_LBTT_LTE_BREAK_WL: - RegAddr = 0xb0; - break; - case BT_8703B_1ANT_LBTT_LTE_BREAK_BT: - RegAddr = 0xb4; - break; - } - - if (RegAddr != 0x0000) - halbtc8703b1ant_LTECoex_InDirectWriteReg(pBtCoexist, RegAddr, 0xff, nTableContent); // 0xa8[15:0] or 0xb4[15:0] - - -} - -VOID -halbtc8703b1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8703b1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8703b1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8703b1ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - u4Byte nBreakTable; - u1Byte nSelectTable; - - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); - - pCoexSta->nCoexTableType = type; - - if (pCoexSta->bConCurrentRxModeOn == TRUE) - { - nBreakTable = 0xf0ffffff; //set WL hi-pri can break BT - nSelectTable = 0xb; //set Tx response = Hi-Pri (ex: Transmitting ACK,BA,CTS) - } - else - { - nBreakTable = 0xffffff; - nSelectTable = 0x3; - } - - switch(type) - { - case 0: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, nBreakTable, nSelectTable); - break; - case 1: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, nBreakTable, nSelectTable); - break; - case 2: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaa5a5a5a, 0xaa5a5a5a, nBreakTable, nSelectTable); - break; - case 3: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaa555555, 0xaa5a5a5a, nBreakTable, nSelectTable); - break; - case 4: - //if ( (pCoexSta->bCCKEverLock) && (pCoexSta->nScanAPNum <= 5) ) - // halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaa555555, 0xaaaa5a5a, nBreakTable, nSelectTable); - //else - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaa555555, 0xaa5a5a5a, nBreakTable, nSelectTable); - break; - case 5: - //if ( (pCoexSta->bCCKEverLock) && (pCoexSta->nScanAPNum <= 5) ) - // halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaa555555, 0xaaaa5a5a, nBreakTable, nSelectTable); - //else - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, nBreakTable, nSelectTable); - break; - case 6: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, nBreakTable, nSelectTable); - break; - case 7: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, nBreakTable, nSelectTable); - break; - case 8: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 9: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 10: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 11: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 12: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 13: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, nBreakTable, nSelectTable); - break; - case 14: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, nBreakTable, nSelectTable); - break; - case 15: - halbtc8703b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, nBreakTable, nSelectTable); - break; - default: - break; - } -} - -VOID -halbtc8703b1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8703b1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8703b1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8703b1ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8703b1ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8703b1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8703b1ant_SwMechanism( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRA - ) -{ - halbtc8703b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8703b1ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bForceExec, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte fwVer=0, u4Tmp=0, cntBtCalChk=0; - BOOLEAN bPgExtSwitch=FALSE; - BOOLEAN bUseExtSwitch=FALSE; - BOOLEAN bIsInMpMode = FALSE; - u1Byte H2C_Parameter[2] ={0}, u1Tmp = 0; - u4Byte u4Tmp1=0, u4Tmp2=0; - - pCoexDm->curAntPosType = antPosType; - -#if 1 - u4Tmp1 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x38); - u4Tmp2 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x54); - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x73); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** (Before Setup) 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n", u1Tmp, u4Tmp1, u4Tmp2)); -#endif - - if(bInitHwCfg) - { - //Disable LTE Coex Function in WiFi side (this should be on if LTE coex is required) - halbtc8703b1ant_LTECoex_Enable(pBtCoexist, 0x0); - - //GNT_WL_LTE always = 1 (this should be config if LTE coex is required) - halbtc8703b1ant_LTECoex_Set_CoexTable(pBtCoexist, BT_8703B_1ANT_CTT_WL_VS_LTE, 0xffff); - - //GNT_BT_LTE always = 1 (this should be config if LTE coex is required) - halbtc8703b1ant_LTECoex_Set_CoexTable(pBtCoexist, BT_8703B_1ANT_CTT_BT_VS_LTE, 0xffff); - - // Wait If BT IQK running, because Path control owner is at BT during BT IQK (setup by WiFi firmware) - while(cntBtCalChk <= 20) - { - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49d); - cntBtCalChk++; - if(u1Tmp & BIT0) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ########### BT is calibrating (wait cnt=%d) ###########\n", cntBtCalChk)); - delay_ms(50); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** BT is NOT calibrating (wait cnt=%d)**********\n", cntBtCalChk)); - break; - } - } - - //set Path control owner to WL at initial step - halbtc8703b1ant_LTECoex_PathControlOwner(pBtCoexist, BT_8703B_1ANT_PCO_WLSIDE); - } - else if(bWifiOff) - { - //Disable LTE Coex Function in WiFi side - halbtc8703b1ant_LTECoex_Enable(pBtCoexist, 0x0); - - //if MP mode - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode); - if(bIsInMpMode) - halbtc8703b1ant_LTECoex_PathControlOwner(pBtCoexist, BT_8703B_1ANT_PCO_WLSIDE); //set Path control owner to WiFI - else - halbtc8703b1ant_LTECoex_PathControlOwner(pBtCoexist, BT_8703B_1ANT_PCO_BTSIDE);//set Path control owner to BT - } - else - { - halbtc8703b1ant_LTECoex_PathControlOwner(pBtCoexist, BT_8703B_1ANT_PCO_WLSIDE); - } - - - if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType) || bInitHwCfg || bWifiOff) - { - // internal switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - // set GNT_BT to low - halbtc8703b1ant_LTECoex_Set_GNT_BT(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_LOW); - //Set GNT_WL to high - halbtc8703b1ant_LTECoex_Set_GNT_WL(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_HIGH); - break; - case BTC_ANT_PATH_BT: - // set GNT_BT to high - halbtc8703b1ant_LTECoex_Set_GNT_BT(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_HIGH); - //Set GNT_WL to low - halbtc8703b1ant_LTECoex_Set_GNT_WL(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_LOW); - break; - default: - case BTC_ANT_PATH_PTA: - // set GNT_BT to PTA - halbtc8703b1ant_LTECoex_Set_GNT_BT(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_PTA, BT_8703B_1ANT_SIG_STA_SET_BY_HW); - //Set GNT_WL to PTA - halbtc8703b1ant_LTECoex_Set_GNT_WL(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_PTA, BT_8703B_1ANT_SIG_STA_SET_BY_HW); - break; - } - } - -#if 1 - u4Tmp1 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x38); - u4Tmp2 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x54); - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x73); - - if(bInitHwCfg) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** (After Init) 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n", u1Tmp, u4Tmp1, u4Tmp2)); - } - else if (bWifiOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** (After WiFi off) 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n", u1Tmp, u4Tmp1, u4Tmp2)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** (After Run time) 0x73 = 0x%x, 0x38= 0x%x, 0x54= 0x%x**********\n", u1Tmp, u4Tmp1, u4Tmp2)); - } -#endif - - pCoexDm->preAntPosType = pCoexDm->curAntPosType; -} - - -VOID -halbtc8703b1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - - -VOID -halbtc8703b1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE; - u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0; - u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; - s1Byte nWiFiDurationAdjust = 0x0; - static BOOLEAN bPreWifiBusy=FALSE; - - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if (bWifiBusy != bPreWifiBusy) - { - bForceExec = TRUE; - bPreWifiBusy = bWifiBusy; - } - - if (pCoexDm->bCurPsTdmaOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - // Adjust WiFi slot by AP number - if (pCoexSta->nScanAPNum <= 5) - nWiFiDurationAdjust = 5; - else if (pCoexSta->nScanAPNum >= 40) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nScanAPNum >= 20) - nWiFiDurationAdjust = -10; - - // for A2DP only case, PS-TDMA/ TDMA - if ((type == 1) || (type == 2) || (type == 9) || (type == 11) || (type == 101) - || (type == 102) || (type == 109) || (type == 101) || (type == 7) ) - { - if (!pCoexSta->bForceLpsOn) //Native power save TDMA, only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt (TDMA) - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - - if (type == 7) - psTdmaByte4Val = 0x14; //BT-Auto-Slot - else - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle, no dynamic slot - } - else - { - psTdmaByte0Val = 0x51; //null-pkt (PS-TDMA) - psTdmaByte3Val = 0x10; //tx-pause at BT-slot - - if (type == 7) - psTdmaByte4Val = 0x14; //BT-Auto-Slot - else - psTdmaByte4Val = 0x50; // 0x778 = d/1 toggle, dynamic slot - } - } - else if ((type == 3) ||(type == 4) || (type == 13) || (type == 14) || (type == 103) || (type == 113) || (type == 114)) - { - psTdmaByte0Val = 0x51; //null-pkt (PS-TDMA) - psTdmaByte3Val = 0x10; //tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle, no dynamic slot - } - else //native power save case - { - psTdmaByte0Val = 0x61; //no null-pkt (TDMA) - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x11; // 0x778 = d/1 toggle, no dynamic slot - //psTdmaByte4Va is not defne for 0x778 = d/1, 1/1 case - } - - // for A2DP slave - if ((pBtLinkInfo->bSlaveRole == TRUE) && (pBtLinkInfo->bA2dpExist)) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - - // (for Antenna Detection Mechanism) - if (type > 100) - { - psTdmaByte0Val = psTdmaByte0Val | 0x82; //set antenna control by SW - psTdmaByte3Val = psTdmaByte3Val | 0x60; //set antenna no toggle, control by antenna diversity - } - - - if(bTurnOn) - { - switch(type) - { - default: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val); - break; - case 1: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 2: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 3: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 4: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 5: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x15, 0x3, psTdmaByte3Val, 0x11); - break; - case 6: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x20, 0x3, psTdmaByte3Val, 0x11); - break; - case 7: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x1e, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 8: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1e, 0x3, 0x10, 0x14); - break; - case 9: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 10: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 12: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); - break; - case 13: - if (pCoexSta->nScanAPNum <= 3) // for Lenovo CPT test A2DP + OPP - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a, 0x3, psTdmaByte3Val, psTdmaByte4Val); - else - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 14: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 15: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); - break; - case 16: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); - break; - case 18: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 20: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3f, 0x03, psTdmaByte3Val, 0x10); - break; - case 21: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); - break; - case 22: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x10); - break; - case 23: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); - break; - case 24: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); - break; - case 25: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 26: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 27: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); - break; - case 28: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); - break; - case 29: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); - break; - case 30: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); - break; - case 31: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); - break; - case 32: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x35, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 33: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x35, 0x3, psTdmaByte3Val, 0x10); - break; - case 34: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); - break; - case 35: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); - break; - case 36: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); - break; - case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving - /* here softap mode screen off will cost 70-80mA for phone */ - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); - break; - - // 1-Ant translate to 2-Ant (for Antenna Detection Mechanism) - case 101: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 102: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 103: - //halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val); - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 105: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x15, 0x3, psTdmaByte3Val, 0x11); - break; - case 106: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x20, 0x3, psTdmaByte3Val, 0x11); - break; - case 109: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 111: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 113: - //halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val); - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 114: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 120: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3f, 0x03, psTdmaByte3Val, 0x10); - break; - case 122: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x10); - break; - case 132: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 133: - halbtc8703b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x11); - break; - - } - } - else - { - - // disable PS tdma - switch(type) - { - case 8: //PTA Control - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - break; - case 0: - default: //Software control, Antenna at BT side - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - break; - case 1: // 2-Ant, 0x778=3, antenna control by antenna diversity - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; -#if 0 - case 9: //Software control, Antenna at WiFi side - halbtc8703b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE); - break; -#endif - } - } - rssiAdjustVal =0; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67))); - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -BOOLEAN -halbtc8703b1ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); - - //halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - //halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); - - //halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - - //halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); - - //halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else - { - if (bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - } - - bCommon = FALSE; - } - - return bCommon; -} - - -VOID -halbtc8703b1ant_TdmaDurationAdjustForAcl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - static BOOLEAN bPreWifiBusy=FALSE; - BOOLEAN bWifiBusy = FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); - - if(BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) - bWifiBusy = TRUE; - else - bWifiBusy = FALSE; - - if( (BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 3 && - pCoexDm->curPsTdma != 9 ) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { -/* if( (BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else */ if(pCoexDm->curPsTdma == 1) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if(result == 1) - { -/* if( (BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else */ if(pCoexDm->curPsTdma == 11) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - else //no change - { - /* Bryant Modify - if(bWifiBusy != bPreWifiBusy) //if busy / idle change - { - bPreWifiBusy = bWifiBusy; - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma); - } - */ - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 9 && - pCoexDm->curPsTdma != 11 ) - { - // recover to previous adjust type - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8703b1ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8703b1ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - pCoexSta->bForceLpsOn = FALSE; - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - - break; - case BTC_PS_LPS_ON: - pCoexSta->bForceLpsOn = TRUE; - halbtc8703b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8703b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - - break; - case BTC_PS_LPS_OFF: - pCoexSta->bForceLpsOn = FALSE; - halbtc8703b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - - break; - default: - break; - } -} - -VOID -halbtc8703b1ant_ActionWifiOnly( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); -} - -VOID -halbtc8703b1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - halbtc8703b1ant_ActionWifiOnly(pBtCoexist); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -//============================================= -// -// Software Coex Mechanism start -// -//============================================= - -// SCO only or SCO+PAN(HS) - -/* -VOID -halbtc8703b1ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); -} - - -VOID -halbtc8703b1ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8703b1ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8703b1ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8703b1ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(HS) only -VOID -halbtc8703b1ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(EDR)+A2DP -VOID -halbtc8703b1ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8703b1ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8703b1ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8703b1ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); -} - -*/ - -//============================================= -// -// Non-Software Coex Mechanism start -// -//============================================= -VOID -halbtc8703b1ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8703b1ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8703b1ant_ActionHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8703b1ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if ( (!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask) ) - { - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - // SCO/HID/A2DP busy - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if ( (pBtLinkInfo->bPanExist) || (bWifiBusy) ) - { - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - //for BT inquiry/page fail after S4 resume - //halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - - - //halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - //halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } -} - -VOID -halbtc8703b1ant_ActionBtScoHidOnlyBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // tdma and coex table - - if(pBtLinkInfo->bScoExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else //HID - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } -} - -VOID -halbtc8703b1ant_ActionWifiConnectedBtAclBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - u1Byte btRssiState; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - btRssiState = halbtc8703b1ant_BtRssiState(2, 28, 0); - - if ( (pCoexSta->lowPriorityRx >= 950) && (!pCoexSta->bUnderIps) - && (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bC2hBtInquiryPage)) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - if(pBtLinkInfo->bHidOnly) //HID - { - halbtc8703b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); - pCoexDm->bAutoTdmaAdjust = FALSE; - return; - } - else if(pBtLinkInfo->bA2dpOnly) //A2DP - { - if(BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - //halbtc8703b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = TRUE; - } - } - else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || - (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->bAutoTdmaAdjust = FALSE; - - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP) - { - if(BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - else - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - //BT no-profile busy (0x9) - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 33); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } -} - -VOID -halbtc8703b1ant_ActionWifiNotConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8703b1ant_ActionWifiNotConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8703b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8703b1ant_ActionWifiNotConnectedAssoAuth( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else if (pBtLinkInfo->bPanExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 2); - } -} - -VOID -halbtc8703b1ant_ActionWifiConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8703b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8703b1ant_ActionWifiConnectedSpecialPacket( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiBusy = FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - //no special packet process for both WiFi and BT very busy - if ((bWifiBusy) && ((pBtLinkInfo->bPanExist) || (pCoexSta->nNumOfProfile >= 2))) - return; - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist)) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else if (pBtLinkInfo->bA2dpExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if(pBtLinkInfo->bPanExist) - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8703b1ant_ActionWifiConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiBusy=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - BOOLEAN bUnder4way=FALSE, bApEnable=FALSE; - u4Byte wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - if(bUnder4way) - { - halbtc8703b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - if(bScan || bLink || bRoam) - { - if(bScan) - halbtc8703b1ant_ActionWifiConnectedScan(pBtCoexist); - else - halbtc8703b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - // power save state - if(!bApEnable && BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) - { - if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP - { - if(!bWifiBusy) - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else //busy - { - if (pCoexSta->nScanAPNum >= BT_8703B_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA - { - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - } - } - else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE)) - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - else - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(!bWifiBusy) - { - if(BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8703b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else if( (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8703b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else - { - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - } - else - { - if(BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8703b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else if( (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8703b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else - { - //halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - //halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } -} - -VOID -halbtc8703b1ant_RunSwCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm=0; - - algorithm = halbtc8703b1ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - - if(halbtc8703b1ant_IsCommonAction(pBtCoexist)) - { - - } - else - { - switch(pCoexDm->curAlgorithm) - { - case BT_8703B_1ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n")); - //halbtc8703b1ant_ActionSco(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n")); - //halbtc8703b1ant_ActionHid(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n")); - //halbtc8703b1ant_ActionA2dp(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); - //halbtc8703b1ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n")); - //halbtc8703b1ant_ActionPanEdr(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n")); - //halbtc8703b1ant_ActionPanHs(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); - //halbtc8703b1ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); - //halbtc8703b1ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); - //halbtc8703b1ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8703B_1ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n")); - //halbtc8703b1ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n")); - //halbtc8703b1ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8703b1ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - BOOLEAN bIncreaseScanDevNum=FALSE; - BOOLEAN bBtCtrlAggBufSize=FALSE; - BOOLEAN bMiracastPlusBt=FALSE; - u1Byte aggBufSize=5; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0, wifiBw; - u1Byte iotPeer=BTC_IOT_PEER_UNKNOWN; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if(pCoexSta->bBtWhckTest) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n")); - halbtc8703b1ant_ActionBtWhckTest(pBtCoexist); - return; - } - - if( (BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bIncreaseScanDevNum = TRUE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - bMiracastPlusBt = TRUE; - } - else - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - bMiracastPlusBt = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - - if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8703b1ant_ActionBtInquiry(pBtCoexist); - } - else - halbtc8703b1ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) ) - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_IOT_PEER, &iotPeer); - - if(BTC_IOT_PEER_CISCO != iotPeer) - { - if(pBtLinkInfo->bScoExist)//if (pBtLinkInfo->bBtHiPriLinkExist) - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5); - else - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - } - else - { - if(pBtLinkInfo->bScoExist) - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5); - else - { - if (BTC_WIFI_BW_HT40==wifiBw) - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x10); - else - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - } - } - - halbtc8703b1ant_SwMechanism(pBtCoexist, TRUE); - halbtc8703b1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message - } - else - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - halbtc8703b1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8703b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8703b1ant_ActionHs(pBtCoexist); - return; - } - - - if(!bWifiConnected) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - if (bScan) - halbtc8703b1ant_ActionWifiNotConnectedScan(pBtCoexist); - else - halbtc8703b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else - halbtc8703b1ant_ActionWifiNotConnected(pBtCoexist); - } - else // wifi LPS/Busy - { - halbtc8703b1ant_ActionWifiConnected(pBtCoexist); - } -} - -u4Byte -halbtc8703b1ant_PSD_Log2Base( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val - - ) -{ - u1Byte i,j; - u4Byte tmp, tmp2, val_integerdB=0, tindex, shiftcount=0; - u4Byte result,val_fractiondB=0,Table_fraction[21]= {0,432, 332, 274, 232, 200, - 174, 151,132,115,100,86,74,62,51,42, - 32,23,15,7,0}; - - if (val == 0) - return 0; - - tmp = val; - - while(1) - { - if (tmp == 1) - break; - else - { - tmp = (tmp >> 1); - shiftcount++; - } - } - - - val_integerdB = shiftcount+1; - - tmp2=1; - for (j=1; j<= val_integerdB;j++) - tmp2 = tmp2*2; - - tmp = (val*100) /tmp2; - tindex = tmp/5; - - if (tindex > 20) - tindex = 20; - - val_fractiondB = Table_fraction[tindex]; - - result = val_integerdB*100 - val_fractiondB; - - return (result); - - -} - -VOID -halbtc8703b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - // sw all off - halbtc8703b1ant_SwMechanism(pBtCoexist, FALSE); - - //halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - //halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - pCoexSta->popEventCnt = 0; -} - -VOID -halbtc8703b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp, - IN BOOLEAN bWifiOnly - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0;//, fwVer; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0, u1Tmpa=0, u1Tmpb=0; - u1Byte H2C_Parameter[2] ={0}; - - u4Byte u4Tmp1=0, u4Tmp2=0; - - - u4Tmp1 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x38); - u4Tmp2 = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x54); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** (Before Init HW config) 0x38= 0x%x, 0x54= 0x%x**********\n", u4Tmp1, u4Tmp2)); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x550, 0x8, 0x1); //enable TBTT nterrupt - - //BT report packet sample rate - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, 0x5); - - // Enable BT counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); - - //Enable PTA (3-wire function form BT side) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x41, 0x02, 0x1); - - //Enable PTA (tx/rx signal form WiFi side) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x4c6, 0x10, 0x1); - - //enable GNT_WL/GNT_BT debug signal to GPIO14/15 - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x73, 0x8, 0x1); - - //enable GNT_WL - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x4e, 0x40, 0x0); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x1, 0x0); - - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - - //Antenna config - if(bWifiOnly) - { - pCoexSta->bConCurrentRxModeOn = FALSE; - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FORCE_EXEC, TRUE, FALSE); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FORCE_EXEC, FALSE, FALSE); - } - else - { - pCoexSta->bConCurrentRxModeOn = TRUE; - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x953, 0x2, 0x1); - //RF 0x1[0] = 0 -> Set GNT_WL_RF_Rx always = 1 for con-current Rx - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0x1, 0x0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, TRUE, FALSE); - } - - // PTA parameter - halbtc8703b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - -} - - - -VOID -halbtc8703b1ant_PSD_ShowData( - IN PBTC_COEXIST pBtCoexist - ) -{ - pu1Byte cliBuf=pBtCoexist->cliBuf; - u4Byte nDeltaFreqPerPoint; - u4Byte freq,freq1,freq2,n=0,i=0, j=0, m=0, PsdRep1, PsdRep2; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n\n============[PSD info] (%d)============\n", - pPsdScan->nPSDGenCount); - CL_PRINTF(cliBuf); - - if (pPsdScan->nPSDGenCount == 0) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n No Data !!\n"); - CL_PRINTF(cliBuf); - return; - } - - if (pPsdScan->nPSDPoint == 0) - nDeltaFreqPerPoint = 0; - else - nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint; - - //if (pPsdScan->bIsPSDShowMaxOnly) - if (0) - { - PsdRep1 = pPsdScan->nPSDMaxValue/100; - PsdRep2 = pPsdScan->nPSDMaxValue - PsdRep1 * 100; - - freq = ((pPsdScan->nRealCentFreq-20) * 1000000 + pPsdScan->nPSDMaxValuePoint * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; - - if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.0%d MHz", - freq1, freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.%d MHz", - freq1, freq2); - - if (PsdRep2 < 10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.0%d dB, (%d) \n", - PsdRep1, PsdRep2, pPsdScan->nPSDMaxValue); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.%d dB, (%d)\n", - PsdRep1, PsdRep2, pPsdScan->nPSDMaxValue); - - CL_PRINTF(cliBuf); - } - else - { - m = pPsdScan->nPSDStartPoint; - n = pPsdScan->nPSDStartPoint; - i = 1; - j = 1; - - while(1) - { - do - { - freq = ((pPsdScan->nRealCentFreq-20) * 1000000 + m * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; - - if (i ==1) - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.000", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.0%2d", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.%3d", freq1,freq2); - } - else if ( (i%8 == 0) || (m == pPsdScan->nPSDStopPoint) ) - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000\n", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d\n", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d\n", freq1,freq2); - } - else - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d", freq1,freq2); - } - - i++; - m++; - CL_PRINTF(cliBuf); - - }while( (i <= 8) && (m <= pPsdScan->nPSDStopPoint)); - - - do - { - PsdRep1 = pPsdScan->nPSDReport_MaxHold[n]/100; - PsdRep2 = pPsdScan->nPSDReport_MaxHold[n] - PsdRep1 * 100; - - if (j ==1) - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.0%d", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.%d", PsdRep1,PsdRep2); - } - else if ( (j%8 == 0) || (n == pPsdScan->nPSDStopPoint) ) - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d\n", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d\n", PsdRep1,PsdRep2); - } - else - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d", PsdRep1,PsdRep2); - } - - j++; - n++; - CL_PRINTF(cliBuf); - - } while( (j <= 8) && (n <= pPsdScan->nPSDStopPoint)); - - if ( (m > pPsdScan->nPSDStopPoint) || (n > pPsdScan->nPSDStopPoint) ) - break; - else - { - i = 1; - j = 1; - } - - } - } - - -} - -VOID -halbtc8703b1ant_PSD_MaxHoldData( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte GenCount - ) -{ - u4Byte i=0, i_max=0, val_max=0, j; - - if (GenCount== 1) - { - memcpy(pPsdScan->nPSDReport_MaxHold, pPsdScan->nPSDReport, BT_8703B_1ANT_ANTDET_PSD_POINTS*sizeof(u4Byte)); - - for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i])); - } - - pPsdScan->nPSDMaxValuePoint = 0; - pPsdScan->nPSDMaxValue = 0; - - } - else - { - for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++) - { - if (pPsdScan->nPSDReport[i] > pPsdScan->nPSDReport_MaxHold[i]) - pPsdScan->nPSDReport_MaxHold[i] = pPsdScan->nPSDReport[i]; - - //search Max Value - if (i ==pPsdScan->nPSDStartPoint ) - { - i_max = i; - val_max = pPsdScan->nPSDReport_MaxHold[i]; - } - else - { - if (pPsdScan->nPSDReport_MaxHold[i] > val_max) - { - i_max = i; - val_max = pPsdScan->nPSDReport_MaxHold[i]; - } - } - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i])); - - } - - pPsdScan->nPSDMaxValuePoint = i_max; - pPsdScan->nPSDMaxValue = val_max; - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i_Max = %d, PSDReport_Max = %d dB\n", pPsdScan->nPSDMaxValuePoint - // ,pPsdScan->nPSDMaxValue)); - } - - -} - -u4Byte -halbtc8703b1ant_PSD_GetData( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte nPoint - ) -{ - //reg 0x808[9:0]: FFT data x - //reg 0x808[22]: 0-->1 to get 1 FFT data y - //reg 0x8b4[15:0]: FFT data y report - - u4Byte val = 0, psd_report =0; - - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - - val &= 0xffbffc00; - val |= nPoint; - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - val |= 0x00400000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x8b4); - - psd_report = val & 0x0000ffff; - - return psd_report; -} - - -VOID -halbtc8703b1ant_PSD_SweepPoint( -IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN s4Byte offset, - IN u4Byte span, - IN u4Byte points, - IN u4Byte avgnum - ) -{ - u4Byte i,val,n,k=0; - u4Byte nPoints=0, psd_report=0; - u4Byte nStartP=0, nStopP=0, nDeltaFreqPerPoint=156250; - u4Byte nPSDCenterFreq=20*10^6, freq,freq1,freq2; - BOOLEAN outloop = FALSE; - u1Byte flag = 0; - u4Byte tmp, PsdRep1, PsdRep2; - u4Byte WiFi_OriginalChannel = 1; - - pPsdScan->bIsPSDRunning = TRUE; - - do - { - switch(flag) - { - case 0: //Get PSD parameters - default: - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), centFreq=0x%x, offset=0x%x, span=0x%x\n", - // centFreq, offset, span)); - - pPsdScan->nPSDBandWidth = 40*1000000; - pPsdScan->nPSDPoint = points; - pPsdScan->nPSDStartBase = points/2; - pPsdScan->nPSDAvgNum = avgnum; - pPsdScan->nRealCentFreq = centFreq; - pPsdScan->nRealOffset = offset; - pPsdScan->nRealSpan = span; - - - nPoints = pPsdScan->nPSDPoint; - nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint; - - //PSD point setup - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - val &= 0xffff0fff; - - switch(pPsdScan->nPSDPoint) - { - case 128: - val |= 0x0; - break; - case 256: - default: - val |=0x00004000; - break; - case 512: - val |= 0x00008000; - break; - case 1024: - val |= 0x0000c000; - break; - } - - switch(pPsdScan->nPSDAvgNum) - { - case 1: - val |= 0x0; - break; - case 8: - val |=0x00001000; - break; - case 16: - val |= 0x00002000; - break; - case 32: - default: - val |= 0x00003000; - break; - } - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD BW= %d, DeltaFreq=%d\n" - // , pPsdScan->nPSDBandWidth, nDeltaFreqPerPoint)); - flag = 1; - break; - case 1: //calculate the PSD point index from freq/offset/span - nPSDCenterFreq = pPsdScan->nPSDBandWidth /2 +offset*(1000000); - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD Center Freq = %d\n", (centFreq + offset))); - - nStartP = pPsdScan->nPSDStartBase + (nPSDCenterFreq - span *(1000000)/2) /nDeltaFreqPerPoint; - pPsdScan->nPSDStartPoint = nStartP - pPsdScan->nPSDStartBase; - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Start PSD Poin Matrix Index = %d\n", pPsdScan->nPSDStartPoint)); - - nStopP = pPsdScan->nPSDStartBase + (nPSDCenterFreq + span *(1000000)/2) /nDeltaFreqPerPoint; - pPsdScan->nPSDStopPoint = nStopP - pPsdScan->nPSDStartBase-1; - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Stop PSD Poin Matrix Index = %d\n",pPsdScan->nPSDStopPoint)); - - flag = 2; - break; - case 2: //set RF channel/BW/Mode - - //set 3-wire off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c); - val |= 0x00300000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val); - - //CCK off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800); - val &= 0xfeffffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val); - - //store WiFi original channel - WiFi_OriginalChannel = pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff); - - //Set RF channel - if (centFreq == 2484) - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, 0xe); - else - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, (centFreq-2412)/5 + 1); //WiFi TRx Mask on - - //Set RF mode = Rx, RF Gain = 0x8a0 - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x0, 0xfffff, 0x308a0); - - //Set RF Rx filter corner - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0x3e4); - - //Set TRx mask off - //un-lock TRx Mask setup - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x1); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x1); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - flag = 3; - break; - case 3: - memset(pPsdScan->nPSDReport,0, pPsdScan->nPSDPoint*sizeof(u4Byte)); - nStartP = pPsdScan->nPSDStartPoint + pPsdScan->nPSDStartBase; - nStopP = pPsdScan->nPSDStopPoint + pPsdScan->nPSDStartBase + 1; - - i = nStartP; - - while (i < nStopP) - { - if (i >= nPoints) - { - psd_report = halbtc8703b1ant_PSD_GetData(pBtCoexist,i-nPoints); - } - else - { - psd_report = halbtc8703b1ant_PSD_GetData(pBtCoexist,i); - } - - if (psd_report == 0) - tmp = 0; - else - //tmp = 20*log10((double)psd_report); - //20*log2(x)/log2(10), log2Base return theresult of the psd_report*100 - tmp = 6 * halbtc8703b1ant_PSD_Log2Base(pBtCoexist, psd_report); - - n = i-pPsdScan->nPSDStartBase; - pPsdScan->nPSDReport[n] = tmp; - PsdRep1 = pPsdScan->nPSDReport[n] /100; - PsdRep2 = pPsdScan->nPSDReport[n] - PsdRep1 * 100; - - freq = ((centFreq-20) * 1000000 + n * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; -/* - if (freq2 < 100) - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.0%d MHz)", n, freq1, freq2)); - else - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.%d MHz)", n, freq1, freq2)); - - if (PsdRep2 < 10) - RT_TRACE(COMP_COEX, DBG_LOUD, (", PSDReport = %d (%d.0%d dB)\n",psd_report, PsdRep1, PsdRep2)); - else - RT_TRACE(COMP_COEX, DBG_LOUD, (", PSDReport = %d (%d.%d dB)\n",psd_report, PsdRep1,PsdRep2)); -*/ - i++; - - k=0; - - //Add Delay between PSD point - while(1) - { - if (k++ > 20000) - break; - } - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint()==============\n")); - } - - flag = 100; - break; - case 99: //error - - outloop = TRUE; - break; - case 100: //recovery - - //set 3-wire on - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c); - val &=0xffcfffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val); - - //CCK on - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800); - val |= 0x01000000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val); - - //PSD off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - val &=0xffbfffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x808,val); - - //TRx Mask on - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - - //lock TRx Mask setup - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x0); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x0); - - //Set RF Rx filter corner - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0x0); - - //restore WiFi original channel - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, WiFi_OriginalChannel); - - outloop = TRUE; - break; - - } - - }while (!outloop); - - - - pPsdScan->bIsPSDRunning = FALSE; - - -} - -//============================================================ -// work around function start with wa_halbtc8703b1ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8703b1ant_ -//============================================================ -VOID -EXhalbtc8703b1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x0; - u2Byte u2Tmp=0x0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx Execute 8703b 1-Ant PowerOn Setting xxxxxxxxxxxxxxxx!!\n")); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("Ant Det Finish = %s, Ant Det Number = %d\n", - (pBoardInfo->btdmAntDetFinish? "Yes":"No"), pBoardInfo->btdmAntNumByAntDet)); - - pBtCoexist->bStopCoexDm = TRUE; - - // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1); - - //set Path control owner to WiFi - halbtc8703b1ant_LTECoex_PathControlOwner(pBtCoexist, BT_8703B_1ANT_PCO_WLSIDE); - - // set GNT_BT to high - halbtc8703b1ant_LTECoex_Set_GNT_BT(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_HIGH); - //Set GNT_WL to low - halbtc8703b1ant_LTECoex_Set_GNT_WL(pBtCoexist, BT_8703B_1ANT_GNT_BLOCK_RFC_BB, BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW, BT_8703B_1ANT_SIG_STA_SET_TO_LOW); - - // set WLAN_ACT = 0 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - - u1Tmp = 0; - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** LTE coex Reg 0x38 (Power-On) = 0x%x**********\n", halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x38))); - - -#if 0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - else - { - - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - // set to S1 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - u1Tmp |= 0x1; // antenna inverse - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - - - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } - -#endif -} - -VOID -EXhalbtc8703b1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8703b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8703b1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly); - pBtCoexist->bStopCoexDm = FALSE; -} - -VOID -EXhalbtc8703b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - pBtCoexist->bStopCoexDm = FALSE; - - halbtc8703b1ant_InitCoexDm(pBtCoexist); - - halbtc8703b1ant_QueryBtInfo(pBtCoexist); -} - -VOID -EXhalbtc8703b1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u2Byte u2Tmp[4]; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - static u1Byte PopReportIn10s = 0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - if(pBtCoexist->bStopCoexDm) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - if (pPsdScan->bAntDet_TryCount == 0) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Mech/ Pos", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos); - CL_PRINTF(cliBuf); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d (%d/%d/%d)", "Ant PG Num/ Mech(Ant_Det)/ Pos", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNumByAntDet, pBoardInfo->btdmAntPos, - pPsdScan->bAntDet_TryCount, pPsdScan->bAntDet_FailCount, pPsdScan->nAntDet_Result); - CL_PRINTF(cliBuf); - - if (pBoardInfo->btdmAntDetFinish) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "Ant Det PSD Value", pPsdScan->nAntDet_PeakVal); - CL_PRINTF(cliBuf); - } - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8703b1Ant, GLCoexVer8703b1Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "WifibHiPri/ Ccklock/ CckEverLock", \ - (pCoexSta->bWiFiIsHighPriTask? "Yes":"No"), - (pCoexSta->bCCKLock? "Yes":"No"), - (pCoexSta->bCCKEverLock? "Yes":"No")); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - PopReportIn10s++; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt); - CL_PRINTF(cliBuf); - - if (PopReportIn10s >= 5) - { - pCoexSta->popEventCnt = 0; - PopReportIn10s = 0; - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d / %d", "SCO/HID/PAN/A2DP/Hi-Pri", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist, pBtLinkInfo->bBtHiPriLinkExist); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) - { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - else - { - btInfoExt = pCoexSta->btInfoExt; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "BT Role/A2DP rate", \ - (pBtLinkInfo->bSlaveRole )? "Slave":"Master", (btInfoExt&BIT0)? "BR":"EDR"); - CL_PRINTF(cliBuf); - } - - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8703b1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism] (before Manual)============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - } - - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ 0x%x", "SM[LowPenaltyRA]/RA Mask", \ - pCoexDm->bCurLowPenaltyRa, pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "NoAggr/ CtrlAggr/ AggrSize", \ - (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), - pBtCoexist->btInfo.aggBufSize); - CL_PRINTF(cliBuf); - - // Fw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism] (before Manual) ============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - } - - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, - (pCoexDm->bCurPsTdmaOn? "On":"Off"), - (pCoexDm->bAutoTdmaAdjust? "Adj":"Fix") ); - - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "WL/BT Coex Table Type", \ - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/IgnWlanAct", \ - u1Tmp[0], u4Tmp[0], pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - u4Tmp[0] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xa0); - u4Tmp[1] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xa4); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "LTE Coex Table W_L/B_L", \ - u4Tmp[0]&0xffff, u4Tmp[1]&0xffff); - CL_PRINTF(cliBuf); - - u4Tmp[0] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xa8); - u4Tmp[1] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xac); - u4Tmp[2] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xb0); - u4Tmp[3] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0xb4); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "LTE Break Table W_L/B_L/L_W/L_B", \ - u4Tmp[0]&0xffff, u4Tmp[1]&0xffff, u4Tmp[2]&0xffff, u4Tmp[3]&0xffff); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \ - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - - u4Tmp[0] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x38); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x73); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %s", "LTE CoexOn/Path Ctrl Owner", \ - ((u4Tmp[0]&BIT7)>> 7), ((u1Tmp[0]&BIT2)? "WL":"BT")); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "LTE 3Wire/OPMode/UART/UARTMode", \ - ((u4Tmp[0]&BIT6)>> 6), ((u4Tmp[0]&(BIT5|BIT4))>> 4),((u4Tmp[0]&BIT3)>> 3), (u4Tmp[0]&(BIT2|BIT1|BIT0))); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %s", "GNT_WL_SWCtrl/GNT_BT_SWCtrl/Dbg", \ - ((u4Tmp[0]&BIT12)>> 12), ((u4Tmp[0]&BIT14)>> 14), ((u1Tmp[0]&BIT3)? "On":"Off")); - CL_PRINTF(cliBuf); - - u4Tmp[0] = halbtc8703b1ant_LTECoex_InDirectReadReg(pBtCoexist, 0x54); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "GNT_WL/GNT_BT/LTE_Busy/UART_Busy", \ - ((u4Tmp[0]&BIT2)>> 2), ((u4Tmp[0]&BIT3)>> 3), ((u4Tmp[0]&BIT1)>> 1), (u4Tmp[0]&BIT0)); - CL_PRINTF(cliBuf); - - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4c6); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x4c6[4]/0x40[5] (WL/BT PTA)", \ - ((u1Tmp[0] & BIT4)>>4), ((u1Tmp[1] & BIT5)>>5)); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x953); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ %s", "0x550(bcn ctrl)/0x522/4-RxAGC", \ - u4Tmp[0], u1Tmp[0], (u1Tmp[1]&0x2)? "On": "Off"); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xc50/OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[1]&0xff, u4Tmp[0]&0xffff, faOfdm, faCck); - CL_PRINTF(cliBuf); - - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); - - halbtc8703b1ant_ReadScoreBoard(pBtCoexist, &u2Tmp[0]); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %04x", "ScoreBoard[14:0] (from BT)", u2Tmp[0]); - CL_PRINTF(cliBuf); - -#if(BT_AUTO_REPORT_ONLY_8703B_1ANT == 1) - //halbtc8703b1ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8703b1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp=0; - - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - - //Write WL "Active" in Score-board for LPS off - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - - halbtc8703b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8703b1ant_InitCoexDm(pBtCoexist); - halbtc8703b1ant_QueryBtInfo(pBtCoexist); - - pCoexSta->bUnderIps = FALSE; - } -} - -VOID -EXhalbtc8703b1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - - if (pCoexSta->bForceLpsOn == TRUE) // LPS No-32K - { - //Write WL "Active" in Score-board for PS-TDMA - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - - } - else // LPS-32K, need check if this h2c 0x71 can work?? (2015/08/28) - { - //Write WL "Non-Active" in Score-board for Native-PS - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - - } - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - - - //Write WL "Active" in Score-board for LPS off - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - - } -} - -VOID -EXhalbtc8703b1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - u1Byte u1Tmpa, u1Tmpb; - u4Byte u4Tmp; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm ) - return; - - if(BTC_SCAN_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } - - if(pBtCoexist->btInfo.bBtDisabled) - return; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - halbtc8703b1ant_QueryBtInfo(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8703b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8703b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8703b1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_SCAN_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8703b1ant_ActionWifiNotConnectedScan(pBtCoexist); - } - else // wifi is connected - { - halbtc8703b1ant_ActionWifiConnectedScan(pBtCoexist); - } - } - else if(BTC_SCAN_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8703b1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8703b1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8703b1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_ASSOCIATE_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - pCoexDm->nArpCnt = 0; - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - //pCoexDm->nArpCnt = 0; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8703b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8703b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8703b1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_ASSOCIATE_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - halbtc8703b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8703b1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8703b1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8703b1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - BOOLEAN bWifiUnderBMode = FALSE; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - //Set CCK Tx/Rx high Pri except 11b mode - if (bWifiUnderBMode) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx - } - else - { - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx - } - - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - pCoexDm->nArpCnt = 0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx - - pCoexSta->bCCKEverLock = FALSE; - } - - halbtc8703b1ant_UpdateWifiChannelInfo(pBtCoexist, type); - -} - -VOID -EXhalbtc8703b1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE, bUnder4way=FALSE; - u1Byte aggBufSize=5; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - - if (BTC_PACKET_ARP == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n")); - - pCoexDm->nArpCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); - - if((pCoexDm->nArpCnt >= 10) && (!bUnder4way)) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type)); - } - - pCoexSta->specialPktPeriodCnt = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8703b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8703b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8703b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8703b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8703b1ant_ActionHs(pBtCoexist); - return; - } - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) ) - { - halbtc8703b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - } -} - -VOID -EXhalbtc8703b1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bBtBusy=FALSE; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8703B_1ANT_MAX) - rspSource = BT_INFO_SRC_8703B_1ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - // if 0xff, it means BT is under WHCK test - if (btInfo == 0xff) - pCoexSta->bBtWhckTest = TRUE; - else - pCoexSta->bBtWhckTest = FALSE; - - if(BT_INFO_SRC_8703B_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btRetryCnt >= 1) - pCoexSta->popEventCnt++; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtPage = TRUE; - else - pCoexSta->bC2hBtPage = FALSE; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2-90; - //pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if(pCoexSta->btInfoExt & BIT1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - halbtc8703b1ant_UpdateWifiChannelInfo(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - halbtc8703b1ant_UpdateWifiChannelInfo(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if(pCoexSta->btInfoExt & BIT3) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8703b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8703B_1ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8703b1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8703B_1ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - pCoexSta->nNumOfProfile = 0; - - // set link exist status - if(!(btInfo&BT_INFO_8703B_1ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - - pCoexSta->bBtHiPriLinkExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8703B_1ANT_B_FTP) - { - pCoexSta->bPanExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8703B_1ANT_B_A2DP) - { - pCoexSta->bA2dpExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8703B_1ANT_B_HID) - { - pCoexSta->bHidExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8703B_1ANT_B_SCO_ESCO) - { - pCoexSta->bScoExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bScoExist = FALSE; - - if ((pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) &&( pCoexSta->bScoExist == FALSE)) - { - if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - { - pCoexSta->bHidExist = TRUE; - pCoexSta->wrongProfileNotification++; - pCoexSta->nNumOfProfile++; - btInfo = btInfo | 0x28; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT HID = true (Hi-Pri > 160)!\n")); - } - } - - //Add Hi-Pri Tx/Rx counter to avoid false detection - if (((pCoexSta->bHidExist) || (pCoexSta->bScoExist)) && (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->bBtHiPriLinkExist = TRUE; - else - pCoexSta->bBtHiPriLinkExist = FALSE; - - if((btInfo&BT_INFO_8703B_1ANT_B_ACL_BUSY) && (pCoexSta->nNumOfProfile == 0)) - { - if (pCoexSta->lowPriorityTx + pCoexSta->lowPriorityRx >= 160) - { - pCoexSta->bPanExist = TRUE; - pCoexSta->nNumOfProfile++; - pCoexSta->wrongProfileNotification++; - btInfo = btInfo | 0x88; - } - } - } - - halbtc8703b1ant_UpdateBtLinkInfo(pBtCoexist); - - btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) - - if(!(btInfo&BT_INFO_8703B_1ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8703B_1ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8703B_1ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8703B_1ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8703B_1ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8703B_1ANT_B_ACL_BUSY) - { - if(BT_8703B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->btStatus = BT_8703B_1ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8703B_1ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8703B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - bBtBusy = TRUE; - else - bBtBusy = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - halbtc8703b1ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8703b1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa,u1Tmpb, u1Tmpc; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n")); - - if(BTC_RF_ON == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - halbtc8703b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - pBtCoexist->bStopCoexDm = FALSE; - } - else if(BTC_RF_OFF == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8703b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - pBtCoexist->bStopCoexDm = TRUE; - - } -} - -VOID -EXhalbtc8703b1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - - halbtc8703b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8703b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - pBtCoexist->bStopCoexDm = TRUE; -} - -VOID -EXhalbtc8703b1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, FALSE); - - halbtc8703b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8703b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8703b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - - pBtCoexist->bStopCoexDm = TRUE; - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - halbtc8703b1ant_PostActiveStateToBT(pBtCoexist, TRUE); - - pBtCoexist->bStopCoexDm = FALSE; - halbtc8703b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8703b1ant_InitCoexDm(pBtCoexist); - halbtc8703b1ant_QueryBtInfo(pBtCoexist); - } -} - - -VOID -EXhalbtc8703b1ant_ScoreBoardStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - // - - -} - -VOID -EXhalbtc8703b1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n")); - - halbtc8703b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0); - halbtc8703b1ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8703b1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8703b1Ant, GLCoexVer8703b1Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8703B_1ANT == 0) - halbtc8703b1ant_QueryBtInfo(pBtCoexist); - halbtc8703b1ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8703b1ant_MonitorBtCtr(pBtCoexist); - halbtc8703b1ant_MonitorWiFiCtr(pBtCoexist); -#if BT_8703B_1ANT_ANTDET_ENABLE - halbtc8703b1ant_MonitorBtEnableDisable(pBtCoexist); -#endif - - if( halbtc8703b1ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust ) - { - - halbtc8703b1ant_RunCoexistMechanism(pBtCoexist); - } - - pCoexSta->specialPktPeriodCnt++; - -#endif -} - -VOID -EXhalbtc8703b1ant_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - //No Antenna Detection required because 8730b is only 1-Ant -} - -VOID -EXhalbtc8703b1ant_AntennaIsolation( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - - -} - -VOID -EXhalbtc8703b1ant_PSDScan( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - - -} - -VOID -EXhalbtc8703b1ant_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ) -{ - -} - -#endif - -#else // #if (RTL8723B_SUPPORT == 1) -VOID -EXhalbtc8703b1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ){} -VOID -EXhalbtc8703b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ){} -VOID -EXhalbtc8703b1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8703b1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ){} -VOID -EXhalbtc8703b1ant_ScoreBoardStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ){} -VOID -EXhalbtc8703b1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8703b1ant_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ){} -VOID -EXhalbtc8703b1ant_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ){} - -#endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.h deleted file mode 100644 index 9d491b7c3..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b1Ant.h +++ /dev/null @@ -1,387 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8703B 1ANT BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8703B_1ANT 1 - -#define BT_INFO_8703B_1ANT_B_FTP BIT7 -#define BT_INFO_8703B_1ANT_B_A2DP BIT6 -#define BT_INFO_8703B_1ANT_B_HID BIT5 -#define BT_INFO_8703B_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8703B_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8703B_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8703B_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8703B_1ANT_B_CONNECTION BIT0 - -#define BT_INFO_8703B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8703B_1ANT 2 - -#define BT_8703B_1ANT_WIFI_NOISY_THRESH 30 //max: 255 - -//for Antenna detection -#define BT_8703B_1ANT_ANTDET_PSDTHRES_BACKGROUND 50 -#define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70 -#define BT_8703B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 55 -#define BT_8703B_1ANT_ANTDET_PSDTHRES_1ANT 35 -#define BT_8703B_1ANT_ANTDET_RETRY_INTERVAL 10 //retry timer if ant det is fail, unit: second -#define BT_8703B_1ANT_ANTDET_ENABLE 0 -#define BT_8703B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 0 - -#define BT_8703B_1ANT_LTECOEX_INDIRECTREG_ACCESS_TIMEOUT 30000 - -typedef enum _BT_8703B_1ANT_SIGNAL_STATE{ - BT_8703B_1ANT_SIG_STA_SET_TO_LOW = 0x0, - BT_8703B_1ANT_SIG_STA_SET_BY_HW = 0x0, - BT_8703B_1ANT_SIG_STA_SET_TO_HIGH = 0x1, - BT_8703B_1ANT_SIG_STA_MAX -}BT_8703B_1ANT_SIGNAL_STATE,*PBT_8703B_1ANT_SIGNAL_STATE; - -typedef enum _BT_8703B_1ANT_PATH_CTRL_OWNER{ - BT_8703B_1ANT_PCO_BTSIDE = 0x0, - BT_8703B_1ANT_PCO_WLSIDE = 0x1, - BT_8703B_1ANT_PCO_MAX -}BT_8703B_1ANT_PATH_CTRL_OWNER,*PBT_8703B_1ANT_PATH_CTRL_OWNER; - -typedef enum _BT_8703B_1ANT_GNT_CTRL_TYPE{ - BT_8703B_1ANT_GNT_TYPE_CTRL_BY_PTA = 0x0, - BT_8703B_1ANT_GNT_TYPE_CTRL_BY_SW = 0x1, - BT_8703B_1ANT_GNT_TYPE_MAX -}BT_8703B_1ANT_GNT_CTRL_TYPE,*PBT_8703B_1ANT_GNT_CTRL_TYPE; - -typedef enum _BT_8703B_1ANT_GNT_CTRL_BLOCK{ - BT_8703B_1ANT_GNT_BLOCK_RFC_BB = 0x0, - BT_8703B_1ANT_GNT_BLOCK_RFC = 0x1, - BT_8703B_1ANT_GNT_BLOCK_BB = 0x2, - BT_8703B_1ANT_GNT_BLOCK_MAX -}BT_8703B_1ANT_GNT_CTRL_BLOCK,*PBT_8703B_1ANT_GNT_CTRL_BLOCK; - -typedef enum _BT_8703B_1ANT_LTE_COEX_TABLE_TYPE{ - BT_8703B_1ANT_CTT_WL_VS_LTE = 0x0, - BT_8703B_1ANT_CTT_BT_VS_LTE = 0x1, - BT_8703B_1ANT_CTT_MAX -}BT_8703B_1ANT_LTE_COEX_TABLE_TYPE,*PBT_8703B_1ANT_LTE_COEX_TABLE_TYPE; - -typedef enum _BT_8703B_1ANT_LTE_BREAK_TABLE_TYPE{ - BT_8703B_1ANT_LBTT_WL_BREAK_LTE = 0x0, - BT_8703B_1ANT_LBTT_BT_BREAK_LTE = 0x1, - BT_8703B_1ANT_LBTT_LTE_BREAK_WL = 0x2, - BT_8703B_1ANT_LBTT_LTE_BREAK_BT = 0x3, - BT_8703B_1ANT_LBTT_MAX -}BT_8703B_1ANT_LTE_BREAK_TABLE_TYPE,*PBT_8703B_1ANT_LTE_BREAK_TABLE_TYPE; - -typedef enum _BT_INFO_SRC_8703B_1ANT{ - BT_INFO_SRC_8703B_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8703B_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8703B_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8703B_1ANT_MAX -}BT_INFO_SRC_8703B_1ANT,*PBT_INFO_SRC_8703B_1ANT; - -typedef enum _BT_8703B_1ANT_BT_STATUS{ - BT_8703B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8703B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8703B_1ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8703B_1ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8703B_1ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8703B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8703B_1ANT_BT_STATUS_MAX -}BT_8703B_1ANT_BT_STATUS,*PBT_8703B_1ANT_BT_STATUS; - -typedef enum _BT_8703B_1ANT_WIFI_STATUS{ - BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8703B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, - BT_8703B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, - BT_8703B_1ANT_WIFI_STATUS_MAX -}BT_8703B_1ANT_WIFI_STATUS,*PBT_8703B_1ANT_WIFI_STATUS; - -typedef enum _BT_8703B_1ANT_COEX_ALGO{ - BT_8703B_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8703B_1ANT_COEX_ALGO_SCO = 0x1, - BT_8703B_1ANT_COEX_ALGO_HID = 0x2, - BT_8703B_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8703B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8703B_1ANT_COEX_ALGO_PANEDR = 0x5, - BT_8703B_1ANT_COEX_ALGO_PANHS = 0x6, - BT_8703B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8703B_1ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8703B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8703B_1ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8703B_1ANT_COEX_ALGO_MAX = 0xb, -}BT_8703B_1ANT_COEX_ALGO,*PBT_8703B_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8703B_1ANT{ - // hw setting - u1Byte preAntPosType; - u1Byte curAntPosType; - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; - u4Byte nArpCnt; - - u1Byte errorCondition; -} COEX_DM_8703B_1ANT, *PCOEX_DM_8703B_1ANT; - -typedef struct _COEX_STA_8703B_1ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - BOOLEAN bBtHiPriLinkExist; - u1Byte nNumOfProfile; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte specialPktPeriodCnt; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - s1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8703B_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8703B_1ANT_MAX]; - BOOLEAN bBtWhckTest; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtPage; //Add for win8.1 page out issue - BOOLEAN bWiFiIsHighPriTask; //Add for win8.1 page out issue - u1Byte btRetryCnt; - u1Byte btInfoExt; - u4Byte popEventCnt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - BOOLEAN bCCKLock; - BOOLEAN bPreCCKLock; - BOOLEAN bCCKEverLock; - u1Byte nCoexTableType; - - BOOLEAN bForceLpsOn; - u4Byte wrongProfileNotification; - - BOOLEAN bConCurrentRxModeOn; - - u2Byte nScoreBoard; -}COEX_STA_8703B_1ANT, *PCOEX_STA_8703B_1ANT; - -#define BT_8703B_1ANT_ANTDET_PSD_POINTS 256 //MAX:1024 -#define BT_8703B_1ANT_ANTDET_PSD_AVGNUM 1 //MAX:3 -#define BT_8703B_1ANT_ANTDET_BUF_LEN 16 - -typedef struct _PSDSCAN_STA_8703B_1ANT{ - -u4Byte nAntDet_BTLEChannel; //BT LE Channel ex:2412 -u4Byte nAntDet_BTTxTime; -u4Byte nAntDet_PrePSDScanPeakVal; -BOOLEAN nAntDet_IsAntDetAvailable; -u4Byte nAntDet_PSDScanPeakVal; -BOOLEAN nAntDet_IsBTReplyAvailable; -u4Byte nAntDet_PSDScanPeakFreq; - -u1Byte nAntDet_Result; -u1Byte nAntDet_PeakVal[BT_8703B_1ANT_ANTDET_BUF_LEN]; -u1Byte nAntDet_PeakFreq[BT_8703B_1ANT_ANTDET_BUF_LEN]; -u4Byte bAntDet_TryCount; -u4Byte bAntDet_FailCount; -u4Byte nAntDet_IntevalCount; -u4Byte nAntDet_ThresOffset; - -u4Byte nRealCentFreq; -s4Byte nRealOffset; -u4Byte nRealSpan; - -u4Byte nPSDBandWidth; //unit: Hz -u4Byte nPSDPoint; //128/256/512/1024 -u4Byte nPSDReport[1024]; //unit:dB (20logx), 0~255 -u4Byte nPSDReport_MaxHold[1024]; //unit:dB (20logx), 0~255 -u4Byte nPSDStartPoint; -u4Byte nPSDStopPoint; -u4Byte nPSDMaxValuePoint; -u4Byte nPSDMaxValue; -u4Byte nPSDStartBase; -u4Byte nPSDAvgNum; // 1/8/16/32 -u4Byte nPSDGenCount; -BOOLEAN bIsPSDRunning; -BOOLEAN bIsPSDShowMaxOnly; -} PSDSCAN_STA_8703B_1ANT, *PPSDSCAN_STA_8703B_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8703b1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8703b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8703b1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8703b1ant_ScoreBoardStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8703b1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b1ant_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); -VOID -EXhalbtc8703b1ant_AntennaIsolation( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); - -VOID -EXhalbtc8703b1ant_PSDScan( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); -VOID -EXhalbtc8703b1ant_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.c deleted file mode 100644 index 2f5d202a2..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.c +++ /dev/null @@ -1,4865 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8703B Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8703b2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8703B_2ANT GLCoexDm8703b2Ant; -static PCOEX_DM_8703B_2ANT pCoexDm=&GLCoexDm8703b2Ant; -static COEX_STA_8703B_2ANT GLCoexSta8703b2Ant; -static PCOEX_STA_8703B_2ANT pCoexSta=&GLCoexSta8703b2Ant; - -const char *const GLBtInfoSrc8703b2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8703b2Ant=20140903; -u4Byte GLCoexVer8703b2Ant=0x43; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8703b2ant_ -//============================================================ -u1Byte -halbtc8703b2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8703b2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8703b2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - } - } -} - -VOID -halbtc8703b2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); -} - -VOID -halbtc8703b2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if ( (pCoexSta->lowPriorityRx >= 950) && (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bUnderIps) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8703b2ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); -} - -VOID -halbtc8703b2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -BOOLEAN -halbtc8703b2ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist,3, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - - if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState )) - { - return TRUE; - } - - } - - return FALSE; -} - -VOID -halbtc8703b2ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - -#if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 1) // profile from bt patch - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } -#else // profile from bt stack - pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist; - pBtLinkInfo->bScoExist = pStackInfo->bScoExist; - pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist; - pBtLinkInfo->bPanExist = pStackInfo->bPanExist; - pBtLinkInfo->bHidExist = pStackInfo->bHidExist; - - //for win-8 stack HID report error - if(!pStackInfo->bHidExist) - pStackInfo->bHidExist = pCoexSta->bHidExist; //sync BTInfo with BT firmware and stack - // when stack HID report error, here we use the info from bt fw. - if(!pStackInfo->bBtLinkExist) - pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist; -#endif - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8703b2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8703B_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { -#if 0 - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else -#endif - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8703B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8703b2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8703b2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte decBtPwrLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = decBtPwrLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n", - decBtPwrLvl, H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); -} - -VOID -halbtc8703b2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte decBtPwrLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n", - (bForceExec? "force to":""), decBtPwrLvl)); - pCoexDm->curBtDecPwrLvl = decBtPwrLvl; - - if(!bForceExec) - { - if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) - return; - } - halbtc8703b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl); - - pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; -} - -VOID -halbtc8703b2ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8703b2ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8703b2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8703b2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8703b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8703b2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8703b2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8703b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8703b2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!")) ); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8703b2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - //return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8703b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8703b2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val); -} - -VOID -halbtc8703b2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8703b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8703b2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8703b2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8703b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8703b2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x1); - } -} - -VOID -halbtc8703b2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8703b2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8703b2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - //=================BB AGC Gain Table - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001); - } - - - //=================RF Gain - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - if(bAgcTableEn) - { - rssiAdjustVal = 8; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - -VOID -halbtc8703b2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8703b2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8703b2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8703b2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8703b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8703b2ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3); - break; - case 2: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3); - break; - case 3: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 4: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3); - break; - case 5: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3); - break; - case 6: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 7: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 8: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 9: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 10: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 11: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 12: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 13: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 14: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3); - break; - case 15: - halbtc8703b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8703b2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8703b2ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8703b2ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8703b2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8703b2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8703b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8703b2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - - - if ( (pCoexSta->bA2dpExist) && (pCoexSta->bHidExist) ) - { - byte5 = byte5 | 0x1; - } - - H2C_Parameter[0] = byte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = byte5; - - pCoexDm->psTdmaPara[0] = byte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = byte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - -VOID -halbtc8703b2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - /* - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - */ - - //halbtc8703b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - halbtc8703b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8703b2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - //halbtc8703b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - //halbtc8703b2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - //halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8703b2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte fwVer=0, u4Tmp=0; - BOOLEAN bPgExtSwitch=FALSE; - BOOLEAN bUseExtSwitch=FALSE; - u1Byte H2C_Parameter[2] ={0}; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver - - if((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch) - bUseExtSwitch = TRUE; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); - - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to High to avoid A2DP click */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); //WiFi TRx Mask off - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); //BT TRx Mask off - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "no antenna inverse" - H2C_Parameter[0] = 0; - } - else - { - //tell firmware "antenna inverse" - H2C_Parameter[0] = 1; - } - - if (bUseExtSwitch) - { - //ext switch type - H2C_Parameter[1] = 1; - } - else - { - //int switch type - H2C_Parameter[1] = 0; - } - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to "Control by PTA"*/ - H2C_Parameter[0] = 0; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0); - } - } - - // ext switch setting - if(bUseExtSwitch) - { - if (bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); // ext switch main at wifi - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); // ext switch aux at wifi - break; - } - } - else // internal switch - { - if (bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp |= BIT23; - u4Tmp &=~BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //fixed external switch S1->Main, S0->Aux - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); // fixed internal switch S0->WiFi, S1->BT - break; - } - } -} - -VOID -halbtc8703b2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - u1Byte wifiRssiState1, btRssiState; - - - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn) - { - type = type +100; //for WiFi RSSI low or BT RSSI low - pCoexDm->bIsSwitchTo1dot5Ant = TRUE; - } - else - { - pCoexDm->bIsSwitchTo1dot5Ant = FALSE; - } - - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(bTurnOn) - { - switch(type) - { - case 1: - default: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 2: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90); - break; - case 3: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); - break; - case 4: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); - break; - case 5: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90); - break; - case 6: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90); - break; - case 7: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); - break; - case 8: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); - break; - case 9: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 10: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90); - break; - case 11: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); - break; - case 12: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90); - break; - case 13: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90); - break; - case 14: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90); - break; - case 15: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); - break; - case 16: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90); - break; - case 17: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); - break; - case 18: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 71: - //halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 101: - case 105: - case 171: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a, 0x03, 0x70, 0x50); - break; - case 102: - case 106: - case 110: - case 114: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d, 0x03, 0x70, 0x50); - break; - case 103: - case 107: - case 111: - case 115: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50); - break; - case 104: - case 108: - case 112: - case 116: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50); - break; - case 109: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 113: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90); - break; - case 121: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 22: - case 122: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 0: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - case 1: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; - default: - halbtc8703b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8703b2ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8703b2ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8703b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8703b2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8703b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - - -VOID -halbtc8703b2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8703b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8703b2ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bLowPwrDisable=TRUE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n")); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n")); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n")); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -/* - pCoexDm->bNeedRecover0x948 = TRUE; - pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - - halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, FALSE, FALSE); -*/ -} - - -VOID -halbtc8703b2ant_ActionWiFiLinkProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa, u1Tmpb; - - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); -} - -BOOLEAN -halbtc8703b2ant_ActionWifiIdleProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if(BTC_RSSI_HIGH(wifiRssiState1) && - (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE)) - { - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n")); - - halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - return TRUE; - } - else - { - halbtc8703b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - return FALSE; - } - - -} - - - -BOOLEAN -halbtc8703b2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte btRssiState=BTC_RSSI_STATE_HIGH; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE; - BOOLEAN bAsus8703b=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else if(BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bBtHsOn) - return FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); -#if 0 - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_IS_ASUS_8703B, &bAsus8703b); - if(!bAsus8703b) - bCommon = FALSE; - else - bCommon = halbtc8703b2ant_ActionWifiIdleProcess(pBtCoexist); -#else - bCommon = FALSE; -#endif - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - //bCommon = FALSE; - bCommon = halbtc8703b2ant_ActionWifiIdleProcess(pBtCoexist); - } - } - } - - return bCommon; -} -VOID -halbtc8703b2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 71) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 71) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -// SCO only or SCO+PAN(HS) -VOID -halbtc8703b2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - else //for SCO quality & wifi performance balance at 11n mode - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4); - } - } -} - - -VOID -halbtc8703b2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9); - } - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8703b2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - //DbgPrint(" AP#>10(%d)\n", apNum); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - return; - - } - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - else - { - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8703b2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8703b2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - else - { - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - - -//PAN(HS) only -VOID -halbtc8703b2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8703b2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12); - - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - else - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8703b2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3); - //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - } - else - { - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - } - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - } - else - { - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8703b2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(2, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - else - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else - { - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8703b2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8703b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //btRssiState = halbtc8703b2ant_BtRssiState(2, 29, 0); - wifiRssiState1 = halbtc8703b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8703b2ant_BtRssiState(3, BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES, 37); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8703b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5); - - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - else - { // only 802.11N mode we have to dec bt power to 4 degree - if(BTC_RSSI_HIGH(btRssiState)) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - // need to check ap Number of Not - if(apNum < 10) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - } - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else - { - halbtc8703b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8703b2ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8703b2ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8703b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8703b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8703b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8703b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8703b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8703b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8703b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); -} - -VOID -halbtc8703b2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - u4Byte numOfWifiLink=0; - u4Byte wifiLinkStatus=0; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bMiracastPlusBt=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if(pCoexSta->bBtWhckTest) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n")); - halbtc8703b2ant_ActionBtWhckTest(pBtCoexist); - return; - } - - algorithm = halbtc8703b2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8703B_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8703b2ant_ActionBtInquiry(pBtCoexist); - return; - } - else - { - /* - if(pCoexDm->bNeedRecover0x948) - { - pCoexDm->bNeedRecover0x948 = FALSE; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948); - } - */ - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n")); - halbtc8703b2ant_ActionWiFiLinkProcess(pBtCoexist); - return; - } - - //for P2P - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - bMiracastPlusBt = TRUE; - } - else - { - bMiracastPlusBt = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8703b2ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8703b2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8703B_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8703b2ant_ActionSco(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8703b2ant_ActionHid(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8703b2ant_ActionA2dp(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8703b2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8703b2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8703b2ant_ActionPanHs(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8703b2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8703b2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8703b2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8703B_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8703b2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8703b2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8703b2ant_WifiOffHwCfg( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bIsInMpMode = FALSE; - u1Byte H2C_Parameter[2] ={0}; - u4Byte fwVer=0; - - // set wlan_act to low - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1 - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to HIGH */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode); - if(!bIsInMpMode) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi -} - -VOID -halbtc8703b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0, fwVer; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - //Antenna config - halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE); - pCoexSta->disVerInfoCnt = 0; - - // PTA parameter - halbtc8703b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); -} - -//============================================================ -// work around function start with wa_halbtc8703b2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8703b2ant_ -//============================================================ -VOID -EXhalbtc8703b2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u2Byte u2Tmp=0x0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20); - - // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - // set to S1 - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - } -} - -VOID -EXhalbtc8703b2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */ - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - u1Tmp |= 0x1; // antenna inverse - } - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } -} - -VOID -EXhalbtc8703b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8703b2ant_InitHwConfig(pBtCoexist, TRUE); -} - -VOID -EXhalbtc8703b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8703b2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8703b2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8703b2Ant, GLCoexVer8703b2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi-100, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) - { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \ - (pBtLinkInfo->bSlaveRole )? "Slave":"Master"); - CL_PRINTF(cliBuf); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8703b2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - // Sw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism] (before Manual)============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism] (before Manual) ============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - } - - psTdmaCase = pCoexDm->curPsTdma; - - if (pCoexDm->bIsSwitchTo1dot5Ant) - psTdmaCase = psTdmaCase + 100; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, - (pCoexDm->bCurPsTdmaOn? "On":"Off"), - (pCoexDm->bAutoTdmaAdjust? "Adj":"Fix") ); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \ - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \ - u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25); - CL_PRINTF(cliBuf); - - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \ - u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), u1Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ - u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3); - CL_PRINTF(cliBuf); - - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ - ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ - u4Tmp[0]&0xff, u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[0]&0xffff, faOfdm, faCck); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 1) - //halbtc8703b2ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8703b2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8703b2ant_WifiOffHwCfg(pBtCoexist); - halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - halbtc8703b2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - halbtc8703b2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8703b2ant_InitCoexDm(pBtCoexist); - halbtc8703b2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8703b2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8703b2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa, u1Tmpb; - - - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); -} - -VOID -EXhalbtc8703b2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8703b2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - u1Byte apNum=0; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - if(apNum < 10) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8703b2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8703b2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE; - static BOOLEAN bPreScoExist=FALSE; - u4Byte raMask=0x0; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8703B_2ANT_MAX) - rspSource = BT_INFO_SRC_8703B_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n")); - return; - } - - // if 0xff, it means BT is under WHCK test - if (btInfo == 0xff) - pCoexSta->bBtWhckTest = TRUE; - else - pCoexSta->bBtWhckTest = FALSE; - - if(BT_INFO_SRC_8703B_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if (pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if( (pCoexSta->btInfoExt & BIT3) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8703b2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8703B_2ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8703B_2ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8703B_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8703B_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8703B_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8703B_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - - if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE)) - { - if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - { - pCoexSta->bHidExist = TRUE; - btInfo = btInfo | 0x20; - } - } - } - - halbtc8703b2ant_UpdateBtLinkInfo(pBtCoexist); - - if(!(btInfo&BT_INFO_8703B_2ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8703B_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8703B_2ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8703B_2ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8703B_2ANT_B_ACL_BUSY) - { - pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8703B_2ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8703B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8703B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8703B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bBtBusy = TRUE; - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8703b2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8703b2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8703b2ant_WifiOffHwCfg(pBtCoexist); - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0 - halbtc8703b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8703b2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - halbtc8703b2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8703b2ant_InitCoexDm(pBtCoexist); - halbtc8703b2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8703b2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - //static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(pCoexSta->disVerInfoCnt <= 5) - { - pCoexSta->disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8703b2Ant, GLCoexVer8703b2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - - if (pCoexSta->disVerInfoCnt == 3) - { - //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n")); - halbtc8703b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE); - } - } - -#if(BT_AUTO_REPORT_ONLY_8703B_2ANT == 0) - halbtc8703b2ant_QueryBtInfo(pBtCoexist); - halbtc8703b2ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8703b2ant_MonitorBtCtr(pBtCoexist); - halbtc8703b2ant_MonitorWiFiCtr(pBtCoexist); - - if( halbtc8703b2ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust) - { - halbtc8703b2ant_RunCoexistMechanism(pBtCoexist); - } -#endif -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.h deleted file mode 100644 index 7cd275ab2..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8703b2Ant.h +++ /dev/null @@ -1,229 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8703B 2Ant BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8703B_2ANT 1 - - -#define BT_INFO_8703B_2ANT_B_FTP BIT7 -#define BT_INFO_8703B_2ANT_B_A2DP BIT6 -#define BT_INFO_8703B_2ANT_B_HID BIT5 -#define BT_INFO_8703B_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8703B_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8703B_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8703B_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8703B_2ANT_B_CONNECTION BIT0 - -#define BTC_RSSI_COEX_THRESH_TOL_8703B_2ANT 2 - - -#define BT_8703B_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 //WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation -#define BT_8703B_2ANT_BT_RSSI_COEXSWITCH_THRES 46 //BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation - -typedef enum _BT_INFO_SRC_8703B_2ANT{ - BT_INFO_SRC_8703B_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8703B_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8703B_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8703B_2ANT_MAX -}BT_INFO_SRC_8703B_2ANT,*PBT_INFO_SRC_8703B_2ANT; - -typedef enum _BT_8703B_2ANT_BT_STATUS{ - BT_8703B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8703B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8703B_2ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8703B_2ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8703B_2ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8703B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8703B_2ANT_BT_STATUS_MAX -}BT_8703B_2ANT_BT_STATUS,*PBT_8703B_2ANT_BT_STATUS; - -typedef enum _BT_8703B_2ANT_COEX_ALGO{ - BT_8703B_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8703B_2ANT_COEX_ALGO_SCO = 0x1, - BT_8703B_2ANT_COEX_ALGO_HID = 0x2, - BT_8703B_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8703B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8703B_2ANT_COEX_ALGO_PANEDR = 0x5, - BT_8703B_2ANT_COEX_ALGO_PANHS = 0x6, - BT_8703B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8703B_2ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8703B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8703B_2ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8703B_2ANT_COEX_ALGO_MAX = 0xb, -}BT_8703B_2ANT_COEX_ALGO,*PBT_8703B_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8703B_2ANT{ - // fw mechanism - u1Byte preBtDecPwrLvl; - u1Byte curBtDecPwrLvl; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - BOOLEAN bNeedRecover0x948; - u4Byte backup0x948; - - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - BOOLEAN bIsSwitchTo1dot5Ant; -} COEX_DM_8703B_2ANT, *PCOEX_DM_8703B_2ANT; - -typedef struct _COEX_STA_8703B_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8703B_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8703B_2ANT_MAX]; - BOOLEAN bBtWhckTest; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - u1Byte nCoexTableType; - BOOLEAN bForceLpsOn; - - u1Byte disVerInfoCnt; -}COEX_STA_8703B_2ANT, *PCOEX_STA_8703B_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8703b2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8703b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8703b2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8703b2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8703b2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8703b2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.c deleted file mode 100644 index 938df4459..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.c +++ /dev/null @@ -1,1545 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8723A Co-exist mechanism -// -// History -// 2012/08/22 Cosa first check in. -// 2012/11/14 Cosa Revise for 8723A 1Ant out sourcing. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8723a1Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8723A_1ANT GLCoexDm8723a1Ant; -static PCOEX_DM_8723A_1ANT pCoexDm=&GLCoexDm8723a1Ant; -static COEX_STA_8723A_1ANT GLCoexSta8723a1Ant; -static PCOEX_STA_8723A_1ANT pCoexSta=&GLCoexSta8723a1Ant; - -const char *const GLBtInfoSrc8723a1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8723a1ant_ -//============================================================ -VOID -halbtc8723a1ant_Reg0x550Bit3( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSet - ) -{ - u1Byte u1tmp=0; - - u1tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x550); - if(bSet) - { - u1tmp |= BIT3; - } - else - { - u1tmp &= ~BIT3; - } - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x550, u1tmp); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], set 0x550[3]=%d\n", (bSet? 1:0))); -} - -VOID -halbtc8723a1ant_NotifyFwScan( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte scanType - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(BTC_SCAN_START == scanType) - H2C_Parameter[0] = 0x1; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Notify FW for wifi scan, write 0x3b=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3b, 1, H2C_Parameter); -} - -VOID -halbtc8723a1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x38, 1, H2C_Parameter); -} - -VOID -halbtc8723a1ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8723a1ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8723a1ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8723a1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - tmpU1 |= BIT0; - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8723a1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8723a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8723a1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8723a1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8723a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8723a1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x25, 1, H2C_Parameter); -} - -VOID -halbtc8723a1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8723a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8723a1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - // byte1[1:0] != 0 means enable pstdma - // for 2Ant bt coexist, if byte1 != 0 means enable pstdma - if(byte1) - { - if(bApEnable) - { - if(type != 5 && type != 12) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - } - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3a, 5, H2C_Parameter); -} - -VOID -halbtc8723a1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(pCoexDm->bCurPsTdmaOn) - { - switch(pCoexDm->curPsTdma) - { - case 1: - default: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x0, 0x40); - break; - case 2: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x0, 0x40); - break; - case 3: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x3f, 0x3, 0x10, 0x40); - break; - case 4: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x15, 0x3, 0x10, 0x0); - break; - case 5: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0x15, 0x3, 0x35, 0xc0); - break; - - case 8: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 9: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 10: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x0, 0x40); - break; - case 12: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0xa9, 0xa, 0x3, 0x15, 0xc0); - break; - - case 18: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - - case 20: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x2a, 0x2a, 0x0, 0x0); - break; - case 21: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x20, 0x3, 0x10, 0x40); - break; - case 22: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x1a, 0x1a, 0x2, 0x40); - break; - case 23: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x12, 0x12, 0x2, 0x40); - break; - case 24: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0xa, 0xa, 0x2, 0x40); - break; - case 25: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40); - break; - case 26: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 27: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x13, 0x5, 0x5, 0x2, 0x40); - break; - case 28: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x3, 0x2f, 0x2f, 0x0, 0x0); - break; - - } - } - else - { - // disable PS tdma - switch(pCoexDm->curPsTdma) - { - case 8: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x8, 0x0, 0x0, 0x0, 0x0); - break; - case 0: - default: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210); - break; - case 9: - halbtc8723a1ant_SetFwPstdma(pBtCoexist, type, 0x0, 0x0, 0x0, 0x0, 0x0); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x110); - break; - - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - - -VOID -halbtc8723a1ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // sw all off - halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - - // hw all off - halbtc8723a1ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); -} - -VOID -halbtc8723a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); -} - -VOID -halbtc8723a1ant_BtEnableAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); -} - -VOID -halbtc8723a1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8723a1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - halbtc8723a1ant_BtEnableAction(pBtCoexist); - } - else - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -VOID -halbtc8723a1ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - u1Byte btState; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - btState = pCoexDm->btStatus; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], TdmaDurationAdjust()\n")); - if(pCoexDm->psTdmaGlobalCnt != pCoexDm->psTdmaMonitorCnt) - { - pCoexDm->psTdmaMonitorCnt = 0; - pCoexDm->psTdmaGlobalCnt = 0; - } - if(pCoexDm->psTdmaMonitorCnt == 0) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], first run BT A2DP + WiFi busy state!!\n")); - if(btState == BT_STATE_8723A_1ANT_ACL_ONLY_BUSY) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - pCoexDm->psTdmaDuAdjType = 22; - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], retryCount = %d\n", retryCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT TxRx counter H+L <= 1200\n")); - if(btState != BT_STATE_8723A_1ANT_ACL_ONLY_BUSY) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], NOT ACL only busy!\n")); - if(BTC_WIFI_BW_HT40 != wifiBw) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 20MHz\n")); - if(result == -1) - { - if(pCoexDm->curPsTdma == 22) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - pCoexDm->psTdmaDuAdjType = 23; - } - else if(pCoexDm->curPsTdma == 23) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - pCoexDm->psTdmaDuAdjType = 24; - } - else if(pCoexDm->curPsTdma == 24) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25); - pCoexDm->psTdmaDuAdjType = 25; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 25) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - pCoexDm->psTdmaDuAdjType = 24; - } - else if(pCoexDm->curPsTdma == 24) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - pCoexDm->psTdmaDuAdjType = 23; - } - else if(pCoexDm->curPsTdma == 23) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - pCoexDm->psTdmaDuAdjType = 22; - } - } - // error handle, if not in the following state, - // set psTdma again. - if( (pCoexDm->psTdmaDuAdjType != 22) && - (pCoexDm->psTdmaDuAdjType != 23) && - (pCoexDm->psTdmaDuAdjType != 24) && - (pCoexDm->psTdmaDuAdjType != 25) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n")); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - pCoexDm->psTdmaDuAdjType = 23; - } - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 40MHz\n")); - if(result == -1) - { - if(pCoexDm->curPsTdma == 23) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - pCoexDm->psTdmaDuAdjType = 24; - } - else if(pCoexDm->curPsTdma == 24) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25); - pCoexDm->psTdmaDuAdjType = 25; - } - else if(pCoexDm->curPsTdma == 25) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 27); - pCoexDm->psTdmaDuAdjType = 27; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 27) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 25); - pCoexDm->psTdmaDuAdjType = 25; - } - else if(pCoexDm->curPsTdma == 25) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - pCoexDm->psTdmaDuAdjType = 24; - } - else if(pCoexDm->curPsTdma == 24) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - pCoexDm->psTdmaDuAdjType = 23; - } - } - // error handle, if not in the following state, - // set psTdma again. - if( (pCoexDm->psTdmaDuAdjType != 23) && - (pCoexDm->psTdmaDuAdjType != 24) && - (pCoexDm->psTdmaDuAdjType != 25) && - (pCoexDm->psTdmaDuAdjType != 27) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n")); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - pCoexDm->psTdmaDuAdjType = 24; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ACL only busy\n")); - if (result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 11) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - - // error handle, if not in the following state, - // set psTdma again. - if( (pCoexDm->psTdmaDuAdjType != 1) && - (pCoexDm->psTdmaDuAdjType != 2) && - (pCoexDm->psTdmaDuAdjType != 9) && - (pCoexDm->psTdmaDuAdjType != 11) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], duration case out of handle!!\n")); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } - pCoexDm->psTdmaMonitorCnt++; -} - - -VOID -halbtc8723a1ant_CoexForWifiConnect( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiConnected=FALSE, bWifiBusy=FALSE; - u1Byte btState, btInfoOriginal=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - btState = pCoexDm->btStatus; - btInfoOriginal = pCoexSta->btInfoC2h[BT_INFO_SRC_8723A_1ANT_BT_RSP][0]; - - if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi connected!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if( !bWifiBusy && - ((BT_STATE_8723A_1ANT_NO_CONNECTION == btState) || - (BT_STATE_8723A_1ANT_CONNECT_IDLE == btState)) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], [Wifi is idle] or [Bt is non connected idle or Bt is connected idle]!!\n")); - - if(BT_STATE_8723A_1ANT_NO_CONNECTION == btState) - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - else if(BT_STATE_8723A_1ANT_CONNECT_IDLE == btState) - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0); - } - else - { - if( (BT_STATE_8723A_1ANT_SCO_ONLY_BUSY == btState) || - (BT_STATE_8723A_1ANT_ACL_SCO_BUSY == btState) || - (BT_STATE_8723A_1ANT_HID_BUSY == btState) || - (BT_STATE_8723A_1ANT_HID_SCO_BUSY == btState) ) - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0x60); - } - else - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0); - } - switch(btState) - { - case BT_STATE_8723A_1ANT_NO_CONNECTION: - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - break; - case BT_STATE_8723A_1ANT_CONNECT_IDLE: - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - break; - case BT_STATE_8723A_1ANT_INQ_OR_PAG: - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - break; - case BT_STATE_8723A_1ANT_SCO_ONLY_BUSY: - case BT_STATE_8723A_1ANT_ACL_SCO_BUSY: - case BT_STATE_8723A_1ANT_HID_BUSY: - case BT_STATE_8723A_1ANT_HID_SCO_BUSY: - halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist); - break; - case BT_STATE_8723A_1ANT_ACL_ONLY_BUSY: - if (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP) - { - halbtc8723a1ant_TdmaDurationAdjust(pBtCoexist); - } - else if(btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - else if( (btInfoOriginal&BT_INFO_8723A_1ANT_B_A2DP) && - (btInfoOriginal&BT_INFO_8723A_1ANT_B_FTP) ) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - } - else - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], error!!!, undefined case in halbtc8723a1ant_CoexForWifiConnect()!!\n")); - break; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is disconnected!!\n")); - } - - pCoexDm->psTdmaGlobalCnt++; -} - -//============================================================ -// work around function start with wa_halbtc8723a1ant_ -//============================================================ -VOID -wa_halbtc8723a1ant_MonitorC2h( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte tmp1b=0x0; - u4Byte curC2hTotalCnt=0x0; - static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0; - - curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_BT_RSP]; - - if(curC2hTotalCnt == preC2hTotalCnt) - { - sameCntPollingTime++; - } - else - { - preC2hTotalCnt = curC2hTotalCnt; - sameCntPollingTime = 0; - } - - if(sameCntPollingTime >= 2) - { - tmp1b = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x1af); - if(tmp1b != 0x0) - { - pCoexSta->c2hHangDetectCnt++; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x1af, 0x0); - } - } -} - -//============================================================ -// extern function start with EXhalbtc8723a1ant_ -//============================================================ -VOID -EXhalbtc8723a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); - - // enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // coex table - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); // 1-Ant coex - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); // wifi break table - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); //coex table - - // antenna switch control parameter - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x858, 0xaaaaaaaa); - - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x860, 0x210); //set antenna at wifi side if ANTSW is software control - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x870, 0x300); //SPDT(connected with TRSW) control by hardware PTA - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x874, 0x22804000); //ANTSW keep by GNT_BT - - // coexistence parameters - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); // enable RTK mode PTA -} - -VOID -EXhalbtc8723a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8723a1ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8723a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!"); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_1ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - if(pStackInfo->bProfileNotified) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \ - pCoexSta->c2hHangDetectCnt); - CL_PRINTF(cliBuf); - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - if(!pBtCoexist->bManualControl) - { - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \ - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x783); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x796); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \ - u1Tmp[0], u1Tmp[1], u1Tmp[2]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x484); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xdac); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8723a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - halbtc8723a1ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - //halbtc8723a1ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8723a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } -} - -VOID -EXhalbtc8723a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE; - - halbtc8723a1ant_NotifyFwScan(pBtCoexist, type); - - if(pBtCoexist->btInfo.bBtDisabled) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - } - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - //set 0x550[3]=1 before PsTdma - halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE); - } - - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - halbtc8723a1ant_CoexForWifiConnect(pBtCoexist); - } - } - } -} - -VOID -EXhalbtc8723a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE; - - if(pBtCoexist->btInfo.bBtDisabled) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - } - else - { - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - //set 0x550[3]=1 before PsTdma - halbtc8723a1ant_Reg0x550Bit3(pBtCoexist, TRUE); - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); // extend wifi slot - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - halbtc8723a1ant_CoexForWifiConnect(pBtCoexist); - } - } - } -} - -VOID -EXhalbtc8723a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } -} - -VOID -EXhalbtc8723a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - if(pBtCoexist->btInfo.bBtDisabled) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - } - else - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 18); - } - } -} - -VOID -EXhalbtc8723a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bForceLps=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = BT_INFO_SRC_8723A_1ANT_BT_RSP; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 0) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8723A_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = - pCoexSta->btInfoC2h[rspSource][1]; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][2]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][3]; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8723A_1ANT_B_INQ_PAGE) - { - pCoexSta->bC2hBtInquiryPage = TRUE; - } - else - { - pCoexSta->bC2hBtInquiryPage = FALSE; - } - btInfo &= ~BIT2; - if(!(btInfo & BIT0)) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_NO_CONNECTION; - bForceLps = FALSE; - } - else - { - bForceLps = TRUE; - if(btInfo == 0x1) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_CONNECT_IDLE; - } - else if(btInfo == 0x9) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_ONLY_BUSY; - bBtBusy = TRUE; - } - else if(btInfo == 0x13) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_SCO_ONLY_BUSY; - bBtBusy = TRUE; - } - else if(btInfo == 0x1b) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_ACL_SCO_BUSY; - bBtBusy = TRUE; - } - else if(btInfo == 0x29) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_BUSY; - bBtBusy = TRUE; - } - else if(btInfo == 0x3b) - { - pCoexDm->btStatus = BT_STATE_8723A_1ANT_HID_SCO_BUSY; - bBtBusy = TRUE; - } - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bBtBusy); - if(bForceLps) - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - else - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - - if( (BT_STATE_8723A_1ANT_NO_CONNECTION == pCoexDm->btStatus) || - (BT_STATE_8723A_1ANT_CONNECT_IDLE == pCoexDm->btStatus) ) - { - if(pCoexSta->bC2hBtInquiryPage) - pCoexDm->btStatus = BT_STATE_8723A_1ANT_INQ_OR_PAG; - } -} - -VOID -EXhalbtc8723a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - - halbtc8723a1ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a1ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE); - - halbtc8723a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8723a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8723a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiConnected=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Periodical!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // work around for c2h hang - wa_halbtc8723a1ant_MonitorC2h(pBtCoexist); - - halbtc8723a1ant_QueryBtInfo(pBtCoexist); - halbtc8723a1ant_MonitorBtCtr(pBtCoexist); - halbtc8723a1ant_MonitorBtEnableDisable(pBtCoexist); - - - if(bScan) - return; - if(bLink) - return; - - if(bWifiConnected) - { - if(pBtCoexist->btInfo.bBtDisabled) - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - - halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - } - else - { - halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a1ant_CoexForWifiConnect(pBtCoexist); - } - } - else - { - halbtc8723a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - halbtc8723a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a1ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - } -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.h deleted file mode 100644 index e1c096e28..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a1Ant.h +++ /dev/null @@ -1,172 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8723A 1Ant BT Co-exist definition -//=========================================== -#define BT_INFO_8723A_1ANT_B_FTP BIT7 -#define BT_INFO_8723A_1ANT_B_A2DP BIT6 -#define BT_INFO_8723A_1ANT_B_HID BIT5 -#define BT_INFO_8723A_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8723A_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8723A_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8723A_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8723A_1ANT_B_CONNECTION BIT0 - -typedef enum _BT_STATE_8723A_1ANT{ - BT_STATE_8723A_1ANT_DISABLED = 0, - BT_STATE_8723A_1ANT_NO_CONNECTION = 1, - BT_STATE_8723A_1ANT_CONNECT_IDLE = 2, - BT_STATE_8723A_1ANT_INQ_OR_PAG = 3, - BT_STATE_8723A_1ANT_ACL_ONLY_BUSY = 4, - BT_STATE_8723A_1ANT_SCO_ONLY_BUSY = 5, - BT_STATE_8723A_1ANT_ACL_SCO_BUSY = 6, - BT_STATE_8723A_1ANT_HID_BUSY = 7, - BT_STATE_8723A_1ANT_HID_SCO_BUSY = 8, - BT_STATE_8723A_1ANT_MAX -}BT_STATE_8723A_1ANT, *PBT_STATE_8723A_1ANT; - -#define BTC_RSSI_COEX_THRESH_TOL_8723A_1ANT 2 - -typedef enum _BT_INFO_SRC_8723A_1ANT{ - BT_INFO_SRC_8723A_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8723A_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8723A_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8723A_1ANT_MAX -}BT_INFO_SRC_8723A_1ANT,*PBT_INFO_SRC_8723A_1ANT; - -typedef enum _BT_8723A_1ANT_BT_STATUS{ - BT_8723A_1ANT_BT_STATUS_IDLE = 0x0, - BT_8723A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8723A_1ANT_BT_STATUS_NON_IDLE = 0x2, - BT_8723A_1ANT_BT_STATUS_MAX -}BT_8723A_1ANT_BT_STATUS,*PBT_8723A_1ANT_BT_STATUS; - -typedef enum _BT_8723A_1ANT_COEX_ALGO{ - BT_8723A_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8723A_1ANT_COEX_ALGO_SCO = 0x1, - BT_8723A_1ANT_COEX_ALGO_HID = 0x2, - BT_8723A_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8723A_1ANT_COEX_ALGO_PANEDR = 0x4, - BT_8723A_1ANT_COEX_ALGO_PANHS = 0x5, - BT_8723A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x6, - BT_8723A_1ANT_COEX_ALGO_PANEDR_HID = 0x7, - BT_8723A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x8, - BT_8723A_1ANT_COEX_ALGO_HID_A2DP = 0x9, - BT_8723A_1ANT_COEX_ALGO_MAX -}BT_8723A_1ANT_COEX_ALGO,*PBT_8723A_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8723A_1ANT{ - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - u4Byte psTdmaMonitorCnt; - u4Byte psTdmaGlobalCnt; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; -} COEX_DM_8723A_1ANT, *PCOEX_DM_8723A_1ANT; - -typedef struct _COEX_STA_8723A_1ANT{ - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - u1Byte preBtRssiState; - u1Byte preBtRssiState1; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8723A_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8723A_1ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - //BOOLEAN bHoldForStackOperation; - //u1Byte bHoldPeriodCnt; - // this is for c2h hang work-around - u4Byte c2hHangDetectCnt; -}COEX_STA_8723A_1ANT, *PCOEX_STA_8723A_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8723a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8723a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.c deleted file mode 100644 index 13354570e..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.c +++ /dev/null @@ -1,3747 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8723A Co-exist mechanism -// -// History -// 2012/08/22 Cosa first check in. -// 2012/11/14 Cosa Revise for 8723A 2Ant out sourcing. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8723a2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8723A_2ANT GLCoexDm8723a2Ant; -static PCOEX_DM_8723A_2ANT pCoexDm=&GLCoexDm8723a2Ant; -static COEX_STA_8723A_2ANT GLCoexSta8723a2Ant; -static PCOEX_STA_8723A_2ANT pCoexSta=&GLCoexSta8723a2Ant; - -const char *const GLBtInfoSrc8723a2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8723a2ant_ -//============================================================ -BOOLEAN -halbtc8723a2ant_IsWifiIdle( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bWifiConnected) - return FALSE; - if(bScan) - return FALSE; - if(bLink) - return FALSE; - if(bRoam) - return FALSE; - - return TRUE; -} - -BOOLEAN -halbtc8723a2ant_IsWifiConnectedIdle( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiConnected=FALSE, bScan=FALSE, bLink=FALSE, bRoam=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(bScan) - return FALSE; - if(bLink) - return FALSE; - if(bRoam) - return FALSE; - if(bWifiConnected && !bWifiBusy) - return TRUE; - else - return FALSE; -} - -u1Byte -halbtc8723a2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8723a2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8723a2ant_IndicateWifiChnlBwInfo( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x19=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x19, 3, H2C_Parameter); -} - -VOID -halbtc8723a2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x38=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x38, 1, H2C_Parameter); -} -u1Byte -halbtc8723a2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bBtHsOn=FALSE, bBtBusy=FALSE, bLimitedDig=FALSE; - u1Byte algorithm=BT_8723A_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - //====================== - // here we get BT status first - //====================== - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_IDLE; - - if((pStackInfo->bScoExist) ||(bBtHsOn) ||(pStackInfo->bHidExist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO or HID or HS exists, set BT non-idle !!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE; - } - else - { - // A2dp profile - if( (pBtCoexist->stackInfo.numOfLink == 1) && - (pStackInfo->bA2dpExist) ) - { - if( (pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 100) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP, low priority tx+rx < 100, set BT connected-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP, low priority tx+rx >= 100, set BT non-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE; - } - } - // Pan profile - if( (pBtCoexist->stackInfo.numOfLink == 1) && - (pStackInfo->bPanExist) ) - { - if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, low priority tx+rx < 600, set BT connected-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE; - } - else - { - if(pCoexSta->lowPriorityTx) - { - if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, low priority rx/tx > 9, set BT connected-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE; - } - } - } - if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN, set BT non-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE; - } - } - // Pan+A2dp profile - if( (pBtCoexist->stackInfo.numOfLink == 2) && - (pStackInfo->bA2dpExist) && - (pStackInfo->bPanExist) ) - { - if((pCoexSta->lowPriorityTx+ pCoexSta->lowPriorityRx) < 600) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, low priority tx+rx < 600, set BT connected-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE; - } - else - { - if(pCoexSta->lowPriorityTx) - { - if((pCoexSta->lowPriorityRx /pCoexSta->lowPriorityTx)>9 ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, low priority rx/tx > 9, set BT connected-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE; - } - } - } - if(BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN+A2DP, set BT non-idle!!!\n")); - pCoexDm->btStatus = BT_8723A_2ANT_BT_STATUS_NON_IDLE; - } - } - } - if(BT_8723A_2ANT_BT_STATUS_IDLE != pCoexDm->btStatus) - { - bBtBusy = TRUE; - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - //====================== - - if(!pStackInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n")); - return algorithm; - } - - if(pStackInfo->bScoExist) - numOfDiffProfile++; - if(pStackInfo->bHidExist) - numOfDiffProfile++; - if(pStackInfo->bPanExist) - numOfDiffProfile++; - if(pStackInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pStackInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_SCO; - } - else - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP; - } - else if(pStackInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pStackInfo->bScoExist) - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_SCO; - } - else if(pStackInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP; - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pStackInfo->bScoExist) - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID; - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pStackInfo->bScoExist) - { - if( pStackInfo->bHidExist && - pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8723A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -BOOLEAN -halbtc8723a2ant_NeedToDecBtPwr( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bRet=FALSE; - BOOLEAN bBtHsOn=FALSE, bWifiConnected=FALSE; - s4Byte btHsRssi=0; - u1Byte btRssiState=BTC_RSSI_STATE_HIGH; - - btRssiState = halbtc8723a2ant_BtRssiState(2, 42, 0); - - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn)) - return FALSE; - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected)) - return FALSE; - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi)) - return FALSE; - if(BTC_RSSI_LOW(btRssiState)) - return FALSE; - - if(bWifiConnected) - { - if(bBtHsOn) - { - if(btHsRssi > 37) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for HS mode!!\n")); - bRet = TRUE; - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n")); - bRet = TRUE; - } - } - - return bRet; -} - -VOID -halbtc8723a2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x29=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x29, 1, H2C_Parameter); -} - -VOID -halbtc8723a2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bDecBtPwr - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bDecBtPwr) - { - H2C_Parameter[0] |= BIT1; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power : %s, FW write 0x21=0x%x\n", - (bDecBtPwr? "Yes!!":"No!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x21, 1, H2C_Parameter); -} - -VOID -halbtc8723a2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDecBtPwr - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power = %s\n", - (bForceExec? "force to":""), ((bDecBtPwr)? "ON":"OFF"))); - pCoexDm->bCurDecBtPwr = bDecBtPwr; - - if(!bForceExec) - { - if(pCoexDm->bPreDecBtPwr == pCoexDm->bCurDecBtPwr) - return; - } - halbtc8723a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->bCurDecBtPwr); - - pCoexDm->bPreDecBtPwr = pCoexDm->bCurDecBtPwr; -} - -VOID -halbtc8723a2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8723a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8723a2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xf0ff7); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8723a2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8723a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8723a2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - tmpU1 |= BIT0; - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8723a2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8723a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8723a2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, swDacSwingLvl); - } - else - { - pBtCoexist->fBtcSetBbReg(pBtCoexist, 0x880, 0xff000000, 0xc0); - } -} - - -VOID -halbtc8723a2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8723a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8723a2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a07611); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc04,0x3a05611); - } -} - -VOID -halbtc8723a2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8723a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8723a2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4e1c0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4d1d0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4c1e0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4b1f0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x4a200001); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xdc000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x90000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x51000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x12000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x00355); - - rssiAdjustVal = 6; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x641c0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x631d0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x621e0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x611f0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78,0x60200001); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x32000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0x71000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xb0000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x12, 0xfffff, 0xfc000); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1a, 0xfffff, 0x30355); - } - - // set rssiAdjustVal for wifi module. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - - -VOID -halbtc8723a2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8723a2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8723a2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8723a2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8723a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8723a2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x25=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x25, 1, H2C_Parameter); -} - -VOID -halbtc8723a2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8723a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8723a2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - - H2C_Parameter[0] = byte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = byte5; - - pCoexDm->psTdmaPara[0] = byte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = byte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x3a(5bytes)=0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x3a, 5, H2C_Parameter); -} - -VOID -halbtc8723a2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - u4Byte btTxRxCnt=0; - - btTxRxCnt = pCoexSta->highPriorityTx+pCoexSta->highPriorityRx+ - pCoexSta->lowPriorityTx+pCoexSta->lowPriorityRx; - - if(btTxRxCnt > 3000) - { - pCoexDm->bCurPsTdmaOn = TRUE; - pCoexDm->curPsTdma = 8; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], turn ON PS TDMA, type=%d for BT tx/rx counters=%d(>3000)\n", - pCoexDm->curPsTdma, btTxRxCnt)); - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(pCoexDm->bCurPsTdmaOn) - { - switch(pCoexDm->curPsTdma) - { - case 1: - default: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98); - break; - case 2: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98); - break; - case 3: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98); - break; - case 4: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0xe1, 0x80); - break; - case 5: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98); - break; - case 6: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98); - break; - case 7: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98); - break; - case 8: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x5, 0x5, 0x60, 0x80); - break; - case 9: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x98); - break; - case 10: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x98); - break; - case 11: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x98); - break; - case 12: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98); - break; - case 13: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x98); - break; - case 14: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x98); - break; - case 15: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x98); - break; - case 16: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x98); - break; - case 17: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x80); - break; - case 18: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x98); - break; - case 19: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x98); - break; - case 20: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x98); - break; - } - } - else - { - // disable PS tdma - switch(pCoexDm->curPsTdma) - { - case 0: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - break; - case 1: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - break; - default: - halbtc8723a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - - -VOID -halbtc8723a2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - // sw all off - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - // hw all off - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); -} - -VOID -halbtc8723a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8723a2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0xffff, 0x3); - halbtc8723a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a2ant_RfShrink(pBtCoexist, FORCE_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, FORCE_EXEC, FALSE, 0xc0); -} - -VOID -halbtc8723a2ant_BtInquiryPage( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bLowPwrDisable=TRUE; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); -} - -VOID -halbtc8723a2ant_BtEnableAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiConnected=FALSE; - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); -} - -VOID -halbtc8723a2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8723a2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - halbtc8723a2ant_BtEnableAction(pBtCoexist); - } - } -} - -BOOLEAN -halbtc8723a2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE; - BOOLEAN bLowPwrDisable=FALSE; - - if(!pStackInfo->bBtLinkExist) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - } - else - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) && - BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + Bt idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) && - (BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + BT idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) && - (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + Bt connected idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else if(!halbtc8723a2ant_IsWifiIdle(pBtCoexist) && - (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + Bt connected idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else if(halbtc8723a2ant_IsWifiIdle(pBtCoexist) && - (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle + BT non-idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else if(halbtc8723a2ant_IsWifiConnectedIdle(pBtCoexist) && - (BT_8723A_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected-idle + BT non-idle!!\n")); - - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - - bCommon = TRUE; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-idle + BT non-idle!!\n")); - halbtc8723a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x20); - - bCommon = FALSE; - } - - return bCommon; -} -VOID -halbtc8723a2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(pCoexDm->bResetTdmaAdjust) - { - pCoexDm->bResetTdmaAdjust = FALSE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -// SCO only or SCO+PAN(HS) -VOID -halbtc8723a2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1; - u4Byte wifiBw; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - - -VOID -halbtc8723a2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1; - u4Byte wifiBw; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8723a2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - } - else - { - if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - else - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - } - else - { - if(btInfoExt&BIT0) //a2dp rate, 1:basic /0:edr - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - else - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -VOID -halbtc8723a2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - - -//PAN(HS) only -VOID -halbtc8723a2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState; - u4Byte wifiBw; - - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8723a2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - } - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - } - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -VOID -halbtc8723a2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1; - u4Byte wifiBw; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - else - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8723a2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - } - else //a2dp edr rate - { - halbtc8723a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -VOID -halbtc8723a2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - - if(halbtc8723a2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8723a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0xffff, 0x3); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 37, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else //a2dp edr rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 1); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 1); - } - } - - // sw mechanism - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - wifiRssiState = halbtc8723a2ant_WifiRssiState(pBtCoexist, 0, 2, 27, 0); - wifiRssiState1 = halbtc8723a2ant_WifiRssiState(pBtCoexist, 1, 2, 47, 0); - - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else //a2dp edr rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 1); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8723a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 1); - } - } - - // sw mechanism - if( (wifiRssiState1 == BTC_RSSI_STATE_HIGH) || - (wifiRssiState1 == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, TRUE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - else - { - halbtc8723a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, FALSE); - halbtc8723a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, FALSE, 0xc0); - } - } -} - -VOID -halbtc8723a2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Manual control!!!\n")); - return; - } - - if(pStackInfo->bProfileNotified) - { - if(pCoexSta->bHoldForStackOperation) - { - // if bt inquiry/page/pair, do not execute. - return; - } - - algorithm = halbtc8723a2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bHoldPeriodCnt && (BT_8723A_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex],Hold BT inquiry/page scan setting (cnt = %d)!!\n", - pCoexSta->bHoldPeriodCnt)); - if(pCoexSta->bHoldPeriodCnt >= 6) - { - pCoexSta->bHoldPeriodCnt = 0; - // next time the coexist parameters should be reset again. - } - else - pCoexSta->bHoldPeriodCnt++; - return; - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - if(halbtc8723a2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bResetTdmaAdjust = TRUE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bResetTdmaAdjust = TRUE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8723A_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8723a2ant_ActionSco(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8723a2ant_ActionHid(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8723a2ant_ActionA2dp(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8723a2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8723a2ant_ActionPanHs(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8723a2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8723a2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8723a2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8723A_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8723a2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8723a2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } - } -} - -//============================================================ -// work around function start with wa_halbtc8723a2ant_ -//============================================================ -VOID -wa_halbtc8723a2ant_MonitorC2h( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte tmp1b=0x0; - u4Byte curC2hTotalCnt=0x0; - static u4Byte preC2hTotalCnt=0x0, sameCntPollingTime=0x0; - - curC2hTotalCnt+=pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_BT_RSP]; - - if(curC2hTotalCnt == preC2hTotalCnt) - { - sameCntPollingTime++; - } - else - { - preC2hTotalCnt = curC2hTotalCnt; - sameCntPollingTime = 0; - } - - if(sameCntPollingTime >= 2) - { - tmp1b = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x1af); - if(tmp1b != 0x0) - { - pCoexSta->c2hHangDetectCnt++; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x1af, 0x0); - } - } -} - -//============================================================ -// extern function start with EXhalbtc8723a2ant_ -//============================================================ -VOID -EXhalbtc8723a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8723a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - u4Byte u4Tmp=0; - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); -} - -VOID -EXhalbtc8723a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8723a2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8723a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!"); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723A_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - if(pStackInfo->bProfileNotified) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723a2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "write 0x1af=0x0 num", \ - pCoexSta->c2hHangDetectCnt); - CL_PRINTF(cliBuf); - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - if(!pBtCoexist->bManualControl) - { - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->bCurDecBtPwr, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x783); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x796); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/ 0x783/ 0x796", \ - u1Tmp[0], u1Tmp[1], u1Tmp[2]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x880", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x484); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x484(rate adaptive)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xdac); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0xda0/0xda4/0xda8/0xdac(FA cnt)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u4Tmp[3]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hp rx[31:16]/tx[15:0])", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8723a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - halbtc8723a2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - //halbtc8723a2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8723a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - } -} - -VOID -EXhalbtc8723a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } -} - -VOID -EXhalbtc8723a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8723a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - halbtc8723a2ant_IndicateWifiChnlBwInfo(pBtCoexist, type); -} - -VOID -EXhalbtc8723a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8723a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = BT_INFO_SRC_8723A_2ANT_BT_RSP; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 0) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8723A_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = - pCoexSta->btInfoC2h[rspSource][1]; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][2]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][3]; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8723A_2ANT_B_INQ_PAGE) - { - pCoexSta->bC2hBtInquiryPage = TRUE; - } - else - { - pCoexSta->bC2hBtInquiryPage = FALSE; - } -} - -VOID -EXhalbtc8723a2ant_StackOperationNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_STACK_OP_INQ_PAGE_PAIR_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], StackOP Inquiry/page/pair start notify\n")); - pCoexSta->bHoldForStackOperation = TRUE; - pCoexSta->bHoldPeriodCnt = 1; - halbtc8723a2ant_BtInquiryPage(pBtCoexist); - } - else if(BTC_STACK_OP_INQ_PAGE_PAIR_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], StackOP Inquiry/page/pair finish notify\n")); - pCoexSta->bHoldForStackOperation = FALSE; - } -} - -VOID -EXhalbtc8723a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8723a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8723a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8723a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Periodical!!\n")); - - // work around for c2h hang - wa_halbtc8723a2ant_MonitorC2h(pBtCoexist); - - halbtc8723a2ant_QueryBtInfo(pBtCoexist); - halbtc8723a2ant_MonitorBtCtr(pBtCoexist); - halbtc8723a2ant_MonitorBtEnableDisable(pBtCoexist); - - halbtc8723a2ant_RunCoexistMechanism(pBtCoexist); -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.h deleted file mode 100644 index 2ce475c1d..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723a2Ant.h +++ /dev/null @@ -1,185 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8723A 2Ant BT Co-exist definition -//=========================================== -#define BT_INFO_8723A_2ANT_B_FTP BIT7 -#define BT_INFO_8723A_2ANT_B_A2DP BIT6 -#define BT_INFO_8723A_2ANT_B_HID BIT5 -#define BT_INFO_8723A_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8723A_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8723A_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8723A_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8723A_2ANT_B_CONNECTION BIT0 - -#define BTC_RSSI_COEX_THRESH_TOL_8723A_2ANT 2 - -typedef enum _BT_INFO_SRC_8723A_2ANT{ - BT_INFO_SRC_8723A_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8723A_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8723A_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8723A_2ANT_MAX -}BT_INFO_SRC_8723A_2ANT,*PBT_INFO_SRC_8723A_2ANT; - -typedef enum _BT_8723A_2ANT_BT_STATUS{ - BT_8723A_2ANT_BT_STATUS_IDLE = 0x0, - BT_8723A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8723A_2ANT_BT_STATUS_NON_IDLE = 0x2, - BT_8723A_2ANT_BT_STATUS_MAX -}BT_8723A_2ANT_BT_STATUS,*PBT_8723A_2ANT_BT_STATUS; - -typedef enum _BT_8723A_2ANT_COEX_ALGO{ - BT_8723A_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8723A_2ANT_COEX_ALGO_SCO = 0x1, - BT_8723A_2ANT_COEX_ALGO_HID = 0x2, - BT_8723A_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8723A_2ANT_COEX_ALGO_PANEDR = 0x4, - BT_8723A_2ANT_COEX_ALGO_PANHS = 0x5, - BT_8723A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x6, - BT_8723A_2ANT_COEX_ALGO_PANEDR_HID = 0x7, - BT_8723A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x8, - BT_8723A_2ANT_COEX_ALGO_HID_A2DP = 0x9, - BT_8723A_2ANT_COEX_ALGO_MAX -}BT_8723A_2ANT_COEX_ALGO,*PBT_8723A_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8723A_2ANT{ - // fw mechanism - BOOLEAN bPreDecBtPwr; - BOOLEAN bCurDecBtPwr; - //BOOLEAN bPreBtLnaConstrain; - //BOOLEAN bCurBtLnaConstrain; - //u1Byte bPreBtPsdMode; - //u1Byte bCurBtPsdMode; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - //BOOLEAN bPreBtAutoReport; - //BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; -} COEX_DM_8723A_2ANT, *PCOEX_DM_8723A_2ANT; - -typedef struct _COEX_STA_8723A_2ANT{ - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - u1Byte preBtRssiState; - u1Byte preBtRssiState1; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8723A_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8723A_2ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - BOOLEAN bHoldForStackOperation; - u1Byte bHoldPeriodCnt; - // this is for c2h hang work-around - u4Byte c2hHangDetectCnt; -}COEX_STA_8723A_2ANT, *PCOEX_STA_8723A_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8723a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8723a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8723a2ant_StackOperationNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.c deleted file mode 100644 index a2768e249..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.c +++ /dev/null @@ -1,5639 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8723B Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8723b1Ant.tmh" -#endif - -//#include -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8723B_1ANT GLCoexDm8723b1Ant; -static PCOEX_DM_8723B_1ANT pCoexDm=&GLCoexDm8723b1Ant; -static COEX_STA_8723B_1ANT GLCoexSta8723b1Ant; -static PCOEX_STA_8723B_1ANT pCoexSta=&GLCoexSta8723b1Ant; -static PSDSCAN_STA_8723B_1ANT GLPsdScan8723b1Ant; -static PPSDSCAN_STA_8723B_1ANT pPsdScan = &GLPsdScan8723b1Ant; - - -const char *const GLBtInfoSrc8723b1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8723b1Ant=20150119; -u4Byte GLCoexVer8723b1Ant=0x58; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8723b1ant_ -//============================================================ -u1Byte -halbtc8723b1ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8723b1ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8723b1ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8723b1ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8723b1ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8723b1ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8723b1ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8723b1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8723b1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8723b1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8723b1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8723b1ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8723b1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -VOID -halbtc8723b1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp, u1Tmp1; - s4Byte wifiRssi; - static u4Byte NumOfBtCounterChk = 0; - - //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS - //if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) ) - - if (pCoexSta->bUnderIps) - { - //pCoexSta->highPriorityTx = 65535; - //pCoexSta->highPriorityRx = 65535; - //pCoexSta->lowPriorityTx = 65535; - //pCoexSta->lowPriorityRx = 65535; - //return; - } - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if( (pCoexSta->lowPriorityTx > 1050) && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->popEventCnt++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", - regHPRx, regHPTx, regLPRx, regLPTx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); - - // This part is for wifi FW and driver to update BT's status as disabled. - // The flow is as the following - // 1. disable BT - // 2. if all BT Tx/Rx counter=0, after 6 sec we query bt info - // 3. Because BT will not rsp from mailbox, so wifi fw will know BT is disabled - // 4. FW will rsp c2h for BT that driver will know BT is disabled. - if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0)) - { - NumOfBtCounterChk++; - if (NumOfBtCounterChk == 3) -{ - halbtc8723b1ant_QueryBtInfo(pBtCoexist); - } - } - else - { - NumOfBtCounterChk = 0; - } - } - - -VOID -halbtc8723b1ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - u4Byte TotalCnt; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); - - if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode)) - { - TotalCnt = pCoexSta->nCRCOK_CCK + pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + - pCoexSta->nCRCOK_11nAgg; - - if ( (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_BUSY) || - (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY) || - (pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_SCO_BUSY) ) - { - if (pCoexSta->nCRCOK_CCK >(TotalCnt -pCoexSta->nCRCOK_CCK)) - { - if (nCCKLockCounter < 3) - nCCKLockCounter++; - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - if (!pCoexSta->bPreCCKLock) - { - - if (nCCKLockCounter >= 3) - pCoexSta->bCCKLock = TRUE; - else - pCoexSta->bCCKLock = FALSE; - } - else - { - if (nCCKLockCounter == 0) - pCoexSta->bCCKLock = FALSE; - else - pCoexSta->bCCKLock = TRUE; - } - - if (pCoexSta->bCCKLock) - pCoexSta->bCCKEverLock = TRUE; - - pCoexSta->bPreCCKLock = pCoexSta->bCCKLock; - - -} - -BOOLEAN -halbtc8723b1ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - - - } - - return FALSE; -} - -VOID -halbtc8723b1ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - pBtLinkInfo->bBtHiPriLinkExist = pCoexSta->bBtHiPriLinkExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8723b1ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8723B_1ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8723B_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8723b1ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8723b1ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8723b1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8723b1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!") )); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8723b1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8723b1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8723b1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8723b1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8723b1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8723b1ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - -#if BT_8723B_1ANT_ANTDET_ENABLE -#if BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE - if (pBoardInfo->btdmAntNumByAntDet == 2) - { - if (type == 3) - type = 14; - else if (type == 4) - type = 13; - else if (type == 5) - type = 8; - } -#endif -#endif - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); - - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 3: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 4: - if ( pCoexSta->bCCKEverLock) - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); - else - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3); - break; - case 5: - if ( pCoexSta->bCCKEverLock) - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaa5a5a, 0xaaaa5a5a, 0xffffff, 0x3); - else - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 6: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 7: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 8: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 9: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 10: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 11: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 12: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 13: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 14: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3); - break; - case 15: - halbtc8723b1ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8723b1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8723b1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8723b1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8723b1ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8723b1ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8723b1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8723b1ant_SwMechanism( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRA - ) -{ - halbtc8723b1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8723b1ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bForceExec, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte fwVer=0, u4Tmp=0, cntBtCalChk=0; - BOOLEAN bPgExtSwitch=FALSE; - BOOLEAN bUseExtSwitch=FALSE; - BOOLEAN bIsInMpMode = FALSE; - u1Byte H2C_Parameter[2] ={0}, u1Tmp = 0; - - pCoexDm->curAntPosType = antPosType; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver - - if((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch) - bUseExtSwitch = TRUE; - -#if BT_8723B_1ANT_ANTDET_ENABLE -#if BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE - if (antPosType == BTC_ANT_PATH_PTA) - { - if ((pBoardInfo->btdmAntDetFinish) && (pBoardInfo->btdmAntNumByAntDet == 2)) - { - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - antPosType = BTC_ANT_PATH_WIFI; - else - antPosType = BTC_ANT_PATH_BT; - } - } -#endif -#endif - - if(bInitHwCfg) - { - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi TRx Mask on - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT TRx Mask on - - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to HIGH */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - // set grant_bt to high - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - //set wlan_act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77); - } - else if(bWifiOff) - { - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to HIGH */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - // set grant_bt to high - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - //set wlan_act to always low - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode); - if(!bIsInMpMode) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi - - // 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac=0xf002 - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &= ~BIT23; - u4Tmp &= ~BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - else - { - /* Use H2C to set GNT_BT to LOW */ - if(fwVer >= 0x180000) - { - if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765) != 0) - { - H2C_Parameter[0] = 0; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - } - else - { - // BT calibration check - while(cntBtCalChk <= 20) - { - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49d); - cntBtCalChk++; - if(u1Tmp & BIT0) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ########### BT is calibrating (wait cnt=%d) ###########\n", cntBtCalChk)); - delay_ms(50); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** BT is NOT calibrating (wait cnt=%d)**********\n", cntBtCalChk)); - break; - } - } - - // set grant_bt to PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0); - } - - if (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) != 0xc) - { - //set wlan_act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); - } - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi - } - - if(bUseExtSwitch) - { - if(bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "no antenna inverse" - H2C_Parameter[0] = 0; - H2C_Parameter[1] = 1; //ext switch type - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - //tell firmware "antenna inverse" - H2C_Parameter[0] = 1; - H2C_Parameter[1] = 1; //ext switch type - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - } - - if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType)) - { - // ext switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); - break; - case BTC_ANT_PATH_BT: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); - break; - default: - case BTC_ANT_PATH_PTA: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); - break; - } - } - } - else - { - if(bInitHwCfg) - { - // 0x4c[23]=1, 0x4c[24]=0 Antenna control by 0x64 - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp |= BIT23; - u4Tmp &=~BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - //Fix Ext switch Main->S1, Aux->S0 - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - - //tell firmware "no antenna inverse" - H2C_Parameter[0] = 0; - H2C_Parameter[1] = 0; //internal switch type - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - - //tell firmware "antenna inverse" - H2C_Parameter[0] = 1; - H2C_Parameter[1] = 0; //internal switch type - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - } - - if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType)) - { - // internal switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); - break; - case BTC_ANT_PATH_BT: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - break; - default: - case BTC_ANT_PATH_PTA: - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x200); - else - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x80); - break; - } - } - } - - pCoexDm->preAntPosType = pCoexDm->curAntPosType; -} - -VOID -halbtc8723b1ant_SetAntPathDCut( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAntennaAux, //For 1-Ant--> 1: Antenna at S0, 0: Antenna at S1. Set 0 for 2-Ant - IN BOOLEAN bExtSwitch, // 1: Ext Switch (SPDT) exist on module, 0: no Ext Switch (SPDT) exist on module - IN BOOLEAN bTwoAntenna, // 1: 2-Antenna, 0:1-Antenna - IN u1Byte antennaPos, //Set Antenna Pos, For 1-Ant: BTC_ANT_PATH_WIFI, BTC_ANT_PATH_BT, BTC_ANT_PATH_PTA, For 2-Ant:BTC_ANT_WIFI_AT_MAIN, BTC_ANT_WIFI_AT_Aux - IN u1Byte wifiState //BTC_WIFI_STAT_INIT, BTC_WIFI_STAT_IQK, BTC_WIFI_STAT_NORMAL_OFF, BTC_WIFI_STAT_MP_OFF, BTC_WIFI_STAT_NORMAL, BTC_WIFI_STAT_ANT_DIV - ) -{ - u1Byte dataLen=5; - u1Byte buf[6] = {0}; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set BT Ant, bAntennaAux/bExtSwitch/bTwoAntenna/antennaPos/wifiState=%d/%d/%d/%d/%d\n", - bAntennaAux, bExtSwitch, bTwoAntenna, antennaPos, wifiState)); - - buf[0] = dataLen; - - if(bAntennaAux) - buf[1] = 0x1; - - if(bExtSwitch) - buf[2] = 0x1; - - if(bTwoAntenna) - buf[3] = 0x1; - - buf[4] = antennaPos; - - buf[5] = wifiState; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_8723B_ANT, (PVOID)&buf[0]); -} - -VOID -halbtc8723b1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - - -VOID -halbtc8723b1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE; - u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0; - u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; - s1Byte nWiFiDurationAdjust = 0x0; - static BOOLEAN bPreWifiBusy=FALSE; - - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - -#if BT_8723B_1ANT_ANTDET_ENABLE -#if BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE - if (pBoardInfo->btdmAntNumByAntDet == 2) - { - if (bTurnOn) - type = type +100; //for WiFi RSSI low or BT RSSI low - else - type = 1; //always translate to TDMA(off,1) for TDMA-off case - } - -#endif -#endif - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if (bWifiBusy != bPreWifiBusy) - { - bForceExec = TRUE; - bPreWifiBusy = bWifiBusy; - } - - if (pCoexDm->bCurPsTdmaOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum <= 5) - { - nWiFiDurationAdjust = 5; - - if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - } - else if (pCoexSta->nScanAPNum >= 40) - { - nWiFiDurationAdjust = -15; - - if (pCoexSta->nA2DPBitPool < 35) - nWiFiDurationAdjust = -5; - else if (pCoexSta->nA2DPBitPool < 45) - nWiFiDurationAdjust = -10; - } - else if (pCoexSta->nScanAPNum >= 20) - { - nWiFiDurationAdjust = -10; - - if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - } - else - { - nWiFiDurationAdjust = 0; - - if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - } - - if ((type == 1) || (type == 2) || (type == 9) || (type == 11) || (type == 101) - || (type == 102) || (type == 109) || (type == 101)) - { - if (!pCoexSta->bForceLpsOn) //Native power save TDMA, only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle, no dynamic slot - } - else - { - psTdmaByte0Val = 0x51; //null-pkt - psTdmaByte3Val = 0x10; //tx-pause at BT-slot - psTdmaByte4Val = 0x50; // 0x778 = d/1 toggle, dynamic slot - } - } - else if ((type == 3) || (type == 13) || (type == 14) || (type == 103) || (type == 113) || (type == 114)) - { - psTdmaByte0Val = 0x51; //null-pkt - psTdmaByte3Val = 0x10; //tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle, no dynamic slot -#if 0 - if (!bWifiBusy) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) -#endif - } - else //native power save case - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x11; // 0x778 = d/1 toggle, no dynamic slot - //psTdmaByte4Va is not defne for 0x778 = d/1, 1/1 case - } - - //if (pBtLinkInfo->bSlaveRole == TRUE) - if ((pBtLinkInfo->bSlaveRole == TRUE) && (pBtLinkInfo->bA2dpExist)) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - - if (type > 100) - { - psTdmaByte0Val = psTdmaByte0Val | 0x82; //set antenna control by SW - psTdmaByte3Val = psTdmaByte3Val | 0x60; //set antenna no toggle, control by antenna diversity - } - - - if(bTurnOn) - { - switch(type) - { - default: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val); - break; - case 1: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 2: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 3: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 4: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0); - break; - case 5: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x15, 0x3, psTdmaByte3Val, 0x11); - break; - case 6: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x20, 0x3, psTdmaByte3Val, 0x11); - break; - case 7: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); - break; - case 8: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 9: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 10: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 12: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); - break; - case 13: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 14: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 15: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); - break; - case 16: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); - break; - case 18: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 20: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3f, 0x03, psTdmaByte3Val, 0x10); - break; - case 21: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); - break; - case 22: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x10); - break; - case 23: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); - break; - case 24: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); - break; - case 25: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 26: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 27: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); - break; - case 28: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); - break; - case 29: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); - break; - case 30: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); - break; - case 31: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); - break; - case 32: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x35, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 33: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x35, 0x3, psTdmaByte3Val, 0x10); - break; - case 34: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); - break; - case 35: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); - break; - case 36: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); - break; - case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving - /* here softap mode screen off will cost 70-80mA for phone */ - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); - break; - - //for 1-Ant translate to 2-Ant - case 101: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 102: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 103: - //halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val); - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 105: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x15, 0x3, psTdmaByte3Val, 0x11); - break; - case 106: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x20, 0x3, psTdmaByte3Val, 0x11); - break; - case 109: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 111: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 113: - //halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val); - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 114: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 120: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3f, 0x03, psTdmaByte3Val, 0x10); - break; - case 122: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x10); - break; - case 132: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 133: - halbtc8723b1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x25, 0x03, psTdmaByte3Val, 0x11); - break; - - } - } - else - { - - // disable PS tdma - switch(type) - { - case 8: //PTA Control - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - break; - case 0: - default: //Software control, Antenna at BT side - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - break; - case 1: // 2-Ant, 0x778=3, antenna control by antenna diversity - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; -#if 0 - case 9: //Software control, Antenna at WiFi side - halbtc8723b1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_WIFI, BTC_WIFI_STAT_NORMAL); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE); - break; -#endif - } - } - rssiAdjustVal =0; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765), pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67))); - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -BOOLEAN -halbtc8723b1ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); - - //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); - - //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - - //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); - - //halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else - { - if (bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - } - - bCommon = FALSE; - } - - return bCommon; -} - - -VOID -halbtc8723b1ant_TdmaDurationAdjustForAcl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - static BOOLEAN bPreWifiBusy=FALSE; - BOOLEAN bWifiBusy = FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); - - if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) - bWifiBusy = TRUE; - else - bWifiBusy = FALSE; - - if( (BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 3 && - pCoexDm->curPsTdma != 9 ) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { -/* if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else */ if(pCoexDm->curPsTdma == 1) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if(result == 1) - { -/* if( (BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else */ if(pCoexDm->curPsTdma == 11) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - else //no change - { - /* Bryant Modify - if(bWifiBusy != bPreWifiBusy) //if busy / idle change - { - bPreWifiBusy = bWifiBusy; - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma); - } - */ - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 9 && - pCoexDm->curPsTdma != 11 ) - { - // recover to previous adjust type - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8723b1ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8723b1ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8723b1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8723b1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - -VOID -halbtc8723b1ant_ActionWifiOnly( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); -} - -VOID -halbtc8723b1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - - bPreBtDisabled = bBtDisabled; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - if(bBtDisabled) - { - halbtc8723b1ant_ActionWifiOnly(pBtCoexist); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -//============================================= -// -// Software Coex Mechanism start -// -//============================================= - -// SCO only or SCO+PAN(HS) - -/* -VOID -halbtc8723b1ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); -} - - -VOID -halbtc8723b1ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8723b1ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8723b1ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8723b1ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(HS) only -VOID -halbtc8723b1ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(EDR)+A2DP -VOID -halbtc8723b1ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8723b1ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8723b1ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8723b1ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); -} - -*/ - -//============================================= -// -// Non-Software Coex Mechanism start -// -//============================================= -VOID -halbtc8723b1ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8723b1ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8723b1ant_ActionHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8723b1ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if ( (!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask) ) - { - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - // SCO/HID/A2DP busy - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if (pCoexSta->bC2hBtRemoteNameReq) - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 33); - else - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if ( (pBtLinkInfo->bPanExist) || (bWifiBusy) ) - { - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if (pCoexSta->bC2hBtRemoteNameReq) - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 33); - else - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - - } -} - -VOID -halbtc8723b1ant_ActionBtScoHidOnlyBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // tdma and coex table - - if(pBtLinkInfo->bScoExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else //HID - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } -} - -VOID -halbtc8723b1ant_ActionWifiConnectedBtAclBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - u1Byte btRssiState; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - btRssiState = halbtc8723b1ant_BtRssiState(2, 28, 0); - - if ( (pCoexSta->lowPriorityRx >= 950) && (!pCoexSta->bUnderIps) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - if(pBtLinkInfo->bHidOnly) //HID - { - halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); - pCoexDm->bAutoTdmaAdjust = FALSE; - return; - } - else if(pBtLinkInfo->bA2dpOnly) //A2DP - { - if(BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - halbtc8723b1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = TRUE; - } - } - else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || - (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->bAutoTdmaAdjust = FALSE; - - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - //BT no-profile busy (0x9) - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 33); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } -} - -VOID -halbtc8723b1ant_ActionWifiNotConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8723b1ant_ActionWifiNotConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8723b1ant_ActionWifiNotConnectedAssoAuth( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else if (pBtLinkInfo->bPanExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 2); - } -} - -VOID -halbtc8723b1ant_ActionWifiConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8723b1ant_ActionWifiConnectedSpecialPacket( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiBusy = FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - //no special packet process for both WiFi and BT very busy - if ((bWifiBusy) && ((pBtLinkInfo->bPanExist) || (pCoexSta->nNumOfProfile >= 2))) - return; - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist)) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else if (pBtLinkInfo->bA2dpExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if(pBtLinkInfo->bPanExist) - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8723b1ant_ActionWifiConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiBusy=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - BOOLEAN bUnder4way=FALSE, bApEnable=FALSE; - u4Byte wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - if(bUnder4way) - { - halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - if(bScan || bLink || bRoam) - { - if(bScan) - halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist); - else - halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - // power save state - if(!bApEnable && BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) - { - if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP - { - if(!bWifiBusy) - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else //busy - { - if (pCoexSta->nScanAPNum >= BT_8723B_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA - { - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - } - } - else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE)) - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - else - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(!bWifiBusy) - { - if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else - { - if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8723b1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else if( (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8723b1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else - { - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } -} - -VOID -halbtc8723b1ant_RunSwCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm=0; - - algorithm = halbtc8723b1ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - - if(halbtc8723b1ant_IsCommonAction(pBtCoexist)) - { - - } - else - { - switch(pCoexDm->curAlgorithm) - { - case BT_8723B_1ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n")); - //halbtc8723b1ant_ActionSco(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n")); - //halbtc8723b1ant_ActionHid(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n")); - //halbtc8723b1ant_ActionA2dp(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); - //halbtc8723b1ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n")); - //halbtc8723b1ant_ActionPanEdr(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n")); - //halbtc8723b1ant_ActionPanHs(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); - //halbtc8723b1ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); - //halbtc8723b1ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); - //halbtc8723b1ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8723B_1ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n")); - //halbtc8723b1ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n")); - //halbtc8723b1ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8723b1ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE, bWifiBusy = FALSE; - BOOLEAN bIncreaseScanDevNum=FALSE; - BOOLEAN bBtCtrlAggBufSize=FALSE; - BOOLEAN bMiracastPlusBt=FALSE; - u1Byte aggBufSize=5; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0, wifiBw; - u1Byte iotPeer=BTC_IOT_PEER_UNKNOWN; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if(pCoexSta->bBtWhckTest) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n")); - halbtc8723b1ant_ActionBtWhckTest(pBtCoexist); - return; - } - - if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bIncreaseScanDevNum = TRUE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - bMiracastPlusBt = TRUE; - } - else - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - bMiracastPlusBt = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - - if (( (pBtLinkInfo->bA2dpExist) || (bWifiBusy) ) && (pCoexSta->bC2hBtInquiryPage) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8723b1ant_ActionBtInquiry(pBtCoexist); - } - else - halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) ) - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_IOT_PEER, &iotPeer); - - if(BTC_IOT_PEER_CISCO != iotPeer) - { - if(pBtLinkInfo->bScoExist)//if (pBtLinkInfo->bBtHiPriLinkExist) - //halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5); - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - else - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - //halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - } - else - { - if(pBtLinkInfo->bScoExist) - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5); - else - { - if (BTC_WIFI_BW_HT40==wifiBw) - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x10); - else - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - } - } - - halbtc8723b1ant_SwMechanism(pBtCoexist, TRUE); - halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message - } - else - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - halbtc8723b1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8723b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8723b1ant_ActionHs(pBtCoexist); - return; - } - - - if(!bWifiConnected) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - if (bScan) - halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist); - else - halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else - halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); - } - else // wifi LPS/Busy - { - halbtc8723b1ant_ActionWifiConnected(pBtCoexist); - } -} - -u4Byte -halbtc8723b1ant_PSD_Log2Base( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val - - ) -{ - u1Byte i,j; - u4Byte tmp, tmp2, val_integerdB=0, tindex, shiftcount=0; - u4Byte result,val_fractiondB=0,Table_fraction[21]= {0,432, 332, 274, 232, 200, - 174, 151,132,115,100,86,74,62,51,42, - 32,23,15,7,0}; - - if (val == 0) - return 0; - - tmp = val; - - while(1) - { - if (tmp == 1) - break; - else - { - tmp = (tmp >> 1); - shiftcount++; - } - } - - - val_integerdB = shiftcount+1; - - tmp2=1; - for (j=1; j<= val_integerdB;j++) - tmp2 = tmp2*2; - - tmp = (val*100) /tmp2; - tindex = tmp/5; - - if (tindex > 20) - tindex = 20; - - val_fractiondB = Table_fraction[tindex]; - - result = val_integerdB*100 - val_fractiondB; - - return (result); - - -} - -VOID -halbtc8723b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - // sw all off - halbtc8723b1ant_SwMechanism(pBtCoexist, FALSE); - - //halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - //halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - pCoexSta->popEventCnt = 0; -} - -VOID -halbtc8723b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp, - IN BOOLEAN bWifiOnly - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0;//, fwVer; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0, u1Tmpa=0, u1Tmpb=0; - u1Byte H2C_Parameter[2] ={0}; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - pPsdScan->nAntDet_IsAntDetAvailable = FALSE; - - //0xf0[15:12] --> Chip Cut information - pCoexSta->nCutVersion = (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xf1) & 0xf0) >> 4; - -#if 0//move to BTC_MEDIA_CONNECT - if(bBackUp) - { - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } -#endif - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x550, 0x8, 0x1); //enable TBTT nterrupt - - // 0x790[5:0]=0x5 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, 0x5); - - // Enable counter statistics - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); - - - //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi - - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - - //Antenna config - if(bWifiOnly) - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FORCE_EXEC, TRUE, FALSE); - else - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, TRUE, FALSE); - -#if 0 - if(bWifiOnly) - { - halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_WIFI, BTC_WIFI_STAT_INIT); - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - } - else - halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_INIT); -#endif - - - - // PTA parameter - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); -} - - - - - -VOID -halbtc8723b1ant_MechanismSwitch( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwitchTo2Antenna - ) -{ - - if (bSwitchTo2Antenna) // 1-Ant -> 2-Ant - { - //un-lock TRx Mask setup for 8723b f-cut - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x1); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x1); - //WiFi TRx Mask on - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - //BT TRx Mask un-lock 0x2c[0], 0x30[0] = 1 - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x2c, 0x7c45); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x30, 0x7c45); - - //BT TRx Mask on - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x1); - - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, FALSE); - } - else - { - //WiFi TRx Mask on - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - - //lock TRx Mask setup for 8723b f-cut - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x0); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x0); - - //BT TRx Mask on - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); - - //BT TRx Mask ock 0x2c[0], 0x30[0] = 0 - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x2c, 0x7c44); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x30, 0x7c44); - - - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - } - -} - - - - -VOID -halbtc8723b1ant_PSD_ShowAntennaDetectResult( - IN PBTC_COEXIST pBtCoexist - ) -{ - pu1Byte cliBuf=pBtCoexist->cliBuf; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n============[Antenna Detection info] ============\n"); - CL_PRINTF(cliBuf); - - if (pPsdScan->nAntDet_Result == 1) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s (>%d)", "Ant Det Result", "2-Antenna (Bad-Isolation)", - BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION); - else if (pPsdScan->nAntDet_Result == 2) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s (%d~%d)", "Ant Det Result", "2-Antenna (Good-Isolation)", - BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION+pPsdScan->nAntDet_ThresOffset, BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s (%d~%d)", "Ant Det Result", "1-Antenna", - BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT, BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION+pPsdScan->nAntDet_ThresOffset); - - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s ", "Antenna Detection Finish", - (pBoardInfo->btdmAntDetFinish? "Yes":"No")); - CL_PRINTF(cliBuf); - - switch(pPsdScan->nAntDet_Result) - { - case 0: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is not available)"); - break; - case 1: // 2-Ant bad-isolation - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is available)"); - break; - case 2: // 2-Ant good-isolation - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is available)"); - break; - case 3: // 1-Ant - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is available)"); - break; - case 4: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(Uncertainty result)"); - break; - case 5: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(Pre-Scan fai)"); - break; - case 6: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(WiFi is Scanning)"); - break; - case 7: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is not idle)"); - break; - case 8: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(Abort by WiFi Scanning)"); - break; - case 9: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(Antenna Init is not ready)"); - break; - case 10: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is Inquiry or page)"); - break; - case 11: - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "(BT is Disabled)"); - break; -} - CL_PRINTF(cliBuf); - - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Ant Detect Total Count",pPsdScan->bAntDet_TryCount); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Ant Detect Fail Count",pPsdScan->bAntDet_FailCount); - CL_PRINTF(cliBuf); - - if ( (!pBoardInfo->btdmAntDetFinish) && (pPsdScan->nAntDet_Result != 5) ) - return; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Response",(pPsdScan->nAntDet_Result? "ok":"fail")); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ms", "BT Tx Time", pPsdScan->nAntDet_BTTxTime); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "BT Tx Ch", pPsdScan->nAntDet_BTLEChannel); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "WiFi PSD Cent-Ch/Offset/Span", - pPsdScan->nRealCentFreq, pPsdScan->nRealOffset, pPsdScan->nRealSpan); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d dB", "PSD Pre-Scan Peak Value", pPsdScan->nAntDet_PrePSDScanPeakVal/100); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s (<= %d)", "PSD Pre-Scan result", - (pPsdScan->nAntDet_Result != 5? "ok":"fail"), BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND+pPsdScan->nAntDet_ThresOffset); - CL_PRINTF(cliBuf); - - if (pPsdScan->nAntDet_Result == 5) - return; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s dB", "PSD Scan Peak Value", pPsdScan->nAntDet_PeakVal); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s MHz", "PSD Scan Peak Freq", pPsdScan->nAntDet_PeakFreq); - CL_PRINTF(cliBuf); - - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "TFBGA Package", - (pBoardInfo->bTfbgaPackage)? "Yes":"No"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "PSD Threshold Offset", pPsdScan->nAntDet_ThresOffset); - CL_PRINTF(cliBuf); - -} - -VOID -halbtc8723b1ant_PSD_ShowData( - IN PBTC_COEXIST pBtCoexist - ) -{ - pu1Byte cliBuf=pBtCoexist->cliBuf; - u4Byte nDeltaFreqPerPoint; - u4Byte freq,freq1,freq2,n=0,i=0, j=0, m=0, PsdRep1, PsdRep2; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n\n============[PSD info] (%d)============\n", - pPsdScan->nPSDGenCount); - CL_PRINTF(cliBuf); - - if (pPsdScan->nPSDGenCount == 0) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n No Data !!\n"); - CL_PRINTF(cliBuf); - return; - } - - if (pPsdScan->nPSDPoint == 0) - nDeltaFreqPerPoint = 0; - else - nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint; - - //if (pPsdScan->bIsPSDShowMaxOnly) - if (0) - { - PsdRep1 = pPsdScan->nPSDMaxValue/100; - PsdRep2 = pPsdScan->nPSDMaxValue - PsdRep1 * 100; - - freq = ((pPsdScan->nRealCentFreq-20) * 1000000 + pPsdScan->nPSDMaxValuePoint * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; - - if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.0%d MHz", - freq1, freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq = %d.%d MHz", - freq1, freq2); - - if (PsdRep2 < 10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.0%d dB, (%d) \n", - PsdRep1, PsdRep2, pPsdScan->nPSDMaxValue); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, ", Value = %d.%d dB, (%d)\n", - PsdRep1, PsdRep2, pPsdScan->nPSDMaxValue); - - CL_PRINTF(cliBuf); - } - else - { - m = pPsdScan->nPSDStartPoint; - n = pPsdScan->nPSDStartPoint; - i = 1; - j = 1; - - while(1) - { - do - { - freq = ((pPsdScan->nRealCentFreq-20) * 1000000 + m * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; - - if (i ==1) - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.000", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.0%2d", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Freq%6d.%3d", freq1,freq2); - } - else if ( (i%8 == 0) || (m == pPsdScan->nPSDStopPoint) ) - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000\n", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d\n", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d\n", freq1,freq2); - } - else - { - if (freq2 == 0) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.000", freq1); - else if (freq2 < 100) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.0%2d", freq1,freq2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%6d.%3d", freq1,freq2); - } - - i++; - m++; - CL_PRINTF(cliBuf); - - }while( (i <= 8) && (m <= pPsdScan->nPSDStopPoint)); - - - do - { - PsdRep1 = pPsdScan->nPSDReport_MaxHold[n]/100; - PsdRep2 = pPsdScan->nPSDReport_MaxHold[n] - PsdRep1 * 100; - - if (j ==1) - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.0%d", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n Val %7d.%d", PsdRep1,PsdRep2); - } - else if ( (j%8 == 0) || (n == pPsdScan->nPSDStopPoint) ) - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d\n", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d\n", PsdRep1,PsdRep2); - } - else - { - if (PsdRep2 <10) - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.0%d", PsdRep1,PsdRep2); - else - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "%7d.%d", PsdRep1,PsdRep2); - } - - j++; - n++; - CL_PRINTF(cliBuf); - - } while( (j <= 8) && (n <= pPsdScan->nPSDStopPoint)); - - if ( (m > pPsdScan->nPSDStopPoint) || (n > pPsdScan->nPSDStopPoint) ) - break; - else - { - i = 1; - j = 1; - } - - } - } - - -} - -VOID -halbtc8723b1ant_PSD_MaxHoldData( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte GenCount - ) -{ - u4Byte i=0, i_max=0, val_max=0, j; - - if (GenCount== 1) - { - memcpy(pPsdScan->nPSDReport_MaxHold, pPsdScan->nPSDReport, BT_8723B_1ANT_ANTDET_PSD_POINTS*sizeof(u4Byte)); - - for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i])); - } - - pPsdScan->nPSDMaxValuePoint = 0; - pPsdScan->nPSDMaxValue = 0; - - } - else - { - for (i= pPsdScan->nPSDStartPoint; i<=pPsdScan->nPSDStopPoint; i++) - { - if (pPsdScan->nPSDReport[i] > pPsdScan->nPSDReport_MaxHold[i]) - pPsdScan->nPSDReport_MaxHold[i] = pPsdScan->nPSDReport[i]; - - //search Max Value - if (i ==pPsdScan->nPSDStartPoint ) - { - i_max = i; - val_max = pPsdScan->nPSDReport_MaxHold[i]; - } - else - { - if (pPsdScan->nPSDReport_MaxHold[i] > val_max) - { - i_max = i; - val_max = pPsdScan->nPSDReport_MaxHold[i]; - } - } - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i = %d, PSDReport = %d dB\n", i, pPsdScan->nPSDReport_MaxHold[i])); - - } - - pPsdScan->nPSDMaxValuePoint = i_max; - pPsdScan->nPSDMaxValue = val_max; - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Max_Hold i_Max = %d, PSDReport_Max = %d dB\n", pPsdScan->nPSDMaxValuePoint - // ,pPsdScan->nPSDMaxValue)); - } - - -} - -u4Byte -halbtc8723b1ant_PSD_GetData( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte nPoint - ) -{ - //reg 0x808[9:0]: FFT data x - //reg 0x808[22]: 0-->1 to get 1 FFT data y - //reg 0x8b4[15:0]: FFT data y report - - u4Byte val = 0, psd_report =0; - - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - - val &= 0xffbffc00; - val |= nPoint; - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - val |= 0x00400000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x8b4); - - psd_report = val & 0x0000ffff; - - return psd_report; -} - - -VOID -halbtc8723b1ant_PSD_SweepPoint( -IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN s4Byte offset, - IN u4Byte span, - IN u4Byte points, - IN u4Byte avgnum - ) -{ - u4Byte i,val,n,k=0; - u4Byte nPoints=0, psd_report=0; - u4Byte nStartP=0, nStopP=0, nDeltaFreqPerPoint=156250; - u4Byte nPSDCenterFreq=20*10^6, freq,freq1,freq2; - BOOLEAN outloop = FALSE; - u1Byte flag = 0; - u4Byte tmp, PsdRep1, PsdRep2; - u4Byte WiFi_OriginalChannel = 1; - - pPsdScan->bIsPSDRunning = TRUE; - - do - { - switch(flag) - { - case 0: //Get PSD parameters - default: - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), centFreq=0x%x, offset=0x%x, span=0x%x\n", - // centFreq, offset, span)); - - pPsdScan->nPSDBandWidth = 40*1000000; - pPsdScan->nPSDPoint = points; - pPsdScan->nPSDStartBase = points/2; - pPsdScan->nPSDAvgNum = avgnum; - pPsdScan->nRealCentFreq = centFreq; - pPsdScan->nRealOffset = offset; - pPsdScan->nRealSpan = span; - - - nPoints = pPsdScan->nPSDPoint; - nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint; - - //PSD point setup - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - val &= 0xffff0fff; - - switch(pPsdScan->nPSDPoint) - { - case 128: - val |= 0x0; - break; - case 256: - default: - val |=0x00004000; - break; - case 512: - val |= 0x00008000; - break; - case 1024: - val |= 0x0000c000; - break; - } - - switch(pPsdScan->nPSDAvgNum) - { - case 1: - val |= 0x0; - break; - case 8: - val |=0x00001000; - break; - case 16: - val |= 0x00002000; - break; - case 32: - default: - val |= 0x00003000; - break; - } - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x808, val); - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD BW= %d, DeltaFreq=%d\n" - // , pPsdScan->nPSDBandWidth, nDeltaFreqPerPoint)); - flag = 1; - break; - case 1: //calculate the PSD point index from freq/offset/span - nPSDCenterFreq = pPsdScan->nPSDBandWidth /2 +offset*(1000000); - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), PSD Center Freq = %d\n", (centFreq + offset))); - - nStartP = pPsdScan->nPSDStartBase + (nPSDCenterFreq - span *(1000000)/2) /nDeltaFreqPerPoint; - pPsdScan->nPSDStartPoint = nStartP - pPsdScan->nPSDStartBase; - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Start PSD Poin Matrix Index = %d\n", pPsdScan->nPSDStartPoint)); - - nStopP = pPsdScan->nPSDStartBase + (nPSDCenterFreq + span *(1000000)/2) /nDeltaFreqPerPoint; - pPsdScan->nPSDStopPoint = nStopP - pPsdScan->nPSDStartBase-1; - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), Stop PSD Poin Matrix Index = %d\n",pPsdScan->nPSDStopPoint)); - - flag = 2; - break; - case 2: //set RF channel/BW/Mode - - //set 3-wire off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c); - val |= 0x00300000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val); - - //CCK off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800); - val &= 0xfeffffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val); - - //store WiFi original channel - WiFi_OriginalChannel = pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff); - - //Set RF channel - if (centFreq == 2484) - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, 0xe); - else - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, (centFreq-2412)/5 + 1); //WiFi TRx Mask on - - //Set RF mode = Rx, RF Gain = 0x8a0 - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x0, 0xfffff, 0x308a0); - - //Set RF Rx filter corner - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0x3e4); - - //Set TRx mask off - //un-lock TRx Mask setup - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x1); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x1); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - flag = 3; - break; - case 3: - memset(pPsdScan->nPSDReport,0, pPsdScan->nPSDPoint*sizeof(u4Byte)); - nStartP = pPsdScan->nPSDStartPoint + pPsdScan->nPSDStartBase; - nStopP = pPsdScan->nPSDStopPoint + pPsdScan->nPSDStartBase + 1; - - i = nStartP; - - while (i < nStopP) - { - if (i >= nPoints) - { - psd_report = halbtc8723b1ant_PSD_GetData(pBtCoexist,i-nPoints); - } - else - { - psd_report = halbtc8723b1ant_PSD_GetData(pBtCoexist,i); - } - - if (psd_report == 0) - tmp = 0; - else - //tmp = 20*log10((double)psd_report); - //20*log2(x)/log2(10), log2Base return theresult of the psd_report*100 - tmp = 6 * halbtc8723b1ant_PSD_Log2Base(pBtCoexist, psd_report); - - n = i-pPsdScan->nPSDStartBase; - pPsdScan->nPSDReport[n] = tmp; - PsdRep1 = pPsdScan->nPSDReport[n] /100; - PsdRep2 = pPsdScan->nPSDReport[n] - PsdRep1 * 100; - - freq = ((centFreq-20) * 1000000 + n * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; -/* - if (freq2 < 100) - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.0%d MHz)", n, freq1, freq2)); - else - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint(), i = %d (%d.%d MHz)", n, freq1, freq2)); - - if (PsdRep2 < 10) - RT_TRACE(COMP_COEX, DBG_LOUD, (", PSDReport = %d (%d.0%d dB)\n",psd_report, PsdRep1, PsdRep2)); - else - RT_TRACE(COMP_COEX, DBG_LOUD, (", PSDReport = %d (%d.%d dB)\n",psd_report, PsdRep1,PsdRep2)); -*/ - i++; - - k=0; - - //Add Delay between PSD point - while(1) - { - if (k++ > 20000) - break; - } - - //RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx SweepPSDPoint()==============\n")); - } - - flag = 100; - break; - case 99: //error - - outloop = TRUE; - break; - case 100: //recovery - - //set 3-wire on - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x88c); - val &=0xffcfffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x88c,val); - - //CCK on - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x800); - val |= 0x01000000; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x800,val); - - //PSD off - val = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x808); - val &=0xffbfffff; - pBtCoexist->fBtcWrite4Byte(pBtCoexist,0x808,val); - - //TRx Mask on - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - - //lock TRx Mask setup - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdd, 0x80, 0x0); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xdf, 0x1, 0x0); - - //Set RF Rx filter corner - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0x0); - - //restore WiFi original channel - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x18, 0x3ff, WiFi_OriginalChannel); - - outloop = TRUE; - break; - - } - - }while (!outloop); - - - - pPsdScan->bIsPSDRunning = FALSE; - - -} - -VOID -halbtc8723b1ant_PSD_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte BTTxTime, - IN u4Byte BTLEChannel - ) -{ - u4Byte realseconds = 0, i=0, j=0; - u4Byte WLPSD_CentFreq = 2484, WLPSD_Span = 2, WLPSD_SweepCount = 50; - s4Byte WLPSD_Offset = -4; - u1Byte BTLECh[13] = {3,6,8,11,13,16,18,21,23,26,28,31,33}; - - u1Byte H2C_Parameter[3] ={0},u1Tmpa,u1Tmpb; - - u1Byte state=0; - BOOLEAN outloop = FALSE, BTResp = FALSE, bScan ,bRoam; - u4Byte freq,freq1,freq2,PsdRep1, PsdRep2, nDeltaFreqPerPoint,u4Tmp; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - pBoardInfo->btdmAntDetFinish = FALSE; - memset(pPsdScan->nAntDet_PeakVal, 0, 16*sizeof(UCHAR)); - memset(pPsdScan->nAntDet_PeakFreq, 0, 16*sizeof(UCHAR)); - - if (pBoardInfo->bTfbgaPackage) //for TFBGA - pPsdScan->nAntDet_ThresOffset = 5; - else - pPsdScan->nAntDet_ThresOffset = 0; - - do - { - switch(state) - { - case 0: - if (BTLEChannel == 39) - WLPSD_CentFreq = 2484; - else - { - for (i=1; i<=13; i++) - { - if (BTLECh[i-1] == BTLEChannel) - { - WLPSD_CentFreq = 2412 + (i-1) * 5; - break; - } - } - - if (i == 14) - { - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Abort!!, Invalid LE channel = %d\n ", BTLEChannel)); - outloop = TRUE; - break; - } - } - - WLPSD_SweepCount = BTTxTime * 238 /100; //BTTxTime/0.42 - - if (WLPSD_SweepCount % 5 != 0) - WLPSD_SweepCount = (WLPSD_SweepCount/5 + 1) * 5; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), BT_LETxTime=%d, BT_LECh = %d\n", BTTxTime, BTLEChannel)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), WLPSD_CentFreq=%d, WLPSD_Offset = %d, WLPSD_Span = %d, WLPSD_SweepCount = %d\n", - WLPSD_CentFreq, WLPSD_Offset, WLPSD_Span,WLPSD_SweepCount)); - - state = 1; - break; - case 1: //stop coex DM & set antenna path - //Stop Coex DM - pBtCoexist->bStopCoexDm = TRUE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Stop Coex DM!!\n")); - - //set native power save - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - //Set TDMA off, - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - - //Set coex table - halbtc8723b1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna at Main Port\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna at Aux Port\n")); - } - - //Set Antenna path, switch WiFi to un-certain antenna port - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, FALSE); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Set Antenna to BT!!\n")); - - //Set AFH mask on at WiFi channel 2472MHz +/- 10MHz - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = 0xd; - H2C_Parameter[2] = 0x14; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Set AFH on, Cent-Ch= %d, Mask=%d\n", - H2C_Parameter[1],H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x778=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); - - state =2; - break; - case 2: //Pre-sweep background psd - for (pPsdScan->nPSDGenCount=1; pPsdScan->nPSDGenCount<=3; pPsdScan->nPSDGenCount++) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), PSDGenCount = %d\n ", pPsdScan->nPSDGenCount)); - halbtc8723b1ant_PSD_SweepPoint(pBtCoexist, WLPSD_CentFreq, WLPSD_Offset, WLPSD_Span, BT_8723B_1ANT_ANTDET_PSD_POINTS, BT_8723B_1ANT_ANTDET_PSD_AVGNUM); - halbtc8723b1ant_PSD_MaxHoldData(pBtCoexist, pPsdScan->nPSDGenCount); - } - - pPsdScan->nAntDet_PrePSDScanPeakVal = pPsdScan->nPSDMaxValue; - - if (pPsdScan->nPSDMaxValue > (BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND+pPsdScan->nAntDet_ThresOffset)*100) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Abort Antenna Detection!! becaus background = %d > thres (%d)\n", - pPsdScan->nPSDMaxValue/100, BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND+pPsdScan->nAntDet_ThresOffset)); - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - pPsdScan->nAntDet_Result = 5; - state = 99; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Start Antenna Detection!! becaus background = %d <= thres (%d)\n", - pPsdScan->nPSDMaxValue/100, BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND+pPsdScan->nAntDet_ThresOffset)); - state = 3; - } - break; - case 3: - BTResp = pBtCoexist->fBtcSetBtAntDetection(pBtCoexist, (u1Byte)(BTTxTime&0xff), (u1Byte)(BTLEChannel&0xff)); - - for (pPsdScan->nPSDGenCount=1; pPsdScan->nPSDGenCount<=WLPSD_SweepCount; pPsdScan->nPSDGenCount++) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), PSDGenCount = %d\n ", pPsdScan->nPSDGenCount)); - halbtc8723b1ant_PSD_SweepPoint(pBtCoexist, WLPSD_CentFreq, WLPSD_Offset, WLPSD_Span, BT_8723B_1ANT_ANTDET_PSD_POINTS, BT_8723B_1ANT_ANTDET_PSD_AVGNUM); - halbtc8723b1ant_PSD_MaxHoldData(pBtCoexist, pPsdScan->nPSDGenCount); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if (bScan ||bRoam) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - pPsdScan->nAntDet_Result = 8; - state = 99; - break; - } - } - - pPsdScan->nAntDet_PSDScanPeakVal = pPsdScan->nPSDMaxValue; - pPsdScan->nAntDet_PSDScanPeakFreq = pPsdScan->nPSDMaxValuePoint; - state = 4; - break; - case 4: - - if (pPsdScan->nPSDPoint == 0) - nDeltaFreqPerPoint = 0; - else - nDeltaFreqPerPoint = pPsdScan->nPSDBandWidth/pPsdScan->nPSDPoint; - - PsdRep1 = pPsdScan->nPSDMaxValue/100; - PsdRep2 = pPsdScan->nPSDMaxValue - PsdRep1 * 100; - - freq = ((pPsdScan->nRealCentFreq-20) * 1000000 + pPsdScan->nPSDMaxValuePoint * nDeltaFreqPerPoint); - freq1 = freq/1000000; - freq2 = freq/1000 - freq1 * 1000; - - if (freq2 < 100) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Max Value: Freq = %d.0%d MHz", freq1, freq2)); - CL_SPRINTF(pPsdScan->nAntDet_PeakFreq, BT_8723B_1ANT_ANTDET_BUF_LEN, "%d.0%d", freq1,freq2); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Max Value: Freq = %d.%d MHz", freq1, freq2)); - CL_SPRINTF(pPsdScan->nAntDet_PeakFreq, BT_8723B_1ANT_ANTDET_BUF_LEN, "%d.%d", freq1,freq2); - } - - if (PsdRep2 < 10) - { - RT_TRACE(COMP_COEX, DBG_LOUD, (", Value = %d.0%d dB\n", PsdRep1, PsdRep2)); - CL_SPRINTF(pPsdScan->nAntDet_PeakVal, BT_8723B_1ANT_ANTDET_BUF_LEN, "%d.0%d", PsdRep1,PsdRep2); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, (", Value = %d.%d dB\n",PsdRep1, PsdRep2)); - CL_SPRINTF(pPsdScan->nAntDet_PeakVal, BT_8723B_1ANT_ANTDET_BUF_LEN, "%d.%d", PsdRep1,PsdRep2); - } - - pPsdScan->nAntDet_IsBTReplyAvailable = TRUE; - - if (BTResp == FALSE) - { - pPsdScan->nAntDet_IsBTReplyAvailable = FALSE; - pPsdScan->nAntDet_Result = 0; - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), BT Response = Fail \n ")); - } - else if (pPsdScan->nPSDMaxValue > (BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION)*100) - { - pPsdScan->nAntDet_Result = 1; - pBoardInfo->btdmAntDetFinish = TRUE; - pBoardInfo->btdmAntNumByAntDet = 2; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Detect Result = 2-Ant, Bad-Isolation!! \n")); - } - else if (pPsdScan->nPSDMaxValue > (BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION+pPsdScan->nAntDet_ThresOffset)*100) - { - pPsdScan->nAntDet_Result = 2; - pBoardInfo->btdmAntDetFinish = TRUE; - pBoardInfo->btdmAntNumByAntDet = 2; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Detect Result = 2-Ant, Good-Isolation!! \n")); - } - else if (pPsdScan->nPSDMaxValue > (BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT)*100) - { - pPsdScan->nAntDet_Result = 3; - pBoardInfo->btdmAntDetFinish = TRUE; - pBoardInfo->btdmAntNumByAntDet = 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Detect Result = 1-Ant!!\n")); - } - else - { - pPsdScan->nAntDet_Result = 4; - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Detect Result = 1-Ant, un-certainity!!\n")); - } - - state = 99; - break; - case 99: //restore setup - - //Set AFH mask off at WiFi channel 2472MHz +/- 10MHz - H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = 0x0; - H2C_Parameter[2] = 0x0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Set AFH on, Cent-Ch= %d, Mask=%d\n", - H2C_Parameter[1],H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); - - //Set Antenna Path - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Set Antenna to PTA\n!!")); - - //Resume Coex DM - pBtCoexist->bStopCoexDm = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Resume Coex DM\n!!")); - - //stimulate coex running - halbtc8723b1ant_RunCoexistMechanism(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Stimulate Coex running\n!!")); - - outloop = TRUE; - break; - } - - }while(!outloop); - - - - } - -VOID -halbtc8723b1ant_PSD_AntennaDetectionCheck( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u4Byte AntDetCount = 0, AntDetFailCount = 0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - BOOLEAN bScan, bRoam; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - - pPsdScan->nAntDet_BTTxTime = 20; //0.42ms*50 = 20ms - pPsdScan->nAntDet_BTLEChannel = 39; - - AntDetCount++; - - pPsdScan->bAntDet_TryCount = AntDetCount; - - if (bScan ||bRoam) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 6; - } - else if(pBtCoexist->btInfo.bBtDisabled) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 11; - } - else if (pCoexSta->nNumOfProfile >= 1) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 7; - } - else if (!pPsdScan->nAntDet_IsAntDetAvailable) //Antenna initial setup is not ready - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 9; - } - else if (pCoexSta->bC2hBtInquiryPage) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 10; - } - else - { - halbtc8723b1ant_PSD_AntennaDetection(pBtCoexist, pPsdScan->nAntDet_BTTxTime, pPsdScan->nAntDet_BTLEChannel); - } - - if (!pBoardInfo->btdmAntDetFinish) - AntDetFailCount++; - - pPsdScan->bAntDet_FailCount = AntDetFailCount; - -} - - -//============================================================ -// work around function start with wa_halbtc8723b1ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8723b1ant_ -//============================================================ -VOID -EXhalbtc8723b1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x0; - u2Byte u2Tmp=0x0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx Execute 8723b 1-Ant PowerOn Setting xxxxxxxxxxxxxxxx!!\n")); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("Ant Det Finish = %s, Ant Det Number = %d\n", - (pBoardInfo->btdmAntDetFinish? "Yes":"No"), pBoardInfo->btdmAntNumByAntDet)); - - pBtCoexist->bStopCoexDm = TRUE; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20); - - // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1); - - // set GRAN_BT = 1 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - // set WLAN_ACT = 0 - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - // set to S1 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - u1Tmp |= 0x1; // antenna inverse - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } -} - -VOID -EXhalbtc8723b1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8723b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8723b1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly); - pBtCoexist->bStopCoexDm = FALSE; -} - -VOID -EXhalbtc8723b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - pBtCoexist->bStopCoexDm = FALSE; - - halbtc8723b1ant_InitCoexDm(pBtCoexist); - - halbtc8723b1ant_QueryBtInfo(pBtCoexist); -} - -VOID -EXhalbtc8723b1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u2Byte u2Tmp[4]; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - static u1Byte PopReportIn10s = 0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - if(pBtCoexist->bStopCoexDm) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - if (pPsdScan->bAntDet_TryCount == 0) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Mech/ Pos", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos); - CL_PRINTF(cliBuf); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d (%d/%d/%d)", "Ant PG Num/ Mech(Ant_Det)/ Pos", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNumByAntDet, pBoardInfo->btdmAntPos, - pPsdScan->bAntDet_TryCount, pPsdScan->bAntDet_FailCount, pPsdScan->nAntDet_Result); - CL_PRINTF(cliBuf); - - if (pBoardInfo->btdmAntDetFinish) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "Ant Det PSD Value", pPsdScan->nAntDet_PeakVal); - CL_PRINTF(cliBuf); - } - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)/ %c", "Version Coex/ Fw/ Patch/ Cut", \ - GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer, pCoexSta->nCutVersion+65); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "WifibHiPri/ Ccklock/ CckEverLock", \ - (pCoexSta->bWiFiIsHighPriTask? "Yes":"No"), - (pCoexSta->bCCKLock? "Yes":"No"), - (pCoexSta->bCCKEverLock? "Yes":"No")); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - PopReportIn10s++; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt); - CL_PRINTF(cliBuf); - - if (PopReportIn10s >= 5) - { - pCoexSta->popEventCnt = 0; - PopReportIn10s = 0; - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d / %d / %d", "SCO/HID/PAN/A2DP/NameReq/WHQL", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist, pCoexSta->bC2hBtRemoteNameReq, pCoexSta->bBtWhckTest ); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) - { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \ - (pBtLinkInfo->bSlaveRole )? "Slave":"Master"); - CL_PRINTF(cliBuf); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %d", "A2DP Rate/Bitpool", \ - (btInfoExt&BIT0)? "BR":"EDR", pCoexSta->nA2DPBitPool); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism] (before Manual)============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - } - - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \ - pCoexDm->bCurLowPenaltyRa); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ - (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), - pBtCoexist->btInfo.aggBufSize); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism] (before Manual) ============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - } - - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - if (pBoardInfo->btdmAntNumByAntDet == 2) - { - if (pCoexDm->bCurPsTdmaOn) - psTdmaCase = psTdmaCase +100; //for WiFi RSSI low or BT RSSI low - else - psTdmaCase = 1; //always translate to TDMA(off,1) for TDMA-off case - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, - (pCoexDm->bCurPsTdmaOn? "On":"Off"), - (pCoexDm->bAutoTdmaAdjust? "Adj":"Fix") ); - - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \ - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "IgnWlanAct", \ - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - /* - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \ - pCoexDm->errorCondition); - CL_PRINTF(cliBuf); - */ - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \ - pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \ - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", \ - u1Tmp[0], u4Tmp[0], (u4Tmp[1]&0x3e000000) >> 25); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x764); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", \ - u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), (u4Tmp[1] & 0xffff), u1Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ - u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ - ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ - u4Tmp[0]&0xff, u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[0]&0xffff, faOfdm, faCck); - CL_PRINTF(cliBuf); - - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 1) - //halbtc8723b1ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8723b1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp=0; - - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - - halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8723b1ant_InitCoexDm(pBtCoexist); - halbtc8723b1ant_QueryBtInfo(pBtCoexist); - - pCoexSta->bUnderIps = FALSE; - } -} - -VOID -EXhalbtc8723b1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8723b1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - u1Byte u1Tmpa, u1Tmpb; - u4Byte u4Tmp; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm ) - return; - - if(BTC_SCAN_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - pPsdScan->nAntDet_IsAntDetAvailable = TRUE; - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } - - if(pBtCoexist->btInfo.bBtDisabled) - return; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - halbtc8723b1ant_QueryBtInfo(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8723b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8723b1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_SCAN_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8723b1ant_ActionWifiNotConnectedScan(pBtCoexist); - } - else // wifi is connected - { - halbtc8723b1ant_ActionWifiConnectedScan(pBtCoexist); - } - } - else if(BTC_SCAN_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8723b1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8723b1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_ASSOCIATE_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - pPsdScan->nAntDet_IsAntDetAvailable = TRUE; - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - pCoexDm->nArpCnt = 0; - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - //pCoexDm->nArpCnt = 0; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8723b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8723b1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_ASSOCIATE_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - halbtc8723b1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8723b1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8723b1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8723b1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - BOOLEAN bWifiUnderBMode = FALSE; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - pPsdScan->nAntDet_IsAntDetAvailable = TRUE; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - //Set CCK Tx/Rx high Pri except 11b mode - if (bWifiUnderBMode) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx - } - - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - pCoexDm->nArpCnt = 0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx - - pCoexSta->bCCKEverLock = FALSE; - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - //H2C_Parameter[0] = 0x1; - H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8723b1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE, bUnder4way=FALSE; - u1Byte aggBufSize=5; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - if (BTC_PACKET_ARP == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n")); - - pCoexDm->nArpCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); - - if((pCoexDm->nArpCnt >= 10) && (!bUnder4way)) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type)); - } - - pCoexSta->specialPktPeriodCnt = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8723b1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8723b1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8723b1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8723b1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8723b1ant_ActionHs(pBtCoexist); - return; - } - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) ) - { - halbtc8723b1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - } -} - -VOID -EXhalbtc8723b1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bBtBusy=FALSE; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8723B_1ANT_MAX) - rspSource = BT_INFO_SRC_8723B_1ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - // if 0xff, it means BT is under WHCK test - if (btInfo == 0xff) - pCoexSta->bBtWhckTest = TRUE; - else - pCoexSta->bBtWhckTest = FALSE; - - if(BT_INFO_SRC_8723B_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btRetryCnt >= 1) - pCoexSta->popEventCnt++; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtRemoteNameReq = TRUE; - else - pCoexSta->bC2hBtRemoteNameReq = FALSE; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2-90; - //pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - if (pCoexSta->btInfoC2h[rspSource][1] == 0x49) - { - pCoexSta->nA2DPBitPool = - pCoexSta->btInfoC2h[rspSource][6]; - } - else - pCoexSta->nA2DPBitPool = 0; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - -#if BT_8723B_1ANT_ANTDET_ENABLE -#if BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE - if ((pBoardInfo->btdmAntDetFinish) && (pBoardInfo->btdmAntNumByAntDet == 2)) - { - if(pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x1\n")); - - //BT TRx Mask un-lock 0x2c[0], 0x30[0] = 1 - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x2c, 0x7c45); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x30, 0x7c45); - - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x1); - } - } - else -#endif -#endif - - { - if(!pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); - - //BT TRx Mask lock 0x2c[0], 0x30[0] = 0 - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x2c, 0x7c44); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x30, 0x7c44); - } - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if(pCoexSta->btInfoExt & BIT1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if(pCoexSta->btInfoExt & BIT3) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8723b1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8723B_1ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - pCoexSta->nNumOfProfile = 0; - - // set link exist status - if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - - pCoexSta->bBtHiPriLinkExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8723B_1ANT_B_FTP) - { - pCoexSta->bPanExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8723B_1ANT_B_A2DP) - { - pCoexSta->bA2dpExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8723B_1ANT_B_HID) - { - pCoexSta->bHidExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8723B_1ANT_B_SCO_ESCO) - { - pCoexSta->bScoExist = TRUE; - pCoexSta->nNumOfProfile++; - } - else - pCoexSta->bScoExist = FALSE; - - if ((pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) &&( pCoexSta->bScoExist == FALSE)) - { - if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - { - pCoexSta->bHidExist = TRUE; - pCoexSta->wrongProfileNotification++; - pCoexSta->nNumOfProfile++; - btInfo = btInfo | 0x28; - } - } - - //Add Hi-Pri Tx/Rx counter to avoid false detection - if (((pCoexSta->bHidExist) || (pCoexSta->bScoExist)) && (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->bBtHiPriLinkExist = TRUE; - - if((btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) && (pCoexSta->nNumOfProfile == 0)) - { - if (pCoexSta->lowPriorityTx + pCoexSta->lowPriorityRx >= 160) - { - pCoexSta->bPanExist = TRUE; - pCoexSta->nNumOfProfile++; - pCoexSta->wrongProfileNotification++; - btInfo = btInfo | 0x88; - } - } - } - - halbtc8723b1ant_UpdateBtLinkInfo(pBtCoexist); - - btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) - - if(!(btInfo&BT_INFO_8723B_1ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8723B_1ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8723B_1ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8723B_1ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8723B_1ANT_B_ACL_BUSY) - { - if(BT_8723B_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8723B_1ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8723B_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - bBtBusy = TRUE; - else - bBtBusy = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - halbtc8723b1ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8723b1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa,u1Tmpb, u1Tmpc; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n")); - - if(BTC_RF_ON == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n")); - pBtCoexist->bStopCoexDm = FALSE; - } - else if(BTC_RF_OFF == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n")); - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - - halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - pBtCoexist->bStopCoexDm = TRUE; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u1Tmpc = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x67=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb, u1Tmpc)); - - } -} - -VOID -EXhalbtc8723b1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - - halbtc8723b1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - pBtCoexist->bStopCoexDm = TRUE; -} - -VOID -EXhalbtc8723b1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - - halbtc8723b1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8723b1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8723b1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - //halbtc8723b1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - - pBtCoexist->bStopCoexDm = TRUE; - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - pBtCoexist->bStopCoexDm = FALSE; - halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8723b1ant_InitCoexDm(pBtCoexist); - halbtc8723b1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8723b1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n")); - - halbtc8723b1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x2, 0xfffff, 0x0); - halbtc8723b1ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8723b1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8723b1Ant, GLCoexVer8723b1Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8723B_1ANT == 0) - halbtc8723b1ant_QueryBtInfo(pBtCoexist); - halbtc8723b1ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8723b1ant_MonitorBtCtr(pBtCoexist); - halbtc8723b1ant_MonitorWiFiCtr(pBtCoexist); -#if BT_8723B_1ANT_ANTDET_ENABLE - halbtc8723b1ant_MonitorBtEnableDisable(pBtCoexist); -#endif - - if ( (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx < 50) && (pBtLinkInfo->bHidExist == TRUE)) - { - pBtLinkInfo->bHidExist = FALSE; - } - - if( halbtc8723b1ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust ) - { - halbtc8723b1ant_RunCoexistMechanism(pBtCoexist); - } - - pCoexSta->specialPktPeriodCnt++; - - // sample to set bt to execute Ant detection - //pBtCoexist->fBtcSetBtAntDetection(pBtCoexist, 20, 14); -/* - if (pPsdScan->bIsAntDetEnable) - { - if (pPsdScan->nPSDGenCount > pPsdScan->realseconds) - pPsdScan->nPSDGenCount = 0; - - halbtc8723b1ant_AntennaDetection(pBtCoexist, pPsdScan->realcentFreq, pPsdScan->realoffset, pPsdScan->realspan, pPsdScan->realseconds); - pPsdScan->nPSDGenTotalCount +=2; - pPsdScan->nPSDGenCount += 2; - } -*/ -#endif -} - -VOID -EXhalbtc8723b1ant_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - static u4Byte AntDetCount = 0, AntDetFailCount = 0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - BOOLEAN bScan, bRoam; - -#if BT_8723B_1ANT_ANTDET_ENABLE - - if (seconds == 0) - { - pPsdScan->bAntDet_TryCount = 0; - pPsdScan->bAntDet_FailCount = 0; - AntDetCount = 0; - AntDetFailCount = 0; - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - return; - } - - if (!pBoardInfo->btdmAntDetFinish) - { - pPsdScan->nAntDet_IntevalCount = pPsdScan->nAntDet_IntevalCount+2; - - if (pPsdScan->nAntDet_IntevalCount >= BT_8723B_1ANT_ANTDET_RETRY_INTERVAL) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna Det Timer is up, Try Detect!!\n")); - halbtc8723b1ant_PSD_AntennaDetectionCheck(pBtCoexist); - - if (pBoardInfo->btdmAntDetFinish) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna Det Success!!\n")); -#if 1 - if (pBoardInfo->btdmAntNumByAntDet == 2) - halbtc8723b1ant_MechanismSwitch(pBtCoexist, TRUE); - else - halbtc8723b1ant_MechanismSwitch(pBtCoexist, FALSE); -#endif - } - else - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna Det Fail!!\n")); - - pPsdScan->nAntDet_IntevalCount = 0; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("xxxxxxxxxxxxxxxx AntennaDetect(), Antenna Det Timer is not up! (%d)\n", pPsdScan->nAntDet_IntevalCount)); - } - - } -#endif - - -/* - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - - pPsdScan->nAntDet_BTTxTime = seconds; //0.42ms*50 = 20ms - pPsdScan->nAntDet_BTLEChannel = centFreq; - - if (seconds == 0) - { - pPsdScan->bAntDet_TryCount = 0; - pPsdScan->bAntDet_FailCount = 0; - AntDetCount = 0; - AntDetFailCount = 0; - pBoardInfo->btdmAntDetFinish = FALSE; - pBoardInfo->btdmAntNumByAntDet = 1; - return; - } - else - { - AntDetCount++; - - pPsdScan->bAntDet_TryCount = AntDetCount; - - if (bScan ||bRoam) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 6; - } - else if (pCoexSta->nNumOfProfile >= 1) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 7; - } - else if (!pPsdScan->nAntDet_IsAntDetAvailable) //Antenna initial setup is not ready - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 9; - } - else if (pCoexSta->bC2hBtInquiryPage) - { - pBoardInfo->btdmAntDetFinish = FALSE; - pPsdScan->nAntDet_Result = 10; - } - else - { - //halbtc8723b1ant_PSD_AntennaDetection(pBtCoexist, pPsdScan->nAntDet_BTTxTime, pPsdScan->nAntDet_BTLEChannel); - } - - if (!pBoardInfo->btdmAntDetFinish) - AntDetFailCount++; - - pPsdScan->bAntDet_FailCount = AntDetFailCount; - } -*/ -} - -VOID -EXhalbtc8723b1ant_AntennaIsolation( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - - -} - -VOID -EXhalbtc8723b1ant_PSDScan( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - - -} - -VOID -EXhalbtc8723b1ant_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - -#if BT_8723B_1ANT_ANTDET_ENABLE - if (pPsdScan->bAntDet_TryCount != 0) - { - halbtc8723b1ant_PSD_ShowAntennaDetectResult(pBtCoexist); - - if (pBoardInfo->btdmAntDetFinish) - halbtc8723b1ant_PSD_ShowData(pBtCoexist); - return; - } -#endif - - //halbtc8723b1ant_ShowPSDData(pBtCoexist); -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.h deleted file mode 100644 index 90a78c819..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b1Ant.h +++ /dev/null @@ -1,338 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8723B 1ANT BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8723B_1ANT 1 - -#define BT_INFO_8723B_1ANT_B_FTP BIT7 -#define BT_INFO_8723B_1ANT_B_A2DP BIT6 -#define BT_INFO_8723B_1ANT_B_HID BIT5 -#define BT_INFO_8723B_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8723B_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8723B_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8723B_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8723B_1ANT_B_CONNECTION BIT0 - -#define BT_INFO_8723B_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8723B_1ANT 2 - -#define BT_8723B_1ANT_WIFI_NOISY_THRESH 50 //30 //max: 255 - -//for Antenna detection -#define BT_8723B_1ANT_ANTDET_PSDTHRES_BACKGROUND 50 -#define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_BADISOLATION 70 -#define BT_8723B_1ANT_ANTDET_PSDTHRES_2ANT_GOODISOLATION 55 -#define BT_8723B_1ANT_ANTDET_PSDTHRES_1ANT 35 -#define BT_8723B_1ANT_ANTDET_RETRY_INTERVAL 10 //retry timer if ant det is fail, unit: second -#define BT_8723B_1ANT_ANTDET_ENABLE 0 -#define BT_8723B_1ANT_ANTDET_COEXMECHANISMSWITCH_ENABLE 0 - -typedef enum _BT_INFO_SRC_8723B_1ANT{ - BT_INFO_SRC_8723B_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8723B_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8723B_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8723B_1ANT_MAX -}BT_INFO_SRC_8723B_1ANT,*PBT_INFO_SRC_8723B_1ANT; - -typedef enum _BT_8723B_1ANT_BT_STATUS{ - BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8723B_1ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8723B_1ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8723B_1ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8723B_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8723B_1ANT_BT_STATUS_MAX -}BT_8723B_1ANT_BT_STATUS,*PBT_8723B_1ANT_BT_STATUS; - -typedef enum _BT_8723B_1ANT_WIFI_STATUS{ - BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8723B_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, - BT_8723B_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, - BT_8723B_1ANT_WIFI_STATUS_MAX -}BT_8723B_1ANT_WIFI_STATUS,*PBT_8723B_1ANT_WIFI_STATUS; - -typedef enum _BT_8723B_1ANT_COEX_ALGO{ - BT_8723B_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8723B_1ANT_COEX_ALGO_SCO = 0x1, - BT_8723B_1ANT_COEX_ALGO_HID = 0x2, - BT_8723B_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8723B_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8723B_1ANT_COEX_ALGO_PANEDR = 0x5, - BT_8723B_1ANT_COEX_ALGO_PANHS = 0x6, - BT_8723B_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8723B_1ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8723B_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8723B_1ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8723B_1ANT_COEX_ALGO_MAX = 0xb, -}BT_8723B_1ANT_COEX_ALGO,*PBT_8723B_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8723B_1ANT{ - // hw setting - u1Byte preAntPosType; - u1Byte curAntPosType; - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; - u4Byte nArpCnt; - - u1Byte errorCondition; -} COEX_DM_8723B_1ANT, *PCOEX_DM_8723B_1ANT; - -typedef struct _COEX_STA_8723B_1ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - BOOLEAN bBtHiPriLinkExist; - u1Byte nNumOfProfile; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte specialPktPeriodCnt; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - s1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8723B_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8723B_1ANT_MAX]; - BOOLEAN bBtWhckTest; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtRemoteNameReq; - BOOLEAN bWiFiIsHighPriTask; //Add for win8.1 page out issue - u1Byte btRetryCnt; - u1Byte btInfoExt; - u4Byte popEventCnt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - BOOLEAN bCCKLock; - BOOLEAN bPreCCKLock; - BOOLEAN bCCKEverLock; - u1Byte nCoexTableType; - - BOOLEAN bForceLpsOn; - u4Byte wrongProfileNotification; - - u1Byte nA2DPBitPool; - u1Byte nCutVersion; -}COEX_STA_8723B_1ANT, *PCOEX_STA_8723B_1ANT; - -#define BT_8723B_1ANT_ANTDET_PSD_POINTS 256 //MAX:1024 -#define BT_8723B_1ANT_ANTDET_PSD_AVGNUM 1 //MAX:3 -#define BT_8723B_1ANT_ANTDET_BUF_LEN 16 - -typedef struct _PSDSCAN_STA_8723B_1ANT{ - -u4Byte nAntDet_BTLEChannel; //BT LE Channel ex:2412 -u4Byte nAntDet_BTTxTime; -u4Byte nAntDet_PrePSDScanPeakVal; -BOOLEAN nAntDet_IsAntDetAvailable; -u4Byte nAntDet_PSDScanPeakVal; -BOOLEAN nAntDet_IsBTReplyAvailable; -u4Byte nAntDet_PSDScanPeakFreq; - -u1Byte nAntDet_Result; -u1Byte nAntDet_PeakVal[BT_8723B_1ANT_ANTDET_BUF_LEN]; -u1Byte nAntDet_PeakFreq[BT_8723B_1ANT_ANTDET_BUF_LEN]; -u4Byte bAntDet_TryCount; -u4Byte bAntDet_FailCount; -u4Byte nAntDet_IntevalCount; -u4Byte nAntDet_ThresOffset; - -u4Byte nRealCentFreq; -s4Byte nRealOffset; -u4Byte nRealSpan; - -u4Byte nPSDBandWidth; //unit: Hz -u4Byte nPSDPoint; //128/256/512/1024 -u4Byte nPSDReport[1024]; //unit:dB (20logx), 0~255 -u4Byte nPSDReport_MaxHold[1024]; //unit:dB (20logx), 0~255 -u4Byte nPSDStartPoint; -u4Byte nPSDStopPoint; -u4Byte nPSDMaxValuePoint; -u4Byte nPSDMaxValue; -u4Byte nPSDStartBase; -u4Byte nPSDAvgNum; // 1/8/16/32 -u4Byte nPSDGenCount; -BOOLEAN bIsPSDRunning; -BOOLEAN bIsPSDShowMaxOnly; -} PSDSCAN_STA_8723B_1ANT, *PPSDSCAN_STA_8723B_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8723b1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8723b1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8723b1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8723b1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b1ant_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); -VOID -EXhalbtc8723b1ant_AntennaIsolation( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); - -VOID -EXhalbtc8723b1ant_PSDScan( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); -VOID -EXhalbtc8723b1ant_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.c deleted file mode 100644 index 4c77b6102..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.c +++ /dev/null @@ -1,4934 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8723B Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8723b2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8723B_2ANT GLCoexDm8723b2Ant; -static PCOEX_DM_8723B_2ANT pCoexDm=&GLCoexDm8723b2Ant; -static COEX_STA_8723B_2ANT GLCoexSta8723b2Ant; -static PCOEX_STA_8723B_2ANT pCoexSta=&GLCoexSta8723b2Ant; - -const char *const GLBtInfoSrc8723b2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8723b2Ant=20150119; -u4Byte GLCoexVer8723b2Ant=0x44; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8723b2ant_ -//============================================================ -u1Byte -halbtc8723b2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8723b2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8723b2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - - bPreBtDisabled = bBtDisabled; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - if(bBtDisabled) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - - -VOID -halbtc8723b2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); -} - -VOID -halbtc8723b2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if( (pCoexSta->lowPriorityTx > 1050) && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->popEventCnt++; - - if ( (pCoexSta->lowPriorityRx >= 950) && (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bUnderIps) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8723b2ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); -} - -VOID -halbtc8723b2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -BOOLEAN -halbtc8723b2ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist,3, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - - if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState )) - { - return TRUE; - } - - } - - return FALSE; -} - -VOID -halbtc8723b2ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - -#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) // profile from bt patch - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } -#else // profile from bt stack - pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist; - pBtLinkInfo->bScoExist = pStackInfo->bScoExist; - pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist; - pBtLinkInfo->bPanExist = pStackInfo->bPanExist; - pBtLinkInfo->bHidExist = pStackInfo->bHidExist; - - //for win-8 stack HID report error - if(!pStackInfo->bHidExist) - pStackInfo->bHidExist = pCoexSta->bHidExist; //sync BTInfo with BT firmware and stack - // when stack HID report error, here we use the info from bt fw. - if(!pStackInfo->bBtLinkExist) - pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist; -#endif - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8723b2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8723B_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { -#if 0 - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else -#endif - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8723B_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8723b2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8723b2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte decBtPwrLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = decBtPwrLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n", - decBtPwrLvl, H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); -} - -VOID -halbtc8723b2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte decBtPwrLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n", - (bForceExec? "force to":""), decBtPwrLvl)); - pCoexDm->curBtDecPwrLvl = decBtPwrLvl; - - if(!bForceExec) - { - if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) - return; - } - halbtc8723b2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl); - - pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; -} - -VOID -halbtc8723b2ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8723b2ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8723b2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8723b2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8723b2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8723b2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8723b2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8723b2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8723b2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!")) ); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8723b2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - //return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8723b2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8723b2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x883, 0x3e, val); -} - -VOID -halbtc8723b2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8723b2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8723b2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8723b2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8723b2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8723b2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc05, 0x30, 0x1); - } -} - -VOID -halbtc8723b2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8723b2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8723b2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - //=================BB AGC Gain Table - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001); - } - - - //=================RF Gain - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - if(bAgcTableEn) - { - rssiAdjustVal = 8; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - -VOID -halbtc8723b2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8723b2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8723b2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8723b2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8723b2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8723b2ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3); - break; - case 2: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3); - break; - case 3: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 4: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3); - break; - case 5: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3); - break; - case 6: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 7: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 8: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 9: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 10: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 11: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 12: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 13: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 14: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3); - break; - case 15: - halbtc8723b2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8723b2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8723b2ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8723b2ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8723b2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8723b2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8723b2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8723b2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - - - if ( (pCoexSta->bA2dpExist) && (pCoexSta->bHidExist) ) - { - byte5 = byte5 | 0x1; - } - - H2C_Parameter[0] = byte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = byte5; - - pCoexDm->psTdmaPara[0] = byte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = byte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - -VOID -halbtc8723b2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - /* - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - */ - - //halbtc8723b2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - halbtc8723b2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8723b2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - //halbtc8723b2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - //halbtc8723b2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - //halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8723b2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte fwVer=0, u4Tmp=0; - BOOLEAN bPgExtSwitch=FALSE; - BOOLEAN bUseExtSwitch=FALSE; - u1Byte H2C_Parameter[2] ={0}; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_EXT_SWITCH, &bPgExtSwitch); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); // [31:16]=fw ver, [15:0]=fw sub ver - - if((fwVer>0 && fwVer<0xc0000) || bPgExtSwitch) - bUseExtSwitch = TRUE; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x39, 0x8, 0x1); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x974, 0xff); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x944, 0x3, 0x3); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x930, 0x77); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); - - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to High to avoid A2DP click */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); //WiFi TRx Mask off - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); //BT TRx Mask off - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "no antenna inverse" - H2C_Parameter[0] = 0; - } - else - { - //tell firmware "antenna inverse" - H2C_Parameter[0] = 1; - } - - if (bUseExtSwitch) - { - //ext switch type - H2C_Parameter[1] = 1; - } - else - { - //int switch type - H2C_Parameter[1] = 0; - } - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to "Control by PTA"*/ - H2C_Parameter[0] = 0; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x0); - } - } - - // ext switch setting - if(bUseExtSwitch) - { - if (bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x1); // ext switch main at wifi - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x92c, 0x3, 0x2); // ext switch aux at wifi - break; - } - } - else // internal switch - { - if (bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp |= BIT23; - u4Tmp &=~BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - } - - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //fixed external switch S1->Main, S0->Aux - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); // fixed internal switch S1->WiFi, S0->BT - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x280); // fixed internal switch S0->WiFi, S1->BT - break; - } - } -} - -VOID -halbtc8723b2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - u1Byte wifiRssiState1, btRssiState; - s1Byte nWiFiDurationAdjust = 0x0; - u1Byte psTdmaByte4Modify = 0x0; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn) - { - type = type +100; //for WiFi RSSI low or BT RSSI low - pCoexDm->bIsSwitchTo1dot5Ant = TRUE; - } - else - { - pCoexDm->bIsSwitchTo1dot5Ant = FALSE; - } - - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum <= 5) - { - if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else - nWiFiDurationAdjust = 5; - } - else if (pCoexSta->nScanAPNum <= 20) - { - if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else - nWiFiDurationAdjust = 0; - } - else if (pCoexSta->nScanAPNum <= 40) - { - if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else - nWiFiDurationAdjust = -5; - } - else - { - if (pCoexSta->nA2DPBitPool >= 45) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nA2DPBitPool >= 35) - nWiFiDurationAdjust = -10; - else - nWiFiDurationAdjust = -10; - } - - if ( (pBtLinkInfo->bSlaveRole == TRUE) && (pBtLinkInfo->bA2dpExist) ) - psTdmaByte4Modify = 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - - - if(bTurnOn) - { - switch(type) - { - case 1: - default: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c+nWiFiDurationAdjust, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 2: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d+nWiFiDurationAdjust, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 3: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 4: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 5: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c+nWiFiDurationAdjust, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 6: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d+nWiFiDurationAdjust, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 7: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 8: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 9: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c+nWiFiDurationAdjust, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 10: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d+nWiFiDurationAdjust, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 11: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 12: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 13: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c+nWiFiDurationAdjust, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 14: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d+nWiFiDurationAdjust, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 15: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 16: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90|psTdmaByte4Modify); - break; - case 17: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); - break; - case 18: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 71: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c+nWiFiDurationAdjust, 0x03, 0xf1, 0x90); - break; - case 101: - case 105: - case 171: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a+nWiFiDurationAdjust, 0x03, 0x70, 0x50|psTdmaByte4Modify); - break; - case 102: - case 106: - case 110: - case 114: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d+nWiFiDurationAdjust, 0x03, 0x70, 0x50|psTdmaByte4Modify); - break; - case 103: - case 107: - case 111: - case 115: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50|psTdmaByte4Modify); - break; - case 104: - case 108: - case 112: - case 116: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50|psTdmaByte4Modify); - break; - case 109: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90|psTdmaByte4Modify); - break; - case 113: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90|psTdmaByte4Modify); - break; - case 121: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90|psTdmaByte4Modify); - break; - case 22: - case 122: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 0: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - case 1: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; - default: - halbtc8723b2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8723b2ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8723b2ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8723b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8723b2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8723b2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - - -VOID -halbtc8723b2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8723b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - pCoexSta->popEventCnt = 0; - -} - -VOID -halbtc8723b2ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bLowPwrDisable=TRUE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n")); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n")); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n")); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -/* - pCoexDm->bNeedRecover0x948 = TRUE; - pCoexDm->backup0x948 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - - halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_AUX, FALSE, FALSE); -*/ -} - - -VOID -halbtc8723b2ant_ActionWiFiLinkProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa, u1Tmpb; - - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); -} - -BOOLEAN -halbtc8723b2ant_ActionWifiIdleProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if(BTC_RSSI_HIGH(wifiRssiState1) && - (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE)) - { - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n")); - - halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - return TRUE; - } - else - { - halbtc8723b2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - return FALSE; - } - - -} - - - -BOOLEAN -halbtc8723b2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte btRssiState=BTC_RSSI_STATE_HIGH; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE; - BOOLEAN bAsus8723b=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else if(BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bBtHsOn) - return FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_IS_ASUS_8723B, &bAsus8723b); - if(!bAsus8723b) - bCommon = FALSE; - else - bCommon = halbtc8723b2ant_ActionWifiIdleProcess(pBtCoexist); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - //bCommon = FALSE; - bCommon = halbtc8723b2ant_ActionWifiIdleProcess(pBtCoexist); - } - } - } - - return bCommon; -} -VOID -halbtc8723b2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 71) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 71) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -// SCO only or SCO+PAN(HS) -VOID -halbtc8723b2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - else //for SCO quality & wifi performance balance at 11n mode - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x4); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x4); - } - } -} - - -VOID -halbtc8723b2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 9); - } - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8723b2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - //DbgPrint(" AP#>10(%d)\n", apNum); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - return; - - } - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - else - { - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8723b2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8723b2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - else - { - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - - -//PAN(HS) only -VOID -halbtc8723b2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8723b2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12); - - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - else - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8723b2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3); - //halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - } - else - { - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - } - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - } - else - { - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8723b2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(2, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - else - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else - { - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8723b2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8723b2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //btRssiState = halbtc8723b2ant_BtRssiState(2, 29, 0); - wifiRssiState1 = halbtc8723b2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8723b2ant_BtRssiState(3, BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES, 37); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8723b2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5); - - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - else - { // only 802.11N mode we have to dec bt power to 4 degree - if(BTC_RSSI_HIGH(btRssiState)) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - // need to check ap Number of Not - if(apNum < 10) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - } - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else - { - halbtc8723b2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8723b2ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8723b2ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8723b2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8723b2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8723b2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8723b2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8723b2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8723b2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8723b2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); -} - -VOID -halbtc8723b2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - u4Byte numOfWifiLink=0; - u4Byte wifiLinkStatus=0; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bMiracastPlusBt=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if(pCoexSta->bBtWhckTest) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n")); - halbtc8723b2ant_ActionBtWhckTest(pBtCoexist); - return; - } - - algorithm = halbtc8723b2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8723B_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8723b2ant_ActionBtInquiry(pBtCoexist); - return; - } - else - { - /* - if(pCoexDm->bNeedRecover0x948) - { - pCoexDm->bNeedRecover0x948 = FALSE; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, pCoexDm->backup0x948); - } - */ - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n")); - halbtc8723b2ant_ActionWiFiLinkProcess(pBtCoexist); - return; - } - - //for P2P - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - bMiracastPlusBt = TRUE; - } - else - { - bMiracastPlusBt = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8723b2ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8723b2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8723B_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8723b2ant_ActionSco(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8723b2ant_ActionHid(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8723b2ant_ActionA2dp(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8723b2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8723b2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8723b2ant_ActionPanHs(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8723b2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8723b2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8723b2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8723B_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8723b2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8723b2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8723b2ant_WifiOffHwCfg( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bIsInMpMode = FALSE; - u1Byte H2C_Parameter[2] ={0}; - u4Byte fwVer=0; - - // set wlan_act to low - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1 - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to HIGH */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_IS_IN_MP_MODE, &bIsInMpMode); - if(!bIsInMpMode) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x0); //BT select s0/s1 is controlled by BT - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x67, 0x20, 0x1); //BT select s0/s1 is controlled by WiFi -} - -VOID -halbtc8723b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0, fwVer; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - //0xf0[15:12] --> Chip Cut information - pCoexSta->nCutVersion = (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xf1) & 0xf0) >> 4; - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - //Antenna config - halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE); - pCoexSta->disVerInfoCnt = 0; - - // PTA parameter - halbtc8723b2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); -} - -//============================================================ -// work around function start with wa_halbtc8723b2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8723b2ant_ -//============================================================ -VOID -EXhalbtc8723b2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u2Byte u2Tmp=0x0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x67, 0x20); - - // enable BB, REG_SYS_FUNC_EN such that we can write 0x948 correctly. - u2Tmp = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x2); - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x2, u2Tmp|BIT0|BIT1); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x948, 0x0); - - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - // set to S1 - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - pBoardInfo->btdmAntPos = BTC_ANTENNA_AT_AUX_PORT; - } - } -} - -VOID -EXhalbtc8723b2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */ - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - u1Tmp |= 0x1; // antenna inverse - } - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } -} - -VOID -EXhalbtc8723b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8723b2ant_InitHwConfig(pBtCoexist, TRUE); -} - -VOID -EXhalbtc8723b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8723b2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8723b2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - static u1Byte PopReportIn10s = 0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)/ %c", "Version Coex/ Fw/ Patch/ Cut", \ - GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer, pCoexSta->nCutVersion+65); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - PopReportIn10s++; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi-100, pCoexSta->btRetryCnt, pCoexSta->popEventCnt); - CL_PRINTF(cliBuf); - - if (PopReportIn10s >= 5) - { - pCoexSta->popEventCnt = 0; - PopReportIn10s = 0; - } - - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d / %d / %d", "SCO/HID/PAN/A2DP/NameReq/WHQL", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist, pCoexSta->bC2hBtRemoteNameReq, pCoexSta->bBtWhckTest ); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) - { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \ - (pBtLinkInfo->bSlaveRole )? "Slave":"Master"); - CL_PRINTF(cliBuf); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "A2DP Rate/Bitpool", \ - (btInfoExt&BIT0)? "BR":"EDR", pCoexSta->nA2DPBitPool); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - // Sw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism] (before Manual)============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism] (before Manual) ============"); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - } - - psTdmaCase = pCoexDm->curPsTdma; - - if (pCoexDm->bIsSwitchTo1dot5Ant) - psTdmaCase = psTdmaCase + 100; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (%s,%s)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, - (pCoexDm->bCurPsTdmaOn? "On":"Off"), - (pCoexDm->bAutoTdmaAdjust? "Adj":"Fix") ); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \ - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \ - u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25); - CL_PRINTF(cliBuf); - - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \ - u4Tmp[0], ((u1Tmp[0]&0x20)>> 5), u1Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ - u4Tmp[0]&0x3, u4Tmp[1]&0xff, u4Tmp[2]&0x3); - CL_PRINTF(cliBuf); - - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ - ((u1Tmp[0] & 0x8)>>3), u1Tmp[1], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[2]&0x1); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ - u4Tmp[0]&0xff, u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[0]&0xffff, faOfdm, faCck); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 1) - //halbtc8723b2ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8723b2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8723b2ant_WifiOffHwCfg(pBtCoexist); - halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - halbtc8723b2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - halbtc8723b2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8723b2ant_InitCoexDm(pBtCoexist); - halbtc8723b2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8723b2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8723b2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa, u1Tmpb; - - - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x948=0x%x, 0x765=0x%x, 0x76e=0x%x\n", - u4Tmp, u1Tmpa, u1Tmpb)); -} - -VOID -EXhalbtc8723b2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8723b2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - u1Byte apNum=0; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - if(apNum < 10) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8723b2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8723b2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE; - static BOOLEAN bPreScoExist=FALSE; - u4Byte raMask=0x0; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8723B_2ANT_MAX) - rspSource = BT_INFO_SRC_8723B_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n")); - return; - } - - // if 0xff, it means BT is under WHCK test - if (btInfo == 0xff) - pCoexSta->bBtWhckTest = TRUE; - else - pCoexSta->bBtWhckTest = FALSE; - - if(BT_INFO_SRC_8723B_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btRetryCnt >= 1) - pCoexSta->popEventCnt++; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtRemoteNameReq = TRUE; - else - pCoexSta->bC2hBtRemoteNameReq = FALSE; - - if (pCoexSta->btInfoC2h[rspSource][1] == 0x49) - { - pCoexSta->nA2DPBitPool = - pCoexSta->btInfoC2h[rspSource][6]; - } - else - pCoexSta->nA2DPBitPool = 0; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if (pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if( (pCoexSta->btInfoExt & BIT3) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8723b2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8723B_2ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8723B_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8723B_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8723B_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8723B_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - - if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE)) - { - if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - { - pCoexSta->bHidExist = TRUE; - btInfo = btInfo | 0x28; - } - } - } - - halbtc8723b2ant_UpdateBtLinkInfo(pBtCoexist); - - if(!(btInfo&BT_INFO_8723B_2ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8723B_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8723B_2ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8723B_2ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8723B_2ANT_B_ACL_BUSY) - { - pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8723B_2ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8723B_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8723B_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bBtBusy = TRUE; - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8723b2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8723b2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8723b2ant_WifiOffHwCfg(pBtCoexist); - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0 - halbtc8723b2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8723b2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - halbtc8723b2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8723b2ant_InitCoexDm(pBtCoexist); - halbtc8723b2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8723b2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - //static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(pCoexSta->disVerInfoCnt <= 5) - { - pCoexSta->disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - - if (pCoexSta->disVerInfoCnt == 3) - { - //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n")); - halbtc8723b2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE); - } - } - -#if(BT_AUTO_REPORT_ONLY_8723B_2ANT == 0) - halbtc8723b2ant_QueryBtInfo(pBtCoexist); - halbtc8723b2ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8723b2ant_MonitorBtCtr(pBtCoexist); - halbtc8723b2ant_MonitorWiFiCtr(pBtCoexist); - - //for some BT speaker that Hi-Pri pkt appear begore start play, this will cause HID exist - if ( (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx < 50) && (pBtLinkInfo->bHidExist == TRUE)) - { - pBtLinkInfo->bHidExist = FALSE; - } - - if( halbtc8723b2ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust) - { - halbtc8723b2ant_RunCoexistMechanism(pBtCoexist); - } -#endif -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.h deleted file mode 100644 index 7ae66968f..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8723b2Ant.h +++ /dev/null @@ -1,235 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8723B 2Ant BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8723B_2ANT 1 - - -#define BT_INFO_8723B_2ANT_B_FTP BIT7 -#define BT_INFO_8723B_2ANT_B_A2DP BIT6 -#define BT_INFO_8723B_2ANT_B_HID BIT5 -#define BT_INFO_8723B_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8723B_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8723B_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8723B_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8723B_2ANT_B_CONNECTION BIT0 - -#define BTC_RSSI_COEX_THRESH_TOL_8723B_2ANT 2 - - -#define BT_8723B_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 //WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation -#define BT_8723B_2ANT_BT_RSSI_COEXSWITCH_THRES 46 //BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation - -typedef enum _BT_INFO_SRC_8723B_2ANT{ - BT_INFO_SRC_8723B_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8723B_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8723B_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8723B_2ANT_MAX -}BT_INFO_SRC_8723B_2ANT,*PBT_INFO_SRC_8723B_2ANT; - -typedef enum _BT_8723B_2ANT_BT_STATUS{ - BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8723B_2ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8723B_2ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8723B_2ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8723B_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8723B_2ANT_BT_STATUS_MAX -}BT_8723B_2ANT_BT_STATUS,*PBT_8723B_2ANT_BT_STATUS; - -typedef enum _BT_8723B_2ANT_COEX_ALGO{ - BT_8723B_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8723B_2ANT_COEX_ALGO_SCO = 0x1, - BT_8723B_2ANT_COEX_ALGO_HID = 0x2, - BT_8723B_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8723B_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8723B_2ANT_COEX_ALGO_PANEDR = 0x5, - BT_8723B_2ANT_COEX_ALGO_PANHS = 0x6, - BT_8723B_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8723B_2ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8723B_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8723B_2ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8723B_2ANT_COEX_ALGO_MAX = 0xb, -}BT_8723B_2ANT_COEX_ALGO,*PBT_8723B_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8723B_2ANT{ - // fw mechanism - u1Byte preBtDecPwrLvl; - u1Byte curBtDecPwrLvl; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - BOOLEAN bNeedRecover0x948; - u4Byte backup0x948; - - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - BOOLEAN bIsSwitchTo1dot5Ant; -} COEX_DM_8723B_2ANT, *PCOEX_DM_8723B_2ANT; - -typedef struct _COEX_STA_8723B_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8723B_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8723B_2ANT_MAX]; - BOOLEAN bBtWhckTest; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtRemoteNameReq; - u1Byte btRetryCnt; - u1Byte btInfoExt; - u4Byte popEventCnt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - u1Byte nCoexTableType; - BOOLEAN bForceLpsOn; - - u1Byte disVerInfoCnt; - - u1Byte nA2DPBitPool; - u1Byte nCutVersion; -}COEX_STA_8723B_2ANT, *PCOEX_STA_8723B_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8723b2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8723b2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8723b2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8723b2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8723b2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8723b2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.c deleted file mode 100644 index d5359ad48..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.c +++ /dev/null @@ -1,3718 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8812A Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8812a1Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8812A_1ANT GLCoexDm8812a1Ant; -static PCOEX_DM_8812A_1ANT pCoexDm=&GLCoexDm8812a1Ant; -static COEX_STA_8812A_1ANT GLCoexSta8812a1Ant; -static PCOEX_STA_8812A_1ANT pCoexSta=&GLCoexSta8812a1Ant; - -const char *const GLBtInfoSrc8812a1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8812a1Ant=20140708; -u4Byte GLCoexVer8812a1Ant=0x52; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8812a1ant_ -//============================================================ -u1Byte -halbtc8812a1ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8812a1ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8812a1ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -//to check 0x430/0x434 is correct?? -VOID -halbtc8812a1ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -//to check 0x42a ?? -VOID -halbtc8812a1ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -//to check 0x456?? -VOID -halbtc8812a1ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8812a1ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8812a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8812a1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8812a1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8812a1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8812a1ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8812a1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte dataLen=3; - u1Byte buf[5] = {0}; - - if(!pBtCoexist->btInfo.bBtDisabled) - { - if(!pCoexSta->btInfoQueryCnt || - (pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8812A_1ANT_BT_RSP]-pCoexSta->btInfoQueryCnt)>2) - { - buf[0] = dataLen; - buf[1] = 0x1; // polling enable, 1=enable, 0=disable - buf[2] = 0x2; // polling time in seconds - buf[3] = 0x1; // auto report enable, 1=enable, 0=disable - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_INFO, (PVOID)&buf[0]); - } - } - pCoexSta->btInfoQueryCnt++; -} - -VOID -halbtc8812a1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp, u1Tmp1; - s4Byte wifiRssi; - static u1Byte NumOfBtCounterChk = 0; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if( (pCoexSta->lowPriorityTx > 1150) && (!pCoexSta->bC2hBtInquiryPage)) - pCoexSta->popEventCnt++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Hi-Pri Rx/Tx: %d/%d, Lo-Pri Rx/Tx: %d/%d\n", - regHPRx, regHPTx, regLPRx, regLPTx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); - - if ((regHPTx == 0) && (regHPRx ==0) && (regLPTx == 0) && (regLPRx == 0)) - { - NumOfBtCounterChk++; - if (NumOfBtCounterChk >= 3) - { - halbtc8812a1ant_QueryBtInfo(pBtCoexist); - NumOfBtCounterChk = 0; - } - } -} - -//to check registers -VOID -halbtc8812a1ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf04); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf14); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf10); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf40); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf06); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf16); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf12); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf42); - } - - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xb58, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xb58, 0x1, 0x0); - - if ( (bWifiBusy) && (wifiRssi >= 30) && (!bWifiUnderBMode)) - { - if ( (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_ACL_BUSY) || - (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY) || - (pCoexDm->btStatus == BT_8812A_1ANT_BT_STATUS_SCO_BUSY) ) - { - if (pCoexSta->nCRCOK_CCK >(pCoexSta->nCRCOK_11g + pCoexSta->nCRCOK_11n + - pCoexSta->nCRCOK_11nAgg) ) - { - if (nCCKLockCounter < 5) - nCCKLockCounter++; - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - } - else - { - if (nCCKLockCounter > 0) - nCCKLockCounter--; - } - - if (!pCoexSta->bPreCCKLock) - { - - if (nCCKLockCounter >= 5) - pCoexSta->bCCKLock = TRUE; - else - pCoexSta->bCCKLock = FALSE; - } - else - { - if (nCCKLockCounter == 0) - pCoexSta->bCCKLock = FALSE; - else - pCoexSta->bCCKLock = TRUE; - } - - pCoexSta->bPreCCKLock = pCoexSta->bCCKLock; - - -} - -BOOLEAN -halbtc8812a1ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - } - - return FALSE; -} - -VOID -halbtc8812a1ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8812a1ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8812A_1ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8812A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8812a1ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8812a1ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8812a1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -//to check -VOID -halbtc8812a1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - tmpU1 |= BIT0; - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8812a1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8812a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8812a1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8812a1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8812a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8812a1ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); - - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 3: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 4: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3); - break; - case 5: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaa5a5a5a, 0xffffff, 0x3); - break; - case 6: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 7: - halbtc8812a1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8812a1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte dataLen=3; - u1Byte buf[5] = {0}; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Ignore Wlan_Act\n", - (bEnable? "Enable":"Disable"))); - - buf[0] = dataLen; - buf[1] = 0x1; // OP_Code - buf[2] = 0x1; // OP_Code_Length - if(bEnable) - buf[3] = 0x1; // OP_Code_Content - else - buf[3] = 0x0; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); -} - -VOID -halbtc8812a1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8812a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8812a1ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8812a1ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8812a1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8812a1ant_SwMechanism( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRA - ) -{ - halbtc8812a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -//to check bForceExec -VOID -halbtc8812a1ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bForceExec, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - u1Byte u1Tmp=0; - - pCoexDm->curAntPosType = antPosType; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb3, 0x77); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x900, 0x00000400); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76d, 0x1); - } - else if(bWifiOff) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb3, 0x77); - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u1Tmp &= ~BIT3; - u1Tmp |= BIT2; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp); - } - - if(bForceExec || (pCoexDm->curAntPosType != pCoexDm->preAntPosType)) - { - // ext switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u1Tmp |= BIT3; - u1Tmp &= ~BIT2; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp); - break; - case BTC_ANT_PATH_BT: - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u1Tmp &= ~BIT3; - u1Tmp |= BIT2; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp); - break; - default: - case BTC_ANT_PATH_PTA: - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u1Tmp |= BIT3; - u1Tmp &= ~BIT2; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp); - break; - } - } - - pCoexDm->preAntPosType = pCoexDm->curAntPosType; -} - -VOID -halbtc8812a1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - - -VOID -halbtc8812a1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bTurnOnByCnt=FALSE, bWifiBusy=FALSE, bWiFiNoisy=FALSE; - u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0; - u1Byte psTdmaByte4Val = 0x50, psTdmaByte0Val = 0x51, psTdmaByte3Val = 0x10; - s1Byte nWiFiDurationAdjust = 0x0; - static BOOLEAN bPreWifiBusy=FALSE; - - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if (bWifiBusy != bPreWifiBusy) - { - bForceExec = TRUE; - bPreWifiBusy = bWifiBusy; - } - - if (pCoexDm->bCurPsTdmaOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum <= 5) - nWiFiDurationAdjust = 2; - else if (pCoexSta->nScanAPNum >= 40) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nScanAPNum >= 20) - nWiFiDurationAdjust = -10; - - if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle - } - - if ( (type == 3) || (type == 13) || (type == 14) ) - { - psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile - - if (!bWifiBusy) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - } - - if (pBtLinkInfo->bSlaveRole == TRUE) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - - if(bTurnOn) - { - switch(type) - { - default: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, psTdmaByte4Val); - break; - case 1: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x3a+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 2: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x2d+nWiFiDurationAdjust, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 3: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, psTdmaByte4Val); - break; - case 4: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0); - break; - case 5: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x11); - break; - case 6: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x11); - break; - case 7: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); - break; - case 8: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 9: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x3, psTdmaByte3Val, psTdmaByte4Val); - break; - case 10: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, psTdmaByte0Val, 0x21, 0x03, psTdmaByte3Val, psTdmaByte4Val); - break; - case 12: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); - break; - case 13: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, psTdmaByte4Val); - break; - case 14: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, psTdmaByte4Val); - break; - case 15: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); - break; - case 16: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); - break; - case 18: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 20: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x3f, 0x03, 0x11, 0x10); - break; - case 21: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); - break; - case 22: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10); - break; - case 23: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); - break; - case 24: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); - break; - case 25: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 26: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - break; - case 27: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); - break; - case 28: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); - break; - case 29: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); - break; - case 30: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); - break; - case 31: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); - break; - case 32: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11); - break; - case 33: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90); - break; - case 34: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); - break; - case 35: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); - break; - case 36: - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); - break; - case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving - /* here softap mode screen off will cost 70-80mA for phone */ - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); - break; - } - } - else - { - - // disable PS tdma - switch(type) - { - case 8: //PTA Control - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - break; - case 0: - default: //Software control, Antenna at BT side - halbtc8812a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - break; - } - } - rssiAdjustVal =0; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); - - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -BOOLEAN -halbtc8812a1ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); - - //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); - - //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - - //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); - - //halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else - { - if (bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - } - - bCommon = FALSE; - } - - return bCommon; -} - - -VOID -halbtc8812a1ant_TdmaDurationAdjustForAcl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - static BOOLEAN bPreWifiBusy=FALSE; - BOOLEAN bWifiBusy = FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); - - if(BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY == wifiStatus) - bWifiBusy = TRUE; - else - bWifiBusy = FALSE; - - if( (BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 3 && - pCoexDm->curPsTdma != 9 ) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if ( (pCoexSta->lowPriorityTx) > 1150 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { - if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if(result == 1) - { - if( (BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - else //no change - { - /* Bryant Modify - if(bWifiBusy != bPreWifiBusy) //if busy / idle change - { - bPreWifiBusy = bWifiBusy; - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, pCoexDm->curPsTdma); - } - */ - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 9 && - pCoexDm->curPsTdma != 11 ) - { - // recover to previous adjust type - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8812a1ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8812a1ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8812a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8812a1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8812a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - -VOID -halbtc8812a1ant_ActionWifiOnly( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); -} - -VOID -halbtc8812a1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - halbtc8812a1ant_ActionWifiOnly(pBtCoexist); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -//============================================= -// -// Software Coex Mechanism start -// -//============================================= - -// SCO only or SCO+PAN(HS) - -/* -VOID -halbtc8812a1ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); -} - - -VOID -halbtc8812a1ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8812a1ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8812a1ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8812a1ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(HS) only -VOID -halbtc8812a1ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(EDR)+A2DP -VOID -halbtc8812a1ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8812a1ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8812a1ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8812a1ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); -} - -*/ - -//============================================= -// -// Non-Software Coex Mechanism start -// -//============================================= -VOID -halbtc8812a1ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8812a1ant_ActionHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8812a1ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask)) - { - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - // SCO/HID/A2DP busy - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if ((pBtLinkInfo->bPanExist) || (bWifiBusy)) - { - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } -} - -VOID -halbtc8812a1ant_ActionBtScoHidOnlyBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // tdma and coex table - - if(pBtLinkInfo->bScoExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else //HID - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } -} - -VOID -halbtc8812a1ant_ActionWifiConnectedBtAclBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - u1Byte btRssiState; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - btRssiState = halbtc8812a1ant_BtRssiState(2, 28, 0); - - if ( (pCoexSta->lowPriorityRx >= 950) && (!pCoexSta->bUnderIps) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - if(pBtLinkInfo->bHidOnly) //HID - { - halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); - pCoexDm->bAutoTdmaAdjust = FALSE; - return; - } - else if(pBtLinkInfo->bA2dpOnly) //A2DP - { - if(BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - halbtc8812a1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = TRUE; - } - } - else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || - (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->bAutoTdmaAdjust = FALSE; - - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - //BT no-profile busy (0x9) - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - pCoexDm->bAutoTdmaAdjust = FALSE; - } -} - -VOID -halbtc8812a1ant_ActionWifiNotConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8812a1ant_ActionWifiNotConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8812a1ant_ActionWifiNotConnectedAssoAuth( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist) ) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else if (pBtLinkInfo->bPanExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 4); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 2); - } -} - -VOID -halbtc8812a1ant_ActionWifiConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //Bryant Add - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8812a1ant_ActionWifiConnectedSpecialPacket( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if(pBtLinkInfo->bPanExist) - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8812a1ant_ActionWifiConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiBusy=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - BOOLEAN bUnder4way=FALSE, bApEnable=FALSE; - u4Byte wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - if(bUnder4way) - { - halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - if(bScan || bLink || bRoam) - { - if(bScan) - halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist); - else - halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - // power save state - if(!bApEnable && BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) - { - if(pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP - { - if(!bWifiBusy) - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else //busy - { - if (pCoexSta->nScanAPNum >= BT_8812A_1ANT_WIFI_NOISY_THRESH) //no force LPS, no PS-TDMA, use pure TDMA - { - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - } - } - else if ((pCoexSta->bPanExist == FALSE) && (pCoexSta->bA2dpExist == FALSE) && (pCoexSta->bHidExist == FALSE)) - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - else - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(!bWifiBusy) - { - if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else - { - if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8812a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else if( (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8812a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else - { - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, NORMAL_EXEC, FALSE, FALSE); - if ( (pCoexSta->highPriorityTx) + (pCoexSta->highPriorityRx) <= 60 ) - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } -} - -VOID -halbtc8812a1ant_RunSwCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm=0; - - algorithm = halbtc8812a1ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - - if(halbtc8812a1ant_IsCommonAction(pBtCoexist)) - { - - } - else - { - switch(pCoexDm->curAlgorithm) - { - case BT_8812A_1ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n")); - //halbtc8812a1ant_ActionSco(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n")); - //halbtc8812a1ant_ActionHid(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n")); - //halbtc8812a1ant_ActionA2dp(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); - //halbtc8812a1ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n")); - //halbtc8812a1ant_ActionPanEdr(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n")); - //halbtc8812a1ant_ActionPanHs(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); - //halbtc8812a1ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); - //halbtc8812a1ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); - //halbtc8812a1ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8812A_1ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n")); - //halbtc8812a1ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n")); - //halbtc8812a1ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8812a1ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - BOOLEAN bIncreaseScanDevNum=FALSE; - BOOLEAN bBtCtrlAggBufSize=FALSE; - BOOLEAN bMiracastPlusBt=FALSE; - u1Byte aggBufSize=5; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0, wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bIncreaseScanDevNum = TRUE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - bMiracastPlusBt = TRUE; - } - else - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - bMiracastPlusBt = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - - if ( (pBtLinkInfo->bA2dpExist) && (pCoexSta->bC2hBtInquiryPage) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8812a1ant_ActionBtInquiry(pBtCoexist); - } - else - halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if ( (pBtLinkInfo->bBtLinkExist) && (bWifiConnected) ) - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 0, 1); - - if(pBtLinkInfo->bScoExist) - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, TRUE, FALSE, 0x5); - else - { - if (BTC_WIFI_BW_HT40==wifiBw) - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x10); - else - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - } - - halbtc8812a1ant_SwMechanism(pBtCoexist, TRUE); - halbtc8812a1ant_RunSwCoexistMechanism(pBtCoexist); //just print debug message - } - else - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x5); - - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - halbtc8812a1ant_RunSwCoexistMechanism(pBtCoexist); ////just print debug message - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], BT Is Inquirying \n") ); - halbtc8812a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8812a1ant_ActionHs(pBtCoexist); - return; - } - - - if(!bWifiConnected) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - if (bScan) - halbtc8812a1ant_ActionWifiNotConnectedScan(pBtCoexist); - else - halbtc8812a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else - halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist); - } - else // wifi LPS/Busy - { - halbtc8812a1ant_ActionWifiConnected(pBtCoexist); - } -} - -VOID -halbtc8812a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - // sw all off - halbtc8812a1ant_SwMechanism(pBtCoexist, FALSE); - - //halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - //halbtc8812a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - pCoexSta->popEventCnt = 0; -} - -VOID -halbtc8812a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp, - IN BOOLEAN bWifiOnly - ) -{ - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - //ant sw control to BT - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, TRUE, FALSE); - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - // PTA parameter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, 0x55555555); - - // coex parameters - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); - - // enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // enable PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); - - // bt clock related - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4); - u1Tmp |= BIT7; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4, u1Tmp); - - // bt clock related - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7); - u1Tmp |= BIT1; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp); -} - -//============================================================ -// work around function start with wa_halbtc8812a1ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8812a1ant_ -//============================================================ -VOID -EXhalbtc8812a1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8812a1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8812a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8812a1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly); - pBtCoexist->bStopCoexDm = FALSE; -} - -VOID -EXhalbtc8812a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - pBtCoexist->bStopCoexDm = FALSE; - - halbtc8812a1ant_InitCoexDm(pBtCoexist); - - halbtc8812a1ant_QueryBtInfo(pBtCoexist); -} - -VOID -EXhalbtc8812a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - if(pBtCoexist->bStopCoexDm) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8812a1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - if(!pBtCoexist->bManualControl) - { - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ - (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), - pBtCoexist->btInfo.aggBufSize); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \ - pCoexDm->errorCondition); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \ - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x778", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb3); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x900); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xcb3/0xcb7/0x900", \ - u1Tmp[0], u1Tmp[1], u4Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x40", \ - u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(hp rx[31:16]/tx[15:0])", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(lp rx[31:16]/tx[15:0])", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - - -VOID -EXhalbtc8812a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp=0; - - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - - halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8812a1ant_InitCoexDm(pBtCoexist); - halbtc8812a1ant_QueryBtInfo(pBtCoexist); - - pCoexSta->bUnderIps = FALSE; - } -} - -VOID -EXhalbtc8812a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8812a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - u1Byte u1Tmpa, u1Tmpb; - u4Byte u4Tmp; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm ) - return; - - if(BTC_SCAN_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } - - if(pBtCoexist->btInfo.bBtDisabled) - return; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - halbtc8812a1ant_QueryBtInfo(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8812a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8812a1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_SCAN_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8812a1ant_ActionWifiNotConnectedScan(pBtCoexist); - } - else // wifi is connected - { - halbtc8812a1ant_ActionWifiConnectedScan(pBtCoexist); - } - } - else if(BTC_SCAN_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8812a1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8812a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_ASSOCIATE_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - pCoexDm->nArpCnt = 0; - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - //pCoexDm->nArpCnt = 0; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8812a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8812a1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_ASSOCIATE_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - halbtc8812a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8812a1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8812a1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -//to check registers... -VOID -EXhalbtc8812a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte dataLen=5; - u1Byte buf[6] = {0}; - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - BOOLEAN bWifiUnderBMode = FALSE; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FORCE_EXEC, FALSE, FALSE); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); -#if 0 - //Set CCK Tx/Rx high Pri except 11b mode - if (bWifiUnderBMode) - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x00); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x00); //CCK Rx - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x10); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x10); //CCK Rx - } -#endif - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - pCoexDm->nArpCnt = 0; - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cd, 0x0); //CCK Tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cf, 0x0); //CCK Rx - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - //H2C_Parameter[0] = 0x1; - H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - buf[0] = dataLen; - buf[1] = 0x5; // OP_Code - buf[2] = 0x3; // OP_Code_Length - buf[3] = H2C_Parameter[0]; // OP_Code_Content - buf[4] = H2C_Parameter[1]; - buf[5] = H2C_Parameter[2]; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); -} - -VOID -EXhalbtc8812a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - if(BTC_PACKET_ARP == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n")); - - pCoexDm->nArpCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); - - if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type)); - } - - pCoexSta->specialPktPeriodCnt = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8812a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8812a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8812a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8812a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8812a1ant_ActionHs(pBtCoexist); - return; - } - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - ( (BTC_PACKET_ARP == type ) && (pCoexSta->bWiFiIsHighPriTask) ) ) - { - halbtc8812a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - } -} - -VOID -EXhalbtc8812a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bBtBusy=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8812A_1ANT_MAX) - rspSource = BT_INFO_SRC_8812A_1ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8812A_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btRetryCnt >= 1) - pCoexSta->popEventCnt++; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtPage = TRUE; - else - pCoexSta->bC2hBtPage = FALSE; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2-90; - //pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if(!pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if(pCoexSta->btInfoExt & BIT1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if(pCoexSta->btInfoExt & BIT3) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8812A_1ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8812a1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8812A_1ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8812A_1ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8812A_1ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8812A_1ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8812A_1ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8812A_1ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - } - - halbtc8812a1ant_UpdateBtLinkInfo(pBtCoexist); - - btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) - - if(!(btInfo&BT_INFO_8812A_1ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8812A_1ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8812A_1ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8812A_1ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8812A_1ANT_B_ACL_BUSY) - { - if(BT_8812A_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8812A_1ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8812A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - bBtBusy = TRUE; - else - bBtBusy = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - halbtc8812a1ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8812a1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp; - u1Byte u1Tmpa,u1Tmpb, u1Tmpc; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF Status notify\n")); - - if(BTC_RF_ON == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned ON!!\n")); - pBtCoexist->bStopCoexDm = FALSE; - } - else if(BTC_RF_OFF == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RF is turned OFF!!\n")); - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - - halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - pBtCoexist->bStopCoexDm = TRUE; - } -} - -VOID -EXhalbtc8812a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - - halbtc8812a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - pBtCoexist->bStopCoexDm = TRUE; -} - -VOID -EXhalbtc8812a1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8812a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FORCE_EXEC, FALSE, TRUE); - halbtc8812a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - - pBtCoexist->bStopCoexDm = TRUE; - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - pBtCoexist->bStopCoexDm = FALSE; - halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8812a1ant_InitCoexDm(pBtCoexist); - halbtc8812a1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8812a1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], *****************Coex DM Reset*****************\n")); - - halbtc8812a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8812a1ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8812a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8812a1Ant, GLCoexVer8812a1Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8812A_1ANT == 0) - halbtc8812a1ant_QueryBtInfo(pBtCoexist); - halbtc8812a1ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8812a1ant_MonitorBtCtr(pBtCoexist); - halbtc8812a1ant_MonitorWiFiCtr(pBtCoexist); - - if( halbtc8812a1ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust ) - { - halbtc8812a1ant_RunCoexistMechanism(pBtCoexist); - } - - pCoexSta->specialPktPeriodCnt++; -#endif -} - -VOID -EXhalbtc8812a1ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ) -{ - switch(opCode) - { - case BTC_DBG_SET_COEX_NORMAL: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to Normal\n")); - pBtCoexist->bManualControl = FALSE; - halbtc8812a1ant_InitCoexDm(pBtCoexist); - break; - case BTC_DBG_SET_COEX_WIFI_ONLY: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to Wifi Only\n")); - pBtCoexist->bManualControl = TRUE; - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); - break; - case BTC_DBG_SET_COEX_BT_ONLY: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set CoexMode to BT only\n")); - pBtCoexist->bManualControl = TRUE; - halbtc8812a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - break; - case BTC_DBG_SET_COEX_DEC_BT_PWR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power\n")); - { - u1Byte dataLen=4; - u1Byte buf[6] = {0}; - u1Byte decBtPwr=0, pwrLevel=0; - if(opLen == 2) - { - decBtPwr = pData[0]; - pwrLevel = pData[1]; - - buf[0] = dataLen; - buf[1] = 0x3; // OP_Code - buf[2] = 0x2; // OP_Code_Length - - buf[3] = decBtPwr; // OP_Code_Content - buf[4] = pwrLevel; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power=%d, pwrLevel=%d\n", decBtPwr, pwrLevel)); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - - case BTC_DBG_SET_COEX_BT_AFH_MAP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map\n")); - { - u1Byte dataLen=5; - u1Byte buf[6] = {0}; - if(opLen == 3) - { - buf[0] = dataLen; - buf[1] = 0x5; // OP_Code - buf[2] = 0x3; // OP_Code_Length - - buf[3] = pData[0]; // OP_Code_Content - buf[4] = pData[1]; - buf[5] = pData[2]; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map = %02x %02x %02x\n", - pData[0], pData[1], pData[2])); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - - case BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active\n")); - { - u1Byte dataLen=3; - u1Byte buf[6] = {0}; - if(opLen == 1) - { - buf[0] = dataLen; - buf[1] = 0x1; // OP_Code - buf[2] = 0x1; // OP_Code_Length - - buf[3] = pData[0]; // OP_Code_Content - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active = 0x%x\n", - pData[0])); - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - default: - break; - } -} - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.h deleted file mode 100644 index 3e2a5d324..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a1Ant.h +++ /dev/null @@ -1,259 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8812A 1ANT BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8812A_1ANT 1 - -#define BT_INFO_8812A_1ANT_B_FTP BIT7 -#define BT_INFO_8812A_1ANT_B_A2DP BIT6 -#define BT_INFO_8812A_1ANT_B_HID BIT5 -#define BT_INFO_8812A_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8812A_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8812A_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8812A_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8812A_1ANT_B_CONNECTION BIT0 - -#define BT_INFO_8812A_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8812A_1ANT 2 - -#define BT_8812A_1ANT_WIFI_NOISY_THRESH 30 //max: 255 - -typedef enum _BT_INFO_SRC_8812A_1ANT{ - BT_INFO_SRC_8812A_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8812A_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8812A_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8812A_1ANT_MAX -}BT_INFO_SRC_8812A_1ANT,*PBT_INFO_SRC_8812A_1ANT; - -typedef enum _BT_8812A_1ANT_BT_STATUS{ - BT_8812A_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8812A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8812A_1ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8812A_1ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8812A_1ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8812A_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8812A_1ANT_BT_STATUS_MAX -}BT_8812A_1ANT_BT_STATUS,*PBT_8812A_1ANT_BT_STATUS; - -typedef enum _BT_8812A_1ANT_WIFI_STATUS{ - BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8812A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, - BT_8812A_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, - BT_8812A_1ANT_WIFI_STATUS_MAX -}BT_8812A_1ANT_WIFI_STATUS,*PBT_8812A_1ANT_WIFI_STATUS; - -typedef enum _BT_8812A_1ANT_COEX_ALGO{ - BT_8812A_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8812A_1ANT_COEX_ALGO_SCO = 0x1, - BT_8812A_1ANT_COEX_ALGO_HID = 0x2, - BT_8812A_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8812A_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8812A_1ANT_COEX_ALGO_PANEDR = 0x5, - BT_8812A_1ANT_COEX_ALGO_PANHS = 0x6, - BT_8812A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8812A_1ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8812A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8812A_1ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8812A_1ANT_COEX_ALGO_MAX = 0xb, -}BT_8812A_1ANT_COEX_ALGO,*PBT_8812A_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8812A_1ANT{ - // hw setting - u1Byte preAntPosType; - u1Byte curAntPosType; - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; - u4Byte nArpCnt; - - u1Byte errorCondition; -} COEX_DM_8812A_1ANT, *PCOEX_DM_8812A_1ANT; - -typedef struct _COEX_STA_8812A_1ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte specialPktPeriodCnt; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - s1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8812A_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8812A_1ANT_MAX]; - u4Byte btInfoQueryCnt; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtPage; //Add for win8.1 page out issue - BOOLEAN bWiFiIsHighPriTask; //Add for win8.1 page out issue - u1Byte btRetryCnt; - u1Byte btInfoExt; - u4Byte popEventCnt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - BOOLEAN bCCKLock; - BOOLEAN bPreCCKLock; - u1Byte nCoexTableType; - - BOOLEAN bForceLpsOn; -}COEX_STA_8812A_1ANT, *PCOEX_STA_8812A_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8812a1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8812a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8812a1ant_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8812a1ant_CoexDmReset( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a1ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ); -VOID -EXhalbtc8812a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.c deleted file mode 100644 index d8f1b5720..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.c +++ /dev/null @@ -1,5435 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8812A Co-exist mechanism -// -// History -// 2012/08/22 Cosa first check in. -// 2012/11/14 Cosa Revise for 8812A 2Ant out sourcing. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8812a2Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8812A_2ANT GLCoexDm8812a2Ant; -static PCOEX_DM_8812A_2ANT pCoexDm=&GLCoexDm8812a2Ant; -static COEX_STA_8812A_2ANT GLCoexSta8812a2Ant; -static PCOEX_STA_8812A_2ANT pCoexSta=&GLCoexSta8812a2Ant; - -const char *const GLBtInfoSrc8812a2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8812a2Ant=20150408; -u4Byte GLCoexVer8812a2Ant=0x39; -//improve 8761ATV D-cut BT off/on fail issue -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8812a2ant_ -//============================================================ -u1Byte -halbtc8812a2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8812a2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8812a2ant_SetEnablePTA( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnablePTA - ) -{ - if(bEnablePTA) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PTA is enable!\n")); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x20); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PTA is disable!\n")); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x00); - - } -} - -VOID -halbtc8812a2ant_EnablePTA( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE (COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Enable PTA %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurEnablePTA = bEnable; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bPreEnablePTA = %d, bCurEnablePTA = %d!!\n", - pCoexDm->bPreEnablePTA, pCoexDm->bCurEnablePTA)); - - if(pCoexDm->bPreEnablePTA == pCoexDm->bCurEnablePTA) - return; - } - halbtc8812a2ant_SetEnablePTA(pBtCoexist, bEnable); - - - pCoexDm->bPreEnablePTA = pCoexDm->bCurEnablePTA; -} - -VOID -halbtc8812a2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - // only 8812a need to consider if core stack is installed. - if(!pStackInfo->hciVersion) - { - bBtActive = FALSE; - } -/* - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } -*/ - - if((pCoexSta->prebtInfoC2hCnt_BT_RSP == pCoexSta->btInfoC2hCnt[1]) && - (pCoexSta->prebtInfoC2hCnt_BT_SEND == pCoexSta->btInfoC2hCnt[2])) - { - bBtActive = FALSE; - } - - pCoexSta->prebtInfoC2hCnt_BT_RSP = pCoexSta->btInfoC2hCnt[1]; - pCoexSta->prebtInfoC2hCnt_BT_SEND = pCoexSta->btInfoC2hCnt[2]; - - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt is detected as disabled %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(pCoexSta->preBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (pCoexSta->preBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - pCoexSta->preBtDisabled = bBtDisabled; - - if(!bBtDisabled) - { - // enable PTA -// halbtc8812a2ant_EnablePTA(pBtCoexist,FORCE_EXEC, TRUE); - } - else - { - // disable PTA -// halbtc8812a2ant_EnablePTA(pBtCoexist,FORCE_EXEC, FALSE); - } - } -} - -u4Byte -halbtc8812a2ant_DecideRaMask( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte raMaskType - ) -{ - u4Byte disRaMask=0x0; - - switch(raMaskType) - { - case 0: // normal mode - disRaMask = 0x0; - break; - case 1: // disable cck 1/2 - disRaMask = 0x00000003; - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - disRaMask = 0x0001f1f7; - break; - default: - break; - } - - return disRaMask; -} - -VOID -halbtc8812a2ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8812a2ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8812a2ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8812a2ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8812a2ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - u4Byte disRaMask=0x0; - - pCoexDm->curRaMaskType = raMaskType; - disRaMask = halbtc8812a2ant_DecideRaMask(pBtCoexist, raMaskType); - halbtc8812a2ant_UpdateRaMask(pBtCoexist, bForceExec, disRaMask); - - halbtc8812a2ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8812a2ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8812a2ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8812a2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8812a2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8812a2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte dataLen=3; - u1Byte buf[5] = {0}; -//8812a watch btifo to check BT enable/disable -// if(!pBtCoexist->btInfo.bBtDisabled) - { - if(!pCoexSta->btInfoQueryCnt || - (pCoexSta->btInfoC2hCnt[BT_INFO_SRC_8812A_2ANT_BT_RSP]-pCoexSta->btInfoQueryCnt)>2) - { - buf[0] = dataLen; - buf[1] = 0x1; // polling enable, 1=enable, 0=disable - buf[2] = 0x2; // polling time in seconds - buf[3] = 0x1; // auto report enable, 1=enable, 0=disable - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_INFO, (PVOID)&buf[0]); - } - } - pCoexSta->btInfoQueryCnt++; -} - -BOOLEAN -halbtc8812a2ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - } - - return FALSE; -} - -VOID -halbtc8812a2ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - -#if 1//(BT_AUTO_REPORT_ONLY_8812A_2ANT == 1) // profile from bt patch - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - pBtLinkInfo->bAclBusy = pCoexSta->bAclBusy; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } -#else // profile from bt stack - pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist; - pBtLinkInfo->bScoExist = pStackInfo->bScoExist; - pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist; - pBtLinkInfo->bPanExist = pStackInfo->bPanExist; - pBtLinkInfo->bHidExist = pStackInfo->bHidExist; - - //for win-8 stack HID report error - if(!pStackInfo->bHidExist) - pStackInfo->bHidExist = pCoexSta->bHidExist; //sync BTInfo with BT firmware and stack - // when stack HID report error, here we use the info from bt fw. - if(!pStackInfo->bBtLinkExist) - pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist; -#endif - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8812a2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8812A_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 0) - { - if(pBtLinkInfo->bAclBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ACL Busy only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR; - } - } - else if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8812A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8812a2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8812a2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte decBtPwrLvl - ) -{ - u1Byte dataLen=4; - u1Byte buf[6] = {0}; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d\n", - decBtPwrLvl)); - - buf[0] = dataLen; - buf[1] = 0x3; // OP_Code - buf[2] = 0x2; // OP_Code_Length - if(decBtPwrLvl) - buf[3] = 0x1; // OP_Code_Content - else - buf[3] = 0x0; - buf[4] = decBtPwrLvl;// pwrLevel - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); -} - -VOID -halbtc8812a2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte decBtPwrLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n", - (bForceExec? "force to":""), decBtPwrLvl)); - pCoexDm->curBtDecPwrLvl = decBtPwrLvl; - - if(!bForceExec) - { - if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) - return; - } - halbtc8812a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl); - - pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; -} - -VOID -halbtc8812a2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8812a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8812a2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8812a2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8812a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8812a2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte tmpU1; - - tmpU1 = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4fd); - tmpU1 |= BIT0; - if(bLowPenaltyRa) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set low penalty!!\n")); - tmpU1 &= ~BIT2; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Tx rate adaptive, set normal!!\n")); - tmpU1 |= BIT2; - } - - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4fd, tmpU1); -} - -VOID -halbtc8812a2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8812a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8812a2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc5b, 0x3e, val); -} - -VOID -halbtc8812a2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8812a2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8812a2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8812a2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8812a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8812a2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x1); - } -} - -VOID -halbtc8812a2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8812a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8812a2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28F4B); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x10AB2); - rssiAdjustVal = 8; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x2884B); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x104B2); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - -VOID -halbtc8812a2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8812a2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8812a2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8812a2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8812a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8812a2ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - switch(type) - { - case 0: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 1: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5ffb5ffb, 0xffffff, 0x3); - break; - case 3: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 4: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0xdfffdfff, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 5: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x5ddd5ddd, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 6: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 7: - if(pCoexSta->nScanAPNum <= 5) - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xfafafafa, 0xffffff, 0x3); - else - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 8: - halbtc8812a2ant_CoexTable(pBtCoexist, bForceExec, 0x5f5f5f5f, 0x5a5a5a5a, 0xffffff, 0x3); - break; - - default: - break; - } -} - -VOID -halbtc8812a2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte dataLen=3; - u1Byte buf[5] = {0}; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Ignore Wlan_Act\n", - (bEnable? "Enable":"Disable"))); - - buf[0] = dataLen; - buf[1] = 0x1; // OP_Code - buf[2] = 0x1; // OP_Code_Length - if(bEnable) - buf[3] = 0x1; // OP_Code_Content - else - buf[3] = 0x0; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); -} - -VOID -halbtc8812a2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8812a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8812a2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - -VOID -halbtc8812a2ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8812a2ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8812a2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8812a2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - /* - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - */ - - halbtc8812a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - //halbtc8812a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8812a2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - //halbtc8812a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - halbtc8812a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - halbtc8812a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8812a2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - u1Byte u1Tmp=0; - - if(bInitHwCfg) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x900, 0x00000400); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76d, 0x1); - } - else if(bWifiOff) - { - - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_WIFI_AT_CPL_MAIN: - break; - case BTC_ANT_WIFI_AT_CPL_AUX: - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - u1Tmp &= ~BIT3; - u1Tmp |= BIT2; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb7, u1Tmp); - break; - default: - break; - } -} - -VOID -halbtc8812a2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - s1Byte nWiFiDurationAdjust = 0x0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if(!bForceExec) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], bPrePsTdmaOn = %d, bCurPsTdmaOn = %d!!\n", - pCoexDm->bPrePsTdmaOn, pCoexDm->bCurPsTdmaOn)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], prePsTdma = %d, curPsTdma = %d!!\n", - pCoexDm->prePsTdma, pCoexDm->curPsTdma)); - - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - - if (pCoexSta->nScanAPNum >= 40) - nWiFiDurationAdjust = -15; - else if (pCoexSta->nScanAPNum >= 20) - nWiFiDurationAdjust = -10; - -/* - if (!pCoexSta->bForceLpsOn) //only for A2DP-only case 1/2/9/11 while wifi noisy threshold > 30 - { - psTdmaByte0Val = 0x61; //no null-pkt - psTdmaByte3Val = 0x11; // no tx-pause at BT-slot - psTdmaByte4Val = 0x10; // 0x778 = d/1 toggle - } - - - if ( (type == 3) || (type == 13) || (type == 14) ) - { - psTdmaByte4Val = psTdmaByte4Val & 0xbf; //no dynamic slot for multi-profile - - if (!bWifiBusy) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - } - - if (pBtLinkInfo->bSlaveRole == TRUE) - psTdmaByte4Val = psTdmaByte4Val | 0x1; //0x778 = 0x1 at wifi slot (no blocking BT Low-Pri pkts) - -*/ - if(bTurnOn) - { - switch(type) - { - case 1: - default: //d1,wb - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x11, 0x10); - break; - case 2: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x11, 0x10); - break; - case 3: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x11, 0x10); - break; - case 4: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x11, 0x10); - break; - case 5: //d1,pb,TXpause - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x63, 0x3c, 0x03, 0x90, 0x10); - break; - case 6: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x63, 0x32, 0x03, 0x90, 0x10); - break; - case 7: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x63, 0x28, 0x03, 0x90, 0x10); - break; - case 8: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x63, 0x1e, 0x03, 0x90, 0x10); - break; - case 9: //d1,bb - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x31, 0x10); - break; - case 10: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x31, 0x10); - break; - case 11: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x31, 0x10); - break; - case 12: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x31, 0x10); - break; - case 13: //d1,bb,TXpause - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x30, 0x10); - break; - case 14: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x32, 0x03, 0x30, 0x10); - break; - case 15: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x28, 0x03, 0x30, 0x10); - break; - case 16: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0x30, 0x10); - break; - case 17: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11); - break; - case 18: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x70, 0x90); - break; - case 22: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x61, 0x1a, 0x1a, 0x21, 0x10); - break; - case 23: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x03, 0x31, 0x10); - break; - - case 71: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - break; - - // following cases is for wifi rssi low, started from 81 - case 80: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3c, 0x3, 0x90, 0x50); - break; - case 81: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x3a+nWiFiDurationAdjust, 0x3, 0x90, 0x50); - break; - case 82: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x30+nWiFiDurationAdjust, 0x03, 0x90, 0x50); - break; - case 83: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x21, 0x03, 0x90, 0x50); - break; - case 84: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x15, 0x3, 0x90, 0x50); - break; - case 85: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x1d, 0x1d, 0x80, 0x50); - break; - case 86: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x53, 0x15, 0x15, 0x80, 0x50); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 0: //ANT2PTA, 0x778=0x1 - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - break; - case 1: //ANT2BT, 0x778=3 - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - delay_ms(5); - halbtc8812a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_CPL_AUX, FALSE, FALSE); - break; - default: - halbtc8812a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8812a2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8812a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0); - - halbtc8812a2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8812a2ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8812a2ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8812a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8812a2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8812a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - -VOID -halbtc8812a2ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -BOOLEAN -halbtc8812a2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - - if(pCoexSta->bC2hBtInquiryPage) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8812a2ant_ActionBtInquiry(pBtCoexist); - return TRUE; - } - - if(pBtLinkInfo->bScoExist || pBtLinkInfo->bHidExist) - { - halbtc8812a2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 0, 0, 0); - } - else - { - halbtc8812a2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - } - - if(!bWifiConnected) - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n")); - - if( (BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) || - (BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else if(BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) - { - if(bBtHsOn) - return FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - bCommon = FALSE; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 17); - - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - bCommon = TRUE; - } - } - } - - return bCommon; -} - -VOID -halbtc8812a2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -//================== -// pstdma for wifi rssi low -//================== -VOID -halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow( - IN PBTC_COEXIST pBtCoexist//, - //IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow()\n")); -#if 0 - if( (BT_8812A_2ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8812A_2ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8812A_2ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 81 && - pCoexDm->curPsTdma != 82 && - pCoexDm->curPsTdma != 83 && - pCoexDm->curPsTdma != 84 ) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } -#endif - pCoexDm->bAutoTdmaAdjust = FALSE; - - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - - if(!pCoexDm->bAutoTdmaAdjustLowRssi) - { - pCoexDm->bAutoTdmaAdjustLowRssi = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjustForWifiRssiLow()!!\n")); - - if(BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(btInfoExt)) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 -// retryCount = pCoexSta->btRetryCnt; -// btInfoExt = pCoexSta->btInfoExt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if ( (pCoexSta->lowPriorityTx) > 1050 || (pCoexSta->lowPriorityRx) > 1250 ) - retryCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { -/* - if( (BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) ) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84); - pCoexDm->psTdmaDuAdjType = 84; - } -*/ - if(pCoexDm->curPsTdma == 80) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - else if(pCoexDm->curPsTdma == 81) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - else if(pCoexDm->curPsTdma == 82) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else if(pCoexDm->curPsTdma == 83) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 84); - pCoexDm->psTdmaDuAdjType = 84; - } - } - else if(result == 1) - { -/* - if( (BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 81) ||(pCoexDm->curPsTdma == 82)) ) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } -*/ - if(pCoexDm->curPsTdma == 84) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 83); - pCoexDm->psTdmaDuAdjType = 83; - } - else if(pCoexDm->curPsTdma == 83) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 82); - pCoexDm->psTdmaDuAdjType = 82; - } - else if(pCoexDm->curPsTdma == 82) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81); - pCoexDm->psTdmaDuAdjType = 81; - } - else if((pCoexDm->curPsTdma == 81)&&((pCoexSta->nScanAPNum <= 5))) - { - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 81); - pCoexDm->psTdmaDuAdjType = 81; - } - } - - if( pCoexDm->curPsTdma != 80 && - pCoexDm->curPsTdma != 81 && - pCoexDm->curPsTdma != 82 && - pCoexDm->curPsTdma != 83 && - pCoexDm->curPsTdma != 84 ) - { - // recover to previous adjust type - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8812a2ant_GetBtRssiThreshold( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte pThres0, - IN pu1Byte pThres1 - ) -{ - u1Byte antType, btThreshold=0; - -// pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_ANT_TYPE, &antType); - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - antType = pBoardInfo->antType; - - - switch(antType) - { - case BTC_ANT_TYPE_0: - *pThres0 = 100; - *pThres1 = 100; - break; - case BTC_ANT_TYPE_1: - *pThres0 = 34; - *pThres1 = 42; - break; - case BTC_ANT_TYPE_2: - *pThres0 = 34; - *pThres1 = 42; - break; - case BTC_ANT_TYPE_3: - *pThres0 = 34; - *pThres1 = 42; - break; - case BTC_ANT_TYPE_4: - *pThres0 = 34; - *pThres1 = 42; - break; - default: - break; - } -} - - - -VOID -halbtc8812a2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - - // pstdma - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - else - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x6); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x6); - } - } -} - -VOID -halbtc8812a2ant_ActionScoHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - - // pstdma - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - else - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x6); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x6); - } - } -} - -VOID -halbtc8812a2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte anttype=0; - BOOLEAN bApEnable=FALSE; - - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - anttype = pBoardInfo->antType; - - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); -// btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - // power save state & pstdma & coex table - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 9); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8812a2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte anttype=0; - BOOLEAN bApEnable=FALSE; - - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - anttype = pBoardInfo->antType; - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); -// btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - -// anttype = 4; - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - - if((pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - - // power save state & pstdma & coex table -/* - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } -*/ - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); //shielding room - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // decrease BT power -/* - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A) // BT HIGH RSSI & shielding room - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8812a2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 2); - else - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x6); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x6); - } - } -} - -VOID -halbtc8812a2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - else - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 85); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(HS) only -VOID -halbtc8812a2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - - // pstdma - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8812a2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - else - { - pCoexDm->bAutoTdmaAdjust = FALSE; - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); - } - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8812a2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); -// btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - else - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 85); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8812a2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); -// btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - if((bApEnable == TRUE) || (BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - else - { - pCoexDm->bAutoTdmaAdjust = FALSE; - halbtc8812a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 86); - } - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8812a2ant_ActionHidA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0; - - halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); - btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); -// btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - // power save state - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 3); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - else - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - // pstdma - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - else - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else if(BTC_RSSI_LOW(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState))) - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - else - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8812a2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH, btRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiBw; - u1Byte btThresh0=0, btThresh1=0, anttype=0; - BOOLEAN bApEnable=FALSE; - - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - anttype = pBoardInfo->antType; - - -// halbtc8812a2ant_GetBtRssiThreshold(pBtCoexist, &btThresh0, &btThresh1); -// btRssiState = halbtc8812a2ant_BtRssiState(3, btThresh0, btThresh1); - - wifiRssiState = halbtc8812a2ant_WifiRssiState(pBtCoexist, 0, 2, 34, 0); - btRssiState = halbtc8812a2ant_BtRssiState(3, 34, 42); - - if(anttype == 0)//ANTTYPE = 0 92E 2ant with SPDT - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 1) //92E 2ant with coupler and bad ant. isolation, 92E 3ant with bad ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 2)//ANTTYPE = 2, 92E 2ant with coupler and normal/good ant. isolation, 92E 3ant with normal ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, TRUE, 83); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - } - } - else if(anttype == 3) //ANTTYPE = 3, 92E 3ant with good ant. isolation - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - } - else //WIFI RSSI || BT RSSI == low - { - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8812a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - } - else //ANTTYPE = 4 for test - { - // power save state & pstdma & coex table - if(BTC_RSSI_HIGH(wifiRssiState) && (!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & shielding room - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else if (BTC_RSSI_HIGH(wifiRssiState)&&(!BTC_RSSI_LOW(btRssiState)) && (pCoexSta->nScanAPNum > NOISY_AP_NUM_THRESH_8812A)) - { //WIFI RSSI = high & BT RSSI = high & noisy enviroment - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //WIFI RSSI || BT RSSI == low - { - halbtc8812a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - halbtc8812a2ant_TdmaDurationAdjustForWifiRssiLow(pBtCoexist); - halbtc8812a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - } - - // decrease BT power - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - -/* - // decrease BT power - if(BTC_RSSI_LOW(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if (pCoexSta->nScanAPNum < NOISY_AP_NUM_THRESH_8812A) // BT HIGH RSSI & shielding room - halbtc8812a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); -*/ - // limited Rx - halbtc8812a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - // fw dac swing level - halbtc8812a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if(BTC_RSSI_HIGH(wifiRssiState)) - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8812a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8812a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8812a2ant_CoexUnder5G( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8812a2ant_CoexAllOff(pBtCoexist); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Under 5G, force set BT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE); -} -//==================================================== -VOID -halbtc8812a2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - if(bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n")); - halbtc8812a2ant_CoexUnder5G(pBtCoexist); - return; - } - - - algorithm = halbtc8812a2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8812A_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8812a2ant_ActionBtInquiry(pBtCoexist); - return; - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8812a2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->bAutoTdmaAdjustLowRssi = FALSE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8812A_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8812a2ant_ActionSco(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_SCO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO+HID.\n")); - halbtc8812a2ant_ActionScoHid(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8812a2ant_ActionHid(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8812a2ant_ActionA2dp(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8812a2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8812a2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8812a2ant_ActionPanHs(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8812a2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8812a2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8812a2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN(HS).\n")); - halbtc8812a2ant_ActionHidA2dpPanHs(pBtCoexist); - break; - case BT_8812A_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8812a2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8812a2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } - -} - -VOID -halbtc8812a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp - ) -{ - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - if(bBackUp) - { - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - - //ant sw control to BT - halbtc8812a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_CPL_AUX, TRUE, FALSE); - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - // PTA parameter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, 0xffff); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, 0x55555555); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, 0x55555555); - - // coex parameters - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x1); - - // enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - // disable PTA to avoid BT insn't on - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x40, 0x00); - - // bt clock related - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x4); - u1Tmp |= BIT7; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x4, u1Tmp); - - // bt clock related - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x7); - u1Tmp |= BIT1; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x7, u1Tmp); -} - -//============================================================ -// work around function start with wa_halbtc8812a2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8812a2ant_ -//============================================================ -VOID -EXhalbtc8812a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8812a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8812a2ant_InitHwConfig(pBtCoexist, TRUE); -} - -VOID -EXhalbtc8812a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8812a2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8812a2ant_BTOffOnNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte BTstatus - ) -{ - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BToff/on notify\n")); - DBG_871X("%s, BTstatus:%d", __func__, BTstatus); - - if(BTC_BT_OFF == BTstatus) - { - //PTA off - pBtCoexist->btInfo.bBtDisabled = TRUE; - halbtc8812a2ant_EnablePTA(pBtCoexist,FORCE_EXEC, FALSE); - - } - else - { - //PTA on - pBtCoexist->btInfo.bBtDisabled = FALSE; - halbtc8812a2ant_EnablePTA(pBtCoexist,FORCE_EXEC, TRUE); - } - -} - - - -VOID -EXhalbtc8812a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u2Byte u2Tmp[4]; - u4Byte u4Tmp[4]; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Antenna type:", \ - pBoardInfo->antType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8812a2Ant, GLCoexVer8812a2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8812a2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d/%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust, pCoexDm->bAutoTdmaAdjustLowRssi); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \ - pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \ - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x ", "0x778 (W_Act)/ 0x6cc (CoTab Sel)", \ - u1Tmp[0], u1Tmp[1]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x8db); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xc5b); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x8db(ADC)/0xc5b[29:25](DAC)", \ - ((u1Tmp[0]&0x60)>>5), ((u1Tmp[1]&0x3e)>>1)); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb3); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xcb7); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xcb3/ 0xcb7", \ - u1Tmp[0], u1Tmp[1]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x974); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/ 0x4c[24:23]/ 0x974", \ - u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u4Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa0a); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(DIG)/0xa0a(CCK-TH)", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf48); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xf48/ 0xa5b (FA cnt-- OFDM : CCK)", \ - u4Tmp[0], (u1Tmp[0]<<8) + u1Tmp[1] ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8812A_2ANT == 1) - halbtc8812a2ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8812a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnder5G=FALSE; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8812a2ant_CoexAllOff(pBtCoexist); - halbtc8812a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_CPL_AUX, FALSE, TRUE); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS notify, force set BT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - if(!bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS notify, force set BT NOT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } -} - -VOID -EXhalbtc8812a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8812a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &pCoexSta->nScanAPNum); - } -} - -VOID -EXhalbtc8812a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8812a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte dataLen=5; - u1Byte buf[6] = {0}; - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - buf[0] = dataLen; - buf[1] = 0x5; // OP_Code - buf[2] = 0x3; // OP_Code_Length - buf[3] = H2C_Parameter[0]; // OP_Code_Content - buf[4] = H2C_Parameter[1]; - buf[5] = H2C_Parameter[2]; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); -} - -VOID -EXhalbtc8812a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } - -} - -VOID -EXhalbtc8812a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE, bWifiUnder5G=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8812A_2ANT_MAX) - rspSource = BT_INFO_SRC_8812A_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8812A_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if( (pCoexSta->btInfoExt&BIT3) && !bWifiUnder5G) - { - // BT already ignored WlanAct - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - if(!pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - - if(pCoexSta->bUnderIps) - { - // work around for 8812a combo hw bug => when IPS, wlanAct is always high. - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS, set BT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - } - } - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8812A_2ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8812A_2ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - pCoexSta->bAclBusy = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8812A_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8812A_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8812A_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8812A_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - if(btInfo & BT_INFO_8812A_2ANT_B_ACL_BUSY) - pCoexSta->bAclBusy = TRUE; - else - pCoexSta->bAclBusy = FALSE; - - } - - halbtc8812a2ant_UpdateBtLinkInfo(pBtCoexist); - - if(!(btInfo&BT_INFO_8812A_2ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8812A_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8812A_2ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8812A_2ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8812A_2ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8812A_2ANT_B_ACL_BUSY) - { - pCoexDm->btStatus = BT_8812A_2ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8812A_2ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8812A_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8812A_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8812A_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bBtBusy = TRUE; - if(!bWifiUnder5G) - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8812a2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8812a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte u1Tmp=0; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8812a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_CPL_AUX, FALSE, TRUE); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify, force set BT to ignore Wlan active!!\n")); - halbtc8812a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - // 0x522=0xff, pause tx - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x522, 0xff); - // 0x40[7:6]=2'b01, modify BT mode. - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0xc0, 0x2); - //PTA off. - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x0); - -} - -VOID -EXhalbtc8812a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8812a2Ant, GLCoexVer8812a2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8812A_2ANT == 0) - halbtc8812a2ant_QueryBtInfo(pBtCoexist); - halbtc8812a2ant_MonitorBtCtr(pBtCoexist); -// halbtc8812a2ant_MonitorBtEnableDisable(pBtCoexist); -#else - if( halbtc8812a2ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust || - pCoexDm->bAutoTdmaAdjustLowRssi) - { - halbtc8812a2ant_RunCoexistMechanism(pBtCoexist); - } -#endif -} - -VOID -EXhalbtc8812a2ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ) -{ - switch(opCode) - { - case BTC_DBG_SET_COEX_DEC_BT_PWR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power\n")); - { - u1Byte dataLen=4; - u1Byte buf[6] = {0}; - u1Byte decBtPwr=0, pwrLevel=0; - if(opLen == 2) - { - decBtPwr = pData[0]; - pwrLevel = pData[1]; - - buf[0] = dataLen; - buf[1] = 0x3; // OP_Code - buf[2] = 0x2; // OP_Code_Length - - buf[3] = decBtPwr; // OP_Code_Content - buf[4] = pwrLevel; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set Dec BT power=%d, pwrLevel=%d\n", decBtPwr, pwrLevel)); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - - case BTC_DBG_SET_COEX_BT_AFH_MAP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map\n")); - { - u1Byte dataLen=5; - u1Byte buf[6] = {0}; - if(opLen == 3) - { - buf[0] = dataLen; - buf[1] = 0x5; // OP_Code - buf[2] = 0x3; // OP_Code_Length - - buf[3] = pData[0]; // OP_Code_Content - buf[4] = pData[1]; - buf[5] = pData[2]; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT AFH Map = %02x %02x %02x\n", - pData[0], pData[1], pData[2])); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - - case BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active\n")); - { - u1Byte dataLen=3; - u1Byte buf[6] = {0}; - if(opLen == 1) - { - buf[0] = dataLen; - buf[1] = 0x1; // OP_Code - buf[2] = 0x1; // OP_Code_Length - - buf[3] = pData[0]; // OP_Code_Content - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set BT Ignore Wlan Active = 0x%x\n", - pData[0])); - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_CTRL_BT_COEX, (PVOID)&buf[0]); - } - } - break; - - default: - break; - } -} - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.h deleted file mode 100644 index bf60763c5..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8812a2Ant.h +++ /dev/null @@ -1,250 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8812A 2Ant BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8812A_2ANT 0 - -#define BT_INFO_8812A_2ANT_B_FTP BIT7 -#define BT_INFO_8812A_2ANT_B_A2DP BIT6 -#define BT_INFO_8812A_2ANT_B_HID BIT5 -#define BT_INFO_8812A_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8812A_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8812A_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8812A_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8812A_2ANT_B_CONNECTION BIT0 - -#define BT_INFO_8812A_2ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8812A_2ANT 2 -#define NOISY_AP_NUM_THRESH_8812A 50 - - -typedef enum _BT_INFO_SRC_8812A_2ANT{ - BT_INFO_SRC_8812A_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8812A_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8812A_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8812A_2ANT_MAX -}BT_INFO_SRC_8812A_2ANT,*PBT_INFO_SRC_8812A_2ANT; - -typedef enum _BT_8812A_2ANT_BT_STATUS{ - BT_8812A_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8812A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8812A_2ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8812A_2ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8812A_2ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8812A_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8812A_2ANT_BT_STATUS_MAX -}BT_8812A_2ANT_BT_STATUS,*PBT_8812A_2ANT_BT_STATUS; - -typedef enum _BT_8812A_2ANT_COEX_ALGO{ - BT_8812A_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8812A_2ANT_COEX_ALGO_SCO = 0x1, - BT_8812A_2ANT_COEX_ALGO_SCO_HID = 0x2, - BT_8812A_2ANT_COEX_ALGO_HID = 0x3, - BT_8812A_2ANT_COEX_ALGO_A2DP = 0x4, - BT_8812A_2ANT_COEX_ALGO_A2DP_PANHS = 0x5, - BT_8812A_2ANT_COEX_ALGO_PANEDR = 0x6, - BT_8812A_2ANT_COEX_ALGO_PANHS = 0x7, - BT_8812A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x8, - BT_8812A_2ANT_COEX_ALGO_PANEDR_HID = 0x9, - BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0xa, - BT_8812A_2ANT_COEX_ALGO_HID_A2DP_PANHS = 0xb, - BT_8812A_2ANT_COEX_ALGO_HID_A2DP = 0xc, - BT_8812A_2ANT_COEX_ALGO_MAX = 0xd -}BT_8812A_2ANT_COEX_ALGO,*PBT_8812A_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8812A_2ANT{ - // fw mechanism - u1Byte preBtDecPwrLvl; - u1Byte curBtDecPwrLvl; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bAutoTdmaAdjustLowRssi; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - BOOLEAN bPreEnablePTA; - BOOLEAN bCurEnablePTA; - - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte curRaMaskType; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; -} COEX_DM_8812A_2ANT, *PCOEX_DM_8812A_2ANT; - -typedef struct _COEX_STA_8812A_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - BOOLEAN bAclBusy; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - u1Byte preBtRssiState; - u1Byte preBtDisabled; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8812A_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8812A_2ANT_MAX]; - u4Byte prebtInfoC2hCnt_BT_RSP; - u4Byte prebtInfoC2hCnt_BT_SEND; - u4Byte btInfoQueryCnt; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - u1Byte nScanAPNum; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - u1Byte nCoexTableType; - BOOLEAN bForceLpsOn; - - u1Byte disVerInfoCnt; - -}COEX_STA_8812A_2ANT, *PCOEX_STA_8812A_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8812a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8812a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8812a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8812a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8812a2ant_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ); -VOID -EXhalbtc8812a2ant_BTOffOnNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte BTstatus - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.c deleted file mode 100644 index df3507765..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.c +++ /dev/null @@ -1,3434 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for 8821A_1ANT Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8821a1Ant.tmh" -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8821A_1ANT GLCoexDm8821a1Ant; -static PCOEX_DM_8821A_1ANT pCoexDm=&GLCoexDm8821a1Ant; -static COEX_STA_8821A_1ANT GLCoexSta8821a1Ant; -static PCOEX_STA_8821A_1ANT pCoexSta=&GLCoexSta8821a1Ant; - -const char *const GLBtInfoSrc8821a1Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8821a1Ant=20140306; -u4Byte GLCoexVer8821a1Ant=0x4b; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8821a1ant_ -//============================================================ -u1Byte -halbtc8821a1ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8821a1ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8821a1ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8821a1ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8821a1ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8821a1ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8821a1ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8821a1ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8821a1ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8821a1ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8821a1ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); -} - -VOID -halbtc8821a1ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); - - -} - -VOID -halbtc8821a1ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp, u4Tmp1; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp, u1Tmp1; - s4Byte wifiRssi; -#if 0 - //to avoid 0x76e[3] = 1 (WLAN_Act control by PTA) during IPS - if (! (pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e) & 0x8) ) - { - pCoexSta->highPriorityTx = 65535; - pCoexSta->highPriorityRx = 65535; - pCoexSta->lowPriorityTx = 65535; - pCoexSta->lowPriorityRx = 65535; - return; - } -#endif - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8821a1ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -BOOLEAN -halbtc8821a1ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - } - - return FALSE; -} - -VOID -halbtc8821a1ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } - - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8821a1ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8821A_1ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO only\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID only\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP only\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(HS) only\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = PAN(EDR) only\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP ==> SCO\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + PAN(EDR)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + PAN(EDR)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + PAN(EDR)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! BT Profile = SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Profile = SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8821A_1ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8821a1ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8821a1ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8821a1ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8821a1ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!") )); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8821a1ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8821a1ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8821a1ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8821a1ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8821a1ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8821a1ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** CoexTable(%d) **********\n", type)); - - switch(type) - { - case 0: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 2: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 3: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 4: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 5: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x5a5a5a5a, 0xaaaa5a5a, 0xffffff, 0x3); - break; - case 6: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0xaaaa5a5a, 0xffffff, 0x3); - break; - case 7: - halbtc8821a1ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8821a1ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8821a1ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8821a1ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8821a1ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - u1Byte realByte1=byte1, realByte5=byte5; - BOOLEAN bApEnable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - - if(bApEnable) - { - if(byte1&BIT4 && !(byte1&BIT5)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW for 1Ant AP mode\n")); - realByte1 &= ~BIT4; - realByte1 |= BIT5; - - realByte5 |= BIT5; - realByte5 &= ~BIT6; - } - } - - H2C_Parameter[0] = realByte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = realByte5; - - pCoexDm->psTdmaPara[0] = realByte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = realByte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], PS-TDMA H2C cmd =0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - -VOID -halbtc8821a1ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8821a1ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8821a1ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8821a1ant_SwMechanism( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRA - ) -{ - halbtc8821a1ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8821a1ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte fwVer=0, u4Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - if(bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - //0x765 = 0x18 - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x3); - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 1; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - - //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x1); //Main Ant to BT for IPS case 0x4c[23]=1 - } - else - { - //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 0; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - - //pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x64, 0x1, 0x0); //Aux Ant to BT for IPS case 0x4c[23]=1 - } - } - else if(bWifiOff) - { - // 0x4c[24:23]=00, Set Antenna control by BT_RFE_CTRL BT Vendor 0xac=0xf002 - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &= ~BIT23; - u4Tmp &= ~BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - //0x765 = 0x18 - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x3); - } - else - { - //0x765 = 0x0 - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x765, 0x18, 0x0); - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_PATH_WIFI: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77); - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2); - break; - case BTC_ANT_PATH_BT: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77); - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1); - break; - default: - case BTC_ANT_PATH_PTA: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x66); - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1); - else - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2); - break; - } -} - -VOID -halbtc8821a1ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0, rssiAdjustVal=0; - //u4Byte fwVer=0; - - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if (pCoexDm->bCurPsTdmaOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(off, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(bTurnOn) - { - switch(type) - { - default: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1a, 0x1a, 0x0, 0x50); - break; - case 1: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x3a, 0x03, 0x10, 0x50); - rssiAdjustVal = 11; - break; - case 2: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x2b, 0x03, 0x10, 0x50); - rssiAdjustVal = 14; - break; - case 3: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x1d, 0x1d, 0x0, 0x52); - break; - case 4: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x14, 0x0); - rssiAdjustVal = 17; - break; - case 5: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x15, 0x3, 0x11, 0x10); - break; - case 6: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x20, 0x3, 0x11, 0x13); - break; - case 7: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xc, 0x5, 0x0, 0x0); - break; - case 8: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - break; - case 9: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x50); - rssiAdjustVal = 18; - break; - case 10: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0xa, 0x0, 0x40); - break; - case 11: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x15, 0x03, 0x10, 0x50); - rssiAdjustVal = 20; - break; - case 12: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x0a, 0x0a, 0x0, 0x50); - break; - case 13: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x12, 0x12, 0x0, 0x50); - break; - case 14: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x21, 0x3, 0x10, 0x52); - break; - case 15: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x13, 0xa, 0x3, 0x8, 0x0); - break; - case 16: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x15, 0x3, 0x10, 0x0); - rssiAdjustVal = 18; - break; - case 18: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x93, 0x25, 0x3, 0x10, 0x0); - rssiAdjustVal = 14; - break; - case 20: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x03, 0x11, 0x10); - break; - case 21: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x11); - break; - case 22: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x25, 0x03, 0x11, 0x10); - break; - case 23: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x18); - rssiAdjustVal = 22; - break; - case 24: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x3, 0x31, 0x18); - rssiAdjustVal = 22; - break; - case 25: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - rssiAdjustVal = 22; - break; - case 26: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0x3, 0x31, 0x18); - rssiAdjustVal = 22; - break; - case 27: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x3, 0x31, 0x98); - rssiAdjustVal = 22; - break; - case 28: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x69, 0x25, 0x3, 0x31, 0x0); - break; - case 29: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xab, 0x1a, 0x1a, 0x1, 0x10); - break; - case 30: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x51, 0x30, 0x3, 0x10, 0x10); - break; - case 31: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1a, 0x1a, 0, 0x58); - break; - case 32: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x61, 0x35, 0x3, 0x11, 0x11); - break; - case 33: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xa3, 0x25, 0x3, 0x30, 0x90); - break; - case 34: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x53, 0x1a, 0x1a, 0x0, 0x10); - break; - case 35: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x63, 0x1a, 0x1a, 0x0, 0x10); - break; - case 36: - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0xd3, 0x12, 0x3, 0x14, 0x50); - break; - case 40: // SoftAP only with no sta associated,BT disable ,TDMA mode for power saving - /* here softap mode screen off will cost 70-80mA for phone */ - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x23, 0x18, 0x00, 0x10, 0x24); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 8: //PTA Control - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x8, 0x0, 0x0, 0x0, 0x0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, FALSE, FALSE); - break; - case 0: - default: //Software control, Antenna at BT side - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE); - break; - case 9: //Software control, Antenna at WiFi side - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x0, 0x0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_WIFI, FALSE, FALSE); - break; - case 10: // under 5G - halbtc8821a1ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x8, 0x0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, FALSE); - break; - } - } - rssiAdjustVal =0; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, &rssiAdjustVal); - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8821a1ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // sw all off - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - // hw all off - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -BOOLEAN -halbtc8821a1ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT non connected-idle!!\n")); - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT connected-idle!!\n")); - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE != pCoexDm->btStatus) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non connected-idle + BT Busy!!\n")); - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - bCommon = TRUE; - } - else - { - if (bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - } - - bCommon = FALSE; - } - - return bCommon; -} - - -VOID -halbtc8821a1ant_TdmaDurationAdjustForAcl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0, btInfoExt; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjustForAcl()\n")); - - if( (BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN == wifiStatus) || - (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN == wifiStatus) || - (BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT == wifiStatus) ) - { - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 3 && - pCoexDm->curPsTdma != 9 ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - return; - } - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - btInfoExt = pCoexSta->btInfoExt; - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - if(result == -1) - { - if( (BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - else if(result == 1) - { - if( (BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(btInfoExt)) && - ((pCoexDm->curPsTdma == 1) ||(pCoexDm->curPsTdma == 2)) ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - } - else //no change - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ********** TDMA(on, %d) **********\n", - pCoexDm->curPsTdma)); - } - - if( pCoexDm->curPsTdma != 1 && - pCoexDm->curPsTdma != 2 && - pCoexDm->curPsTdma != 9 && - pCoexDm->curPsTdma != 11 ) - { - // recover to previous adjust type - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - } -} - -VOID -halbtc8821a1ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8821a1ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - break; - case BTC_PS_LPS_ON: - halbtc8821a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8821a1ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - break; - case BTC_PS_LPS_OFF: - halbtc8821a1ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - break; - default: - break; - } -} - -VOID -halbtc8821a1ant_CoexUnder5G( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE); - - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 10); - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 5); -} - -VOID -halbtc8821a1ant_ActionWifiOnly( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 9); -} - -VOID -halbtc8821a1ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - halbtc8821a1ant_ActionWifiOnly(pBtCoexist); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - } - } -} - -//============================================= -// -// Software Coex Mechanism start -// -//============================================= - -// SCO only or SCO+PAN(HS) -VOID -halbtc8821a1ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8821a1ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE); -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8821a1ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8821a1ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8821a1ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(HS) only -VOID -halbtc8821a1ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); -} - -//PAN(EDR)+A2DP -VOID -halbtc8821a1ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); -} - -VOID -halbtc8821a1ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE); -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8821a1ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE); -} - -VOID -halbtc8821a1ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_SwMechanism(pBtCoexist, TRUE); -} - -//============================================= -// -// Non-Software Coex Mechanism start -// -//============================================= -VOID -halbtc8821a1ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8821a1ant_ActionHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); -} - -VOID -halbtc8821a1ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bApEnable=FALSE, bWifiBusy=FALSE, bBtBusy=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if((!bWifiConnected) && (!pCoexSta->bWiFiIsHighPriTask)) - { - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - } - else if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - // SCO/HID/A2DP busy - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if ((pBtLinkInfo->bPanExist) || (bWifiBusy)) - { - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } -} - -VOID -halbtc8821a1ant_ActionBtScoHidOnlyBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - // tdma and coex table - - if(pBtLinkInfo->bScoExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - else //HID - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 5); - } -} - -VOID -halbtc8821a1ant_ActionWifiConnectedBtAclBusy( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte wifiStatus - ) -{ - u1Byte btRssiState; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - btRssiState = halbtc8821a1ant_BtRssiState(2, 28, 0); - - if(pBtLinkInfo->bHidOnly) //HID - { - halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, wifiStatus); - pCoexDm->bAutoTdmaAdjust = FALSE; - return; - } - else if(pBtLinkInfo->bA2dpOnly) //A2DP - { - if(BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE == wifiStatus) - { - //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a1ant_TdmaDurationAdjustForAcl(pBtCoexist, wifiStatus); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - } - else //for low BT RSSI - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - } - else if(pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist) //HID+A2DP - { - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else //for low BT RSSI - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6); - } - else if( (pBtLinkInfo->bPanOnly) || (pBtLinkInfo->bHidExist&&pBtLinkInfo->bPanExist) ) //PAN(OPP,FTP), HID+PAN(OPP,FTP) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 6); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else if ( ((pBtLinkInfo->bA2dpExist) && (pBtLinkInfo->bPanExist)) || - (pBtLinkInfo->bHidExist&&pBtLinkInfo->bA2dpExist&&pBtLinkInfo->bPanExist) ) //A2DP+PAN(OPP,FTP), HID+A2DP+PAN(OPP,FTP) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - pCoexDm->bAutoTdmaAdjust = FALSE; - } -} - -VOID -halbtc8821a1ant_ActionWifiNotConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - // power save state - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8821a1ant_ActionWifiNotConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - - //Bryant Add - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8821a1ant_ActionWifiNotConnectedAssoAuth( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if( (pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if( (pBtLinkInfo->bA2dpExist) || (pBtLinkInfo->bPanExist) ) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8821a1ant_ActionWifiConnectedScan( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - if (pBtLinkInfo->bA2dpExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if (pBtLinkInfo->bA2dpExist && pBtLinkInfo->bPanExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - } - else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN); - } - else - { - //halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - //halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 1); - - //Bryant Add - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8821a1ant_ActionWifiConnectedSpecialPacket( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if((pBtLinkInfo->bScoExist) || (pBtLinkInfo->bHidExist) || (pBtLinkInfo->bA2dpExist)) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 32); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else if(pBtLinkInfo->bPanExist) - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 20); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 4); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } -} - -VOID -halbtc8821a1ant_ActionWifiConnected( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiBusy=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - BOOLEAN bUnder4way=FALSE, bApEnable=FALSE; - u4Byte wifiBw; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect()===>\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - if(bUnder4way) - { - halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under 4way<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - if(bScan || bLink || bRoam) - { - if(bScan) - halbtc8821a1ant_ActionWifiConnectedScan(pBtCoexist); - else - halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexForWifiConnect(), return for wifi is under scan<===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE, &bApEnable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - // power save state - if(!bApEnable && BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus && !pBtCoexist->btLinkInfo.bHidOnly) - { - if(!bWifiBusy && pBtCoexist->btLinkInfo.bA2dpOnly) //A2DP - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - else - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - // tdma and coex table - if(!bWifiBusy) - { - if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8821a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - } - else - { - if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) - { - halbtc8821a1ant_ActionWifiConnectedBtAclBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else if( (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - halbtc8821a1ant_ActionBtScoHidOnlyBusy(pBtCoexist, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY); - } - else - { - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - } -} - -VOID -halbtc8821a1ant_RunSwCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte algorithm=0; - - algorithm = halbtc8821a1ant_ActionAlgorithm(pBtCoexist); - pCoexDm->curAlgorithm = algorithm; - - if(halbtc8821a1ant_IsCommonAction(pBtCoexist)) - { - - } - else - { - switch(pCoexDm->curAlgorithm) - { - case BT_8821A_1ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = SCO.\n")); - halbtc8821a1ant_ActionSco(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID.\n")); - halbtc8821a1ant_ActionHid(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP.\n")); - halbtc8821a1ant_ActionA2dp(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = A2DP+PAN(HS).\n")); - halbtc8821a1ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR).\n")); - halbtc8821a1ant_ActionPanEdr(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HS mode.\n")); - halbtc8821a1ant_ActionPanHs(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN+A2DP.\n")); - halbtc8821a1ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = PAN(EDR)+HID.\n")); - halbtc8821a1ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP+PAN.\n")); - halbtc8821a1ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8821A_1ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = HID+A2DP.\n")); - halbtc8821a1ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action algorithm = coexist All Off!!\n")); - //halbtc8821a1ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8821a1ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - BOOLEAN bIncreaseScanDevNum=FALSE; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bWifiUnder5G=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - if(pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Stop Coex DM <===\n")); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - if(bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for 5G <===\n")); - halbtc8821a1ant_CoexUnder5G(pBtCoexist); - return; - } - - if( (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bIncreaseScanDevNum = TRUE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_INC_SCAN_DEV_NUM, &bIncreaseScanDevNum); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(!pBtLinkInfo->bScoExist && !pBtLinkInfo->bHidExist) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - } - else - { - if(bWifiConnected) - { - wifiRssiState = halbtc8821a1ant_WifiRssiState(pBtCoexist, 1, 2, 30, 0); - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1); - } - else - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 1, 1, 1, 1); - } - } - else - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - } - - } - - if(pBtLinkInfo->bScoExist) - { - bBtCtrlAggBufSize = TRUE; - aggBufSize = 0x3; - } - else if(pBtLinkInfo->bHidExist) - { - bBtCtrlAggBufSize = TRUE; - aggBufSize = 0x5; - } - else if(pBtLinkInfo->bA2dpExist || pBtLinkInfo->bPanExist) - { - bBtCtrlAggBufSize = TRUE; - aggBufSize = 0x8; - } - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - - halbtc8821a1ant_RunSwCoexistMechanism(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8821a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8821a1ant_ActionHs(pBtCoexist); - return; - } - - - if(!bWifiConnected) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is non connected-idle !!!\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - if (bScan) - halbtc8821a1ant_ActionWifiNotConnectedScan(pBtCoexist); - else - halbtc8821a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else - halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist); - } - else // wifi LPS/Busy - { - halbtc8821a1ant_ActionWifiConnected(pBtCoexist); - } -} - -VOID -halbtc8821a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - // sw all off - halbtc8821a1ant_SwMechanism(pBtCoexist, FALSE); - - //halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); -} - -VOID -halbtc8821a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp, - IN BOOLEAN bWifiOnly - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - BOOLEAN bWifiUnder5G=FALSE; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 1Ant Init HW Config!!\n")); - - if(bWifiOnly) - return; - - if(bBackUp) - { - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - } - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - //Antenna config - if(bWifiUnder5G) - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, TRUE, FALSE); - else - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_PTA, TRUE, FALSE); - - // PTA parameter - halbtc8821a1ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); -} - -//============================================================ -// work around function start with wa_halbtc8821a1ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8821a1ant_ -//============================================================ -VOID -EXhalbtc8821a1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8821a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8821a1ant_InitHwConfig(pBtCoexist, TRUE, bWifiOnly); -} - -VOID -EXhalbtc8821a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - pBtCoexist->bStopCoexDm = FALSE; - - halbtc8821a1ant_InitCoexDm(pBtCoexist); - - halbtc8821a1ant_QueryBtInfo(pBtCoexist); -} - -VOID -EXhalbtc8821a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u2Byte u2Tmp[4]; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - if(pBtCoexist->bStopCoexDm) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Coex is STOPPED]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8821a1Ant, GLCoexVer8821a1Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821a1Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - if(!pBtCoexist->bManualControl) - { - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "SM[LowPenaltyRA]", \ - pCoexDm->bCurLowPenaltyRa); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", \ - (pBtCoexist->btInfo.bRejectAggPkt? "Yes":"No"), (pBtCoexist->btInfo.bBtCtrlAggBufSize? "Yes":"No"), - pBtCoexist->btInfo.aggBufSize); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Rate Mask", \ - pBtCoexist->btInfo.raMask); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d ", "IgnWlanAct", \ - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x ", "Latest error condition(should be 0)", \ - pCoexDm->errorCondition); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", \ - pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", \ - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc58); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x778/ 0xc58[29:25]", \ - u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x8db); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0x8db[6:5]", \ - ((u1Tmp[0]&0x60)>>5)); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x975); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0xcb4[29:28]/0xcb4[7:0]/0x974[9:8]", \ - (u4Tmp[0]&0x30000000)>>28, u4Tmp[0]&0xff, u1Tmp[0]& 0x3); - CL_PRINTF(cliBuf); - - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/0x4c[24:23]/0x64[0]", \ - u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u1Tmp[1]&0x1); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "0xc50(dig)", \ - u4Tmp[0]&0xff); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf48); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5d); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA", \ - u4Tmp[0], (u1Tmp[0]<<8) + u1Tmp[1] ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 1) - halbtc8821a1ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8821a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u4Byte u4Tmp=0; - - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - - halbtc8821a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8821a1ant_InitCoexDm(pBtCoexist); - halbtc8821a1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8821a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) - return; - - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8821a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm ) - return; - - if(BTC_SCAN_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - - halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 8); //Force antenna setup for no scan result issue - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } - - if(pBtCoexist->btInfo.bBtDisabled) - return; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - halbtc8821a1ant_QueryBtInfo(pBtCoexist); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8821a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8821a1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_SCAN_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8821a1ant_ActionWifiNotConnectedScan(pBtCoexist); - } - else // wifi is connected - { - halbtc8821a1ant_ActionWifiConnectedScan(pBtCoexist); - } - } - else if(BTC_SCAN_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - if(!bWifiConnected) // non-connected scan - { - halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8821a1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8821a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_ASSOCIATE_START == type) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - pCoexDm->nArpCnt = 0; - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - pCoexDm->nArpCnt = 0; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8821a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8821a1ant_ActionHs(pBtCoexist); - return; - } - - if(BTC_ASSOCIATE_START == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - halbtc8821a1ant_ActionWifiNotConnectedAssoAuth(pBtCoexist); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(!bWifiConnected) // non-connected scan - { - halbtc8821a1ant_ActionWifiNotConnected(pBtCoexist); - } - else - { - halbtc8821a1ant_ActionWifiConnected(pBtCoexist); - } - } -} - -VOID -EXhalbtc8821a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - pCoexDm->nArpCnt = 0; - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - //H2C_Parameter[0] = 0x1; - H2C_Parameter[0] = 0x0; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8821a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - BOOLEAN bBtHsOn=FALSE; - u4Byte wifiLinkStatus=0; - u4Byte numOfWifiLink=0; - BOOLEAN bBtCtrlAggBufSize=FALSE; - u1Byte aggBufSize=5; - - if(pBtCoexist->bManualControl || - pBtCoexist->bStopCoexDm || - pBtCoexist->btInfo.bBtDisabled ) - return; - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - pCoexSta->bWiFiIsHighPriTask = TRUE; - - if(BTC_PACKET_ARP == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet ARP notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet DHCP or EAPOL notify\n")); - } - } - else - { - pCoexSta->bWiFiIsHighPriTask = FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet [Type = %d] notify\n", type)); - } - - pCoexSta->specialPktPeriodCnt = 0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - if(numOfWifiLink >= 2) - { - halbtc8821a1ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0); - halbtc8821a1ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, bBtCtrlAggBufSize, aggBufSize); - halbtc8821a1ant_ActionWifiMultiPort(pBtCoexist); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - if(pCoexSta->bC2hBtInquiryPage) - { - halbtc8821a1ant_ActionBtInquiry(pBtCoexist); - return; - } - else if(bBtHsOn) - { - halbtc8821a1ant_ActionHs(pBtCoexist); - return; - } - - if( BTC_PACKET_DHCP == type || - BTC_PACKET_EAPOL == type || - BTC_PACKET_ARP == type ) - { - //RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], special Packet(%d) notify\n", type)); - if(BTC_PACKET_ARP == type) - { - pCoexDm->nArpCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ARP Packet Count = %d\n", pCoexDm->nArpCnt)); - if(pCoexDm->nArpCnt >= 10) // if APR PKT > 10 after connect, do not go to ActionWifiConnectedSpecialPacket(pBtCoexist) - return; - } - - halbtc8821a1ant_ActionWifiConnectedSpecialPacket(pBtCoexist); - } -} - -VOID -EXhalbtc8821a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bBtBusy=FALSE; - BOOLEAN bWifiUnder5G=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8821A_1ANT_MAX) - rspSource = BT_INFO_SRC_8821A_1ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(BT_INFO_SRC_8821A_1ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - if (pCoexSta->btInfoC2h[rspSource][2]&0x20) - pCoexSta->bC2hBtPage = TRUE; - else - pCoexSta->bC2hBtPage = FALSE; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if(!pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x15 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x15\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if(pCoexSta->btInfoExt & BIT1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(bWifiConnected) - { - EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - if( (pCoexSta->btInfoExt & BIT3) && !bWifiUnder5G) - { - if(!pBtCoexist->bManualControl && !pBtCoexist->bStopCoexDm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - } -#if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8821a1ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8821A_1ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8821A_1ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8821A_1ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8821A_1ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8821A_1ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8821A_1ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - } - - halbtc8821a1ant_UpdateBtLinkInfo(pBtCoexist); - - btInfo = btInfo & 0x1f; //mask profile bit for connect-ilde identification ( for CSR case: A2DP idle --> 0x41) - - if(!(btInfo&BT_INFO_8821A_1ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8821A_1ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8821A_1ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8821A_1ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8821A_1ANT_B_ACL_BUSY) - { - if(BT_8821A_1ANT_BT_STATUS_ACL_BUSY != pCoexDm->btStatus) - pCoexDm->bAutoTdmaAdjust = FALSE; - pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8821A_1ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8821A_1ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - bBtBusy = TRUE; - else - bBtBusy = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - halbtc8821a1ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8821a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 0); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - - halbtc8821a1ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - - pBtCoexist->bStopCoexDm = TRUE; -} - -VOID -EXhalbtc8821a1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - - halbtc8821a1ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a1ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8821a1ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - halbtc8821a1ant_SetAntPath(pBtCoexist, BTC_ANT_PATH_BT, FALSE, TRUE); - //halbtc8821a1ant_SetAntPathDCut(pBtCoexist, FALSE, FALSE, FALSE, BTC_ANT_PATH_BT, BTC_WIFI_STAT_NORMAL_OFF); - - pBtCoexist->bStopCoexDm = TRUE; - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - pBtCoexist->bStopCoexDm = FALSE; - halbtc8821a1ant_InitHwConfig(pBtCoexist, FALSE, FALSE); - halbtc8821a1ant_InitCoexDm(pBtCoexist); - halbtc8821a1ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8821a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8821a1Ant, GLCoexVer8821a1Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - -#if(BT_AUTO_REPORT_ONLY_8821A_1ANT == 0) - halbtc8821a1ant_QueryBtInfo(pBtCoexist); - halbtc8821a1ant_MonitorBtCtr(pBtCoexist); - halbtc8821a1ant_MonitorBtEnableDisable(pBtCoexist); -#else - if( halbtc8821a1ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust ) - { - //if(pCoexSta->specialPktPeriodCnt > 2) - //{ - halbtc8821a1ant_RunCoexistMechanism(pBtCoexist); - //} - } - - pCoexSta->specialPktPeriodCnt++; -#endif -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.h deleted file mode 100644 index 829a81187..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a1Ant.h +++ /dev/null @@ -1,214 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8821A 1ANT BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8821A_1ANT 1 - -#define BT_INFO_8821A_1ANT_B_FTP BIT7 -#define BT_INFO_8821A_1ANT_B_A2DP BIT6 -#define BT_INFO_8821A_1ANT_B_HID BIT5 -#define BT_INFO_8821A_1ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8821A_1ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8821A_1ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8821A_1ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8821A_1ANT_B_CONNECTION BIT0 - -#define BT_INFO_8821A_1ANT_A2DP_BASIC_RATE(_BT_INFO_EXT_) \ - (((_BT_INFO_EXT_&BIT0))? TRUE:FALSE) - -#define BTC_RSSI_COEX_THRESH_TOL_8821A_1ANT 2 - -typedef enum _BT_INFO_SRC_8821A_1ANT{ - BT_INFO_SRC_8821A_1ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8821A_1ANT_BT_RSP = 0x1, - BT_INFO_SRC_8821A_1ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8821A_1ANT_MAX -}BT_INFO_SRC_8821A_1ANT,*PBT_INFO_SRC_8821A_1ANT; - -typedef enum _BT_8821A_1ANT_BT_STATUS{ - BT_8821A_1ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8821A_1ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8821A_1ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8821A_1ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8821A_1ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8821A_1ANT_BT_STATUS_MAX -}BT_8821A_1ANT_BT_STATUS,*PBT_8821A_1ANT_BT_STATUS; - -typedef enum _BT_8821A_1ANT_WIFI_STATUS{ - BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8821A_1ANT_WIFI_STATUS_NON_CONNECTED_ASSO_AUTH_SCAN = 0x1, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN = 0x2, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SPECIAL_PKT = 0x3, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_IDLE = 0x4, - BT_8821A_1ANT_WIFI_STATUS_CONNECTED_BUSY = 0x5, - BT_8821A_1ANT_WIFI_STATUS_MAX -}BT_8821A_1ANT_WIFI_STATUS,*PBT_8821A_1ANT_WIFI_STATUS; - -typedef enum _BT_8821A_1ANT_COEX_ALGO{ - BT_8821A_1ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8821A_1ANT_COEX_ALGO_SCO = 0x1, - BT_8821A_1ANT_COEX_ALGO_HID = 0x2, - BT_8821A_1ANT_COEX_ALGO_A2DP = 0x3, - BT_8821A_1ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8821A_1ANT_COEX_ALGO_PANEDR = 0x5, - BT_8821A_1ANT_COEX_ALGO_PANHS = 0x6, - BT_8821A_1ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8821A_1ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8821A_1ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8821A_1ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8821A_1ANT_COEX_ALGO_MAX = 0xb, -}BT_8821A_1ANT_COEX_ALGO,*PBT_8821A_1ANT_COEX_ALGO; - -typedef struct _COEX_DM_8821A_1ANT{ - // fw mechanism - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; - - // sw mechanism - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - - u4Byte backupArfrCnt1; // Auto Rate Fallback Retry cnt - u4Byte backupArfrCnt2; // Auto Rate Fallback Retry cnt - u2Byte backupRetryLimit; - u1Byte backupAmpduMaxTime; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - u4Byte preRaMask; - u4Byte curRaMask; - u1Byte preArfrType; - u1Byte curArfrType; - u1Byte preRetryLimitType; - u1Byte curRetryLimitType; - u1Byte preAmpduTimeType; - u1Byte curAmpduTimeType; - u4Byte nArpCnt; - - u1Byte errorCondition; -} COEX_DM_8821A_1ANT, *PCOEX_DM_8821A_1ANT; - -typedef struct _COEX_STA_8821A_1ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte specialPktPeriodCnt; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8821A_1ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8821A_1ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - BOOLEAN bC2hBtPage; //Add for win8.1 page out issue - BOOLEAN bWiFiIsHighPriTask; //Add for win8.1 page out issue - u1Byte btRetryCnt; - u1Byte btInfoExt; -}COEX_STA_8821A_1ANT, *PCOEX_STA_8821A_1ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8821a1ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a1ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8821a1ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a1ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a1ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8821a1ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a1ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8821a1ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a1ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.c deleted file mode 100644 index 85288a7fd..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.c +++ /dev/null @@ -1,4859 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8821A Co-exist mechanism -// -// History -// 2012/11/15 Cosa first check in. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtc8821a2Ant.tmh" -#endif - -#if (RTL8821A_SUPPORT == 1) - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8821A_2ANT GLCoexDm8821a2Ant; -static PCOEX_DM_8821A_2ANT pCoexDm=&GLCoexDm8821a2Ant; -static COEX_STA_8821A_2ANT GLCoexSta8821a2Ant; -static PCOEX_STA_8821A_2ANT pCoexSta=&GLCoexSta8821a2Ant; - -const char *const GLBtInfoSrc8821a2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8821a2Ant=20150921; -u4Byte GLCoexVer8821a2Ant=0x58; -//modify 20140903v43 a2dpandhid tdmaonoff a2dp glitch _ tdma off 778=3(case1)->778=1(case0) -//and to improve tp while a2dphid case23->case25 , case123->case125 for asus spec -//and modify for asus bt WHQL test _ tdma off_ 778=3->1_ -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8821a2ant_ -//============================================================ -u1Byte -halbtc8821a2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8821a2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8821a2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - } - } -} - -VOID -halbtc8821a2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); -} - -VOID -halbtc8821a2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - if ( (pCoexSta->lowPriorityRx >= 950) && (pCoexSta->lowPriorityRx >= pCoexSta->lowPriorityTx) && (!pCoexSta->bUnderIps) ) - { - pBtLinkInfo->bSlaveRole = TRUE; - } - else - { - pBtLinkInfo->bSlaveRole = FALSE; - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - -VOID -halbtc8821a2ant_MonitorWiFiCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte u4Tmp; - u2Byte u2Tmp[3]; - s4Byte wifiRssi=0; - BOOLEAN bWifiBusy = FALSE, bWifiUnderBMode = FALSE; - static u1Byte nCCKLockCounter = 0; - - - if (pCoexSta->bUnderIps) - { - pCoexSta->nCRCOK_CCK = 0; - pCoexSta->nCRCOK_11g = 0; - pCoexSta->nCRCOK_11n = 0; - pCoexSta->nCRCOK_11nAgg = 0; - - pCoexSta->nCRCErr_CCK = 0; - pCoexSta->nCRCErr_11g = 0; - pCoexSta->nCRCErr_11n = 0; - pCoexSta->nCRCErr_11nAgg = 0; - } - else - { - pCoexSta->nCRCOK_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf88); - pCoexSta->nCRCOK_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf94); - pCoexSta->nCRCOK_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf90); - pCoexSta->nCRCOK_11nAgg= pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfb8); - - pCoexSta->nCRCErr_CCK = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf84); - pCoexSta->nCRCErr_11g = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf96); - pCoexSta->nCRCErr_11n = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xf92); - pCoexSta->nCRCErr_11nAgg = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0xfba); - } - - //reset counter - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x1); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xf16, 0x1, 0x0); -} - -VOID -halbtc8821a2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -BOOLEAN -halbtc8821a2ant_IsWifiStatusChanged( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreWifiBusy=FALSE, bPreUnder4way=FALSE, bPreBtHsOn=FALSE; - BOOLEAN bWifiBusy=FALSE, bUnder4way=FALSE, bBtHsOn=FALSE; - BOOLEAN bWifiConnected=FALSE; - u1Byte wifiRssiState=BTC_RSSI_STATE_HIGH; - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS, &bUnder4way); - - if(bWifiConnected) - { - if(bWifiBusy != bPreWifiBusy) - { - bPreWifiBusy = bWifiBusy; - return TRUE; - } - if(bUnder4way != bPreUnder4way) - { - bPreUnder4way = bUnder4way; - return TRUE; - } - if(bBtHsOn != bPreBtHsOn) - { - bPreBtHsOn = bBtHsOn; - return TRUE; - } - - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist,3, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - - if ( (BTC_RSSI_STATE_HIGH ==wifiRssiState ) || (BTC_RSSI_STATE_LOW ==wifiRssiState )) - { - return TRUE; - } - - } - - return FALSE; -} - -VOID -halbtc8821a2ant_UpdateBtLinkInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - -#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1) // profile from bt patch - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - pBtLinkInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pBtLinkInfo->bScoExist = pCoexSta->bScoExist; - pBtLinkInfo->bA2dpExist = pCoexSta->bA2dpExist; - pBtLinkInfo->bPanExist = pCoexSta->bPanExist; - pBtLinkInfo->bHidExist = pCoexSta->bHidExist; - - // work around for HS mode. - if(bBtHsOn) - { - pBtLinkInfo->bPanExist = TRUE; - pBtLinkInfo->bBtLinkExist = TRUE; - } -#else // profile from bt stack - pBtLinkInfo->bBtLinkExist = pStackInfo->bBtLinkExist; - pBtLinkInfo->bScoExist = pStackInfo->bScoExist; - pBtLinkInfo->bA2dpExist = pStackInfo->bA2dpExist; - pBtLinkInfo->bPanExist = pStackInfo->bPanExist; - pBtLinkInfo->bHidExist = pStackInfo->bHidExist; - - //for win-8 stack HID report error - if(!pStackInfo->bHidExist) - pStackInfo->bHidExist = pCoexSta->bHidExist; //sync BTInfo with BT firmware and stack - // when stack HID report error, here we use the info from bt fw. - if(!pStackInfo->bBtLinkExist) - pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist; -#endif - // check if Sco only - if( pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bScoOnly = TRUE; - else - pBtLinkInfo->bScoOnly = FALSE; - - // check if A2dp only - if( !pBtLinkInfo->bScoExist && - pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bA2dpOnly = TRUE; - else - pBtLinkInfo->bA2dpOnly = FALSE; - - // check if Pan only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - pBtLinkInfo->bPanExist && - !pBtLinkInfo->bHidExist ) - pBtLinkInfo->bPanOnly = TRUE; - else - pBtLinkInfo->bPanOnly = FALSE; - - // check if Hid only - if( !pBtLinkInfo->bScoExist && - !pBtLinkInfo->bA2dpExist && - !pBtLinkInfo->bPanExist && - pBtLinkInfo->bHidExist ) - pBtLinkInfo->bHidOnly = TRUE; - else - pBtLinkInfo->bHidOnly = FALSE; -} - -u1Byte -halbtc8821a2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8821A_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(!pBtLinkInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No BT link exists!!!\n")); - return algorithm; - } - - if(pBtLinkInfo->bScoExist) - numOfDiffProfile++; - if(pBtLinkInfo->bHidExist) - numOfDiffProfile++; - if(pBtLinkInfo->bPanExist) - numOfDiffProfile++; - if(pBtLinkInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pBtLinkInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pBtLinkInfo->bScoExist) - { - if(pBtLinkInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else if(pBtLinkInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { -#if 0 - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else -#endif - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> SCO\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS) ==> SCO\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR) ==> SCO\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - } - else if( pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - } - } - else - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pBtLinkInfo->bScoExist) - { - if( pBtLinkInfo->bHidExist && - pBtLinkInfo->bPanExist && - pBtLinkInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8821A_2ANT_COEX_ALGO_SCO; - } - } - } - } - - return algorithm; -} - -VOID -halbtc8821a2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8821a2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte decBtPwrLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = decBtPwrLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power level = %d, FW write 0x62=0x%x\n", - decBtPwrLvl, H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); -} - -VOID -halbtc8821a2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte decBtPwrLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power level = %d\n", - (bForceExec? "force to":""), decBtPwrLvl)); - pCoexDm->curBtDecPwrLvl = decBtPwrLvl; - - if(!bForceExec) - { - if(pCoexDm->preBtDecPwrLvl == pCoexDm->curBtDecPwrLvl) - return; - } - halbtc8821a2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->curBtDecPwrLvl); - - pCoexDm->preBtDecPwrLvl = pCoexDm->curBtDecPwrLvl; -} - -VOID -halbtc8821a2ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8821a2ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - halbtc8821a2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8821a2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8821a2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8821a2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8821a2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8821a2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8821a2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf5; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xa0; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xa0; //MCS5 or OFDM36 - //H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - //H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - //H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!")) ); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8821a2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - //return; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8821a2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8821a2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc5b, 0x3e, val); -} - -VOID -halbtc8821a2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8821a2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8821a2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8821a2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8821a2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8821a2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x1); - } -} - -VOID -halbtc8821a2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8821a2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8821a2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - //=================BB AGC Gain Table - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table On!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6e1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6d1B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6c1C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6b1D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x6a1E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x691F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0x68200001); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB Agc Table Off!\n")); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xaa1A0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa91B0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa81C0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa71D0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa61E0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa51F0001); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0xc78, 0xa4200001); - } - - - //=================RF Gain - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x1); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38fff); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x38ffe); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x380c3); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x40, 0xfffff, 0x28ce6); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xed, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - if(bAgcTableEn) - { - rssiAdjustVal = 8; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - -VOID -halbtc8821a2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8821a2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8821a2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8821a2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8821a2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8821a2ant_CoexTableWithType( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexSta->nCoexTableType = type; - - switch(type) - { - case 0: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x55555555, 0xffffff, 0x3); - break; - case 1: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55555555, 0x5afa5afa, 0xffffff, 0x3); - break; - case 2: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5ada5ada, 0x5ada5ada, 0xffffff, 0x3); - break; - case 3: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xaaaaaaaa, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 4: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xffffffff, 0xffffffff, 0xffffff, 0x3); - break; - case 5: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5fff5fff, 0xffffff, 0x3); - break; - case 6: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55ff55ff, 0x5a5a5a5a, 0xffffff, 0x3); - break; - case 7: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 8: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 9: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 10: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 11: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 12: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0x5ada5ada, 0xffffff, 0x3); - break; - case 13: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 14: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fff5fff, 0x5ada5ada, 0xffffff, 0x3); - break; - case 15: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x55dd55dd, 0xaaaaaaaa, 0xffffff, 0x3); - break; - case 16: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0x5fdf5fdf, 0x5fdb5fdb, 0xffffff, 0x3); - break; - case 17: - halbtc8821a2ant_CoexTable(pBtCoexist, bForceExec, 0xfafafafa, 0xfafafafa, 0xffffff, 0x3); - break; - default: - break; - } -} - -VOID -halbtc8821a2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8821a2ant_SetLpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - u1Byte lps=lpsVal; - u1Byte rpwm=rpwmVal; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_LPS_VAL, &lps); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RPWM_VAL, &rpwm); -} - -VOID -halbtc8821a2ant_LpsRpwm( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bForceExecPwrCmd=FALSE; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set lps/rpwm=0x%x/0x%x \n", - (bForceExec? "force to":""), lpsVal, rpwmVal)); - pCoexDm->curLps = lpsVal; - pCoexDm->curRpwm = rpwmVal; - - if(!bForceExec) - { - if( (pCoexDm->preLps == pCoexDm->curLps) && - (pCoexDm->preRpwm == pCoexDm->curRpwm) ) - { - return; - } - } - halbtc8821a2ant_SetLpsRpwm(pBtCoexist, lpsVal, rpwmVal); - - pCoexDm->preLps = pCoexDm->curLps; - pCoexDm->preRpwm = pCoexDm->curRpwm; -} - -VOID -halbtc8821a2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - halbtc8821a2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8821a2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[5] ={0}; - - H2C_Parameter[0] = byte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = byte5; - - pCoexDm->psTdmaPara[0] = byte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = byte5; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(5bytes)=0x%x%08x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 5, H2C_Parameter); -} - -VOID -halbtc8821a2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - /* - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - */ - - //halbtc8821a2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - halbtc8821a2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); -} - -VOID -halbtc8821a2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - //halbtc8821a2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - //halbtc8821a2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8821a2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - if(bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x974, 0x3ff); - //pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77); - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 1; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 0; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1); - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2); - break; - } -} - -VOID -halbtc8821a2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - u1Byte wifiRssiState1, btRssiState; - - - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - if (!(BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) && bTurnOn) - { - type = type +100; //for WiFi RSSI low or BT RSSI low - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(bTurnOn) - { - switch(type) - { - case 1: - default: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 2: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90); - break; - case 3: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); - break; - case 4: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); - break; - case 5: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90); - break; - case 6: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90); - break; - case 7: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); - break; - case 8: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); - break; - case 9: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 10: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x03, 0xf1, 0x90); - break; - case 11: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); - break; - case 12: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0xf1, 0x90); - break; - case 13: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x3, 0x70, 0x90); - break; - case 14: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x2d, 0x3, 0x70, 0x90); - break; - case 15: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); - break; - case 16: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x3, 0x70, 0x90); - break; - case 17: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); - break; - case 18: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 23: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1e, 0x03, 0xf0, 0x14); - break; - case 24: - case 124: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3c, 0x03, 0x70, 0x50); - break; - //case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink - case 25: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x14, 0x03, 0xf1, 0x90); - break; - case 26: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x30, 0x03, 0xf1, 0x90); - break; - case 71: - //halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 101: - case 105: - case 171: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x3a, 0x03, 0x70, 0x50); - break; - case 102: - case 106: - case 110: - case 114: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x2d, 0x03, 0x70, 0x50); - break; - case 103: - case 107: - case 111: - case 115: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x50); - break; - case 104: - case 108: - case 112: - case 116: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x10, 0x03, 0x70, 0x50); - break; - case 109: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0xf1, 0x90); - break; - case 113: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x3c, 0x03, 0x70, 0x90); - break; - case 121: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 22: - case 122: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x35, 0x03, 0x71, 0x11); - break; - case 123: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x1c, 0x03, 0x70, 0x54); - break; - //case25/case125 : for lenovo bt pan tp degrade<30% while wifi downlink - case 125: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x14, 0x03, 0x70, 0x50); - break; - case 126: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0xd3, 0x30, 0x03, 0x70, 0x50); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 0: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - case 1: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; - default: - halbtc8821a2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8821a2ant_PsTdmaCheckForPowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bNewPsState - ) -{ - u1Byte lpsMode=0x0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_LPS_MODE, &lpsMode); - - if(lpsMode) // already under LPS state - { - if(bNewPsState) - { - // keep state under LPS, do nothing. - } - else - { - // will leave LPS state, turn off psTdma first - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - } - else // NO PS state - { - if(bNewPsState) - { - // will enter LPS state, turn off psTdma first - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - // keep state under NO PS state, do nothing. - } - } -} - -VOID -halbtc8821a2ant_PowerSaveState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte psType, - IN u1Byte lpsVal, - IN u1Byte rpwmVal - ) -{ - BOOLEAN bLowPwrDisable=FALSE; - - switch(psType) - { - case BTC_PS_WIFI_NATIVE: - // recover to original 32k low power setting - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_NORMAL_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - case BTC_PS_LPS_ON: - halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, TRUE); - halbtc8821a2ant_LpsRpwm(pBtCoexist, NORMAL_EXEC, lpsVal, rpwmVal); - // when coex force to enter LPS, do not enter 32k low power. - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - // power save must executed before psTdma. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_ENTER_LPS, NULL); - pCoexSta->bForceLpsOn = TRUE; - break; - case BTC_PS_LPS_OFF: - halbtc8821a2ant_PsTdmaCheckForPowerSaveState(pBtCoexist, FALSE); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_LEAVE_LPS, NULL); - pCoexSta->bForceLpsOn = FALSE; - break; - default: - break; - } -} - - -VOID -halbtc8821a2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8821a2ant_CoexUnder5G( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a2ant_CoexAllOff(pBtCoexist); - - halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE); -} - -VOID -halbtc8821a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, 0); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8821a2ant_ActionBtInquiry( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - BOOLEAN bWifiConnected=FALSE; - BOOLEAN bLowPwrDisable=TRUE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi link process + BT Inq/Page!!\n")); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT Inq/Page!!\n")); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi no-link + BT Inq/Page!!\n")); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - -} - - -VOID -halbtc8821a2ant_ActionWiFiLinkProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte u1Tmpa, u1Tmpb; - - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 15); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - - - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb)); -} - -BOOLEAN -halbtc8821a2ant_ActionWifiIdleProcess( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES-20, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if(BTC_RSSI_HIGH(wifiRssiState1) && - (pCoexSta->bHidExist == TRUE) && (pCoexSta->bA2dpExist == TRUE)) - { - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT HID+A2DP exist!!\n")); - - halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - return TRUE; - } - - // - else if (pCoexSta->bPanExist== TRUE) - { - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi idle process for BT PAN exist!!\n")); - - halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - return TRUE; - } - - else - { - halbtc8821a2ant_DacSwing(pBtCoexist, NORMAL_EXEC, TRUE, 0x18); - return FALSE; - } - - -} - - - -BOOLEAN -halbtc8821a2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte btRssiState=BTC_RSSI_STATE_HIGH; - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bBtHsOn=FALSE, bLowPwrDisable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi non-connected idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - if(BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT non connected-idle!!\n")); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else if(BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bBtHsOn) - return FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi connected + BT connected-idle!!\n")); - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xb); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - bCommon = TRUE; - } - else - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Busy + BT Busy!!\n")); - bCommon = FALSE; - //bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Connected-Idle + BT Busy!!\n")); - //bCommon = FALSE; - bCommon = halbtc8821a2ant_ActionWifiIdleProcess(pBtCoexist); - } - } - } - - return bCommon; -} -VOID -halbtc8821a2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(!pCoexDm->bAutoTdmaAdjust) - { - pCoexDm->bAutoTdmaAdjust = TRUE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 71) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 71) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } -} - -// SCO only or SCO+PAN(HS) -VOID -halbtc8821a2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - else //for SCO quality & wifi performance balance at 11n mode - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 8); - else - { - if(pBtLinkInfo->bScoOnly) - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 17); - else - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12); - } - } - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18); - } - } -} - - -VOID -halbtc8821a2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 2); - } - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 24); - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8821a2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - - // define the office environment - if( (apNum >= 10) && BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - //DbgPrint(" AP#>10(%d)\n", apNum); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - //halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,TRUE,0x6); - } - return; - - } - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - } - else - { - //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821a2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821a2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 10); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 26); - } - else - { - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 26); - } - - // sw mechanism - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - - -//PAN(HS) only -VOID -halbtc8821a2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8821a2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - else - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 12); - - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - else - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 13); - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821a2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3); - //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 11); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); - } - else - { - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - } - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - } - else - { - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - //halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8821a2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,wifiRssiState1, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(2, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 0); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, FALSE, 0x8); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(BTC_WIFI_BW_HT40 == wifiBw) - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - else - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else - { - halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821a2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, wifiRssiState1, btRssiState; - u4Byte wifiBw; - u1Byte apNum=0; - - wifiRssiState = halbtc8821a2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - //btRssiState = halbtc8821a2ant_BtRssiState(2, 29, 0); - wifiRssiState1 = halbtc8821a2ant_WifiRssiState(pBtCoexist, 1, 2, BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0); - btRssiState = halbtc8821a2ant_BtRssiState(3, BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES, 37); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - - halbtc8821a2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x5); - - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_LEGACY == wifiBw) - { - if(BTC_RSSI_HIGH(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - else - { // only 802.11N mode we have to dec bt power to 4 degree - if(BTC_RSSI_HIGH(btRssiState)) - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - // need to check ap Number of Not - if(apNum < 10) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 4); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - } - else if(BTC_RSSI_MEDIUM(btRssiState)) - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 2); - else - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - } - - if (BTC_RSSI_HIGH(wifiRssiState1) && BTC_RSSI_HIGH(btRssiState)) - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 7); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - } - else - { - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 14); - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_LPS_ON, 0x50, 0x4); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - } - else - { - //halbtc8821a2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - } - - // sw mechanism - if(BTC_WIFI_BW_HT40 == wifiBw) - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821a2ant_ActionBtWhckTest( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); -} - -VOID -halbtc8821a2ant_ActionWifiMultiPort( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821a2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821a2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, 0); - - // sw all off - halbtc8821a2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821a2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - //pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x0); - halbtc8821a2ant_CoexTableWithType(pBtCoexist, NORMAL_EXEC, 0); - - halbtc8821a2ant_PowerSaveState(pBtCoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0); - halbtc8821a2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); -} - -VOID -halbtc8821a2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bWifiUnder5G=FALSE, bBtHsOn=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - u4Byte numOfWifiLink=0; - u4Byte wifiLinkStatus=0; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - BOOLEAN bMiracastPlusBt=FALSE; - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism()===>\n")); - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), return for Manual CTRL <===\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - if(bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n")); - halbtc8821a2ant_CoexUnder5G(pBtCoexist); - return; - } - - if(pCoexSta->bUnderIps) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi is under IPS !!!\n")); - return; - } - - if(pCoexSta->bBtWhckTest) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under WHCK TEST!!!\n")); - halbtc8821a2ant_ActionBtWhckTest(pBtCoexist); - return; - } - - algorithm = halbtc8821a2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8821A_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8821a2ant_ActionBtInquiry(pBtCoexist); - return; - } - else - { - - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if(bScan || bLink || bRoam) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], WiFi is under Link Process !!\n")); - halbtc8821a2ant_ActionWiFiLinkProcess(pBtCoexist); - return; - } - - //for P2P - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus); - numOfWifiLink = wifiLinkStatus>>16; - - if((numOfWifiLink>=2) || (wifiLinkStatus&WIFI_P2P_GO_CONNECTED)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], Multi-Port numOfWifiLink = %d, wifiLinkStatus = 0x%x\n", numOfWifiLink,wifiLinkStatus) ); - - if(pBtLinkInfo->bBtLinkExist) - { - bMiracastPlusBt = TRUE; - } - else - { - bMiracastPlusBt = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - halbtc8821a2ant_ActionWifiMultiPort(pBtCoexist); - - return; - } - else - { - bMiracastPlusBt = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_MIRACAST_PLUS_BT, &bMiracastPlusBt); - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8821a2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bAutoTdmaAdjust = FALSE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8821A_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8821a2ant_ActionSco(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8821a2ant_ActionHid(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8821a2ant_ActionA2dp(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8821a2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8821a2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8821a2ant_ActionPanHs(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8821a2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8821a2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8821a2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8821A_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8821a2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8821a2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } -} - -VOID -halbtc8821a2ant_WifiOffHwCfg( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bIsInMpMode = FALSE; - u1Byte H2C_Parameter[2] ={0}; - u4Byte fwVer=0; - - // set wlan_act to low - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1, 0xfffff, 0x780); //WiFi goto standby while GNT_BT 0-->1 - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - if(fwVer >= 0x180000) - { - /* Use H2C to set GNT_BT to HIGH */ - H2C_Parameter[0] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x6E, 1, H2C_Parameter); - } - else - { - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x765, 0x18); - } -} - -VOID -halbtc8821a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bBackUp - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0, fwVer; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = - pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - - //Antenna config - halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE); - pCoexSta->disVerInfoCnt = 0; - - // PTA parameter - halbtc8821a2ant_CoexTableWithType(pBtCoexist, FORCE_EXEC, 0); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x4); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); -} - -//============================================================ -// work around function start with wa_halbtc8821a2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8821a2ant_ -//============================================================ -VOID -EXhalbtc8821a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ - -} - -VOID -EXhalbtc8821a2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u1Byte u1Tmp=0x4; /* Set BIT2 by default since it's 2ant case */ - - // - // S0 or S1 setting and Local register setting(By the setting fw can get ant number, S0/S1, ... info) - // Local setting bit define - // BIT0: "0" for no antenna inverse; "1" for antenna inverse - // BIT1: "0" for internal switch; "1" for external switch - // BIT2: "0" for one antenna; "1" for two antenna - // NOTE: here default all internal switch and 1-antenna ==> BIT1=0 and BIT2=0 - if(pBtCoexist->chipInterface == BTC_INTF_USB) - { - // fixed at S0 for USB interface - u1Tmp |= 0x1; // antenna inverse - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0xfe08, u1Tmp); - } - else - { - // for PCIE and SDIO interface, we check efuse 0xc3[6] - if(pBoardInfo->singleAntPath == 0) - { - } - else if(pBoardInfo->singleAntPath == 1) - { - // set to S0 - u1Tmp |= 0x1; // antenna inverse - } - - if(pBtCoexist->chipInterface == BTC_INTF_PCI) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x384, u1Tmp); - } - else if(pBtCoexist->chipInterface == BTC_INTF_SDIO) - { - pBtCoexist->fBtcWriteLocalReg1Byte(pBtCoexist, 0x60, u1Tmp); - } - } -} - -VOID -EXhalbtc8821a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - halbtc8821a2ant_InitHwConfig(pBtCoexist, TRUE); -} - -VOID -EXhalbtc8821a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8821a2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8821a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte faOfdm, faCck; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %ddBm/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled)? ("disabled"): ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus)? "non-connected idle": - ( (BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy")))), - pCoexSta->btRssi-100, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, pBtLinkInfo->bHidExist, pBtLinkInfo->bPanExist, pBtLinkInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) - { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", \ - (pBtLinkInfo->bSlaveRole )? "Slave":"Master"); - CL_PRINTF(cliBuf); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821a2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", \ - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xc5b); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x880[29:25]/0xc58[29:25]", \ - u1Tmp[0], (u4Tmp[0]&0x3e000000) >> 25, ((u1Tmp[1]&0x3e)>>1)); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x764); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x764/ 0x765/ 0x76e", \ - (u4Tmp[0]&0xff), (u4Tmp[0]&0xff00)>>8, u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", \ - u4Tmp[0]&0xff, ((u4Tmp[0]&0x30000000)>>28)); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x974); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/ 0x4c[24:23]/ 0x974", \ - u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u4Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ - u4Tmp[0]&0xff, u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = ((u4Tmp[0]&0xffff0000) >> 16) + ((u4Tmp[1]&0xffff0000) >> 16) + (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3]&0xffff0000) >> 16) + (u4Tmp[3] & 0xffff) ; - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[0]&0xffff, faOfdm, faCck); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCOK_CCK, pCoexSta->nCRCOK_11g, pCoexSta->nCRCOK_11n, pCoexSta->nCRCOK_11nAgg); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", \ - pCoexSta->nCRCErr_CCK, pCoexSta->nCRCErr_11g, pCoexSta->nCRCErr_11n, pCoexSta->nCRCErr_11nAgg); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2], u1Tmp[0]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); -#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 1) - //halbtc8821a2ant_MonitorBtCtr(pBtCoexist); -#endif - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8821a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8821a2ant_WifiOffHwCfg(pBtCoexist); - halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - halbtc8821a2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8821a2ant_InitCoexDm(pBtCoexist); - halbtc8821a2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8821a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8821a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte u1Tmpa, u1Tmpb; - - u1Tmpa = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - u1Tmpb = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } - - RT_TRACE(COMP_COEX, DBG_LOUD, ("############# [BTCoex], 0x765=0x%x, 0x76e=0x%x\n", u1Tmpa, u1Tmpb)); -} - -VOID -EXhalbtc8821a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8821a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - u1Byte apNum=0; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - { - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - if(apNum < 10) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - } - - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); -} - -VOID -EXhalbtc8821a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8821a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - PBTC_BT_LINK_INFO pBtLinkInfo=&pBtCoexist->btLinkInfo; - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE, bWifiUnder5G=FALSE; - static BOOLEAN bPreScoExist=FALSE; - u4Byte raMask=0x0; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8821A_2ANT_MAX) - rspSource = BT_INFO_SRC_8821A_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), return for Manual CTRL<===\n")); - return; - } - - // if 0xff, it means BT is under WHCK test - if (btInfo == 0xff) - pCoexSta->bBtWhckTest = TRUE; - else - pCoexSta->bBtWhckTest = FALSE; - - if(BT_INFO_SRC_8821A_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - pCoexSta->bBtTxRxMask = (pCoexSta->btInfoC2h[rspSource][2]&0x40); - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TX_RX_MASK, &pCoexSta->bBtTxRxMask); - if(pCoexSta->bBtTxRxMask) - { - /* BT into is responded by BT FW and BT RF REG 0x3C != 0x01 => Need to switch BT TRx Mask */ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Switch BT TRx Mask since BT RF REG 0x3C != 0x01\n")); - pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x01); - } - - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit1 check, send wifi BW&Chnl to BT!!\n")); - if(bWifiConnected) - { - EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - - - if(!pBtCoexist->bManualControl && !bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info = 0x%x!!\n", pCoexSta->btInfoExt)); - if( (pCoexSta->btInfoExt&BIT3) ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=1, bWifiConnected=%d\n", bWifiConnected)); - if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3=0, bWifiConnected=%d\n", bWifiConnected)); - // BT already NOT ignore Wlan active, do nothing here. - if(!bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n")); - halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - } - } - } - -#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0) - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8821a2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } -#endif - } - - // check BIT2 first ==> check if bt is under inquiry or page scan - if(btInfo & BT_INFO_8821A_2ANT_B_INQ_PAGE) - pCoexSta->bC2hBtInquiryPage = TRUE; - else - pCoexSta->bC2hBtInquiryPage = FALSE; - - // set link exist status - if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION)) - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - } - else // connection exists - { - pCoexSta->bBtLinkExist = TRUE; - if(btInfo & BT_INFO_8821A_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - if(btInfo & BT_INFO_8821A_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - if(btInfo & BT_INFO_8821A_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - if(btInfo & BT_INFO_8821A_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - - if ( (pCoexSta->bHidExist == FALSE) && (pCoexSta->bC2hBtInquiryPage == FALSE) && (pCoexSta->bScoExist == FALSE)) - { - if (pCoexSta->highPriorityTx + pCoexSta->highPriorityRx >= 160) - pCoexSta->bHidExist = TRUE; - } - } - - halbtc8821a2ant_UpdateBtLinkInfo(pBtCoexist); - - if(!(btInfo&BT_INFO_8821A_2ANT_B_CONNECTION)) - { - pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Connected idle!!!\n")); - } - else if(btInfo == BT_INFO_8821A_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Connected-idle!!!\n")); - } - else if((btInfo&BT_INFO_8821A_2ANT_B_SCO_ESCO) || - (btInfo&BT_INFO_8821A_2ANT_B_SCO_BUSY)) - { - pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_SCO_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT SCO busy!!!\n")); - } - else if(btInfo&BT_INFO_8821A_2ANT_B_ACL_BUSY) - { - pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_ACL_BUSY; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT ACL busy!!!\n")); - } - else - { - pCoexDm->btStatus = BT_8821A_2ANT_BT_STATUS_MAX; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BtInfoNotify(), BT Non-Defined state!!!\n")); - } - - if( (BT_8821A_2ANT_BT_STATUS_ACL_BUSY == pCoexDm->btStatus) || - (BT_8821A_2ANT_BT_STATUS_SCO_BUSY == pCoexDm->btStatus) || - (BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY == pCoexDm->btStatus) ) - { - bBtBusy = TRUE; - bLimitedDig = TRUE; - } - else - { - bBtBusy = FALSE; - bLimitedDig = FALSE; - } - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8821a2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8821a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8821a2ant_WifiOffHwCfg(pBtCoexist); - //remove due to interrupt is disabled that polling c2h will fail and delay 100ms. - //pBtCoexist->fBtcSetBtReg(pBtCoexist, BTC_BT_REG_RF, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0 - halbtc8821a2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - - EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8821a2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - halbtc8821a2ant_InitHwConfig(pBtCoexist, FALSE); - halbtc8821a2ant_InitCoexDm(pBtCoexist); - halbtc8821a2ant_QueryBtInfo(pBtCoexist); - } -} - -VOID -EXhalbtc8821a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - //static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(pCoexSta->disVerInfoCnt <= 5) - { - pCoexSta->disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8821a2Ant, GLCoexVer8821a2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - - if (pCoexSta->disVerInfoCnt == 3) - { - //Antenna config to set 0x765 = 0x0 (GNT_BT control by PTA) after initial - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Set GNT_BT control by PTA\n")); - halbtc8821a2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, FALSE, FALSE); - } - } - -#if(BT_AUTO_REPORT_ONLY_8821A_2ANT == 0) - halbtc8821a2ant_QueryBtInfo(pBtCoexist); - halbtc8821a2ant_MonitorBtEnableDisable(pBtCoexist); -#else - halbtc8821a2ant_MonitorBtCtr(pBtCoexist); - halbtc8821a2ant_MonitorWiFiCtr(pBtCoexist); - - if( halbtc8821a2ant_IsWifiStatusChanged(pBtCoexist) || - pCoexDm->bAutoTdmaAdjust) - { - halbtc8821a2ant_RunCoexistMechanism(pBtCoexist); - } -#endif -} - - -#endif - -#else // #if (RTL8821A_SUPPORT == 1) -VOID -EXhalbtc8821a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8821a2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8821a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ){} -VOID -EXhalbtc8821a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8821a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ){} -VOID -EXhalbtc8821a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ){} -VOID -EXhalbtc8821a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8821a2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ){} -VOID -EXhalbtc8821a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ){} -VOID -EXhalbtc8821a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ){} -#endif // #if (RTL8821A_SUPPORT == 1) \ No newline at end of file diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.h deleted file mode 100644 index 7964b3455..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821a2Ant.h +++ /dev/null @@ -1,227 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8821A 2Ant BT Co-exist definition -//=========================================== -#define BT_AUTO_REPORT_ONLY_8821A_2ANT 1 - - -#define BT_INFO_8821A_2ANT_B_FTP BIT7 -#define BT_INFO_8821A_2ANT_B_A2DP BIT6 -#define BT_INFO_8821A_2ANT_B_HID BIT5 -#define BT_INFO_8821A_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8821A_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8821A_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8821A_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8821A_2ANT_B_CONNECTION BIT0 - -#define BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT 2 - - -#define BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42 //WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation -#define BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES 46 //BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation - -typedef enum _BT_INFO_SRC_8821A_2ANT{ - BT_INFO_SRC_8821A_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8821A_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8821A_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8821A_2ANT_MAX -}BT_INFO_SRC_8821A_2ANT,*PBT_INFO_SRC_8821A_2ANT; - -typedef enum _BT_8821A_2ANT_BT_STATUS{ - BT_8821A_2ANT_BT_STATUS_NON_CONNECTED_IDLE = 0x0, - BT_8821A_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8821A_2ANT_BT_STATUS_INQ_PAGE = 0x2, - BT_8821A_2ANT_BT_STATUS_ACL_BUSY = 0x3, - BT_8821A_2ANT_BT_STATUS_SCO_BUSY = 0x4, - BT_8821A_2ANT_BT_STATUS_ACL_SCO_BUSY = 0x5, - BT_8821A_2ANT_BT_STATUS_MAX -}BT_8821A_2ANT_BT_STATUS,*PBT_8821A_2ANT_BT_STATUS; - -typedef enum _BT_8821A_2ANT_COEX_ALGO{ - BT_8821A_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8821A_2ANT_COEX_ALGO_SCO = 0x1, - BT_8821A_2ANT_COEX_ALGO_HID = 0x2, - BT_8821A_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8821A_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8821A_2ANT_COEX_ALGO_PANEDR = 0x5, - BT_8821A_2ANT_COEX_ALGO_PANHS = 0x6, - BT_8821A_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8821A_2ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8821A_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8821A_2ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8821A_2ANT_COEX_ALGO_MAX = 0xb, -}BT_8821A_2ANT_COEX_ALGO,*PBT_8821A_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8821A_2ANT{ - // fw mechanism - u1Byte preBtDecPwrLvl; - u1Byte curBtDecPwrLvl; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[5]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bAutoTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; - - BOOLEAN bNeedRecover0x948; - u4Byte backup0x948; - - u1Byte preLps; - u1Byte curLps; - u1Byte preRpwm; - u1Byte curRpwm; -} COEX_DM_8821A_2ANT, *PCOEX_DM_8821A_2ANT; - -typedef struct _COEX_STA_8821A_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - BOOLEAN bBtTxRxMask; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8821A_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8821A_2ANT_MAX]; - BOOLEAN bBtWhckTest; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; - - u4Byte nCRCOK_CCK; - u4Byte nCRCOK_11g; - u4Byte nCRCOK_11n; - u4Byte nCRCOK_11nAgg; - - u4Byte nCRCErr_CCK; - u4Byte nCRCErr_11g; - u4Byte nCRCErr_11n; - u4Byte nCRCErr_11nAgg; - - u1Byte nCoexTableType; - BOOLEAN bForceLpsOn; - - u1Byte disVerInfoCnt; -}COEX_STA_8821A_2ANT, *PCOEX_STA_8821A_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8821a2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a2ant_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8821a2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821a2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8821a2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8821a2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821a2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.c b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.c deleted file mode 100644 index 5a0145c3c..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.c +++ /dev/null @@ -1,4344 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//============================================================ -// Description: -// -// This file is for RTL8821A_CSR_CSR Co-exist mechanism -// -// History -// 2012/08/22 Cosa first check in. -// 2012/11/14 Cosa Revise for 8821A_CSR 2Ant out sourcing. -// -//============================================================ - -//============================================================ -// include files -//============================================================ -#include "Mp_Precomp.h" - -#if WPP_SOFTWARE_TRACE -#include "HalBtcCsr8821a2Ant.tmh" -#endif - -#define _BTCOEX_CSR 1 - -#ifndef rtw_warn_on - #define rtw_warn_on(condition) do {} while (0) -#endif - -#if(BT_30_SUPPORT == 1) -//============================================================ -// Global variables, these are static variables -//============================================================ -static COEX_DM_8821A_CSR_2ANT GLCoexDm8821aCsr2Ant; -static PCOEX_DM_8821A_CSR_2ANT pCoexDm=&GLCoexDm8821aCsr2Ant; -static COEX_STA_8821A_CSR_2ANT GLCoexSta8821aCsr2Ant; -static PCOEX_STA_8821A_CSR_2ANT pCoexSta=&GLCoexSta8821aCsr2Ant; - -const char *const GLBtInfoSrc8821aCsr2Ant[]={ - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - -u4Byte GLCoexVerDate8821aCsr2Ant=20140901; -u4Byte GLCoexVer8821aCsr2Ant=0x51; - -//============================================================ -// local function proto type if needed -//============================================================ -//============================================================ -// local function start with halbtc8821aCsr2ant_ -//============================================================ -u1Byte -halbtc8821aCsr2ant_BtRssiState( - u1Byte levelNum, - u1Byte rssiThresh, - u1Byte rssiThresh1 - ) -{ - s4Byte btRssi=0; - u1Byte btRssiState=pCoexSta->preBtRssiState; - - btRssi = pCoexSta->btRssi; - - if(levelNum == 2) - { - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT Rssi thresh error!!\n")); - return pCoexSta->preBtRssiState; - } - - if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_LOW) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_LOW)) - { - if(btRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preBtRssiState == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preBtRssiState == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(btRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - btRssiState = BTC_RSSI_STATE_HIGH; - } - else if(btRssi < rssiThresh) - { - btRssiState = BTC_RSSI_STATE_LOW; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(btRssi < rssiThresh1) - { - btRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - btRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preBtRssiState = btRssiState; - - return btRssiState; -} - -u1Byte -halbtc8821aCsr2ant_WifiRssiState( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte index, - IN u1Byte levelNum, - IN u1Byte rssiThresh, - IN u1Byte rssiThresh1 - ) -{ - s4Byte wifiRssi=0; - u1Byte wifiRssiState=pCoexSta->preWifiRssiState[index]; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - - if(levelNum == 2) - { - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else - { - if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - else if(levelNum == 3) - { - if(rssiThresh > rssiThresh1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], wifi RSSI thresh error!!\n")); - return pCoexSta->preWifiRssiState[index]; - } - - if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_LOW) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_LOW)) - { - if(wifiRssi >= (rssiThresh+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_LOW; - } - } - else if( (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_MEDIUM) || - (pCoexSta->preWifiRssiState[index] == BTC_RSSI_STATE_STAY_MEDIUM)) - { - if(wifiRssi >= (rssiThresh1+BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT)) - { - wifiRssiState = BTC_RSSI_STATE_HIGH; - } - else if(wifiRssi < rssiThresh) - { - wifiRssiState = BTC_RSSI_STATE_LOW; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_MEDIUM; - } - } - else - { - if(wifiRssi < rssiThresh1) - { - wifiRssiState = BTC_RSSI_STATE_MEDIUM; - } - else - { - wifiRssiState = BTC_RSSI_STATE_STAY_HIGH; - } - } - } - - pCoexSta->preWifiRssiState[index] = wifiRssiState; - - return wifiRssiState; -} - -VOID -halbtc8821aCsr2ant_MonitorBtEnableDisable( - IN PBTC_COEXIST pBtCoexist - ) -{ - static BOOLEAN bPreBtDisabled=FALSE; - static u4Byte btDisableCnt=0; - BOOLEAN bBtActive=TRUE, bBtDisabled=FALSE; - - // This function check if bt is disabled - - if( pCoexSta->highPriorityTx == 0 && - pCoexSta->highPriorityRx == 0 && - pCoexSta->lowPriorityTx == 0 && - pCoexSta->lowPriorityRx == 0) - { - bBtActive = FALSE; - } - if( pCoexSta->highPriorityTx == 0xffff && - pCoexSta->highPriorityRx == 0xffff && - pCoexSta->lowPriorityTx == 0xffff && - pCoexSta->lowPriorityRx == 0xffff) - { - bBtActive = FALSE; - } - if(bBtActive) - { - btDisableCnt = 0; - bBtDisabled = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is enabled !!\n")); - } - else - { - btDisableCnt++; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], bt all counters=0, %d times!!\n", - btDisableCnt)); - if(btDisableCnt >= 2) - { - bBtDisabled = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_DISABLE, &bBtDisabled); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is disabled !!\n")); - } - } - if(bPreBtDisabled != bBtDisabled) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is from %s to %s!!\n", - (bPreBtDisabled ? "disabled":"enabled"), - (bBtDisabled ? "disabled":"enabled"))); - bPreBtDisabled = bBtDisabled; - if(!bBtDisabled) - { - } - else - { - } - } -} - -VOID -halbtc8821aCsr2ant_MonitorBtCtr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u4Byte regHPTxRx, regLPTxRx, u4Tmp; - u4Byte regHPTx=0, regHPRx=0, regLPTx=0, regLPRx=0; - u1Byte u1Tmp; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord)>>16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord)>>16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], High Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regHPTxRx, regHPTx, regHPTx, regHPRx, regHPRx)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Low Priority Tx/Rx (reg 0x%x)=0x%x(%d)/0x%x(%d)\n", - regLPTxRx, regLPTx, regLPTx, regLPRx, regLPRx)); - - // reset counter - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0x5d); -} - -VOID -halbtc8821aCsr2ant_UpdateRaMask( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte disRateMask - ) -{ - pCoexDm->curRaMask = disRateMask; - - if( bForceExec || (pCoexDm->preRaMask != pCoexDm->curRaMask)) - { - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_UPDATE_RAMASK, &pCoexDm->curRaMask); - } - pCoexDm->preRaMask = pCoexDm->curRaMask; -} - -VOID -halbtc8821aCsr2ant_AutoRateFallbackRetry( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - BOOLEAN bWifiUnderBMode=FALSE; - - pCoexDm->curArfrType = type; - - if( bForceExec || (pCoexDm->preArfrType != pCoexDm->curArfrType)) - { - switch(pCoexDm->curArfrType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, pCoexDm->backupArfrCnt1); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, pCoexDm->backupArfrCnt2); - break; - case 1: - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - if(bWifiUnderBMode) - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x01010101); - } - else - { - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x430, 0x0); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x434, 0x04030201); - } - break; - default: - break; - } - } - - pCoexDm->preArfrType = pCoexDm->curArfrType; -} - -VOID -halbtc8821aCsr2ant_RetryLimit( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curRetryLimitType = type; - - if( bForceExec || (pCoexDm->preRetryLimitType != pCoexDm->curRetryLimitType)) - { - switch(pCoexDm->curRetryLimitType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, pCoexDm->backupRetryLimit); - break; - case 1: // retry limit=8 - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x42a, 0x0808); - break; - default: - break; - } - } - - pCoexDm->preRetryLimitType = pCoexDm->curRetryLimitType; -} - -VOID -halbtc8821aCsr2ant_AmpduMaxTime( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduTimeType = type; - - if( bForceExec || (pCoexDm->preAmpduTimeType != pCoexDm->curAmpduTimeType)) - { - switch(pCoexDm->curAmpduTimeType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, pCoexDm->backupAmpduMaxTime); - break; - case 1: // AMPDU timw = 0x38 * 32us - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x38); - break; - case 2: - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x456, 0x17); - break; - default: - break; - } - } - - pCoexDm->preAmpduTimeType = pCoexDm->curAmpduTimeType; -} - -VOID -halbtc8821aCsr2Ant_AmpduMaxNum( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte type - ) -{ - pCoexDm->curAmpduNumType = type; - - if( bForceExec || (pCoexDm->preAmpduNumType != pCoexDm->curAmpduNumType)) - { - switch(pCoexDm->curAmpduNumType) - { - case 0: // normal mode - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x4ca, pCoexDm->backupAmpduMaxNum); - break; - case 1: - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x4ca, 0x0808); - break; - case 2: - pBtCoexist->fBtcWrite2Byte(pBtCoexist, 0x4ca, 0x1f1f); - break; - default: - break; - } - } - - pCoexDm->preAmpduNumType = pCoexDm->curAmpduNumType; - -} - -VOID -halbtc8821aCsr2ant_LimitedTx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte raMaskType, - IN u1Byte arfrType, - IN u1Byte retryLimitType, - IN u1Byte ampduTimeType, - IN u1Byte ampduNumType - ) -{ - switch(raMaskType) - { - case 0: // normal mode - halbtc8821aCsr2ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0); - break; - case 1: // disable cck 1/2 - halbtc8821aCsr2ant_UpdateRaMask(pBtCoexist, bForceExec, 0x00000003); - break; - case 2: // disable cck 1/2/5.5, ofdm 6/9/12/18/24, mcs 0/1/2/3/4 - halbtc8821aCsr2ant_UpdateRaMask(pBtCoexist, bForceExec, 0x0001f1f7); - break; - default: - break; - } - - halbtc8821aCsr2ant_AutoRateFallbackRetry(pBtCoexist, bForceExec, arfrType); - halbtc8821aCsr2ant_RetryLimit(pBtCoexist, bForceExec, retryLimitType); - halbtc8821aCsr2ant_AmpduMaxTime(pBtCoexist, bForceExec, ampduTimeType); - halbtc8821aCsr2Ant_AmpduMaxNum(pBtCoexist, bForceExec, ampduNumType); -} - - - -VOID -halbtc8821aCsr2ant_LimitedRx( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRejApAggPkt, - IN BOOLEAN bBtCtrlAggBufSize, - IN u1Byte aggBufSize - ) -{ - BOOLEAN bRejectRxAgg=bRejApAggPkt; - BOOLEAN bBtCtrlRxAggSize=bBtCtrlAggBufSize; - u1Byte rxAggSize=aggBufSize; - - //============================================ - // Rx Aggregation related setting - //============================================ - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_TO_REJ_AP_AGG_PKT, &bRejectRxAgg); - // decide BT control aggregation buf size or not - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_CTRL_AGG_SIZE, &bBtCtrlRxAggSize); - // aggregation buf size, only work when BT control Rx aggregation size. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_AGG_BUF_SIZE, &rxAggSize); - // real update aggregation setting - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); -} - -VOID -halbtc8821aCsr2ant_QueryBtInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - pCoexSta->bC2hBtInfoReqSent = TRUE; - - H2C_Parameter[0] |= BIT0; // trigger - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Query Bt Info, FW write 0x61=0x%x\n", - H2C_Parameter[0])); - - rtw_warn_on(_BTCOEX_CSR); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x61, 1, H2C_Parameter); -} - -u1Byte -halbtc8821aCsr2ant_ActionAlgorithm( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bBtHsOn=FALSE; - u1Byte algorithm=BT_8821A_CSR_2ANT_COEX_ALGO_UNDEFINED; - u1Byte numOfDiffProfile=0; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - //sync StackInfo with BT firmware and stack - pStackInfo->bHidExist = pCoexSta->bHidExist; - pStackInfo->bBtLinkExist = pCoexSta->bBtLinkExist; - pStackInfo->bScoExist = pCoexSta->bScoExist; - pStackInfo->bPanExist = pCoexSta->bPanExist; - pStackInfo->bA2dpExist = pCoexSta->bA2dpExist; - - if(!pStackInfo->bBtLinkExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], No profile exists!!!\n")); - return algorithm; - } - - if(pStackInfo->bScoExist) - numOfDiffProfile++; - if(pStackInfo->bHidExist) - numOfDiffProfile++; - if(pStackInfo->bPanExist) - numOfDiffProfile++; - if(pStackInfo->bA2dpExist) - numOfDiffProfile++; - - if(numOfDiffProfile == 1) - { - if(pStackInfo->bScoExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO only\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_SCO; - } - else - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID only\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP only\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_A2DP; - } - else if(pStackInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(HS) only\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PAN(EDR) only\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR; - } - } - } - } - else if(numOfDiffProfile == 2) - { - if(pStackInfo->bScoExist) - { - if(pStackInfo->bHidExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pStackInfo->bA2dpExist) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP ==> SCO\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - else if(pStackInfo->bPanExist) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_SCO; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + PAN(EDR)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - if(pStackInfo->numOfHid >= 2) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID*2 + A2DP\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP; - } - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + PAN(EDR)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_A2DP_PANHS; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_A2DP; - } - } - } - } - else if(numOfDiffProfile == 3) - { - if(pStackInfo->bScoExist) - { - if( pStackInfo->bHidExist && - pStackInfo->bA2dpExist ) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP ==> HID\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - else if( pStackInfo->bHidExist && - pStackInfo->bPanExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + PAN(EDR)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - } - else if( pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + A2DP + PAN(EDR) ==> HID\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - else - { - if( pStackInfo->bHidExist && - pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(HS)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], HID + A2DP + PAN(EDR)\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP_PANEDR; - } - } - } - } - else if(numOfDiffProfile >= 3) - { - if(pStackInfo->bScoExist) - { - if( pStackInfo->bHidExist && - pStackInfo->bPanExist && - pStackInfo->bA2dpExist ) - { - if(bBtHsOn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Error!!! SCO + HID + A2DP + PAN(HS)\n")); - - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCO + HID + A2DP + PAN(EDR)==>PAN(EDR)+HID\n")); - algorithm = BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID; - } - } - } - } - - return algorithm; -} - -BOOLEAN -halbtc8821aCsr2ant_NeedToDecBtPwr( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bRet=FALSE; - BOOLEAN bBtHsOn=FALSE, bWifiConnected=FALSE; - s4Byte btHsRssi=0; - u1Byte btRssiState; - - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn)) - return FALSE; - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected)) - return FALSE; - if(!pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi)) - return FALSE; - - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - if(bWifiConnected) - { - if(bBtHsOn) - { - if(btHsRssi > 37) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for HS mode!!\n")); - bRet = TRUE; - } - } - else - { - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Need to decrease bt power for Wifi is connected!!\n")); - bRet = TRUE; - } - } - } - - return bRet; -} - -VOID -halbtc8821aCsr2ant_SetFwDacSwingLevel( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte dacSwingLvl - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - // There are several type of dacswing - // 0x18/ 0x10/ 0xc/ 0x8/ 0x4/ 0x6 - H2C_Parameter[0] = dacSwingLvl; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Set Dac Swing Level=0x%x\n", dacSwingLvl)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x64=0x%x\n", H2C_Parameter[0])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x64, 1, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_SetFwDecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bDecBtPwr - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bDecBtPwr) - { - H2C_Parameter[0] |= BIT1; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], decrease Bt Power : %s, FW write 0x62=0x%x\n", - (bDecBtPwr? "Yes!!":"No!!"), H2C_Parameter[0])); - - rtw_warn_on(_BTCOEX_CSR); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x62, 1, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_DecBtPwr( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDecBtPwr - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s Dec BT power = %s\n", - (bForceExec? "force to":""), ((bDecBtPwr)? "ON":"OFF"))); - pCoexDm->bCurDecBtPwr = bDecBtPwr; - - if(!bForceExec) - { - if(pCoexDm->bPreDecBtPwr == pCoexDm->bCurDecBtPwr) - return; - } - - /* TODO: may CSR consider to decrease BT power? */ - //halbtc8821aCsr2ant_SetFwDecBtPwr(pBtCoexist, pCoexDm->bCurDecBtPwr); - - pCoexDm->bPreDecBtPwr = pCoexDm->bCurDecBtPwr; -} - -VOID -halbtc8821aCsr2ant_SetBtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnableAutoReport - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - H2C_Parameter[0] = 0; - - if(bEnableAutoReport) - { - H2C_Parameter[0] |= BIT0; - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], BT FW auto report : %s, FW write 0x68=0x%x\n", - (bEnableAutoReport? "Enabled!!":"Disabled!!"), H2C_Parameter[0])); - - rtw_warn_on(_BTCOEX_CSR); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x68, 1, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_BtAutoReport( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnableAutoReport - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s BT Auto report = %s\n", - (bForceExec? "force to":""), ((bEnableAutoReport)? "Enabled":"Disabled"))); - pCoexDm->bCurBtAutoReport = bEnableAutoReport; - - if(!bForceExec) - { - if(pCoexDm->bPreBtAutoReport == pCoexDm->bCurBtAutoReport) - return; - } - //halbtc8821aCsr2ant_SetBtAutoReport(pBtCoexist, pCoexDm->bCurBtAutoReport); - - pCoexDm->bPreBtAutoReport = pCoexDm->bCurBtAutoReport; -} - -VOID -halbtc8821aCsr2ant_FwDacSwingLvl( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u1Byte fwDacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s set FW Dac Swing level = %d\n", - (bForceExec? "force to":""), fwDacSwingLvl)); - pCoexDm->curFwDacSwingLvl = fwDacSwingLvl; - - if(!bForceExec) - { - if(pCoexDm->preFwDacSwingLvl == pCoexDm->curFwDacSwingLvl) - return; - } - - halbtc8821aCsr2ant_SetFwDacSwingLevel(pBtCoexist, pCoexDm->curFwDacSwingLvl); - - pCoexDm->preFwDacSwingLvl = pCoexDm->curFwDacSwingLvl; -} - -VOID -halbtc8821aCsr2ant_SetSwRfRxLpfCorner( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bRxRfShrinkOn - ) -{ - if(bRxRfShrinkOn) - { - //Shrink RF Rx LPF corner - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Shrink RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, 0xffffc); - } - else - { - //Resume RF Rx LPF corner - // After initialized, we can use pCoexDm->btRf0x1eBackup - if(pBtCoexist->bInitilized) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Resume RF Rx LPF corner!!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff, pCoexDm->btRf0x1eBackup); - } - } -} - -VOID -halbtc8821aCsr2ant_RfShrink( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bRxRfShrinkOn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Rx RF Shrink = %s\n", - (bForceExec? "force to":""), ((bRxRfShrinkOn)? "ON":"OFF"))); - pCoexDm->bCurRfRxLpfShrink = bRxRfShrinkOn; - - if(!bForceExec) - { - if(pCoexDm->bPreRfRxLpfShrink == pCoexDm->bCurRfRxLpfShrink) - return; - } - halbtc8821aCsr2ant_SetSwRfRxLpfCorner(pBtCoexist, pCoexDm->bCurRfRxLpfShrink); - - pCoexDm->bPreRfRxLpfShrink = pCoexDm->bCurRfRxLpfShrink; -} - -VOID -halbtc8821aCsr2ant_SetSwPenaltyTxRateAdaptive( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bLowPenaltyRa - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = 0x6; // opCode, 0x6= Retry_Penalty - - if(bLowPenaltyRa) - { - H2C_Parameter[1] |= BIT0; - H2C_Parameter[2] = 0x00; //normal rate except MCS7/6/5, OFDM54/48/36 - H2C_Parameter[3] = 0xf7; //MCS7 or OFDM54 - H2C_Parameter[4] = 0xf8; //MCS6 or OFDM48 - H2C_Parameter[5] = 0xf9; //MCS5 or OFDM36 - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set WiFi Low-Penalty Retry: %s", - (bLowPenaltyRa? "ON!!":"OFF!!") )); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x69, 6, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_LowPenaltyRa( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bLowPenaltyRa - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn LowPenaltyRA = %s\n", - (bForceExec? "force to":""), ((bLowPenaltyRa)? "ON":"OFF"))); - pCoexDm->bCurLowPenaltyRa = bLowPenaltyRa; - - if(!bForceExec) - { - if(pCoexDm->bPreLowPenaltyRa == pCoexDm->bCurLowPenaltyRa) - return; - } - halbtc8821aCsr2ant_SetSwPenaltyTxRateAdaptive(pBtCoexist, pCoexDm->bCurLowPenaltyRa); - - pCoexDm->bPreLowPenaltyRa = pCoexDm->bCurLowPenaltyRa; -} - -VOID -halbtc8821aCsr2ant_SetDacSwingReg( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte level - ) -{ - u1Byte val=(u1Byte)level; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Write SwDacSwing = 0x%x\n", level)); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xc5b, 0x3e, val); -} - -VOID -halbtc8821aCsr2ant_SetSwFullTimeDacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bSwDacSwingOn, - IN u4Byte swDacSwingLvl - ) -{ - if(bSwDacSwingOn) - { - halbtc8821aCsr2ant_SetDacSwingReg(pBtCoexist, swDacSwingLvl); - } - else - { - halbtc8821aCsr2ant_SetDacSwingReg(pBtCoexist, 0x18); - } -} - - -VOID -halbtc8821aCsr2ant_DacSwing( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bDacSwingOn, - IN u4Byte dacSwingLvl - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn DacSwing=%s, dacSwingLvl=0x%x\n", - (bForceExec? "force to":""), ((bDacSwingOn)? "ON":"OFF"), dacSwingLvl)); - pCoexDm->bCurDacSwingOn = bDacSwingOn; - pCoexDm->curDacSwingLvl = dacSwingLvl; - - if(!bForceExec) - { - if( (pCoexDm->bPreDacSwingOn == pCoexDm->bCurDacSwingOn) && - (pCoexDm->preDacSwingLvl == pCoexDm->curDacSwingLvl) ) - return; - } - delay_ms(30); - halbtc8821aCsr2ant_SetSwFullTimeDacSwing(pBtCoexist, bDacSwingOn, dacSwingLvl); - - pCoexDm->bPreDacSwingOn = pCoexDm->bCurDacSwingOn; - pCoexDm->preDacSwingLvl = pCoexDm->curDacSwingLvl; -} - -VOID -halbtc8821aCsr2ant_SetAdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAdcBackOff - ) -{ - if(bAdcBackOff) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level On!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x3); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BB BackOff Level Off!\n")); - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x8db, 0x60, 0x1); - } -} - -VOID -halbtc8821aCsr2ant_AdcBackOff( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAdcBackOff - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn AdcBackOff = %s\n", - (bForceExec? "force to":""), ((bAdcBackOff)? "ON":"OFF"))); - pCoexDm->bCurAdcBackOff = bAdcBackOff; - - if(!bForceExec) - { - if(pCoexDm->bPreAdcBackOff == pCoexDm->bCurAdcBackOff) - return; - } - halbtc8821aCsr2ant_SetAdcBackOff(pBtCoexist, pCoexDm->bCurAdcBackOff); - - pCoexDm->bPreAdcBackOff = pCoexDm->bCurAdcBackOff; -} - -VOID -halbtc8821aCsr2ant_SetAgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAgcTableEn - ) -{ - u1Byte rssiAdjustVal=0; - - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x02000); - if(bAgcTableEn) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table On!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x28F4B); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x10AB2); - rssiAdjustVal = 8; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Agc Table Off!\n")); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x2884B); - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0x3b, 0xfffff, 0x104B2); - } - pBtCoexist->fBtcSetRfReg(pBtCoexist, BTC_RF_A, 0xef, 0xfffff, 0x0); - - // set rssiAdjustVal for wifi module. - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, &rssiAdjustVal); -} - -VOID -halbtc8821aCsr2ant_AgcTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bAgcTableEn - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s %s Agc Table\n", - (bForceExec? "force to":""), ((bAgcTableEn)? "Enable":"Disable"))); - pCoexDm->bCurAgcTableEn = bAgcTableEn; - - if(!bForceExec) - { - if(pCoexDm->bPreAgcTableEn == pCoexDm->bCurAgcTableEn) - return; - } - halbtc8821aCsr2ant_SetAgcTable(pBtCoexist, bAgcTableEn); - - pCoexDm->bPreAgcTableEn = pCoexDm->bCurAgcTableEn; -} - -VOID -halbtc8821aCsr2ant_SetCoexTable( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c0=0x%x\n", val0x6c0)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c0, val0x6c0); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c4=0x%x\n", val0x6c4)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c4, val0x6c4); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6c8=0x%x\n", val0x6c8)); - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x6c8, val0x6c8); - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set coex table, set 0x6cc=0x%x\n", val0x6cc)); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x6cc, val0x6cc); -} - -VOID -halbtc8821aCsr2ant_CoexTable( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN u4Byte val0x6c0, - IN u4Byte val0x6c4, - IN u4Byte val0x6c8, - IN u1Byte val0x6cc - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s write Coex Table 0x6c0=0x%x, 0x6c4=0x%x, 0x6c8=0x%x, 0x6cc=0x%x\n", - (bForceExec? "force to":""), val0x6c0, val0x6c4, val0x6c8, val0x6cc)); - pCoexDm->curVal0x6c0 = val0x6c0; - pCoexDm->curVal0x6c4 = val0x6c4; - pCoexDm->curVal0x6c8 = val0x6c8; - pCoexDm->curVal0x6cc = val0x6cc; - - if(!bForceExec) - { - if( (pCoexDm->preVal0x6c0 == pCoexDm->curVal0x6c0) && - (pCoexDm->preVal0x6c4 == pCoexDm->curVal0x6c4) && - (pCoexDm->preVal0x6c8 == pCoexDm->curVal0x6c8) && - (pCoexDm->preVal0x6cc == pCoexDm->curVal0x6cc) ) - return; - } - halbtc8821aCsr2ant_SetCoexTable(pBtCoexist, val0x6c0, val0x6c4, val0x6c8, val0x6cc); - - pCoexDm->preVal0x6c0 = pCoexDm->curVal0x6c0; - pCoexDm->preVal0x6c4 = pCoexDm->curVal0x6c4; - pCoexDm->preVal0x6c8 = pCoexDm->curVal0x6c8; - pCoexDm->preVal0x6cc = pCoexDm->curVal0x6cc; -} - -VOID -halbtc8821aCsr2ant_SetFwIgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bEnable - ) -{ - u1Byte H2C_Parameter[1] ={0}; - - if(bEnable) - { - H2C_Parameter[0] |= BIT0; // function enable - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], set FW for BT Ignore Wlan_Act, FW write 0x63=0x%x\n", - H2C_Parameter[0])); - - rtw_warn_on(_BTCOEX_CSR); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x63, 1, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_IgnoreWlanAct( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bEnable - ) -{ - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn Ignore WlanAct %s\n", - (bForceExec? "force to":""), (bEnable? "ON":"OFF"))); - pCoexDm->bCurIgnoreWlanAct = bEnable; - - if(!bForceExec) - { - if(pCoexDm->bPreIgnoreWlanAct == pCoexDm->bCurIgnoreWlanAct) - return; - } - //halbtc8821aCsr2ant_SetFwIgnoreWlanAct(pBtCoexist, bEnable); - - pCoexDm->bPreIgnoreWlanAct = pCoexDm->bCurIgnoreWlanAct; -} - -VOID -halbtc8821aCsr2ant_SetFwPstdma( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte byte1, - IN u1Byte byte2, - IN u1Byte byte3, - IN u1Byte byte4, - IN u1Byte byte5 - ) -{ - u1Byte H2C_Parameter[6] ={0}; - - H2C_Parameter[0] = byte1; - H2C_Parameter[1] = byte2; - H2C_Parameter[2] = byte3; - H2C_Parameter[3] = byte4; - H2C_Parameter[4] = byte5; - H2C_Parameter[5] = 0x01; - - pCoexDm->psTdmaPara[0] = byte1; - pCoexDm->psTdmaPara[1] = byte2; - pCoexDm->psTdmaPara[2] = byte3; - pCoexDm->psTdmaPara[3] = byte4; - pCoexDm->psTdmaPara[4] = byte5; - pCoexDm->psTdmaPara[5] = 0x01; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x60(6bytes)=0x%x%08x%02x\n", - H2C_Parameter[0], - H2C_Parameter[1]<<24|H2C_Parameter[2]<<16|H2C_Parameter[3]<<8|H2C_Parameter[4], H2C_Parameter[5])); - - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x60, 6, H2C_Parameter); -} - -VOID -halbtc8821aCsr2ant_SwMechanism1( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bShrinkRxLPF, - IN BOOLEAN bLowPenaltyRA, - IN BOOLEAN bLimitedDIG, - IN BOOLEAN bBTLNAConstrain - ) -{ - u4Byte wifiBw; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 != wifiBw) //only shrink RF Rx LPF for HT40 - { - if (bShrinkRxLPF) - bShrinkRxLPF = FALSE; - } - - halbtc8821aCsr2ant_RfShrink(pBtCoexist, NORMAL_EXEC, bShrinkRxLPF); - halbtc8821aCsr2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, bLowPenaltyRA); - - //no limited DIG - //halbtc8821aCsr2ant_SetBtLnaConstrain(pBtCoexist, NORMAL_EXEC, bBTLNAConstrain); -} - -VOID -halbtc8821aCsr2ant_SwMechanism2( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bAGCTableShift, - IN BOOLEAN bADCBackOff, - IN BOOLEAN bSWDACSwing, - IN u4Byte dacSwingLvl - ) -{ - //halbtc8821aCsr2ant_AgcTable(pBtCoexist, NORMAL_EXEC, bAGCTableShift); - halbtc8821aCsr2ant_AdcBackOff(pBtCoexist, NORMAL_EXEC, bADCBackOff); - halbtc8821aCsr2ant_DacSwing(pBtCoexist, NORMAL_EXEC, bSWDACSwing, dacSwingLvl); -} - -VOID -halbtc8821aCsr2ant_SetAntPath( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte antPosType, - IN BOOLEAN bInitHwCfg, - IN BOOLEAN bWifiOff - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - if(bInitHwCfg) - { - // 0x4c[23]=0, 0x4c[24]=1 Antenna control by WL/BT - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp &=~BIT23; - u4Tmp |= BIT24; - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x4c, u4Tmp); - - pBtCoexist->fBtcWrite4Byte(pBtCoexist, 0x974, 0x3ff); - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0xcb4, 0x77); - - if(pBoardInfo->btdmAntPos == BTC_ANTENNA_AT_MAIN_PORT) - { - //tell firmware "antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 1; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - else - { - //tell firmware "no antenna inverse" ==> WRONG firmware antenna control code.==>need fw to fix - H2C_Parameter[0] = 0; - H2C_Parameter[1] = 1; - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x65, 2, H2C_Parameter); - } - } - - // ext switch setting - switch(antPosType) - { - case BTC_ANT_WIFI_AT_MAIN: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x1); - break; - case BTC_ANT_WIFI_AT_AUX: - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0xcb7, 0x30, 0x2); - break; - } -} - -VOID -halbtc8821aCsr2ant_PsTdma( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bForceExec, - IN BOOLEAN bTurnOn, - IN u1Byte type - ) -{ - BOOLEAN bTurnOnByCnt=FALSE; - u1Byte psTdmaTypeByCnt=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], %s turn %s PS TDMA, type=%d\n", - (bForceExec? "force to":""), (bTurnOn? "ON":"OFF"), type)); - pCoexDm->bCurPsTdmaOn = bTurnOn; - pCoexDm->curPsTdma = type; - - if(!bForceExec) - { - if( (pCoexDm->bPrePsTdmaOn == pCoexDm->bCurPsTdmaOn) && - (pCoexDm->prePsTdma == pCoexDm->curPsTdma) ) - return; - } - if(bTurnOn) - { - switch(type) - { - case 1: - default: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - break; - case 2: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - break; - case 3: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0xf1, 0x90); - break; - case 4: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x10, 0x03, 0xf1, 0x90); - break; - case 5: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - break; - case 6: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - break; - case 7: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1c, 0x3, 0x70, 0x90); - break; - case 8: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x10, 0x3, 0x70, 0x90); - break; - case 9: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - break; - case 10: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0xe1, 0x90); - break; - case 11: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0xe1, 0x90); - break; - case 12: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 13: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0x60, 0x90); - break; - case 14: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x12, 0x12, 0x60, 0x90); - break; - case 15: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0xa, 0xa, 0x60, 0x90); - break; - case 16: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0x60, 0x90); - break; - case 17: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xa3, 0x2f, 0x2f, 0x60, 0x90); - break; - case 18: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x5, 0x5, 0xe1, 0x90); - break; - case 19: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0xe1, 0x90); - break; - case 20: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x25, 0x25, 0x60, 0x90); - break; - case 21: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x15, 0x03, 0x70, 0x90); - break; - case 22: //ad2dp master - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xeb, 0x11, 0x11, 0x21, 0x10); - break; - case 23: //a2dp slave - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xeb, 0x12, 0x12, 0x20, 0x10); - break; - case 71: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0xe3, 0x1a, 0x1a, 0xe1, 0x90); - break; - } - } - else - { - // disable PS tdma - switch(type) - { - case 0: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - case 1: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x48, 0x0); - break; - default: - halbtc8821aCsr2ant_SetFwPstdma(pBtCoexist, 0x0, 0x0, 0x0, 0x40, 0x0); - break; - } - } - - // update pre state - pCoexDm->bPrePsTdmaOn = pCoexDm->bCurPsTdmaOn; - pCoexDm->prePsTdma = pCoexDm->curPsTdma; -} - -VOID -halbtc8821aCsr2ant_CoexAllOff( - IN PBTC_COEXIST pBtCoexist - ) -{ - // fw all off - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - // sw all off - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - - // hw all off - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3); -} - -VOID -halbtc8821aCsr2ant_CoexUnder5G( - IN PBTC_COEXIST pBtCoexist - ) -{ - halbtc8821aCsr2ant_CoexAllOff(pBtCoexist); - - halbtc8821aCsr2ant_IgnoreWlanAct(pBtCoexist, NORMAL_EXEC, TRUE); -} - -VOID -halbtc8821aCsr2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - // force to reset coex mechanism - halbtc8821aCsr2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3); - - halbtc8821aCsr2ant_PsTdma(pBtCoexist, FORCE_EXEC, FALSE, 1); - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, FORCE_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, FORCE_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); -} - -VOID -halbtc8821aCsr2ant_BtInquiryPage( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bLowPwrDisable=TRUE; - - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5afa5afa, 0xffff, 0x3); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); -} -BOOLEAN -halbtc8821aCsr2ant_IsCommonAction( - IN PBTC_COEXIST pBtCoexist - ) -{ - BOOLEAN bCommon=FALSE, bWifiConnected=FALSE, bWifiBusy=FALSE; - BOOLEAN bLowPwrDisable=FALSE; - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - - if(!bWifiConnected && - BT_8821A_CSR_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi IPS + BT IPS!!\n")); - - - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 0); - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, 0, 0, 0); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8821A_CSR_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus) ) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Busy + BT IPS!!\n")); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi LPS + BT IPS!!\n")); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 0); - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, 0, 0, 0); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8821A_CSR_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi IPS + BT LPS!!\n")); - - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 0); - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, 0, 0, 0); - - bCommon = TRUE; - } - else if(bWifiConnected && - (BT_8821A_CSR_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ) - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Busy + BT LPS!!\n")); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi LPS + BT LPS!!\n")); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,TRUE,TRUE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 0); - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, 0, 0, 0); - - bCommon = TRUE; - } - else if(!bWifiConnected && - (BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) ) - { - bLowPwrDisable = FALSE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi IPS + BT Busy!!\n")); - - //halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 0); - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, 0, 0, 0); - - bCommon = TRUE; - } - else - { - bLowPwrDisable = TRUE; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_DISABLE_LOW_POWER, &bLowPwrDisable); - - if(bWifiBusy) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi Busy + BT Busy!!\n")); - bCommon = FALSE; - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Wifi LPS + BT Busy!!\n")); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 21); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - bCommon = TRUE; - } - - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,TRUE,TRUE); - } - - if (bCommon == TRUE) - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5afa5afa, 0xffff, 0x3); - - return bCommon; -} -VOID -halbtc8821aCsr2ant_TdmaDurationAdjust( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bScoHid, - IN BOOLEAN bTxPause, - IN u1Byte maxInterval - ) -{ - static s4Byte up,dn,m,n,WaitCount; - s4Byte result; //0: no change, +1: increase WiFi duration, -1: decrease WiFi duration - u1Byte retryCount=0; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TdmaDurationAdjust()\n")); - - if(pCoexDm->bResetTdmaAdjust) - { - pCoexDm->bResetTdmaAdjust = FALSE; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], first run TdmaDurationAdjust()!!\n")); - { - if(bScoHid) - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(maxInterval == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(maxInterval == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - else - { - if(maxInterval == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(maxInterval == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(maxInterval == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - else - { - if(bTxPause) - { - if(maxInterval == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(maxInterval == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(maxInterval == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - } - else - { - if(maxInterval == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(maxInterval == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(maxInterval == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - } - } - } - //============ - up = 0; - dn = 0; - m = 1; - n= 3; - result = 0; - WaitCount = 0; - } - else - { - //accquire the BT TRx retry count from BT_Info byte2 - retryCount = pCoexSta->btRetryCnt; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], retryCount = %d\n", retryCount)); - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], up=%d, dn=%d, m=%d, n=%d, WaitCount=%d\n", - up, dn, m, n, WaitCount)); - result = 0; - WaitCount++; - - if(retryCount == 0) // no retry in the last 2-second duration - { - up++; - dn--; - - if (dn <= 0) - dn = 0; - - if(up >= n) // if ³sÄò n ­Ó2¬í retry count¬°0, «h½Õ¼eWiFi duration - { - WaitCount = 0; - n = 3; - up = 0; - dn = 0; - result = 1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Increase wifi duration!!\n")); - } - } - else if (retryCount <= 3) // <=3 retry in the last 2-second duration - { - up--; - dn++; - - if (up <= 0) - up = 0; - - if (dn == 2) // if ³sÄò 2 ­Ó2¬í retry count< 3, «h½Õ¯¶WiFi duration - { - if (WaitCount <= 2) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter<3!!\n")); - } - } - else //retry count > 3, ¥u­n1¦¸ retry count > 3, «h½Õ¯¶WiFi duration - { - if (WaitCount == 1) - m++; // Á×§K¤@ª½¦b¨â­Ólevel¤¤¨Ó¦^ - else - m = 1; - - if ( m >= 20) //m ³Ì¤j­È = 20 ' ³Ì¤j120¬í recheck¬O§_½Õ¾ã WiFi duration. - m = 20; - - n = 3*m; - up = 0; - dn = 0; - WaitCount = 0; - result = -1; - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], Decrease wifi duration for retryCounter>3!!\n")); - } - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], max Interval = %d\n", maxInterval)); - if(maxInterval == 1) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - - if(pCoexDm->curPsTdma == 71) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - pCoexDm->psTdmaDuAdjType = 5; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - pCoexDm->psTdmaDuAdjType = 13; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - - if(result == -1) - { - if(pCoexDm->curPsTdma == 71) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - pCoexDm->psTdmaDuAdjType = 1; - } - else if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 71); - pCoexDm->psTdmaDuAdjType = 71; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - pCoexDm->psTdmaDuAdjType = 9; - } - } - } - } - else if(maxInterval == 2) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 6); - pCoexDm->psTdmaDuAdjType = 6; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - pCoexDm->psTdmaDuAdjType = 14; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 2); - pCoexDm->psTdmaDuAdjType = 2; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - pCoexDm->psTdmaDuAdjType = 10; - } - } - } - } - else if(maxInterval == 3) - { - if(bTxPause) - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 1\n")); - if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 8); - pCoexDm->psTdmaDuAdjType = 8; - } - else if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 16); - pCoexDm->psTdmaDuAdjType = 16; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 7); - pCoexDm->psTdmaDuAdjType = 7; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 15); - pCoexDm->psTdmaDuAdjType = 15; - } - } - } - else - { - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], TxPause = 0\n")); - if(pCoexDm->curPsTdma == 5) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 6) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 7) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 8) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - if(pCoexDm->curPsTdma == 13) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 14) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 15) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 16) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - if(result == -1) - { - if(pCoexDm->curPsTdma == 1) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 4); - pCoexDm->psTdmaDuAdjType = 4; - } - else if(pCoexDm->curPsTdma == 9) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 12); - pCoexDm->psTdmaDuAdjType = 12; - } - } - else if (result == 1) - { - if(pCoexDm->curPsTdma == 4) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 3) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 2) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 3); - pCoexDm->psTdmaDuAdjType = 3; - } - else if(pCoexDm->curPsTdma == 12) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 11) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - else if(pCoexDm->curPsTdma == 10) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 11); - pCoexDm->psTdmaDuAdjType = 11; - } - } - } - } - } - - // if current PsTdma not match with the recorded one (when scan, dhcp...), - // then we have to adjust it back to the previous record one. - if(pCoexDm->curPsTdma != pCoexDm->psTdmaDuAdjType) - { - BOOLEAN bScan=FALSE, bLink=FALSE, bRoam=FALSE; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], PsTdma type dismatch!!!, curPsTdma=%d, recordPsTdma=%d\n", - pCoexDm->curPsTdma, pCoexDm->psTdmaDuAdjType)); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - - if( !bScan && !bLink && !bRoam) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, pCoexDm->psTdmaDuAdjType); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], roaming/link/scan is under progress, will adjust next time!!!\n")); - } - } - - // when halbtc8821aCsr2ant_TdmaDurationAdjust() is called, fw dac swing is included in the function. - //if(pCoexDm->psTdmaDuAdjType == 71) - // halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0xc); //Skip because A2DP get worse at HT40 - //else - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 0x6); -} - -// SCO only or SCO+PAN(HS) -VOID -halbtc8821aCsr2ant_ActionSco( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState,btRssiState; - u4Byte wifiBw; - - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55555555, 0x55555555, 0xffffff, 0x3); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); - - halbtc8821aCsr2ant_LowPenaltyRa(pBtCoexist, NORMAL_EXEC, TRUE); - - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 1, 0, 2, 0); - - if(pCoexSta->bSlave == FALSE) - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x4); - else - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x2); - -/* - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 4); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for SCO quality at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x5a5a5a5a, 0x5a5a5a5a, 0xffff, 0x3); - } - else //for SCO quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x5aea5aea, 0x5aea5aea, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - - // fw mechanism - //halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - //halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 0); //for voice quality - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -*/ -} - - -VOID -halbtc8821aCsr2ant_ActionHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5aea5aea, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 9); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 13); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//A2DP only / PAN(EDR) only/ A2DP+PAN(HS) -VOID -halbtc8821aCsr2ant_ActionA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - halbtc8821aCsr2ant_LimitedRx(pBtCoexist, NORMAL_EXEC, FALSE, TRUE, 0x8); - - if(pCoexSta->bSlave == FALSE) - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0xfdfdfdfd, 0xdfdadfda, 0xffffff, 0x3); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 22); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 1); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x0c); - } - else - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0xfdfdfdfd, 0xdfdadfda, 0xffffff, 0x3); - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 23); - halbtc8821aCsr2ant_LimitedTx(pBtCoexist, NORMAL_EXEC, 0, 0, 0, 0, 2); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,TRUE,0x18); - } - -/* - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - //fw dac swing is called in halbtc8821aCsr2ant_TdmaDurationAdjust() - //halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - else - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 1); - } - else - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -*/ -} - -VOID -halbtc8821aCsr2ant_ActionA2dpPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2,35, 0); - - //fw dac swing is called in halbtc8821aCsr2ant_TdmaDurationAdjust() - //halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 2); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 1); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821aCsr2ant_ActionPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5aff5aff, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 1); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 5); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - - -//PAN(HS) only -VOID -halbtc8821aCsr2ant_ActionPanHs( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - } - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - } - else - { - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - } - - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, FALSE, 1); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -//PAN(EDR)+A2DP -VOID -halbtc8821aCsr2ant_ActionPanEdrA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5afa5afa, 0xffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5afa5afa, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - }; - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, FALSE, 3); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, FALSE, TRUE, 3); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,FALSE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821aCsr2ant_ActionPanEdrHid( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState; - u4Byte wifiBw; - - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5f5a5f, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 3); - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 10); - } - else - { - halbtc8821aCsr2ant_PsTdma(pBtCoexist, NORMAL_EXEC, TRUE, 14); - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -// HID+A2DP+PAN(EDR) -VOID -halbtc8821aCsr2ant_ActionHidA2dpPanEdr( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - halbtc8821aCsr2ant_FwDacSwingLvl(pBtCoexist, NORMAL_EXEC, 6); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 3); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 3); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821aCsr2ant_ActionHidA2dp( - IN PBTC_COEXIST pBtCoexist - ) -{ - u1Byte wifiRssiState, btRssiState, btInfoExt; - u4Byte wifiBw; - - btInfoExt = pCoexSta->btInfoExt; - wifiRssiState = halbtc8821aCsr2ant_WifiRssiState(pBtCoexist, 0, 2, 15, 0); - btRssiState = halbtc8821aCsr2ant_BtRssiState(2, 35, 0); - - if(halbtc8821aCsr2ant_NeedToDecBtPwr(pBtCoexist)) - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, TRUE); - else - halbtc8821aCsr2ant_DecBtPwr(pBtCoexist, NORMAL_EXEC, FALSE); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - - if (BTC_WIFI_BW_LEGACY == wifiBw) //for HID at 11b/g mode - { -//Allen halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5f5b5f5b, 0xffffff, 0x3); - } - else //for HID quality & wifi performance balance at 11n mode - { -//Allen halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5a5a5a5a, 0xffff, 0x3); - halbtc8821aCsr2ant_CoexTable(pBtCoexist, NORMAL_EXEC, 0x55ff55ff, 0x5f5b5f5b, 0xffffff, 0x3); - - } - - if(BTC_WIFI_BW_HT40 == wifiBw) - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,TRUE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } - else - { - // fw mechanism - if( (btRssiState == BTC_RSSI_STATE_HIGH) || - (btRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - if(btInfoExt&BIT0) //a2dp basic rate - { -// halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - - } - else //a2dp edr rate - { -//Allen halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, FALSE, 2); - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - } - else - { - if(btInfoExt&BIT0) //a2dp basic rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - else //a2dp edr rate - { - halbtc8821aCsr2ant_TdmaDurationAdjust(pBtCoexist, TRUE, TRUE, 2); - } - } - - // sw mechanism - if( (wifiRssiState == BTC_RSSI_STATE_HIGH) || - (wifiRssiState == BTC_RSSI_STATE_STAY_HIGH) ) - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,TRUE,FALSE,FALSE,0x18); - } - else - { - halbtc8821aCsr2ant_SwMechanism1(pBtCoexist,FALSE,TRUE,FALSE,FALSE); - halbtc8821aCsr2ant_SwMechanism2(pBtCoexist,FALSE,FALSE,FALSE,0x18); - } - } -} - -VOID -halbtc8821aCsr2ant_RunCoexistMechanism( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - BOOLEAN bWifiUnder5G=FALSE; - u1Byte btInfoOriginal=0, btRetryCnt=0; - u1Byte algorithm=0; - - if(pBtCoexist->bManualControl) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Manual control!!!\n")); - return; - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - if(bWifiUnder5G) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], RunCoexistMechanism(), run 5G coex setting!!<===\n")); - halbtc8821aCsr2ant_CoexUnder5G(pBtCoexist); - return; - } - - //if(pStackInfo->bProfileNotified) - { - algorithm = halbtc8821aCsr2ant_ActionAlgorithm(pBtCoexist); - if(pCoexSta->bC2hBtInquiryPage && (BT_8821A_CSR_2ANT_COEX_ALGO_PANHS!=algorithm)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT is under inquiry/page scan !!\n")); - halbtc8821aCsr2ant_BtInquiryPage(pBtCoexist); - return; - } - - pCoexDm->curAlgorithm = algorithm; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Algorithm = %d \n", pCoexDm->curAlgorithm)); - - if(halbtc8821aCsr2ant_IsCommonAction(pBtCoexist)) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant common.\n")); - pCoexDm->bResetTdmaAdjust = TRUE; - } - else - { - if(pCoexDm->curAlgorithm != pCoexDm->preAlgorithm) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], preAlgorithm=%d, curAlgorithm=%d\n", - pCoexDm->preAlgorithm, pCoexDm->curAlgorithm)); - pCoexDm->bResetTdmaAdjust = TRUE; - } - switch(pCoexDm->curAlgorithm) - { - case BT_8821A_CSR_2ANT_COEX_ALGO_SCO: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = SCO.\n")); - halbtc8821aCsr2ant_ActionSco(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID.\n")); - halbtc8821aCsr2ant_ActionHid(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP.\n")); - halbtc8821aCsr2ant_ActionA2dp(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_A2DP_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = A2DP+PAN(HS).\n")); - halbtc8821aCsr2ant_ActionA2dpPanHs(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR).\n")); - halbtc8821aCsr2ant_ActionPanEdr(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_PANHS: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HS mode.\n")); - halbtc8821aCsr2ant_ActionPanHs(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN+A2DP.\n")); - halbtc8821aCsr2ant_ActionPanEdrA2dp(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = PAN(EDR)+HID.\n")); - halbtc8821aCsr2ant_ActionPanEdrHid(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP_PANEDR: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP+PAN.\n")); - halbtc8821aCsr2ant_ActionHidA2dpPanEdr(pBtCoexist); - break; - case BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = HID+A2DP.\n")); - halbtc8821aCsr2ant_ActionHidA2dp(pBtCoexist); - break; - default: - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Action 2-Ant, algorithm = coexist All Off!!\n")); - halbtc8821aCsr2ant_CoexAllOff(pBtCoexist); - break; - } - pCoexDm->preAlgorithm = pCoexDm->curAlgorithm; - } - } -} - - - -//============================================================ -// work around function start with wa_halbtc8821aCsr2ant_ -//============================================================ -//============================================================ -// extern function start with EXhalbtc8821aCsr2ant_ -//============================================================ -VOID -EXhalbtc8821aCsr2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ) -{ -} - -VOID -EXhalbtc8821aCsr2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - u4Byte u4Tmp=0; - u2Byte u2Tmp=0; - u1Byte u1Tmp=0; - u1Byte H2C_Parameter[2] ={0}; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], 2Ant Init HW Config!!\n")); - - if(bWifiOnly) - return; - - //if(bBackUp) - { - // backup rf 0x1e value - pCoexDm->btRf0x1eBackup = pBtCoexist->fBtcGetRfReg(pBtCoexist, BTC_RF_A, 0x1e, 0xfffff); - pCoexDm->backupArfrCnt1 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - pCoexDm->backupArfrCnt2 = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - pCoexDm->backupRetryLimit = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - pCoexDm->backupAmpduMaxTime = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - pCoexDm->backupAmpduMaxNum = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x4ca); - } - - #if 0 /* REMOVE */ - // 0x790[5:0]=0x5 - u1Tmp = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x790); - u1Tmp &= 0xc0; - u1Tmp |= 0x5; - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x790, u1Tmp); - #endif - - //Antenna config - halbtc8821aCsr2ant_SetAntPath(pBtCoexist, BTC_ANT_WIFI_AT_MAIN, TRUE, FALSE); - - // PTA parameter - halbtc8821aCsr2ant_CoexTable(pBtCoexist, FORCE_EXEC, 0x55555555, 0x55555555, 0xffff, 0x3); - - // Enable counter statistics - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); //0x76e[3] =1, WLAN_Act control by PTA - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x778, 0x3); - - #if 0 /* REMOVE */ - pBtCoexist->fBtcWrite1ByteBitMask(pBtCoexist, 0x40, 0x20, 0x1); - #endif -} - -VOID -EXhalbtc8821aCsr2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Coex Mechanism Init!!\n")); - - halbtc8821aCsr2ant_InitCoexDm(pBtCoexist); -} - -VOID -EXhalbtc8821aCsr2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ) -{ - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - pu1Byte cliBuf=pBtCoexist->cliBuf; - u1Byte u1Tmp[4], i, btInfoExt, psTdmaCase=0; - u4Byte u4Tmp[4]; - u4Byte fwVer=0, btPatchVer=0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum); - CL_PRINTF(cliBuf); - - if(pBtCoexist->bManualControl) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "[Action Manual control]!!"); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%d/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8821aCsr2Ant, GLCoexVer8821aCsr2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x ", "Wifi channel informed to BT", \ - pCoexDm->wifiChnlInfo[0], pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2]); - CL_PRINTF(cliBuf); - - // wifi status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Wifi Status]============"); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_WIFI_STATUS); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[BT Status]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pCoexSta->bC2hBtInquiryPage)?("inquiry/page scan"):((BT_8821A_CSR_2ANT_BT_STATUS_IDLE == pCoexDm->btStatus)? "idle":( (BT_8821A_CSR_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus)? "connected-idle":"busy"))), - pCoexSta->btRssi, pCoexSta->btRetryCnt); - CL_PRINTF(cliBuf); - - if(pStackInfo->bProfileNotified) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pStackInfo->bScoExist, pStackInfo->bHidExist, pStackInfo->bPanExist, pStackInfo->bA2dpExist); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt&BIT0)? "Basic rate":"EDR rate"); - CL_PRINTF(cliBuf); - - for(i=0; ibtInfoC2hCnt[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8821aCsr2Ant[i], \ - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i]); - CL_PRINTF(cliBuf); - } - } - - // Sw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Sw mechanism]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, pCoexDm->bCurLowPenaltyRa, pCoexDm->bLimitedDig); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d(0x%x) ", "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, pCoexDm->bCurAdcBackOff, pCoexDm->bCurDacSwingOn, pCoexDm->curDacSwingLvl); - CL_PRINTF(cliBuf); - - // Fw mechanism - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - if(!pBtCoexist->bManualControl) - { - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d", "PS TDMA", \ - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->bCurDecBtPwr, pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - // Hw setting - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x ", "0x778 (W_Act)/ 0x6cc (CoTab Sel)", \ - u1Tmp[0], u1Tmp[1]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x8db); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xc5b); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x8db(ADC)/0xc5b[29:25](DAC)", \ - ((u1Tmp[0]&0x60)>>5), ((u1Tmp[1]&0x3e)>>1)); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcb4); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xcb4[7:0](ctrl)/ 0xcb4[29:28](val)", \ - u4Tmp[0]&0xff, ((u4Tmp[0]&0x30000000)>>28)); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x974); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x40/ 0x4c[24:23]/ 0x974", \ - u1Tmp[0], ((u4Tmp[0]&0x01800000)>>23), u4Tmp[1]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa0a); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "0xc50(DIG)/0xa0a(CCK-TH)", \ - u4Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xf48); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x", "OFDM-FA/ CCK-FA", \ - u4Tmp[0], (u1Tmp[0]<<8) + u1Tmp[1] ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8", \ - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x770 (hi-pri Rx/Tx)", \ - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "0x774(low-pri Rx/Tx)", \ - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - -VOID -EXhalbtc8821aCsr2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_IPS_ENTER == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS ENTER notify\n")); - pCoexSta->bUnderIps = TRUE; - halbtc8821aCsr2ant_CoexAllOff(pBtCoexist); - } - else if(BTC_IPS_LEAVE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], IPS LEAVE notify\n")); - pCoexSta->bUnderIps = FALSE; - //halbtc8821aCsr2ant_InitCoexDm(pBtCoexist); - } -} - -VOID -EXhalbtc8821aCsr2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_LPS_ENABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS ENABLE notify\n")); - pCoexSta->bUnderLps = TRUE; - } - else if(BTC_LPS_DISABLE == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], LPS DISABLE notify\n")); - pCoexSta->bUnderLps = FALSE; - } -} - -VOID -EXhalbtc8821aCsr2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_SCAN_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN START notify\n")); - } - else if(BTC_SCAN_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], SCAN FINISH notify\n")); - } -} - -VOID -EXhalbtc8821aCsr2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(BTC_ASSOCIATE_START == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT START notify\n")); - } - else if(BTC_ASSOCIATE_FINISH == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CONNECT FINISH notify\n")); - } -} - -VOID -EXhalbtc8821aCsr2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - u1Byte H2C_Parameter[3] ={0}; - u4Byte wifiBw; - u1Byte wifiCentralChnl; - - if(BTC_MEDIA_CONNECT == type) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA connect notify\n")); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], MEDIA disconnect notify\n")); - } - - // only 2.4G we need to inform bt the chnl mask - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_CENTRAL_CHNL, &wifiCentralChnl); - if( (BTC_MEDIA_CONNECT == type) && - (wifiCentralChnl <= 14) ) - { - H2C_Parameter[0] = 0x1; - H2C_Parameter[1] = wifiCentralChnl; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - if(BTC_WIFI_BW_HT40 == wifiBw) - H2C_Parameter[2] = 0x30; - else - H2C_Parameter[2] = 0x20; - } - - #if 0 /* REMOVE */ - pCoexDm->wifiChnlInfo[0] = H2C_Parameter[0]; - pCoexDm->wifiChnlInfo[1] = H2C_Parameter[1]; - pCoexDm->wifiChnlInfo[2] = H2C_Parameter[2]; - - RT_TRACE(COMP_COEX, DBG_TRACE, ("[BTCoex], FW write 0x66=0x%x\n", - H2C_Parameter[0]<<16|H2C_Parameter[1]<<8|H2C_Parameter[2])); - - rtw_warn_on(_BTCOEX_CSR); - pBtCoexist->fBtcFillH2c(pBtCoexist, 0x66, 3, H2C_Parameter); - #endif -} - -VOID -EXhalbtc8821aCsr2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(type == BTC_PACKET_DHCP) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], DHCP Packet notify\n")); - } -} - -VOID -EXhalbtc8821aCsr2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ) -{ - u1Byte btInfo=0; - u1Byte i, rspSource=0; - BOOLEAN bBtBusy=FALSE, bLimitedDig=FALSE; - BOOLEAN bWifiConnected=FALSE, bBtHsOn=FALSE, bWifiUnder5G=FALSE; - - pCoexSta->bC2hBtInfoReqSent = FALSE; - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &bWifiUnder5G); - - rspSource = tmpBuf[0]&0xf; - if(rspSource >= BT_INFO_SRC_8821A_CSR_2ANT_MAX) - rspSource = BT_INFO_SRC_8821A_CSR_2ANT_WIFI_FW; - pCoexSta->btInfoC2hCnt[rspSource]++; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Bt info[%d], length=%d, hex data=[", rspSource, length)); - for(i=0; ibtInfoC2h[rspSource][i] = tmpBuf[i]; - if(i == 1) - btInfo = tmpBuf[i]; - if(i == length-1) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x]\n", tmpBuf[i])); - } - else - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("0x%02x, ", tmpBuf[i])); - } - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_CONNECTED, &bWifiConnected); - if(BT_INFO_SRC_8821A_CSR_2ANT_WIFI_FW != rspSource) - { - pCoexSta->btRetryCnt = // [3:0] - pCoexSta->btInfoC2h[rspSource][2]&0xf; - - pCoexSta->btRssi = - pCoexSta->btInfoC2h[rspSource][3]*2+10; - - pCoexSta->btInfoExt = - pCoexSta->btInfoC2h[rspSource][4]; - - #if 0 /* REMOVE */ - // Here we need to resend some wifi info to BT - // because bt is reset and loss of the info. - if( (pCoexSta->btInfoExt & BIT1) ) - { - - if(bWifiConnected) - { - EXhalbtc8821aCsr2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_CONNECT); - } - else - { - EXhalbtc8821aCsr2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); - } - } - #endif - - #if 0 /* REMOVE */ - if(!pBtCoexist->bManualControl && !bWifiUnder5G) - { - if( (pCoexSta->btInfoExt&BIT3) ) - { - if(bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT NOT to ignore Wlan active!!\n")); - halbtc8821aCsr2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, FALSE); - } - } - else - { - // BT already NOT ignore Wlan active, do nothing here. - if(!bWifiConnected) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT ext info bit3 check, set BT to ignore Wlan active!!\n")); - halbtc8821aCsr2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - } - } - } - #endif - - #if 0 /* REMOVE */ - if( (pCoexSta->btInfoExt & BIT4) ) - { - // BT auto report already enabled, do nothing - } - else - { - halbtc8821aCsr2ant_BtAutoReport(pBtCoexist, FORCE_EXEC, TRUE); - } - #endif - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - - if(btInfo == BT_INFO_8821A_CSR_2ANT_B_CONNECTION) // connection exists but no busy - { - pCoexSta->bBtLinkExist = TRUE; - pCoexDm->btStatus = BT_8821A_CSR_2ANT_BT_STATUS_CONNECTED_IDLE; - } - else if(btInfo & BT_INFO_8821A_CSR_2ANT_B_CONNECTION) // connection exists and some link is busy - { - pCoexSta->bBtLinkExist = TRUE; - - if(btInfo & BT_INFO_8821A_CSR_2ANT_B_FTP) - pCoexSta->bPanExist = TRUE; - else - pCoexSta->bPanExist = FALSE; - - if(btInfo & BT_INFO_8821A_CSR_2ANT_B_A2DP) - pCoexSta->bA2dpExist = TRUE; - else - pCoexSta->bA2dpExist = FALSE; - - if(btInfo & BT_INFO_8821A_CSR_2ANT_B_HID) - pCoexSta->bHidExist = TRUE; - else - pCoexSta->bHidExist = FALSE; - - if(btInfo & BT_INFO_8821A_CSR_2ANT_B_SCO_ESCO) - pCoexSta->bScoExist = TRUE; - else - pCoexSta->bScoExist = FALSE; - - if (pCoexSta->btInfoExt & 0x80) - pCoexSta->bSlave = TRUE; //Slave - else - pCoexSta->bSlave = FALSE; //Master - - pCoexDm->btStatus = BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE; - } - else - { - pCoexSta->bBtLinkExist = FALSE; - pCoexSta->bPanExist = FALSE; - pCoexSta->bA2dpExist = FALSE; - pCoexSta->bSlave = FALSE; - pCoexSta->bHidExist = FALSE; - pCoexSta->bScoExist = FALSE; - pCoexDm->btStatus = BT_8821A_CSR_2ANT_BT_STATUS_IDLE; - } - - if(bBtHsOn) - { - pCoexDm->btStatus = BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE; - } - - if(btInfo & BT_INFO_8821A_CSR_2ANT_B_INQ_PAGE) - { - pCoexSta->bC2hBtInquiryPage = TRUE; - pCoexDm->btStatus = BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE; - } - else - { - pCoexSta->bC2hBtInquiryPage = FALSE; - } - - - if(BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE == pCoexDm->btStatus) - { - bBtBusy = TRUE; - } - else - { - bBtBusy = FALSE; - } - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bBtBusy); - - if(BT_8821A_CSR_2ANT_BT_STATUS_IDLE != pCoexDm->btStatus) - { - bLimitedDig = TRUE; - } - else - { - bLimitedDig = FALSE; - } - pCoexDm->bLimitedDig = bLimitedDig; - pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_BL_BT_LIMITED_DIG, &bLimitedDig); - - halbtc8821aCsr2ant_RunCoexistMechanism(pBtCoexist); -} - -VOID -EXhalbtc8821aCsr2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Halt notify\n")); - - halbtc8821aCsr2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - EXhalbtc8821aCsr2ant_MediaStatusNotify(pBtCoexist, BTC_MEDIA_DISCONNECT); -} - -VOID -EXhalbtc8821aCsr2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify\n")); - - if(BTC_WIFI_PNP_SLEEP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to SLEEP\n")); - halbtc8821aCsr2ant_IgnoreWlanAct(pBtCoexist, FORCE_EXEC, TRUE); - } - else if(BTC_WIFI_PNP_WAKE_UP == pnpState) - { - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Pnp notify to WAKE UP\n")); - } -} - -VOID -EXhalbtc8821aCsr2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ) -{ - static u1Byte disVerInfoCnt=0; - u4Byte fwVer=0, btPatchVer=0; - PBTC_BOARD_INFO pBoardInfo=&pBtCoexist->boardInfo; - PBTC_STACK_INFO pStackInfo=&pBtCoexist->stackInfo; - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ==========================Periodical===========================\n")); - - if(disVerInfoCnt <= 5) - { - disVerInfoCnt += 1; - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Ant PG Num/ Ant Mech/ Ant Pos = %d/ %d/ %d\n", - pBoardInfo->pgAntNum, pBoardInfo->btdmAntNum, pBoardInfo->btdmAntPos)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], BT stack/ hci ext ver = %s / %d\n", - ((pStackInfo->bProfileNotified)? "Yes":"No"), pStackInfo->hciVersion)); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], CoexVer/ FwVer/ PatchVer = %d_%x/ 0x%x/ 0x%x(%d)\n", - GLCoexVerDate8821aCsr2Ant, GLCoexVer8821aCsr2Ant, fwVer, btPatchVer, btPatchVer)); - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], ****************************************************************\n")); - } - - //halbtc8821aCsr2ant_QueryBtInfo(pBtCoexist); - //halbtc8821aCsr2ant_RunCoexistMechanism(pBtCoexist); - halbtc8821aCsr2ant_MonitorBtCtr(pBtCoexist); - halbtc8821aCsr2ant_MonitorBtEnableDisable(pBtCoexist); -} - - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.h deleted file mode 100644 index 9a96b07e1..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtc8821aCsr2Ant.h +++ /dev/null @@ -1,208 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -//=========================================== -// The following is for 8821A_CSR 2Ant BT Co-exist definition -//=========================================== -#define BT_INFO_8821A_CSR_2ANT_B_FTP BIT7 -#define BT_INFO_8821A_CSR_2ANT_B_A2DP BIT6 -#define BT_INFO_8821A_CSR_2ANT_B_HID BIT5 -#define BT_INFO_8821A_CSR_2ANT_B_SCO_BUSY BIT4 -#define BT_INFO_8821A_CSR_2ANT_B_ACL_BUSY BIT3 -#define BT_INFO_8821A_CSR_2ANT_B_INQ_PAGE BIT2 -#define BT_INFO_8821A_CSR_2ANT_B_SCO_ESCO BIT1 -#define BT_INFO_8821A_CSR_2ANT_B_CONNECTION BIT0 - -#define BTC_RSSI_COEX_THRESH_TOL_8821A_CSR_2ANT 2 - -typedef enum _BT_INFO_SRC_8821A_CSR_2ANT{ - BT_INFO_SRC_8821A_CSR_2ANT_WIFI_FW = 0x0, - BT_INFO_SRC_8821A_CSR_2ANT_BT_RSP = 0x1, - BT_INFO_SRC_8821A_CSR_2ANT_BT_ACTIVE_SEND = 0x2, - BT_INFO_SRC_8821A_CSR_2ANT_MAX -}BT_INFO_SRC_8821A_CSR_2ANT,*PBT_INFO_SRC_8821A_CSR_2ANT; - -typedef enum _BT_8821A_CSR_2ANT_BT_STATUS{ - BT_8821A_CSR_2ANT_BT_STATUS_IDLE = 0x0, - BT_8821A_CSR_2ANT_BT_STATUS_CONNECTED_IDLE = 0x1, - BT_8821A_CSR_2ANT_BT_STATUS_NON_IDLE = 0x2, - BT_8821A_CSR_2ANT_BT_STATUS_MAX -}BT_8821A_CSR_2ANT_BT_STATUS,*PBT_8821A_CSR_2ANT_BT_STATUS; - -typedef enum _BT_8821A_CSR_2ANT_COEX_ALGO{ - BT_8821A_CSR_2ANT_COEX_ALGO_UNDEFINED = 0x0, - BT_8821A_CSR_2ANT_COEX_ALGO_SCO = 0x1, - BT_8821A_CSR_2ANT_COEX_ALGO_HID = 0x2, - BT_8821A_CSR_2ANT_COEX_ALGO_A2DP = 0x3, - BT_8821A_CSR_2ANT_COEX_ALGO_A2DP_PANHS = 0x4, - BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR = 0x5, - BT_8821A_CSR_2ANT_COEX_ALGO_PANHS = 0x6, - BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_A2DP = 0x7, - BT_8821A_CSR_2ANT_COEX_ALGO_PANEDR_HID = 0x8, - BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP_PANEDR = 0x9, - BT_8821A_CSR_2ANT_COEX_ALGO_HID_A2DP = 0xa, - BT_8821A_CSR_2ANT_COEX_ALGO_MAX = 0xb, -}BT_8821A_CSR_2ANT_COEX_ALGO,*PBT_8821A_CSR_2ANT_COEX_ALGO; - -typedef struct _COEX_DM_8821A_CSR_2ANT{ - // fw mechanism - BOOLEAN bPreDecBtPwr; - BOOLEAN bCurDecBtPwr; - u1Byte preFwDacSwingLvl; - u1Byte curFwDacSwingLvl; - BOOLEAN bCurIgnoreWlanAct; - BOOLEAN bPreIgnoreWlanAct; - u1Byte prePsTdma; - u1Byte curPsTdma; - u1Byte psTdmaPara[6]; - u1Byte psTdmaDuAdjType; - BOOLEAN bResetTdmaAdjust; - BOOLEAN bPrePsTdmaOn; - BOOLEAN bCurPsTdmaOn; - BOOLEAN bPreBtAutoReport; - BOOLEAN bCurBtAutoReport; - - // sw mechanism - BOOLEAN bPreRfRxLpfShrink; - BOOLEAN bCurRfRxLpfShrink; - u4Byte btRf0x1eBackup; - BOOLEAN bPreLowPenaltyRa; - BOOLEAN bCurLowPenaltyRa; - BOOLEAN bPreDacSwingOn; - u4Byte preDacSwingLvl; - BOOLEAN bCurDacSwingOn; - u4Byte curDacSwingLvl; - BOOLEAN bPreAdcBackOff; - BOOLEAN bCurAdcBackOff; - BOOLEAN bPreAgcTableEn; - BOOLEAN bCurAgcTableEn; - u4Byte preVal0x6c0; - u4Byte curVal0x6c0; - u4Byte preVal0x6c4; - u4Byte curVal0x6c4; - u4Byte preVal0x6c8; - u4Byte curVal0x6c8; - u1Byte preVal0x6cc; - u1Byte curVal0x6cc; - BOOLEAN bLimitedDig; - - u4Byte preRaMask; - u4Byte curRaMask; - - u1Byte curAmpduNumType; - u1Byte preAmpduNumType; - u2Byte backupAmpduMaxNum; - - u1Byte curAmpduTimeType; - u1Byte preAmpduTimeType; - u1Byte backupAmpduMaxTime; - - u1Byte curArfrType; - u1Byte preArfrType; - u4Byte backupArfrCnt1; - u4Byte backupArfrCnt2; - - u1Byte curRetryLimitType; - u1Byte preRetryLimitType; - u2Byte backupRetryLimit; - - // algorithm related - u1Byte preAlgorithm; - u1Byte curAlgorithm; - u1Byte btStatus; - u1Byte wifiChnlInfo[3]; -} COEX_DM_8821A_CSR_2ANT, *PCOEX_DM_8821A_CSR_2ANT; - -typedef struct _COEX_STA_8821A_CSR_2ANT{ - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bA2dpExist; - BOOLEAN bSlave; - BOOLEAN bHidExist; - BOOLEAN bPanExist; - - BOOLEAN bUnderLps; - BOOLEAN bUnderIps; - u4Byte highPriorityTx; - u4Byte highPriorityRx; - u4Byte lowPriorityTx; - u4Byte lowPriorityRx; - u1Byte btRssi; - u1Byte preBtRssiState; - u1Byte preWifiRssiState[4]; - BOOLEAN bC2hBtInfoReqSent; - u1Byte btInfoC2h[BT_INFO_SRC_8821A_CSR_2ANT_MAX][10]; - u4Byte btInfoC2hCnt[BT_INFO_SRC_8821A_CSR_2ANT_MAX]; - BOOLEAN bC2hBtInquiryPage; - u1Byte btRetryCnt; - u1Byte btInfoExt; -}COEX_STA_8821A_CSR_2ANT, *PCOEX_STA_8821A_CSR_2ANT; - -//=========================================== -// The following is interface which will notify coex module. -//=========================================== -VOID -EXhalbtc8821aCsr2ant_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821aCsr2ant_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtc8821aCsr2ant_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821aCsr2ant_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtc8821aCsr2ant_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtc8821aCsr2ant_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821aCsr2ant_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtc8821aCsr2ant_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtc8821aCsr2ant_DisplayCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtcOutSrc.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtcOutSrc.h deleted file mode 100644 index 25dc3bf71..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/HalBtcOutSrc.h +++ /dev/null @@ -1,748 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __HALBTC_OUT_SRC_H__ -#define __HALBTC_OUT_SRC_H__ - -#define NORMAL_EXEC FALSE -#define FORCE_EXEC TRUE - -#define BTC_RF_OFF 0x0 -#define BTC_RF_ON 0x1 - -#define BTC_RF_A 0x0 -#define BTC_RF_B 0x1 -#define BTC_RF_C 0x2 -#define BTC_RF_D 0x3 - -#define BTC_SMSP SINGLEMAC_SINGLEPHY -#define BTC_DMDP DUALMAC_DUALPHY -#define BTC_DMSP DUALMAC_SINGLEPHY -#define BTC_MP_UNKNOWN 0xff - -#define BT_COEX_ANT_TYPE_PG 0 -#define BT_COEX_ANT_TYPE_ANTDIV 1 -#define BT_COEX_ANT_TYPE_DETECTED 2 - -#define BTC_MIMO_PS_STATIC 0 // 1ss -#define BTC_MIMO_PS_DYNAMIC 1 // 2ss - -#define BTC_RATE_DISABLE 0 -#define BTC_RATE_ENABLE 1 - -// single Antenna definition -#define BTC_ANT_PATH_WIFI 0 -#define BTC_ANT_PATH_BT 1 -#define BTC_ANT_PATH_PTA 2 -// dual Antenna definition -#define BTC_ANT_WIFI_AT_MAIN 0 -#define BTC_ANT_WIFI_AT_AUX 1 -// coupler Antenna definition -#define BTC_ANT_WIFI_AT_CPL_MAIN 0 -#define BTC_ANT_WIFI_AT_CPL_AUX 1 - -typedef enum _BTC_POWERSAVE_TYPE{ - BTC_PS_WIFI_NATIVE = 0, // wifi original power save behavior - BTC_PS_LPS_ON = 1, - BTC_PS_LPS_OFF = 2, - BTC_PS_MAX -} BTC_POWERSAVE_TYPE, *PBTC_POWERSAVE_TYPE; - -typedef enum _BTC_BT_REG_TYPE{ - BTC_BT_REG_RF = 0, - BTC_BT_REG_MODEM = 1, - BTC_BT_REG_BLUEWIZE = 2, - BTC_BT_REG_VENDOR = 3, - BTC_BT_REG_LE = 4, - BTC_BT_REG_MAX -} BTC_BT_REG_TYPE, *PBTC_BT_REG_TYPE; - -typedef enum _BTC_CHIP_INTERFACE{ - BTC_INTF_UNKNOWN = 0, - BTC_INTF_PCI = 1, - BTC_INTF_USB = 2, - BTC_INTF_SDIO = 3, - BTC_INTF_MAX -} BTC_CHIP_INTERFACE, *PBTC_CHIP_INTERFACE; - -typedef enum _BTC_CHIP_TYPE{ - BTC_CHIP_UNDEF = 0, - BTC_CHIP_CSR_BC4 = 1, - BTC_CHIP_CSR_BC8 = 2, - BTC_CHIP_RTL8723A = 3, - BTC_CHIP_RTL8821 = 4, - BTC_CHIP_RTL8723B = 5, - BTC_CHIP_MAX -} BTC_CHIP_TYPE, *PBTC_CHIP_TYPE; - -// following is for wifi link status -#define WIFI_STA_CONNECTED BIT0 -#define WIFI_AP_CONNECTED BIT1 -#define WIFI_HS_CONNECTED BIT2 -#define WIFI_P2P_GO_CONNECTED BIT3 -#define WIFI_P2P_GC_CONNECTED BIT4 - -// following is for command line utility -#define CL_SPRINTF rsprintf -#define CL_PRINTF DCMD_Printf - - -typedef struct _BTC_BOARD_INFO{ - // The following is some board information - u1Byte btChipType; - u1Byte pgAntNum; // pg ant number - u1Byte btdmAntNum; // ant number for btdm - u1Byte btdmAntNumByAntDet; // ant number for btdm after antenna detection - u1Byte btdmAntPos; //Bryant Add to indicate Antenna Position for (pgAntNum = 2) && (btdmAntNum =1) (DPDT+1Ant case) - u1Byte singleAntPath; // current used for 8723b only, 1=>s0, 0=>s1 - u1Byte bTfbgaPackage; //for Antenna detect threshold - u1Byte btdmAntDetFinish; - u1Byte antType; -} BTC_BOARD_INFO, *PBTC_BOARD_INFO; - -typedef enum _BTC_DBG_OPCODE{ - BTC_DBG_SET_COEX_NORMAL = 0x0, - BTC_DBG_SET_COEX_WIFI_ONLY = 0x1, - BTC_DBG_SET_COEX_BT_ONLY = 0x2, - BTC_DBG_SET_COEX_DEC_BT_PWR = 0x3, - BTC_DBG_SET_COEX_BT_AFH_MAP = 0x4, - BTC_DBG_SET_COEX_BT_IGNORE_WLAN_ACT = 0x5, - BTC_DBG_MAX -}BTC_DBG_OPCODE,*PBTC_DBG_OPCODE; - -typedef enum _BTC_RSSI_STATE{ - BTC_RSSI_STATE_HIGH = 0x0, - BTC_RSSI_STATE_MEDIUM = 0x1, - BTC_RSSI_STATE_LOW = 0x2, - BTC_RSSI_STATE_STAY_HIGH = 0x3, - BTC_RSSI_STATE_STAY_MEDIUM = 0x4, - BTC_RSSI_STATE_STAY_LOW = 0x5, - BTC_RSSI_MAX -}BTC_RSSI_STATE,*PBTC_RSSI_STATE; -#define BTC_RSSI_HIGH(_rssi_) ((_rssi_==BTC_RSSI_STATE_HIGH||_rssi_==BTC_RSSI_STATE_STAY_HIGH)? TRUE:FALSE) -#define BTC_RSSI_MEDIUM(_rssi_) ((_rssi_==BTC_RSSI_STATE_MEDIUM||_rssi_==BTC_RSSI_STATE_STAY_MEDIUM)? TRUE:FALSE) -#define BTC_RSSI_LOW(_rssi_) ((_rssi_==BTC_RSSI_STATE_LOW||_rssi_==BTC_RSSI_STATE_STAY_LOW)? TRUE:FALSE) - -typedef enum _BTC_WIFI_ROLE{ - BTC_ROLE_STATION = 0x0, - BTC_ROLE_AP = 0x1, - BTC_ROLE_IBSS = 0x2, - BTC_ROLE_HS_MODE = 0x3, - BTC_ROLE_MAX -}BTC_WIFI_ROLE,*PBTC_WIFI_ROLE; - -typedef enum _BTC_WIRELESS_FREQ{ - BTC_FREQ_2_4G = 0x0, - BTC_FREQ_5G = 0x1, - BTC_FREQ_MAX -}BTC_WIRELESS_FREQ,*PBTC_WIRELESS_FREQ; - -typedef enum _BTC_WIFI_BW_MODE{ - BTC_WIFI_BW_LEGACY = 0x0, - BTC_WIFI_BW_HT20 = 0x1, - BTC_WIFI_BW_HT40 = 0x2, - BTC_WIFI_BW_HT80 = 0x3, - BTC_WIFI_BW_HT160 = 0x4, - BTC_WIFI_BW_MAX -}BTC_WIFI_BW_MODE,*PBTC_WIFI_BW_MODE; - -typedef enum _BTC_WIFI_TRAFFIC_DIR{ - BTC_WIFI_TRAFFIC_TX = 0x0, - BTC_WIFI_TRAFFIC_RX = 0x1, - BTC_WIFI_TRAFFIC_MAX -}BTC_WIFI_TRAFFIC_DIR,*PBTC_WIFI_TRAFFIC_DIR; - -typedef enum _BTC_WIFI_PNP{ - BTC_WIFI_PNP_WAKE_UP = 0x0, - BTC_WIFI_PNP_SLEEP = 0x1, - BTC_WIFI_PNP_MAX -}BTC_WIFI_PNP,*PBTC_WIFI_PNP; - -typedef enum _BTC_IOT_PEER -{ - BTC_IOT_PEER_UNKNOWN = 0, - BTC_IOT_PEER_REALTEK = 1, - BTC_IOT_PEER_REALTEK_92SE = 2, - BTC_IOT_PEER_BROADCOM = 3, - BTC_IOT_PEER_RALINK = 4, - BTC_IOT_PEER_ATHEROS = 5, - BTC_IOT_PEER_CISCO = 6, - BTC_IOT_PEER_MERU = 7, - BTC_IOT_PEER_MARVELL = 8, - BTC_IOT_PEER_REALTEK_SOFTAP = 9,// peer is RealTek SOFT_AP, by Bohn, 2009.12.17 - BTC_IOT_PEER_SELF_SOFTAP = 10, // Self is SoftAP - BTC_IOT_PEER_AIRGO = 11, - BTC_IOT_PEER_INTEL = 12, - BTC_IOT_PEER_RTK_APCLIENT = 13, - BTC_IOT_PEER_REALTEK_81XX = 14, - BTC_IOT_PEER_REALTEK_WOW = 15, - BTC_IOT_PEER_REALTEK_JAGUAR_BCUTAP = 16, - BTC_IOT_PEER_REALTEK_JAGUAR_CCUTAP = 17, - BTC_IOT_PEER_MAX, -}BTC_IOT_PEER, *PBTC_IOT_PEER; - -//for 8723b-d cut large current issue -typedef enum _BT_WIFI_COEX_STATE{ - BTC_WIFI_STAT_INIT, - BTC_WIFI_STAT_IQK, - BTC_WIFI_STAT_NORMAL_OFF, - BTC_WIFI_STAT_MP_OFF, - BTC_WIFI_STAT_NORMAL, - BTC_WIFI_STAT_ANT_DIV, - BTC_WIFI_STAT_MAX -}BT_WIFI_COEX_STATE,*PBT_WIFI_COEX_STATE; - -typedef enum _BT_ANT_TYPE{ - BTC_ANT_TYPE_0, - BTC_ANT_TYPE_1, - BTC_ANT_TYPE_2, - BTC_ANT_TYPE_3, - BTC_ANT_TYPE_4, - BTC_ANT_TYPE_MAX -}BT_ANT_TYPE,*PBT_ANT_TYPE; - -// defined for BFP_BTC_GET -typedef enum _BTC_GET_TYPE{ - // type BOOLEAN - BTC_GET_BL_HS_OPERATION, - BTC_GET_BL_HS_CONNECTING, - BTC_GET_BL_WIFI_CONNECTED, - BTC_GET_BL_WIFI_BUSY, - BTC_GET_BL_WIFI_SCAN, - BTC_GET_BL_WIFI_LINK, - BTC_GET_BL_WIFI_ROAM, - BTC_GET_BL_WIFI_4_WAY_PROGRESS, - BTC_GET_BL_WIFI_UNDER_5G, - BTC_GET_BL_WIFI_AP_MODE_ENABLE, - BTC_GET_BL_WIFI_ENABLE_ENCRYPTION, - BTC_GET_BL_WIFI_UNDER_B_MODE, - BTC_GET_BL_EXT_SWITCH, - BTC_GET_BL_WIFI_IS_IN_MP_MODE, - BTC_GET_BL_IS_ASUS_8723B, - - // type s4Byte - BTC_GET_S4_WIFI_RSSI, - BTC_GET_S4_HS_RSSI, - - // type u4Byte - BTC_GET_U4_WIFI_BW, - BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, - BTC_GET_U4_WIFI_FW_VER, - BTC_GET_U4_WIFI_LINK_STATUS, - BTC_GET_U4_BT_PATCH_VER, - - // type u1Byte - BTC_GET_U1_WIFI_DOT11_CHNL, - BTC_GET_U1_WIFI_CENTRAL_CHNL, - BTC_GET_U1_WIFI_HS_CHNL, - BTC_GET_U1_MAC_PHY_MODE, - BTC_GET_U1_AP_NUM, - BTC_GET_U1_ANT_TYPE, - BTC_GET_U1_IOT_PEER, - - //===== for 1Ant ====== - BTC_GET_U1_LPS_MODE, - - BTC_GET_MAX -}BTC_GET_TYPE,*PBTC_GET_TYPE; - -// defined for BFP_BTC_SET -typedef enum _BTC_SET_TYPE{ - // type BOOLEAN - BTC_SET_BL_BT_DISABLE, - BTC_SET_BL_BT_TRAFFIC_BUSY, - BTC_SET_BL_BT_LIMITED_DIG, - BTC_SET_BL_FORCE_TO_ROAM, - BTC_SET_BL_TO_REJ_AP_AGG_PKT, - BTC_SET_BL_BT_CTRL_AGG_SIZE, - BTC_SET_BL_INC_SCAN_DEV_NUM, - BTC_SET_BL_BT_TX_RX_MASK, - BTC_SET_BL_MIRACAST_PLUS_BT, - - // type u1Byte - BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON, - BTC_SET_U1_AGG_BUF_SIZE, - - // type trigger some action - BTC_SET_ACT_GET_BT_RSSI, - BTC_SET_ACT_AGGREGATE_CTRL, - //===== for 1Ant ====== - // type BOOLEAN - - // type u1Byte - BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE, - BTC_SET_U1_LPS_VAL, - BTC_SET_U1_RPWM_VAL, - // type trigger some action - BTC_SET_ACT_LEAVE_LPS, - BTC_SET_ACT_ENTER_LPS, - BTC_SET_ACT_NORMAL_LPS, - BTC_SET_ACT_DISABLE_LOW_POWER, - BTC_SET_ACT_UPDATE_RAMASK, - BTC_SET_ACT_SEND_MIMO_PS, - // BT Coex related - BTC_SET_ACT_CTRL_BT_INFO, - BTC_SET_ACT_CTRL_BT_COEX, - BTC_SET_ACT_CTRL_8723B_ANT, - //================= - BTC_SET_MAX -}BTC_SET_TYPE,*PBTC_SET_TYPE; - -typedef enum _BTC_DBG_DISP_TYPE{ - BTC_DBG_DISP_COEX_STATISTICS = 0x0, - BTC_DBG_DISP_BT_LINK_INFO = 0x1, - BTC_DBG_DISP_WIFI_STATUS = 0x2, - BTC_DBG_DISP_MAX -}BTC_DBG_DISP_TYPE,*PBTC_DBG_DISP_TYPE; - -typedef enum _BTC_NOTIFY_TYPE_IPS{ - BTC_IPS_LEAVE = 0x0, - BTC_IPS_ENTER = 0x1, - BTC_IPS_MAX -}BTC_NOTIFY_TYPE_IPS,*PBTC_NOTIFY_TYPE_IPS; -typedef enum _BTC_NOTIFY_TYPE_LPS{ - BTC_LPS_DISABLE = 0x0, - BTC_LPS_ENABLE = 0x1, - BTC_LPS_MAX -}BTC_NOTIFY_TYPE_LPS,*PBTC_NOTIFY_TYPE_LPS; -typedef enum _BTC_NOTIFY_TYPE_SCAN{ - BTC_SCAN_FINISH = 0x0, - BTC_SCAN_START = 0x1, - BTC_SCAN_MAX -}BTC_NOTIFY_TYPE_SCAN,*PBTC_NOTIFY_TYPE_SCAN; -typedef enum _BTC_NOTIFY_TYPE_ASSOCIATE{ - BTC_ASSOCIATE_FINISH = 0x0, - BTC_ASSOCIATE_START = 0x1, - BTC_ASSOCIATE_MAX -}BTC_NOTIFY_TYPE_ASSOCIATE,*PBTC_NOTIFY_TYPE_ASSOCIATE; -typedef enum _BTC_NOTIFY_TYPE_MEDIA_STATUS{ - BTC_MEDIA_DISCONNECT = 0x0, - BTC_MEDIA_CONNECT = 0x1, - BTC_MEDIA_MAX -}BTC_NOTIFY_TYPE_MEDIA_STATUS,*PBTC_NOTIFY_TYPE_MEDIA_STATUS; -typedef enum _BTC_NOTIFY_TYPE_SPECIAL_PACKET{ - BTC_PACKET_UNKNOWN = 0x0, - BTC_PACKET_DHCP = 0x1, - BTC_PACKET_ARP = 0x2, - BTC_PACKET_EAPOL = 0x3, - BTC_PACKET_MAX -}BTC_NOTIFY_TYPE_SPECIAL_PACKET,*PBTC_NOTIFY_TYPE_SPECIAL_PACKET; -typedef enum _BTC_NOTIFY_TYPE_STACK_OPERATION{ - BTC_STACK_OP_NONE = 0x0, - BTC_STACK_OP_INQ_PAGE_PAIR_START = 0x1, - BTC_STACK_OP_INQ_PAGE_PAIR_FINISH = 0x2, - BTC_STACK_OP_MAX -}BTC_NOTIFY_TYPE_STACK_OPERATION,*PBTC_NOTIFY_TYPE_STACK_OPERATION; - -//Bryant Add -typedef enum _BTC_ANTENNA_POS{ - BTC_ANTENNA_AT_MAIN_PORT = 0x1, - BTC_ANTENNA_AT_AUX_PORT = 0x2, -}BTC_ANTENNA_POS,*PBTC_ANTENNA_POS; - -//Bryant Add -typedef enum _BTC_BT_OFFON{ - BTC_BT_OFF = 0x0, - BTC_BT_ON = 0x1, -}BTC_BTOFFON,*PBTC_BT_OFFON; - -typedef u1Byte -(*BFP_BTC_R1)( - IN PVOID pBtcContext, - IN u4Byte RegAddr - ); -typedef u2Byte -(*BFP_BTC_R2)( - IN PVOID pBtcContext, - IN u4Byte RegAddr - ); -typedef u4Byte -(*BFP_BTC_R4)( - IN PVOID pBtcContext, - IN u4Byte RegAddr - ); -typedef VOID -(*BFP_BTC_W1)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u1Byte Data - ); -typedef VOID -(*BFP_BTC_W1_BIT_MASK)( - IN PVOID pBtcContext, - IN u4Byte regAddr, - IN u1Byte bitMask, - IN u1Byte data1b - ); -typedef VOID -(*BFP_BTC_W2)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u2Byte Data - ); -typedef VOID -(*BFP_BTC_W4)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u4Byte Data - ); -typedef VOID -(*BFP_BTC_LOCAL_REG_W1)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u1Byte Data - ); -typedef VOID -(*BFP_BTC_SET_BB_REG)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u4Byte BitMask, - IN u4Byte Data - ); -typedef u4Byte -(*BFP_BTC_GET_BB_REG)( - IN PVOID pBtcContext, - IN u4Byte RegAddr, - IN u4Byte BitMask - ); -typedef VOID -(*BFP_BTC_SET_RF_REG)( - IN PVOID pBtcContext, - IN u1Byte eRFPath, - IN u4Byte RegAddr, - IN u4Byte BitMask, - IN u4Byte Data - ); -typedef u4Byte -(*BFP_BTC_GET_RF_REG)( - IN PVOID pBtcContext, - IN u1Byte eRFPath, - IN u4Byte RegAddr, - IN u4Byte BitMask - ); -typedef VOID -(*BFP_BTC_FILL_H2C)( - IN PVOID pBtcContext, - IN u1Byte elementId, - IN u4Byte cmdLen, - IN pu1Byte pCmdBuffer - ); - -typedef BOOLEAN -(*BFP_BTC_GET)( - IN PVOID pBtCoexist, - IN u1Byte getType, - OUT PVOID pOutBuf - ); - -typedef BOOLEAN -(*BFP_BTC_SET)( - IN PVOID pBtCoexist, - IN u1Byte setType, - OUT PVOID pInBuf - ); -typedef u2Byte -(*BFP_BTC_SET_BT_REG)( - IN PVOID pBtcContext, - IN u1Byte regType, - IN u4Byte offset, - IN u4Byte value - ); -typedef BOOLEAN -(*BFP_BTC_SET_BT_ANT_DETECTION)( - IN PVOID pBtcContext, - IN u1Byte txTime, - IN u1Byte btChnl - ); -typedef u2Byte -(*BFP_BTC_GET_BT_REG)( - IN PVOID pBtcContext, - IN u1Byte regType, - IN u4Byte offset, - IN pu4Byte data - ); -typedef VOID -(*BFP_BTC_DISP_DBG_MSG)( - IN PVOID pBtCoexist, - IN u1Byte dispType - ); - -typedef struct _BTC_BT_INFO{ - BOOLEAN bBtDisabled; - u1Byte rssiAdjustForAgcTableOn; - u1Byte rssiAdjustFor1AntCoexType; - BOOLEAN bPreBtCtrlAggBufSize; - BOOLEAN bBtCtrlAggBufSize; - BOOLEAN bPreRejectAggPkt; - BOOLEAN bRejectAggPkt; - BOOLEAN bIncreaseScanDevNum; - BOOLEAN bBtTxRxMask; - u1Byte preAggBufSize; - u1Byte aggBufSize; - BOOLEAN bBtBusy; - BOOLEAN bLimitedDig; - u2Byte btHciVer; - u2Byte btRealFwVer; - u1Byte btFwVer; - u4Byte getBtFwVerCnt; - BOOLEAN bMiracastPlusBt; - - BOOLEAN bBtDisableLowPwr; - - BOOLEAN bBtCtrlLps; - BOOLEAN bBtLpsOn; - BOOLEAN bForceToRoam; // for 1Ant solution - u1Byte lpsVal; - u1Byte rpwmVal; - u4Byte raMask; -} BTC_BT_INFO, *PBTC_BT_INFO; - -typedef struct _BTC_STACK_INFO{ - BOOLEAN bProfileNotified; - u2Byte hciVersion; // stack hci version - u1Byte numOfLink; - BOOLEAN bBtLinkExist; - BOOLEAN bScoExist; - BOOLEAN bAclExist; - BOOLEAN bA2dpExist; - BOOLEAN bHidExist; - u1Byte numOfHid; - BOOLEAN bPanExist; - BOOLEAN bUnknownAclExist; - s1Byte minBtRssi; -} BTC_STACK_INFO, *PBTC_STACK_INFO; - -typedef struct _BTC_BT_LINK_INFO{ - BOOLEAN bBtLinkExist; - BOOLEAN bBtHiPriLinkExist; - BOOLEAN bScoExist; - BOOLEAN bScoOnly; - BOOLEAN bA2dpExist; - BOOLEAN bA2dpOnly; - BOOLEAN bHidExist; - BOOLEAN bHidOnly; - BOOLEAN bPanExist; - BOOLEAN bPanOnly; - BOOLEAN bSlaveRole; - BOOLEAN bAclBusy; -} BTC_BT_LINK_INFO, *PBTC_BT_LINK_INFO; - -typedef struct _BTC_STATISTICS{ - u4Byte cntBind; - u4Byte cntPowerOn; - u4Byte cntPreLoadFirmware; - u4Byte cntInitHwConfig; - u4Byte cntInitCoexDm; - u4Byte cntIpsNotify; - u4Byte cntLpsNotify; - u4Byte cntScanNotify; - u4Byte cntConnectNotify; - u4Byte cntMediaStatusNotify; - u4Byte cntSpecialPacketNotify; - u4Byte cntBtInfoNotify; - u4Byte cntRfStatusNotify; - u4Byte cntPeriodical; - u4Byte cntCoexDmSwitch; - u4Byte cntStackOperationNotify; - u4Byte cntDbgCtrl; -} BTC_STATISTICS, *PBTC_STATISTICS; - -typedef struct _BTC_COEXIST{ - BOOLEAN bBinded; // make sure only one adapter can bind the data context - PVOID Adapter; // default adapter - BTC_BOARD_INFO boardInfo; - BTC_BT_INFO btInfo; // some bt info referenced by non-bt module - BTC_STACK_INFO stackInfo; - BTC_BT_LINK_INFO btLinkInfo; - BTC_CHIP_INTERFACE chipInterface; - - BOOLEAN bInitilized; - BOOLEAN bStopCoexDm; - BOOLEAN bManualControl; - pu1Byte cliBuf; - BTC_STATISTICS statistics; - u1Byte pwrModeVal[10]; - - // function pointers - // io related - BFP_BTC_R1 fBtcRead1Byte; - BFP_BTC_W1 fBtcWrite1Byte; - BFP_BTC_W1_BIT_MASK fBtcWrite1ByteBitMask; - BFP_BTC_R2 fBtcRead2Byte; - BFP_BTC_W2 fBtcWrite2Byte; - BFP_BTC_R4 fBtcRead4Byte; - BFP_BTC_W4 fBtcWrite4Byte; - BFP_BTC_LOCAL_REG_W1 fBtcWriteLocalReg1Byte; - // read/write bb related - BFP_BTC_SET_BB_REG fBtcSetBbReg; - BFP_BTC_GET_BB_REG fBtcGetBbReg; - - // read/write rf related - BFP_BTC_SET_RF_REG fBtcSetRfReg; - BFP_BTC_GET_RF_REG fBtcGetRfReg; - - // fill h2c related - BFP_BTC_FILL_H2C fBtcFillH2c; - // other - BFP_BTC_DISP_DBG_MSG fBtcDispDbgMsg; - // normal get/set related - BFP_BTC_GET fBtcGet; - BFP_BTC_SET fBtcSet; - - BFP_BTC_GET_BT_REG fBtcGetBtReg; - BFP_BTC_SET_BT_REG fBtcSetBtReg; - - BFP_BTC_SET_BT_ANT_DETECTION fBtcSetBtAntDetection; -} BTC_COEXIST, *PBTC_COEXIST; - -extern BTC_COEXIST GLBtCoexist; - -BOOLEAN -EXhalbtcoutsrc_InitlizeVariables( - IN PVOID Adapter - ); -VOID -EXhalbtcoutsrc_PowerOnSetting( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_PreLoadFirmware( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_InitHwConfig( - IN PBTC_COEXIST pBtCoexist, - IN BOOLEAN bWifiOnly - ); -VOID -EXhalbtcoutsrc_InitCoexDm( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_IpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtcoutsrc_LpsNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtcoutsrc_ScanNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtcoutsrc_ConnectNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte action - ); -VOID -EXhalbtcoutsrc_MediaStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN RT_MEDIA_STATUS mediaStatus - ); -VOID -EXhalbtcoutsrc_SpecialPacketNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pktType - ); -VOID -EXhalbtcoutsrc_BtInfoNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtcoutsrc_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtcoutsrc_StackOperationNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ); -VOID -EXhalbtcoutsrc_HaltNotify( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_PnpNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte pnpState - ); -VOID -EXhalbtcoutsrc_ScoreBoardStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN pu1Byte tmpBuf, - IN u1Byte length - ); -VOID -EXhalbtcoutsrc_CoexDmSwitch( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_Periodical( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_DbgControl( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte opCode, - IN u1Byte opLen, - IN pu1Byte pData - ); -VOID -EXhalbtcoutsrc_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ); -VOID -EXhalbtcoutsrc_StackUpdateProfileInfo( - VOID - ); -VOID -EXhalbtcoutsrc_SetHciVersion( - IN u2Byte hciVersion - ); -VOID -EXhalbtcoutsrc_SetBtPatchVersion( - IN u2Byte btHciVersion, - IN u2Byte btPatchVersion - ); -VOID -EXhalbtcoutsrc_UpdateMinBtRssi( - IN s1Byte btRssi - ); -#if 0 -VOID -EXhalbtcoutsrc_SetBtExist( - IN BOOLEAN bBtExist - ); -#endif -VOID -EXhalbtcoutsrc_SetChipType( - IN u1Byte chipType - ); -VOID -EXhalbtcoutsrc_SetAntNum( - IN u1Byte type, - IN u1Byte antNum - ); -VOID -EXhalbtcoutsrc_SetSingleAntPath( - IN u1Byte singleAntPath - ); -VOID -EXhalbtcoutsrc_DisplayBtCoexInfo( - IN PBTC_COEXIST pBtCoexist - ); -VOID -EXhalbtcoutsrc_DisplayAntDetection( - IN PBTC_COEXIST pBtCoexist - ); - -#endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/Mp_Precomp.h b/drivers/net/wireless/realtek/rtl8188fu/hal/btc/Mp_Precomp.h deleted file mode 100644 index 62abb5e28..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/btc/Mp_Precomp.h +++ /dev/null @@ -1,89 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __MP_PRECOMP_H__ -#define __MP_PRECOMP_H__ - -#include -#include - -#define BT_TMP_BUF_SIZE 100 - -#ifdef PLATFORM_LINUX -#define rsprintf snprintf -#elif defined(PLATFORM_WINDOWS) -#define rsprintf sprintf_s -#endif - -#define DCMD_Printf DBG_BT_INFO - -#define delay_ms(ms) rtw_mdelay_os(ms) - -#ifdef bEnable -#undef bEnable -#endif - -#define WPP_SOFTWARE_TRACE 0 - -typedef enum _BTC_MSG_COMP_TYPE{ - COMP_COEX = 0, - COMP_MAX -}BTC_MSG_COMP_TYPE; -extern u4Byte GLBtcDbgType[]; - -#define DBG_OFF 0 -#define DBG_SEC 1 -#define DBG_SERIOUS 2 -#define DBG_WARNING 3 -#define DBG_LOUD 4 -#define DBG_TRACE 5 - -#if DBG -#ifdef RT_TRACE -#undef RT_TRACE -#define RT_TRACE(dbgtype, dbgflag, printstr)\ -do {\ - if (GLBtcDbgType[dbgtype] & BIT(dbgflag))\ - {\ - DbgPrint printstr;\ - }\ -} while (0) -#endif -#else -#define RT_TRACE(dbgtype, dbgflag, printstr) -#endif - -#include "HalBtcOutSrc.h" -#include "HalBtc8188c2Ant.h" -#include "HalBtc8192d2Ant.h" -#include "HalBtc8192e1Ant.h" -#include "HalBtc8192e2Ant.h" -#include "HalBtc8723a1Ant.h" -#include "HalBtc8723a2Ant.h" -#include "HalBtc8723b1Ant.h" -#include "HalBtc8723b2Ant.h" -#include "HalBtc8812a1Ant.h" -#include "HalBtc8812a2Ant.h" -#include "HalBtc8821a1Ant.h" -#include "HalBtc8821a2Ant.h" -#include "HalBtc8821aCsr2Ant.h" -#include "HalBtc8703b1Ant.h" -#include "HalBtc8703b2Ant.h" - -#endif // __MP_PRECOMP_H__ diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_btcoex.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_btcoex.c deleted file mode 100644 index 29a64c2d4..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_btcoex.c +++ /dev/null @@ -1,3690 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#define __HAL_BTCOEX_C__ - -#ifdef CONFIG_BT_COEXIST - -#include -#include -#include - -//==================================== -// Global variables -//==================================== -const char *const BtProfileString[] = -{ - "NONE", - "A2DP", - "PAN", - "HID", - "SCO", -}; - -const char *const BtSpecString[] = -{ - "1.0b", - "1.1", - "1.2", - "2.0+EDR", - "2.1+EDR", - "3.0+HS", - "4.0", -}; - -const char *const BtLinkRoleString[] = -{ - "Master", - "Slave", -}; - -const char *const h2cStaString[] = -{ - "successful", - "h2c busy", - "rf off", - "fw not read", -}; - -const char *const ioStaString[] = -{ - "success", - "can not IO", - "rf off", - "fw not read", - "wait io timeout", - "invalid len", - "idle Q empty", - "insert waitQ fail", - "unknown fail", - "wrong level", - "h2c stopped", -}; - -const char *const GLBtcWifiBwString[]={ - "11bg", - "HT20", - "HT40", - "HT80", - "HT160" -}; - -const char *const GLBtcWifiFreqString[]={ - "2.4G", - "5G" -}; - -const char *const GLBtcIotPeerString[] = { - "UNKNOWN", - "REALTEK", - "REALTEK_92SE", - "BROADCOM", - "RALINK", - "ATHEROS", - "CISCO", - "MERU", - "MARVELL", - "REALTEK_SOFTAP", /* peer is RealTek SOFT_AP, by Bohn, 2009.12.17 */ - "SELF_SOFTAP", /* Self is SoftAP */ - "AIRGO", - "INTEL", - "RTK_APCLIENT", - "REALTEK_81XX", - "REALTEK_WOW", - "REALTEK_JAGUAR_BCUTAP", - "REALTEK_JAGUAR_CCUTAP" -}; - -#define HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS 8000 - -BTC_COEXIST GLBtCoexist; -u8 GLBtcWiFiInScanState; -u8 GLBtcWiFiInIQKState; -u8 GLBtcWiFiInIPS; -u8 GLBtcWiFiInLPS; -u8 GLBtcBtCoexAliveRegistered; - -/* - * BT control H2C/C2H - */ -/* EXT_EID */ -typedef enum _bt_ext_eid { - C2H_WIFI_FW_ACTIVE_RSP = 0, - C2H_TRIG_BY_BT_FW -} BT_EXT_EID; - -/* C2H_STATUS */ -typedef enum _bt_c2h_status { - BT_STATUS_OK = 0, - BT_STATUS_VERSION_MISMATCH, - BT_STATUS_UNKNOWN_OPCODE, - BT_STATUS_ERROR_PARAMETER -} BT_C2H_STATUS; - -/* C2H BT OP CODES */ -typedef enum _bt_op_code { - BT_OP_GET_BT_VERSION = 0, - BT_OP_WRITE_REG_ADDR = 12, - BT_OP_WRITE_REG_VALUE, - BT_OP_READ_REG = 17 -} BT_OP_CODE; - -#define BTC_MPOPER_TIMEOUT 50 /* unit: ms */ - -#define C2H_MAX_SIZE 16 -u8 GLBtcBtMpOperSeq; -_mutex GLBtcBtMpOperLock; -_timer GLBtcBtMpOperTimer; -_sema GLBtcBtMpRptSema; -u8 GLBtcBtMpRptSeq; -u8 GLBtcBtMpRptStatus; -u8 GLBtcBtMpRptRsp[C2H_MAX_SIZE]; -u8 GLBtcBtMpRptRspSize; -u8 GLBtcBtMpRptWait; -u8 GLBtcBtMpRptWiFiOK; -u8 GLBtcBtMpRptBTOK; - -/* - * Debug - */ -u32 GLBtcDbgType[COMP_MAX]; -u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE]; - -typedef struct _btcoexdbginfo -{ - u8 *info; - u32 size; // buffer total size - u32 len; // now used length -} BTCDBGINFO, *PBTCDBGINFO; - -BTCDBGINFO GLBtcDbgInfo; - -#define BT_Operation(Adapter) _FALSE - -static void DBG_BT_INFO_INIT(PBTCDBGINFO pinfo, u8 *pbuf, u32 size) -{ - if (NULL == pinfo) return; - - _rtw_memset(pinfo, 0, sizeof(BTCDBGINFO)); - - if (pbuf && size) { - pinfo->info = pbuf; - pinfo->size = size; - } -} - -void DBG_BT_INFO(u8 *dbgmsg) -{ - PBTCDBGINFO pinfo; - u32 msglen, buflen; - u8 *pbuf; - - - pinfo = &GLBtcDbgInfo; - - if (NULL == pinfo->info) - return; - - msglen = strlen(dbgmsg); - if (pinfo->len + msglen > pinfo->size) - return; - - pbuf = pinfo->info + pinfo->len; - _rtw_memcpy(pbuf, dbgmsg, msglen); - pinfo->len += msglen; -} - -//==================================== -// Debug related function -//==================================== -static u8 halbtcoutsrc_IsBtCoexistAvailable(PBTC_COEXIST pBtCoexist) -{ - if (!pBtCoexist->bBinded || - NULL == pBtCoexist->Adapter) - { - return _FALSE; - } - return _TRUE; -} - -static void halbtcoutsrc_DbgInit(void) -{ - u8 i; - - for (i = 0; i < COMP_MAX; i++) - GLBtcDbgType[i] = 0; -} - -static u8 halbtcoutsrc_IsCsrBtCoex(PBTC_COEXIST pBtCoexist) -{ - if (pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC4 - || pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC8 - ){ - return _TRUE; - } - return _FALSE; -} - -static u8 halbtcoutsrc_IsHwMailboxExist(PBTC_COEXIST pBtCoexist) -{ - if (pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC4 - || pBtCoexist->boardInfo.btChipType == BTC_CHIP_CSR_BC8 - ){ - return _FALSE; - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - return _FALSE; - } - else - return _TRUE; -} - -static void halbtcoutsrc_LeaveLps(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter; - - - padapter = pBtCoexist->Adapter; - - pBtCoexist->btInfo.bBtCtrlLps = _TRUE; - pBtCoexist->btInfo.bBtLpsOn = _FALSE; - - rtw_btcoex_LPS_Leave(padapter); -} - -void halbtcoutsrc_EnterLps(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter; - - - padapter = pBtCoexist->Adapter; - - pBtCoexist->btInfo.bBtCtrlLps = _TRUE; - pBtCoexist->btInfo.bBtLpsOn = _TRUE; - - rtw_btcoex_LPS_Enter(padapter); -} - -void halbtcoutsrc_NormalLps(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter; - - - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Normal LPS behavior!!!\n")); - - padapter = pBtCoexist->Adapter; - - if (pBtCoexist->btInfo.bBtCtrlLps) - { - pBtCoexist->btInfo.bBtLpsOn = _FALSE; - rtw_btcoex_LPS_Leave(padapter); - pBtCoexist->btInfo.bBtCtrlLps = _FALSE; - - // recover the LPS state to the original -#if 0 - padapter->HalFunc.UpdateLPSStatusHandler( - padapter, - pPSC->RegLeisurePsMode, - pPSC->RegPowerSaveMode); -#endif - } -} - -/* - * Constraint: - * 1. this function will request pwrctrl->lock - */ -void halbtcoutsrc_LeaveLowPower(PBTC_COEXIST pBtCoexist) -{ -#ifdef CONFIG_LPS_LCLK - PADAPTER padapter; - PHAL_DATA_TYPE pHalData; - struct pwrctrl_priv *pwrctrl; - s32 ready; - u32 stime; - s32 utime; - u32 timeout; // unit: ms - - - padapter = pBtCoexist->Adapter; - pHalData = GET_HAL_DATA(padapter); - pwrctrl = adapter_to_pwrctl(padapter); - ready = _FAIL; -#ifdef LPS_RPWM_WAIT_MS - timeout = LPS_RPWM_WAIT_MS; -#else // !LPS_RPWM_WAIT_MS - timeout = 30; -#endif // !LPS_RPWM_WAIT_MS - - if (GLBtcBtCoexAliveRegistered == _TRUE) - return; - - stime = rtw_get_current_time(); - do { - ready = rtw_register_task_alive(padapter, BTCOEX_ALIVE); - if (_SUCCESS == ready) - break; - - utime = rtw_get_passing_time_ms(stime); - if (utime > timeout) - break; - - rtw_msleep_os(1); - } while (1); - - GLBtcBtCoexAliveRegistered = _TRUE; -#endif // CONFIG_LPS_LCLK -} - -/* - * Constraint: - * 1. this function will request pwrctrl->lock - */ -void halbtcoutsrc_NormalLowPower(PBTC_COEXIST pBtCoexist) -{ -#ifdef CONFIG_LPS_LCLK - PADAPTER padapter; - - if (GLBtcBtCoexAliveRegistered == _FALSE) - return; - - padapter = pBtCoexist->Adapter; - rtw_unregister_task_alive(padapter, BTCOEX_ALIVE); - - GLBtcBtCoexAliveRegistered = _FALSE; -#endif // CONFIG_LPS_LCLK -} - -void halbtcoutsrc_DisableLowPower(PBTC_COEXIST pBtCoexist, u8 bLowPwrDisable) -{ - pBtCoexist->btInfo.bBtDisableLowPwr = bLowPwrDisable; - if (bLowPwrDisable) - halbtcoutsrc_LeaveLowPower(pBtCoexist); // leave 32k low power. - else - halbtcoutsrc_NormalLowPower(pBtCoexist); // original 32k low power behavior. -} - -void halbtcoutsrc_AggregationCheck(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter; - BOOLEAN bNeedToAct = _FALSE; - static u32 preTime = 0; - u32 curTime = 0; - - padapter = pBtCoexist->Adapter; - - //===================================== - // To void continuous deleteBA=>addBA=>deleteBA=>addBA - // This function is not allowed to continuous called. - // It can only be called after 8 seconds. - //===================================== - - curTime = rtw_systime_to_ms(rtw_get_current_time()); - if((curTime - preTime) < HALBTCOUTSRC_AGG_CHK_WINDOW_IN_MS) // over 8 seconds you can execute this function again. - { - return; - } - else - { - preTime = curTime; - } - - if (pBtCoexist->btInfo.bRejectAggPkt) - { - bNeedToAct = _TRUE; - pBtCoexist->btInfo.bPreRejectAggPkt = pBtCoexist->btInfo.bRejectAggPkt; - } - else - { - if(pBtCoexist->btInfo.bPreRejectAggPkt) - { - bNeedToAct = _TRUE; - pBtCoexist->btInfo.bPreRejectAggPkt = pBtCoexist->btInfo.bRejectAggPkt; - } - - if (pBtCoexist->btInfo.bPreBtCtrlAggBufSize != - pBtCoexist->btInfo.bBtCtrlAggBufSize) - { - bNeedToAct = _TRUE; - pBtCoexist->btInfo.bPreBtCtrlAggBufSize = pBtCoexist->btInfo.bBtCtrlAggBufSize; - } - - if (pBtCoexist->btInfo.bBtCtrlAggBufSize) - { - if (pBtCoexist->btInfo.preAggBufSize != - pBtCoexist->btInfo.aggBufSize) - { - bNeedToAct = _TRUE; - } - pBtCoexist->btInfo.preAggBufSize = pBtCoexist->btInfo.aggBufSize; - } - } - - if (bNeedToAct) - rtw_btcoex_rx_ampdu_apply(padapter); -} - -u8 halbtcoutsrc_IsWifiBusy(PADAPTER padapter) -{ - struct mlme_priv *pmlmepriv; - - - pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) - { - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) - return _TRUE; - if (_TRUE == pmlmepriv->LinkDetectInfo.bBusyTraffic) - return _TRUE; - } - -#if defined(CONFIG_CONCURRENT_MODE) - pmlmepriv = &padapter->pbuddy_adapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) - { - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) - return _TRUE; - if (_TRUE == pmlmepriv->LinkDetectInfo.bBusyTraffic) - return _TRUE; - } -#endif - - return _FALSE; -} - -static u32 _halbtcoutsrc_GetWifiLinkStatus(PADAPTER padapter) -{ - struct mlme_priv *pmlmepriv; - u8 bp2p; - u32 portConnectedStatus; - - - pmlmepriv = &padapter->mlmepriv; - bp2p = _FALSE; - portConnectedStatus = 0; - -#ifdef CONFIG_P2P - if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) - bp2p = _TRUE; -#endif // CONFIG_P2P - - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE) == _TRUE) - { - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) - { - if (_TRUE == bp2p) - portConnectedStatus |= WIFI_P2P_GO_CONNECTED; - else - portConnectedStatus |= WIFI_AP_CONNECTED; - } - else - { - if (_TRUE == bp2p) - portConnectedStatus |= WIFI_P2P_GC_CONNECTED; - else - portConnectedStatus |= WIFI_STA_CONNECTED; - } - } - - return portConnectedStatus; -} - -u32 halbtcoutsrc_GetWifiLinkStatus(PBTC_COEXIST pBtCoexist) -{ - //================================= - // return value: - // [31:16]=> connected port number - // [15:0]=> port connected bit define - //================================ - - PADAPTER padapter; - u32 retVal; - u32 portConnectedStatus, numOfConnectedPort; - - - padapter = pBtCoexist->Adapter; - retVal = 0; - portConnectedStatus = 0; - numOfConnectedPort = 0; - - retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter); - if (retVal) - { - portConnectedStatus |= retVal; - numOfConnectedPort++; - } - -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->pbuddy_adapter) - { - retVal = _halbtcoutsrc_GetWifiLinkStatus(padapter->pbuddy_adapter); - if (retVal) - { - portConnectedStatus |= retVal; - numOfConnectedPort++; - } - } -#endif // CONFIG_CONCURRENT_MODE - - retVal = (numOfConnectedPort << 16) | portConnectedStatus; - - return retVal; -} - -static u8 _is_btfwver_valid(PBTC_COEXIST pBtCoexist, u16 btfwver) -{ - if (!btfwver) - return _FALSE; - - if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - if (btfwver == 0x8723) - return _FALSE; - - return _TRUE; -} - -static void _btmpoper_timer_hdl(void *p) -{ - if (GLBtcBtMpRptWait) { - GLBtcBtMpRptWait = 0; - _rtw_up_sema(&GLBtcBtMpRptSema); - } -} - -/* - * !IMPORTANT! - * Before call this function, caller should acquire "GLBtcBtMpOperLock"! - * Othrewise there will be racing problem and something may go wrong. - */ -static u8 _btmpoper_cmd(PBTC_COEXIST pBtCoexist, u8 opcode, u8 opcodever, u8 *cmd, u8 size) -{ - PADAPTER padapter; - u8 buf[H2C_BTMP_OPER_LEN] = {0}; - u8 buflen; - u8 seq; - u8 timer_cancelled; - s32 ret; - - - if (!cmd && size) - size = 0; - if ((size + 2) > H2C_BTMP_OPER_LEN) - return BT_STATUS_H2C_LENGTH_EXCEEDED; - buflen = size + 2; - - seq = GLBtcBtMpOperSeq & 0xF; - GLBtcBtMpOperSeq++; - - buf[0] = (opcodever & 0xF) | (seq << 4); - buf[1] = opcode; - if (cmd && size) - _rtw_memcpy(buf+2, cmd, size); - - GLBtcBtMpRptWait = 1; - GLBtcBtMpRptWiFiOK = 0; - GLBtcBtMpRptBTOK = 0; - GLBtcBtMpRptStatus = 0; - padapter = pBtCoexist->Adapter; - _set_timer(&GLBtcBtMpOperTimer, BTC_MPOPER_TIMEOUT); - if (rtw_hal_fill_h2c_cmd(padapter, H2C_BT_MP_OPER, buflen, buf) == _FAIL) { - _cancel_timer(&GLBtcBtMpOperTimer, &timer_cancelled); - ret = BT_STATUS_H2C_FAIL; - goto exit; - } - - _rtw_down_sema(&GLBtcBtMpRptSema); - /* GLBtcBtMpRptWait should be 0 here*/ - - if (!GLBtcBtMpRptWiFiOK) { - DBG_871X("%s: Didn't get H2C Rsp Event!\n", __FUNCTION__); - ret = BT_STATUS_H2C_TIMTOUT; - goto exit; - } - if (!GLBtcBtMpRptBTOK) { - DBG_871X("%s: Didn't get BT response!\n", __FUNCTION__); - ret = BT_STATUS_H2C_BT_NO_RSP; - goto exit; - } - if (seq != GLBtcBtMpRptSeq) { - DBG_871X("%s: Sequence number not match!(%d!=%d)!\n", - __FUNCTION__, seq, GLBtcBtMpRptSeq); - ret = BT_STATUS_C2H_REQNUM_MISMATCH; - goto exit; - } - - switch (GLBtcBtMpRptStatus) { - /* Examine the status reported from C2H */ - case BT_STATUS_OK: - ret = BT_STATUS_BT_OP_SUCCESS; - DBG_871X("%s: C2H status = BT_STATUS_BT_OP_SUCCESS\n", __FUNCTION__); - break; - case BT_STATUS_VERSION_MISMATCH: - ret = BT_STATUS_OPCODE_L_VERSION_MISMATCH; - DBG_871X("%s: C2H status = BT_STATUS_OPCODE_L_VERSION_MISMATCH\n", __FUNCTION__); - break; - case BT_STATUS_UNKNOWN_OPCODE: - ret = BT_STATUS_UNKNOWN_OPCODE_L; - DBG_871X("%s: C2H status = MP_BT_STATUS_UNKNOWN_OPCODE_L\n", __FUNCTION__); - break; - case BT_STATUS_ERROR_PARAMETER: - ret = BT_STATUS_PARAMETER_FORMAT_ERROR_L; - DBG_871X("%s: C2H status = MP_BT_STATUS_PARAMETER_FORMAT_ERROR_L\n", __FUNCTION__); - break; - default: - ret = BT_STATUS_UNKNOWN_STATUS_L; - DBG_871X("%s: C2H status = MP_BT_STATUS_UNKNOWN_STATUS_L\n", __FUNCTION__); - break; - } - -exit: - return ret; -} - -u32 halbtcoutsrc_GetBtPatchVer(PBTC_COEXIST pBtCoexist) -{ - if (_is_btfwver_valid(pBtCoexist, pBtCoexist->btInfo.btRealFwVer) == _TRUE) - goto exit; - - if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) { - _irqL irqL; - u8 ret; - - - _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL); - - ret = _btmpoper_cmd(pBtCoexist, BT_OP_GET_BT_VERSION, 0, NULL, 0); - if (BT_STATUS_BT_OP_SUCCESS == ret) { - pBtCoexist->btInfo.btRealFwVer = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp); - pBtCoexist->btInfo.btFwVer = *(GLBtcBtMpRptRsp+2); - } - pBtCoexist->btInfo.getBtFwVerCnt++; - - _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL); - } else { -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - u1Byte dataLen = 2; - u1Byte buf[4] = {0}; - - buf[0] = 0x0; /* OP_Code */ - buf[1] = 0x0; /* OP_Code_Length */ - BT_SendEventExtBtCoexControl(pBtCoexist->Adapter, _FALSE, dataLen, &buf[0]); -#endif /* !CONFIG_BT_COEXIST_SOCKET_TRX */ - } - -exit: - return pBtCoexist->btInfo.btRealFwVer; -} - -s32 halbtcoutsrc_GetWifiRssi(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - s32 UndecoratedSmoothedPWDB = 0; - - pHalData = GET_HAL_DATA(padapter); - - UndecoratedSmoothedPWDB = pHalData->EntryMinUndecoratedSmoothedPWDB; - - return UndecoratedSmoothedPWDB; -} - -static u8 halbtcoutsrc_GetWifiScanAPNum(PADAPTER padapter) -{ - struct mlme_priv *pmlmepriv; - struct mlme_ext_priv *pmlmeext; - static u8 scan_AP_num = 0; - - - pmlmepriv = &padapter->mlmepriv; - pmlmeext = &padapter->mlmeextpriv; - - if (GLBtcWiFiInScanState == _FALSE) { - if (pmlmepriv->num_of_scanned > 0xFF) - scan_AP_num = 0xFF; - else - scan_AP_num = (u8)pmlmepriv->num_of_scanned; - } - - return scan_AP_num; -} - -u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - PHAL_DATA_TYPE pHalData; - struct mlme_ext_priv *mlmeext; - u8 bSoftApExist, bVwifiExist; - u8 *pu8; - s32 *pS4Tmp; - u32 *pU4Tmp; - u8 *pU1Tmp; - u8 ret; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return _FALSE; - - padapter = pBtCoexist->Adapter; - pHalData = GET_HAL_DATA(padapter); - mlmeext = &padapter->mlmeextpriv; - bSoftApExist = _FALSE; - bVwifiExist = _FALSE; - pu8 = (u8*)pOutBuf; - pS4Tmp = (s32*)pOutBuf; - pU4Tmp = (u32*)pOutBuf; - pU1Tmp = (u8*)pOutBuf; - ret = _TRUE; - - switch (getType) - { - case BTC_GET_BL_HS_OPERATION: - *pu8 = _FALSE; - ret = _FALSE; - break; - - case BTC_GET_BL_HS_CONNECTING: - *pu8 = _FALSE; - ret = _FALSE; - break; - - case BTC_GET_BL_WIFI_CONNECTED: - *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE); -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == *pu8) && padapter->pbuddy_adapter) - { - *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_ASOC_STATE); - } -#endif // CONFIG_CONCURRENT_MODE - break; - - case BTC_GET_BL_WIFI_BUSY: - *pu8 = halbtcoutsrc_IsWifiBusy(padapter); - break; - - case BTC_GET_BL_WIFI_SCAN: -#if 0 - *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_SITE_MONITOR); -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == *pu8) && padapter->pbuddy_adapter) - { - *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_SITE_MONITOR); - } -#endif // CONFIG_CONCURRENT_MODE -#else - /* Use the value of the new variable GLBtcWiFiInScanState to judge whether WiFi is in scan state or not, since the originally used flag - WIFI_SITE_MONITOR in fwstate may not be cleared in time */ - *pu8 = GLBtcWiFiInScanState; -#endif - break; - - case BTC_GET_BL_WIFI_LINK: - *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == *pu8) && padapter->pbuddy_adapter) - { - *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_UNDER_LINKING); - } -#endif // CONFIG_CONCURRENT_MODE - break; - - case BTC_GET_BL_WIFI_ROAM: - *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_UNDER_LINKING); -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == *pu8) && padapter->pbuddy_adapter) - { - *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_UNDER_LINKING); - } -#endif // CONFIG_CONCURRENT_MODE - break; - - case BTC_GET_BL_WIFI_4_WAY_PROGRESS: - *pu8 = _FALSE; - break; - - case BTC_GET_BL_WIFI_UNDER_5G: - *pu8 = (pHalData->CurrentBandType == 1)? _TRUE : _FALSE; - break; - - case BTC_GET_BL_WIFI_AP_MODE_ENABLE: - *pu8 = check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE); -#ifdef CONFIG_CONCURRENT_MODE - if ((_FALSE == *pu8) && padapter->pbuddy_adapter) - { - *pu8 = check_fwstate(&padapter->pbuddy_adapter->mlmepriv, WIFI_AP_STATE); - } -#endif // CONFIG_CONCURRENT_MODE - break; - - case BTC_GET_BL_WIFI_ENABLE_ENCRYPTION: - *pu8 = padapter->securitypriv.dot11PrivacyAlgrthm == 0? _FALSE: _TRUE; - break; - - case BTC_GET_BL_WIFI_UNDER_B_MODE: - if (mlmeext->cur_wireless_mode == WIRELESS_11B) - *pu8 = _TRUE; - else - *pu8 = _FALSE; - break; - - case BTC_GET_BL_WIFI_IS_IN_MP_MODE: - if (padapter->registrypriv.mp_mode == 0) - { - *pu8 = _FALSE; - } - else - { - *pu8 = _TRUE; - } - break; - - case BTC_GET_BL_EXT_SWITCH: - *pu8 = _FALSE; - break; - case BTC_GET_BL_IS_ASUS_8723B: - /* Always return FALSE in linux driver since this case is added only for windows driver */ - *pu8 = _FALSE; - break; - - case BTC_GET_S4_WIFI_RSSI: - *pS4Tmp = halbtcoutsrc_GetWifiRssi(padapter); - break; - - case BTC_GET_S4_HS_RSSI: - *pS4Tmp = 0; - ret = _FALSE; - break; - - case BTC_GET_U4_WIFI_BW: - if (IsLegacyOnly(mlmeext->cur_wireless_mode)) - *pU4Tmp = BTC_WIFI_BW_LEGACY; - else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20) - *pU4Tmp = BTC_WIFI_BW_HT20; - else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_40) - *pU4Tmp = BTC_WIFI_BW_HT40; - else - *pU4Tmp = BTC_WIFI_BW_HT40; /* todo */ - break; - - case BTC_GET_U4_WIFI_TRAFFIC_DIRECTION: - { - PRT_LINK_DETECT_T plinkinfo; - plinkinfo = &padapter->mlmepriv.LinkDetectInfo; - - if (plinkinfo->NumTxOkInPeriod > plinkinfo->NumRxOkInPeriod) - *pU4Tmp = BTC_WIFI_TRAFFIC_TX; - else - *pU4Tmp = BTC_WIFI_TRAFFIC_RX; - } - break; - - case BTC_GET_U4_WIFI_FW_VER: - *pU4Tmp = pHalData->FirmwareVersion << 16; - *pU4Tmp |= pHalData->FirmwareSubVersion; - break; - - case BTC_GET_U4_WIFI_LINK_STATUS: - *pU4Tmp = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist); - break; - - case BTC_GET_U4_BT_PATCH_VER: - *pU4Tmp = halbtcoutsrc_GetBtPatchVer(pBtCoexist); - break; - - case BTC_GET_U1_WIFI_DOT11_CHNL: - *pU1Tmp = padapter->mlmeextpriv.cur_channel; - break; - - case BTC_GET_U1_WIFI_CENTRAL_CHNL: - *pU1Tmp = pHalData->CurrentChannel; - break; - - case BTC_GET_U1_WIFI_HS_CHNL: - *pU1Tmp = 0; - ret = _FALSE; - break; - - case BTC_GET_U1_MAC_PHY_MODE: -// *pU1Tmp = BTC_SMSP; -// *pU1Tmp = BTC_DMSP; -// *pU1Tmp = BTC_DMDP; -// *pU1Tmp = BTC_MP_UNKNOWN; - break; - - case BTC_GET_U1_AP_NUM: - *pU1Tmp = halbtcoutsrc_GetWifiScanAPNum(padapter); - break; - case BTC_GET_U1_ANT_TYPE: - switch(pHalData->bt_coexist.btAntisolation) - { - case 0: - *pU1Tmp = (u1Byte)BTC_ANT_TYPE_0; - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_0; - break; - case 1: - *pU1Tmp = (u1Byte)BTC_ANT_TYPE_1; - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_1; - break; - case 2: - *pU1Tmp = (u1Byte)BTC_ANT_TYPE_2; - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_2; - break; - case 3: - *pU1Tmp = (u1Byte)BTC_ANT_TYPE_3; - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_3; - break; - case 4: - *pU1Tmp = (u1Byte)BTC_ANT_TYPE_4; - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_4; - break; - } - break; - case BTC_GET_U1_IOT_PEER: - *pU1Tmp = mlmeext->mlmext_info.assoc_AP_vendor; - break; - - //=======1Ant=========== - case BTC_GET_U1_LPS_MODE: - *pU1Tmp = padapter->dvobj->pwrctl_priv.pwr_mode; - break; - - default: - ret = _FALSE; - break; - } - - return ret; -} - -u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - PHAL_DATA_TYPE pHalData; - u8 *pu8; - u8 *pU1Tmp; - u32 *pU4Tmp; - u8 ret; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - pHalData = GET_HAL_DATA(padapter); - pu8 = (u8*)pInBuf; - pU1Tmp = (u8*)pInBuf; - pU4Tmp = (u32*)pInBuf; - ret = _TRUE; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return _FALSE; - - switch (setType) - { - // set some u8 type variables. - case BTC_SET_BL_BT_DISABLE: - pBtCoexist->btInfo.bBtDisabled = *pu8; - break; - - case BTC_SET_BL_BT_TRAFFIC_BUSY: - pBtCoexist->btInfo.bBtBusy = *pu8; - break; - - case BTC_SET_BL_BT_LIMITED_DIG: - pBtCoexist->btInfo.bLimitedDig = *pu8; - break; - - case BTC_SET_BL_FORCE_TO_ROAM: - pBtCoexist->btInfo.bForceToRoam = *pu8; - break; - - case BTC_SET_BL_TO_REJ_AP_AGG_PKT: - pBtCoexist->btInfo.bRejectAggPkt = *pu8; - break; - - case BTC_SET_BL_BT_CTRL_AGG_SIZE: - pBtCoexist->btInfo.bBtCtrlAggBufSize = *pu8; - break; - - case BTC_SET_BL_INC_SCAN_DEV_NUM: - pBtCoexist->btInfo.bIncreaseScanDevNum = *pu8; - break; - - case BTC_SET_BL_BT_TX_RX_MASK: - pBtCoexist->btInfo.bBtTxRxMask = *pu8; - break; - - case BTC_SET_BL_MIRACAST_PLUS_BT: - pBtCoexist->btInfo.bMiracastPlusBt = *pu8; - break; - - // set some u8 type variables. - case BTC_SET_U1_RSSI_ADJ_VAL_FOR_AGC_TABLE_ON: - pBtCoexist->btInfo.rssiAdjustForAgcTableOn = *pU1Tmp; - break; - - case BTC_SET_U1_AGG_BUF_SIZE: - pBtCoexist->btInfo.aggBufSize = *pU1Tmp; - break; - - // the following are some action which will be triggered - case BTC_SET_ACT_GET_BT_RSSI: -#if 0 - BT_SendGetBtRssiEvent(padapter); -#else - ret = _FALSE; -#endif - break; - - case BTC_SET_ACT_AGGREGATE_CTRL: - halbtcoutsrc_AggregationCheck(pBtCoexist); - break; - - //=======1Ant=========== - // set some u8 type variables. - case BTC_SET_U1_RSSI_ADJ_VAL_FOR_1ANT_COEX_TYPE: - pBtCoexist->btInfo.rssiAdjustFor1AntCoexType = *pU1Tmp; - break; - - case BTC_SET_U1_LPS_VAL: - pBtCoexist->btInfo.lpsVal = *pU1Tmp; - break; - - case BTC_SET_U1_RPWM_VAL: - pBtCoexist->btInfo.rpwmVal = *pU1Tmp; - break; - - // the following are some action which will be triggered - case BTC_SET_ACT_LEAVE_LPS: - halbtcoutsrc_LeaveLps(pBtCoexist); - break; - - case BTC_SET_ACT_ENTER_LPS: - halbtcoutsrc_EnterLps(pBtCoexist); - break; - - case BTC_SET_ACT_NORMAL_LPS: - halbtcoutsrc_NormalLps(pBtCoexist); - break; - - case BTC_SET_ACT_DISABLE_LOW_POWER: - halbtcoutsrc_DisableLowPower(pBtCoexist, *pu8); - break; - - case BTC_SET_ACT_UPDATE_RAMASK: - pBtCoexist->btInfo.raMask = *pU4Tmp; - - if (check_fwstate(&padapter->mlmepriv, WIFI_ASOC_STATE) == _TRUE) - { - struct sta_info *psta; - PWLAN_BSSID_EX cur_network; - - cur_network = &padapter->mlmeextpriv.mlmext_info.network; - psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress); - rtw_hal_update_ra_mask(psta, 0); - } - break; - - case BTC_SET_ACT_SEND_MIMO_PS: - { - u8 newMimoPsMode = 3; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - /* *pU1Tmp = 0 use SM_PS static type */ - /* *pU1Tmp = 1 disable SM_PS */ - if (*pU1Tmp == 0) - newMimoPsMode = WLAN_HT_CAP_SM_PS_STATIC; - else if (*pU1Tmp == 1) - newMimoPsMode = WLAN_HT_CAP_SM_PS_DISABLED; - - if (check_fwstate(&padapter->mlmepriv , WIFI_ASOC_STATE) == _TRUE) { - /* issue_action_SM_PS(padapter, get_my_bssid(&(pmlmeinfo->network)), newMimoPsMode); */ - issue_action_SM_PS_wait_ack(padapter , get_my_bssid(&(pmlmeinfo->network)) , newMimoPsMode, 3 , 1); - } - } - break; - - case BTC_SET_ACT_CTRL_BT_INFO: -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - { - u8 dataLen = *pU1Tmp; - u8 tmpBuf[20]; - if (dataLen) - { - _rtw_memcpy(tmpBuf, pU1Tmp+1, dataLen); - } - BT_SendEventExtBtInfoControl(padapter, dataLen, &tmpBuf[0]); - } -#else //!CONFIG_BT_COEXIST_SOCKET_TRX - ret = _FALSE; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - break; - - case BTC_SET_ACT_CTRL_BT_COEX: -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - { - u8 dataLen = *pU1Tmp; - u8 tmpBuf[20]; - if (dataLen) - { - _rtw_memcpy(tmpBuf, pU1Tmp+1, dataLen); - } - BT_SendEventExtBtCoexControl(padapter, _FALSE, dataLen, &tmpBuf[0]); - } -#else //!CONFIG_BT_COEXIST_SOCKET_TRX - ret = _FALSE; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - break; - case BTC_SET_ACT_CTRL_8723B_ANT: -#if 0 - { - u1Byte dataLen=*pU1Tmp; - u1Byte tmpBuf[20]; - if(dataLen) - { - PlatformMoveMemory(&tmpBuf[0], pU1Tmp+1, dataLen); - } - BT_Set8723bAnt(Adapter, dataLen, &tmpBuf[0]); - } -#else - ret = _FALSE; -#endif - break; - //===================== - default: - ret = _FALSE; - break; - } - - return ret; -} - -u8 halbtcoutsrc_UnderIps(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter; - struct pwrctrl_priv *pwrpriv; - u8 bMacPwrCtrlOn; - - padapter = pBtCoexist->Adapter; - pwrpriv = &padapter->dvobj->pwrctl_priv; - bMacPwrCtrlOn = _FALSE; - - if ((_TRUE == pwrpriv->bips_processing) - && (IPS_NONE != pwrpriv->ips_mode_req) - ) - { - return _TRUE; - } - - if (rf_off == pwrpriv->rf_pwrstate) - { - return _TRUE; - } - - rtw_hal_get_hwreg(padapter, HW_VAR_APFM_ON_MAC, &bMacPwrCtrlOn); - if (_FALSE == bMacPwrCtrlOn) - { - return _TRUE; - } - - return _FALSE; -} - -u8 halbtcoutsrc_UnderLps(PBTC_COEXIST pBtCoexist) -{ - return GLBtcWiFiInLPS; -} - -u8 halbtcoutsrc_Under32K(PBTC_COEXIST pBtCoexist) -{ - /* todo: the method to check whether wifi is under 32K or not */ - return _FALSE; -} - -void halbtcoutsrc_DisplayCoexStatistics(PBTC_COEXIST pBtCoexist) -{ -#if 0 - PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter; - PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt; - PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter); - u8 *cliBuf = pBtCoexist->cliBuf; - u8 i; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Statistics]============"); - CL_PRINTF(cliBuf); - -#if (H2C_USE_IO_THREAD != 1) - for(i=0; ih2cStatistics[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \ - h2cStaString[i], pHalData->h2cStatistics[i]); - CL_PRINTF(cliBuf); - } - } -#else - for(i=0; iioComStr.ioH2cStatistics[i]) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = [%s] = %d", "H2C statistics", \ - ioStaString[i], Adapter->ioComStr.ioH2cStatistics[i]); - CL_PRINTF(cliBuf); - } - } -#endif -#if 0 - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x", "lastHMEBoxNum", \ - pHalData->LastHMEBoxNum); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x / 0x%x", "LastOkH2c/FirstFailH2c(fwNotRead)", \ - pHalData->lastSuccessH2cEid, pHalData->firstFailedH2cEid); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "c2hIsr/c2hIntr/clr1AF/noRdy/noBuf", \ - pHalData->InterruptLog.nIMR_C2HCMD, DBG_Var.c2hInterruptCnt, DBG_Var.c2hClrReadC2hCnt, - DBG_Var.c2hNotReadyCnt, DBG_Var.c2hBufAlloFailCnt); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "c2hPacket", \ - DBG_Var.c2hPacketCnt); - CL_PRINTF(cliBuf); -#endif - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Periodical/ DbgCtrl", \ - pBtCoexist->statistics.cntPeriodical, pBtCoexist->statistics.cntDbgCtrl); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d", "PowerOn/InitHw/InitCoexDm/RfStatus", \ - pBtCoexist->statistics.cntPowerOn, pBtCoexist->statistics.cntInitHwConfig, pBtCoexist->statistics.cntInitCoexDm, - pBtCoexist->statistics.cntRfStatusNotify); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "Ips/Lps/Scan/Connect/Mstatus", \ - pBtCoexist->statistics.cntIpsNotify, pBtCoexist->statistics.cntLpsNotify, - pBtCoexist->statistics.cntScanNotify, pBtCoexist->statistics.cntConnectNotify, - pBtCoexist->statistics.cntMediaStatusNotify); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d", "Special pkt/Bt info/ bind", - pBtCoexist->statistics.cntSpecialPacketNotify, pBtCoexist->statistics.cntBtInfoNotify, - pBtCoexist->statistics.cntBind); - CL_PRINTF(cliBuf); -#endif -} - -void halbtcoutsrc_DisplayBtLinkInfo(PBTC_COEXIST pBtCoexist) -{ -#if 0 - PADAPTER padapter = (PADAPTER)pBtCoexist->Adapter; - PBT_MGNT pBtMgnt = &padapter->MgntInfo.BtInfo.BtMgnt; - u8 *cliBuf = pBtCoexist->cliBuf; - u8 i; - - - if (pBtCoexist->stackInfo.bProfileNotified) - { - for (i=0; iExtConfig.NumberOfACL; i++) - { - if (pBtMgnt->ExtConfig.HCIExtensionVer >= 1) - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s/ %s", "Bt link type/spec/role", \ - BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile], - BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec], - BtLinkRoleString[pBtMgnt->ExtConfig.aclLink[i].linkRole]); - CL_PRINTF(cliBuf); } - else - { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s/ %s", "Bt link type/spec", \ - BtProfileString[pBtMgnt->ExtConfig.aclLink[i].BTProfile], - BtSpecString[pBtMgnt->ExtConfig.aclLink[i].BTCoreSpec]); - CL_PRINTF(cliBuf); - } - } - } -#endif -} - -void halbtcoutsrc_DisplayWifiStatus(PBTC_COEXIST pBtCoexist) -{ - PADAPTER padapter = pBtCoexist->Adapter; - struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); - u8* cliBuf=pBtCoexist->cliBuf; - s32 wifiRssi=0, btHsRssi=0; - BOOLEAN bScan=_FALSE, bLink=_FALSE, bRoam=_FALSE, bWifiBusy=_FALSE, bWifiUnderBMode=_FALSE; - u32 wifiBw=BTC_WIFI_BW_HT20, wifiTrafficDir=BTC_WIFI_TRAFFIC_TX, wifiFreq=BTC_FREQ_2_4G; - u32 wifiLinkStatus=0x0; - BOOLEAN bBtHsOn=_FALSE, bLowPower=_FALSE; - u8 wifiChnl=0, wifiHsChnl=0, nScanAPNum = 0, FwPSState; - - wifiLinkStatus = halbtcoutsrc_GetWifiLinkStatus(pBtCoexist); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "STA/vWifi/HS/p2pGo/p2pGc", \ - ((wifiLinkStatus&WIFI_STA_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_AP_CONNECTED)? 1:0), - ((wifiLinkStatus&WIFI_HS_CONNECTED)? 1:0), ((wifiLinkStatus&WIFI_P2P_GO_CONNECTED)? 1:0), - ((wifiLinkStatus&WIFI_P2P_GC_CONNECTED)? 1:0) ); - CL_PRINTF(cliBuf); - - if (wifiLinkStatus&WIFI_STA_CONNECTED) { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "IOT Peer", GLBtcIotPeerString[padapter->mlmeextpriv.mlmext_info.assoc_AP_vendor]); - CL_PRINTF(cliBuf); - } - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiChnl); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(High Speed)", \ - wifiChnl, wifiHsChnl, bBtHsOn); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", \ - wifiRssi-100, btHsRssi-100); - CL_PRINTF(cliBuf); - - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \ - bLink, bRoam, bScan); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_5G, &wifiFreq); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &nScanAPNum); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s / %s/ %s/ AP=%d ", "Wifi freq/ bw/ traffic", \ - GLBtcWifiFreqString[wifiFreq], ((bWifiUnderBMode)? "11b": GLBtcWifiBwString[wifiBw]), - ((!bWifiBusy)? "idle": ((BTC_WIFI_TRAFFIC_TX==wifiTrafficDir)? "uplink":"downlink")), - nScanAPNum); - CL_PRINTF(cliBuf); - - // power status - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s%s%s", "Power Status", \ - ((halbtcoutsrc_UnderIps(pBtCoexist) == _TRUE)? "IPS ON":"IPS OFF"), - ((halbtcoutsrc_UnderLps(pBtCoexist) == _TRUE)? ", LPS ON":", LPS OFF"), - ((halbtcoutsrc_Under32K(pBtCoexist) == _TRUE)? ", 32k":"")); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x (0x%x/0x%x)", "Power mode cmd(lps/rpwm)", \ - pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1], - pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3], - pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5], - pBtCoexist->btInfo.lpsVal, - pBtCoexist->btInfo.rpwmVal); - CL_PRINTF(cliBuf); -} - -void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType) -{ - PBTC_COEXIST pBtCoexist; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - switch(dispType) - { - case BTC_DBG_DISP_COEX_STATISTICS: - halbtcoutsrc_DisplayCoexStatistics(pBtCoexist); - break; - case BTC_DBG_DISP_BT_LINK_INFO: - halbtcoutsrc_DisplayBtLinkInfo(pBtCoexist); - break; - case BTC_DBG_DISP_WIFI_STATUS: - halbtcoutsrc_DisplayWifiStatus(pBtCoexist); - break; - default: - break; - } -} - -//==================================== -// IO related function -//==================================== -u8 halbtcoutsrc_Read1Byte(void *pBtcContext, u32 RegAddr) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - return rtw_read8(padapter, RegAddr); -} - -u16 halbtcoutsrc_Read2Byte(void *pBtcContext, u32 RegAddr) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - return rtw_read16(padapter, RegAddr); -} - -u32 halbtcoutsrc_Read4Byte(void *pBtcContext, u32 RegAddr) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - return rtw_read32(padapter, RegAddr); -} - -void halbtcoutsrc_Write1Byte(void *pBtcContext, u32 RegAddr, u8 Data) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - rtw_write8(padapter, RegAddr, Data); -} - -void halbtcoutsrc_BitMaskWrite1Byte(void *pBtcContext, u32 regAddr, u8 bitMask, u8 data1b) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - u8 originalValue, bitShift; - u8 i; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - originalValue = 0; - bitShift = 0; - - if(bitMask != 0xff) - { - originalValue = rtw_read8(padapter, regAddr); - - for (i=0; i<=7; i++) - { - if ((bitMask>>i)&0x1) - break; - } - bitShift = i; - - data1b = (originalValue & ~bitMask) | ((data1b << bitShift) & bitMask); - } - - rtw_write8(padapter, regAddr, data1b); -} - -void halbtcoutsrc_Write2Byte(void *pBtcContext, u32 RegAddr, u16 Data) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - rtw_write16(padapter, RegAddr, Data); -} - -void halbtcoutsrc_Write4Byte(void *pBtcContext, u32 RegAddr, u32 Data) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - rtw_write32(padapter, RegAddr, Data); -} - -void halbtcoutsrc_WriteLocalReg1Byte(void *pBtcContext, u32 RegAddr, u8 Data) -{ - PBTC_COEXIST pBtCoexist=(PBTC_COEXIST)pBtcContext; - PADAPTER Adapter=pBtCoexist->Adapter; - - if(BTC_INTF_SDIO == pBtCoexist->chipInterface) - { - rtw_write8(Adapter, SDIO_LOCAL_BASE | RegAddr, Data); - } - else - { - rtw_write8(Adapter, RegAddr, Data); - } -} - -void halbtcoutsrc_SetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask, u32 Data) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - PHY_SetBBReg(padapter, RegAddr, BitMask, Data); -} - - -u32 halbtcoutsrc_GetBbReg(void *pBtcContext, u32 RegAddr, u32 BitMask) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - return PHY_QueryBBReg(padapter, RegAddr, BitMask); -} - -void halbtcoutsrc_SetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask, u32 Data) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - PHY_SetRFReg(padapter, eRFPath, RegAddr, BitMask, Data); -} - -u32 halbtcoutsrc_GetRfReg(void *pBtcContext, u8 eRFPath, u32 RegAddr, u32 BitMask) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - return PHY_QueryRFReg(padapter, eRFPath, RegAddr, BitMask); -} - -u16 halbtcoutsrc_SetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 Data) -{ - PBTC_COEXIST pBtCoexist; - u16 ret = BT_STATUS_BT_OP_SUCCESS; - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - - if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) { - u8 buf[3] = {0}; - _irqL irqL; - u8 op_code; - u8 status; - - _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL); - - Data = cpu_to_le32(Data); - op_code = BT_OP_WRITE_REG_VALUE; - status = _btmpoper_cmd(pBtCoexist, op_code, 0, (u8 *)&Data, 3); - if (status != BT_STATUS_BT_OP_SUCCESS) - ret = SET_BT_MP_OPER_RET(op_code, status); - else { - buf[0] = RegType; - *(u16 *)(buf+1) = cpu_to_le16((u16)RegAddr); - op_code = BT_OP_WRITE_REG_ADDR; - status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3); - if (status != BT_STATUS_BT_OP_SUCCESS) - ret = SET_BT_MP_OPER_RET(op_code, status); - } - - _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL); - } else - ret = BT_STATUS_NOT_IMPLEMENT; - - return ret; -} - -u8 halbtcoutsrc_SetBtAntDetection(void *pBtcContext, u8 txTime, u8 btChnl) -{ -/* Always return _FALSE since we don't implement this yet */ -#if 0 - PBTC_COEXIST pBtCoexist = (PBTC_COEXIST)pBtcContext; - PADAPTER Adapter = pBtCoexist->Adapter; - u1Byte btCanTx = 0; - BOOLEAN bStatus = FALSE; - - bStatus = NDBG_SetBtAntDetection(Adapter, txTime, btChnl, &btCanTx); - if (bStatus && btCanTx) - return _TRUE; - else - return _FALSE; -#else - return _FALSE; -#endif -} - -u16 halbtcoutsrc_GetBtReg(void *pBtcContext, u8 RegType, u32 RegAddr, u32 *data) -{ - PBTC_COEXIST pBtCoexist; - u16 ret = BT_STATUS_BT_OP_SUCCESS; - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - - if (halbtcoutsrc_IsHwMailboxExist(pBtCoexist) == _TRUE) { - u8 buf[3] = {0}; - _irqL irqL; - u8 op_code; - u8 status; - - buf[0] = RegType; - *(u16 *)(buf+1) = cpu_to_le16((u16)RegAddr); - - _enter_critical_mutex(&GLBtcBtMpOperLock, &irqL); - - op_code = BT_OP_READ_REG; - status = _btmpoper_cmd(pBtCoexist, op_code, 0, buf, 3); - if (status == BT_STATUS_BT_OP_SUCCESS) - *data = le16_to_cpu(*(u16 *)GLBtcBtMpRptRsp); - else - ret = SET_BT_MP_OPER_RET(op_code, status); - - _exit_critical_mutex(&GLBtcBtMpOperLock, &irqL); - - } else - ret = BT_STATUS_NOT_IMPLEMENT; - - return ret; -} - -void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, u8 *pCmdBuffer) -{ - PBTC_COEXIST pBtCoexist; - PADAPTER padapter; - - - pBtCoexist = (PBTC_COEXIST)pBtcContext; - padapter = pBtCoexist->Adapter; - - rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer); -} - -//==================================== -// Extern functions called by other module -//==================================== -u8 EXhalbtcoutsrc_IsTfbgaPackageType(PADAPTER padapter) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - -#ifdef CONFIG_RTL8723B - if ((pHalData->PackageType == PACKAGE_TFBGA79) || (pHalData->PackageType == PACKAGE_TFBGA80) - || (pHalData->PackageType == PACKAGE_TFBGA90)) { - return _TRUE; - } -#endif - - return _FALSE; -} - -u8 EXhalbtcoutsrc_BindBtCoexWithAdapter(void *padapter) -{ - PBTC_COEXIST pBtCoexist=&GLBtCoexist; - u1Byte antNum=2, chipType; - - if(pBtCoexist->bBinded) - return _FALSE; - else - pBtCoexist->bBinded = _TRUE; - - pBtCoexist->statistics.cntBind++; - - pBtCoexist->Adapter = padapter; - - pBtCoexist->stackInfo.bProfileNotified = _FALSE; - - pBtCoexist->btInfo.bBtCtrlAggBufSize = _FALSE; - pBtCoexist->btInfo.aggBufSize = 5; - - pBtCoexist->btInfo.bIncreaseScanDevNum = _FALSE; - pBtCoexist->btInfo.bMiracastPlusBt = _FALSE; - -#if 0 - chipType = HALBT_GetBtChipType(Adapter); - EXhalbtcoutsrc_SetChipType(chipType); - antNum = HALBT_GetPgAntNum(Adapter); - EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum); -#endif - // set default antenna position to main port - pBtCoexist->boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - - pBtCoexist->boardInfo.btdmAntDetFinish = _FALSE; - pBtCoexist->boardInfo.btdmAntNumByAntDet = 1; - - pBtCoexist->boardInfo.bTfbgaPackage = EXhalbtcoutsrc_IsTfbgaPackageType((PADAPTER)padapter); - - if (pBtCoexist->boardInfo.bTfbgaPackage) - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Package Type = TFBGA\n")); - else - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], Package Type = Non-TFBGA\n")); - - return _TRUE; -} - -u8 EXhalbtcoutsrc_InitlizeVariables(void *padapter) -{ - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - - //pBtCoexist->statistics.cntBind++; - - halbtcoutsrc_DbgInit(); - -#ifdef CONFIG_PCI_HCI - pBtCoexist->chipInterface = BTC_INTF_PCI; -#elif defined(CONFIG_USB_HCI) - pBtCoexist->chipInterface = BTC_INTF_USB; -#elif defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) - pBtCoexist->chipInterface = BTC_INTF_SDIO; -#else - pBtCoexist->chipInterface = BTC_INTF_UNKNOWN; -#endif - - EXhalbtcoutsrc_BindBtCoexWithAdapter(padapter); - - pBtCoexist->fBtcRead1Byte = halbtcoutsrc_Read1Byte; - pBtCoexist->fBtcWrite1Byte = halbtcoutsrc_Write1Byte; - pBtCoexist->fBtcWrite1ByteBitMask = halbtcoutsrc_BitMaskWrite1Byte; - pBtCoexist->fBtcRead2Byte = halbtcoutsrc_Read2Byte; - pBtCoexist->fBtcWrite2Byte = halbtcoutsrc_Write2Byte; - pBtCoexist->fBtcRead4Byte = halbtcoutsrc_Read4Byte; - pBtCoexist->fBtcWrite4Byte = halbtcoutsrc_Write4Byte; - pBtCoexist->fBtcWriteLocalReg1Byte = halbtcoutsrc_WriteLocalReg1Byte; - - pBtCoexist->fBtcSetBbReg = halbtcoutsrc_SetBbReg; - pBtCoexist->fBtcGetBbReg = halbtcoutsrc_GetBbReg; - - pBtCoexist->fBtcSetRfReg = halbtcoutsrc_SetRfReg; - pBtCoexist->fBtcGetRfReg = halbtcoutsrc_GetRfReg; - - pBtCoexist->fBtcFillH2c = halbtcoutsrc_FillH2cCmd; - pBtCoexist->fBtcDispDbgMsg = halbtcoutsrc_DisplayDbgMsg; - - pBtCoexist->fBtcGet = halbtcoutsrc_Get; - pBtCoexist->fBtcSet = halbtcoutsrc_Set; - pBtCoexist->fBtcGetBtReg = halbtcoutsrc_GetBtReg; - pBtCoexist->fBtcSetBtReg = halbtcoutsrc_SetBtReg; - pBtCoexist->fBtcSetBtAntDetection = halbtcoutsrc_SetBtAntDetection; - - pBtCoexist->cliBuf = &GLBtcDbgBuf[0]; - - pBtCoexist->boardInfo.singleAntPath = 0; - - GLBtcWiFiInScanState = _FALSE; - - GLBtcWiFiInIQKState = _FALSE; - - GLBtcWiFiInIPS = _FALSE; - - GLBtcWiFiInLPS = _FALSE; - - GLBtcBtCoexAliveRegistered = _FALSE; - - /* BT Control H2C/C2H*/ - GLBtcBtMpOperSeq = 0; - _rtw_mutex_init(&GLBtcBtMpOperLock); - _init_timer(&GLBtcBtMpOperTimer, ((PADAPTER)padapter)->pnetdev, _btmpoper_timer_hdl, pBtCoexist); - _rtw_init_sema(&GLBtcBtMpRptSema, 0); - GLBtcBtMpRptSeq = 0; - GLBtcBtMpRptStatus = 0; - _rtw_memset(GLBtcBtMpRptRsp, 0, C2H_MAX_SIZE); - GLBtcBtMpRptRspSize = 0; - GLBtcBtMpRptWait = 0; - GLBtcBtMpRptWiFiOK = 0; - GLBtcBtMpRptBTOK = 0; - - return _TRUE; -} - -void EXhalbtcoutsrc_PowerOnSetting(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - /* Power on setting function is only added in 8723B currently */ - if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_PowerOnSetting(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_PowerOnSetting(pBtCoexist); - } -} - -void EXhalbtcoutsrc_PreLoadFirmware(PBTC_COEXIST pBtCoexist) -{ - if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntPreLoadFirmware++; - - if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if(pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_PreLoadFirmware(pBtCoexist); - else if(pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_PreLoadFirmware(pBtCoexist); - } -} - -void EXhalbtcoutsrc_InitHwConfig(PBTC_COEXIST pBtCoexist, u8 bWifiOnly) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntInitHwConfig++; - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_InitHwConfig(pBtCoexist, bWifiOnly); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_InitHwConfig(pBtCoexist, bWifiOnly); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_InitHwConfig(pBtCoexist, bWifiOnly); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_InitHwConfig(pBtCoexist, bWifiOnly); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_InitHwConfig(pBtCoexist, bWifiOnly); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_InitHwConfig(pBtCoexist, bWifiOnly); - } -} - -void EXhalbtcoutsrc_InitCoexDm(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntInitCoexDm++; - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_InitCoexDm(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_InitCoexDm(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_InitCoexDm(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_InitCoexDm(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_InitCoexDm(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_InitCoexDm(pBtCoexist); - } - - pBtCoexist->bInitilized = _TRUE; -} - -void EXhalbtcoutsrc_IpsNotify(PBTC_COEXIST pBtCoexist, u8 type) -{ - u8 ipsType; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntIpsNotify++; - if (pBtCoexist->bManualControl) - return; - - if (IPS_NONE == type) - { - ipsType = BTC_IPS_LEAVE; - GLBtcWiFiInIPS = _FALSE; - } - else - { - ipsType = BTC_IPS_ENTER; - GLBtcWiFiInIPS = _TRUE; - } - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_IpsNotify(pBtCoexist, ipsType); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_IpsNotify(pBtCoexist, ipsType); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_IpsNotify(pBtCoexist, ipsType); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_IpsNotify(pBtCoexist, ipsType); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_IpsNotify(pBtCoexist, ipsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_IpsNotify(pBtCoexist, ipsType); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_LpsNotify(PBTC_COEXIST pBtCoexist, u8 type) -{ - u8 lpsType; - - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntLpsNotify++; - if (pBtCoexist->bManualControl) - return; - - if (PS_MODE_ACTIVE == type) - { - lpsType = BTC_LPS_DISABLE; - GLBtcWiFiInLPS = _FALSE; - } - else - { - lpsType = BTC_LPS_ENABLE; - GLBtcWiFiInLPS = _TRUE; - } - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_LpsNotify(pBtCoexist, lpsType); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_LpsNotify(pBtCoexist, lpsType); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_LpsNotify(pBtCoexist, lpsType); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_LpsNotify(pBtCoexist, lpsType); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_LpsNotify(pBtCoexist, lpsType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_LpsNotify(pBtCoexist, lpsType); - } -} - -void EXhalbtcoutsrc_ScanNotify(PBTC_COEXIST pBtCoexist, u8 type) -{ - u8 scanType; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntScanNotify++; - if (pBtCoexist->bManualControl) - return; - - if (type) - { - scanType = BTC_SCAN_START; - GLBtcWiFiInScanState = _TRUE; - } - else - { - scanType = BTC_SCAN_FINISH; - GLBtcWiFiInScanState = _FALSE; - } - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_ScanNotify(pBtCoexist, scanType); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_ScanNotify(pBtCoexist, scanType); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_ScanNotify(pBtCoexist, scanType); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_ScanNotify(pBtCoexist, scanType); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_ScanNotify(pBtCoexist, scanType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_ScanNotify(pBtCoexist, scanType); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_ConnectNotify(PBTC_COEXIST pBtCoexist, u8 action) -{ - u8 assoType; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntConnectNotify++; - if (pBtCoexist->bManualControl) - return; - - if (action) - assoType = BTC_ASSOCIATE_START; - else - assoType = BTC_ASSOCIATE_FINISH; - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_ConnectNotify(pBtCoexist, assoType); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_ConnectNotify(pBtCoexist, assoType); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_ConnectNotify(pBtCoexist, assoType); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_ConnectNotify(pBtCoexist, assoType); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_ConnectNotify(pBtCoexist, assoType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_ConnectNotify(pBtCoexist, assoType); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_MediaStatusNotify(PBTC_COEXIST pBtCoexist, RT_MEDIA_STATUS mediaStatus) -{ - u8 mStatus; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntMediaStatusNotify++; - if (pBtCoexist->bManualControl) - return; - - if (RT_MEDIA_CONNECT == mediaStatus) - mStatus = BTC_MEDIA_CONNECT; - else - mStatus = BTC_MEDIA_DISCONNECT; - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_MediaStatusNotify(pBtCoexist, mStatus); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_MediaStatusNotify(pBtCoexist, mStatus); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_MediaStatusNotify(pBtCoexist, mStatus); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_MediaStatusNotify(pBtCoexist, mStatus); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_MediaStatusNotify(pBtCoexist, mStatus); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_MediaStatusNotify(pBtCoexist, mStatus); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_SpecialPacketNotify(PBTC_COEXIST pBtCoexist, u8 pktType) -{ - u8 packetType; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntSpecialPacketNotify++; - if (pBtCoexist->bManualControl) - return; - - if (PACKET_DHCP == pktType) - packetType = BTC_PACKET_DHCP; - else if (PACKET_EAPOL == pktType) - packetType = BTC_PACKET_EAPOL; - else if (PACKET_ARP == pktType) - packetType = BTC_PACKET_ARP; - else - { - packetType = BTC_PACKET_UNKNOWN; - return; - } - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_SpecialPacketNotify(pBtCoexist, packetType); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_SpecialPacketNotify(pBtCoexist, packetType); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_SpecialPacketNotify(pBtCoexist, packetType); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_SpecialPacketNotify(pBtCoexist, packetType); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_SpecialPacketNotify(pBtCoexist, packetType); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_SpecialPacketNotify(pBtCoexist, packetType); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_BtInfoNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntBtInfoNotify++; - - // All notify is called in cmd thread, don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_BtInfoNotify(pBtCoexist, tmpBuf, length); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -VOID -EXhalbtcoutsrc_RfStatusNotify( - IN PBTC_COEXIST pBtCoexist, - IN u1Byte type - ) -{ - if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntRfStatusNotify++; - - if(IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - } - else if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if(pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_RfStatusNotify(pBtCoexist, type); - } - else if(IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if(pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_RfStatusNotify(pBtCoexist, type); - } - else if(IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - } - else if(IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - } -} - -void EXhalbtcoutsrc_StackOperationNotify(PBTC_COEXIST pBtCoexist, u8 type) -{ -#if 0 - u8 stackOpType; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntStackOperationNotify++; - if (pBtCoexist->bManualControl) - return; - - if ((HCI_BT_OP_INQUIRY_START == type) || - (HCI_BT_OP_PAGING_START == type) || - (HCI_BT_OP_PAIRING_START == type)) - { - stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_START; - } - else if ((HCI_BT_OP_INQUIRY_FINISH == type) || - (HCI_BT_OP_PAGING_SUCCESS == type) || - (HCI_BT_OP_PAGING_UNSUCCESS == type) || - (HCI_BT_OP_PAIRING_FINISH == type) ) - { - stackOpType = BTC_STACK_OP_INQ_PAGE_PAIR_FINISH; - } - else - { - stackOpType = BTC_STACK_OP_NONE; - } - -#endif -} - -void EXhalbtcoutsrc_HaltNotify(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_HaltNotify(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_HaltNotify(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_HaltNotify(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_HaltNotify(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_HaltNotify(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_HaltNotify(pBtCoexist); - } - - pBtCoexist->bBinded = FALSE; -} - -void EXhalbtcoutsrc_SwitchBtTRxMask(PBTC_COEXIST pBtCoexist) -{ - if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - { - halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x01); //BT goto standby while GNT_BT 1-->0 - } - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - { - halbtcoutsrc_SetBtReg(pBtCoexist, 0, 0x3c, 0x15); //BT goto standby while GNT_BT 1-->0 - } - } -} - -void EXhalbtcoutsrc_PnpNotify(PBTC_COEXIST pBtCoexist, u8 pnpState) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - // - // currently only 1ant we have to do the notification, - // once pnp is notified to sleep state, we have to leave LPS that we can sleep normally. - // - - if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_PnpNotify(pBtCoexist,pnpState); - else if(pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_PnpNotify(pBtCoexist,pnpState); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_PnpNotify(pBtCoexist,pnpState); - else if(pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_PnpNotify(pBtCoexist,pnpState); - } - else if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_PnpNotify(pBtCoexist, pnpState); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_PnpNotify(pBtCoexist,pnpState); - else if(pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_PnpNotify(pBtCoexist,pnpState); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_PnpNotify(pBtCoexist, pnpState); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_PnpNotify(pBtCoexist, pnpState); - } -} - -void EXhalbtcoutsrc_ScoreBoardStatusNotify(PBTC_COEXIST pBtCoexist, u8 *tmpBuf, u8 length) -{ - if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_ScoreBoardStatusNotify(pBtCoexist, tmpBuf, length); - } -} - -void EXhalbtcoutsrc_CoexDmSwitch(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntCoexDmSwitch++; - - halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - { - pBtCoexist->bStopCoexDm = TRUE; - EXhalbtc8723b1ant_CoexDmReset(pBtCoexist); - EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_DETECTED, 2); - EXhalbtc8723b2ant_InitHwConfig(pBtCoexist, FALSE); - EXhalbtc8723b2ant_InitCoexDm(pBtCoexist); - pBtCoexist->bStopCoexDm = FALSE; - } - } - - halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_Periodical(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - pBtCoexist->statistics.cntPeriodical++; - - // Periodical should be called in cmd thread, - // don't need to leave low power again -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - { - if (!halbtcoutsrc_UnderIps(pBtCoexist)) - { - EXhalbtc8821a1ant_Periodical(pBtCoexist); - } - } - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_Periodical(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_Periodical(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_Periodical(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_Periodical(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_Periodical(pBtCoexist); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_DbgControl(PBTC_COEXIST pBtCoexist, u8 opCode, u8 opLen, u8 *pData) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->statistics.cntDbgCtrl++; - - // This function doesn't be called yet, - // default no need to leave low power to avoid deadlock -// halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_DbgControl(pBtCoexist, opCode, opLen, pData); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_DbgControl(pBtCoexist, opCode, opLen, pData); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_DbgControl(pBtCoexist, opCode, opLen, pData); - } - -// halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -#if 0 -VOID -EXhalbtcoutsrc_AntennaDetection( - IN PBTC_COEXIST pBtCoexist, - IN u4Byte centFreq, - IN u4Byte offset, - IN u4Byte span, - IN u4Byte seconds - ) -{ - if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - /* Need to refine the following power save operations to enable this function in the future */ -#if 0 - IPSDisable(pBtCoexist->Adapter, FALSE, 0); - LeisurePSLeave(pBtCoexist->Adapter, LPS_DISABLE_BT_COEX); -#endif - - if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if(pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_AntennaDetection(pBtCoexist, centFreq, offset, span, seconds); - } - - //IPSReturn(pBtCoexist->Adapter, 0xff); -} -#endif - -void EXhalbtcoutsrc_StackUpdateProfileInfo(void) -{ -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - PADAPTER padapter = (PADAPTER)GLBtCoexist.Adapter; - PBT_MGNT pBtMgnt = &padapter->coex_info.BtMgnt; - u8 i; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->stackInfo.bProfileNotified = _TRUE; - - pBtCoexist->stackInfo.numOfLink = - pBtMgnt->ExtConfig.NumberOfACL+pBtMgnt->ExtConfig.NumberOfSCO; - - // reset first - pBtCoexist->stackInfo.bBtLinkExist = _FALSE; - pBtCoexist->stackInfo.bScoExist = _FALSE; - pBtCoexist->stackInfo.bAclExist = _FALSE; - pBtCoexist->stackInfo.bA2dpExist = _FALSE; - pBtCoexist->stackInfo.bHidExist = _FALSE; - pBtCoexist->stackInfo.numOfHid = 0; - pBtCoexist->stackInfo.bPanExist = _FALSE; - - if (!pBtMgnt->ExtConfig.NumberOfACL) - pBtCoexist->stackInfo.minBtRssi = 0; - - if (pBtCoexist->stackInfo.numOfLink) - { - pBtCoexist->stackInfo.bBtLinkExist = _TRUE; - if (pBtMgnt->ExtConfig.NumberOfSCO) - pBtCoexist->stackInfo.bScoExist = _TRUE; - if (pBtMgnt->ExtConfig.NumberOfACL) - pBtCoexist->stackInfo.bAclExist = _TRUE; - } - - for (i=0; iExtConfig.NumberOfACL; i++) - { - if (BT_PROFILE_A2DP == pBtMgnt->ExtConfig.aclLink[i].BTProfile) - { - pBtCoexist->stackInfo.bA2dpExist = _TRUE; - } - else if (BT_PROFILE_PAN == pBtMgnt->ExtConfig.aclLink[i].BTProfile) - { - pBtCoexist->stackInfo.bPanExist = _TRUE; - } - else if (BT_PROFILE_HID == pBtMgnt->ExtConfig.aclLink[i].BTProfile) - { - pBtCoexist->stackInfo.bHidExist = _TRUE; - pBtCoexist->stackInfo.numOfHid++; - } - else - { - pBtCoexist->stackInfo.bUnknownAclExist = _TRUE; - } - } -#endif //CONFIG_BT_COEXIST_SOCKET_TRX -} - -void EXhalbtcoutsrc_UpdateMinBtRssi(s8 btRssi) -{ - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->stackInfo.minBtRssi = btRssi; -} - -void EXhalbtcoutsrc_SetHciVersion(u16 hciVersion) -{ - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->stackInfo.hciVersion = hciVersion; -} - -void EXhalbtcoutsrc_SetBtPatchVersion(u16 btHciVersion, u16 btPatchVersion) -{ - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - pBtCoexist->btInfo.btRealFwVer = btPatchVersion; - pBtCoexist->btInfo.btHciVer = btHciVersion; -} - -#if 0 -void EXhalbtcoutsrc_SetBtExist(u8 bBtExist) -{ - GLBtCoexist.boardInfo.bBtExist = bBtExist; -} -#endif -void EXhalbtcoutsrc_SetChipType(u8 chipType) -{ - switch(chipType) - { - default: - case BT_2WIRE: - case BT_ISSC_3WIRE: - case BT_ACCEL: - case BT_RTL8756: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_UNDEF; - break; - case BT_CSR_BC4: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_CSR_BC4; - break; - case BT_CSR_BC8: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_CSR_BC8; - break; - case BT_RTL8723A: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723A; - break; - case BT_RTL8821: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8821; - break; - case BT_RTL8723B: - GLBtCoexist.boardInfo.btChipType = BTC_CHIP_RTL8723B; - break; - } -} - -void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum) -{ - if (BT_COEX_ANT_TYPE_PG == type) - { - GLBtCoexist.boardInfo.pgAntNum = antNum; - GLBtCoexist.boardInfo.btdmAntNum = antNum; -#if 0 - //The antenna position: Main (default) or Aux for pgAntNum=2 && btdmAntNum =1 - //The antenna position should be determined by auto-detect mechanism - // The following is assumed to main, and those must be modified if y auto-detect mechanism is ready - if ((GLBtCoexist.boardInfo.pgAntNum == 2) && (GLBtCoexist.boardInfo.btdmAntNum == 1) ) - GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - else - GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; -#endif - } - else if (BT_COEX_ANT_TYPE_ANTDIV == type) - { - GLBtCoexist.boardInfo.btdmAntNum = antNum; - //GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } - else if (BT_COEX_ANT_TYPE_DETECTED == type) - { - GLBtCoexist.boardInfo.btdmAntNum = antNum; - //GLBtCoexist.boardInfo.btdmAntPos = BTC_ANTENNA_AT_MAIN_PORT; - } -} - -// -// Currently used by 8723b only, S0 or S1 -// -void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath) -{ - GLBtCoexist.boardInfo.singleAntPath = singleAntPath; -} - -void EXhalbtcoutsrc_DisplayBtCoexInfo(PBTC_COEXIST pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (IS_HARDWARE_TYPE_8821(pBtCoexist->Adapter)) - { - if (halbtcoutsrc_IsCsrBtCoex(pBtCoexist) == _TRUE) - EXhalbtc8821aCsr2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8821a2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8821a1ant_DisplayCoexInfo(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_DisplayCoexInfo(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8703B(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8703b2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8703b1ant_DisplayCoexInfo(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8192E(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8192e2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8192e1ant_DisplayCoexInfo(pBtCoexist); - } - else if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) - { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8812a1ant_DisplayCoexInfo(pBtCoexist); - } - - halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_DisplayAntDetection(PBTC_COEXIST pBtCoexist) -{ - if(!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if(IS_HARDWARE_TYPE_8723B(pBtCoexist->Adapter)) - { - if(pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_DisplayAntDetection(pBtCoexist); - } - - halbtcoutsrc_NormalLowPower(pBtCoexist); -} - -void EXhalbtcoutsrc_BTOffOnNotify(PBTC_COEXIST pBtCoexist, u8 bBTON) -{ - - if (IS_HARDWARE_TYPE_8812(pBtCoexist->Adapter)) { - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8812a2ant_BTOffOnNotify(pBtCoexist, (bBTON == _TRUE)?BTC_BT_ON:BTC_BT_OFF); - } - -} - -static void halbt_InitHwConfig92C(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - u8 u1Tmp; - - - pHalData = GET_HAL_DATA(padapter); - if( (pHalData->bt_coexist.btChipType == BT_CSR_BC4) || - (pHalData->bt_coexist.btChipType == BT_CSR_BC8)) - { - if (pHalData->rf_type == RF_1T1R) - { - // Config to 1T1R - u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable); - u1Tmp &= ~BIT(1); - rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp); - RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp)); - - u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable); - u1Tmp &= ~BIT(1); - rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp); - RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp)); - } - } -} - -static void halbt_InitHwConfig92D(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - u8 u1Tmp; - - pHalData = GET_HAL_DATA(padapter); - if ((pHalData->bt_coexist.btChipType == BT_CSR_BC4) || - (pHalData->bt_coexist.btChipType == BT_CSR_BC8)) - { - if (pHalData->rf_type == RF_1T1R) - { - // Config to 1T1R - u1Tmp = rtw_read8(padapter, rOFDM0_TRxPathEnable); - u1Tmp &= ~BIT(1); - rtw_write8(padapter, rOFDM0_TRxPathEnable, u1Tmp); - RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xC04 = 0x%x\n", u1Tmp)); - - u1Tmp = rtw_read8(padapter, rOFDM1_TRxPathEnable); - u1Tmp &= ~BIT(1); - rtw_write8(padapter, rOFDM1_TRxPathEnable, u1Tmp); - RT_DISP(FBT, BT_TRACE, ("[BTCoex], BT write 0xD04 = 0x%x\n", u1Tmp)); - } - } -} - -/* - * Description: - * Run BT-Coexist mechansim or not - * - */ -void hal_btcoex_SetBTCoexist(PADAPTER padapter, u8 bBtExist) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - pHalData->bt_coexist.bBtExist = bBtExist; - - //EXhalbtcoutsrc_SetBtExist(bBtExist); -} - -/* - * Dewcription: - * Check is co-exist mechanism enabled or not - * - * Return: - * _TRUE Enable BT co-exist mechanism - * _FALSE Disable BT co-exist mechanism - */ -u8 hal_btcoex_IsBtExist(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - return pHalData->bt_coexist.bBtExist; -} - -u8 hal_btcoex_IsBtDisabled(PADAPTER padapter) -{ - if (!hal_btcoex_IsBtExist(padapter)) - return _TRUE; - - if (GLBtCoexist.btInfo.bBtDisabled) - return _TRUE; - else - return _FALSE; -} - -void hal_btcoex_SetChipType(PADAPTER padapter, u8 chipType) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - pHalData->bt_coexist.btChipType = chipType; - - EXhalbtcoutsrc_SetChipType(chipType); -} - -u8 hal_btcoex_GetChipType(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - return pHalData->bt_coexist.btChipType; -} - -void hal_btcoex_SetPgAntNum(PADAPTER padapter, u8 antNum) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - - pHalData->bt_coexist.btTotalAntNum = antNum; - EXhalbtcoutsrc_SetAntNum(BT_COEX_ANT_TYPE_PG, antNum); -} - -u8 hal_btcoex_GetPgAntNum(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - - - pHalData = GET_HAL_DATA(padapter); - - return pHalData->bt_coexist.btTotalAntNum; -} - -void hal_btcoex_SetSingleAntPath(PADAPTER padapter, u8 singleAntPath) -{ - EXhalbtcoutsrc_SetSingleAntPath(singleAntPath); -} - -u8 hal_btcoex_Initialize(PADAPTER padapter) -{ - u8 ret1; - u8 ret2; - - - _rtw_memset(&GLBtCoexist, 0, sizeof(GLBtCoexist)); - ret1 = EXhalbtcoutsrc_InitlizeVariables((void*)padapter); - ret2 = (ret1==_TRUE) ? _TRUE : _FALSE; - - return ret2; -} - -void hal_btcoex_PowerOnSetting(PADAPTER padapter) -{ - EXhalbtcoutsrc_PowerOnSetting(&GLBtCoexist); -} - -void hal_btcoex_PreLoadFirmware(PADAPTER padapter) -{ - EXhalbtcoutsrc_PreLoadFirmware(&GLBtCoexist); -} - -void hal_btcoex_InitHwConfig(PADAPTER padapter, u8 bWifiOnly) -{ - if (!hal_btcoex_IsBtExist(padapter)) - return; - - EXhalbtcoutsrc_InitHwConfig(&GLBtCoexist, bWifiOnly); - EXhalbtcoutsrc_InitCoexDm(&GLBtCoexist); -} - -void hal_btcoex_IpsNotify(PADAPTER padapter, u8 type) -{ - EXhalbtcoutsrc_IpsNotify(&GLBtCoexist, type); -} - -void hal_btcoex_LpsNotify(PADAPTER padapter, u8 type) -{ - EXhalbtcoutsrc_LpsNotify(&GLBtCoexist, type); -} - -void hal_btcoex_ScanNotify(PADAPTER padapter, u8 type) -{ - EXhalbtcoutsrc_ScanNotify(&GLBtCoexist, type); -} - -void hal_btcoex_ConnectNotify(PADAPTER padapter, u8 action) -{ - EXhalbtcoutsrc_ConnectNotify(&GLBtCoexist, action); -} - -void hal_btcoex_MediaStatusNotify(PADAPTER padapter, u8 mediaStatus) -{ - EXhalbtcoutsrc_MediaStatusNotify(&GLBtCoexist, mediaStatus); -} - -void hal_btcoex_SpecialPacketNotify(PADAPTER padapter, u8 pktType) -{ - EXhalbtcoutsrc_SpecialPacketNotify(&GLBtCoexist, pktType); -} - -void hal_btcoex_IQKNotify(PADAPTER padapter, u8 state) -{ - GLBtcWiFiInIQKState = state; -} - -void hal_btcoex_BtInfoNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - if (GLBtcWiFiInIQKState == _TRUE) - return; - - EXhalbtcoutsrc_BtInfoNotify(&GLBtCoexist, tmpBuf, length); -} - -void hal_btcoex_BtMpRptNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - u8 extid, status, len, seq; - - - if (!GLBtcBtMpRptWait) - return; - - if ((length < 3) || (!tmpBuf)) - return; - - extid = tmpBuf[0]; - /* not response from BT FW then exit*/ - switch (extid) { - case C2H_WIFI_FW_ACTIVE_RSP: - GLBtcBtMpRptWiFiOK = 1; - return; - - case C2H_TRIG_BY_BT_FW: - _cancel_timer_ex(&GLBtcBtMpOperTimer); - GLBtcBtMpRptWait = 0; - GLBtcBtMpRptBTOK = 1; - break; - - default: - return; - } - - status = tmpBuf[1] & 0xF; - len = tmpBuf[1] >> 4; - seq = tmpBuf[2] >> 4; - - GLBtcBtMpRptSeq = seq; - GLBtcBtMpRptStatus = status; - _rtw_memcpy(GLBtcBtMpRptRsp, tmpBuf+3, len); - GLBtcBtMpRptRspSize = len; - _rtw_up_sema(&GLBtcBtMpRptSema); -} - -void hal_btcoex_SuspendNotify(PADAPTER padapter, u8 state) -{ - if (state == 1) - state = BTC_WIFI_PNP_SLEEP; - else - state = BTC_WIFI_PNP_WAKE_UP; - - EXhalbtcoutsrc_PnpNotify(&GLBtCoexist, state); -} - -void hal_btcoex_HaltNotify(PADAPTER padapter) -{ - EXhalbtcoutsrc_HaltNotify(&GLBtCoexist); -} - -void hal_btcoex_ScoreBoardStatusNotify(PADAPTER padapter, u8 length, u8 *tmpBuf) -{ - EXhalbtcoutsrc_ScoreBoardStatusNotify(&GLBtCoexist, tmpBuf, length); -} - -void hal_btcoex_SwitchBtTRxMask(PADAPTER padapter) -{ - EXhalbtcoutsrc_SwitchBtTRxMask(&GLBtCoexist); -} - -void hal_btcoex_Hanlder(PADAPTER padapter) -{ - EXhalbtcoutsrc_Periodical(&GLBtCoexist); -} - -s32 hal_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter) -{ - return (s32)GLBtCoexist.btInfo.bRejectAggPkt; -} - -s32 hal_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER padapter) -{ - return (s32)GLBtCoexist.btInfo.bBtCtrlAggBufSize; -} - -u32 hal_btcoex_GetAMPDUSize(PADAPTER padapter) -{ - return (u32)GLBtCoexist.btInfo.aggBufSize; -} - -void hal_btcoex_SetManualControl(PADAPTER padapter, u8 bmanual) -{ - GLBtCoexist.bManualControl = bmanual; -} - -u8 hal_btcoex_1Ant(PADAPTER padapter) -{ - if (hal_btcoex_IsBtExist(padapter) == _FALSE) - return _FALSE; - - if (GLBtCoexist.boardInfo.btdmAntNum == 1) - return _TRUE; - - return _FALSE; -} - -u8 hal_btcoex_IsBtControlLps(PADAPTER padapter) -{ - if (hal_btcoex_IsBtExist(padapter) == _FALSE) - return _FALSE; - - if (GLBtCoexist.btInfo.bBtDisabled) - return _FALSE; - - if (GLBtCoexist.btInfo.bBtCtrlLps) - return _TRUE; - - return _FALSE; -} - -u8 hal_btcoex_IsLpsOn(PADAPTER padapter) -{ - if (hal_btcoex_IsBtExist(padapter) == _FALSE) - return _FALSE; - - if (GLBtCoexist.btInfo.bBtDisabled) - return _FALSE; - - if (GLBtCoexist.btInfo.bBtLpsOn) - return _TRUE; - - return _FALSE; -} - -u8 hal_btcoex_RpwmVal(PADAPTER padapter) -{ - return GLBtCoexist.btInfo.rpwmVal; -} - -u8 hal_btcoex_LpsVal(PADAPTER padapter) -{ - return GLBtCoexist.btInfo.lpsVal; -} - -u32 hal_btcoex_GetRaMask(PADAPTER padapter) -{ - if (!hal_btcoex_IsBtExist(padapter)) - return 0; - - if (GLBtCoexist.btInfo.bBtDisabled) - return 0; - - /* Modify by YiWei , suggest by Cosa and Jenyu - * Remove the limit antenna number , because 2 antenna case (ex: 8192eu)also want to get BT coex report rate mask. - */ - /*if (GLBtCoexist.boardInfo.btdmAntNum != 1) - return 0;*/ - - return GLBtCoexist.btInfo.raMask; -} - -void hal_btcoex_RecordPwrMode(PADAPTER padapter, u8 *pCmdBuf, u8 cmdLen) -{ - RT_TRACE(COMP_COEX, DBG_LOUD, ("[BTCoex], FW write pwrModeCmd=0x%04x%08x\n", - pCmdBuf[0]<<8|pCmdBuf[1], - pCmdBuf[2]<<24|pCmdBuf[3]<<16|pCmdBuf[4]<<8|pCmdBuf[5])); - - _rtw_memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen); -} - -void hal_btcoex_DisplayBtCoexInfo(PADAPTER padapter, u8 *pbuf, u32 bufsize) -{ - PBTCDBGINFO pinfo; - - - pinfo = &GLBtcDbgInfo; - DBG_BT_INFO_INIT(pinfo, pbuf, bufsize); - EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist); - DBG_BT_INFO_INIT(pinfo, NULL, 0); -} - -void hal_btcoex_SetDBG(PADAPTER padapter, u32 *pDbgModule) -{ - u32 i; - - - if (NULL == pDbgModule) - return; - - for (i = 0; i < COMP_MAX; i++) - GLBtcDbgType[i] = pDbgModule[i]; -} - -u32 hal_btcoex_GetDBG(PADAPTER padapter, u8 *pStrBuf, u32 bufSize) -{ - s32 count; - u8 *pstr; - u32 leftSize; - - - if ((NULL == pStrBuf) || (0 == bufSize)) - return 0; - - count = 0; - pstr = pStrBuf; - leftSize = bufSize; -// DBG_871X(FUNC_ADPT_FMT ": bufsize=%d\n", FUNC_ADPT_ARG(padapter), bufSize); - - count = rtw_sprintf(pstr, leftSize, "#define DBG\t%d\n", DBG); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - - count = rtw_sprintf(pstr, leftSize, "BTCOEX Debug Setting:\n"); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - - count = rtw_sprintf(pstr, leftSize, - "COMP_COEX: 0x%08X\n\n", - GLBtcDbgType[COMP_COEX]); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - -#if 0 - count = rtw_sprintf(pstr, leftSize, "INTERFACE Debug Setting Definition:\n"); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for INTF_INIT\n", - GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_INIT?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for INTF_NOTIFY\n\n", - GLBtcDbgType[BTC_MSG_INTERFACE]&INTF_NOTIFY?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - - count = rtw_sprintf(pstr, leftSize, "ALGORITHM Debug Setting Definition:\n"); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[0]=%d for BT_RSSI_STATE\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_RSSI_STATE?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[1]=%d for WIFI_RSSI_STATE\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_WIFI_RSSI_STATE?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[2]=%d for BT_MONITOR\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_BT_MONITOR?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[3]=%d for TRACE\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[4]=%d for TRACE_FW\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[5]=%d for TRACE_FW_DETAIL\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_DETAIL?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[6]=%d for TRACE_FW_EXEC\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_FW_EXEC?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[7]=%d for TRACE_SW\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[8]=%d for TRACE_SW_DETAIL\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_DETAIL?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; - count = rtw_sprintf(pstr, leftSize, "\tbit[9]=%d for TRACE_SW_EXEC\n", - GLBtcDbgType[BTC_MSG_ALGORITHM]&ALGO_TRACE_SW_EXEC?1:0); - if ((count < 0) || (count >= leftSize)) - goto exit; - pstr += count; - leftSize -= count; -#endif - -exit: - count = pstr - pStrBuf; -// DBG_871X(FUNC_ADPT_FMT ": usedsize=%d\n", FUNC_ADPT_ARG(padapter), count); - - return count; -} - -u8 hal_btcoex_IncreaseScanDeviceNum(PADAPTER padapter) -{ - if (!hal_btcoex_IsBtExist(padapter)) - return _FALSE; - - if (GLBtCoexist.btInfo.bIncreaseScanDevNum) - return _TRUE; - - return _FALSE; -} - -u8 hal_btcoex_IsBtLinkExist(PADAPTER padapter) -{ - if (GLBtCoexist.btLinkInfo.bBtLinkExist) - return _TRUE; - - return _FALSE; -} - -void hal_btcoex_SetBtPatchVersion(PADAPTER padapter,u16 btHciVer,u16 btPatchVer) -{ - EXhalbtcoutsrc_SetBtPatchVersion(btHciVer,btPatchVer); -} - -void hal_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion) -{ - EXhalbtcoutsrc_SetHciVersion(hciVersion); -} - -void hal_btcoex_StackUpdateProfileInfo(void) -{ - EXhalbtcoutsrc_StackUpdateProfileInfo(); -} - -void hal_btcoex_BTOffOnNotify(PADAPTER padapter, u8 bBTON) -{ - EXhalbtcoutsrc_BTOffOnNotify(&GLBtCoexist, bBTON); -} - -/* - * Description: - * Setting BT coex antenna isolation type . - * coex mechanisn/ spital stream/ best throughput - * anttype = 0 , PSTDMA / 2SS / 0.5T , bad isolation , WiFi/BT ANT Distance<15cm , (<20dB) for 2,3 antenna - * anttype = 1 , PSTDMA / 1SS / 0.5T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 2 antenna - * anttype = 2 , TDMA / 2SS / T , normal isolaiton , 50cm>WiFi/BT ANT Distance>15cm , (>20dB) for 3 antenna - * anttype = 3 , no TDMA / 1SS / 0.5T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 2 antenna - * anttype = 4 , no TDMA / 2SS / T , good isolation , WiFi/BT ANT Distance >50cm , (>40dB) for 3 antenna - * wifi only throughput ~ T - * wifi/BT share one antenna with SPDT - */ -void hal_btcoex_SetAntIsolationType(PADAPTER padapter, u8 anttype) -{ - PHAL_DATA_TYPE pHalData; - PBTC_COEXIST pBtCoexist = &GLBtCoexist; - - /*DBG_871X("####%s , anttype = %d , %d\n" , __func__ , anttype , __LINE__); */ - pHalData = GET_HAL_DATA(padapter); - - - pHalData->bt_coexist.btAntisolation = anttype; - - switch (pHalData->bt_coexist.btAntisolation) { - case 0: - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_0; - break; - case 1: - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_1; - break; - case 2: - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_2; - break; - case 3: - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_3; - break; - case 4: - pBtCoexist->boardInfo.antType = (u1Byte)BTC_ANT_TYPE_4; - break; - } - -} - -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -int -hal_btcoex_ParseAntIsolationConfigFile( - PADAPTER Adapter, - char* buffer -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - u32 i = 0 , j = 0; - char *szLine , *ptmp; - int rtStatus = _SUCCESS; - char param_value_string[10]; - u8 param_value; - u8 anttype = 4; - - u8 ant_num = 3 , ant_distance = 50 , rfe_type = 1; - - typedef struct ant_isolation { - char *param_name; /* antenna isolation config parameter name */ - u8 *value; /* antenna isolation config parameter value */ - } ANT_ISOLATION; - - ANT_ISOLATION ant_isolation_param[] = { - {"ANT_NUMBER" , &ant_num}, - {"ANT_DISTANCE" , &ant_distance}, - {"RFE_TYPE" , &rfe_type}, - {NULL , 0} - }; - - - - /* DBG_871X("===>Hal_ParseAntIsolationConfigFile()\n" ); */ - - ptmp = buffer; - for (szLine = GetLineFromBuffer(ptmp) ; szLine != NULL; szLine = GetLineFromBuffer(ptmp)) { - /* skip comment */ - if (IsCommentString(szLine)) - continue; - - /* DBG_871X("%s : szLine = %s , strlen(szLine) = %d\n" , __func__ , szLine , strlen(szLine));*/ - for (j = 0 ; ant_isolation_param[j].param_name != NULL ; j++) { - if (strstr(szLine , ant_isolation_param[j].param_name) != NULL) { - i = 0; - while (i < strlen(szLine)) { - if (szLine[i] != '"') - ++i; - else { - /* skip only has one " */ - if (strpbrk(szLine , "\"") == strrchr(szLine , '"')) { - DBG_871X("Fail to parse parameters , format error!\n"); - break; - } - _rtw_memset((PVOID)param_value_string , 0 , 10); - if (!ParseQualifiedString(szLine , &i , param_value_string , '"' , '"')) { - DBG_871X("Fail to parse parameters\n"); - return _FAIL; - } else if (!GetU1ByteIntegerFromStringInDecimal(param_value_string , ant_isolation_param[j].value)) - DBG_871X("Fail to GetU1ByteIntegerFromStringInDecimal\n"); - - break; - } - } - } - } - } - - /* YiWei 20140716 , for BT coex antenna isolation control */ - /* rfe_type = 0 was SPDT , rfe_type = 1 was coupler */ - if (ant_num == 3 && ant_distance >= 50) - anttype = 3; - else if (ant_num == 2 && ant_distance >= 50 && rfe_type == 1) - anttype = 2; - else if (ant_num == 3 && ant_distance >= 15 && ant_distance < 50) - anttype = 2; - else if (ant_num == 2 && ant_distance >= 15 && ant_distance < 50 && rfe_type == 1) - anttype = 2; - else if ((ant_num == 2 && ant_distance < 15 && rfe_type == 1) || (ant_num == 3 && ant_distance < 15)) - anttype = 1; - else if (ant_num == 2 && rfe_type == 0) - anttype = 0; - else - anttype = 0; - - hal_btcoex_SetAntIsolationType(Adapter, anttype); - - DBG_871X("%s : ant_num = %d\n" , __func__ , ant_num); - DBG_871X("%s : ant_distance = %d\n" , __func__ , ant_distance); - DBG_871X("%s : rfe_type = %d\n" , __func__ , rfe_type); - /* DBG_871X("<===Hal_ParseAntIsolationConfigFile()\n"); */ - return rtStatus; -} - - -int -hal_btcoex_AntIsolationConfig_ParaFile( - IN PADAPTER Adapter, - IN char* pFileName -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0 , rtStatus = _FAIL; - - _rtw_memset(pHalData->para_file_buf , 0 , MAX_PARA_FILE_BUF_LEN); - - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - } - } - - - if (rtStatus == _SUCCESS) { - /*DBG_871X("%s(): read %s ok\n", __func__ , pFileName);*/ - rtStatus = hal_btcoex_ParseAntIsolationConfigFile(Adapter , pHalData->para_file_buf); - } else { - DBG_871X("%s(): No File %s, Load from *** Array!\n" , __func__ , pFileName); - } - - return rtStatus; -} -#endif // CONFIG_LOAD_PHY_PARA_FROM_FILE - -u16 hal_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data) -{ - u16 ret = 0; - - halbtcoutsrc_LeaveLowPower(&GLBtCoexist); - - ret = halbtcoutsrc_GetBtReg(&GLBtCoexist, type, addr, data); - - halbtcoutsrc_NormalLowPower(&GLBtCoexist); - - return ret; -} - -u16 hal_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val) -{ - u16 ret = 0; - - halbtcoutsrc_LeaveLowPower(&GLBtCoexist); - - ret = halbtcoutsrc_SetBtReg(&GLBtCoexist, type, addr, val); - - halbtcoutsrc_NormalLowPower(&GLBtCoexist); - - return ret; -} -#endif // CONFIG_BT_COEXIST - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com.c index ea4d095c0..176112b29 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com.c @@ -26,10 +26,6 @@ //#define CONFIG_GTK_OL_DBG -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -char rtw_phy_para_file_path[PATH_LENGTH_MAX]; -#endif - void dump_chip_info(HAL_VERSION ChipVersion) { int cnt = 0; @@ -966,8 +962,7 @@ int hal_read_mac_hidden_rpt(_adapter *adapter) #if defined(CONFIG_USB_HCI) || defined(CONFIG_PCI_HCI) u8 hci_type = rtw_get_intf_type(adapter); - if ((hci_type == RTW_USB || hci_type == RTW_PCIE) - && !rtw_is_hw_init_completed(adapter)) + if (!rtw_is_hw_init_completed(adapter)) rtw_hal_power_on(adapter); #endif @@ -1008,8 +1003,7 @@ mac_hidden_rpt_hdl: exit: #if defined(CONFIG_USB_HCI) || defined(CONFIG_PCI_HCI) - if ((hci_type == RTW_USB || hci_type == RTW_PCIE) - && !rtw_is_hw_init_completed(adapter)) + if (!rtw_is_hw_init_completed(adapter)) rtw_hal_power_off(adapter); #endif @@ -1668,14 +1662,6 @@ void hw_var_port_switch(_adapter *adapter) rtw_write8(adapter, REG_BSSID1+i, bssid[i]); /* write bcn ctl */ -#ifdef CONFIG_BT_COEXIST -#if defined(CONFIG_RTL8723B) || defined(CONFIG_RTL8703B) - // always enable port0 beacon function for PSTDMA - bcn_ctrl_1 |= EN_BCN_FUNCTION; - // always disable port1 beacon function for PSTDMA - bcn_ctrl &= ~EN_BCN_FUNCTION; -#endif -#endif rtw_write8(adapter, REG_BCN_CTRL, bcn_ctrl_1); rtw_write8(adapter, REG_BCN_CTRL_1, bcn_ctrl); @@ -2327,26 +2313,6 @@ void rtw_hal_set_fw_rsvd_page(_adapter* adapter, bool finished) BufIndex += (CurtPktPageNum*PageSize); -#ifdef CONFIG_BT_COEXIST - /* BT Qos null data * 1 page */ - RsvdPageLoc.LocBTQosNull = TotalPageNum; - DBG_871X("LocBTQosNull: %d\n", RsvdPageLoc.LocBTQosNull); - rtw_hal_construct_NullFunctionData( - adapter, - &ReservedPagePacket[BufIndex], - &BTQosNullLength, - get_my_bssid(&pmlmeinfo->network), - _TRUE, 0, 0, _FALSE); - rtw_hal_fill_fake_txdesc(adapter, - &ReservedPagePacket[BufIndex-TxDescLen], - BTQosNullLength, _FALSE, _TRUE, _FALSE); - - CurtPktPageNum = (u8)PageNum(TxDescLen + BTQosNullLength, PageSize); - - TotalPageNum += CurtPktPageNum; - - BufIndex += (CurtPktPageNum*PageSize); -#endif /* CONFIG_BT_COEXIT */ /* null data * 1 page */ RsvdPageLoc.LocNullData = TotalPageNum; @@ -3445,8 +3411,6 @@ int hal_efuse_macaddr_offset(_adapter *adapter) case RTL8188F: if (interface_type == RTW_USB) addr_offset = EEPROM_MAC_ADDR_8188FU; - else if (interface_type == RTW_SDIO) - addr_offset = EEPROM_MAC_ADDR_8188FS; break; #endif #ifdef CONFIG_RTL8812A diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com_phycfg.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com_phycfg.c index 9bb536806..72f03cdc5 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com_phycfg.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_com_phycfg.c @@ -2362,15 +2362,6 @@ int phy_load_tx_power_by_rate(_adapter *adapter, u8 chk_file) /* tx power limit is based on tx power by rate */ hal_data->txpwr_limit_loaded = 0; -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (chk_file - && phy_ConfigBBWithPgParaFile(adapter, PHY_FILE_PHY_REG_PG) == _SUCCESS - ) { - hal_data->txpwr_by_rate_from_file = 1; - goto post_hdl; - } -#endif - #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_SUCCESS == ODM_ConfigBBWithHeaderFile(&hal_data->odmpriv, CONFIG_BB_PHY_REG_PG)) { DBG_871X("default power by rate loaded\n"); @@ -2411,15 +2402,6 @@ int phy_load_tx_power_limit(_adapter *adapter, u8 chk_file) goto exit; } -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (chk_file - && PHY_ConfigRFWithPowerLimitTableParaFile(adapter, PHY_FILE_TXPWR_LMT) == _SUCCESS - ) { - hal_data->txpwr_limit_from_file = 1; - goto post_hdl; - } -#endif - #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_SUCCESS == ODM_ConfigRFWithHeaderFile(&hal_data->odmpriv, CONFIG_RF_TXPWR_LMT, (ODM_RF_RADIO_PATH_E)0)) { DBG_871X("default power limit loaded\n"); @@ -2773,1531 +2755,3 @@ void dump_tx_power_limit(void *sel, _adapter *adapter) } } } - -/* - * phy file path is stored in global char array rtw_phy_para_file_path - * need to care about racing - */ -int rtw_get_phy_file_path(_adapter *adapter, const char *file_name) -{ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - struct hal_spec_t *hal_spec = GET_HAL_SPEC(adapter); - int len = 0; - - if (file_name) { - len += snprintf(rtw_phy_para_file_path, PATH_LENGTH_MAX, "%s", rtw_phy_file_path); - #if defined(CONFIG_MULTIDRV) || defined(REALTEK_CONFIG_PATH_WITH_IC_NAME_FOLDER) - len += snprintf(rtw_phy_para_file_path + len, PATH_LENGTH_MAX - len, "%s/", hal_spec->ic_name); - #endif - len += snprintf(rtw_phy_para_file_path + len, PATH_LENGTH_MAX - len, "%s", file_name); - - return _TRUE; - } -#endif - return _FALSE; -} - -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -int -phy_ConfigMACWithParaFile( - IN PADAPTER Adapter, - IN char* pFileName -) -{ - PHAL_DATA_TYPE pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_MAC_PARA_FILE)) - return rtStatus; - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->mac_reg_len == 0) && (pHalData->mac_reg == NULL)) - { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pHalData->mac_reg = rtw_zvmalloc(rlen); - if(pHalData->mac_reg) { - _rtw_memcpy(pHalData->mac_reg, pHalData->para_file_buf, rlen); - pHalData->mac_reg_len = rlen; - } - else { - DBG_871X("%s mac_reg alloc fail !\n",__FUNCTION__); - } - } - } - } - else - { - if ((pHalData->mac_reg_len != 0) && (pHalData->mac_reg != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pHalData->mac_reg, pHalData->mac_reg_len); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if (rtStatus == _SUCCESS) - { - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if(!IsCommentString(szLine)) - { - // Get 1st hex value as register offset - if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - { - if(u4bRegOffset == 0xffff) - { // Ending. - break; - } - - // Get 2nd hex value as register value. - szLine += u4bMove; - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - rtw_write8(Adapter, u4bRegOffset, (u8)u4bRegValue); - } - } - } - } - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -int -phy_ConfigBBWithParaFile( - IN PADAPTER Adapter, - IN char* pFileName, - IN u32 ConfigType -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - char *pBuf = NULL; - u32 *pBufLen = NULL; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_PARA_FILE)) - return rtStatus; - - switch(ConfigType) - { - case CONFIG_BB_PHY_REG: - pBuf = pHalData->bb_phy_reg; - pBufLen = &pHalData->bb_phy_reg_len; - break; - case CONFIG_BB_AGC_TAB: - pBuf = pHalData->bb_agc_tab; - pBufLen = &pHalData->bb_agc_tab_len; - break; - default: - DBG_871X("Unknown ConfigType!! %d\r\n", ConfigType); - break; - } - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) - { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pBuf = rtw_zvmalloc(rlen); - if(pBuf) { - _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen); - *pBufLen = rlen; - - switch(ConfigType) - { - case CONFIG_BB_PHY_REG: - pHalData->bb_phy_reg = pBuf; - break; - case CONFIG_BB_AGC_TAB: - pHalData->bb_agc_tab = pBuf; - break; - } - } - else { - DBG_871X("%s(): ConfigType %d alloc fail !\n",__FUNCTION__,ConfigType); - } - } - } - } - else - { - if ((pBufLen != NULL) && (*pBufLen != 0) && (pBuf != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pBuf, *pBufLen); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if (rtStatus == _SUCCESS) - { - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if(!IsCommentString(szLine)) - { - // Get 1st hex value as register offset. - if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - { - if(u4bRegOffset == 0xffff) - { // Ending. - break; - } - else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) - { - #ifdef CONFIG_LONG_DELAY_ISSUE - rtw_msleep_os(50); - #else - rtw_mdelay_os(50); - #endif - } - else if (u4bRegOffset == 0xfd) - { - rtw_mdelay_os(5); - } - else if (u4bRegOffset == 0xfc) - { - rtw_mdelay_os(1); - } - else if (u4bRegOffset == 0xfb) - { - rtw_udelay_os(50); - } - else if (u4bRegOffset == 0xfa) - { - rtw_udelay_os(5); - } - else if (u4bRegOffset == 0xf9) - { - rtw_udelay_os(1); - } - - // Get 2nd hex value as register value. - szLine += u4bMove; - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - //DBG_871X("[BB-ADDR]%03lX=%08lX\n", u4bRegOffset, u4bRegValue); - PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue); - - if (u4bRegOffset == 0xa24) - pHalData->odmpriv.RFCalibrateInfo.RegA24 = u4bRegValue; - - // Add 1us delay between BB/RF register setting. - rtw_udelay_os(1); - } - } - } - } - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -VOID -phy_DecryptBBPgParaFile( - PADAPTER Adapter, - char* buffer - ) -{ - u32 i = 0, j = 0; - u8 map[95] = {0}; - u8 currentChar; - char *BufOfLines, *ptmp; - - //DBG_871X("=====>phy_DecryptBBPgParaFile()\n"); - // 32 the ascii code of the first visable char, 126 the last one - for ( i = 0; i < 95; ++i ) - map[i] = ( u8 ) ( 94 - i ); - - ptmp = buffer; - i = 0; - for (BufOfLines = GetLineFromBuffer(ptmp); BufOfLines != NULL; BufOfLines = GetLineFromBuffer(ptmp)) - { - //DBG_871X("Encrypted Line: %s\n", BufOfLines); - - for ( j = 0; j < strlen(BufOfLines); ++j ) - { - currentChar = BufOfLines[j]; - - if ( currentChar == '\0' ) - break; - - currentChar -= (u8) ( ( ( ( i + j ) * 3 ) % 128 ) ); - - BufOfLines[j] = map[currentChar - 32] + 32; - } - //DBG_871X("Decrypted Line: %s\n", BufOfLines ); - if (strlen(BufOfLines) != 0) - i++; - BufOfLines[strlen(BufOfLines)] = '\n'; - } -} - -int -phy_ParseBBPgParaFile( - PADAPTER Adapter, - char* buffer - ) -{ - int rtStatus = _SUCCESS; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegMask, u4bRegValue; - u32 u4bMove; - BOOLEAN firstLine = _TRUE; - u8 tx_num = 0; - u8 band = 0, rf_path = 0; - - //DBG_871X("=====>phy_ParseBBPgParaFile()\n"); - - if ( Adapter->registrypriv.RegDecryptCustomFile == 1 ) - phy_DecryptBBPgParaFile( Adapter, buffer); - - ptmp = buffer; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if (isAllSpaceOrTab(szLine, sizeof(*szLine))) - continue; - - if(!IsCommentString(szLine)) - { - // Get header info (relative value or exact value) - if ( firstLine ) - { - if ( eqNByte( szLine, (u8 *)("#[v1]"), 5 ) ) - { - - pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; - //DBG_871X("This is a new format PHY_REG_PG.txt \n"); - } - else if ( eqNByte( szLine, (u8 *)("#[v0]"), 5 )) - { - pHalData->odmpriv.PhyRegPgVersion = szLine[3] - '0'; - //DBG_871X("This is a old format PHY_REG_PG.txt ok\n"); - } - else - { - DBG_871X("The format in PHY_REG_PG are invalid %s\n", szLine); - return _FAIL; - } - - if ( eqNByte( szLine + 5, (u8 *)("[Exact]#"), 8 ) ) - { - pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; - //DBG_871X("The values in PHY_REG_PG are exact values ok\n"); - firstLine = _FALSE; - continue; - } - else if ( eqNByte( szLine + 5, (pu1Byte)("[Relative]#"), 11 ) ) - { - pHalData->odmpriv.PhyRegPgValueType = PHY_REG_PG_RELATIVE_VALUE; - //DBG_871X("The values in PHY_REG_PG are relative values ok\n"); - firstLine = _FALSE; - continue; - } - else - { - DBG_871X("The values in PHY_REG_PG are invalid %s\n", szLine); - return _FAIL; - } - } - - if ( pHalData->odmpriv.PhyRegPgVersion == 0 ) - { - // Get 1st hex value as register offset. - if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - { - szLine += u4bMove; - if(u4bRegOffset == 0xffff) - { // Ending. - break; - } - - // Get 2nd hex value as register mask. - if ( GetHexValueFromString(szLine, &u4bRegMask, &u4bMove) ) - szLine += u4bMove; - else - return _FAIL; - - if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE ) - { - // Get 3rd hex value as register value. - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, u4bRegValue); - //DBG_871X("[ADDR] %03X=%08X Mask=%08x\n", u4bRegOffset, u4bRegValue, u4bRegMask); - } - else - { - return _FAIL; - } - } - else if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE ) - { - u32 combineValue = 0; - u8 integer = 0, fraction = 0; - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - PHY_StoreTxPowerByRate(Adapter, 0, 0, 1, u4bRegOffset, u4bRegMask, combineValue); - - //DBG_871X("[ADDR] 0x%3x = 0x%4x\n", u4bRegOffset, combineValue ); - } - } - } - else if ( pHalData->odmpriv.PhyRegPgVersion > 0 ) - { - u32 index = 0, cnt = 0; - - if ( eqNByte( szLine, "0xffff", 6 ) ) - break; - - if( !eqNByte( "#[END]#", szLine, 7 ) ) - { - // load the table label info - if ( szLine[0] == '#' ) - { - index = 0; - if ( eqNByte( szLine, "#[2.4G]" , 7 ) ) - { - band = BAND_ON_2_4G; - index += 8; - } - else if ( eqNByte( szLine, "#[5G]", 5) ) - { - band = BAND_ON_5G; - index += 6; - } - else - { - DBG_871X("Invalid band %s in PHY_REG_PG.txt \n", szLine ); - return _FAIL; - } - - rf_path= szLine[index] - 'A'; - //DBG_871X(" Table label Band %d, RfPath %d\n", band, rf_path ); - } - else // load rows of tables - { - if ( szLine[1] == '1' ) - tx_num = RF_1TX; - else if ( szLine[1] == '2' ) - tx_num = RF_2TX; - else if ( szLine[1] == '3' ) - tx_num = RF_3TX; - else if ( szLine[1] == '4' ) - tx_num = RF_4TX; - else - { - DBG_871X("Invalid row in PHY_REG_PG.txt '%c'(%d)\n", szLine[1], szLine[1]); - return _FAIL; - } - - while ( szLine[index] != ']' ) - ++index; - ++index;// skip ] - - // Get 2nd hex value as register offset. - szLine += index; - if ( GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove) ) - szLine += u4bMove; - else - return _FAIL; - - // Get 2nd hex value as register mask. - if ( GetHexValueFromString(szLine, &u4bRegMask, &u4bMove) ) - szLine += u4bMove; - else - return _FAIL; - - if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_RELATIVE_VALUE ) - { - // Get 3rd hex value as register value. - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, u4bRegValue); - //DBG_871X("[ADDR] %03X (tx_num %d) =%08X Mask=%08x\n", u4bRegOffset, tx_num, u4bRegValue, u4bRegMask); - } - else - { - return _FAIL; - } - } - else if ( pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE ) - { - u32 combineValue = 0; - u8 integer = 0, fraction = 0; - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - - if ( GetFractionValueFromString( szLine, &integer, &fraction, &u4bMove ) ) - szLine += u4bMove; - else - return _FAIL; - - integer *= 2; - if ( fraction == 5 ) integer += 1; - combineValue <<= 8; - combineValue |= ( ( ( integer / 10 ) << 4 ) + ( integer % 10 ) ); - //DBG_871X(" %d", integer ); - PHY_StoreTxPowerByRate(Adapter, band, rf_path, tx_num, u4bRegOffset, u4bRegMask, combineValue); - - //DBG_871X("[ADDR] 0x%3x (tx_num %d) = 0x%4x\n", u4bRegOffset, tx_num, combineValue ); - } - } - } - } - } - } - //DBG_871X("<=====phy_ParseBBPgParaFile()\n"); - return rtStatus; -} - -int -phy_ConfigBBWithPgParaFile( - IN PADAPTER Adapter, - IN const char *pFileName) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_PG_PARA_FILE)) - return rtStatus; - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if (pHalData->bb_phy_reg_pg == NULL) { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pHalData->bb_phy_reg_pg = rtw_zvmalloc(rlen); - if(pHalData->bb_phy_reg_pg) { - _rtw_memcpy(pHalData->bb_phy_reg_pg, pHalData->para_file_buf, rlen); - pHalData->bb_phy_reg_pg_len = rlen; - } - else { - DBG_871X("%s bb_phy_reg_pg alloc fail !\n",__FUNCTION__); - } - } - } - } else { - if ((pHalData->bb_phy_reg_pg_len != 0) && (pHalData->bb_phy_reg_pg != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if(rtStatus == _SUCCESS) - { - //DBG_871X("phy_ConfigBBWithPgParaFile(): read %s ok\n", pFileName); - phy_ParseBBPgParaFile(Adapter, pHalData->para_file_buf); - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -#if (MP_DRIVER == 1 ) - -int -phy_ConfigBBWithMpParaFile( - IN PADAPTER Adapter, - IN char* pFileName -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_BB_MP_PARA_FILE)) - return rtStatus; - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->bb_phy_reg_mp_len == 0) && (pHalData->bb_phy_reg_mp == NULL)) - { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pHalData->bb_phy_reg_mp = rtw_zvmalloc(rlen); - if(pHalData->bb_phy_reg_mp) { - _rtw_memcpy(pHalData->bb_phy_reg_mp, pHalData->para_file_buf, rlen); - pHalData->bb_phy_reg_mp_len = rlen; - } - else { - DBG_871X("%s bb_phy_reg_mp alloc fail !\n",__FUNCTION__); - } - } - } - } - else - { - if ((pHalData->bb_phy_reg_mp_len != 0) && (pHalData->bb_phy_reg_mp != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pHalData->bb_phy_reg_mp, pHalData->bb_phy_reg_mp_len); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if(rtStatus == _SUCCESS) - { - //DBG_871X("phy_ConfigBBWithMpParaFile(): read %s ok\n", pFileName); - - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if(!IsCommentString(szLine)) - { - // Get 1st hex value as register offset. - if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - { - if(u4bRegOffset == 0xffff) - { // Ending. - break; - } - else if (u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) - { - #ifdef CONFIG_LONG_DELAY_ISSUE - rtw_msleep_os(50); - #else - rtw_mdelay_os(50); - #endif - } - else if (u4bRegOffset == 0xfd) - { - rtw_mdelay_os(5); - } - else if (u4bRegOffset == 0xfc) - { - rtw_mdelay_os(1); - } - else if (u4bRegOffset == 0xfb) - { - rtw_udelay_os(50); - } - else if (u4bRegOffset == 0xfa) - { - rtw_udelay_os(5); - } - else if (u4bRegOffset == 0xf9) - { - rtw_udelay_os(1); - } - - // Get 2nd hex value as register value. - szLine += u4bMove; - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - //DBG_871X("[ADDR]%03lX=%08lX\n", u4bRegOffset, u4bRegValue); - PHY_SetBBReg(Adapter, u4bRegOffset, bMaskDWord, u4bRegValue); - - // Add 1us delay between BB/RF register setting. - rtw_udelay_os(1); - } - } - } - } - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -#endif - -int -PHY_ConfigRFWithParaFile( - IN PADAPTER Adapter, - IN char* pFileName, - IN u8 eRFPath -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 u4bRegOffset, u4bRegValue, u4bMove; - u16 i; - char *pBuf = NULL; - u32 *pBufLen = NULL; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_PARA_FILE)) - return rtStatus; - - switch(eRFPath) - { - case ODM_RF_PATH_A: - pBuf = pHalData->rf_radio_a; - pBufLen = &pHalData->rf_radio_a_len; - break; - case ODM_RF_PATH_B: - pBuf = pHalData->rf_radio_b; - pBufLen = &pHalData->rf_radio_b_len; - break; - default: - DBG_871X("Unknown RF path!! %d\r\n", eRFPath); - break; - } - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pBufLen != NULL) && (*pBufLen == 0) && (pBuf == NULL)) - { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pBuf = rtw_zvmalloc(rlen); - if(pBuf) { - _rtw_memcpy(pBuf, pHalData->para_file_buf, rlen); - *pBufLen = rlen; - - switch(eRFPath) - { - case ODM_RF_PATH_A: - pHalData->rf_radio_a = pBuf; - break; - case ODM_RF_PATH_B: - pHalData->rf_radio_b = pBuf; - break; - } - } - else { - DBG_871X("%s(): eRFPath=%d alloc fail !\n",__FUNCTION__,eRFPath); - } - } - } - } - else - { - if ((pBufLen != NULL) && (*pBufLen != 0) && (pBuf != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pBuf, *pBufLen); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if(rtStatus == _SUCCESS) - { - //DBG_871X("%s(): read %s successfully\n", __FUNCTION__, pFileName); - - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if(!IsCommentString(szLine)) - { - // Get 1st hex value as register offset. - if(GetHexValueFromString(szLine, &u4bRegOffset, &u4bMove)) - { - if(u4bRegOffset == 0xfe || u4bRegOffset == 0xffe) - { // Deay specific ms. Only RF configuration require delay. - #ifdef CONFIG_LONG_DELAY_ISSUE - rtw_msleep_os(50); - #else - rtw_mdelay_os(50); - #endif - } - else if (u4bRegOffset == 0xfd) - { - //delay_ms(5); - for(i=0;i<100;i++) - rtw_udelay_os(MAX_STALL_TIME); - } - else if (u4bRegOffset == 0xfc) - { - //delay_ms(1); - for(i=0;i<20;i++) - rtw_udelay_os(MAX_STALL_TIME); - } - else if (u4bRegOffset == 0xfb) - { - rtw_udelay_os(50); - } - else if (u4bRegOffset == 0xfa) - { - rtw_udelay_os(5); - } - else if (u4bRegOffset == 0xf9) - { - rtw_udelay_os(1); - } - else if(u4bRegOffset == 0xffff) - { - break; - } - - // Get 2nd hex value as register value. - szLine += u4bMove; - if(GetHexValueFromString(szLine, &u4bRegValue, &u4bMove)) - { - PHY_SetRFReg(Adapter, eRFPath, u4bRegOffset, bRFRegOffsetMask, u4bRegValue); - - // Temp add, for frequency lock, if no delay, that may cause - // frequency shift, ex: 2412MHz => 2417MHz - // If frequency shift, the following action may works. - // Fractional-N table in radio_a.txt - //0x2a 0x00001 // channel 1 - //0x2b 0x00808 frequency divider. - //0x2b 0x53333 - //0x2c 0x0000c - rtw_udelay_os(1); - } - } - } - } - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -VOID -initDeltaSwingIndexTables( - PADAPTER Adapter, - char* Band, - char* Path, - char* Sign, - char* Channel, - char* Rate, - char* Data -) -{ - #define STR_EQUAL_5G(_band, _path, _sign, _rate, _chnl) \ - ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\ - (strcmp(Rate, _rate) == 0) && (strcmp(Channel, _chnl) == 0)\ - ) - #define STR_EQUAL_2G(_band, _path, _sign, _rate) \ - ((strcmp(Band, _band) == 0) && (strcmp(Path, _path) == 0) && (strcmp(Sign, _sign) == 0) &&\ - (strcmp(Rate, _rate) == 0)\ - ) - - #define STORE_SWING_TABLE(_array, _iteratedIdx) \ - for(token = strsep(&Data, delim); token != NULL; token = strsep(&Data, delim))\ - {\ - sscanf(token, "%d", &idx);\ - _array[_iteratedIdx++] = (u8)idx;\ - }\ - - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - u32 j = 0; - char *token; - char delim[] = ","; - u32 idx = 0; - - //DBG_871X("===>initDeltaSwingIndexTables(): Band: %s;\nPath: %s;\nSign: %s;\nChannel: %s;\nRate: %s;\n, Data: %s;\n", - // Band, Path, Sign, Channel, Rate, Data); - - if ( STR_EQUAL_2G("2G", "A", "+", "CCK") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, j); - } - else if ( STR_EQUAL_2G("2G", "A", "-", "CCK") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, j); - } - else if ( STR_EQUAL_2G("2G", "B", "+", "CCK") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, j); - } - else if ( STR_EQUAL_2G("2G", "B", "-", "CCK") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, j); - } - else if ( STR_EQUAL_2G("2G", "A", "+", "ALL") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, j); - } - else if ( STR_EQUAL_2G("2G", "A", "-", "ALL") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, j); - } - else if ( STR_EQUAL_2G("2G", "B", "+", "ALL") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, j); - } - else if ( STR_EQUAL_2G("2G", "B", "-", "ALL") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, j); - } - else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "0") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[0], j); - } - else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "0") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[0], j); - } - else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "0") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[0], j); - } - else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "0") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[0], j); - } - else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "1") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[1], j); - } - else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "1") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[1], j); - } - else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "1") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[1], j); - } - else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "1") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[1], j); - } - else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "2") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[2], j); - } - else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "2") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[2], j); - } - else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "2") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[2], j); - } - else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "2") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[2], j); - } - else if ( STR_EQUAL_5G("5G", "A", "+", "ALL", "3") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[3], j); - } - else if ( STR_EQUAL_5G("5G", "A", "-", "ALL", "3") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[3], j); - } - else if ( STR_EQUAL_5G("5G", "B", "+", "ALL", "3") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[3], j); - } - else if ( STR_EQUAL_5G("5G", "B", "-", "ALL", "3") ) - { - STORE_SWING_TABLE(pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[3], j); - } - else - { - DBG_871X("===>initDeltaSwingIndexTables(): The input is invalid!!\n"); - } -} - -int -PHY_ConfigRFWithTxPwrTrackParaFile( - IN PADAPTER Adapter, - IN char* pFileName -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - int rlen = 0, rtStatus = _FAIL; - char *szLine, *ptmp; - u32 i = 0, j = 0; - char c = 0; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_TRACK_PARA_FILE)) - return rtStatus; - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if ((pHalData->rf_tx_pwr_track_len == 0) && (pHalData->rf_tx_pwr_track == NULL)) - { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_track = rtw_zvmalloc(rlen); - if(pHalData->rf_tx_pwr_track) { - _rtw_memcpy(pHalData->rf_tx_pwr_track, pHalData->para_file_buf, rlen); - pHalData->rf_tx_pwr_track_len = rlen; - } - else { - DBG_871X("%s rf_tx_pwr_track alloc fail !\n",__FUNCTION__); - } - } - } - } - else - { - if ((pHalData->rf_tx_pwr_track_len != 0) && (pHalData->rf_tx_pwr_track != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if(rtStatus == _SUCCESS) - { - //DBG_871X("%s(): read %s successfully\n", __FUNCTION__, pFileName); - - ptmp = pHalData->para_file_buf; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if ( ! IsCommentString(szLine) ) - { - char band[5]="", path[5]="", sign[5] = ""; - char chnl[5]="", rate[10]=""; - char data[300]=""; // 100 is too small - - if (strlen(szLine) < 10 || szLine[0] != '[') - continue; - - strncpy(band, szLine+1, 2); - strncpy(path, szLine+5, 1); - strncpy(sign, szLine+8, 1); - - i = 10; // szLine+10 - if ( ! ParseQualifiedString(szLine, &i, rate, '[', ']') ) { - //DBG_871X("Fail to parse rate!\n"); - } - if ( ! ParseQualifiedString(szLine, &i, chnl, '[', ']') ) { - //DBG_871X("Fail to parse channel group!\n"); - } - while ( szLine[i] != '{' && i < strlen(szLine)) - i++; - if ( ! ParseQualifiedString(szLine, &i, data, '{', '}') ) { - //DBG_871X("Fail to parse data!\n"); - } - - initDeltaSwingIndexTables(Adapter, band, path, sign, chnl, rate, data); - } - } - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } -#if 0 - for (i = 0; i < DELTA_SWINGIDX_SIZE; ++i) - { - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P[i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N[%d] = %d\n", i, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N[i]); - - for (j = 0; j < 3; ++j) - { - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P[j][i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N[j][i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P[j][i]); - DBG_871X("pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[%d][%d] = %d\n", j, i, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N[j][i]); - } - } -#endif - return rtStatus; -} - -int -phy_ParsePowerLimitTableFile( - PADAPTER Adapter, - char* buffer -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - PDM_ODM_T pDM_Odm = &(pHalData->odmpriv); - u32 i = 0, forCnt = 0; - u8 loadingStage = 0, limitValue = 0, fraction = 0; - char *szLine, *ptmp; - int rtStatus = _SUCCESS; - char band[10], bandwidth[10], rateSection[10], - regulation[TXPWR_LMT_MAX_REGULATION_NUM][10], rfPath[10],colNumBuf[10]; - u8 colNum = 0; - - DBG_871X("===>phy_ParsePowerLimitTableFile()\n" ); - - if ( Adapter->registrypriv.RegDecryptCustomFile == 1 ) - phy_DecryptBBPgParaFile( Adapter, buffer); - - ptmp = buffer; - for (szLine = GetLineFromBuffer(ptmp); szLine != NULL; szLine = GetLineFromBuffer(ptmp)) - { - if (isAllSpaceOrTab(szLine, sizeof(*szLine))) - continue; - - // skip comment - if ( IsCommentString( szLine ) ) { - continue; - } - - if( loadingStage == 0 ) { - for ( forCnt = 0; forCnt < TXPWR_LMT_MAX_REGULATION_NUM; ++forCnt ) - _rtw_memset( ( PVOID ) regulation[forCnt], 0, 10 ); - _rtw_memset( ( PVOID ) band, 0, 10 ); - _rtw_memset( ( PVOID ) bandwidth, 0, 10 ); - _rtw_memset( ( PVOID ) rateSection, 0, 10 ); - _rtw_memset( ( PVOID ) rfPath, 0, 10 ); - _rtw_memset( ( PVOID ) colNumBuf, 0, 10 ); - - if ( szLine[0] != '#' || szLine[1] != '#' ) - continue; - - // skip the space - i = 2; - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - szLine[--i] = ' '; // return the space in front of the regulation info - - // Parse the label of the table - if ( ! ParseQualifiedString( szLine, &i, band, ' ', ',' ) ) { - DBG_871X( "Fail to parse band!\n"); - return _FAIL; - } - if ( ! ParseQualifiedString( szLine, &i, bandwidth, ' ', ',' ) ) { - DBG_871X("Fail to parse bandwidth!\n"); - return _FAIL; - } - if ( ! ParseQualifiedString( szLine, &i, rfPath, ' ', ',' ) ) { - DBG_871X("Fail to parse rf path!\n"); - return _FAIL; - } - if ( ! ParseQualifiedString( szLine, &i, rateSection, ' ', ',' ) ) { - DBG_871X("Fail to parse rate!\n"); - return _FAIL; - } - - loadingStage = 1; - } - else if ( loadingStage == 1 ) - { - if ( szLine[0] != '#' || szLine[1] != '#' ) - continue; - - // skip the space - i = 2; - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - if ( !eqNByte( (u8 *)(szLine + i), (u8 *)("START"), 5 ) ) { - DBG_871X("Lost \"## START\" label\n"); - return _FAIL; - } - - loadingStage = 2; - } - else if ( loadingStage == 2 ) - { - if ( szLine[0] != '#' || szLine[1] != '#' ) - continue; - - // skip the space - i = 2; - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - if ( ! ParseQualifiedString( szLine, &i, colNumBuf, '#', '#' ) ) { - DBG_871X("Fail to parse column number!\n"); - return _FAIL; - } - - if ( !GetU1ByteIntegerFromStringInDecimal( colNumBuf, &colNum ) ) - return _FAIL; - - if ( colNum > TXPWR_LMT_MAX_REGULATION_NUM ) { - DBG_871X("unvalid col number %d (greater than max %d)\n", - colNum, TXPWR_LMT_MAX_REGULATION_NUM ); - return _FAIL; - } - - for ( forCnt = 0; forCnt < colNum; ++forCnt ) - { - u8 regulation_name_cnt = 0; - - // skip the space - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - while ( szLine[i] != ' ' && szLine[i] != '\t' && szLine[i] != '\0' ) - regulation[forCnt][regulation_name_cnt++] = szLine[i++]; - //DBG_871X("regulation %s!\n", regulation[forCnt]); - - if ( regulation_name_cnt == 0 ) { - DBG_871X("unvalid number of regulation!\n"); - return _FAIL; - } - } - - loadingStage = 3; - } - else if ( loadingStage == 3 ) - { - char channel[10] = {0}, powerLimit[10] = {0}; - u8 cnt = 0; - - // the table ends - if ( szLine[0] == '#' && szLine[1] == '#' ) { - i = 2; - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - if ( eqNByte( (u8 *)(szLine + i), (u8 *)("END"), 3 ) ) { - loadingStage = 0; - continue; - } - else { - DBG_871X("Wrong format\n"); - DBG_871X("<===== phy_ParsePowerLimitTableFile()\n"); - return _FAIL; - } - } - - if ( ( szLine[0] != 'c' && szLine[0] != 'C' ) || - ( szLine[1] != 'h' && szLine[1] != 'H' ) ) { - DBG_871X("Meet wrong channel => power limt pair '%c','%c'(%d,%d)\n", szLine[0], szLine[1], szLine[0], szLine[1]); - continue; - } - i = 2;// move to the location behind 'h' - - // load the channel number - cnt = 0; - while ( szLine[i] >= '0' && szLine[i] <= '9' ) { - channel[cnt] = szLine[i]; - ++cnt; - ++i; - } - //DBG_871X("chnl %s!\n", channel); - - for ( forCnt = 0; forCnt < colNum; ++forCnt ) - { - // skip the space between channel number and the power limit value - while ( szLine[i] == ' ' || szLine[i] == '\t' ) - ++i; - - // load the power limit value - cnt = 0; - fraction = 0; - _rtw_memset( ( PVOID ) powerLimit, 0, 10 ); - while ( ( szLine[i] >= '0' && szLine[i] <= '9' ) || szLine[i] == '.' ) - { - if ( szLine[i] == '.' ){ - if ( ( szLine[i+1] >= '0' && szLine[i+1] <= '9' ) ) { - fraction = szLine[i+1]; - i += 2; - } - else { - DBG_871X("Wrong fraction in TXPWR_LMT.txt\n"); - return _FAIL; - } - - break; - } - - powerLimit[cnt] = szLine[i]; - ++cnt; - ++i; - } - - if ( powerLimit[0] == '\0' ) { - powerLimit[0] = '6'; - powerLimit[1] = '3'; - i += 2; - } - else { - if ( !GetU1ByteIntegerFromStringInDecimal( powerLimit, &limitValue ) ) - return _FAIL; - - limitValue *= 2; - cnt = 0; - if ( fraction == '5' ) - ++limitValue; - - // the value is greater or equal to 100 - if ( limitValue >= 100 ) { - powerLimit[cnt++] = limitValue/100 + '0'; - limitValue %= 100; - - if ( limitValue >= 10 ) { - powerLimit[cnt++] = limitValue/10 + '0'; - limitValue %= 10; - } - else { - powerLimit[cnt++] = '0'; - } - - powerLimit[cnt++] = limitValue + '0'; - } - // the value is greater or equal to 10 - else if ( limitValue >= 10 ) { - powerLimit[cnt++] = limitValue/10 + '0'; - limitValue %= 10; - powerLimit[cnt++] = limitValue + '0'; - } - // the value is less than 10 - else - powerLimit[cnt++] = limitValue + '0'; - - powerLimit[cnt] = '\0'; - } - - //DBG_871X("ch%s => %s\n", channel, powerLimit); - - // store the power limit value - PHY_SetTxPowerLimit(pDM_Odm, (u8 *)regulation[forCnt], (u8 *)band, - (u8 *)bandwidth, (u8 *)rateSection, (u8 *)rfPath, (u8 *)channel, (u8 *)powerLimit ); - - } - } - else - { - DBG_871X("Abnormal loading stage in phy_ParsePowerLimitTableFile()!\n"); - rtStatus = _FAIL; - break; - } - } - - DBG_871X("<===phy_ParsePowerLimitTableFile()\n"); - return rtStatus; -} - -int -PHY_ConfigRFWithPowerLimitTableParaFile( - IN PADAPTER Adapter, - IN const char *pFileName -) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - int rlen = 0, rtStatus = _FAIL; - - if(!(Adapter->registrypriv.load_phy_file & LOAD_RF_TXPWR_LMT_PARA_FILE)) - return rtStatus; - - _rtw_memset(pHalData->para_file_buf, 0, MAX_PARA_FILE_BUF_LEN); - - if (pHalData->rf_tx_pwr_lmt == NULL) { - rtw_get_phy_file_path(Adapter, pFileName); - if (rtw_is_file_readable(rtw_phy_para_file_path) == _TRUE) - { - rlen = rtw_retrieve_from_file(rtw_phy_para_file_path, pHalData->para_file_buf, MAX_PARA_FILE_BUF_LEN); - if (rlen > 0) - { - rtStatus = _SUCCESS; - pHalData->rf_tx_pwr_lmt = rtw_zvmalloc(rlen); - if(pHalData->rf_tx_pwr_lmt) { - _rtw_memcpy(pHalData->rf_tx_pwr_lmt, pHalData->para_file_buf, rlen); - pHalData->rf_tx_pwr_lmt_len = rlen; - } - else { - DBG_871X("%s rf_tx_pwr_lmt alloc fail !\n",__FUNCTION__); - } - } - } - } else { - if ((pHalData->rf_tx_pwr_lmt_len != 0) && (pHalData->rf_tx_pwr_lmt != NULL)) { - _rtw_memcpy(pHalData->para_file_buf, pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len); - rtStatus = _SUCCESS; - } - else { - DBG_871X("%s(): Critical Error !!!\n",__FUNCTION__); - } - } - - if(rtStatus == _SUCCESS) - { - //DBG_871X("%s(): read %s ok\n", __FUNCTION__, pFileName); - rtStatus = phy_ParsePowerLimitTableFile( Adapter, pHalData->para_file_buf ); - } - else - { - DBG_871X("%s(): No File %s, Load from HWImg Array!\n", __FUNCTION__, pFileName); - } - - return rtStatus; -} - -void phy_free_filebuf_mask(_adapter *padapter, u8 mask) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - if (pHalData->mac_reg && (mask & LOAD_MAC_PARA_FILE)) { - rtw_vmfree(pHalData->mac_reg, pHalData->mac_reg_len); - pHalData->mac_reg = NULL; - } - if (mask & LOAD_BB_PARA_FILE) { - if (pHalData->bb_phy_reg) { - rtw_vmfree(pHalData->bb_phy_reg, pHalData->bb_phy_reg_len); - pHalData->bb_phy_reg = NULL; - } - if (pHalData->bb_agc_tab) { - rtw_vmfree(pHalData->bb_agc_tab, pHalData->bb_agc_tab_len); - pHalData->bb_agc_tab = NULL; - } - } - if (pHalData->bb_phy_reg_pg && (mask & LOAD_BB_PG_PARA_FILE)) { - rtw_vmfree(pHalData->bb_phy_reg_pg, pHalData->bb_phy_reg_pg_len); - pHalData->bb_phy_reg_pg = NULL; - } - if (pHalData->bb_phy_reg_mp && (mask & LOAD_BB_MP_PARA_FILE)) { - rtw_vmfree(pHalData->bb_phy_reg_mp, pHalData->bb_phy_reg_mp_len); - pHalData->bb_phy_reg_mp = NULL; - } - if (mask & LOAD_RF_PARA_FILE) { - if (pHalData->rf_radio_a) { - rtw_vmfree(pHalData->rf_radio_a, pHalData->rf_radio_a_len); - pHalData->rf_radio_a = NULL; - } - if (pHalData->rf_radio_b) { - rtw_vmfree(pHalData->rf_radio_b, pHalData->rf_radio_b_len); - pHalData->rf_radio_b = NULL; - } - } - if (pHalData->rf_tx_pwr_track && (mask & LOAD_RF_TXPWR_TRACK_PARA_FILE)) { - rtw_vmfree(pHalData->rf_tx_pwr_track, pHalData->rf_tx_pwr_track_len); - pHalData->rf_tx_pwr_track = NULL; - } - if (pHalData->rf_tx_pwr_lmt && (mask & LOAD_RF_TXPWR_LMT_PARA_FILE)) { - rtw_vmfree(pHalData->rf_tx_pwr_lmt, pHalData->rf_tx_pwr_lmt_len); - pHalData->rf_tx_pwr_lmt = NULL; - } -} - -inline void phy_free_filebuf(_adapter *padapter) -{ - phy_free_filebuf_mask(padapter, 0xFF); -} - -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_dm.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_dm.c index 83736c674..76e99c907 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_dm.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_dm.c @@ -90,9 +90,6 @@ void Init_ODM_ComInfo(_adapter *adapter) rtw_odm_init_ic_type(adapter); - if (rtw_get_intf_type(adapter) == RTW_GSPI) - ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_INTERFACE, ODM_ITRF_SDIO); - else ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_INTERFACE, rtw_get_intf_type(adapter)); ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(pHalData->VersionID)); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_hci/hal_usb.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_hci/hal_usb.c index cf0d87c8e..6ae5e7a63 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_hci/hal_usb.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_hci/hal_usb.c @@ -35,7 +35,7 @@ int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz) #ifdef PLATFORM_LINUX tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))usb_recv_tasklet, + (void *)usb_recv_tasklet, (unsigned long)padapter); #endif /* PLATFORM_LINUX */ @@ -45,23 +45,6 @@ int usb_init_recv_priv(_adapter *padapter, u16 ini_in_buf_sz) #endif /* CONFIG_RX_INDICATE_QUEUE */ #endif /* PLATFORM_FREEBSD */ -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE -#ifdef PLATFORM_LINUX - precvpriv->int_in_urb = usb_alloc_urb(0, GFP_KERNEL); - if(precvpriv->int_in_urb == NULL){ - res = _FAIL; - DBG_8192C("alloc_urb for interrupt in endpoint fail !!!!\n"); - goto exit; - } -#endif /* PLATFORM_LINUX */ - precvpriv->int_in_buf = rtw_zmalloc(ini_in_buf_sz); - if(precvpriv->int_in_buf == NULL){ - res = _FAIL; - DBG_8192C("alloc_mem for interrupt in endpoint fail !!!!\n"); - goto exit; - } -#endif /* CONFIG_USB_INTERRUPT_IN_PIPE */ - /* init recv_buf */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); _rtw_init_queue(&precvpriv->recv_buf_pending_queue); @@ -177,17 +160,6 @@ void usb_free_recv_priv (_adapter *padapter, u16 ini_in_buf_sz) if(precvpriv->pallocated_recv_buf) rtw_mfree(precvpriv->pallocated_recv_buf, NR_RECVBUFF *sizeof(struct recv_buf) + 4); -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE -#ifdef PLATFORM_LINUX - if(precvpriv->int_in_urb) - { - usb_free_urb(precvpriv->int_in_urb); - } -#endif - if(precvpriv->int_in_buf) - rtw_mfree(precvpriv->int_in_buf, ini_in_buf_sz); -#endif /* CONFIG_USB_INTERRUPT_IN_PIPE */ - #ifdef PLATFORM_LINUX if (skb_queue_len(&precvpriv->rx_skb_queue)) { diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_intf.c b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_intf.c index 94f3d1199..3cfd43e53 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/hal_intf.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/hal_intf.c @@ -46,17 +46,8 @@ void rtw_hal_read_chip_info(_adapter *padapter) u8 hci_type = rtw_get_intf_type(padapter); u32 start = rtw_get_current_time(); - /* before access eFuse, make sure card enable has been called */ - if ((hci_type == RTW_SDIO || hci_type == RTW_GSPI) - && !rtw_is_hw_init_completed(padapter)) - rtw_hal_power_on(padapter); - padapter->HalFunc.read_adapter_info(padapter); - if ((hci_type == RTW_SDIO || hci_type == RTW_GSPI) - && !rtw_is_hw_init_completed(padapter)) - rtw_hal_power_off(padapter); - DBG_871X("%s in %d ms\n", __func__, rtw_get_passing_time_ms(start)); } @@ -104,9 +95,6 @@ void rtw_hal_data_deinit(_adapter *padapter) if (is_primary_adapter(padapter)) { if (padapter->HalData) { - #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - phy_free_filebuf(padapter); - #endif rtw_vmfree(padapter->HalData, padapter->hal_data_sz); padapter->HalData = NULL; padapter->hal_data_sz = 0; @@ -526,12 +514,6 @@ s32 rtw_hal_interrupt_handler(_adapter *padapter) return ret; } #endif -#if defined(CONFIG_USB_HCI) && defined(CONFIG_SUPPORT_USB_INT) -void rtw_hal_interrupt_handler(_adapter *padapter, u16 pkt_len, u8 *pbuf) -{ - padapter->HalFunc.interrupt_handler(padapter, pkt_len, pbuf); -} -#endif void rtw_hal_set_bwmode(_adapter *padapter, CHANNEL_WIDTH Bandwidth, u8 Offset) { @@ -784,7 +766,7 @@ s32 rtw_hal_fill_h2c_cmd(PADAPTER padapter, u8 ElementID, u32 CmdLen, u8 *pCmdBu if (pri_adapter->bFWReady == _TRUE) return padapter->HalFunc.fill_h2c_cmd(padapter, ElementID, CmdLen, pCmdBuffer); - else if (padapter->registrypriv.mp_mode == 0) + else DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" FW doesn't exit when no MP mode, by pass H2C id:0x%02x\n" , FUNC_ADPT_ARG(padapter), ElementID); return _FAIL; @@ -926,12 +908,6 @@ u8 rtw_hal_ops_check(_adapter *padapter) ret = _FAIL; } #endif/*#if defined(CONFIG_PCI_HCI)*/ - #if (defined(CONFIG_PCI_HCI)) || (defined(CONFIG_USB_HCI) && defined(CONFIG_SUPPORT_USB_INT)) - if (NULL == padapter->HalFunc.interrupt_handler) { - rtw_hal_error_msg("interrupt_handler"); - ret = _FAIL; - } - #endif /*#if (defined(CONFIG_PCI_HCI)) || (defined(CONFIG_USB_HCI) && defined(CONFIG_SUPPORT_USB_INT))*/ #if defined(CONFIG_PCI_HCI) || defined (CONFIG_SDIO_HCI) || defined (CONFIG_GSPI_HCI) if (NULL == padapter->HalFunc.enable_interrupt) { diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/led/hal_usb_led.c b/drivers/net/wireless/realtek/rtl8188fu/hal/led/hal_usb_led.c index 3b9a1cad8..7f772bb06 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/led/hal_usb_led.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/led/hal_usb_led.c @@ -5012,11 +5012,6 @@ LedControlUSB( { struct led_priv *ledpriv = &(padapter->ledpriv); -#if(MP_DRIVER == 1) - if (padapter->registrypriv.mp_mode == 1) - return; -#endif - if (RTW_CANNOT_RUN(padapter) || (!rtw_is_hw_init_completed(padapter))) { /*DBG_871X("%s bDriverStopped:%s, bSurpriseRemoved:%s\n" , __func__ diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.c deleted file mode 100644 index 142fef12e..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.c +++ /dev/null @@ -1,2504 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - #include "mp_precomp.h" - #include "phydm_precomp.h" - -#ifndef index_mapping_NUM_88E - #define index_mapping_NUM_88E 15 -#endif - -//#if(DM_ODM_SUPPORT_TYPE & ODM_WIN) - -#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \ - do {\ - for(_offset = 0; _offset < _size; _offset++)\ - {\ - if(_deltaThermal < thermalThreshold[_direction][_offset])\ - {\ - if(_offset != 0)\ - _offset--;\ - break;\ - }\ - } \ - if(_offset >= _size)\ - _offset = _size-1;\ - } while(0) - - -void ConfigureTxpowerTrack( - IN PVOID pDM_VOID, - OUT PTXPWRTRACK_CFG pConfig - ) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -#if RTL8812A_SUPPORT -#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - //if (IS_HARDWARE_TYPE_8812(pDM_Odm->Adapter)) - if(pDM_Odm->SupportICType==ODM_RTL8812) - ConfigureTxpowerTrack_8812A(pConfig); - //else -#endif -#endif - -#if RTL8814A_SUPPORT - if(pDM_Odm->SupportICType== ODM_RTL8814A) - ConfigureTxpowerTrack_8814A(pConfig); -#endif - - -#if RTL8188E_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8188E) - ConfigureTxpowerTrack_8188E(pConfig); -#endif -} - -#if (RTL8192E_SUPPORT==1) -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_92E( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - u1Byte ThermalValue = 0, delta, delta_IQK, delta_LCK, channel, is_decrease, rf_mimo_mode; - u1Byte ThermalValue_AVG_count = 0; - u1Byte OFDM_min_index = 10; //OFDM BB Swing should be less than +2.5dB, which is required by Arthur - s1Byte OFDM_index[2], index ; - u4Byte ThermalValue_AVG = 0, Reg0x18; - u4Byte i = 0, j = 0, rf; - s4Byte value32, CCK_index = 0, ele_A, ele_D, ele_C, X, Y; - prtl8192cd_priv priv = pDM_Odm->priv; - - rf_mimo_mode = pDM_Odm->RFType; - //ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("%s:%d rf_mimo_mode:%d\n", __FUNCTION__, __LINE__, rf_mimo_mode)); - -#ifdef MP_TEST - if ((OPMODE & WIFI_MP_STATE) || priv->pshare->rf_ft_var.mp_specific) { - channel = priv->pshare->working_channel; - if (priv->pshare->mp_txpwr_tracking == FALSE) - return; - } else -#endif - { - channel = (priv->pmib->dot11RFEntry.dot11channel); - } - - ThermalValue = (unsigned char)ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_RF_T_METER_92E, 0xfc00); //0x42: RF Reg[15:10] 88E - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\nReadback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", ThermalValue, priv->pshare->ThermalValue, priv->pmib->dot11RFEntry.ther)); - - - switch (rf_mimo_mode) { - case MIMO_1T1R: - rf = 1; - break; - case MIMO_2T2R: - rf = 2; - break; - default: - rf = 2; - break; - } - - //Query OFDM path A default setting Bit[31:21] - ele_D = PHY_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskOFDM_D); - for (i = 0; i < OFDM_TABLE_SIZE_92E; i++) { - if (ele_D == (OFDMSwingTable_92E[i] >> 22)) { - OFDM_index[0] = (unsigned char)i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("PathA 0xC80[31:22] = 0x%x, OFDM_index=%d\n", ele_D, OFDM_index[0])); - break; - } - } - - //Query OFDM path B default setting - if (rf_mimo_mode == MIMO_2T2R) { - ele_D = PHY_QueryBBReg(priv, rOFDM0_XBTxIQImbalance, bMaskOFDM_D); - for (i = 0; i < OFDM_TABLE_SIZE_92E; i++) { - if (ele_D == (OFDMSwingTable_92E[i] >> 22)) { - OFDM_index[1] = (unsigned char)i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("PathB 0xC88[31:22] = 0x%x, OFDM_index=%d\n", ele_D, OFDM_index[1])); - break; - } - } - } - - /* calculate average thermal meter */ - { - priv->pshare->ThermalValue_AVG_88XX[priv->pshare->ThermalValue_AVG_index_88XX] = ThermalValue; - priv->pshare->ThermalValue_AVG_index_88XX++; - if (priv->pshare->ThermalValue_AVG_index_88XX == AVG_THERMAL_NUM_88XX) - priv->pshare->ThermalValue_AVG_index_88XX = 0; - - for (i = 0; i < AVG_THERMAL_NUM_88XX; i++) { - if (priv->pshare->ThermalValue_AVG_88XX[i]) { - ThermalValue_AVG += priv->pshare->ThermalValue_AVG_88XX[i]; - ThermalValue_AVG_count++; - } - } - - if (ThermalValue_AVG_count) { - ThermalValue = (unsigned char)(ThermalValue_AVG / ThermalValue_AVG_count); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("AVG Thermal Meter = 0x%x \n", ThermalValue)); - } - } - - /* Initialize */ - if (!priv->pshare->ThermalValue) { - priv->pshare->ThermalValue = priv->pmib->dot11RFEntry.ther; - priv->pshare->ThermalValue_IQK = ThermalValue; - priv->pshare->ThermalValue_LCK = ThermalValue; - } - - if (ThermalValue != priv->pshare->ThermalValue) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\n******** START POWER TRACKING ********\n")); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\nReadback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", ThermalValue, priv->pshare->ThermalValue, priv->pmib->dot11RFEntry.ther)); - - delta = RTL_ABS(ThermalValue, priv->pmib->dot11RFEntry.ther); - delta_IQK = RTL_ABS(ThermalValue, priv->pshare->ThermalValue_IQK); - delta_LCK = RTL_ABS(ThermalValue, priv->pshare->ThermalValue_LCK); - is_decrease = ((ThermalValue < priv->pmib->dot11RFEntry.ther) ? 1 : 0); - -#ifdef _TRACKING_TABLE_FILE - if (priv->pshare->rf_ft_var.pwr_track_file) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Diff: (%s)%d ==> get index from table : %d)\n", (is_decrease?"-":"+"), delta, get_tx_tracking_index(priv, channel, i, delta, is_decrease, 0))); - - if (is_decrease) { - for (i = 0; i < rf; i++) { - OFDM_index[i] = priv->pshare->OFDM_index0[i] + get_tx_tracking_index(priv, channel, i, delta, is_decrease, 0); - OFDM_index[i] = ((OFDM_index[i] > (OFDM_TABLE_SIZE_92E- 1)) ? (OFDM_TABLE_SIZE_92E - 1) : OFDM_index[i]); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> decrese power ---> new OFDM_INDEX:%d (%d + %d)\n", OFDM_index[i], priv->pshare->OFDM_index0[i], get_tx_tracking_index(priv, channel, i, delta, is_decrease, 0))); - CCK_index = priv->pshare->CCK_index0 + get_tx_tracking_index(priv, channel, i, delta, is_decrease, 1); - CCK_index = ((CCK_index > (CCK_TABLE_SIZE_92E - 1)) ? (CCK_TABLE_SIZE_92E - 1) : CCK_index); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> Decrese power ---> new CCK_INDEX:%d (%d + %d)\n", CCK_index, priv->pshare->CCK_index0, get_tx_tracking_index(priv, channel, i, delta, is_decrease, 1))); - } - } else { - for (i = 0; i < rf; i++) { - OFDM_index[i] = priv->pshare->OFDM_index0[i] - get_tx_tracking_index(priv, channel, i, delta, is_decrease, 0); - OFDM_index[i] = ((OFDM_index[i] < OFDM_min_index) ? OFDM_min_index : OFDM_index[i]); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> Increse power ---> new OFDM_INDEX:%d (%d - %d)\n", OFDM_index[i], priv->pshare->OFDM_index0[i], get_tx_tracking_index(priv, channel, i, delta, is_decrease, 0))); - CCK_index = priv->pshare->CCK_index0 - get_tx_tracking_index(priv, channel, i, delta, is_decrease, 1); - CCK_index = ((CCK_index < 0 )? 0 : CCK_index); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> Increse power ---> new CCK_INDEX:%d (%d - %d)\n", CCK_index, priv->pshare->CCK_index0, get_tx_tracking_index(priv, channel, i, delta, is_decrease, 1))); - } - } - } -#endif //CFG_TRACKING_TABLE_FILE - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("OFDMSwingTable_92E[(unsigned int)OFDM_index[0]] = %x \n",OFDMSwingTable_92E[(unsigned int)OFDM_index[0]])); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("OFDMSwingTable_92E[(unsigned int)OFDM_index[1]] = %x \n",OFDMSwingTable_92E[(unsigned int)OFDM_index[1]])); - - //Adujst OFDM Ant_A according to IQK result - ele_D = (OFDMSwingTable_92E[(unsigned int)OFDM_index[0]] & 0xFFC00000) >> 22; - X = priv->pshare->RegE94; - Y = priv->pshare->RegE9C; - - if (X != 0) { - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - ele_A = ((X * ele_D) >> 8) & 0x000003FF; - - //new element C = element D x Y - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D) >> 8) & 0x000003FF; - - //wirte new elements A, C, D to regC80 and regC94, element B is always 0 - value32 = (ele_D << 22) | ((ele_C & 0x3F) << 16) | ele_A; - PHY_SetBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, value32); - - value32 = (ele_C&0x000003C0)>>6; - PHY_SetBBReg(priv, rOFDM0_XCTxAFE, bMaskH4Bits, value32); - - value32 = ((X * ele_D)>>7)&0x01; - PHY_SetBBReg(priv, rOFDM0_ECCAThreshold, BIT(24), value32); - } else { - PHY_SetBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable_92E[(unsigned int)OFDM_index[0]]); - PHY_SetBBReg(priv, rOFDM0_XCTxAFE, bMaskH4Bits, 0x00); - PHY_SetBBReg(priv, rOFDM0_ECCAThreshold, BIT(24), 0x00); - } - - set_CCK_swing_index(priv, CCK_index); - - if (rf == 2) { - ele_D = (OFDMSwingTable_92E[(unsigned int)OFDM_index[1]] & 0xFFC00000) >> 22; - X = priv->pshare->RegEB4; - Y = priv->pshare->RegEBC; - - if (X != 0) { - if ((X & 0x00000200) != 0) //consider minus - X = X | 0xFFFFFC00; - ele_A = ((X * ele_D) >> 8) & 0x000003FF; - - //new element C = element D x Y - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D) >> 8) & 0x00003FF; - - //wirte new elements A, C, D to regC88 and regC9C, element B is always 0 - value32 = (ele_D << 22) | ((ele_C & 0x3F) << 16) | ele_A; - PHY_SetBBReg(priv, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); - - value32 = (ele_C & 0x000003C0) >> 6; - PHY_SetBBReg(priv, rOFDM0_XDTxAFE, bMaskH4Bits, value32); - - value32 = ((X * ele_D) >> 7) & 0x01; - PHY_SetBBReg(priv, rOFDM0_ECCAThreshold, BIT(28), value32); - } else { - PHY_SetBBReg(priv, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable_92E[(unsigned int)OFDM_index[1]]); - PHY_SetBBReg(priv, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); - PHY_SetBBReg(priv, rOFDM0_ECCAThreshold, BIT(28), 0x00); - } - - } - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("0xc80 = 0x%x \n", PHY_QueryBBReg(priv, rOFDM0_XATxIQImbalance, bMaskDWord))); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("0xc88 = 0x%x \n", PHY_QueryBBReg(priv, rOFDM0_XBTxIQImbalance, bMaskDWord))); - - if (delta_IQK > 3) { - priv->pshare->ThermalValue_IQK = ThermalValue; -#ifdef MP_TEST - if (!(priv->pshare->rf_ft_var.mp_specific && (OPMODE & (WIFI_MP_CTX_BACKGROUND | WIFI_MP_CTX_PACKET)))) -#endif - PHY_IQCalibrate_8192E(pDM_Odm,false); - } - - if (delta_LCK > 8) { - RTL_W8(0x522, 0xff); - Reg0x18 = PHY_QueryRFReg(priv, RF_PATH_A, 0x18, bMask20Bits, 1); - PHY_SetRFReg(priv, RF_PATH_A, 0xB4, BIT(14), 1); - PHY_SetRFReg(priv, RF_PATH_A, 0x18, BIT(15), 1); - delay_ms(1); - PHY_SetRFReg(priv, RF_PATH_A, 0xB4, BIT(14), 0); - PHY_SetRFReg(priv, RF_PATH_A, 0x18, bMask20Bits, Reg0x18); - RTL_W8(0x522, 0x0); - priv->pshare->ThermalValue_LCK = ThermalValue; - } - } - - //update thermal meter value - priv->pshare->ThermalValue = ThermalValue; - for (i = 0 ; i < rf ; i++) - priv->pshare->OFDM_index[i] = OFDM_index[i]; - priv->pshare->CCK_index = CCK_index; - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("\n******** END:%s() ********\n", __FUNCTION__)); -} -#endif - -#if (RTL8814A_SUPPORT ==1) - -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries2( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - u1Byte ThermalValue = 0, delta, delta_LCK, delta_IQK, channel, is_increase; - u1Byte ThermalValue_AVG_count = 0, p = 0, i = 0; - u4Byte ThermalValue_AVG = 0, Reg0x18; - u4Byte BBSwingReg[4] = {rA_TxScale_Jaguar,rB_TxScale_Jaguar,rC_TxScale_Jaguar2,rD_TxScale_Jaguar2}; - s4Byte ele_D; - u4Byte BBswingIdx; - prtl8192cd_priv priv = pDM_Odm->priv; - TXPWRTRACK_CFG c; - BOOLEAN bTSSIenable = FALSE; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - //4 1. The following TWO tables decide the final index of OFDM/CCK swing table. - pu1Byte deltaSwingTableIdx_TUP_A = NULL, deltaSwingTableIdx_TDOWN_A = NULL; - pu1Byte deltaSwingTableIdx_TUP_B = NULL, deltaSwingTableIdx_TDOWN_B = NULL; - //for 8814 add by Yu Chen - pu1Byte deltaSwingTableIdx_TUP_C = NULL, deltaSwingTableIdx_TDOWN_C = NULL; - pu1Byte deltaSwingTableIdx_TUP_D = NULL, deltaSwingTableIdx_TDOWN_D = NULL; - -#ifdef MP_TEST - if ((OPMODE & WIFI_MP_STATE) || priv->pshare->rf_ft_var.mp_specific) { - channel = priv->pshare->working_channel; - if (priv->pshare->mp_txpwr_tracking == FALSE) - return; - } else -#endif - { - channel = (priv->pmib->dot11RFEntry.dot11channel); - } - - ConfigureTxpowerTrack(pDM_Odm, &c); - pRFCalibrateInfo->DefaultOfdmIndex = priv->pshare->OFDM_index0[ODM_RF_PATH_A]; - - (*c.GetDeltaSwingTable)(pDM_Odm, (pu1Byte*)&deltaSwingTableIdx_TUP_A, (pu1Byte*)&deltaSwingTableIdx_TDOWN_A, - (pu1Byte*)&deltaSwingTableIdx_TUP_B, (pu1Byte*)&deltaSwingTableIdx_TDOWN_B); - - if(pDM_Odm->SupportICType & ODM_RTL8814A) // for 8814 path C & D - (*c.GetDeltaSwingTable8814only)(pDM_Odm, (pu1Byte*)&deltaSwingTableIdx_TUP_C, (pu1Byte*)&deltaSwingTableIdx_TDOWN_C, - (pu1Byte*)&deltaSwingTableIdx_TUP_D, (pu1Byte*)&deltaSwingTableIdx_TDOWN_D); - - ThermalValue = (u1Byte)ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, c.ThermalRegAddr, 0xfc00); //0x42: RF Reg[15:10] 88E - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("\nReadback Thermal Meter = 0x%x, pre thermal meter 0x%x, EEPROMthermalmeter 0x%x\n", ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue, priv->pmib->dot11RFEntry.ther)); - - /* Initialize */ - if (!pDM_Odm->RFCalibrateInfo.ThermalValue) { - pDM_Odm->RFCalibrateInfo.ThermalValue = priv->pmib->dot11RFEntry.ther; - } - - if (!pDM_Odm->RFCalibrateInfo.ThermalValue_LCK) { - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = priv->pmib->dot11RFEntry.ther; - } - - if (!pDM_Odm->RFCalibrateInfo.ThermalValue_IQK) { - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = priv->pmib->dot11RFEntry.ther; - } - - bTSSIenable = (BOOLEAN)ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, rRF_TxGainOffset, BIT7); // check TSSI enable - - //4 Query OFDM BB swing default setting Bit[31:21] - for(p = ODM_RF_PATH_A ; p < c.RfPathCount ; p++) - { - ele_D = ODM_GetBBReg(pDM_Odm, BBSwingReg[p], 0xffe00000); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("0x%x:0x%x ([31:21] = 0x%x)\n", BBSwingReg[p], ODM_GetBBReg(pDM_Odm, BBSwingReg[p], bMaskDWord), ele_D)); - - for (BBswingIdx = 0; BBswingIdx < TXSCALE_TABLE_SIZE; BBswingIdx++) {//4 - if (ele_D == TxScalingTable_Jaguar[BBswingIdx]) { - pDM_Odm->RFCalibrateInfo.OFDM_index[p] = (u1Byte)BBswingIdx; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("OFDM_index[%d]=%d\n",p, pDM_Odm->RFCalibrateInfo.OFDM_index[p])); - break; - } - } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("KfreeOffset[%d]=%d\n",p, pRFCalibrateInfo->KfreeOffset[p])); - - } - - /* calculate average thermal meter */ - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index++; - if(pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index == c.AverageThermalNum) //Average times = c.AverageThermalNum - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; - - for(i = 0; i < c.AverageThermalNum; i++) - { - if(pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i]) - { - ThermalValue_AVG += pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i]; - ThermalValue_AVG_count++; - } - } - - if(ThermalValue_AVG_count) //Calculate Average ThermalValue after average enough times - { - ThermalValue = (u1Byte)(ThermalValue_AVG / ThermalValue_AVG_count); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("AVG Thermal Meter = 0x%X, EEPROMthermalmeter = 0x%X\n", ThermalValue, priv->pmib->dot11RFEntry.ther)); - } - - //4 Calculate delta, delta_LCK, delta_IQK. - delta = RTL_ABS(ThermalValue, priv->pmib->dot11RFEntry.ther); - delta_LCK = RTL_ABS(ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue_LCK); - delta_IQK = RTL_ABS(ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue_IQK); - is_increase = ((ThermalValue < priv->pmib->dot11RFEntry.ther) ? 0 : 1); - - //4 if necessary, do LCK. - if (!(pDM_Odm->SupportICType & ODM_RTL8821)) { - if (delta_LCK > c.Threshold_IQK) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("delta_LCK(%d) >= Threshold_IQK(%d)\n", delta_LCK, c.Threshold_IQK)); - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; - if (c.PHY_LCCalibrate) - (*c.PHY_LCCalibrate)(pDM_Odm); - } - } - - if (delta_IQK > c.Threshold_IQK) - { - panic_printk("%s(%d)\n", __FUNCTION__, __LINE__); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("delta_IQK(%d) >= Threshold_IQK(%d)\n", delta_IQK, c.Threshold_IQK)); - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; - if(c.DoIQK) - (*c.DoIQK)(pDM_Odm, TRUE, 0, 0); - } - - if(!priv->pmib->dot11RFEntry.ther) /*Don't do power tracking since no calibrated thermal value*/ - return; - - //4 Do Power Tracking - - if(bTSSIenable == TRUE) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("**********Enter PURE TSSI MODE**********\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, TSSI_MODE, p, 0); - } - else if (ThermalValue != pDM_Odm->RFCalibrateInfo.ThermalValue) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("\n******** START POWER TRACKING ********\n")); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("\nReadback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue, priv->pmib->dot11RFEntry.ther)); - -#ifdef _TRACKING_TABLE_FILE - if (priv->pshare->rf_ft_var.pwr_track_file) - { - if (is_increase) // thermal is higher than base - { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - switch(p) - { - case ODM_RF_PATH_B: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_B[%d] = %d\n", delta, deltaSwingTableIdx_TUP_B[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_B[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_C: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_C[%d] = %d\n", delta, deltaSwingTableIdx_TUP_C[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_C[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_C] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_D: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_D[%d] = %d\n", delta, deltaSwingTableIdx_TUP_D[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_D[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_D] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - default: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_A[%d] = %d\n", delta, deltaSwingTableIdx_TUP_A[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_A[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - } - } - } - else // thermal is lower than base - { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - switch(p) - { - case ODM_RF_PATH_B: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_B[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_B[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_C: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_C[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_C[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_C[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_C] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_D: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_D[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_D[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_D[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_D] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - default: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_A[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_A[delta])); - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - } - } - } - - if (is_increase) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> increse power ---> \n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0); - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> decrese power --->\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0); - } - } -#endif - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\n******** END:%s() ********\n", __FUNCTION__)); - //update thermal meter value - pDM_Odm->RFCalibrateInfo.ThermalValue = ThermalValue; - - } -} - -#elif(ODM_IC_11AC_SERIES_SUPPORT) -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - unsigned char ThermalValue = 0, delta, delta_LCK, channel, is_decrease; - unsigned char ThermalValue_AVG_count = 0; - unsigned int ThermalValue_AVG = 0, Reg0x18; - unsigned int BBSwingReg[4]={0xc1c,0xe1c,0x181c,0x1a1c}; - int ele_D, value32; - char OFDM_index[2], index; - unsigned int i = 0, j = 0, rf_path, max_rf_path =2 ,rf; - prtl8192cd_priv priv = pDM_Odm->priv; - unsigned char OFDM_min_index = 7; //OFDM BB Swing should be less than +2.5dB, which is required by Arthur and Mimic - -#ifdef MP_TEST - if ((OPMODE & WIFI_MP_STATE) || priv->pshare->rf_ft_var.mp_specific) { - channel = priv->pshare->working_channel; - if (priv->pshare->mp_txpwr_tracking == FALSE) - return; - } else -#endif - { - channel = (priv->pmib->dot11RFEntry.dot11channel); - } - -#if RTL8881A_SUPPORT - if (pDM_Odm->SupportICType == ODM_RTL8881A) { - max_rf_path = 1; - if ((get_bonding_type_8881A() == BOND_8881AM ||get_bonding_type_8881A() == BOND_8881AN) - && priv->pshare->rf_ft_var.use_intpa8881A && (priv->pmib->dot11RFEntry.phyBandSelect == PHY_BAND_2G)) - OFDM_min_index = 6; // intPA - upper bond set to +3 dB (base: -2 dB)ot11RFEntry.phyBandSelect == PHY_BAND_2G)) - else - OFDM_min_index = 10; //OFDM BB Swing should be less than +1dB, which is required by Arthur and Mimic - } -#endif - - - ThermalValue = (unsigned char)PHY_QueryRFReg(priv, RF_PATH_A, 0x42, 0xfc00, 1); //0x42: RF Reg[15:10] 88E - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\nReadback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", ThermalValue, priv->pshare->ThermalValue, priv->pmib->dot11RFEntry.ther)); - - - //4 Query OFDM BB swing default setting Bit[31:21] - for(rf_path = 0 ; rf_path < max_rf_path ; rf_path++){ - ele_D = PHY_QueryBBReg(priv, BBSwingReg[rf_path], 0xffe00000); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("0x%x:0x%x ([31:21] = 0x%x)\n",BBSwingReg[rf_path], PHY_QueryBBReg(priv, BBSwingReg[rf_path], bMaskDWord),ele_D)); - for (i = 0; i < OFDM_TABLE_SIZE_8812; i++) {//4 - if (ele_D == OFDMSwingTable_8812[i]) { - OFDM_index[rf_path] = (unsigned char)i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("OFDM_index[%d]=%d\n",rf_path, OFDM_index[rf_path])); - break; - } - } - } -#if 0 - //Query OFDM path A default setting Bit[31:21] - ele_D = PHY_QueryBBReg(priv, 0xc1c, 0xffe00000); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("0xc1c:0x%x ([31:21] = 0x%x)\n", PHY_QueryBBReg(priv, 0xc1c, bMaskDWord),ele_D)); - for (i = 0; i < OFDM_TABLE_SIZE_8812; i++) {//4 - if (ele_D == OFDMSwingTable_8812[i]) { - OFDM_index[0] = (unsigned char)i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("OFDM_index[0]=%d\n", OFDM_index[0])); - break; - } - } - //Query OFDM path B default setting - if (rf == 2) { - ele_D = PHY_QueryBBReg(priv, 0xe1c, 0xffe00000); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("0xe1c:0x%x ([32:21] = 0x%x)\n", PHY_QueryBBReg(priv, 0xe1c, bMaskDWord),ele_D)); - for (i = 0; i < OFDM_TABLE_SIZE_8812; i++) { - if (ele_D == OFDMSwingTable_8812[i]) { - OFDM_index[1] = (unsigned char)i; - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("OFDM_index[1]=%d\n", OFDM_index[1])); - break; - } - } - } -#endif - /* Initialize */ - if (!priv->pshare->ThermalValue) { - priv->pshare->ThermalValue = priv->pmib->dot11RFEntry.ther; - priv->pshare->ThermalValue_LCK = ThermalValue; - } - - /* calculate average thermal meter */ - { - priv->pshare->ThermalValue_AVG_8812[priv->pshare->ThermalValue_AVG_index_8812] = ThermalValue; - priv->pshare->ThermalValue_AVG_index_8812++; - if (priv->pshare->ThermalValue_AVG_index_8812 == AVG_THERMAL_NUM_8812) - priv->pshare->ThermalValue_AVG_index_8812 = 0; - - for (i = 0; i < AVG_THERMAL_NUM_8812; i++) { - if (priv->pshare->ThermalValue_AVG_8812[i]) { - ThermalValue_AVG += priv->pshare->ThermalValue_AVG_8812[i]; - ThermalValue_AVG_count++; - } - } - - if (ThermalValue_AVG_count) { - ThermalValue = (unsigned char)(ThermalValue_AVG / ThermalValue_AVG_count); - //printk("AVG Thermal Meter = 0x%x \n", ThermalValue); - } - } - - - //4 If necessary, do power tracking - - if(!priv->pmib->dot11RFEntry.ther) /*Don't do power tracking since no calibrated thermal value*/ - return; - - if (ThermalValue != priv->pshare->ThermalValue) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\n******** START POWER TRACKING ********\n")); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\nReadback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", ThermalValue, priv->pshare->ThermalValue, priv->pmib->dot11RFEntry.ther)); - delta = RTL_ABS(ThermalValue, priv->pmib->dot11RFEntry.ther); - delta_LCK = RTL_ABS(ThermalValue, priv->pshare->ThermalValue_LCK); - is_decrease = ((ThermalValue < priv->pmib->dot11RFEntry.ther) ? 1 : 0); - //if (priv->pmib->dot11RFEntry.phyBandSelect == PHY_BAND_5G) - { -#ifdef _TRACKING_TABLE_FILE - if (priv->pshare->rf_ft_var.pwr_track_file) { - for (rf_path = 0; rf_path < max_rf_path; rf_path++) { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Diff: (%s)%d ==> get index from table : %d)\n", (is_decrease?"-":"+"), delta, get_tx_tracking_index(priv, channel, rf_path, delta, is_decrease, 0))); - if (is_decrease) { - OFDM_index[rf_path] = priv->pshare->OFDM_index0[rf_path] + get_tx_tracking_index(priv, channel, rf_path, delta, is_decrease, 0); - OFDM_index[rf_path] = ((OFDM_index[rf_path] > (OFDM_TABLE_SIZE_8812 - 1)) ? (OFDM_TABLE_SIZE_8812 - 1) : OFDM_index[rf_path]); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> decrese power ---> new OFDM_INDEX:%d (%d + %d)\n", OFDM_index[rf_path], priv->pshare->OFDM_index0[rf_path], get_tx_tracking_index(priv, channel, rf_path, delta, is_decrease, 0))); -#if 0// RTL8881A_SUPPORT - if (pDM_Odm->SupportICType == ODM_RTL8881A){ - if(priv->pshare->rf_ft_var.pwrtrk_TxAGC_enable){ - if(priv->pshare->AddTxAGC){//TxAGC has been added - AddTxPower88XX_AC(priv,0); - priv->pshare->AddTxAGC = 0; - priv->pshare->AddTxAGC_index = 0; - } - } - } -#endif - } else { - - OFDM_index[rf_path] = priv->pshare->OFDM_index0[rf_path] - get_tx_tracking_index(priv, channel, rf_path, delta, is_decrease, 0); -#if 0// RTL8881A_SUPPORT - if(pDM_Odm->SupportICType == ODM_RTL8881A){ - if(priv->pshare->rf_ft_var.pwrtrk_TxAGC_enable){ - if(OFDM_index[i] < OFDM_min_index){ - priv->pshare->AddTxAGC_index = (OFDM_min_index - OFDM_index[i])/2; // Calculate Remnant TxAGC Value, 2 index for 1 TxAGC - AddTxPower88XX_AC(priv,priv->pshare->AddTxAGC_index); - priv->pshare->AddTxAGC = 1; //AddTxAGC Flag = 1 - OFDM_index[i] = OFDM_min_index; - } - else{ - if(priv->pshare->AddTxAGC){// TxAGC been added - priv->pshare->AddTxAGC = 0; - priv->pshare->AddTxAGC_index = 0; - AddTxPower88XX_AC(priv,0); //minus the added TPI - } - } - } - } -#else - OFDM_index[rf_path] = ((OFDM_index[rf_path] < OFDM_min_index) ? OFDM_min_index : OFDM_index[rf_path]); -#endif - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,(">>> increse power ---> new OFDM_INDEX:%d (%d - %d)\n", OFDM_index[rf_path], priv->pshare->OFDM_index0[rf_path], get_tx_tracking_index(priv, channel, rf_path, delta, is_decrease, 0))); - } - } - } -#endif - //4 Set new BB swing index - for (rf_path = 0; rf_path < max_rf_path; rf_path++) { - PHY_SetBBReg(priv, BBSwingReg[rf_path], 0xffe00000, OFDMSwingTable_8812[(unsigned int)OFDM_index[rf_path]]); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Readback 0x%x[31:21] = 0x%x, OFDM_index:%d\n",BBSwingReg[rf_path], PHY_QueryBBReg(priv, BBSwingReg[rf_path], 0xffe00000), OFDM_index[rf_path])); - } - - } - if (delta_LCK > 8) { - RTL_W8(0x522, 0xff); - Reg0x18 = PHY_QueryRFReg(priv, RF_PATH_A, 0x18, bMask20Bits, 1); - PHY_SetRFReg(priv, RF_PATH_A, 0xB4, BIT(14), 1); - PHY_SetRFReg(priv, RF_PATH_A, 0x18, BIT(15), 1); - delay_ms(200); // frequency deviation - PHY_SetRFReg(priv, RF_PATH_A, 0xB4, BIT(14), 0); - PHY_SetRFReg(priv, RF_PATH_A, 0x18, bMask20Bits, Reg0x18); - #ifdef CONFIG_RTL_8812_SUPPORT - if (GET_CHIP_VER(priv)== VERSION_8812E) - UpdateBBRFVal8812(priv, priv->pmib->dot11RFEntry.dot11channel); - #endif - RTL_W8(0x522, 0x0); - priv->pshare->ThermalValue_LCK = ThermalValue; - } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("\n******** END:%s() ********\n", __FUNCTION__)); - - //update thermal meter value - priv->pshare->ThermalValue = ThermalValue; - for (rf_path = 0; rf_path < max_rf_path; rf_path++) - priv->pshare->OFDM_index[rf_path] = OFDM_index[rf_path]; - } -} - -#endif - - -VOID -ODM_TXPowerTrackingCallback_ThermalMeter( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); -#if (RTL8814A_SUPPORT == 1) //use this function to do power tracking after 8814 by YuChen - if (pDM_Odm->SupportICType & ODM_RTL8814A) { - ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries2(pDM_Odm); - return; - } -#elif ODM_IC_11AC_SERIES_SUPPORT - if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { - ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries(pDM_Odm); - return; - } -#endif - -#if (RTL8192E_SUPPORT == 1) - if (pDM_Odm->SupportICType==ODM_RTL8192E) { - ODM_TXPowerTrackingCallback_ThermalMeter_92E(pDM_Odm); - return; - } -#endif - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - //PMGNT_INFO pMgntInfo = &Adapter->MgntInfo; -#endif - - u1Byte ThermalValue = 0, delta, delta_LCK, delta_IQK, offset; - u1Byte ThermalValue_AVG_count = 0; - u4Byte ThermalValue_AVG = 0; -// s4Byte ele_A=0, ele_D, TempCCk, X, value32; -// s4Byte Y, ele_C=0; -// s1Byte OFDM_index[2], CCK_index=0, OFDM_index_old[2]={0,0}, CCK_index_old=0, index; -// s1Byte deltaPowerIndex = 0; - u4Byte i = 0;//, j = 0; - BOOLEAN is2T = FALSE; -// BOOLEAN bInteralPA = FALSE; - - u1Byte OFDM_max_index = 34, rf = (is2T) ? 2 : 1; //OFDM BB Swing should be less than +3.0dB, which is required by Arthur - u1Byte Indexforchannel = 0;/*GetRightChnlPlaceforIQK(pHalData->CurrentChannel)*/ - enum _POWER_DEC_INC { POWER_DEC, POWER_INC }; - #if (DM_ODM_SUPPORT_TYPE == ODM_CE) - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; - #endif - #if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc; - #endif - - TXPWRTRACK_CFG c; - - - //4 1. The following TWO tables decide the final index of OFDM/CCK swing table. - s1Byte deltaSwingTableIdx[2][index_mapping_NUM_88E] = { - // {{Power decreasing(lower temperature)}, {Power increasing(higher temperature)}} - {0,0,2,3,4,4,5,6,7,7,8,9,10,10,11}, {0,0,1,2,3,4,4,4,4,5,7,8,9,9,10} - }; - u1Byte thermalThreshold[2][index_mapping_NUM_88E]={ - // {{Power decreasing(lower temperature)}, {Power increasing(higher temperature)}} - {0,2,4,6,8,10,12,14,16,18,20,22,24,26,27}, {0,2,4,6,8,10,12,14,16,18,20,22,25,25,25} - }; - -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - prtl8192cd_priv priv = pDM_Odm->priv; -#endif - - //4 2. Initilization ( 7 steps in total ) - - ConfigureTxpowerTrack(pDM_Odm, &c); - - pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; //cosa add for debug - pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = TRUE; - -#if (MP_DRIVER == 1) - pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = pHalData->TxPowerTrackControl; // We should keep updating the control variable according to HalData. - // RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. - pDM_Odm->RFCalibrateInfo.RegA24 = 0x090e1317; -#endif - -#if (DM_ODM_SUPPORT_TYPE == ODM_AP) && defined(MP_TEST) - if ((OPMODE & WIFI_MP_STATE) || pDM_Odm->priv->pshare->rf_ft_var.mp_specific) { - if(pDM_Odm->priv->pshare->mp_txpwr_tracking == FALSE) - return; - } -#endif - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("===>odm_TXPowerTrackingCallback_ThermalMeter_8188E, pDM_Odm->BbSwingIdxCckBase: %d, pDM_Odm->BbSwingIdxOfdmBase: %d \n", pRFCalibrateInfo->BbSwingIdxCckBase, pRFCalibrateInfo->BbSwingIdxOfdmBase)); -/* - if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { - ODM_SetRFReg(pDM_Odm, RF_PATH_A, c.ThermalRegAddr, BIT17 | BIT16, 0x3); - pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; - return; - } -*/ - ThermalValue = (u1Byte)ODM_GetRFReg(pDM_Odm, RF_PATH_A, c.ThermalRegAddr, 0xfc00); //0x42: RF Reg[15:10] 88E -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - if( ! ThermalValue || ! pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) -#else - if( ! pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) -#endif - return; - - //4 3. Initialize ThermalValues of RFCalibrateInfo - - if( ! pDM_Odm->RFCalibrateInfo.ThermalValue) - { - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; - } - - if(pDM_Odm->RFCalibrateInfo.bReloadtxpowerindex) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("reload ofdm index for band switch\n")); - } - - //4 4. Calculate average thermal meter - - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index++; - if(pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index == c.AverageThermalNum) - pDM_Odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; - - for(i = 0; i < c.AverageThermalNum; i++) - { - if(pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i]) - { - ThermalValue_AVG += pDM_Odm->RFCalibrateInfo.ThermalValue_AVG[i]; - ThermalValue_AVG_count++; - } - } - - if(ThermalValue_AVG_count) - { - // Give the new thermo value a weighting - ThermalValue_AVG += (ThermalValue*4); - - ThermalValue = (u1Byte)(ThermalValue_AVG / (ThermalValue_AVG_count+4)); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("AVG Thermal Meter = 0x%x \n", ThermalValue)); - } - - //4 5. Calculate delta, delta_LCK, delta_IQK. - - delta = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue):(pDM_Odm->RFCalibrateInfo.ThermalValue - ThermalValue); - delta_LCK = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_LCK)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK):(pDM_Odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); - delta_IQK = (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue_IQK)?(ThermalValue - pDM_Odm->RFCalibrateInfo.ThermalValue_IQK):(pDM_Odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); - - //4 6. If necessary, do LCK. - if (!(pDM_Odm->SupportICType & ODM_RTL8821)) { - /*if((delta_LCK > pHalData->Delta_LCK) && (pHalData->Delta_LCK != 0))*/ - if (delta_LCK >= c.Threshold_IQK) { - /*Delta temperature is equal to or larger than 20 centigrade.*/ - pDM_Odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; - (*c.PHY_LCCalibrate)(pDM_Odm); - } - } - - //3 7. If necessary, move the index of swing table to adjust Tx power. - - if (delta > 0 && pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) - { -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - delta = ThermalValue > pHalData->EEPROMThermalMeter?(ThermalValue - pHalData->EEPROMThermalMeter):(pHalData->EEPROMThermalMeter - ThermalValue); -#else - delta = (ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther)?(ThermalValue - pDM_Odm->priv->pmib->dot11RFEntry.ther):(pDM_Odm->priv->pmib->dot11RFEntry.ther - ThermalValue); -#endif - - - //4 7.1 The Final Power Index = BaseIndex + PowerIndexOffset - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - if(ThermalValue > pHalData->EEPROMThermalMeter) { -#else - if(ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther) { -#endif - CALCULATE_SWINGTALBE_OFFSET(offset, POWER_INC, index_mapping_NUM_88E, delta); - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex = deltaSwingTableIdx[POWER_INC][offset]; - - } else { - - CALCULATE_SWINGTALBE_OFFSET(offset, POWER_DEC, index_mapping_NUM_88E, delta); - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex = (-1)*deltaSwingTableIdx[POWER_DEC][offset]; - } - - if (pDM_Odm->RFCalibrateInfo.DeltaPowerIndex == pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast) - pDM_Odm->RFCalibrateInfo.PowerIndexOffset = 0; - else - pDM_Odm->RFCalibrateInfo.PowerIndexOffset = pDM_Odm->RFCalibrateInfo.DeltaPowerIndex - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast; - - for(i = 0; i < rf; i++) - pDM_Odm->RFCalibrateInfo.OFDM_index[i] = pRFCalibrateInfo->BbSwingIdxOfdmBase + pDM_Odm->RFCalibrateInfo.PowerIndexOffset; - pDM_Odm->RFCalibrateInfo.CCK_index = pRFCalibrateInfo->BbSwingIdxCckBase + pDM_Odm->RFCalibrateInfo.PowerIndexOffset; - - pRFCalibrateInfo->BbSwingIdxCck = pDM_Odm->RFCalibrateInfo.CCK_index; - pRFCalibrateInfo->BbSwingIdxOfdm[RF_PATH_A] = pDM_Odm->RFCalibrateInfo.OFDM_index[RF_PATH_A]; - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("The 'CCK' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d)\n", pRFCalibrateInfo->BbSwingIdxCck, pRFCalibrateInfo->BbSwingIdxCckBase, pDM_Odm->RFCalibrateInfo.PowerIndexOffset)); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("The 'OFDM' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d)\n", pRFCalibrateInfo->BbSwingIdxOfdm[RF_PATH_A], pRFCalibrateInfo->BbSwingIdxOfdmBase, pDM_Odm->RFCalibrateInfo.PowerIndexOffset)); - - //4 7.1 Handle boundary conditions of index. - - - for(i = 0; i < rf; i++) - { - if(pDM_Odm->RFCalibrateInfo.OFDM_index[i] > OFDM_max_index) - { - pDM_Odm->RFCalibrateInfo.OFDM_index[i] = OFDM_max_index; - } - else if (pDM_Odm->RFCalibrateInfo.OFDM_index[i] < 0) - { - pDM_Odm->RFCalibrateInfo.OFDM_index[i] = 0; - } - } - - if(pDM_Odm->RFCalibrateInfo.CCK_index > c.SwingTableSize_CCK-1) - pDM_Odm->RFCalibrateInfo.CCK_index = c.SwingTableSize_CCK-1; - else if (pDM_Odm->RFCalibrateInfo.CCK_index < 0) - pDM_Odm->RFCalibrateInfo.CCK_index = 0; - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("The thermal meter is unchanged or TxPowerTracking OFF: ThermalValue: %d , pDM_Odm->RFCalibrateInfo.ThermalValue: %d)\n", ThermalValue, pDM_Odm->RFCalibrateInfo.ThermalValue)); - pDM_Odm->RFCalibrateInfo.PowerIndexOffset = 0; - } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("TxPowerTracking: [CCK] Swing Current Index: %d, Swing Base Index: %d\n", pDM_Odm->RFCalibrateInfo.CCK_index, pRFCalibrateInfo->BbSwingIdxCckBase)); - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("TxPowerTracking: [OFDM] Swing Current Index: %d, Swing Base Index: %d\n", pDM_Odm->RFCalibrateInfo.OFDM_index[RF_PATH_A], pRFCalibrateInfo->BbSwingIdxOfdmBase)); - - if (pDM_Odm->RFCalibrateInfo.PowerIndexOffset != 0 && pDM_Odm->RFCalibrateInfo.TxPowerTrackControl) - { - //4 7.2 Configure the Swing Table to adjust Tx Power. - - pDM_Odm->RFCalibrateInfo.bTxPowerChanged = TRUE; // Always TRUE after Tx Power is adjusted by power tracking. - // - // 2012/04/23 MH According to Luke's suggestion, we can not write BB digital - // to increase TX power. Otherwise, EVM will be bad. - // - // 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. - if (ThermalValue > pDM_Odm->RFCalibrateInfo.ThermalValue) - { - //ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - // ("Temperature Increasing: delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", - // pDM_Odm->RFCalibrateInfo.PowerIndexOffset, delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); - } - else if (ThermalValue < pDM_Odm->RFCalibrateInfo.ThermalValue)// Low temperature - { - //ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - // ("Temperature Decreasing: delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", - // pDM_Odm->RFCalibrateInfo.PowerIndexOffset, delta, ThermalValue, pHalData->EEPROMThermalMeter, pDM_Odm->RFCalibrateInfo.ThermalValue)); - } -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - if (ThermalValue > pHalData->EEPROMThermalMeter) -#else - if (ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther) -#endif - { -// ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Temperature(%d) hugher than PG value(%d), increases the power by TxAGC\n", ThermalValue, pHalData->EEPROMThermalMeter)); - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, TXAGC, 0, 0); - } - else - { - // ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("Temperature(%d) lower than PG value(%d), increases the power by TxAGC\n", ThermalValue, pHalData->EEPROMThermalMeter)); - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, BBSWING, RF_PATH_A, Indexforchannel); - if(is2T) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, BBSWING, RF_PATH_B, Indexforchannel); - } - - pRFCalibrateInfo->BbSwingIdxCckBase = pRFCalibrateInfo->BbSwingIdxCck; - pRFCalibrateInfo->BbSwingIdxOfdmBase = pRFCalibrateInfo->BbSwingIdxOfdm[RF_PATH_A]; - pDM_Odm->RFCalibrateInfo.ThermalValue = ThermalValue; - - } - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - // if((delta_IQK > pHalData->Delta_IQK) && (pHalData->Delta_IQK != 0)) - if ((delta_IQK >= 8)) // Delta temperature is equal to or larger than 20 centigrade. - (*c.DoIQK)(pDM_Odm, delta_IQK, ThermalValue, 8); -#endif - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("<===dm_TXPowerTrackingCallback_ThermalMeter_8188E\n")); - - pDM_Odm->RFCalibrateInfo.TXPowercount = 0; -} - -#if (DM_ODM_SUPPORT_TYPE & ODM_WIN) - - -VOID -phy_PathAStandBy( - IN PADAPTER pAdapter - ) -{ - RTPRINT(FINIT, INIT_IQK, ("Path-A standby mode!\n")); - - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x0); - PHY_SetBBReg(pAdapter, 0x840, bMaskDWord, 0x00010000); - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x808000); -} - -//1 7. IQK -//#define MAX_TOLERANCE 5 -//#define IQK_DELAY_TIME 1 //ms - -u1Byte //bit0 = 1 => Tx OK, bit1 = 1 => Rx OK -phy_PathA_IQK_8192C( - IN PADAPTER pAdapter, - IN BOOLEAN configPathB - ) -{ - - u4Byte regEAC, regE94, regE9C, regEA4; - u1Byte result = 0x00; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - RTPRINT(FINIT, INIT_IQK, ("Path A IQK!\n")); - - //path-A IQK setting - RTPRINT(FINIT, INIT_IQK, ("Path-A IQK setting!\n")); - if(pAdapter->interfaceIndex == 0) - { - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1f); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f); - } - else - { - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x10008c22); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x10008c22); - } - - PHY_SetBBReg(pAdapter, rTx_IQK_PI_A, bMaskDWord, 0x82140102); - - PHY_SetBBReg(pAdapter, rRx_IQK_PI_A, bMaskDWord, configPathB ? 0x28160202 : - IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)?0x28160202:0x28160502); - - //path-B IQK setting - if(configPathB) - { - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_B, bMaskDWord, 0x10008c22); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_B, bMaskDWord, 0x10008c22); - PHY_SetBBReg(pAdapter, rTx_IQK_PI_B, bMaskDWord, 0x82140102); - PHY_SetBBReg(pAdapter, rRx_IQK_PI_B, bMaskDWord, 0x28160202); - } - - //LO calibration setting - RTPRINT(FINIT, INIT_IQK, ("LO calibration setting!\n")); - PHY_SetBBReg(pAdapter, rIQK_AGC_Rsp, bMaskDWord, 0x001028d1); - - //One shot, path A LOK & IQK - RTPRINT(FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); - PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - PHY_SetBBReg(pAdapter, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - // delay x ms - RTPRINT(FINIT, INIT_IQK, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME)); - PlatformStallExecution(IQK_DELAY_TIME*1000); - - // Check failed - regEAC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xeac = 0x%x\n", regEAC)); - regE94 = PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xe94 = 0x%x\n", regE94)); - regE9C= PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xe9c = 0x%x\n", regE9C)); - regEA4= PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xea4 = 0x%x\n", regEA4)); - - if(!(regEAC & BIT28) && - (((regE94 & 0x03FF0000)>>16) != 0x142) && - (((regE9C & 0x03FF0000)>>16) != 0x42) ) - result |= 0x01; - else //if Tx not OK, ignore Rx - return result; - - if(!(regEAC & BIT27) && //if Tx is OK, check whether Rx is OK - (((regEA4 & 0x03FF0000)>>16) != 0x132) && - (((regEAC & 0x03FF0000)>>16) != 0x36)) - result |= 0x02; - else - RTPRINT(FINIT, INIT_IQK, ("Path A Rx IQK fail!!\n")); - - return result; - - -} - -u1Byte //bit0 = 1 => Tx OK, bit1 = 1 => Rx OK -phy_PathB_IQK_8192C( - IN PADAPTER pAdapter - ) -{ - u4Byte regEAC, regEB4, regEBC, regEC4, regECC; - u1Byte result = 0x00; - RTPRINT(FINIT, INIT_IQK, ("Path B IQK!\n")); - - //One shot, path B LOK & IQK - RTPRINT(FINIT, INIT_IQK, ("One shot, path A LOK & IQK!\n")); - PHY_SetBBReg(pAdapter, rIQK_AGC_Cont, bMaskDWord, 0x00000002); - PHY_SetBBReg(pAdapter, rIQK_AGC_Cont, bMaskDWord, 0x00000000); - - // delay x ms - RTPRINT(FINIT, INIT_IQK, ("Delay %d ms for One shot, path B LOK & IQK.\n", IQK_DELAY_TIME)); - PlatformStallExecution(IQK_DELAY_TIME*1000); - - // Check failed - regEAC = PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xeac = 0x%x\n", regEAC)); - regEB4 = PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xeb4 = 0x%x\n", regEB4)); - regEBC= PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xebc = 0x%x\n", regEBC)); - regEC4= PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_B_2, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xec4 = 0x%x\n", regEC4)); - regECC= PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_B_2, bMaskDWord); - RTPRINT(FINIT, INIT_IQK, ("0xecc = 0x%x\n", regECC)); - - if(!(regEAC & BIT31) && - (((regEB4 & 0x03FF0000)>>16) != 0x142) && - (((regEBC & 0x03FF0000)>>16) != 0x42)) - result |= 0x01; - else - return result; - - if(!(regEAC & BIT30) && - (((regEC4 & 0x03FF0000)>>16) != 0x132) && - (((regECC & 0x03FF0000)>>16) != 0x36)) - result |= 0x02; - else - RTPRINT(FINIT, INIT_IQK, ("Path B Rx IQK fail!!\n")); - - - return result; - -} - -VOID -phy_PathAFillIQKMatrix( - IN PADAPTER pAdapter, - IN BOOLEAN bIQKOK, - IN s4Byte result[][8], - IN u1Byte final_candidate, - IN BOOLEAN bTxOnly - ) -{ - u4Byte Oldval_0, X, TX0_A, reg; - s4Byte Y, TX0_C; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - RTPRINT(FINIT, INIT_IQK, ("Path A IQ Calibration %s !\n",(bIQKOK)?"Success":"Failed")); - - if(final_candidate == 0xFF) - return; - - else if(bIQKOK) - { - Oldval_0 = (PHY_QueryBBReg(pAdapter, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - X = result[final_candidate][0]; - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - TX0_A = (X * Oldval_0) >> 8; - RTPRINT(FINIT, INIT_IQK, ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", X, TX0_A, Oldval_0)); - PHY_SetBBReg(pAdapter, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); - PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); - - Y = result[final_candidate][1]; - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - - //path B IQK result + 3 - if(pAdapter->interfaceIndex == 1 && pHalData->CurrentBandType == BAND_ON_5G) - Y += 3; - - TX0_C = (Y * Oldval_0) >> 8; - RTPRINT(FINIT, INIT_IQK, ("Y = 0x%x, TX = 0x%x\n", Y, TX0_C)); - PHY_SetBBReg(pAdapter, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); - PHY_SetBBReg(pAdapter, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); - PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); - - if(bTxOnly) - { - RTPRINT(FINIT, INIT_IQK, ("phy_PathAFillIQKMatrix only Tx OK\n")); - return; - } - - reg = result[final_candidate][2]; - PHY_SetBBReg(pAdapter, rOFDM0_XARxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][3] & 0x3F; - PHY_SetBBReg(pAdapter, rOFDM0_XARxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][3] >> 6) & 0xF; - PHY_SetBBReg(pAdapter, rOFDM0_RxIQExtAnta, 0xF0000000, reg); - } -} - -VOID -phy_PathBFillIQKMatrix( - IN PADAPTER pAdapter, - IN BOOLEAN bIQKOK, - IN s4Byte result[][8], - IN u1Byte final_candidate, - IN BOOLEAN bTxOnly //do Tx only - ) -{ - u4Byte Oldval_1, X, TX1_A, reg; - s4Byte Y, TX1_C; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - RTPRINT(FINIT, INIT_IQK, ("Path B IQ Calibration %s !\n",(bIQKOK)?"Success":"Failed")); - - if(final_candidate == 0xFF) - return; - - else if(bIQKOK) - { - Oldval_1 = (PHY_QueryBBReg(pAdapter, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - X = result[final_candidate][4]; - if ((X & 0x00000200) != 0) - X = X | 0xFFFFFC00; - TX1_A = (X * Oldval_1) >> 8; - RTPRINT(FINIT, INIT_IQK, ("X = 0x%x, TX1_A = 0x%x\n", X, TX1_A)); - PHY_SetBBReg(pAdapter, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); - PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); - - Y = result[final_candidate][5]; - if ((Y & 0x00000200) != 0) - Y = Y | 0xFFFFFC00; - if(pHalData->CurrentBandType == BAND_ON_5G) - Y += 3; //temp modify for preformance - TX1_C = (Y * Oldval_1) >> 8; - RTPRINT(FINIT, INIT_IQK, ("Y = 0x%x, TX1_C = 0x%x\n", Y, TX1_C)); - PHY_SetBBReg(pAdapter, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); - PHY_SetBBReg(pAdapter, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); - PHY_SetBBReg(pAdapter, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1)); - - if(bTxOnly) - return; - - reg = result[final_candidate][6]; - PHY_SetBBReg(pAdapter, rOFDM0_XBRxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][7] & 0x3F; - PHY_SetBBReg(pAdapter, rOFDM0_XBRxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][7] >> 6) & 0xF; - PHY_SetBBReg(pAdapter, rOFDM0_AGCRSSITable, 0x0000F000, reg); - } -} - - -BOOLEAN -phy_SimularityCompare_92C( - IN PADAPTER pAdapter, - IN s4Byte result[][8], - IN u1Byte c1, - IN u1Byte c2 - ) -{ - u4Byte i, j, diff, SimularityBitMap, bound = 0; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - u1Byte final_candidate[2] = {0xFF, 0xFF}; //for path A and path B - BOOLEAN bResult = TRUE, is2T = IS_92C_SERIAL( pHalData->VersionID); - - if(is2T) - bound = 8; - else - bound = 4; - - SimularityBitMap = 0; - - for( i = 0; i < bound; i++ ) - { - diff = (result[c1][i] > result[c2][i]) ? (result[c1][i] - result[c2][i]) : (result[c2][i] - result[c1][i]); - if (diff > MAX_TOLERANCE) - { - if((i == 2 || i == 6) && !SimularityBitMap) - { - if(result[c1][i]+result[c1][i+1] == 0) - final_candidate[(i/4)] = c2; - else if (result[c2][i]+result[c2][i+1] == 0) - final_candidate[(i/4)] = c1; - else - SimularityBitMap = SimularityBitMap|(1< do IQK again -*/ -BOOLEAN -phy_SimularityCompare( - IN PADAPTER pAdapter, - IN s4Byte result[][8], - IN u1Byte c1, - IN u1Byte c2 - ) -{ - return phy_SimularityCompare_92C(pAdapter, result, c1, c2); - -} - -VOID -phy_IQCalibrate_8192C( - IN PADAPTER pAdapter, - IN s4Byte result[][8], - IN u1Byte t, - IN BOOLEAN is2T - ) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - u4Byte i; - u1Byte PathAOK, PathBOK; - u4Byte ADDA_REG[IQK_ADDA_REG_NUM] = { - rFPGA0_XCD_SwitchControl, rBlue_Tooth, - rRx_Wait_CCA, rTx_CCK_RFON, - rTx_CCK_BBON, rTx_OFDM_RFON, - rTx_OFDM_BBON, rTx_To_Rx, - rTx_To_Tx, rRx_CCK, - rRx_OFDM, rRx_Wait_RIFS, - rRx_TO_Rx, rStandby, - rSleep, rPMPD_ANAEN }; - u4Byte IQK_MAC_REG[IQK_MAC_REG_NUM] = { - REG_TXPAUSE, REG_BCN_CTRL, - REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; - - //since 92C & 92D have the different define in IQK_BB_REG - u4Byte IQK_BB_REG_92C[IQK_BB_REG_NUM] = { - rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, - rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, - rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, - rFPGA0_XB_RFInterfaceOE, /*rFPGA0_RFMOD*/ rCCK0_AFESetting - }; - - u4Byte IQK_BB_REG_92D[IQK_BB_REG_NUM_92D] = { //for normal - rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, - rFPGA0_XB_RFInterfaceOE, rOFDM0_TRMuxPar, - rFPGA0_XCD_RFInterfaceSW, rOFDM0_TRxPathEnable, - /*rFPGA0_RFMOD*/ rCCK0_AFESetting, rFPGA0_AnalogParameter4, - rOFDM0_XAAGCCore1, rOFDM0_XBAGCCore1 - }; -#if MP_DRIVER - const u4Byte retryCount = 9; -#else - const u4Byte retryCount = 2; -#endif - //Neil Chen--2011--05--19-- - //3 Path Div - u1Byte rfPathSwitch=0x0; - - // Note: IQ calibration must be performed after loading - // PHY_REG.txt , and radio_a, radio_b.txt - - u4Byte bbvalue; - - if(t==0) - { - //bbvalue = PHY_QueryBBReg(pAdapter, rFPGA0_RFMOD, bMaskDWord); - // RTPRINT(FINIT, INIT_IQK, ("phy_IQCalibrate_8192C()==>0x%08x\n",bbvalue)); - - RTPRINT(FINIT, INIT_IQK, ("IQ Calibration for %s\n", (is2T ? "2T2R" : "1T1R"))); - - // Save ADDA parameters, turn Path A ADDA on - phy_SaveADDARegisters(pAdapter, ADDA_REG, pHalData->ADDA_backup, IQK_ADDA_REG_NUM); - phy_SaveMACRegisters(pAdapter, IQK_MAC_REG, pHalData->IQK_MAC_backup); - phy_SaveADDARegisters(pAdapter, IQK_BB_REG_92C, pHalData->IQK_BB_backup, IQK_BB_REG_NUM); - } - - phy_PathADDAOn(pAdapter, ADDA_REG, TRUE, is2T); - - if(t==0) - { - pHalData->bRfPiEnable = (u1Byte)PHY_QueryBBReg(pAdapter, rFPGA0_XA_HSSIParameter1, BIT(8)); - } - - if(!pHalData->bRfPiEnable){ - // Switch BB to PI mode to do IQ Calibration. - phy_PIModeSwitch(pAdapter, TRUE); - } - - //MAC settings - phy_MACSettingCalibration(pAdapter, IQK_MAC_REG, pHalData->IQK_MAC_backup); - - //PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, BIT24, 0x00); - PHY_SetBBReg(pAdapter, rCCK0_AFESetting, bMaskDWord, (0x0f000000 | (PHY_QueryBBReg(pAdapter, rCCK0_AFESetting, bMaskDWord))) ); - PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); - PHY_SetBBReg(pAdapter, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); - PHY_SetBBReg(pAdapter, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); - { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); - PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); - PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); - } - - if(is2T) - { - PHY_SetBBReg(pAdapter, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); - PHY_SetBBReg(pAdapter, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00010000); - } - - { - //Page B init - PHY_SetBBReg(pAdapter, rConfig_AntA, bMaskDWord, 0x00080000); - - if(is2T) - { - PHY_SetBBReg(pAdapter, rConfig_AntB, bMaskDWord, 0x00080000); - } - } - // IQ calibration setting - RTPRINT(FINIT, INIT_IQK, ("IQK setting!\n")); - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x808000); - PHY_SetBBReg(pAdapter, rTx_IQK, bMaskDWord, 0x01007c00); - PHY_SetBBReg(pAdapter, rRx_IQK, bMaskDWord, 0x01004800); - - for(i = 0 ; i < retryCount ; i++){ - PathAOK = phy_PathA_IQK_8192C(pAdapter, is2T); - if(PathAOK == 0x03){ - RTPRINT(FINIT, INIT_IQK, ("Path A IQK Success!!\n")); - result[t][0] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; - result[t][1] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; - result[t][2] = (PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - result[t][3] = (PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - break; - } - else if (i == (retryCount-1) && PathAOK == 0x01) //Tx IQK OK - { - RTPRINT(FINIT, INIT_IQK, ("Path A IQK Only Tx Success!!\n")); - - result[t][0] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; - result[t][1] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; - } - } - - if(0x00 == PathAOK){ - RTPRINT(FINIT, INIT_IQK, ("Path A IQK failed!!\n")); - } - - if(is2T){ - phy_PathAStandBy(pAdapter); - - // Turn Path B ADDA on - phy_PathADDAOn(pAdapter, ADDA_REG, FALSE, is2T); - - for(i = 0 ; i < retryCount ; i++){ - PathBOK = phy_PathB_IQK_8192C(pAdapter); - if(PathBOK == 0x03){ - RTPRINT(FINIT, INIT_IQK, ("Path B IQK Success!!\n")); - result[t][4] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][6] = (PHY_QueryBBReg(pAdapter, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; - result[t][7] = (PHY_QueryBBReg(pAdapter, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; - break; - } - else if (i == (retryCount - 1) && PathBOK == 0x01) //Tx IQK OK - { - RTPRINT(FINIT, INIT_IQK, ("Path B Only Tx IQK Success!!\n")); - result[t][4] = (PHY_QueryBBReg(pAdapter, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (PHY_QueryBBReg(pAdapter, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; - } - } - - if(0x00 == PathBOK){ - RTPRINT(FINIT, INIT_IQK, ("Path B IQK failed!!\n")); - } - } - - //Back to BB mode, load original value - RTPRINT(FINIT, INIT_IQK, ("IQK:Back to BB mode, load original value!\n")); - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0); - - if(t!=0) - { - if(!pHalData->bRfPiEnable){ - // Switch back BB to SI mode after finish IQ Calibration. - phy_PIModeSwitch(pAdapter, FALSE); - } - - // Reload ADDA power saving parameters - phy_ReloadADDARegisters(pAdapter, ADDA_REG, pHalData->ADDA_backup, IQK_ADDA_REG_NUM); - - // Reload MAC parameters - phy_ReloadMACRegisters(pAdapter, IQK_MAC_REG, pHalData->IQK_MAC_backup); - - // Reload BB parameters - phy_ReloadADDARegisters(pAdapter, IQK_BB_REG_92C, pHalData->IQK_BB_backup, IQK_BB_REG_NUM); - - /*Restore RX initial gain*/ - PHY_SetBBReg(pAdapter, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3); - if (is2T) - PHY_SetBBReg(pAdapter, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00032ed3); - //load 0xe30 IQC default value - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); - - } - RTPRINT(FINIT, INIT_IQK, ("phy_IQCalibrate_8192C() <==\n")); - -} - - -VOID -phy_LCCalibrate92C( - IN PADAPTER pAdapter, - IN BOOLEAN is2T - ) -{ - u1Byte tmpReg; - u4Byte RF_Amode=0, RF_Bmode=0, LC_Cal; -// HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - //Check continuous TX and Packet TX - tmpReg = PlatformEFIORead1Byte(pAdapter, 0xd03); - - if((tmpReg&0x70) != 0) //Deal with contisuous TX case - PlatformEFIOWrite1Byte(pAdapter, 0xd03, tmpReg&0x8F); //disable all continuous TX - else // Deal with Packet TX case - PlatformEFIOWrite1Byte(pAdapter, REG_TXPAUSE, 0xFF); // block all queues - - if((tmpReg&0x70) != 0) - { - //1. Read original RF mode - //Path-A - RF_Amode = PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_AC, bMask12Bits); - - //Path-B - if(is2T) - RF_Bmode = PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_AC, bMask12Bits); - - //2. Set RF mode = standby mode - //Path-A - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); - - //Path-B - if(is2T) - PHY_SetRFReg(pAdapter, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); - } - - //3. Read RF reg18 - LC_Cal = PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_CHNLBW, bMask12Bits); - - //4. Set LC calibration begin bit15 - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); - - delay_ms(100); - - - //Restore original situation - if((tmpReg&0x70) != 0) //Deal with contisuous TX case - { - //Path-A - PlatformEFIOWrite1Byte(pAdapter, 0xd03, tmpReg); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); - - //Path-B - if(is2T) - PHY_SetRFReg(pAdapter, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); - } - else // Deal with Packet TX case - { - PlatformEFIOWrite1Byte(pAdapter, REG_TXPAUSE, 0x00); - } -} - - -VOID -phy_LCCalibrate( - IN PADAPTER pAdapter, - IN BOOLEAN is2T - ) -{ - phy_LCCalibrate92C(pAdapter, is2T); -} - - - -//Analog Pre-distortion calibration -#define APK_BB_REG_NUM 8 -#define APK_CURVE_REG_NUM 4 -#define PATH_NUM 2 - -VOID -phy_APCalibrate_8192C( - IN PADAPTER pAdapter, - IN s1Byte delta, - IN BOOLEAN is2T - ) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - u4Byte regD[PATH_NUM]; - u4Byte tmpReg, index, offset, i, apkbound; - u1Byte path, pathbound = PATH_NUM; - u4Byte BB_backup[APK_BB_REG_NUM]; - u4Byte BB_REG[APK_BB_REG_NUM] = { - rFPGA1_TxBlock, rOFDM0_TRxPathEnable, - rFPGA0_RFMOD, rOFDM0_TRMuxPar, - rFPGA0_XCD_RFInterfaceSW, rFPGA0_XAB_RFInterfaceSW, - rFPGA0_XA_RFInterfaceOE, rFPGA0_XB_RFInterfaceOE }; - u4Byte BB_AP_MODE[APK_BB_REG_NUM] = { - 0x00000020, 0x00a05430, 0x02040000, - 0x000800e4, 0x00204000 }; - u4Byte BB_normal_AP_MODE[APK_BB_REG_NUM] = { - 0x00000020, 0x00a05430, 0x02040000, - 0x000800e4, 0x22204000 }; - - u4Byte AFE_backup[IQK_ADDA_REG_NUM]; - u4Byte AFE_REG[IQK_ADDA_REG_NUM] = { - rFPGA0_XCD_SwitchControl, rBlue_Tooth, - rRx_Wait_CCA, rTx_CCK_RFON, - rTx_CCK_BBON, rTx_OFDM_RFON, - rTx_OFDM_BBON, rTx_To_Rx, - rTx_To_Tx, rRx_CCK, - rRx_OFDM, rRx_Wait_RIFS, - rRx_TO_Rx, rStandby, - rSleep, rPMPD_ANAEN }; - - u4Byte MAC_backup[IQK_MAC_REG_NUM]; - u4Byte MAC_REG[IQK_MAC_REG_NUM] = { - REG_TXPAUSE, REG_BCN_CTRL, - REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; - - u4Byte APK_RF_init_value[PATH_NUM][APK_BB_REG_NUM] = { - {0x0852c, 0x1852c, 0x5852c, 0x1852c, 0x5852c}, - {0x2852e, 0x0852e, 0x3852e, 0x0852e, 0x0852e} - }; - - u4Byte APK_normal_RF_init_value[PATH_NUM][APK_BB_REG_NUM] = { - {0x0852c, 0x0a52c, 0x3a52c, 0x5a52c, 0x5a52c}, //path settings equal to path b settings - {0x0852c, 0x0a52c, 0x5a52c, 0x5a52c, 0x5a52c} - }; - - u4Byte APK_RF_value_0[PATH_NUM][APK_BB_REG_NUM] = { - {0x52019, 0x52014, 0x52013, 0x5200f, 0x5208d}, - {0x5201a, 0x52019, 0x52016, 0x52033, 0x52050} - }; - - u4Byte APK_normal_RF_value_0[PATH_NUM][APK_BB_REG_NUM] = { - {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a}, //path settings equal to path b settings - {0x52019, 0x52017, 0x52010, 0x5200d, 0x5206a} - }; -#if 0 - u4Byte APK_RF_value_A[PATH_NUM][APK_BB_REG_NUM] = { - {0x1adb0, 0x1adb0, 0x1ada0, 0x1ad90, 0x1ad80}, - {0x00fb0, 0x00fb0, 0x00fa0, 0x00f90, 0x00f80} - }; -#endif - u4Byte AFE_on_off[PATH_NUM] = { - 0x04db25a4, 0x0b1b25a4}; //path A on path B off / path A off path B on - - u4Byte APK_offset[PATH_NUM] = { - rConfig_AntA, rConfig_AntB}; - - u4Byte APK_normal_offset[PATH_NUM] = { - rConfig_Pmpd_AntA, rConfig_Pmpd_AntB}; - - u4Byte APK_value[PATH_NUM] = { - 0x92fc0000, 0x12fc0000}; - - u4Byte APK_normal_value[PATH_NUM] = { - 0x92680000, 0x12680000}; - - s1Byte APK_delta_mapping[APK_BB_REG_NUM][13] = { - {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, - {-4, -3, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, - {-6, -4, -2, -2, -1, -1, 0, 1, 2, 3, 4, 5, 6}, - {-1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6}, - {-11, -9, -7, -5, -3, -1, 0, 0, 0, 0, 0, 0, 0} - }; - - u4Byte APK_normal_setting_value_1[13] = { - 0x01017018, 0xf7ed8f84, 0x1b1a1816, 0x2522201e, 0x322e2b28, - 0x433f3a36, 0x5b544e49, 0x7b726a62, 0xa69a8f84, 0xdfcfc0b3, - 0x12680000, 0x00880000, 0x00880000 - }; - - u4Byte APK_normal_setting_value_2[16] = { - 0x01c7021d, 0x01670183, 0x01000123, 0x00bf00e2, 0x008d00a3, - 0x0068007b, 0x004d0059, 0x003a0042, 0x002b0031, 0x001f0025, - 0x0017001b, 0x00110014, 0x000c000f, 0x0009000b, 0x00070008, - 0x00050006 - }; - - u4Byte APK_result[PATH_NUM][APK_BB_REG_NUM]; //val_1_1a, val_1_2a, val_2a, val_3a, val_4a -// u4Byte AP_curve[PATH_NUM][APK_CURVE_REG_NUM]; - - s4Byte BB_offset, delta_V, delta_offset; - -#if MP_DRIVER == 1 - PMPT_CONTEXT pMptCtx = &(pAdapter->MptCtx); - - pMptCtx->APK_bound[0] = 45; - pMptCtx->APK_bound[1] = 52; -#endif - - RTPRINT(FINIT, INIT_IQK, ("==>phy_APCalibrate_8192C() delta %d\n", delta)); - RTPRINT(FINIT, INIT_IQK, ("AP Calibration for %s\n", (is2T ? "2T2R" : "1T1R"))); - if(!is2T) - pathbound = 1; - - //2 FOR NORMAL CHIP SETTINGS - -// Temporarily do not allow normal driver to do the following settings because these offset -// and value will cause RF internal PA to be unpredictably disabled by HW, such that RF Tx signal -// will disappear after disable/enable card many times on 88CU. RF SD and DD have not find the -// root cause, so we remove these actions temporarily. Added by tynli and SD3 Allen. 2010.05.31. -#if MP_DRIVER != 1 - return; -#endif - //settings adjust for normal chip - for(index = 0; index < PATH_NUM; index ++) - { - APK_offset[index] = APK_normal_offset[index]; - APK_value[index] = APK_normal_value[index]; - AFE_on_off[index] = 0x6fdb25a4; - } - - for(index = 0; index < APK_BB_REG_NUM; index ++) - { - for(path = 0; path < pathbound; path++) - { - APK_RF_init_value[path][index] = APK_normal_RF_init_value[path][index]; - APK_RF_value_0[path][index] = APK_normal_RF_value_0[path][index]; - } - BB_AP_MODE[index] = BB_normal_AP_MODE[index]; - } - - apkbound = 6; - - //save BB default value - for(index = 0; index < APK_BB_REG_NUM ; index++) - { - if(index == 0) //skip - continue; - BB_backup[index] = PHY_QueryBBReg(pAdapter, BB_REG[index], bMaskDWord); - } - - //save MAC default value - phy_SaveMACRegisters(pAdapter, MAC_REG, MAC_backup); - - //save AFE default value - phy_SaveADDARegisters(pAdapter, AFE_REG, AFE_backup, IQK_ADDA_REG_NUM); - - for(path = 0; path < pathbound; path++) - { - - - if(path == RF_PATH_A) - { - //path A APK - //load APK setting - //path-A - offset = rPdp_AntA; - for(index = 0; index < 11; index ++) - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_1[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - - PHY_SetBBReg(pAdapter, rConfig_Pmpd_AntB, bMaskDWord, 0x12680000); - - offset = rConfig_AntA; - for(; index < 13; index ++) - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_1[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - - //page-B1 - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x400000); - - //path A - offset = rPdp_AntA; - for(index = 0; index < 16; index++) - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_2[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0); - } - else if(path == RF_PATH_B) - { - //path B APK - //load APK setting - //path-B - offset = rPdp_AntB; - for(index = 0; index < 10; index ++) - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_1[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - PHY_SetBBReg(pAdapter, rConfig_Pmpd_AntA, bMaskDWord, 0x12680000); - - PHY_SetBBReg(pAdapter, rConfig_Pmpd_AntB, bMaskDWord, 0x12680000); - - offset = rConfig_AntA; - index = 11; - for(; index < 13; index ++) //offset 0xb68, 0xb6c - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_1[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - - //page-B1 - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x400000); - - //path B - offset = 0xb60; - for(index = 0; index < 16; index++) - { - PHY_SetBBReg(pAdapter, offset, bMaskDWord, APK_normal_setting_value_2[index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", offset, PHY_QueryBBReg(pAdapter, offset, bMaskDWord))); - - offset += 0x04; - } - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0); - } - - //save RF default value - regD[path] = PHY_QueryRFReg(pAdapter, path, RF_TXBIAS_A, bRFRegOffsetMask); - - //Path A AFE all on, path B AFE All off or vise versa - for(index = 0; index < IQK_ADDA_REG_NUM ; index++) - PHY_SetBBReg(pAdapter, AFE_REG[index], bMaskDWord, AFE_on_off[path]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0xe70 %x\n", PHY_QueryBBReg(pAdapter, rRx_Wait_CCA, bMaskDWord))); - - //BB to AP mode - if(path == 0) - { - for(index = 0; index < APK_BB_REG_NUM ; index++) - { - - if(index == 0) //skip - continue; - else if (index < 5) - PHY_SetBBReg(pAdapter, BB_REG[index], bMaskDWord, BB_AP_MODE[index]); - else if (BB_REG[index] == 0x870) - PHY_SetBBReg(pAdapter, BB_REG[index], bMaskDWord, BB_backup[index]|BIT10|BIT26); - else - PHY_SetBBReg(pAdapter, BB_REG[index], BIT10, 0x0); - } - - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); - } - else //path B - { - PHY_SetBBReg(pAdapter, rTx_IQK_Tone_B, bMaskDWord, 0x01008c00); - PHY_SetBBReg(pAdapter, rRx_IQK_Tone_B, bMaskDWord, 0x01008c00); - - } - - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x800 %x\n", PHY_QueryBBReg(pAdapter, 0x800, bMaskDWord))); - - //MAC settings - phy_MACSettingCalibration(pAdapter, MAC_REG, MAC_backup); - - if(path == RF_PATH_A) //Path B to standby mode - { - PHY_SetRFReg(pAdapter, RF_PATH_B, RF_AC, bRFRegOffsetMask, 0x10000); - } - else //Path A to standby mode - { - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_AC, bRFRegOffsetMask, 0x10000); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_MODE1, bRFRegOffsetMask, 0x1000f); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_MODE2, bRFRegOffsetMask, 0x20103); - } - - delta_offset = ((delta+14)/2); - if(delta_offset < 0) - delta_offset = 0; - else if (delta_offset > 12) - delta_offset = 12; - - //AP calibration - for(index = 0; index < APK_BB_REG_NUM; index++) - { - if(index != 1) //only DO PA11+PAD01001, AP RF setting - continue; - - tmpReg = APK_RF_init_value[path][index]; -#if 1 - if(!pHalData->bAPKThermalMeterIgnore) - { - BB_offset = (tmpReg & 0xF0000) >> 16; - - if(!(tmpReg & BIT15)) //sign bit 0 - { - BB_offset = -BB_offset; - } - - delta_V = APK_delta_mapping[index][delta_offset]; - - BB_offset += delta_V; - - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() APK index %d tmpReg 0x%x delta_V %d delta_offset %d\n", index, tmpReg, delta_V, delta_offset)); - - if(BB_offset < 0) - { - tmpReg = tmpReg & (~BIT15); - BB_offset = -BB_offset; - } - else - { - tmpReg = tmpReg | BIT15; - } - tmpReg = (tmpReg & 0xFFF0FFFF) | (BB_offset << 16); - } -#endif - -#if DEV_BUS_TYPE==RT_PCI_INTERFACE - if(IS_81xxC_VENDOR_UMC_B_CUT(pHalData->VersionID)) - PHY_SetRFReg(pAdapter, path, RF_IPA_A, bRFRegOffsetMask, 0x894ae); - else -#endif - PHY_SetRFReg(pAdapter, path, RF_IPA_A, bRFRegOffsetMask, 0x8992e); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0xc %x\n", PHY_QueryRFReg(pAdapter, path, RF_IPA_A, bRFRegOffsetMask))); - PHY_SetRFReg(pAdapter, path, RF_AC, bRFRegOffsetMask, APK_RF_value_0[path][index]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x0 %x\n", PHY_QueryRFReg(pAdapter, path, RF_AC, bRFRegOffsetMask))); - PHY_SetRFReg(pAdapter, path, RF_TXBIAS_A, bRFRegOffsetMask, tmpReg); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0xd %x\n", PHY_QueryRFReg(pAdapter, path, RF_TXBIAS_A, bRFRegOffsetMask))); - - // PA11+PAD01111, one shot - i = 0; - do - { - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0x800000); - { - PHY_SetBBReg(pAdapter, APK_offset[path], bMaskDWord, APK_value[0]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", APK_offset[path], PHY_QueryBBReg(pAdapter, APK_offset[path], bMaskDWord))); - delay_ms(3); - PHY_SetBBReg(pAdapter, APK_offset[path], bMaskDWord, APK_value[1]); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0x%x value 0x%x\n", APK_offset[path], PHY_QueryBBReg(pAdapter, APK_offset[path], bMaskDWord))); - - delay_ms(20); - } - PHY_SetBBReg(pAdapter, rFPGA0_IQK, 0xffffff00, 0); - - if(path == RF_PATH_A) - tmpReg = PHY_QueryBBReg(pAdapter, rAPK, 0x03E00000); - else - tmpReg = PHY_QueryBBReg(pAdapter, rAPK, 0xF8000000); - RTPRINT(FINIT, INIT_IQK, ("phy_APCalibrate_8192C() offset 0xbd8[25:21] %x\n", tmpReg)); - - - i++; - } - while(tmpReg > apkbound && i < 4); - - APK_result[path][index] = tmpReg; - } - } - - //reload MAC default value - phy_ReloadMACRegisters(pAdapter, MAC_REG, MAC_backup); - - //reload BB default value - for(index = 0; index < APK_BB_REG_NUM ; index++) - { - - if(index == 0) //skip - continue; - PHY_SetBBReg(pAdapter, BB_REG[index], bMaskDWord, BB_backup[index]); - } - - //reload AFE default value - phy_ReloadADDARegisters(pAdapter, AFE_REG, AFE_backup, IQK_ADDA_REG_NUM); - - //reload RF path default value - for(path = 0; path < pathbound; path++) - { - PHY_SetRFReg(pAdapter, path, RF_TXBIAS_A, bRFRegOffsetMask, regD[path]); - if(path == RF_PATH_B) - { - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_MODE1, bRFRegOffsetMask, 0x1000f); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_MODE2, bRFRegOffsetMask, 0x20101); - } - - //note no index == 0 - if (APK_result[path][1] > 6) - APK_result[path][1] = 6; - RTPRINT(FINIT, INIT_IQK, ("apk path %d result %d 0x%x \t", path, 1, APK_result[path][1])); - } - - RTPRINT(FINIT, INIT_IQK, ("\n")); - - - for(path = 0; path < pathbound; path++) - { - PHY_SetRFReg(pAdapter, path, RF_BS_PA_APSET_G1_G4, bRFRegOffsetMask, - ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (APK_result[path][1] << 5) | APK_result[path][1])); - if(path == RF_PATH_A) - PHY_SetRFReg(pAdapter, path, RF_BS_PA_APSET_G5_G8, bRFRegOffsetMask, - ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (0x00 << 5) | 0x05)); - else - PHY_SetRFReg(pAdapter, path, RF_BS_PA_APSET_G5_G8, bRFRegOffsetMask, - ((APK_result[path][1] << 15) | (APK_result[path][1] << 10) | (0x02 << 5) | 0x05)); - - PHY_SetRFReg(pAdapter, path, RF_BS_PA_APSET_G9_G11, bRFRegOffsetMask, ((0x08 << 15) | (0x08 << 10) | (0x08 << 5) | 0x08)); - } - - pHalData->bAPKdone = TRUE; - - RTPRINT(FINIT, INIT_IQK, ("<==phy_APCalibrate_8192C()\n")); -} - - -VOID -PHY_IQCalibrate_8192C( - IN PADAPTER pAdapter, - IN BOOLEAN bReCovery - ) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - s4Byte result[4][8]; //last is final result - u1Byte i, final_candidate, Indexforchannel; - BOOLEAN bPathAOK, bPathBOK; - s4Byte RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC, RegTmp = 0; - BOOLEAN is12simular, is13simular, is23simular; - BOOLEAN bStartContTx = FALSE, bSingleTone = FALSE, bCarrierSuppression = FALSE; - u4Byte IQK_BB_REG_92C[IQK_BB_REG_NUM] = { - rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, - rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, - rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, - rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, - rOFDM0_RxIQExtAnta}; - - if (ODM_CheckPowerStatus(pAdapter) == FALSE) - return; - -#if MP_DRIVER == 1 - bStartContTx = pAdapter->MptCtx.bStartContTx; - bSingleTone = pAdapter->MptCtx.bSingleTone; - bCarrierSuppression = pAdapter->MptCtx.bCarrierSuppression; -#endif - - //ignore IQK when continuous Tx - if(bStartContTx || bSingleTone || bCarrierSuppression) - return; - -#ifdef DISABLE_BB_RF - return; -#endif - if(pAdapter->bSlaveOfDMSP) - return; - - if (bReCovery) - { - phy_ReloadADDARegisters(pAdapter, IQK_BB_REG_92C, pHalData->IQK_BB_backup_recover, 9); - return; - - } - - RTPRINT(FINIT, INIT_IQK, ("IQK:Start!!!\n")); - - for(i = 0; i < 8; i++) - { - result[0][i] = 0; - result[1][i] = 0; - result[2][i] = 0; - result[3][i] = 0; - } - final_candidate = 0xff; - bPathAOK = FALSE; - bPathBOK = FALSE; - is12simular = FALSE; - is23simular = FALSE; - is13simular = FALSE; - - AcquireCCKAndRWPageAControl(pAdapter); - /*RT_TRACE(COMP_INIT,DBG_LOUD,("Acquire Mutex in IQCalibrate\n"));*/ - for (i=0; i<3; i++) - { - /*For 88C 1T1R*/ - phy_IQCalibrate_8192C(pAdapter, result, i, FALSE); - - if(i == 1) - { - is12simular = phy_SimularityCompare(pAdapter, result, 0, 1); - if(is12simular) - { - final_candidate = 0; - break; - } - } - - if(i == 2) - { - is13simular = phy_SimularityCompare(pAdapter, result, 0, 2); - if(is13simular) - { - final_candidate = 0; - break; - } - - is23simular = phy_SimularityCompare(pAdapter, result, 1, 2); - if(is23simular) - final_candidate = 1; - else - { - for(i = 0; i < 8; i++) - RegTmp += result[3][i]; - - if(RegTmp != 0) - final_candidate = 3; - else - final_candidate = 0xFF; - } - } - } -// RT_TRACE(COMP_INIT,DBG_LOUD,("Release Mutex in IQCalibrate \n")); - ReleaseCCKAndRWPageAControl(pAdapter); - - for (i=0; i<4; i++) - { - RegE94 = result[i][0]; - RegE9C = result[i][1]; - RegEA4 = result[i][2]; - RegEAC = result[i][3]; - RegEB4 = result[i][4]; - RegEBC = result[i][5]; - RegEC4 = result[i][6]; - RegECC = result[i][7]; - RTPRINT(FINIT, INIT_IQK, ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n ", RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); - } - - if(final_candidate != 0xff) - { - pHalData->RegE94 = RegE94 = result[final_candidate][0]; - pHalData->RegE9C = RegE9C = result[final_candidate][1]; - RegEA4 = result[final_candidate][2]; - RegEAC = result[final_candidate][3]; - pHalData->RegEB4 = RegEB4 = result[final_candidate][4]; - pHalData->RegEBC = RegEBC = result[final_candidate][5]; - RegEC4 = result[final_candidate][6]; - RegECC = result[final_candidate][7]; - RTPRINT(FINIT, INIT_IQK, ("IQK: final_candidate is %x\n",final_candidate)); - RTPRINT(FINIT, INIT_IQK, ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n ", RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); - bPathAOK = bPathBOK = TRUE; - } - else - { - RegE94 = RegEB4 = pHalData->RegE94 = pHalData->RegEB4 = 0x100; //X default value - RegE9C = RegEBC = pHalData->RegE9C = pHalData->RegEBC = 0x0; //Y default value - } - - if((RegE94 != 0)/*&&(RegEA4 != 0)*/) - { - if(pHalData->CurrentBandType == BAND_ON_5G) - phy_PathAFillIQKMatrix_5G_Normal(pAdapter, bPathAOK, result, final_candidate, (RegEA4 == 0)); - else - phy_PathAFillIQKMatrix(pAdapter, bPathAOK, result, final_candidate, (RegEA4 == 0)); - - } - - if (IS_92C_SERIAL(pHalData->VersionID) || IS_92D_SINGLEPHY(pHalData->VersionID)) - { - if((RegEB4 != 0)/*&&(RegEC4 != 0)*/) - { - if(pHalData->CurrentBandType == BAND_ON_5G) - phy_PathBFillIQKMatrix_5G_Normal(pAdapter, bPathBOK, result, final_candidate, (RegEC4 == 0)); - else - phy_PathBFillIQKMatrix(pAdapter, bPathBOK, result, final_candidate, (RegEC4 == 0)); - } - } - - phy_SaveADDARegisters(pAdapter, IQK_BB_REG_92C, pHalData->IQK_BB_backup_recover, 9); - -} - - -VOID -PHY_LCCalibrate_8192C( - IN PADAPTER pAdapter - ) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - BOOLEAN bStartContTx = FALSE, bSingleTone = FALSE, bCarrierSuppression = FALSE; - PMGNT_INFO pMgntInfo=&pAdapter->MgntInfo; - PMGNT_INFO pMgntInfoBuddyAdapter; - u4Byte timeout = 2000, timecount = 0; - PADAPTER BuddyAdapter = pAdapter->BuddyAdapter; - -#if MP_DRIVER == 1 - bStartContTx = pAdapter->MptCtx.bStartContTx; - bSingleTone = pAdapter->MptCtx.bSingleTone; - bCarrierSuppression = pAdapter->MptCtx.bCarrierSuppression; -#endif - -#ifdef DISABLE_BB_RF - return; -#endif - - //ignore LCK when continuous Tx - if(bStartContTx || bSingleTone || bCarrierSuppression) - return; - - if(BuddyAdapter != NULL && - ((pAdapter->interfaceIndex == 0 && pHalData->CurrentBandType == BAND_ON_2_4G) || - (pAdapter->interfaceIndex == 1 && pHalData->CurrentBandType == BAND_ON_5G))) - { - pMgntInfoBuddyAdapter=&BuddyAdapter->MgntInfo; - while(pMgntInfoBuddyAdapter->bScanInProgress && timecount < timeout) - { - delay_ms(50); - timecount += 50; - } - } - - while(pMgntInfo->bScanInProgress && timecount < timeout) - { - delay_ms(50); - timecount += 50; - } - - pHalData->bLCKInProgress = TRUE; - - RTPRINT(FINIT, INIT_IQK, ("LCK:Start!!!interface %d currentband %x delay %d ms\n", pAdapter->interfaceIndex, pHalData->CurrentBandType, timecount)); - - //if(IS_92C_SERIAL(pHalData->VersionID) || IS_92D_SINGLEPHY(pHalData->VersionID)) - if(IS_2T2R(pHalData->VersionID)) - { - phy_LCCalibrate(pAdapter, TRUE); - } - else{ - // For 88C 1T1R - phy_LCCalibrate(pAdapter, FALSE); - } - - pHalData->bLCKInProgress = FALSE; - - RTPRINT(FINIT, INIT_IQK, ("LCK:Finish!!!interface %d\n", pAdapter->interfaceIndex)); - - -} - -VOID -PHY_APCalibrate_8192C( - IN PADAPTER pAdapter, - IN s1Byte delta - ) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); - - //default disable APK, because Tx NG issue, suggest by Jenyu, 2011.11.25 - return; - -#ifdef DISABLE_BB_RF - return; -#endif - -#if FOR_BRAZIL_PRETEST != 1 - if(pHalData->bAPKdone) -#endif - return; - - if(IS_92C_SERIAL( pHalData->VersionID)){ - phy_APCalibrate_8192C(pAdapter, delta, TRUE); - } - else{ - // For 88C 1T1R - phy_APCalibrate_8192C(pAdapter, delta, FALSE); - } -} - - -#endif - - -//3============================================================ -//3 IQ Calibration -//3============================================================ - -VOID -ODM_ResetIQKResult( - IN PVOID pDM_VOID -) -{ - return; -} -#if 1//!(DM_ODM_SUPPORT_TYPE & ODM_AP) -u1Byte ODM_GetRightChnlPlaceforIQK(u1Byte chnl) -{ - u1Byte channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = - {1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,149,151,153,155,157,159,161,163,165}; - u1Byte place = chnl; - - - if(chnl > 14) - { - for(place = 14; placeAdapter; - -#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - if (*pDM_Odm->pIsFcsModeEnable) - return; -#endif - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - if (!IS_HARDWARE_TYPE_JAGUAR(Adapter)) - return; -#if (DM_ODM_SUPPORT_TYPE & (ODM_CE)) - else if (IS_HARDWARE_TYPE_8812AU(Adapter)) - return; -#endif -#endif - -#if (RTL8821A_SUPPORT == 1) - if (pDM_Odm->bLinked) { - if ((*pDM_Odm->pChannel != pDM_Odm->preChannel) && (!*pDM_Odm->pbScanInProcess)) { - pDM_Odm->preChannel = *pDM_Odm->pChannel; - pDM_Odm->LinkedInterval = 0; - } - - if (pDM_Odm->LinkedInterval < 3) - pDM_Odm->LinkedInterval++; - - if (pDM_Odm->LinkedInterval == 2) { - /*Mark out IQK flow to prevent tx stuck. by Maddest 20130306*/ - /*Open it verified by James 20130715*/ -#if (DM_ODM_SUPPORT_TYPE == ODM_CE) - PHY_IQCalibrate_8821A(pDM_Odm, FALSE); -#elif (DM_ODM_SUPPORT_TYPE == ODM_WIN) - PHY_IQCalibrate(Adapter, FALSE); -#else - PHY_IQCalibrate_8821A(Adapter, FALSE); -#endif - } - } else - pDM_Odm->LinkedInterval = 0; -#endif -} - -void phydm_rf_init(IN PVOID pDM_VOID) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - odm_TXPowerTrackingInit(pDM_Odm); - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - ODM_ClearTxPowerTrackingState(pDM_Odm); -#endif - -#if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) -#if (RTL8814A_SUPPORT == 1) - if (pDM_Odm->SupportICType & ODM_RTL8814A) - PHY_IQCalibrate_8814A_Init(pDM_Odm); -#endif -#endif - -} - -void phydm_rf_watchdog(IN PVOID pDM_VOID) -{ - PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - ODM_TXPowerTrackingCheck(pDM_Odm); - if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) - odm_IQCalibrate(pDM_Odm); -#endif -} diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.h deleted file mode 100644 index 4cacdb54a..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ap.h +++ /dev/null @@ -1,162 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - #ifndef __HAL_PHY_RF_H__ - #define __HAL_PHY_RF_H__ - -#include "phydm_powertracking_ap.h" -#if (RTL8814A_SUPPORT == 1) -#include "rtl8814a/phydm_iqk_8814a.h" -#endif - -#if (RTL8822B_SUPPORT == 1) -#include "rtl8822b/phydm_iqk_8822b.h" -#endif - - -typedef enum _PWRTRACK_CONTROL_METHOD { - BBSWING, - TXAGC, - MIX_MODE, - TSSI_MODE -} PWRTRACK_METHOD; - -typedef VOID (*FuncSetPwr)(PVOID, PWRTRACK_METHOD, u1Byte, u1Byte); -typedef VOID(*FuncIQK)(PVOID, u1Byte, u1Byte, u1Byte); -typedef VOID (*FuncLCK)(PVOID); - //refine by YuChen for 8814A -typedef VOID (*FuncSwing)(PVOID, pu1Byte*, pu1Byte*, pu1Byte*, pu1Byte*); -typedef VOID (*FuncSwing8814only)(PVOID, pu1Byte*, pu1Byte*, pu1Byte*, pu1Byte*); - -typedef struct _TXPWRTRACK_CFG { - u1Byte SwingTableSize_CCK; - u1Byte SwingTableSize_OFDM; - u1Byte Threshold_IQK; - u1Byte Threshold_DPK; - u1Byte AverageThermalNum; - u1Byte RfPathCount; - u4Byte ThermalRegAddr; - FuncSetPwr ODM_TxPwrTrackSetPwr; - FuncIQK DoIQK; - FuncLCK PHY_LCCalibrate; - FuncSwing GetDeltaSwingTable; - FuncSwing8814only GetDeltaSwingTable8814only; -} TXPWRTRACK_CFG, *PTXPWRTRACK_CFG; - -VOID -ConfigureTxpowerTrack( - IN PVOID pDM_VOID, - OUT PTXPWRTRACK_CFG pConfig - ); - - -VOID -ODM_TXPowerTrackingCallback_ThermalMeter( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ); - -#if (RTL8192E_SUPPORT==1) -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_92E( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ); -#endif - -#if (RTL8814A_SUPPORT == 1) -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries2( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ); - -#elif ODM_IC_11AC_SERIES_SUPPORT -VOID -ODM_TXPowerTrackingCallback_ThermalMeter_JaguarSeries( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PVOID pDM_VOID -#else - IN PADAPTER Adapter -#endif - ); -#endif - -#define IS_CCK_RATE(_rate) (ODM_MGN_1M == _rate || _rate == ODM_MGN_2M || _rate == ODM_MGN_5_5M || _rate == ODM_MGN_11M ) - - -#if(DM_ODM_SUPPORT_TYPE & ODM_WIN) -#define MAX_TOLERANCE 5 -#define IQK_DELAY_TIME 1 //ms - - // -// BB/MAC/RF other monitor API -// - -void PHY_SetMonitorMode8192C(IN PADAPTER pAdapter, - IN BOOLEAN bEnableMonitorMode ); - -// -// IQ calibrate -// -void -PHY_IQCalibrate_8192C( IN PADAPTER pAdapter, - IN BOOLEAN bReCovery); - -// -// LC calibrate -// -void -PHY_LCCalibrate_8192C( IN PADAPTER pAdapter); - -// -// AP calibrate -// -void -PHY_APCalibrate_8192C( IN PADAPTER pAdapter, - IN s1Byte delta); -#endif - -#define ODM_TARGET_CHNL_NUM_2G_5G 59 - - -VOID -ODM_ResetIQKResult( - IN PVOID pDM_VOID -); -u1Byte -ODM_GetRightChnlPlaceforIQK( - IN u1Byte chnl -); - -void phydm_rf_init(IN PVOID pDM_VOID); -void phydm_rf_watchdog(IN PVOID pDM_VOID); - -#endif // #ifndef __HAL_PHY_RF_H__ - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ce.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ce.c index 8afa89706..fcae9b5f4 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ce.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_ce.c @@ -188,18 +188,6 @@ ODM_TXPowerTrackingCallback_ThermalMeter( pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; //cosa add for debug pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = TRUE; -#if (MP_DRIVER == 1) -#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = pHalData->TxPowerTrackControl; // We should keep updating the control variable according to HalData. -#endif - -#if (DM_ODM_SUPPORT_TYPE == ODM_CE) - if (pDM_Odm->mp_mode == TRUE) -#endif - // RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. - pDM_Odm->RFCalibrateInfo.RegA24 = 0x090e1317; -#endif - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("===>ODM_TXPowerTrackingCallback_ThermalMeter Start\n pRFCalibrateInfo->BbSwingIdxCckBase: %d, pRFCalibrateInfo->BbSwingIdxOfdmBase[A]: %d, pRFCalibrateInfo->DefaultOfdmIndex: %d\n", pRFCalibrateInfo->BbSwingIdxCckBase, pRFCalibrateInfo->BbSwingIdxOfdmBase[ODM_RF_PATH_A], pRFCalibrateInfo->DefaultOfdmIndex)); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.c deleted file mode 100644 index 41087bf36..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.c +++ /dev/null @@ -1,716 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - #include "mp_precomp.h" - #include "phydm_precomp.h" - -//#if(DM_ODM_SUPPORT_TYPE & ODM_WIN) - -#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \ - do {\ - for(_offset = 0; _offset < _size; _offset++)\ - {\ - if(_deltaThermal < thermalThreshold[_direction][_offset])\ - {\ - if(_offset != 0)\ - _offset--;\ - break;\ - }\ - } \ - if(_offset >= _size)\ - _offset = _size-1;\ - } while(0) - - -void ConfigureTxpowerTrack( - IN PDM_ODM_T pDM_Odm, - OUT PTXPWRTRACK_CFG pConfig - ) -{ -#if RTL8192E_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8192E) - ConfigureTxpowerTrack_8192E(pConfig); -#endif -#if RTL8821A_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8821) - ConfigureTxpowerTrack_8821A(pConfig); -#endif -#if RTL8812A_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8812) - ConfigureTxpowerTrack_8812A(pConfig); -#endif -#if RTL8188E_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8188E) - ConfigureTxpowerTrack_8188E(pConfig); -#endif - -#if RTL8188F_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8188F) - ConfigureTxpowerTrack_8188F(pConfig); -#endif - -#if RTL8723B_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8723B) - ConfigureTxpowerTrack_8723B(pConfig); -#endif - -#if RTL8814A_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8814A) - ConfigureTxpowerTrack_8814A(pConfig); -#endif - -#if RTL8821B_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8821B) - ConfigureTxpowerTrack_8821B(pConfig); -#endif - -#if RTL8703B_SUPPORT - if(pDM_Odm->SupportICType==ODM_RTL8703B) - ConfigureTxpowerTrack_8703B(pConfig); -#endif - -} - -//====================================================================== -// <20121113, Kordan> This function should be called when TxAGC changed. -// Otherwise the previous compensation is gone, because we record the -// delta of temperature between two TxPowerTracking watch dogs. -// -// NOTE: If Tx BB swing or Tx scaling is varified during run-time, still -// need to call this function. -//====================================================================== -VOID -ODM_ClearTxPowerTrackingState( - IN PDM_ODM_T pDM_Odm - ) -{ - PHAL_DATA_TYPE pHalData = GET_HAL_DATA(pDM_Odm->Adapter); - u1Byte p = 0; - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - pRFCalibrateInfo->BbSwingIdxCckBase = pRFCalibrateInfo->DefaultCckIndex; - pRFCalibrateInfo->BbSwingIdxCck = pRFCalibrateInfo->DefaultCckIndex; - pRFCalibrateInfo->CCK_index = 0; - - for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) - { - pRFCalibrateInfo->BbSwingIdxOfdmBase[p] = pRFCalibrateInfo->DefaultOfdmIndex; - pRFCalibrateInfo->BbSwingIdxOfdm[p] = pRFCalibrateInfo->DefaultOfdmIndex; - pRFCalibrateInfo->OFDM_index[p] = pRFCalibrateInfo->DefaultOfdmIndex; - - pRFCalibrateInfo->PowerIndexOffset[p] = 0; - pRFCalibrateInfo->DeltaPowerIndex[p] = 0; - pRFCalibrateInfo->DeltaPowerIndexLast[p] = 0; - - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = 0; // Initial Mix mode power tracking - pRFCalibrateInfo->Remnant_OFDMSwingIdx[p] = 0; - pRFCalibrateInfo->KfreeOffset[p] = 0; - } - - pRFCalibrateInfo->Modify_TxAGC_Flag_PathA= FALSE; //Initial at Modify Tx Scaling Mode - pRFCalibrateInfo->Modify_TxAGC_Flag_PathB= FALSE; //Initial at Modify Tx Scaling Mode - pRFCalibrateInfo->Modify_TxAGC_Flag_PathC= FALSE; //Initial at Modify Tx Scaling Mode - pRFCalibrateInfo->Modify_TxAGC_Flag_PathD= FALSE; //Initial at Modify Tx Scaling Mode - pRFCalibrateInfo->Remnant_CCKSwingIdx= 0; - pRFCalibrateInfo->ThermalValue = pHalData->EEPROMThermalMeter; - - pRFCalibrateInfo->Modify_TxAGC_Value_CCK=0; //modify by Mingzhi.Guo - pRFCalibrateInfo->Modify_TxAGC_Value_OFDM=0; //modify by Mingzhi.Guo - -} - -VOID -ODM_TXPowerTrackingCallback_ThermalMeter( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PDM_ODM_T pDM_Odm -#else - IN PADAPTER Adapter -#endif - ) -{ - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); - PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc; -#elif (DM_ODM_SUPPORT_TYPE == ODM_WIN) - PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc; -#else - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -#endif - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - u1Byte ThermalValue = 0, delta, delta_LCK, delta_IQK, p = 0, i = 0, pathName = 0; - s1Byte diff_DPK[4] = {0}; - u1Byte ThermalValue_AVG_count = 0; - u4Byte ThermalValue_AVG = 0; - - u1Byte OFDM_min_index = 0; // OFDM BB Swing should be less than +3.0dB, which is required by Arthur - u1Byte Indexforchannel = 0; // GetRightChnlPlaceforIQK(pHalData->CurrentChannel) - BOOLEAN bTSSIenable = FALSE; - - TXPWRTRACK_CFG c; - - //4 1. The following TWO tables decide the final index of OFDM/CCK swing table. - pu1Byte deltaSwingTableIdx_TUP_A, deltaSwingTableIdx_TDOWN_A; - pu1Byte deltaSwingTableIdx_TUP_B, deltaSwingTableIdx_TDOWN_B; - //for 8814 add by Yu Chen - pu1Byte deltaSwingTableIdx_TUP_C = NULL, deltaSwingTableIdx_TDOWN_C = NULL; - pu1Byte deltaSwingTableIdx_TUP_D= NULL, deltaSwingTableIdx_TDOWN_D = NULL; - - //4 2. Initilization ( 7 steps in total ) - - ConfigureTxpowerTrack(pDM_Odm, &c); - - (*c.GetDeltaSwingTable)(pDM_Odm, (pu1Byte*)&deltaSwingTableIdx_TUP_A, (pu1Byte*)&deltaSwingTableIdx_TDOWN_A, - (pu1Byte*)&deltaSwingTableIdx_TUP_B, (pu1Byte*)&deltaSwingTableIdx_TDOWN_B); - - if(pDM_Odm->SupportICType & ODM_RTL8814A) // for 8814 path C & D - (*c.GetDeltaSwingTable8814only)(pDM_Odm, (pu1Byte*)&deltaSwingTableIdx_TUP_C, (pu1Byte*)&deltaSwingTableIdx_TDOWN_C, - (pu1Byte*)&deltaSwingTableIdx_TUP_D, (pu1Byte*)&deltaSwingTableIdx_TDOWN_D); - - - pRFCalibrateInfo->TXPowerTrackingCallbackCnt++; //cosa add for debug - pRFCalibrateInfo->bTXPowerTrackingInit = TRUE; - -#if (MP_DRIVER == 1) - /*pRFCalibrateInfo->TxPowerTrackControl = pHalData->TxPowerTrackControl; - We should keep updating the control variable according to HalData. - RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */ - pRFCalibrateInfo->RegA24 = 0x090e1317; -#endif - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("===>ODM_TXPowerTrackingCallback_ThermalMeter, \ - \n pRFCalibrateInfo->BbSwingIdxCckBase: %d, pRFCalibrateInfo->BbSwingIdxOfdmBase[A]: %d, pRFCalibrateInfo->DefaultOfdmIndex: %d\n", - pRFCalibrateInfo->BbSwingIdxCckBase, pRFCalibrateInfo->BbSwingIdxOfdmBase[ODM_RF_PATH_A], pRFCalibrateInfo->DefaultOfdmIndex)); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("pRFCalibrateInfo->TxPowerTrackControl %d, pHalData->EEPROMThermalMeter %d\n", pRFCalibrateInfo->TxPowerTrackControl, pHalData->EEPROMThermalMeter)); - ThermalValue = (u1Byte)ODM_GetRFReg(pDM_Odm, ODM_RF_PATH_A, c.ThermalRegAddr, 0xfc00); //0x42: RF Reg[15:10] 88E - - - if( ! pRFCalibrateInfo->TxPowerTrackControl ) - return; - - - //4 3. Initialize ThermalValues of RFCalibrateInfo - - if(pRFCalibrateInfo->bReloadtxpowerindex) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("reload ofdm index for band switch\n")); - } - - //4 4. Calculate average thermal meter - - pRFCalibrateInfo->ThermalValue_AVG[pRFCalibrateInfo->ThermalValue_AVG_index] = ThermalValue; - pRFCalibrateInfo->ThermalValue_AVG_index++; - if(pRFCalibrateInfo->ThermalValue_AVG_index == c.AverageThermalNum) //Average times = c.AverageThermalNum - pRFCalibrateInfo->ThermalValue_AVG_index = 0; - - for(i = 0; i < c.AverageThermalNum; i++) - { - if(pRFCalibrateInfo->ThermalValue_AVG[i]) - { - ThermalValue_AVG += pRFCalibrateInfo->ThermalValue_AVG[i]; - ThermalValue_AVG_count++; - } - } - - if(ThermalValue_AVG_count) //Calculate Average ThermalValue after average enough times - { - ThermalValue = (u1Byte)(ThermalValue_AVG / ThermalValue_AVG_count); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("AVG Thermal Meter = 0x%X, EFUSE Thermal Base = 0x%X\n", ThermalValue, pHalData->EEPROMThermalMeter)); - } - - //4 5. Calculate delta, delta_LCK, delta_IQK. - - //"delta" here is used to determine whether thermal value changes or not. - delta = (ThermalValue > pRFCalibrateInfo->ThermalValue)?(ThermalValue - pRFCalibrateInfo->ThermalValue):(pRFCalibrateInfo->ThermalValue - ThermalValue); - delta_LCK = (ThermalValue > pRFCalibrateInfo->ThermalValue_LCK)?(ThermalValue - pRFCalibrateInfo->ThermalValue_LCK):(pRFCalibrateInfo->ThermalValue_LCK - ThermalValue); - delta_IQK = (ThermalValue > pRFCalibrateInfo->ThermalValue_IQK)?(ThermalValue - pRFCalibrateInfo->ThermalValue_IQK):(pRFCalibrateInfo->ThermalValue_IQK - ThermalValue); - - if(pRFCalibrateInfo->ThermalValue_IQK == 0xff) //no PG, use thermal value for IQK - { - pRFCalibrateInfo->ThermalValue_IQK = ThermalValue; - delta_IQK = (ThermalValue > pRFCalibrateInfo->ThermalValue_IQK)?(ThermalValue - pRFCalibrateInfo->ThermalValue_IQK):(pRFCalibrateInfo->ThermalValue_IQK - ThermalValue); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("no PG, use ThermalValue for IQK\n")); - } - - for(p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - diff_DPK[p] = (s1Byte)ThermalValue - (s1Byte)pRFCalibrateInfo->DpkThermal[p]; - } - - //4 6. If necessary, do LCK. - - if (!(pDM_Odm->SupportICType & ODM_RTL8821)) { - /*no PG , do LCK at initial status*/ - if (pRFCalibrateInfo->ThermalValue_LCK == 0xff) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("no PG, do LCK\n")); - pRFCalibrateInfo->ThermalValue_LCK = ThermalValue; - if(c.PHY_LCCalibrate) - (*c.PHY_LCCalibrate)(pDM_Odm); - delta_LCK = (ThermalValue > pRFCalibrateInfo->ThermalValue_LCK)?(ThermalValue - pRFCalibrateInfo->ThermalValue_LCK):(pRFCalibrateInfo->ThermalValue_LCK - ThermalValue); - } - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("(delta, delta_LCK, delta_IQK) = (%d, %d, %d)\n", delta, delta_LCK, delta_IQK)); - - /* Delta temperature is equal to or larger than 20 centigrade.*/ - if (delta_LCK >= c.Threshold_IQK) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("delta_LCK(%d) >= Threshold_IQK(%d)\n", delta_LCK, c.Threshold_IQK)); - pRFCalibrateInfo->ThermalValue_LCK = ThermalValue; - if(c.PHY_LCCalibrate) - (*c.PHY_LCCalibrate)(pDM_Odm); - } - } - - //3 7. If necessary, move the index of swing table to adjust Tx power. - - if (delta > 0 && pRFCalibrateInfo->TxPowerTrackControl) - { - //"delta" here is used to record the absolute value of differrence. -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - delta = ThermalValue > pHalData->EEPROMThermalMeter?(ThermalValue - pHalData->EEPROMThermalMeter):(pHalData->EEPROMThermalMeter - ThermalValue); -#else - delta = (ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther)?(ThermalValue - pDM_Odm->priv->pmib->dot11RFEntry.ther):(pDM_Odm->priv->pmib->dot11RFEntry.ther - ThermalValue); -#endif - if (delta >= TXPWR_TRACK_TABLE_SIZE) - delta = TXPWR_TRACK_TABLE_SIZE - 1; - - //4 7.1 The Final Power Index = BaseIndex + PowerIndexOffset - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - if(ThermalValue > pHalData->EEPROMThermalMeter) { -#else - if(ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther) { -#endif - - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - pRFCalibrateInfo->DeltaPowerIndexLast[p] = pRFCalibrateInfo->DeltaPowerIndex[p]; //recording poer index offset - switch(p) - { - case ODM_RF_PATH_B: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_B[%d] = %d\n", delta, deltaSwingTableIdx_TUP_B[delta])); - - pRFCalibrateInfo->DeltaPowerIndex[p] = deltaSwingTableIdx_TUP_B[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_B[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_C: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_C[%d] = %d\n", delta, deltaSwingTableIdx_TUP_C[delta])); - - pRFCalibrateInfo->DeltaPowerIndex[p] = deltaSwingTableIdx_TUP_C[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_C[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_C] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_D: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_D[%d] = %d\n", delta, deltaSwingTableIdx_TUP_D[delta])); - - pRFCalibrateInfo->DeltaPowerIndex[p] = deltaSwingTableIdx_TUP_D[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_D[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_D] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - default: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TUP_A[%d] = %d\n", delta, deltaSwingTableIdx_TUP_A[delta])); - - pRFCalibrateInfo->DeltaPowerIndex[p] = deltaSwingTableIdx_TUP_A[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = deltaSwingTableIdx_TUP_A[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is higher and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - } - - } - - } - else { - - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - pRFCalibrateInfo->DeltaPowerIndexLast[p] = pRFCalibrateInfo->DeltaPowerIndex[p]; //recording poer index offset - switch(p) - { - case ODM_RF_PATH_B: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_B[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_B[delta])); - pRFCalibrateInfo->DeltaPowerIndex[p] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_C: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_C[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_C[delta])); - pRFCalibrateInfo->DeltaPowerIndex[p] = -1 * deltaSwingTableIdx_TDOWN_C[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_C[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_C] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - case ODM_RF_PATH_D: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_D[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_D[delta])); - pRFCalibrateInfo->DeltaPowerIndex[p] = -1 * deltaSwingTableIdx_TDOWN_D[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_D[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_D] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - - default: - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("deltaSwingTableIdx_TDOWN_A[%d] = %d\n", delta, deltaSwingTableIdx_TDOWN_A[delta])); - pRFCalibrateInfo->DeltaPowerIndex[p] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; - pRFCalibrateInfo->Absolute_OFDMSwingIdx[p] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; // Record delta swing for mix mode power tracking - ODM_RT_TRACE(pDM_Odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("******Temp is lower and pRFCalibrateInfo->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = %d\n", pRFCalibrateInfo->Absolute_OFDMSwingIdx[p])); - break; - } - - } - - } - - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("\n\n=========================== [Path-%d] Calculating PowerIndexOffset===========================\n", p)); - - if(pRFCalibrateInfo->DeltaPowerIndex[p] == pRFCalibrateInfo->DeltaPowerIndexLast[p]) // If Thermal value changes but lookup table value still the same - pRFCalibrateInfo->PowerIndexOffset[p] = 0; - else - pRFCalibrateInfo->PowerIndexOffset[p] = pRFCalibrateInfo->DeltaPowerIndex[p] - pRFCalibrateInfo->DeltaPowerIndexLast[p]; // Power Index Diff between 2 times Power Tracking - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("[Path-%d] PowerIndexOffset(%d) = DeltaPowerIndex(%d) - DeltaPowerIndexLast(%d)\n", p, pRFCalibrateInfo->PowerIndexOffset[p], pRFCalibrateInfo->DeltaPowerIndex[p], pRFCalibrateInfo->DeltaPowerIndexLast[p])); - - pRFCalibrateInfo->OFDM_index[p] = pRFCalibrateInfo->BbSwingIdxOfdmBase[p] + pRFCalibrateInfo->PowerIndexOffset[p]; - pRFCalibrateInfo->CCK_index = pRFCalibrateInfo->BbSwingIdxCckBase + pRFCalibrateInfo->PowerIndexOffset[p]; - - pRFCalibrateInfo->BbSwingIdxCck = pRFCalibrateInfo->CCK_index; - pRFCalibrateInfo->BbSwingIdxOfdm[p] = pRFCalibrateInfo->OFDM_index[p]; - - // *************Print BB Swing Base and Index Offset************* - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("The 'CCK' final index(%d) = BaseIndex(%d) + PowerIndexOffset(%d)\n", pRFCalibrateInfo->BbSwingIdxCck, pRFCalibrateInfo->BbSwingIdxCckBase, pRFCalibrateInfo->PowerIndexOffset[p])); - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("The 'OFDM' final index(%d) = BaseIndex[%d](%d) + PowerIndexOffset(%d)\n", pRFCalibrateInfo->BbSwingIdxOfdm[p], p, pRFCalibrateInfo->BbSwingIdxOfdmBase[p], pRFCalibrateInfo->PowerIndexOffset[p])); - - //4 7.1 Handle boundary conditions of index. - - if(pRFCalibrateInfo->OFDM_index[p] > c.SwingTableSize_OFDM-1) - { - pRFCalibrateInfo->OFDM_index[p] = c.SwingTableSize_OFDM-1; - } - else if (pRFCalibrateInfo->OFDM_index[p] <= OFDM_min_index) - { - pRFCalibrateInfo->OFDM_index[p] = OFDM_min_index; - } - } - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("\n\n========================================================================================================\n")); - if(pRFCalibrateInfo->CCK_index > c.SwingTableSize_CCK-1) - pRFCalibrateInfo->CCK_index = c.SwingTableSize_CCK-1; - else if (pRFCalibrateInfo->CCK_index <= 0) - pRFCalibrateInfo->CCK_index = 0; - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("The thermal meter is unchanged or TxPowerTracking OFF(%d): ThermalValue: %d , pRFCalibrateInfo->ThermalValue: %d\n", - pRFCalibrateInfo->TxPowerTrackControl, ThermalValue, pRFCalibrateInfo->ThermalValue)); - - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - pRFCalibrateInfo->PowerIndexOffset[p] = 0; - } - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("TxPowerTracking: [CCK] Swing Current Index: %d, Swing Base Index: %d\n", - pRFCalibrateInfo->CCK_index, pRFCalibrateInfo->BbSwingIdxCckBase)); //Print Swing base & current - - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("TxPowerTracking: [OFDM] Swing Current Index: %d, Swing Base Index[%d]: %d\n", - pRFCalibrateInfo->OFDM_index[p], p, pRFCalibrateInfo->BbSwingIdxOfdmBase[p])); - } - - if ((pRFCalibrateInfo->PowerIndexOffset[ODM_RF_PATH_A] != 0 || - pRFCalibrateInfo->PowerIndexOffset[ODM_RF_PATH_B] != 0 || - pRFCalibrateInfo->PowerIndexOffset[ODM_RF_PATH_C] != 0 || - pRFCalibrateInfo->PowerIndexOffset[ODM_RF_PATH_D] != 0) && - pRFCalibrateInfo->TxPowerTrackControl && (pHalData->EEPROMThermalMeter != 0xff)) - { - //4 7.2 Configure the Swing Table to adjust Tx Power. - - pRFCalibrateInfo->bTxPowerChanged = TRUE; // Always TRUE after Tx Power is adjusted by power tracking. - // - // 2012/04/23 MH According to Luke's suggestion, we can not write BB digital - // to increase TX power. Otherwise, EVM will be bad. - // - // 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. - if (ThermalValue > pRFCalibrateInfo->ThermalValue) - { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("Temperature Increasing(%d): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", - p, pRFCalibrateInfo->PowerIndexOffset[p], delta, ThermalValue, pHalData->EEPROMThermalMeter, pRFCalibrateInfo->ThermalValue)); - } - } - - else if (ThermalValue < pRFCalibrateInfo->ThermalValue)// Low temperature - { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("Temperature Decreasing(%d): delta_pi: %d , delta_t: %d, Now_t: %d, EFUSE_t: %d, Last_t: %d\n", - p, pRFCalibrateInfo->PowerIndexOffset[p], delta, ThermalValue, pHalData->EEPROMThermalMeter, pRFCalibrateInfo->ThermalValue)); - } - } - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - if (ThermalValue > pHalData->EEPROMThermalMeter) -#else - if (ThermalValue > pDM_Odm->priv->pmib->dot11RFEntry.ther) -#endif - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("Temperature(%d) higher than PG value(%d)\n", ThermalValue, pHalData->EEPROMThermalMeter)); - - if (pDM_Odm->SupportICType == ODM_RTL8188E || pDM_Odm->SupportICType == ODM_RTL8192E ||pDM_Odm->SupportICType == ODM_RTL8821 || - pDM_Odm->SupportICType == ODM_RTL8812 || pDM_Odm->SupportICType == ODM_RTL8723B || pDM_Odm->SupportICType == ODM_RTL8814A || pDM_Odm->SupportICType == ODM_RTL8703B || pDM_Odm->SupportICType == ODM_RTL8188F) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("**********Enter POWER Tracking MIX_MODE**********\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0); - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("**********Enter POWER Tracking BBSWING_MODE**********\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, BBSWING, p, Indexforchannel); - } - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("Temperature(%d) lower than PG value(%d)\n", ThermalValue, pHalData->EEPROMThermalMeter)); - - if (pDM_Odm->SupportICType == ODM_RTL8188E || pDM_Odm->SupportICType == ODM_RTL8192E || pDM_Odm->SupportICType == ODM_RTL8821 || - pDM_Odm->SupportICType == ODM_RTL8812 || pDM_Odm->SupportICType == ODM_RTL8723B || pDM_Odm->SupportICType == ODM_RTL8814A || pDM_Odm->SupportICType == ODM_RTL8703B || pDM_Odm->SupportICType == ODM_RTL8188F) - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("**********Enter POWER Tracking MIX_MODE**********\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, Indexforchannel); - } - else - { - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("**********Enter POWER Tracking BBSWING_MODE**********\n")); - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, BBSWING, p, Indexforchannel); - } - - } - - pRFCalibrateInfo->BbSwingIdxCckBase = pRFCalibrateInfo->BbSwingIdxCck; // Record last time Power Tracking result as base. - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) - pRFCalibrateInfo->BbSwingIdxOfdmBase[p] = pRFCalibrateInfo->BbSwingIdxOfdm[p]; - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("pRFCalibrateInfo->ThermalValue = %d ThermalValue= %d\n", pRFCalibrateInfo->ThermalValue, ThermalValue)); - - pRFCalibrateInfo->ThermalValue = ThermalValue; //Record last Power Tracking Thermal Value - - } - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - - if(!IS_HARDWARE_TYPE_8723B(Adapter)) - { - // Delta temperature is equal to or larger than 20 centigrade (When threshold is 8). - if ((delta_IQK >= c.Threshold_IQK)) { - if ( ! pRFCalibrateInfo->bIQKInProgress) - (*c.DoIQK)(pDM_Odm, delta_IQK, ThermalValue, 8); - } - } - if (pRFCalibrateInfo->DpkThermal[ODM_RF_PATH_A] != 0) { - if ((diff_DPK[ODM_RF_PATH_A] >= c.Threshold_DPK)) { - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xcc4, BIT14|BIT13|BIT12|BIT11|BIT10, (diff_DPK[ODM_RF_PATH_A] / c.Threshold_DPK)); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } else if ((diff_DPK[ODM_RF_PATH_A] <= -1 * c.Threshold_DPK)) { - s4Byte value = 0x20 + (diff_DPK[ODM_RF_PATH_A] / c.Threshold_DPK); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xcc4, BIT14|BIT13|BIT12|BIT11|BIT10, value); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } else { - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xcc4, BIT14|BIT13|BIT12|BIT11|BIT10, 0); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } - } - if (pRFCalibrateInfo->DpkThermal[ODM_RF_PATH_B] != 0) { - if ((diff_DPK[ODM_RF_PATH_B] >= c.Threshold_DPK)) { - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xec4, BIT14|BIT13|BIT12|BIT11|BIT10, (diff_DPK[ODM_RF_PATH_B] / c.Threshold_DPK)); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } else if ((diff_DPK[ODM_RF_PATH_B] <= -1 * c.Threshold_DPK)) { - s4Byte value = 0x20 + (diff_DPK[ODM_RF_PATH_B] / c.Threshold_DPK); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xec4, BIT14|BIT13|BIT12|BIT11|BIT10, value); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } else { - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x1); - ODM_SetBBReg(pDM_Odm, 0xec4, BIT14|BIT13|BIT12|BIT11|BIT10, 0); - ODM_SetBBReg(pDM_Odm, 0x82c, BIT(31), 0x0); - } - } - -#endif - - ODM_RT_TRACE(pDM_Odm,ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD,("<===ODM_TXPowerTrackingCallback_ThermalMeter\n")); - - pRFCalibrateInfo->TXPowercount = 0; -} - - - -//3============================================================ -//3 IQ Calibration -//3============================================================ - -VOID -ODM_ResetIQKResult( - IN PDM_ODM_T pDM_Odm -) -{ - return; -} -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) -u1Byte ODM_GetRightChnlPlaceforIQK(u1Byte chnl) -{ - u1Byte channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = - {1,2,3,4,5,6,7,8,9,10,11,12,13,14,36,38,40,42,44,46,48,50,52,54,56,58,60,62,64,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,130,132,134,136,138,140,149,151,153,155,157,159,161,163,165}; - u1Byte place = chnl; - - - if(chnl > 14) - { - for(place = 14; placeAdapter; - -#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - if (*pDM_Odm->pIsFcsModeEnable) - return; -#endif - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - if (!IS_HARDWARE_TYPE_JAGUAR(Adapter)) - return; -#if (DM_ODM_SUPPORT_TYPE & (ODM_CE)) - else if (IS_HARDWARE_TYPE_8812AU(Adapter)) - return; -#endif -#endif - -#if (RTL8821A_SUPPORT == 1) - if (pDM_Odm->bLinked) { - if ((*pDM_Odm->pChannel != pDM_Odm->preChannel) && (!*pDM_Odm->pbScanInProcess)) { - pDM_Odm->preChannel = *pDM_Odm->pChannel; - pDM_Odm->LinkedInterval = 0; - } - - if (pDM_Odm->LinkedInterval < 3) - pDM_Odm->LinkedInterval++; - - if (pDM_Odm->LinkedInterval == 2) { - /*Mark out IQK flow to prevent tx stuck. by Maddest 20130306*/ - /*Open it verified by James 20130715*/ -#if (DM_ODM_SUPPORT_TYPE == ODM_CE) - PHY_IQCalibrate_8821A(pDM_Odm, FALSE); -#elif (DM_ODM_SUPPORT_TYPE == ODM_WIN) - PHY_IQCalibrate(Adapter, FALSE); -#else - PHY_IQCalibrate_8821A(Adapter, FALSE); -#endif - } - } else - pDM_Odm->LinkedInterval = 0; -#endif -} - -void phydm_rf_init(IN PDM_ODM_T pDM_Odm) -{ - - odm_TXPowerTrackingInit(pDM_Odm); - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - ODM_ClearTxPowerTrackingState(pDM_Odm); -#endif - -#if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) -#if (RTL8814A_SUPPORT == 1) - if (pDM_Odm->SupportICType & ODM_RTL8814A) - PHY_IQCalibrate_8814A_Init(pDM_Odm); -#endif -#endif - -} - -void phydm_rf_watchdog(IN PDM_ODM_T pDM_Odm) -{ - -#if (DM_ODM_SUPPORT_TYPE & (ODM_WIN|ODM_CE)) - ODM_TXPowerTrackingCheck(pDM_Odm); - if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) - odm_IQCalibrate(pDM_Odm); -#endif -} \ No newline at end of file diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.h deleted file mode 100644 index aa20db1b7..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/halphyrf_win.h +++ /dev/null @@ -1,108 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - - #ifndef __HAL_PHY_RF_H__ - #define __HAL_PHY_RF_H__ - -#include "phydm_kfree.h" -#if (RTL8814A_SUPPORT == 1) -#include "rtl8814a/phydm_iqk_8814a.h" -#endif - -#if (RTL8822B_SUPPORT == 1) -#include "rtl8822b/phydm_iqk_8822b.h" -#endif -#include "phydm_powertracking_win.h" - -typedef enum _SPUR_CAL_METHOD { - PLL_RESET, - AFE_PHASE_SEL -} SPUR_CAL_METHOD; - -typedef enum _PWRTRACK_CONTROL_METHOD { - BBSWING, - TXAGC, - MIX_MODE, - TSSI_MODE -} PWRTRACK_METHOD; - -typedef VOID (*FuncSetPwr)(PDM_ODM_T, PWRTRACK_METHOD, u1Byte, u1Byte); -typedef VOID(*FuncIQK)(PVOID, u1Byte, u1Byte, u1Byte); -typedef VOID (*FuncLCK)(PDM_ODM_T); - //refine by YuChen for 8814A -typedef VOID (*FuncSwing)(PDM_ODM_T, pu1Byte*, pu1Byte*, pu1Byte*, pu1Byte*); -typedef VOID (*FuncSwing8814only)(PDM_ODM_T, pu1Byte*, pu1Byte*, pu1Byte*, pu1Byte*); - -typedef struct _TXPWRTRACK_CFG { - u1Byte SwingTableSize_CCK; - u1Byte SwingTableSize_OFDM; - u1Byte Threshold_IQK; - u1Byte Threshold_DPK; - u1Byte AverageThermalNum; - u1Byte RfPathCount; - u4Byte ThermalRegAddr; - FuncSetPwr ODM_TxPwrTrackSetPwr; - FuncIQK DoIQK; - FuncLCK PHY_LCCalibrate; - FuncSwing GetDeltaSwingTable; - FuncSwing8814only GetDeltaSwingTable8814only; -} TXPWRTRACK_CFG, *PTXPWRTRACK_CFG; - -VOID -ConfigureTxpowerTrack( - IN PDM_ODM_T pDM_Odm, - OUT PTXPWRTRACK_CFG pConfig - ); - - -VOID -ODM_ClearTxPowerTrackingState( - IN PDM_ODM_T pDM_Odm - ); - -VOID -ODM_TXPowerTrackingCallback_ThermalMeter( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PDM_ODM_T pDM_Odm -#else - IN PADAPTER Adapter -#endif - ); - - - -#define ODM_TARGET_CHNL_NUM_2G_5G 59 - - -VOID -ODM_ResetIQKResult( - IN PDM_ODM_T pDM_Odm -); -u1Byte -ODM_GetRightChnlPlaceforIQK( - IN u1Byte chnl -); - -VOID odm_IQCalibrate(IN PDM_ODM_T pDM_Odm); -VOID phydm_rf_init( IN PDM_ODM_T pDM_Odm); -VOID phydm_rf_watchdog( IN PDM_ODM_T pDM_Odm); - -#endif // #ifndef __HAL_PHY_RF_H__ - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.c index d80c163aa..b1bc9b314 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.c @@ -124,9 +124,6 @@ ODM_InitMpDriverStatus( PADAPTER Adapter = pDM_Odm->Adapter; - // Update information every period - pDM_Odm->mp_mode = (BOOLEAN)Adapter->registrypriv.mp_mode; - #else // MP mode is always false at AP side @@ -147,8 +144,6 @@ ODM_UpdateMpDriverStatus( #elif(DM_ODM_SUPPORT_TYPE & ODM_CE) PADAPTER Adapter = pDM_Odm->Adapter; - // Update information erery period - pDM_Odm->mp_mode = (BOOLEAN)Adapter->registrypriv.mp_mode; #else diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.h index cf42ef2da..fb91ff03a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.h +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm.h @@ -735,7 +735,6 @@ typedef struct DM_Out_Source_Dynamic_Mechanism_Structure u1Byte InterfaceIndex; /*Add for 92D dual MAC: 0--Mac0 1--Mac1*/ BOOLEAN bIsMPChip; BOOLEAN bOneEntryOnly; - BOOLEAN mp_mode; u4Byte OneEntry_MACID; u1Byte pre_number_linked_client; u1Byte number_linked_client; diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_adaptivity.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_adaptivity.c index 8883be5f9..0f6f87fcf 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_adaptivity.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_adaptivity.c @@ -634,7 +634,7 @@ Phydm_AdaptivityInit( pDM_Odm->Adaptivity_IGI_upper = 0; pDM_Odm->Adaptivity_enable = FALSE; /*use this flag to decide enable or disable*/ - if (pDM_Odm->bWIFITest == TRUE || pDM_Odm->mp_mode == TRUE) + if (pDM_Odm->bWIFITest == TRUE) pDM_Odm->EDCCA_enable = FALSE; else pDM_Odm->EDCCA_enable = TRUE; /*even no adaptivity, we still enable EDCCA*/ diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_antdiv.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_antdiv.c index 188af39cf..f24e3873a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_antdiv.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_antdiv.c @@ -4736,8 +4736,6 @@ odm_AntennaDiversityInit( ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - if(pDM_Odm->mp_mode == TRUE) - return; #if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY)) ODM_AntDiv_Config(pDM_Odm); @@ -4751,8 +4749,6 @@ odm_AntennaDiversity( ) { PDM_ODM_T pDM_Odm = (PDM_ODM_T)pDM_VOID; - if(pDM_Odm->mp_mode == TRUE) - return; #if (defined(CONFIG_PHYDM_ANTENNA_DIVERSITY)) ODM_AntDiv(pDM_Odm); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_debug.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_debug.c index 73efc277f..a0f1f5a4b 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_debug.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_debug.c @@ -1430,12 +1430,10 @@ phydm_cmd_parser( case PHYDM_RA: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); + PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); - PHYDM_SNPRINTF((output + used, out_len - used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); - input_idx++; - } + PHYDM_SNPRINTF((output + used, out_len - used, "new SET, RA_var[%d]= (( %d ))\n", i , var1[i])); + input_idx++; } if (input_idx >= 1) { @@ -1451,12 +1449,10 @@ phydm_cmd_parser( case PHYDM_PATHDIV: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_HEX, &var1[i]); + PHYDM_SSCANF(input[i + 1], DCMD_HEX, &var1[i]); - /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i]));*/ - input_idx++; - } + /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, PATHDIV_var[%d]= (( %d ))\n", i , var1[i]));*/ + input_idx++; } if (input_idx >= 1) { @@ -1471,12 +1467,10 @@ phydm_cmd_parser( case PHYDM_DEBUG: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); + PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); - /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, Debug_var[%d]= (( %d ))\n", i , var1[i]));*/ - input_idx++; - } + /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, Debug_var[%d]= (( %d ))\n", i , var1[i]));*/ + input_idx++; } if (input_idx >= 1) { @@ -1490,12 +1484,10 @@ phydm_cmd_parser( case PHYDM_SUPPORT_ABILITY: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); + PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); - /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, support ablity_var[%d]= (( %d ))\n", i , var1[i]));*/ - input_idx++; - } + /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, support ablity_var[%d]= (( %d ))\n", i , var1[i]));*/ + input_idx++; } if (input_idx >= 1) { @@ -1508,10 +1500,8 @@ phydm_cmd_parser( case PHYDM_SMART_ANT: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_HEX, &var1[i]); - input_idx++; - } + PHYDM_SSCANF(input[i + 1], DCMD_HEX, &var1[i]); + input_idx++; } if (input_idx >= 1) { @@ -1531,10 +1521,8 @@ phydm_cmd_parser( BOOLEAN bEnableDbgMode; u1Byte central_ch, primary_ch_idx, bandwidth; - for (i = 0; i < 4; i++) { - if (input[i + 1]) - PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); - } + for (i = 0; i < 4; i++) + PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); bEnableDbgMode = (BOOLEAN)var1[0]; central_ch = (u1Byte) var1[1]; @@ -1568,12 +1556,10 @@ phydm_cmd_parser( case PHYDM_SET_TXAGC: for (i = 0; i < 5; i++) { - if (input[i + 1]) { - PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); + PHYDM_SSCANF(input[i + 1], DCMD_DECIMAL, &var1[i]); - /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, support ablity_var[%d]= (( %d ))\n", i , var1[i]));*/ - input_idx++; - } + /*PHYDM_SNPRINTF((output+used, out_len-used, "new SET, support ablity_var[%d]= (( %d ))\n", i , var1[i]));*/ + input_idx++; } phydm_set_txagc(pDM_Odm, (u4Byte *)var1, &used, output, &out_len); @@ -1657,10 +1643,8 @@ phydm_cmd_parser( { u1Byte type = 0; - if (input[1]) { - PHYDM_SSCANF(input[1], DCMD_DECIMAL, &var1[0]); - type = (u1Byte)var1[0]; - } + PHYDM_SSCANF(input[1], DCMD_DECIMAL, &var1[0]); + type = (u1Byte)var1[0]; if (type == 0) phydm_DumpBbReg(pDM_Odm); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_dig.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_dig.c index fbca415fa..33469f4fc 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_dig.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_dig.c @@ -1341,7 +1341,7 @@ odm_DIG( else #endif { -#if ((DM_ODM_SUPPORT_TYPE & ODM_WIN) || ((DM_ODM_SUPPORT_TYPE & ODM_CE) && (ODM_CONFIG_BT_COEXIST == 1))) +#if ((DM_ODM_SUPPORT_TYPE & ODM_WIN)) if(pDM_Odm->bBtHsOperation) { if(pDM_Odm->bLinked) diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_edcaturbocheck.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_edcaturbocheck.c index 6d3dc6d38..ff6e7481f 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_edcaturbocheck.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_edcaturbocheck.c @@ -205,15 +205,6 @@ odm_EdcaTurboCheckCE( } else { - if(pDM_Odm->SupportInterface==ODM_ITRF_PCIE) { - if((ICType==ODM_RTL8192C)&&(pDM_Odm->RFType==ODM_2T2R)) { - EDCA_BE_UL = 0x60a42b; - EDCA_BE_DL = 0x60a42b; - } else { - EDCA_BE_UL = 0x6ea42b; - EDCA_BE_DL = 0x6ea42b; - } - } } //92D txop can't be set to 0x3e for cisco1250 diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_hwconfig.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_hwconfig.c index 22601ec50..cc5731104 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_hwconfig.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_hwconfig.c @@ -26,19 +26,9 @@ #include "phydm_precomp.h" #define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm)) -#define READ_AND_CONFIG_TC(ic, txt) (ODM_ReadAndConfig_TC_##ic##txt(pDM_Odm)) -#if (PHYDM_TESTCHIP_SUPPORT == 1) -#define READ_AND_CONFIG(ic, txt) do {\ - if (pDM_Odm->bIsMPChip)\ - READ_AND_CONFIG_MP(ic,txt);\ - else\ - READ_AND_CONFIG_TC(ic,txt);\ - } while(0) -#else #define READ_AND_CONFIG READ_AND_CONFIG_MP -#endif #define GET_VERSION_MP(ic, txt) (ODM_GetVersion_MP_##ic##txt()) #define GET_VERSION_TC(ic, txt) (ODM_GetVersion_TC_##ic##txt()) @@ -241,7 +231,7 @@ odm_SignalScaleMapping_92CSeries( #endif #if ((DEV_BUS_TYPE == RT_USB_INTERFACE) ||(DEV_BUS_TYPE == RT_SDIO_INTERFACE)) - if((pDM_Odm->SupportInterface == ODM_ITRF_USB) || (pDM_Odm->SupportInterface == ODM_ITRF_SDIO)) + if((pDM_Odm->SupportInterface == ODM_ITRF_USB)) { if(CurrSig >= 51 && CurrSig <= 100) { @@ -2270,8 +2260,6 @@ ODM_ConfigRFWithTxPwrTrackHeaderFile( if (pDM_Odm->SupportICType == ODM_RTL8188F) { if (pDM_Odm->SupportInterface == ODM_ITRF_USB) READ_AND_CONFIG_MP(8188F, _TxPowerTrack_USB); - else if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO) - READ_AND_CONFIG_MP(8188F, _TxPowerTrack_SDIO); } #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.c index b8fe78407..8c086e7b4 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.c @@ -458,13 +458,8 @@ odm_TXPowerTrackingThermalMeterInit( pRFCalibrateInfo->TXPowercount = 0; pRFCalibrateInfo->bTXPowerTrackingInit = _FALSE; - if(pDM_Odm->mp_mode == FALSE) - pRFCalibrateInfo->TxPowerTrackControl = _TRUE; - else - pRFCalibrateInfo->TxPowerTrackControl = _FALSE; - - if(pDM_Odm->mp_mode == FALSE) - pRFCalibrateInfo->TxPowerTrackControl = _TRUE; + pRFCalibrateInfo->TxPowerTrackControl = _TRUE; + pRFCalibrateInfo->TxPowerTrackControl = _TRUE; MSG_8192C("pDM_Odm TxPowerTrackControl = %d\n", pRFCalibrateInfo->TxPowerTrackControl); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.h index c068b7479..8de5b154d 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.h +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_powertracking_ce.h @@ -123,28 +123,10 @@ typedef struct ODM_RF_Calibration_Structure u1Byte DeltaSwingTableIdx_2GCCKA_N[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GCCKB_P[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GCCKB_N[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GCCKC_P[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GCCKC_N[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GCCKD_P[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GCCKD_N[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GA_P[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GA_N[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GB_P[DELTA_SWINGIDX_SIZE]; u1Byte DeltaSwingTableIdx_2GB_N[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GC_P[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GC_N[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GD_P[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GD_N[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GA_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GA_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GB_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GB_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GC_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GC_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GD_P[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_5GD_N[BAND_NUM][DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GA_P_8188E[DELTA_SWINGIDX_SIZE]; - u1Byte DeltaSwingTableIdx_2GA_N_8188E[DELTA_SWINGIDX_SIZE]; u1Byte BbSwingIdxOfdm[MAX_RF_PATH]; u1Byte BbSwingIdxOfdmCurrent; diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_pre_define.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_pre_define.h index c64e0d40f..67b4c6249 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_pre_define.h +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_pre_define.h @@ -249,9 +249,7 @@ // ODM_CMNINFO_INTERFACE typedef enum tag_ODM_Support_Interface_Definition { - ODM_ITRF_PCIE = 0x1, ODM_ITRF_USB = 0x2, - ODM_ITRF_SDIO = 0x4, ODM_ITRF_ALL = 0x7, }ODM_INTERFACE_E; @@ -294,13 +292,11 @@ typedef enum tag_ODM_Support_IC_Type_Definition #endif #define ODM_IC_11N_SERIES_SUPPORT 1 -#define ODM_CONFIG_BT_COEXIST 0 #elif (DM_ODM_SUPPORT_TYPE == ODM_WIN) #define ODM_IC_11AC_SERIES_SUPPORT 1 #define ODM_IC_11N_SERIES_SUPPORT 1 -#define ODM_CONFIG_BT_COEXIST 1 #else @@ -314,12 +310,6 @@ typedef enum tag_ODM_Support_IC_Type_Definition #define ODM_IC_11AC_SERIES_SUPPORT 1 #endif -#ifdef CONFIG_BT_COEXIST -#define ODM_CONFIG_BT_COEXIST 1 -#else -#define ODM_CONFIG_BT_COEXIST 0 -#endif - #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_types.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_types.h index ff47bb406..ad4b5c8f4 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_types.h +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/phydm_types.h @@ -118,7 +118,6 @@ typedef enum _RT_SPINLOCK_TYPE{ #define STA_INFO_T RT_WLAN_STA #define PSTA_INFO_T PRT_WLAN_STA #define __func__ __FUNCTION__ - #define PHYDM_TESTCHIP_SUPPORT TESTCHIP_SUPPORT #define bMaskH3Bytes 0xffffff00 #define SUCCESS 0 #define FAIL (-1) @@ -162,12 +161,6 @@ typedef enum _RT_SPINLOCK_TYPE{ #define _TRUE 1 #define _FALSE 0 - #if (defined(TESTCHIP_SUPPORT)) - #define PHYDM_TESTCHIP_SUPPORT 1 - #else - #define PHYDM_TESTCHIP_SUPPORT 0 - #endif - #elif (DM_ODM_SUPPORT_TYPE == ODM_CE) #include #if 0 @@ -244,11 +237,6 @@ typedef enum _RT_SPINLOCK_TYPE{ #define FPGA_TWO_MAC_VERIFICATION 0 #define RTL8881A_SUPPORT 0 - #if (defined(TESTCHIP_SUPPORT)) - #define PHYDM_TESTCHIP_SUPPORT 1 - #else - #define PHYDM_TESTCHIP_SUPPORT 0 - #endif #endif #define READ_NEXT_PAIR(v1, v2, i) do { if (i+2 >= ArrayLen) break; i += 2; v1 = Array[i]; v2 = Array[i+1]; } while(0) diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halhwimg8188f_rf.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halhwimg8188f_rf.c index 9d0bba561..f980c672a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halhwimg8188f_rf.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halhwimg8188f_rf.c @@ -342,157 +342,11 @@ ODM_GetVersion_MP_8188F_RadioA(void) return 31; } -/****************************************************************************** -* TxPowerTrack_AP.TXT -******************************************************************************/ - -#if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) -u1Byte gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_AP_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_AP_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_AP_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_AP_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; -u1Byte gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_AP_8188F[] = {0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11}; -u1Byte gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_AP_8188F[] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9}; -u1Byte gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_AP_8188F[] = {0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11}; -u1Byte gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_AP_8188F[] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_AP_8188F[] = {0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 9, 9, 9, 9, 10, 10, 10, 10, 11, 11}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_AP_8188F[] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_AP_8188F[] = {0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 7, 8, 8, 9, 9, 9, 10, 10, 10, 10, 11, 11}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_AP_8188F[] = {0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9}; -#endif - -void -ODM_ReadAndConfig_MP_8188F_TxPowerTrack_AP( - IN PDM_ODM_T pDM_Odm -) -{ -#if (DM_ODM_SUPPORT_TYPE & (ODM_AP)) - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_MP_8188F\n")); - - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE); - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P, gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N, gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P, gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N, gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_AP_8188F, DELTA_SWINGIDX_SIZE*3); -#endif -} - -/****************************************************************************** -* TxPowerTrack_SDIO.TXT -******************************************************************************/ - -#if DEV_BUS_TYPE == RT_SDIO_INTERFACE -u1Byte gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_SDIO_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_SDIO_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_SDIO_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_SDIO_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; -u1Byte gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8188F[] = {0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9}; -u1Byte gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8188F[] = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 8, 8, 8, 8}; -u1Byte gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8188F[] = {0, 1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 9, 10, 11, 12, 13, 14, 15, 16, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18}; -u1Byte gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8188F[] = {0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8188F[] = {0, 1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8188F[] = {0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 5, 6, 6, 6, 6, 7, 7}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8188F[] = {0, 1, 2, 3, 4, 6, 7, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 16, 16, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18}; -u1Byte gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8188F[] = {0, 0, 1, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14}; -#endif - -void -ODM_ReadAndConfig_MP_8188F_TxPowerTrack_SDIO( - IN PDM_ODM_T pDM_Odm -) -{ -#if DEV_BUS_TYPE == RT_SDIO_INTERFACE - PODM_RF_CAL_T pRFCalibrateInfo = &(pDM_Odm->RFCalibrateInfo); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> ODM_ReadAndConfig_MP_MP_8188F\n")); - - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_P, gDeltaSwingTableIdx_MP_2GA_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GA_N, gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_P, gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GB_N, gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_P, gDeltaSwingTableIdx_MP_2GCCKA_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE); - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P, gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N, gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P, gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N, gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_SDIO_8188F, DELTA_SWINGIDX_SIZE*3); -#endif -} - /****************************************************************************** * TxPowerTrack_USB.TXT ******************************************************************************/ #if DEV_BUS_TYPE == RT_USB_INTERFACE -u1Byte gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_USB_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_USB_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_USB_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 12, 13, 13, 14, 14, 15, 16, 17, 17, 17, 17, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, - {0, 1, 2, 3, 3, 5, 5, 6, 6, 7, 8, 9, 10, 11, 11, 12, 13, 14, 14, 15, 15, 16, 16, 17, 17, 18, 18, 18, 18, 18}, -}; -u1Byte gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_USB_8188F[][DELTA_SWINGIDX_SIZE] = { - {0, 1, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, - {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}, -}; u1Byte gDeltaSwingTableIdx_MP_2GB_N_TxPowerTrack_USB_8188F[] = {0, 0, 1, 1, 2, 2, 2, 3, 3, 3, 3, 4, 5, 5, 5, 6, 6, 7, 7, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9}; u1Byte gDeltaSwingTableIdx_MP_2GB_P_TxPowerTrack_USB_8188F[] = {0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 7, 8, 8, 8, 8}; u1Byte gDeltaSwingTableIdx_MP_2GA_N_TxPowerTrack_USB_8188F[] = {0, 1, 1, 2, 3, 4, 4, 4, 5, 6, 7, 8, 8, 9, 10, 11, 12, 13, 13, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15}; @@ -523,11 +377,6 @@ ODM_ReadAndConfig_MP_8188F_TxPowerTrack_USB( ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKA_N, gDeltaSwingTableIdx_MP_2GCCKA_N_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE); ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_P, gDeltaSwingTableIdx_MP_2GCCKB_P_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE); ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_2GCCKB_N, gDeltaSwingTableIdx_MP_2GCCKB_N_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE); - - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_P, gDeltaSwingTableIdx_MP_5GA_P_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GA_N, gDeltaSwingTableIdx_MP_5GA_N_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_P, gDeltaSwingTableIdx_MP_5GB_P_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE*3); - ODM_MoveMemory(pDM_Odm, pRFCalibrateInfo->DeltaSwingTableIdx_5GB_N, gDeltaSwingTableIdx_MP_5GB_N_TxPowerTrack_USB_8188F, DELTA_SWINGIDX_SIZE*3); #endif } diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.c b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.c index 26e373e00..e7e428eb9 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.c @@ -589,21 +589,7 @@ GetDeltaSwingTable_8188F( u1Byte TxRate = 0xFF; u1Byte channel = pHalData->CurrentChannel; - if (pDM_Odm->mp_mode == TRUE) { - #if (DM_ODM_SUPPORT_TYPE & (ODM_WIN | ODM_CE)) - #if (DM_ODM_SUPPORT_TYPE & ODM_WIN) - #if (MP_DRIVER == 1) - PMPT_CONTEXT pMptCtx = &(Adapter->MptCtx); - - TxRate = MptToMgntRate(pMptCtx->MptRateIndex); - #endif - #elif (DM_ODM_SUPPORT_TYPE & ODM_CE) - PMPT_CONTEXT pMptCtx = &(Adapter->mppriv.MptCtx); - - TxRate = MptToMgntRate(pMptCtx->MptRateIndex); - #endif - #endif - } else { + { u2Byte rate = *(pDM_Odm->pForcedDataRate); if (!rate) { /*auto rate*/ @@ -2877,9 +2863,6 @@ PHY_IQCalibrate_8188F( pDM_Odm->RFCalibrateInfo.RegE9C = pDM_Odm->RFCalibrateInfo.RegEBC = 0x0; //Y default value } -#if MP_DRIVER == 1 - if ((pMptCtx->MptRfPath == ODM_RF_PATH_A) || ((pDM_Odm->mp_mode) == 0)) -#endif { if (RegE94 != 0) { #if !(DM_ODM_SUPPORT_TYPE & ODM_AP) @@ -2891,9 +2874,6 @@ PHY_IQCalibrate_8188F( } #if !(DM_ODM_SUPPORT_TYPE & ODM_AP) -#if MP_DRIVER == 1 - if ((pMptCtx->MptRfPath == ODM_RF_PATH_A) || ((pDM_Odm->mp_mode) == 0)) -#endif { if (RegEB4 != 0) _PHY_PathBFillIQKMatrix8188F(pAdapter, bPathBOK, result, final_candidate, (RegEC4 == 0)); @@ -2992,59 +2972,6 @@ PHY_LCCalibrate_8188F( } -VOID -PHY_APCalibrate_8188F( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PDM_ODM_T pDM_Odm, -#else - IN PADAPTER pAdapter, -#endif - IN s1Byte delta -) -{ -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) -#if DBG - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(pAdapter); -#if (DM_ODM_SUPPORT_TYPE == ODM_CE) - PDM_ODM_T pDM_Odm = &pHalData->odmpriv; -#endif -#if (DM_ODM_SUPPORT_TYPE == ODM_WIN) - PDM_ODM_T pDM_Odm = &pHalData->DM_OutSrc; -#endif -#endif -#endif -#if DISABLE_BB_RF - return; -#endif - - return; -#if 0 -#if (DM_ODM_SUPPORT_TYPE == ODM_CE) - if (!(pDM_Odm->SupportAbility & ODM_RF_CALIBRATION)) - return; -#endif - -#if FOR_BRAZIL_PRETEST != 1 - if (pDM_Odm->RFCalibrateInfo.bAPKdone) -#endif - return; - -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - if (IS_2T2R(pHalData->VersionID)) - phy_APCalibrate_8188F(pAdapter, delta, TRUE); - else -#endif - { - // For 88C 1T1R -#if !(DM_ODM_SUPPORT_TYPE & ODM_AP) - phy_APCalibrate_8188F(pAdapter, delta, FALSE); -#else - phy_APCalibrate_8188F(pDM_Odm, delta, FALSE); -#endif - } -#endif -} - VOID phy_SetRFPathSwitch_8188F( #if (DM_ODM_SUPPORT_TYPE & ODM_AP) IN PDM_ODM_T pDM_Odm, diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.h b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.h index 9d384b9c5..e29270531 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.h +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/phydm/rtl8188f/halphyrf_8188f.h @@ -70,17 +70,6 @@ PHY_LCCalibrate_8188F( IN PVOID pDM_VOID ); -// -// AP calibrate -// -void -PHY_APCalibrate_8188F( -#if (DM_ODM_SUPPORT_TYPE & ODM_AP) - IN PDM_ODM_T pDM_Odm, -#else - IN PADAPTER pAdapter, -#endif - IN s1Byte delta); void PHY_DigitalPredistortion_8188F( IN PADAPTER pAdapter); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_cmd.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_cmd.c index eb5aaeca4..5c2f923ea 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_cmd.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_cmd.c @@ -576,19 +576,6 @@ void rtl8188f_set_FwPwrMode_cmd(PADAPTER padapter, u8 psmode) } if (psmode > 0) { -#ifdef CONFIG_BT_COEXIST - if (rtw_btcoex_IsBtControlLps(padapter) == _TRUE) { - PowerState = rtw_btcoex_RpwmVal(padapter); - byte5 = rtw_btcoex_LpsVal(padapter); - - if ((rlbm == 2) && (byte5 & BIT(4))) { - /* Keep awake interval to 1 to prevent from */ - /* decreasing coex performance */ - awake_intvl = 2; - rlbm = 2; - } - } else -#endif /* CONFIG_BT_COEXIST */ { PowerState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ byte5 = 0x40; @@ -664,9 +651,6 @@ void rtl8188f_set_FwPwrMode_cmd(PADAPTER padapter, u8 psmode) } #endif -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_RecordPwrMode(padapter, u1H2CPwrModeParm, H2C_PWRMODE_LEN); -#endif /* CONFIG_BT_COEXIST */ RT_PRINT_DATA(_module_hal_init_c_, _drv_always_, "u1H2CPwrModeParm:", u1H2CPwrModeParm, H2C_PWRMODE_LEN); @@ -915,278 +899,6 @@ void rtl8188f_fw_try_ap_cmd(PADAPTER padapter, u32 need_ack) } #endif -#ifdef CONFIG_BT_COEXIST -static void ConstructBtNullFunctionData( - PADAPTER padapter, - u8 *pframe, - u32 *pLength, - u8 *StaAddr, - u8 bQoS, - u8 AC, - u8 bEosp, - u8 bForcePowerSave) -{ - struct rtw_ieee80211_hdr *pwlanhdr; - u16 *fctrl; - u32 pktlen; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - u8 bssid[ETH_ALEN]; - - - DBG_871X("+" FUNC_ADPT_FMT ": qos=%d eosp=%d ps=%d\n", - FUNC_ADPT_ARG(padapter), bQoS, bEosp, bForcePowerSave); - - pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - - if (NULL == StaAddr) { - _rtw_memcpy(bssid, myid(&padapter->eeprompriv), ETH_ALEN); - StaAddr = bssid; - } - - fctrl = &pwlanhdr->frame_ctl; - *fctrl = 0; - if (bForcePowerSave) - SetPwrMgt(fctrl); - - SetFrDs(fctrl); - _rtw_memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); - _rtw_memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); - _rtw_memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); - - SetDuration(pwlanhdr, 0); - SetSeqNum(pwlanhdr, 0); - - if (bQoS == _TRUE) { - struct rtw_ieee80211_hdr_3addr_qos *pwlanqoshdr; - - SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); - - pwlanqoshdr = (struct rtw_ieee80211_hdr_3addr_qos *)pframe; - SetPriority(&pwlanqoshdr->qc, AC); - SetEOSP(&pwlanqoshdr->qc, bEosp); - - pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); - } else { - SetFrameSubType(pframe, WIFI_DATA_NULL); - - pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - } - - *pLength = pktlen; -} - -static void SetFwRsvdPagePkt_BTCoex(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - struct xmit_frame *pcmdframe; - struct pkt_attrib *pattrib; - struct xmit_priv *pxmitpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - u32 BeaconLength = 0; - u32 BTQosNullLength = 0; - u8 *ReservedPagePacket; - u8 TxDescLen, TxDescOffset; - u8 TotalPageNum = 0, CurtPktPageNum = 0, RsvdPageNum = 0; - u16 BufIndex, PageSize; - u32 TotalPacketLen, MaxRsvdPageBufSize = 0; - RSVDPAGE_LOC RsvdPageLoc; - - - /*DBG_8192C("+" FUNC_ADPT_FMT "\n", FUNC_ADPT_ARG(padapter)); */ - - pHalData = GET_HAL_DATA(padapter); - pxmitpriv = &padapter->xmitpriv; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - TxDescLen = TXDESC_SIZE; - TxDescOffset = TXDESC_OFFSET; - PageSize = PAGE_SIZE_TX_8188F; - - RsvdPageNum = BCNQ_PAGE_NUM_8188F; - MaxRsvdPageBufSize = RsvdPageNum * PageSize; - - pcmdframe = rtw_alloc_cmdxmitframe(pxmitpriv); - if (pcmdframe == NULL) { - DBG_8192C("%s: alloc ReservedPagePacket fail!\n", __func__); - return; - } - - ReservedPagePacket = pcmdframe->buf_addr; - _rtw_memset(&RsvdPageLoc, 0, sizeof(RSVDPAGE_LOC)); - - /*3 (1) beacon */ - BufIndex = TxDescOffset; - ConstructBeacon(padapter, &ReservedPagePacket[BufIndex], &BeaconLength); - - /* When we count the first page size, we need to reserve description size for the RSVD */ - /* packet, it will be filled in front of the packet in TXPKTBUF. */ - CurtPktPageNum = (u8)PageNum_128(TxDescLen + BeaconLength); - /*If we don't add 1 more page, the WOWLAN function has a problem. Baron thinks it's a bug of firmware */ - if (CurtPktPageNum == 1) - CurtPktPageNum += 1; - TotalPageNum += CurtPktPageNum; - - BufIndex += (CurtPktPageNum * PageSize); - - /* Jump to lastest page */ - if (BufIndex < (MaxRsvdPageBufSize - PageSize)) { - BufIndex = TxDescOffset + (MaxRsvdPageBufSize - PageSize); - TotalPageNum = BCNQ_PAGE_NUM_8188F - 1; - } - - /*3 (6) BT Qos null data */ - RsvdPageLoc.LocBTQosNull = TotalPageNum; - ConstructBtNullFunctionData( - padapter, - &ReservedPagePacket[BufIndex], - &BTQosNullLength, - NULL, - _TRUE, 0, 0, _FALSE); - rtl8188f_fill_fake_txdesc(padapter, &ReservedPagePacket[BufIndex - TxDescLen], BTQosNullLength, _FALSE, _TRUE, _FALSE); - - CurtPktPageNum = (u8)PageNum_128(TxDescLen + BTQosNullLength); - - TotalPageNum += CurtPktPageNum; - - TotalPacketLen = BufIndex + BTQosNullLength; - if (TotalPacketLen > MaxRsvdPageBufSize) { - DBG_8192C(FUNC_ADPT_FMT ": ERROR: The rsvd page size is not enough!!TotalPacketLen %d, MaxRsvdPageBufSize %d\n", - FUNC_ADPT_ARG(padapter), TotalPacketLen, MaxRsvdPageBufSize); - goto error; - } - - /* update attribute */ - pattrib = &pcmdframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - pattrib->qsel = QSLT_BEACON; - pattrib->pktlen = pattrib->last_txcmdsz = TotalPacketLen - TxDescOffset; -#ifdef CONFIG_PCI_HCI - dump_mgntframe(padapter, pcmdframe); -#else - dump_mgntframe_and_wait(padapter, pcmdframe, 100); -#endif - - /*DBG_8192C(FUNC_ADPT_FMT ": Set RSVD page location to Fw, TotalPacketLen(%d), TotalPageNum(%d)\n", */ - /* FUNC_ADPT_ARG(padapter), TotalPacketLen, TotalPageNum); */ - rtl8188f_set_FwRsvdPage_cmd(padapter, &RsvdPageLoc); - rtl8188f_set_FwAoacRsvdPage_cmd(padapter, &RsvdPageLoc); - - return; - -error: - rtw_free_xmitframe(pxmitpriv, pcmdframe); -} - -void rtl8188f_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter) -{ - PHAL_DATA_TYPE pHalData; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - u8 bRecover = _FALSE; - u8 bcn_valid = _FALSE; - u8 DLBcnCount = 0; - u32 poll = 0; - u8 val8; - - - DBG_8192C("+" FUNC_ADPT_FMT ": iface_type=%d fw_state=0x%08X\n", - FUNC_ADPT_ARG(padapter), get_iface_type(padapter), get_fwstate(&padapter->mlmepriv)); - -#ifdef CONFIG_DEBUG - if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _FALSE) { - DBG_8192C(FUNC_ADPT_FMT ": [WARNING] not in AP mode!!\n", - FUNC_ADPT_ARG(padapter)); - } -#endif /* CONFIG_DEBUG */ - - pHalData = GET_HAL_DATA(padapter); - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - - /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ - /* Suggested by filen. Added by tynli. */ - rtw_write16(padapter, REG_BCN_PSR_RPT, (0xC000 | pmlmeinfo->aid)); - - /* set REG_CR bit 8 */ - val8 = rtw_read8(padapter, REG_CR + 1); - val8 |= BIT(0); /* ENSWBCN */ - rtw_write8(padapter, REG_CR + 1, val8); - - /* Disable Hw protection for a time which revserd for Hw sending beacon. */ - /* Fix download reserved page packet fail that access collision with the protection time. */ - /* 2010.05.11. Added by tynli. */ - val8 = rtw_read8(padapter, REG_BCN_CTRL); - val8 &= ~EN_BCN_FUNCTION; - val8 |= DIS_TSF_UDT; - rtw_write8(padapter, REG_BCN_CTRL, val8); - - /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ - if (pHalData->RegFwHwTxQCtrl & BIT(6)) - bRecover = _TRUE; - - /* To tell Hw the packet is not a real beacon frame. */ - pHalData->RegFwHwTxQCtrl &= ~BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL + 2, pHalData->RegFwHwTxQCtrl); - - /* Clear beacon valid check bit. */ - rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); - rtw_hal_set_hwreg(padapter, HW_VAR_DL_BCN_SEL, NULL); - - DLBcnCount = 0; - poll = 0; - do { - SetFwRsvdPagePkt_BTCoex(padapter); - DLBcnCount++; - do { - rtw_yield_os(); - /*rtw_mdelay_os(10); */ - /* check rsvd page download OK. */ - rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, &bcn_valid); - poll++; - } while (!bcn_valid && (poll % 10) != 0 && !RTW_CANNOT_RUN(padapter)); - } while (!bcn_valid && (DLBcnCount <= 100) && !RTW_CANNOT_RUN(padapter)); - - if (_TRUE == bcn_valid) { - struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); - pwrctl->fw_psmode_iface_id = padapter->iface_id; - DBG_8192C(ADPT_FMT": DL RSVD page success! DLBcnCount:%d, poll:%d\n", - ADPT_ARG(padapter), DLBcnCount, poll); - } else { - DBG_871X(ADPT_FMT": DL RSVD page fail! DLBcnCount:%d, poll:%d\n", - ADPT_ARG(padapter), DLBcnCount, poll); - DBG_871X(ADPT_FMT": DL RSVD page fail! bSurpriseRemoved=%s\n", - ADPT_ARG(padapter), rtw_is_surprise_removed(padapter)?"True":"False"); - DBG_871X(ADPT_FMT": DL RSVD page fail! bDriverStopped=%s\n", - ADPT_ARG(padapter), rtw_is_drv_stopped(padapter)?"True":"False"); - } - - /* 2010.05.11. Added by tynli. */ - val8 = rtw_read8(padapter, REG_BCN_CTRL); - val8 |= EN_BCN_FUNCTION; - val8 &= ~DIS_TSF_UDT; - rtw_write8(padapter, REG_BCN_CTRL, val8); - - /* To make sure that if there exists an adapter which would like to send beacon. */ - /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ - /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ - /* the beacon cannot be sent by HW. */ - /* 2010.06.23. Added by tynli. */ - if (bRecover) { - pHalData->RegFwHwTxQCtrl |= BIT(6); - rtw_write8(padapter, REG_FWHW_TXQ_CTRL + 2, pHalData->RegFwHwTxQCtrl); - } - - /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ - val8 = rtw_read8(padapter, REG_CR + 1); - val8 &= ~BIT(0); /* ~ENSWBCN */ - rtw_write8(padapter, REG_CR + 1, val8); -} -#endif /* CONFIG_BT_COEXIST */ - #ifdef CONFIG_P2P void rtl8188f_set_p2p_ps_offload_cmd(_adapter *padapter, u8 p2p_ps_state) { diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_dm.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_dm.c index 9d5b0d435..806ad0cf4 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_dm.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_dm.c @@ -290,15 +290,6 @@ static void Update_ODM_ComInfo_8188f(PADAPTER Adapter) SupportAbility |= ODM_BB_ANT_DIV; #endif -#if (MP_DRIVER==1) - if (Adapter->registrypriv.mp_mode == 1) { - SupportAbility = 0 - | ODM_RF_CALIBRATION - | ODM_RF_TX_PWR_TRACK - ; - } -#endif/*(MP_DRIVER==1) */ - #ifdef CONFIG_DISABLE_ODM SupportAbility = 0; #endif/*CONFIG_DISABLE_ODM */ @@ -415,10 +406,6 @@ rtl8188f_HalDmWatchDog( PADAPTER pbuddy_adapter = Adapter->pbuddy_adapter; #endif /*CONFIG_CONCURRENT_MODE */ - if (Adapter->registrypriv.mp_mode == 1 && Adapter->mppriv.mp_dm == 0) /* for MP power tracking */ - return; - - if (!rtw_is_hw_init_completed(Adapter)) goto skip_dm; @@ -482,9 +469,6 @@ rtl8188f_HalDmWatchDog( /*FindMinimumRSSI_8188f(Adapter); */ /*ODM_CmnInfoUpdate(&pHalData->odmpriv ,ODM_CMNINFO_RSSI_MIN, pHalData->MinUndecoratedPWDBForDM); */ -#ifdef CONFIG_BT_COEXIST - bBtDisabled = rtw_btcoex_IsBtDisabled(Adapter); -#endif /* CONFIG_BT_COEXIST */ ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_BT_ENABLED, ((bBtDisabled == _TRUE) ? _FALSE : _TRUE)); ODM_DMWatchdog(&pHalData->odmpriv); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_hal_init.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_hal_init.c index 4ebf83347..3a6d13dde 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_hal_init.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_hal_init.c @@ -840,95 +840,6 @@ int ReservedPage_Compare(PADAPTER Adapter, PRT_MP_FIRMWARE pFirmware, u32 BTPatc return _TRUE; } -#ifdef CONFIG_BT_COEXIST -/* As the size of bt firmware is more than 16k which is too big for some platforms, we divide it - * into four parts to transfer. The last parameter of _WriteBTFWtoTxPktBuf8188F is used to indicate - * the location of every part. We call the first 4096 byte of bt firmware as part 1, the second 4096 - * part as part 2, the third 4096 part as part 3, the remain as part 4. First we transform the part - * 4 and set the register 0x209 to 0x90, then the 32 bytes description are added to the head of part - * 4, and those bytes are putted at the location 0x90. Second we transform the part 3 and set the - * register 0x209 to 0x70. The 32 bytes description and part 3(4196 bytes) are putted at the location - * 0x70. It can contain 4196 bytes between 0x70 and 0x90. So the last 32 bytes os part 3 will cover the - * 32 bytes description of part4. Using this method, we can put the whole bt firmware to 0x30 and only - * has 32 bytes descrption at the head of part 1. -*/ -s32 FirmwareDownloadBT(PADAPTER padapter, PRT_MP_FIRMWARE pFirmware) -{ - s32 rtStatus; - u8 *pBTFirmwareBuf; - u32 BTFirmwareLen; - u8 download_time; - s8 i; - - - rtStatus = _SUCCESS; - pBTFirmwareBuf = NULL; - BTFirmwareLen = 0; - - /* */ - /* Patch BT Fw. Download BT RAM code to Tx packet buffer. */ - /* */ - if (padapter->bBTFWReady) { - DBG_8192C("%s: BT Firmware is ready!!\n", __func__); - return _FAIL; - } - -#ifdef CONFIG_FILE_FWIMG - if (rtw_is_file_readable(rtw_fw_mp_bt_file_path) == _TRUE) { - DBG_8192C("%s: acquire MP BT FW from file:%s\n", __func__, rtw_fw_mp_bt_file_path); - - rtStatus = rtw_retrieve_from_file(rtw_fw_mp_bt_file_path, FwBuffer, FW_8188F_SIZE); - BTFirmwareLen = rtStatus >= 0 ? rtStatus : 0; - pBTFirmwareBuf = FwBuffer; - } else -#endif /* CONFIG_FILE_FWIMG */ - { -#ifdef CONFIG_EMBEDDED_FWIMG - DBG_8192C("%s: Download MP BT FW from header\n", __func__); - - pBTFirmwareBuf = (u8 *)Rtl8188FFwBTImgArray; - BTFirmwareLen = Rtl8188FFwBTImgArrayLength; - pFirmware->szFwBuffer = pBTFirmwareBuf; - pFirmware->ulFwLength = BTFirmwareLen; -#endif /* CONFIG_EMBEDDED_FWIMG */ - } - - DBG_8192C("%s: MP BT Firmware size=%d\n", __func__, BTFirmwareLen); - - /* for h2c cam here should be set to true */ - padapter->bFWReady = _TRUE; - - download_time = (BTFirmwareLen + 4095) / 4096; - DBG_8192C("%s: download_time is %d\n", __func__, download_time); - - /* Download BT patch Fw. */ - for (i = (download_time - 1); i >= 0; i--) { - if (i == (download_time - 1)) { - rtStatus = _WriteBTFWtoTxPktBuf8188F(padapter, pBTFirmwareBuf + (4096 * i), (BTFirmwareLen - (4096 * i)), 1); - DBG_8192C("%s: start %d, len %d, time 1\n", __func__, 4096 * i, BTFirmwareLen - (4096 * i)); - } else { - rtStatus = _WriteBTFWtoTxPktBuf8188F(padapter, pBTFirmwareBuf + (4096 * i), 4096, (download_time - i)); - DBG_8192C("%s: start %d, len 4096, time %d\n", __func__, 4096 * i, download_time - i); - } - - if (rtStatus != _SUCCESS) { - DBG_8192C("%s: BT Firmware download to Tx packet buffer fail!\n", __func__); - padapter->bBTFWReady = _FALSE; - return rtStatus; - } - } - - ReservedPage_Compare(padapter, pFirmware, BTFirmwareLen); - - padapter->bBTFWReady = _TRUE; - SetFwBTFwPatchCmd(padapter, (u16)BTFirmwareLen); - rtStatus = _CheckWLANFwPatchBTFwReady(padapter); - - DBG_8192C("<===%s: return %s!\n", __func__, rtStatus == _SUCCESS ? "SUCCESS" : "FAIL"); - - return rtStatus; -} -#endif /* CONFIG_BT_COEXIST */ #endif /* CONFIG_MP_INCLUDED */ #if defined(CONFIG_USB_HCI) || defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI) @@ -1116,10 +1027,6 @@ s32 rtl8188f_FirmwareDownload(PADAPTER padapter, BOOLEAN bUsedqFw) } } -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_PreLoadFirmware(padapter); -#endif - dev_info(&psdpriv->pusbdev->dev, "request firmware %s\n",fw_name); if (request_firmware(&fw, fw_name, &psdpriv->pusbdev->dev)) { dev_err(&psdpriv->pusbdev->dev, "Firmware %s not available\n", fw_name); @@ -2876,10 +2783,6 @@ void rtl8188f_InitBeaconParameters(PADAPTER padapter) val8 = DIS_TSF_UDT; val16 = val8 | (val8 << 8); /* port0 and port1 */ -#ifdef CONFIG_BT_COEXIST - /* Enable prot0 beacon function for PSTDMA */ - val16 |= EN_BCN_FUNCTION; -#endif rtw_write16(padapter, REG_BCN_CTRL, val16); /* TODO: Remove these magic number */ @@ -3144,22 +3047,8 @@ void UpdateHalRAMask8188F(PADAPTER padapter, u32 mac_id, u8 rssi_level) mask &= rate_bitmap; -#ifdef CONFIG_BT_COEXIST - rate_bitmap = rtw_btcoex_GetRaMask(padapter); - mask &= ~rate_bitmap; -#endif /* CONFIG_BT_COEXIST */ #ifdef CONFIG_CMCC_TEST -#ifdef CONFIG_BT_COEXIST - if (pmlmeext->cur_wireless_mode & WIRELESS_11G) { - if (mac_id == 0) { - DBG_871X("CMCC_BT update raid entry, mask=0x%x\n", mask); - /*mask &=0xffffffc0; //disable CCK & <12M OFDM rate for 11G mode for CMCC */ - mask &= 0xffffff00; /*disable CCK & <24M OFDM rate for 11G mode for CMCC */ - DBG_871X("CMCC_BT update raid entry, mask=0x%x\n", mask); - } - } -#endif #endif if (pHalData->fw_ractrl == _TRUE) @@ -5169,11 +5058,6 @@ static void hw_var_set_bcn_func(PADAPTER padapter, u8 variable, u8 *val) u8 val8; val8 = rtw_read8(padapter, bcn_ctrl_reg); val8 &= ~(EN_BCN_FUNCTION | EN_TXBCN_RPT); -#ifdef CONFIG_BT_COEXIST - /* Always enable port0 beacon function for PSTDMA */ - if (REG_BCN_CTRL == bcn_ctrl_reg) - val8 |= EN_BCN_FUNCTION; -#endif rtw_write8(padapter, bcn_ctrl_reg, val8); } } @@ -5755,12 +5639,6 @@ s32 c2h_handler_8188f(PADAPTER padapter, u8 *buf) /*CCX_FwC2HTxRpt(padapter, QueueID, pC2hEvent->payload); */ break; -#ifdef CONFIG_BT_COEXIST - case C2H_BT_INFO: - rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->plen, pC2hEvent->payload); - break; -#endif - #ifdef CONFIG_RTW_CUSTOMER_STR case C2H_CUSTOMER_STR_RPT: c2h_customer_str_rpt_hdl(padapter, pC2hEvent->payload, pC2hEvent->plen); @@ -5810,12 +5688,6 @@ static void process_c2h_event(PADAPTER padapter, PC2H_EVT_HDR pC2hEvent, u8 *c2h break; -#ifdef CONFIG_BT_COEXIST - case C2H_BT_INFO: - rtw_btcoex_BtInfoNotify(padapter, pC2hEvent->CmdLen, c2hBuf); - break; -#endif - /* #ifdef CONFIG_MP_INCLUDED case C2H_BT_MP_INFO: @@ -6129,30 +6001,10 @@ void SetHwReg8188F(PADAPTER padapter, u8 variable, u8 *val) case HW_VAR_MLME_SITESURVEY: hw_var_set_mlme_sitesurvey(padapter, variable, val); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_ScanNotify(padapter, *val ? _TRUE : _FALSE); -#endif /* CONFIG_BT_COEXIST */ break; case HW_VAR_MLME_JOIN: hw_var_set_mlme_join(padapter, variable, val); - -#ifdef CONFIG_BT_COEXIST - switch (*val) { - case 0: - /* prepare to join */ - rtw_btcoex_ConnectNotify(padapter, _TRUE); - break; - case 1: - /* joinbss_event callback when join res < 0 */ - rtw_btcoex_ConnectNotify(padapter, _FALSE); - break; - case 2: - /* sta add event callback */ - /*rtw_btcoex_MediaStatusNotify(padapter, RT_MEDIA_CONNECT); */ - break; - } -#endif /* CONFIG_BT_COEXIST */ break; case HW_VAR_ON_RCR_AM: @@ -6507,11 +6359,6 @@ void SetHwReg8188F(PADAPTER padapter, u8 variable, u8 *val) break; case HW_VAR_DL_RSVD_PAGE: -#ifdef CONFIG_BT_COEXIST - if (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE) == _TRUE) - rtl8188f_download_BTCoex_AP_mode_rsvd_page(padapter); - else -#endif /* CONFIG_BT_COEXIST */ { rtl8188f_download_rsvd_page(padapter, RT_MEDIA_CONNECT); } @@ -7015,40 +6862,5 @@ void rtl8188f_stop_thread(_adapter *padapter) #endif } -#if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST) -extern void check_bt_status_work(void *data); -void rtl8188fs_init_checkbthang_workqueue(_adapter *adapter) -{ -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) - adapter->priv_checkbt_wq = alloc_workqueue("sdio_wq", 0, 0); -#else - adapter->priv_checkbt_wq = create_workqueue("sdio_wq"); -#endif - INIT_DELAYED_WORK(&adapter->checkbt_work, (void *)check_bt_status_work); -} - -void rtl8188fs_free_checkbthang_workqueue(_adapter *adapter) -{ - if (adapter->priv_checkbt_wq) { - cancel_delayed_work_sync(&adapter->checkbt_work); - flush_workqueue(adapter->priv_checkbt_wq); - destroy_workqueue(adapter->priv_checkbt_wq); - adapter->priv_checkbt_wq = NULL; - } -} - -void rtl8188fs_cancle_checkbthang_workqueue(_adapter *adapter) -{ - if (adapter->priv_checkbt_wq) - cancel_delayed_work_sync(&adapter->checkbt_work); -} - -void rtl8188fs_hal_check_bt_hang(_adapter *adapter) -{ - if (adapter->priv_checkbt_wq) - queue_delayed_work(adapter->priv_checkbt_wq, &(adapter->checkbt_work), 0); -} -#endif - diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_phycfg.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_phycfg.c index 40fe483db..e6542cb16 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_phycfg.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_phycfg.c @@ -477,10 +477,6 @@ s32 PHY_MACConfig8188F(PADAPTER Adapter) /* */ /* Config MAC */ /* */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - rtStatus = phy_ConfigMACWithParaFile(Adapter, PHY_FILE_MAC_REG); - if (rtStatus == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG ODM_ConfigMACWithHeaderFile(&pHalData->odmpriv); @@ -547,9 +543,6 @@ phy_BB8188f_Config_ParaFile( /* */ /* 1. Read PHY_REG.TXT BB INIT!! */ /* */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (phy_ConfigBBWithParaFile(Adapter, PHY_FILE_PHY_REG, CONFIG_BB_PHY_REG) == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG)) @@ -562,34 +555,9 @@ phy_BB8188f_Config_ParaFile( goto phy_BB8190_Config_ParaFile_Fail; } -#if MP_DRIVER == 1 - if (Adapter->registrypriv.mp_mode == 1) { - /* */ - /* 1.1 Read PHY_REG_MP.TXT BB INIT!! */ - /* */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (phy_ConfigBBWithMpParaFile(Adapter, PHY_FILE_PHY_REG_MP) == _FAIL) -#endif - { -#ifdef CONFIG_EMBEDDED_FWIMG - if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG_MP)) - rtStatus = _FAIL; -#endif - } - - if (rtStatus != _SUCCESS) { - DBG_8192C("%s():Write BB Reg MP Fail!!", __func__); - goto phy_BB8190_Config_ParaFile_Fail; - } - } -#endif /* #if (MP_DRIVER == 1) */ - /* */ /* 2. Read BB AGC table Initialization */ /* */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (phy_ConfigBBWithParaFile(Adapter, PHY_FILE_AGC_TAB, CONFIG_BB_AGC_TAB) == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_SUCCESS != ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB)) diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_rf6052.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_rf6052.c index 60c3d440d..399182445 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_rf6052.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/rtl8188f_rf6052.c @@ -197,9 +197,6 @@ phy_RF6052_Config_ParaFile( /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { case RF_PATH_A: -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (PHY_ConfigRFWithParaFile(Adapter, PHY_FILE_RADIO_A, eRFPath) == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) @@ -208,9 +205,6 @@ phy_RF6052_Config_ParaFile( } break; case RF_PATH_B: -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (PHY_ConfigRFWithParaFile(Adapter, PHY_FILE_RADIO_B, eRFPath) == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, (ODM_RF_RADIO_PATH_E)eRFPath)) @@ -247,9 +241,6 @@ phy_RF6052_Config_ParaFile( /*3 Configuration of Tx Power Tracking */ /*3 ----------------------------------------------------------------- */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - if (PHY_ConfigRFWithTxPwrTrackParaFile(Adapter, PHY_FILE_TXPWR_TRACK) == _FAIL) -#endif { #ifdef CONFIG_EMBEDDED_FWIMG ODM_ConfigRFWithTxPwrTrackHeaderFile(&pHalData->odmpriv); diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/rtl8188fu_xmit.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/rtl8188fu_xmit.c index 823c5182c..dda532f3c 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/rtl8188fu_xmit.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/rtl8188fu_xmit.c @@ -29,7 +29,7 @@ s32 rtl8188fu_init_xmit_priv(_adapter *padapter) #ifdef PLATFORM_LINUX tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))rtl8188fu_xmit_tasklet, + (void *)rtl8188fu_xmit_tasklet, (unsigned long)padapter); #endif return _SUCCESS; diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_halinit.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_halinit.c index f0cad0c9f..ef9dc9695 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_halinit.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_halinit.c @@ -158,30 +158,6 @@ static u32 _InitPowerOn_8188FU(PADAPTER padapter) | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); rtw_write16(padapter, REG_CR_8188F, value16); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_PowerOnSetting(padapter); - - /* external switch to S1 */ - /* 0x38[11] = 0x1 */ - /* 0x4c[23] = 0x1 */ - /* 0x64[0] = 0 */ - value16 = rtw_read16(padapter, REG_PWR_DATA); - /* Switch the control of EESK, EECS to RFC for DPDT or Antenna switch */ - value16 |= BIT(11); /* BIT_EEPRPAD_RFE_CTRL_EN */ - rtw_write16(padapter, REG_PWR_DATA, value16); - /*DBG_8192C("%s: REG_PWR_DATA(0x%x)=0x%04X\n", __func__, REG_PWR_DATA, rtw_read16(padapter, REG_PWR_DATA)); */ - - value32 = rtw_read32(padapter, REG_LEDCFG0); - value32 |= BIT(23); /* DPDT_SEL_EN, 1 for SW control */ - rtw_write32(padapter, REG_LEDCFG0, value32); - /*DBG_8192C("%s: REG_LEDCFG0(0x%x)=0x%08X\n", __func__, REG_LEDCFG0, rtw_read32(padapter, REG_LEDCFG0)); */ - - value8 = rtw_read8(padapter, REG_PAD_CTRL1_8188F); - value8 &= ~BIT(0); /* BIT_SW_DPDT_SEL_DATA, DPDT_SEL default configuration */ - rtw_write8(padapter, REG_PAD_CTRL1_8188F, value8); - /*DBG_8192C("%s: REG_PAD_CTRL1(0x%x)=0x%02X\n", __func__, REG_PAD_CTRL1_8188F, rtw_read8(padapter, REG_PAD_CTRL1_8188F)); */ -#endif /* CONFIG_BT_COEXIST */ - return status; } @@ -232,11 +208,6 @@ static u8 _LLTWrite( */ static void _InitInterrupt(PADAPTER padapter) { -#ifdef CONFIG_SUPPORT_USB_INT - /* clear interrupt, write 1 clear */ - rtw_write32(padapter, REG_HISR0_8188F, 0xFFFFFFFF); - rtw_write32(padapter, REG_HISR1_8188F, 0xFFFFFFFF); -#endif /* CONFIG_SUPPORT_USB_INT */ } static void _InitQueueReservedPage(PADAPTER padapter) @@ -764,7 +735,9 @@ static void usb_AggSettingRxUpdate(PADAPTER padapter) aggctrl &= ~RXDMA_AGG_EN; aggrx &= ~BIT_USB_RXDMA_AGG_EN; rxdmamode &= ~BIT_DMA_MODE; +#if defined(fallthrough) fallthrough; +#endif default: DBG_8192C("%s: RX Aggregation Disable!\n", __func__); break; @@ -1213,23 +1186,6 @@ u32 rtl8188fu_hal_init(PADAPTER padapter) /*InitHalDm(Adapter); */ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_DOWNLOAD_FW); - if (padapter->registrypriv.mp_mode == 0 - #if defined(CONFIG_MP_INCLUDED) && defined(CONFIG_RTW_CUSTOMER_STR) - || padapter->registrypriv.mp_customer_str - #endif - ) { - status = rtl8188f_FirmwareDownload(padapter, _FALSE); - if (status != _SUCCESS) { - padapter->bFWReady = _FALSE; - pHalData->fw_ractrl = _FALSE; - DBG_871X("fw download fail!\n"); - goto exit; - } else { - padapter->bFWReady = _TRUE; - pHalData->fw_ractrl = _TRUE; - DBG_871X("fw download ok!\n"); - } - } if (pwrctrlpriv->reg_rfoff == _TRUE) pwrctrlpriv->rf_pwrstate = rf_off; @@ -1372,12 +1328,6 @@ u32 rtl8188fu_hal_init(PADAPTER padapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8188f_InitHalDm(padapter); -#if (MP_DRIVER == 1) - if (padapter->registrypriv.mp_mode == 1) { - padapter->mppriv.channel = pHalData->CurrentChannel; - MPT_InitializeAdapter(padapter, padapter->mppriv.channel); - } else -#endif { pwrctrlpriv->rf_pwrstate = rf_on; @@ -1391,35 +1341,10 @@ u32 rtl8188fu_hal_init(PADAPTER padapter) PHY_LCCalibrate_8188F(&pHalData->odmpriv); -#ifdef CONFIG_BT_COEXIST - /* Inform WiFi FW that it is the beginning of IQK */ - h2cCmdBuf = 1; - FillH2CCmd8188F(padapter, H2C_8188F_BT_WLAN_CALIBRATION, 1, &h2cCmdBuf); - - start_time = rtw_get_current_time(); - do { - if (rtw_read8(padapter, 0x1e7) & 0x01) - break; - - rtw_msleep_os(50); - } while (rtw_get_passing_time_ms(start_time) <= 400); - - - rtw_btcoex_IQKNotify(padapter, _TRUE); -#endif - restore_iqk_rst = (pwrpriv->bips_processing == _TRUE) ? _TRUE : _FALSE; PHY_IQCalibrate_8188F(padapter, _FALSE, restore_iqk_rst); pHalData->odmpriv.RFCalibrateInfo.bIQKInitialized = _TRUE; -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IQKNotify(padapter, _FALSE); - - /* Inform WiFi FW that it is the finish of IQK */ - h2cCmdBuf = 0; - FillH2CCmd8188F(padapter, H2C_8188F_BT_WLAN_CALIBRATION, 1, &h2cCmdBuf); -#endif - ODM_TXPowerTrackingCheck(&pHalData->odmpriv); } } @@ -1431,12 +1356,7 @@ u32 rtl8188fu_hal_init(PADAPTER padapter) /* _InitPABias(Adapter); */ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BT_COEXIST); -#ifdef CONFIG_BT_COEXIST - /* Init BT hw config. */ - rtw_btcoex_HAL_Initialize(padapter, _FALSE); -#else /* rtw_btcoex_HAL_Initialize(padapter, _TRUE); // For Test. */ -#endif #if 0 /* 2010/05/20 MH We need to init timer after update setting. Otherwise, we can not get correct inf setting. */ @@ -1967,11 +1887,6 @@ u32 rtl8188fu_hal_deinit(PADAPTER Adapter) rtw_write32(Adapter, REG_HIMR1_8188F, IMR_DISABLED_8188F); #endif -#ifdef CONFIG_MP_INCLUDED - if (Adapter->registrypriv.mp_mode == 1) - MPT_DeInitAdapter(Adapter); -#endif - #ifdef SUPPORT_HW_RFOFF_DETECTED DBG_871X("%s: bkeepfwalive(%x)\n", __func__, pwrctl->bkeepfwalive); @@ -2003,10 +1918,6 @@ unsigned int rtl8188fu_inirp_init(PADAPTER Adapter) struct recv_priv *precvpriv = &(Adapter->recvpriv); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); -#endif /*CONFIG_USB_INTERRUPT_IN_PIPE */ _func_enter_; @@ -2031,17 +1942,6 @@ unsigned int rtl8188fu_inirp_init(PADAPTER Adapter) precvpriv->free_recv_buf_queue_cnt--; } -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - _read_interrupt = pintfhdl->io_ops._read_interrupt; - if (_read_interrupt(pintfhdl, RECV_INT_IN_ADDR) == _FALSE) { - RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_interrupt error\n")); - status = _FAIL; - } - pHalData->IntrMask[0] = rtw_read32(Adapter, REG_USB_HIMR); - MSG_8192C("pHalData->IntrMask = 0x%04x\n", pHalData->IntrMask[0]); - pHalData->IntrMask[0] |= UHIMR_C2HCMD | UHIMR_CPWM; - rtw_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); -#endif /*CONFIG_USB_INTERRUPT_IN_PIPE */ exit: @@ -2055,20 +1955,9 @@ exit: unsigned int rtl8188fu_inirp_deinit(PADAPTER Adapter) { -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(Adapter); -#endif /*CONFIG_USB_INTERRUPT_IN_PIPE */ RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); rtw_read_port_cancel(Adapter); -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - pHalData->IntrMask[0] = rtw_read32(Adapter, REG_USB_HIMR); - MSG_8192C("%s pHalData->IntrMask = 0x%04x\n", __func__, pHalData->IntrMask[0]); - pHalData->IntrMask[0] = 0x0; - rtw_write32(Adapter, REG_USB_HIMR, pHalData->IntrMask[0]); - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); -#endif /*CONFIG_USB_INTERRUPT_IN_PIPE */ return _SUCCESS; } @@ -2545,9 +2434,6 @@ void rtl8188fu_set_hal_ops(_adapter *padapter) #ifdef CONFIG_XMIT_THREAD_MODE pHalFunc->xmit_thread_handler = &rtl8188fu_xmit_buf_handler; #endif -#ifdef CONFIG_SUPPORT_USB_INT - pHalFunc->interrupt_handler = interrupt_handler_8188fu; -#endif _func_exit_; } diff --git a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_ops.c b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_ops.c index 2814eab27..c7d1165c4 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_ops.c +++ b/drivers/net/wireless/realtek/rtl8188fu/hal/rtl8188f/usb/usb_ops.c @@ -20,110 +20,6 @@ #include -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct reportpwrstate_parm pwr_rpt; - - if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { - DBG_8192C("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); - return; - } - - /* HISR */ - _rtw_memcpy(&(pHalData->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); - _rtw_memcpy(&(pHalData->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); - -#if 0 /*DBG */ - { - u32 hisr = 0 , hisr_ex = 0; - - _rtw_memcpy(&hisr, &(pHalData->IntArray[0]), 4); - hisr = le32_to_cpu(hisr); - - _rtw_memcpy(&hisr_ex, &(pHalData->IntArray[1]), 4); - hisr_ex = le32_to_cpu(hisr_ex); - - if ((hisr != 0) || (hisr_ex != 0)) - DBG_871X("===> %s hisr:0x%08x ,hisr_ex:0x%08x\n", __func__, hisr, hisr_ex); - } -#endif - - -#ifdef CONFIG_LPS_LCLK - if (pHalData->IntArray[0] & IMR_CPWM_88E) { - _rtw_memcpy(&pwr_rpt.state, &(pbuf[USB_INTR_CONTENT_CPWM1_OFFSET]), 1); - /*_rtw_memcpy(&pwr_rpt.state2, &(pbuf[USB_INTR_CONTENT_CPWM2_OFFSET]), 1); */ - - /*88e's cpwm value only change BIT0, so driver need to add PS_STATE_S2 for LPS flow. */ - pwr_rpt.state |= PS_STATE_S2; - _set_workitem(&(adapter_to_pwrctl(padapter)->cpwm_event)); - } -#endif/*CONFIG_LPS_LCLK */ - -#ifdef CONFIG_INTERRUPT_BASED_TXBCN -#ifdef CONFIG_INTERRUPT_BASED_TXBCN_EARLY_INT - if (pHalData->IntArray[0] & IMR_BCNDMAINT0_88E) - /* suspect code indent for conditional statements */ -#endif -#ifdef CONFIG_INTERRUPT_BASED_TXBCN_BCN_OK_ERR - if (pHalData->IntArray[0] & (IMR_TBDER_88E | IMR_TBDOK_88E)) - /* suspect code indent for conditional statements */ -#endif - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#if 0 - if (pHalData->IntArray[0] & IMR_BCNDMAINT0_88E) - DBG_8192C("%s: HISR_BCNERLY_INT\n", __func__); - if (pHalData->IntArray[0] & IMR_TBDOK_88E) - DBG_8192C("%s: HISR_TXBCNOK\n", __func__); - if (pHalData->IntArray[0] & IMR_TBDER_88E) - DBG_8192C("%s: HISR_TXBCNERR\n", __func__); -#endif - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /*send_beacon(padapter); */ - if (pmlmepriv->update_bcn == _TRUE) { - /*tx_beacon_hdl(padapter, NULL); */ - set_tx_beacon_cmd(padapter); - } - } -#ifdef CONFIG_CONCURRENT_MODE - if (check_buddy_fwstate(padapter, WIFI_AP_STATE)) { - /*send_beacon(padapter); */ - if (padapter->pbuddy_adapter->mlmepriv.update_bcn == _TRUE) { - /*tx_beacon_hdl(padapter, NULL); */ - set_tx_beacon_cmd(padapter->pbuddy_adapter); - } - } -#endif - } -#endif /*CONFIG_INTERRUPT_BASED_TXBCN */ - - - - -#ifdef DBG_CONFIG_ERROR_DETECT_INT - if (pHalData->IntArray[1] & IMR_TXERR_8188F) - DBG_871X("===> %s Tx Error Flag Interrupt Status\n", __func__); - if (pHalData->IntArray[1] & IMR_RXERR_8188F) - DBG_871X("===> %s Rx Error Flag INT Status\n", __func__); - if (pHalData->IntArray[1] & IMR_TXFOVW_8188F) - DBG_871X("===> %s Transmit FIFO Overflow\n", __func__); - if (pHalData->IntArray[1] & IMR_RXFOVW_8188F) - DBG_871X("===> %s Receive FIFO Overflow\n", __func__); -#endif/*DBG_CONFIG_ERROR_DETECT_INT */ - - - /* C2H Event */ - if (pbuf[0] != 0) { - _rtw_memcpy(&(pHalData->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); - /*rtw_c2h_wk_cmd(padapter); to do.. */ - } - -} -#endif - static s32 pre_recv_entry(union recv_frame *precvframe, u8 *pphy_status) { s32 ret = _SUCCESS; @@ -409,8 +305,7 @@ int recvbuf2recvframe(PADAPTER padapter, void *ptr) pattrib = &precvframe->u.hdr.attrib; - if ((padapter->registrypriv.mp_mode == 0) - && ((pattrib->crc_err) || (pattrib->icv_err))) { + if (((pattrib->crc_err) || (pattrib->icv_err))) { DBG_8192C("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); @@ -541,10 +436,6 @@ void rtl8188fu_set_intf_ops(struct _io_ops *pops) pops->_read_port_cancel = &usb_read_port_cancel; pops->_write_port_cancel = &usb_write_port_cancel; -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - pops->_read_interrupt = &usb_read_interrupt; -#endif - _func_exit_; } diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/autoconf.h b/drivers/net/wireless/realtek/rtl8188fu/include/autoconf.h index bec56f8df..d68e24dac 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/autoconf.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/autoconf.h @@ -160,11 +160,6 @@ #define ENABLE_USB_DROP_INCORRECT_OUT -/* #define CONFIG_SUPPORT_USB_INT */ -#ifdef CONFIG_SUPPORT_USB_INT -/* #define CONFIG_USB_INTERRUPT_IN_PIPE */ -#endif - /* #define CONFIG_REDUCE_USB_TX_INT */ /* Trade-off: Improve performance, but may cause TX URBs blocked by USB Host/Bus driver on few platforms. */ /* @@ -238,29 +233,12 @@ /* #define CONFIG_IPS_LEVEL_2 1 */ /*enable this to set default IPS mode to IPS_LEVEL_2 */ #endif - #if defined(CONFIG_LPS) && defined(CONFIG_SUPPORT_USB_INT) - /* #define CONFIG_LPS_LCLK */ - #endif - #ifdef CONFIG_LPS_LCLK #define CONFIG_XMIT_THREAD_MODE #endif #endif /* CONFIG_POWER_SAVING */ -#ifdef CONFIG_BT_COEXIST - /* for ODM and outsrc BT-Coex */ - #define BT_30_SUPPORT 1 - - #ifndef CONFIG_LPS - #define CONFIG_LPS /* download reserved page to FW */ - #endif - - #ifndef CONFIG_C2H_PACKET_EN - #define CONFIG_C2H_PACKET_EN - #endif -#else /* !ONFIG_BT_COEXIST */ #define BT_30_SUPPORT 0 -#endif /* CONFIG_BT_COEXIST */ #ifdef CONFIG_GPIO_WAKEUP #ifndef WAKEUP_GPIO_IDX diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/drv_types.h b/drivers/net/wireless/realtek/rtl8188fu/include/drv_types.h index 704c03238..0e6ddaa58 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/drv_types.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/drv_types.h @@ -150,10 +150,6 @@ typedef struct _ADAPTER _adapter, ADAPTER,*PADAPTER; #include #include -#ifdef CONFIG_BT_COEXIST -#include -#endif // CONFIG_BT_COEXIST - #define SPEC_DEV_ID_NONE BIT(0) #define SPEC_DEV_ID_DISABLE_HT BIT(1) #define SPEC_DEV_ID_ENABLE_PS BIT(2) @@ -197,11 +193,6 @@ struct registry_priv u8 short_retry_lmt; u16 busy_thresh; u8 ack_policy; - u8 mp_mode; -#if defined(CONFIG_MP_INCLUDED) && defined(CONFIG_RTW_CUSTOMER_STR) - u8 mp_customer_str; -#endif - u8 mp_dm; u8 software_encrypt; u8 software_decrypt; #ifdef CONFIG_TX_EARLY_MODE @@ -260,13 +251,6 @@ struct registry_priv char alpha2[2]; u8 channel_plan; u8 full_ch_in_p2p_handshake; /* 0: reply only softap channel, 1: reply full channel list*/ -#ifdef CONFIG_BT_COEXIST - u8 btcoex; - u8 bt_iso; - u8 bt_sco; - u8 bt_ampdu; - s8 ant_num; -#endif BOOLEAN bAcceptAddbaReq; u8 antdiv_cfg; @@ -331,11 +315,6 @@ struct registry_priv u8 check_fw_ps; u8 RegPwrTrimEnable; -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - u8 load_phy_file; - u8 RegDecryptCustomFile; -#endif - #ifdef CONFIG_MULTI_VIR_IFACES u8 ext_iface_num;//primary/secondary iface is excluded #endif @@ -1002,10 +981,6 @@ struct _ADAPTER{ struct wifi_display_info wfd_info; #endif //CONFIG_WFD -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - struct bt_coex_info coex_info; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - ERROR_CODE LastError; /* <20130613, Kordan> Only the functions associated with MP records the error code by now. */ PVOID HalData; diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/hal_btcoex.h b/drivers/net/wireless/realtek/rtl8188fu/include/hal_btcoex.h index dd2eb84f4..cb33a2a95 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/hal_btcoex.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/hal_btcoex.h @@ -87,10 +87,6 @@ void hal_btcoex_SendScanNotify(PADAPTER, u8 type); void hal_btcoex_StackUpdateProfileInfo(void); void hal_btcoex_BTOffOnNotify(PADAPTER padapter, u8 bBTON); void hal_btcoex_SetAntIsolationType(PADAPTER padapter, u8 anttype); -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -int hal_btcoex_AntIsolationConfig_ParaFile(IN PADAPTER Adapter,IN char* pFileName); -int hal_btcoex_ParseAntIsolationConfigFile(PADAPTER Adapter, char* buffer); -#endif // CONFIG_LOAD_PHY_PARA_FROM_FILE u16 hal_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data); u16 hal_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val); #endif // !__HAL_BTCOEX_H__ diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/hal_com.h b/drivers/net/wireless/realtek/rtl8188fu/include/hal_com.h index 206a19359..59c5b8d74 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/hal_com.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/hal_com.h @@ -534,12 +534,6 @@ static inline u32 rtw_phydm_ability_get(_adapter *adapter) return rtw_phydm_ability_ops(adapter, HAL_PHYDM_ABILITY_GET, 0); } -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -extern char *rtw_phy_file_path; -extern char rtw_phy_para_file_path[PATH_LENGTH_MAX]; -#define GetLineFromBuffer(buffer) strsep(&buffer, "\r\n") -#endif - #ifdef CONFIG_FW_C2H_DEBUG void Debug_FwC2H(PADAPTER padapter, u8 *pdata, u8 len); #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/hal_com_phycfg.h b/drivers/net/wireless/realtek/rtl8188fu/include/hal_com_phycfg.h index f3633550b..550d636d6 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/hal_com_phycfg.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/hal_com_phycfg.h @@ -252,52 +252,5 @@ void dump_tx_power_limit(void *sel, _adapter *adapter); int rtw_get_phy_file_path(_adapter *adapter, const char *file_name); -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -#define MAC_FILE_FW_NIC "FW_NIC.bin" -#define MAC_FILE_FW_WW_IMG "FW_WoWLAN.bin" -#define PHY_FILE_MAC_REG "MAC_REG.txt" - -#define PHY_FILE_AGC_TAB "AGC_TAB.txt" -#define PHY_FILE_PHY_REG "PHY_REG.txt" -#define PHY_FILE_PHY_REG_MP "PHY_REG_MP.txt" -#define PHY_FILE_PHY_REG_PG "PHY_REG_PG.txt" - -#define PHY_FILE_RADIO_A "RadioA.txt" -#define PHY_FILE_RADIO_B "RadioB.txt" -#define PHY_FILE_RADIO_C "RadioC.txt" -#define PHY_FILE_RADIO_D "RadioD.txt" -#define PHY_FILE_TXPWR_TRACK "TxPowerTrack.txt" -#define PHY_FILE_TXPWR_LMT "TXPWR_LMT.txt" - -#define PHY_FILE_WIFI_ANT_ISOLATION "wifi_ant_isolation.txt" - -#define MAX_PARA_FILE_BUF_LEN 25600 - -#define LOAD_MAC_PARA_FILE BIT0 -#define LOAD_BB_PARA_FILE BIT1 -#define LOAD_BB_PG_PARA_FILE BIT2 -#define LOAD_BB_MP_PARA_FILE BIT3 -#define LOAD_RF_PARA_FILE BIT4 -#define LOAD_RF_TXPWR_TRACK_PARA_FILE BIT5 -#define LOAD_RF_TXPWR_LMT_PARA_FILE BIT6 - -int phy_ConfigMACWithParaFile(IN PADAPTER Adapter, IN char* pFileName); - -int phy_ConfigBBWithParaFile(IN PADAPTER Adapter, IN char* pFileName, IN u32 ConfigType); - -int phy_ConfigBBWithPgParaFile(IN PADAPTER Adapter, IN const char *pFileName); - -int phy_ConfigBBWithMpParaFile(IN PADAPTER Adapter, IN char* pFileName); - -int PHY_ConfigRFWithParaFile(IN PADAPTER Adapter, IN char* pFileName, IN u8 eRFPath); - -int PHY_ConfigRFWithTxPwrTrackParaFile(IN PADAPTER Adapter, IN char* pFileName); - -int PHY_ConfigRFWithPowerLimitTableParaFile(IN PADAPTER Adapter, IN const char *pFileName); - -void phy_free_filebuf_mask(_adapter *padapter, u8 mask); -void phy_free_filebuf(_adapter *padapter); -#endif /* CONFIG_LOAD_PHY_PARA_FROM_FILE */ - #endif /* __HAL_COMMON_H__ */ diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/hal_data.h b/drivers/net/wireless/realtek/rtl8188fu/include/hal_data.h index 5a41e2564..6ea230432 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/hal_data.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/hal_data.h @@ -23,9 +23,6 @@ #if 1//def CONFIG_SINGLE_IMG #include "../hal/phydm/phydm_precomp.h" -#ifdef CONFIG_BT_COEXIST -#include -#endif #ifdef CONFIG_SDIO_HCI #include @@ -579,11 +576,6 @@ typedef struct hal_com_data struct sreset_priv srestpriv; #endif //#ifdef DBG_CONFIG_ERROR_DETECT -#ifdef CONFIG_BT_COEXIST - // For bluetooth co-existance - BT_COEXIST bt_coexist; -#endif // CONFIG_BT_COEXIST - #if defined(CONFIG_RTL8723B) || defined(CONFIG_RTL8703B) || defined(CONFIG_RTL8188F) #ifndef CONFIG_PCI_HCI // mutual exclusive with PCI -- so they're SDIO and GSPI // Interrupt relatd register information. @@ -592,28 +584,6 @@ typedef struct hal_com_data #endif #endif /*endif CONFIG_RTL8723B */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - char para_file_buf[MAX_PARA_FILE_BUF_LEN]; - char *mac_reg; - u32 mac_reg_len; - char *bb_phy_reg; - u32 bb_phy_reg_len; - char *bb_agc_tab; - u32 bb_agc_tab_len; - char *bb_phy_reg_pg; - u32 bb_phy_reg_pg_len; - char *bb_phy_reg_mp; - u32 bb_phy_reg_mp_len; - char *rf_radio_a; - u32 rf_radio_a_len; - char *rf_radio_b; - u32 rf_radio_b_len; - char *rf_tx_pwr_track; - u32 rf_tx_pwr_track_len; - char *rf_tx_pwr_lmt; - u32 rf_tx_pwr_lmt_len; -#endif - #ifdef CONFIG_BACKGROUND_NOISE_MONITOR s16 noise[ODM_MAX_CHANNEL_NUM]; #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/hal_intf.h b/drivers/net/wireless/realtek/rtl8188fu/include/hal_intf.h index 29a0dcf41..e9f66ec76 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/hal_intf.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/hal_intf.h @@ -22,10 +22,7 @@ enum RTL871X_HCI_TYPE { - RTW_PCIE = BIT0, RTW_USB = BIT1, - RTW_SDIO = BIT2, - RTW_GSPI = BIT3, }; enum _CHIP_TYPE { @@ -269,10 +266,6 @@ struct hal_ops { s32 (*interrupt_handler)(_adapter *padapter); #endif -#if defined(CONFIG_USB_HCI) && defined(CONFIG_SUPPORT_USB_INT) - void (*interrupt_handler)(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif - #if defined(CONFIG_PCI_HCI) void (*irp_reset)(_adapter *padapter); #endif @@ -608,9 +601,6 @@ void rtw_hal_write_rfreg(_adapter *padapter, u32 eRFPath, u32 RegAddr, u32 BitMa #if defined(CONFIG_PCI_HCI) s32 rtw_hal_interrupt_handler(_adapter *padapter); #endif -#if defined(CONFIG_USB_HCI) && defined(CONFIG_SUPPORT_USB_INT) -void rtw_hal_interrupt_handler(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif void rtw_hal_set_bwmode(_adapter *padapter, CHANNEL_WIDTH Bandwidth, u8 Offset); void rtw_hal_set_chan(_adapter *padapter, u8 channel); diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/ieee80211.h b/drivers/net/wireless/realtek/rtl8188fu/include/ieee80211.h index 8ed08a90a..efad58480 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/ieee80211.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/ieee80211.h @@ -1384,29 +1384,22 @@ enum ieee80211_state { #define PORT_FMT "%u" #define PORT_ARG(x) ntohs(*((u16 *)(x))) -#ifdef PLATFORM_FREEBSD //Baron change func to macro -#define is_multicast_mac_addr(Addr) ((((Addr[0]) & 0x01) == 0x01) && ((Addr[0]) != 0xff)) -#define is_broadcast_mac_addr(Addr) ((((Addr[0]) & 0xff) == 0xff) && (((Addr[1]) & 0xff) == 0xff) && \ -(((Addr[2]) & 0xff) == 0xff) && (((Addr[3]) & 0xff) == 0xff) && (((Addr[4]) & 0xff) == 0xff) && \ -(((Addr[5]) & 0xff) == 0xff)) -#else -extern __inline int is_multicast_mac_addr(const u8 *addr) +static inline int is_multicast_mac_addr(const u8 *addr) { return ((addr[0] != 0xff) && (0x01 & addr[0])); } -extern __inline int is_broadcast_mac_addr(const u8 *addr) +static inline int is_broadcast_mac_addr(const u8 *addr) { return ((addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && \ (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff)); } -extern __inline int is_zero_mac_addr(const u8 *addr) +static int is_zero_mac_addr(const u8 *addr) { return ((addr[0] == 0x00) && (addr[1] == 0x00) && (addr[2] == 0x00) && \ (addr[3] == 0x00) && (addr[4] == 0x00) && (addr[5] == 0x00)); } -#endif //PLATFORM_FREEBSD #define CFG_IEEE80211_RESERVE_FCS (1<<0) #define CFG_IEEE80211_COMPUTE_FCS (1<<1) diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_intf.h b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_intf.h index 761fb17d4..b28de8009 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_intf.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_intf.h @@ -124,8 +124,6 @@ u16 rtw_recv_select_queue(struct sk_buff *skb); int rtw_ndev_notifier_register(void); void rtw_ndev_notifier_unregister(void); -#include "../os_dep/linux/rtw_proc.h" - #ifdef CONFIG_IOCTL_CFG80211 #include "../os_dep/linux/ioctl_cfg80211.h" #endif //CONFIG_IOCTL_CFG80211 diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service.h b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service.h index e601e80a7..0409183ad 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service.h @@ -635,3 +635,4 @@ char alpha_to_upper(char c); #endif + diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service_linux.h b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service_linux.h index c6b6ec7c6..a2e913de6 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service_linux.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/osdep_service_linux.h @@ -109,14 +109,6 @@ #endif #endif -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - #include - #include - #include - #include - #include -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - #ifdef CONFIG_USB_HCI typedef struct urb * PURB; #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,22)) @@ -162,7 +154,11 @@ typedef int thread_return; typedef void* thread_context; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) #define thread_exit() complete_and_exit(NULL, 0) +#else + #define thread_exit() kthread_complete_and_exit(NULL, 0) +#endif typedef void timer_hdl_return; typedef void* timer_hdl_context; diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_cmd.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_cmd.h index 66d374d6a..d00abc9ca 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_cmd.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_cmd.h @@ -191,9 +191,6 @@ void rtl8188f_set_FwPsTuneParam_cmd(PADAPTER padapter); void rtl8188f_set_FwMacIdConfig_cmd(_adapter* padapter, u8 mac_id, u8 raid, u8 bw, u8 sgi, u32 mask); void rtl8188f_set_FwBtMpOper_cmd(PADAPTER padapter, u8 idx, u8 ver, u8 reqnum, u8 *param); void rtl8188f_download_rsvd_page(PADAPTER padapter, u8 mstatus); -#ifdef CONFIG_BT_COEXIST -void rtl8188f_download_BTCoex_AP_mode_rsvd_page(PADAPTER padapter); -#endif // CONFIG_BT_COEXIST #ifdef CONFIG_P2P void rtl8188f_set_p2p_ps_offload_cmd(PADAPTER padapter, u8 p2p_ps_state); #endif //CONFIG_P2P diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_hal.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_hal.h index 22024d122..89fc28c83 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_hal.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtl8188f_hal.h @@ -233,13 +233,6 @@ void _8051Reset8188(PADAPTER padapter); void rtl8188f_start_thread(_adapter *padapter); void rtl8188f_stop_thread(_adapter *padapter); -#if defined(CONFIG_CHECK_BT_HANG) && defined(CONFIG_BT_COEXIST) -void rtl8188fs_init_checkbthang_workqueue(_adapter * adapter); -void rtl8188fs_free_checkbthang_workqueue(_adapter * adapter); -void rtl8188fs_cancle_checkbthang_workqueue(_adapter * adapter); -void rtl8188fs_hal_check_bt_hang(_adapter * adapter); -#endif - #ifdef CONFIG_GPIO_WAKEUP void HalSetOutPutGPIO(PADAPTER padapter, u8 index, u8 OutPutValue); #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_btcoex.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_btcoex.h deleted file mode 100644 index b1489c4b6..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_btcoex.h +++ /dev/null @@ -1,436 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __RTW_BTCOEX_H__ -#define __RTW_BTCOEX_H__ - -#include - -/* For H2C: H2C_BT_MP_OPER. Return status definition to the user layer */ -typedef enum _BT_CTRL_STATUS { - BT_STATUS_SUCCESS = 0x00, /* Success */ - BT_STATUS_BT_OP_SUCCESS = 0x01, /* bt fw op execution success */ - BT_STATUS_H2C_SUCCESS = 0x02, /* H2c success */ - BT_STATUS_H2C_FAIL = 0x03, /* H2c fail */ - BT_STATUS_H2C_LENGTH_EXCEEDED = 0x04, /* H2c command length exceeded */ - BT_STATUS_H2C_TIMTOUT = 0x05, /* H2c timeout */ - BT_STATUS_H2C_BT_NO_RSP = 0x06, /* H2c sent, bt no rsp */ - BT_STATUS_C2H_SUCCESS = 0x07, /* C2h success */ - BT_STATUS_C2H_REQNUM_MISMATCH = 0x08, /* bt fw wrong rsp */ - BT_STATUS_OPCODE_U_VERSION_MISMATCH = 0x08, /* Upper layer OP code version mismatch. */ - BT_STATUS_OPCODE_L_VERSION_MISMATCH = 0x0a, /* Lower layer OP code version mismatch. */ - BT_STATUS_UNKNOWN_OPCODE_U = 0x0b, /* Unknown Upper layer OP code */ - BT_STATUS_UNKNOWN_OPCODE_L = 0x0c, /* Unknown Lower layer OP code */ - BT_STATUS_PARAMETER_FORMAT_ERROR_U = 0x0d, /* Wrong parameters sent by upper layer. */ - BT_STATUS_PARAMETER_FORMAT_ERROR_L = 0x0e, /* bt fw parameter format is not consistency */ - BT_STATUS_PARAMETER_OUT_OF_RANGE_U = 0x0f, /* uppery layer parameter value is out of range */ - BT_STATUS_PARAMETER_OUT_OF_RANGE_L = 0x10, /* bt fw parameter value is out of range */ - BT_STATUS_UNKNOWN_STATUS_L = 0x11, /* bt returned an defined status code */ - BT_STATUS_UNKNOWN_STATUS_H = 0x12, /* driver need to do error handle or not handle-well. */ - BT_STATUS_WRONG_LEVEL = 0x13, /* should be under passive level */ - BT_STATUS_NOT_IMPLEMENT = 0x14, /* op code not implemented yet */ - BT_STATUS_BT_STACK_OP_SUCCESS = 0x15, /* bt stack op execution success */ - BT_STATUS_BT_STACK_NOT_SUPPORT = 0x16, /* stack version not support this. */ - BT_STATUS_BT_STACK_SEND_HCI_EVENT_FAIL = 0x17, /* send hci event fail */ - BT_STATUS_BT_STACK_NOT_BIND = 0x18, /* stack not bind wifi driver */ - BT_STATUS_BT_STACK_NO_RSP = 0x19, /* stack doesn't have any rsp. */ - BT_STATUS_MAX -} BT_CTRL_STATUS, *PBT_CTRL_STATUS; - -#define SET_BT_MP_OPER_RET(OpCode, StatusCode) ((OpCode << 8) | StatusCode) -#define GET_OP_CODE_FROM_BT_MP_OPER_RET(RetCode) ((RetCode & 0xF0) >> 8) -#define GET_STATUS_CODE_FROM_BT_MP_OPER_RET(RetCode) (RetCode & 0x0F) -#define CHECK_STATUS_CODE_FROM_BT_MP_OPER_RET(RetCode, StatusCode) (GET_STATUS_CODE_FROM_BT_MP_OPER_RET(RetCode) == StatusCode) - -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - -#define NETLINK_USER 31 -#define CONNECT_PORT 30000 -#define CONNECT_PORT_BT 30001 -#define KERNEL_SOCKET_OK 0x01 -#define NETLINK_SOCKET_OK 0x02 - -#define OTHER 0 -#define RX_ATTEND_ACK 1 -#define RX_LEAVE_ACK 2 -#define RX_BT_LEAVE 3 -#define RX_INVITE_REQ 4 -#define RX_ATTEND_REQ 5 -#define RX_INVITE_RSP 6 - -#define invite_req "INVITE_REQ" -#define invite_rsp "INVITE_RSP" -#define attend_req "ATTEND_REQ" -#define attend_ack "ATTEND_ACK" -#define wifi_leave "WIFI_LEAVE" -#define leave_ack "LEAVE_ACK" -#define bt_leave "BT_LEAVE" - -#define BT_INFO_NOTIFY_CMD 0x0106 -#define BT_INFO_LEN 8 - -typedef struct _HCI_LINK_INFO{ - u2Byte ConnectHandle; - u1Byte IncomingTrafficMode; - u1Byte OutgoingTrafficMode; - u1Byte BTProfile; - u1Byte BTCoreSpec; - s1Byte BT_RSSI; - u1Byte TrafficProfile; - u1Byte linkRole; -}HCI_LINK_INFO, *PHCI_LINK_INFO; - -#define MAX_BT_ACL_LINK_NUM 8 - -typedef struct _HCI_EXT_CONFIG{ - HCI_LINK_INFO aclLink[MAX_BT_ACL_LINK_NUM]; - u1Byte btOperationCode; - u2Byte CurrentConnectHandle; - u1Byte CurrentIncomingTrafficMode; - u1Byte CurrentOutgoingTrafficMode; - - u1Byte NumberOfACL; - u1Byte NumberOfSCO; - u1Byte CurrentBTStatus; - u2Byte HCIExtensionVer; - - BOOLEAN bEnableWifiScanNotify; -}HCI_EXT_CONFIG, *PHCI_EXT_CONFIG; - -typedef struct _HCI_PHY_LINK_BSS_INFO{ - u2Byte bdCap; // capability information - - // Qos related. Added by Annie, 2005-11-01. - //BSS_QOS BssQos; - -}HCI_PHY_LINK_BSS_INFO, *PHCI_PHY_LINK_BSS_INFO; - -typedef enum _BT_CONNECT_TYPE{ - BT_CONNECT_AUTH_REQ =0x00, - BT_CONNECT_AUTH_RSP =0x01, - BT_CONNECT_ASOC_REQ =0x02, - BT_CONNECT_ASOC_RSP =0x03, - BT_DISCONNECT =0x04 -}BT_CONNECT_TYPE,*PBT_CONNECT_TYPE; - - -typedef struct _PACKET_IRP_HCIEVENT_DATA { - u8 EventCode; - u8 Length; //total cmd length = extension event length+1(extension event code length) - u8 Data[1]; // byte1 is extension event code -} rtw_HCI_event; - - -struct btinfo_8761ATV { - u8 cid; - u8 len; - - u8 bConnection:1; - u8 bSCOeSCO:1; - u8 bInQPage:1; - u8 bACLBusy:1; - u8 bSCOBusy:1; - u8 bHID:1; - u8 bA2DP:1; - u8 bFTP:1; - - u8 retry_cnt:4; - u8 rsvd_34:1; - u8 bPage:1; - u8 TRxMask:1; - u8 Sniff_attempt:1; - - u8 rssi; - - u8 A2dp_rate:1; - u8 ReInit:1; - u8 MaxPower:1; - u8 bEnIgnoreWlanAct:1; - u8 TxPowerLow:1; - u8 TxPowerHigh:1; - u8 eSCO_SCO:1; - u8 Master_Slave:1; - - u8 ACL_TRx_TP_low; - u8 ACL_TRx_TP_high; -}; - -#define HCIOPCODE(_OCF, _OGF) ((_OGF)<<10|(_OCF)) -#define HCIOPCODELOW(_OCF, _OGF) (u8)(HCIOPCODE(_OCF, _OGF)&0x00ff) -#define HCIOPCODEHIGHT(_OCF, _OGF) (u8)(HCIOPCODE(_OCF, _OGF)>>8) -#define HCI_OGF(opCode) (unsigned char)((0xFC00 & (opCode)) >> 10) -#define HCI_OCF(opCode) ( 0x3FF & (opCode)) - - -typedef enum _HCI_STATUS{ - HCI_STATUS_SUCCESS =0x00, //Success - HCI_STATUS_UNKNOW_HCI_CMD =0x01, //Unknown HCI Command - HCI_STATUS_UNKNOW_CONNECT_ID =0X02, //Unknown Connection Identifier - HCI_STATUS_HW_FAIL =0X03, //Hardware Failure - HCI_STATUS_PAGE_TIMEOUT =0X04, //Page Timeout - HCI_STATUS_AUTH_FAIL =0X05, //Authentication Failure - HCI_STATUS_PIN_OR_KEY_MISSING =0X06, //PIN or Key Missing - HCI_STATUS_MEM_CAP_EXCEED =0X07, //Memory Capacity Exceeded - HCI_STATUS_CONNECT_TIMEOUT =0X08, //Connection Timeout - HCI_STATUS_CONNECT_LIMIT =0X09, //Connection Limit Exceeded - HCI_STATUS_SYN_CONNECT_LIMIT =0X0a, //Synchronous Connection Limit To A Device Exceeded - HCI_STATUS_ACL_CONNECT_EXISTS =0X0b, //ACL Connection Already Exists - HCI_STATUS_CMD_DISALLOW =0X0c, //Command Disallowed - HCI_STATUS_CONNECT_RJT_LIMIT_RESOURCE =0X0d, //Connection Rejected due to Limited Resources - HCI_STATUS_CONNECT_RJT_SEC_REASON =0X0e, //Connection Rejected Due To Security Reasons - HCI_STATUS_CONNECT_RJT_UNACCEPT_BD_ADDR =0X0f, //Connection Rejected due to Unacceptable BD_ADDR - HCI_STATUS_CONNECT_ACCEPT_TIMEOUT =0X10, //Connection Accept Timeout Exceeded - HCI_STATUS_UNSUPPORT_FEATURE_PARA_VALUE =0X11, //Unsupported Feature or Parameter Value - HCI_STATUS_INVALID_HCI_CMD_PARA_VALUE =0X12, //Invalid HCI Command Parameters - HCI_STATUS_REMOTE_USER_TERMINATE_CONNECT =0X13, //Remote User Terminated Connection - HCI_STATUS_REMOTE_DEV_TERMINATE_LOW_RESOURCE =0X14, //Remote Device Terminated Connection due to Low Resources - HCI_STATUS_REMOTE_DEV_TERMINATE_CONNECT_POWER_OFF =0X15, //Remote Device Terminated Connection due to Power Off - HCI_STATUS_CONNECT_TERMINATE_LOCAL_HOST =0X16, //Connection Terminated By Local Host - HCI_STATUS_REPEATE_ATTEMPT =0X17, //Repeated Attempts - HCI_STATUS_PAIR_NOT_ALLOW =0X18, //Pairing Not Allowed - HCI_STATUS_UNKNOW_LMP_PDU =0X19, //Unknown LMP PDU - HCI_STATUS_UNSUPPORT_REMOTE_LMP_FEATURE =0X1a, //Unsupported Remote Feature / Unsupported LMP Feature - HCI_STATUS_SOC_OFFSET_REJECT =0X1b, //SCO Offset Rejected - HCI_STATUS_SOC_INTERVAL_REJECT =0X1c, //SCO Interval Rejected - HCI_STATUS_SOC_AIR_MODE_REJECT =0X1d,//SCO Air Mode Rejected - HCI_STATUS_INVALID_LMP_PARA =0X1e, //Invalid LMP Parameters - HCI_STATUS_UNSPECIFIC_ERROR =0X1f, //Unspecified Error - HCI_STATUS_UNSUPPORT_LMP_PARA_VALUE =0X20, //Unsupported LMP Parameter Value - HCI_STATUS_ROLE_CHANGE_NOT_ALLOW =0X21, //Role Change Not Allowed - HCI_STATUS_LMP_RESPONSE_TIMEOUT =0X22, //LMP Response Timeout - HCI_STATUS_LMP_ERROR_TRANSACTION_COLLISION =0X23, //LMP Error Transaction Collision - HCI_STATUS_LMP_PDU_NOT_ALLOW =0X24, //LMP PDU Not Allowed - HCI_STATUS_ENCRYPTION_MODE_NOT_ALLOW =0X25, //Encryption Mode Not Acceptable - HCI_STATUS_LINK_KEY_CAN_NOT_CHANGE =0X26, //Link Key Can Not be Changed - HCI_STATUS_REQUEST_QOS_NOT_SUPPORT =0X27, //Requested QoS Not Supported - HCI_STATUS_INSTANT_PASSED =0X28, //Instant Passed - HCI_STATUS_PAIRING_UNIT_KEY_NOT_SUPPORT =0X29, //Pairing With Unit Key Not Supported - HCI_STATUS_DIFFERENT_TRANSACTION_COLLISION =0X2a, //Different Transaction Collision - HCI_STATUS_RESERVE_1 =0X2b, //Reserved - HCI_STATUS_QOS_UNACCEPT_PARA =0X2c, //QoS Unacceptable Parameter - HCI_STATUS_QOS_REJECT =0X2d, //QoS Rejected - HCI_STATUS_CHNL_CLASSIFICATION_NOT_SUPPORT =0X2e, //Channel Classification Not Supported - HCI_STATUS_INSUFFICIENT_SECURITY =0X2f, //Insufficient Security - HCI_STATUS_PARA_OUT_OF_RANGE =0x30, //Parameter Out Of Mandatory Range - HCI_STATUS_RESERVE_2 =0X31, //Reserved - HCI_STATUS_ROLE_SWITCH_PENDING =0X32, //Role Switch Pending - HCI_STATUS_RESERVE_3 =0X33, //Reserved - HCI_STATUS_RESERVE_SOLT_VIOLATION =0X34, //Reserved Slot Violation - HCI_STATUS_ROLE_SWITCH_FAIL =0X35, //Role Switch Failed - HCI_STATUS_EXTEND_INQUIRY_RSP_TOO_LARGE =0X36, //Extended Inquiry Response Too Large - HCI_STATUS_SEC_SIMPLE_PAIRING_NOT_SUPPORT =0X37, //Secure Simple Pairing Not Supported By Host. - HCI_STATUS_HOST_BUSY_PAIRING =0X38, //Host Busy - Pairing - HCI_STATUS_CONNECT_REJ_NOT_SUIT_CHNL_FOUND =0X39, //Connection Rejected due to No Suitable Channel Found - HCI_STATUS_CONTROLLER_BUSY =0X3a //CONTROLLER BUSY -}RTW_HCI_STATUS; - -#define HCI_EVENT_COMMAND_COMPLETE 0x0e - -#define OGF_EXTENSION 0X3f -typedef enum HCI_EXTENSION_COMMANDS{ - HCI_SET_ACL_LINK_DATA_FLOW_MODE =0x0010, - HCI_SET_ACL_LINK_STATUS =0x0020, - HCI_SET_SCO_LINK_STATUS =0x0030, - HCI_SET_RSSI_VALUE =0x0040, - HCI_SET_CURRENT_BLUETOOTH_STATUS =0x0041, - - //The following is for RTK8723 - HCI_EXTENSION_VERSION_NOTIFY =0x0100, - HCI_LINK_STATUS_NOTIFY =0x0101, - HCI_BT_OPERATION_NOTIFY =0x0102, - HCI_ENABLE_WIFI_SCAN_NOTIFY =0x0103, - HCI_QUERY_RF_STATUS =0x0104, - HCI_BT_ABNORMAL_NOTIFY =0x0105, - HCI_BT_INFO_NOTIFY =0x0106, - HCI_BT_COEX_NOTIFY =0x0107, - HCI_BT_PATCH_VERSION_NOTIFY =0x0108, - HCI_BT_AFH_MAP_NOTIFY =0x0109, - HCI_BT_REGISTER_VALUE_NOTIFY =0x010a, - - //The following is for IVT - HCI_WIFI_CURRENT_CHANNEL =0x0300, - HCI_WIFI_CURRENT_BANDWIDTH =0x0301, - HCI_WIFI_CONNECTION_STATUS =0x0302 -}RTW_HCI_EXT_CMD; - -#define HCI_EVENT_EXTENSION_RTK 0xfe -typedef enum HCI_EXTENSION_EVENT_RTK{ - HCI_EVENT_EXT_WIFI_SCAN_NOTIFY =0x01, - HCI_EVENT_EXT_WIFI_RF_STATUS_NOTIFY =0x02, - HCI_EVENT_EXT_BT_INFO_CONTROL =0x03, - HCI_EVENT_EXT_BT_COEX_CONTROL =0x04 -}RTW_HCI_EXT_EVENT; - -typedef enum _BT_TRAFFIC_MODE{ - BT_MOTOR_EXT_BE = 0x00, //Best Effort. Default. for HCRP, PAN, SDP, RFCOMM-based profiles like FTP,OPP, SPP, DUN, etc. - BT_MOTOR_EXT_GUL = 0x01, //Guaranteed Latency. This type of traffic is used e.g. for HID and AVRCP. - BT_MOTOR_EXT_GUB = 0X02, //Guaranteed Bandwidth. - BT_MOTOR_EXT_GULB = 0X03 //Guaranteed Latency and Bandwidth. for A2DP and VDP. -} BT_TRAFFIC_MODE; - -typedef enum _BT_TRAFFIC_MODE_PROFILE{ - BT_PROFILE_NONE, - BT_PROFILE_A2DP, - BT_PROFILE_PAN , - BT_PROFILE_HID, - BT_PROFILE_SCO -} BT_TRAFFIC_MODE_PROFILE; - -typedef enum _HCI_EXT_BT_OPERATION { - HCI_BT_OP_NONE = 0x0, - HCI_BT_OP_INQUIRY_START = 0x1, - HCI_BT_OP_INQUIRY_FINISH = 0x2, - HCI_BT_OP_PAGING_START = 0x3, - HCI_BT_OP_PAGING_SUCCESS = 0x4, - HCI_BT_OP_PAGING_UNSUCCESS = 0x5, - HCI_BT_OP_PAIRING_START = 0x6, - HCI_BT_OP_PAIRING_FINISH = 0x7, - HCI_BT_OP_BT_DEV_ENABLE = 0x8, - HCI_BT_OP_BT_DEV_DISABLE = 0x9, - HCI_BT_OP_MAX -} HCI_EXT_BT_OPERATION, *PHCI_EXT_BT_OPERATION; - -typedef struct _BT_MGNT{ - BOOLEAN bBTConnectInProgress; - BOOLEAN bLogLinkInProgress; - BOOLEAN bPhyLinkInProgress; - BOOLEAN bPhyLinkInProgressStartLL; - u1Byte BtCurrentPhyLinkhandle; - u2Byte BtCurrentLogLinkhandle; - u1Byte CurrentConnectEntryNum; - u1Byte DisconnectEntryNum; - u1Byte CurrentBTConnectionCnt; - BT_CONNECT_TYPE BTCurrentConnectType; - BT_CONNECT_TYPE BTReceiveConnectPkt; - u1Byte BTAuthCount; - u1Byte BTAsocCount; - BOOLEAN bStartSendSupervisionPkt; - BOOLEAN BtOperationOn; - BOOLEAN BTNeedAMPStatusChg; - BOOLEAN JoinerNeedSendAuth; - HCI_PHY_LINK_BSS_INFO bssDesc; - HCI_EXT_CONFIG ExtConfig; - BOOLEAN bNeedNotifyAMPNoCap; - BOOLEAN bCreateSpportQos; - BOOLEAN bSupportProfile; - u1Byte BTChannel; - BOOLEAN CheckChnlIsSuit; - BOOLEAN bBtScan; - BOOLEAN btLogoTest; - BOOLEAN bRfStatusNotified; - BOOLEAN bBtRsvedPageDownload; -}BT_MGNT, *PBT_MGNT; - -struct bt_coex_info { - /* For Kernel Socket */ - struct socket *udpsock; - struct sockaddr_in wifi_sockaddr; /*wifi socket*/ - struct sockaddr_in bt_sockaddr;/* BT socket */ - struct sock *sk_store;/*back up socket for UDP RX int*/ - - /* store which socket is OK */ - u8 sock_open; - - u8 BT_attend; - u8 is_exist; /* socket exist */ - BT_MGNT BtMgnt; - struct workqueue_struct *btcoex_wq; - struct delayed_work recvmsg_work; -}; -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - -#define PACKET_NORMAL 0 -#define PACKET_DHCP 1 -#define PACKET_ARP 2 -#define PACKET_EAPOL 3 - -void rtw_btcoex_Initialize(PADAPTER); -void rtw_btcoex_PowerOnSetting(PADAPTER padapter); -void rtw_btcoex_PreLoadFirmware(PADAPTER padapter); -void rtw_btcoex_HAL_Initialize(PADAPTER padapter, u8 bWifiOnly); -void rtw_btcoex_IpsNotify(PADAPTER, u8 type); -void rtw_btcoex_LpsNotify(PADAPTER, u8 type); -void rtw_btcoex_ScanNotify(PADAPTER, u8 type); -void rtw_btcoex_ConnectNotify(PADAPTER, u8 action); -void rtw_btcoex_MediaStatusNotify(PADAPTER, u8 mediaStatus); -void rtw_btcoex_SpecialPacketNotify(PADAPTER, u8 pktType); -void rtw_btcoex_IQKNotify(PADAPTER padapter, u8 state); -void rtw_btcoex_BtInfoNotify(PADAPTER, u8 length, u8 *tmpBuf); -void rtw_btcoex_BtMpRptNotify(PADAPTER, u8 length, u8 *tmpBuf); -void rtw_btcoex_SuspendNotify(PADAPTER, u8 state); -void rtw_btcoex_HaltNotify(PADAPTER); -void rtw_btcoex_ScoreBoardStatusNotify(PADAPTER, u8 length, u8 *tmpBuf); -void rtw_btcoex_SwitchBtTRxMask(PADAPTER); -void rtw_btcoex_Switch(PADAPTER, u8 enable); -u8 rtw_btcoex_IsBtDisabled(PADAPTER); -void rtw_btcoex_Handler(PADAPTER); -s32 rtw_btcoex_IsBTCoexRejectAMPDU(PADAPTER padapter); -s32 rtw_btcoex_IsBTCoexCtrlAMPDUSize(PADAPTER); -u32 rtw_btcoex_GetAMPDUSize(PADAPTER); -void rtw_btcoex_SetManualControl(PADAPTER, u8 bmanual); -u8 rtw_btcoex_1Ant(PADAPTER); -u8 rtw_btcoex_IsBtControlLps(PADAPTER); -u8 rtw_btcoex_IsLpsOn(PADAPTER); -u8 rtw_btcoex_RpwmVal(PADAPTER); -u8 rtw_btcoex_LpsVal(PADAPTER); -void rtw_btcoex_SetBTCoexist(PADAPTER, u8 bBtExist); -void rtw_btcoex_SetChipType(PADAPTER, u8 chipType); -void rtw_btcoex_SetPGAntNum(PADAPTER, u8 antNum); -u8 rtw_btcoex_GetPGAntNum(PADAPTER); -void rtw_btcoex_SetSingleAntPath(PADAPTER padapter, u8 singleAntPath); -u32 rtw_btcoex_GetRaMask(PADAPTER); -void rtw_btcoex_RecordPwrMode(PADAPTER, u8 *pCmdBuf, u8 cmdLen); -void rtw_btcoex_DisplayBtCoexInfo(PADAPTER, u8 *pbuf, u32 bufsize); -void rtw_btcoex_SetDBG(PADAPTER, u32 *pDbgModule); -u32 rtw_btcoex_GetDBG(PADAPTER, u8 *pStrBuf, u32 bufSize); -u8 rtw_btcoex_IncreaseScanDeviceNum(PADAPTER); -u8 rtw_btcoex_IsBtLinkExist(PADAPTER); -void rtw_btcoex_BTOffOnNotify(PADAPTER padapter, u8 bBTON); -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX -void rtw_btcoex_SetBtPatchVersion(PADAPTER padapter,u16 btHciVer, u16 btPatchVer); -void rtw_btcoex_SetHciVersion(PADAPTER padapter, u16 hciVersion); -void rtw_btcoex_StackUpdateProfileInfo(void); -void rtw_btcoex_init_socket(_adapter *padapter); -void rtw_btcoex_close_socket(_adapter *padapter); -void rtw_btcoex_dump_tx_msg(u8 *tx_msg, u8 len, u8 *msg_name); -u8 rtw_btcoex_sendmsgbysocket(_adapter *padapter, u8 *msg, u8 msg_size, bool force); -u8 rtw_btcoex_create_kernel_socket(_adapter *padapter); -void rtw_btcoex_close_kernel_socket(_adapter *padapter); -void rtw_btcoex_recvmsgbysocket(void *data); -u16 rtw_btcoex_parse_recv_data(u8 *msg, u8 msg_size); -u8 rtw_btcoex_btinfo_cmd(PADAPTER padapter, u8 *pbuf, u16 length); -void rtw_btcoex_parse_hci_cmd(_adapter *padapter, u8 *cmd, u16 len); -void rtw_btcoex_SendEventExtBtCoexControl(PADAPTER Adapter, u8 bNeedDbgRsp, u8 dataLen, void *pData); -void rtw_btcoex_SendEventExtBtInfoControl(PADAPTER Adapter, u8 dataLen, void *pData); -void rtw_btcoex_SendScanNotify(PADAPTER padapter, u8 scanType); -#define BT_SendEventExtBtCoexControl(Adapter, bNeedDbgRsp, dataLen, pData) rtw_btcoex_SendEventExtBtCoexControl(Adapter, bNeedDbgRsp, dataLen, pData) -#define BT_SendEventExtBtInfoControl(Adapter, dataLen, pData) rtw_btcoex_SendEventExtBtInfoControl(Adapter, dataLen, pData) -#endif //CONFIG_BT_COEXIST_SOCKET_TRX -u16 rtw_btcoex_btreg_read(PADAPTER padapter, u8 type, u16 addr, u32 *data); -u16 rtw_btcoex_btreg_write(PADAPTER padapter, u8 type, u16 addr, u16 val); - -// ================================================== -// Below Functions are called by BT-Coex -// ================================================== -void rtw_btcoex_rx_ampdu_apply(PADAPTER); -void rtw_btcoex_LPS_Enter(PADAPTER); -void rtw_btcoex_LPS_Leave(PADAPTER); - -#endif // __RTW_BTCOEX_H__ - diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_cmd.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_cmd.h index 9bbc63523..5037e4972 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_cmd.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_cmd.h @@ -1108,10 +1108,6 @@ void rtw_dfs_master_status_apply(_adapter *adapter, u8 self_action); #endif /* CONFIG_DFS_MASTER */ #endif /* CONFIG_AP_MODE */ -#ifdef CONFIG_BT_COEXIST -u8 rtw_btinfo_cmd(PADAPTER padapter, u8 *pbuf, u16 length); -#endif - u8 rtw_enable_hw_update_tsf_cmd(_adapter *padapter); u8 rtw_set_ch_cmd(_adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_debug.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_debug.h index d96dca25c..dc9d73dca 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_debug.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_debug.h @@ -506,12 +506,6 @@ ssize_t proc_set_en_fwps(struct file *file, const char __user *buffer, size_t co //int proc_get_rssi_disp(struct seq_file *m, void *v); //ssize_t proc_set_rssi_disp(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); -#ifdef CONFIG_BT_COEXIST -int proc_get_btcoex_dbg(struct seq_file *m, void *v); -ssize_t proc_set_btcoex_dbg(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); -int proc_get_btcoex_info(struct seq_file *m, void *v); -#endif /* CONFIG_BT_COEXIST */ - #if defined(DBG_CONFIG_ERROR_DETECT) int proc_get_sreset(struct seq_file *m, void *v); ssize_t proc_set_sreset(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_pwrctrl.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_pwrctrl.h index 61f4905a2..9a84e1b3d 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_pwrctrl.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_pwrctrl.h @@ -40,9 +40,6 @@ #define RECV_ALIVE BIT(1) #define CMD_ALIVE BIT(2) #define EVT_ALIVE BIT(3) -#ifdef CONFIG_BT_COEXIST -#define BTCOEX_ALIVE BIT(4) -#endif // CONFIG_BT_COEXIST enum Power_Mgnt { @@ -312,10 +309,6 @@ struct pwrctrl_priv u8 bInternalAutoSuspend; u8 bInSuspend; -#ifdef CONFIG_BT_COEXIST - u8 bAutoResume; - u8 autopm_cnt; -#endif u8 bSupportRemoteWakeup; u8 wowlan_wake_reason; u8 wowlan_ap_mode; diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_recv.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_recv.h index 498e88a07..1285cb8b9 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_recv.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_recv.h @@ -402,14 +402,6 @@ struct recv_priv uint ff_hwaddr; ATOMIC_T rx_pending_cnt; -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE -#ifdef PLATFORM_LINUX - PURB int_in_urb; -#endif - - u8 *int_in_buf; -#endif //CONFIG_USB_INTERRUPT_IN_PIPE - #endif #if defined(PLATFORM_LINUX) || defined(PLATFORM_FREEBSD) #ifdef PLATFORM_FREEBSD diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_security.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_security.h index 72138cb95..7b3ed42b6 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_security.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_security.h @@ -238,12 +238,6 @@ struct security_priv #endif /* DBG_SW_SEC_CNT */ }; -struct rtw_sha256_state { - u64 length; - u32 state[8], curlen; - u8 buf[64]; -}; - #define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst)\ do{\ switch(psecuritypriv->dot11AuthAlgrthm)\ @@ -484,3 +478,4 @@ u8 rtw_handle_tkip_countermeasure(_adapter* adapter, const char *caller); #endif //__RTL871X_SECURITY_H_ + diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_wifi_regd.h b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_wifi_regd.h index c23262a37..13679b809 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/rtw_wifi_regd.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/rtw_wifi_regd.h @@ -20,8 +20,8 @@ enum country_code_type_t { COUNTRY_CODE_MAX }; -void rtw_regd_init(struct wiphy *wiphy); -void rtw_reg_notify_by_driver(struct wiphy *wiphy); +int rtw_regd_init(_adapter *padapter); +void rtw_reg_notify_by_driver(_adapter *adapter); #endif /* __RTW_WIFI_REGD_H__ */ diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops.h b/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops.h index ee23314aa..81f3f7179 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops.h @@ -55,33 +55,21 @@ enum{ #ifdef CONFIG_RTL8188E void rtl8188eu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8188eu_set_intf_ops(struct _io_ops *pops); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8188eu(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif #if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) void rtl8812au_set_hw_type(struct dvobj_priv *pdvobj); void rtl8812au_set_intf_ops(struct _io_ops *pops); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8812au(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif #ifdef CONFIG_RTL8814A void rtl8814au_set_hw_type(struct dvobj_priv *pdvobj); void rtl8814au_set_intf_ops(struct _io_ops *pops); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8814au(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif /* CONFIG_RTL8814 */ #ifdef CONFIG_RTL8192E void rtl8192eu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8192eu_set_intf_ops(struct _io_ops *pops); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8192eu(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif @@ -90,9 +78,6 @@ void rtl8188fu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8188fu_set_intf_ops(struct _io_ops *pops); void rtl8188fu_recv_tasklet(void *priv); void rtl8188fu_xmit_tasklet(void *priv); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8188fu(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif #ifdef CONFIG_RTL8723B @@ -100,9 +85,6 @@ void rtl8723bu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8723bu_set_intf_ops(struct _io_ops *pops); void rtl8723bu_recv_tasklet(void *priv); void rtl8723bu_xmit_tasklet(void *priv); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8723bu(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif #endif #ifdef CONFIG_RTL8703B @@ -110,9 +92,6 @@ void rtl8703bu_set_hw_type(struct dvobj_priv *pdvobj); void rtl8703bu_set_intf_ops(struct _io_ops *pops); void rtl8703bu_recv_tasklet(void *priv); void rtl8703bu_xmit_tasklet(void *priv); -#ifdef CONFIG_SUPPORT_USB_INT -void interrupt_handler_8703bu(_adapter *padapter, u16 pkt_len, u8 *pbuf); -#endif /* CONFIG_SUPPORT_USB_INT */ #endif /* CONFIG_RTL8703B */ enum RTW_USB_SPEED { diff --git a/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops_linux.h b/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops_linux.h index b0d0f43ee..87bc5d652 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops_linux.h +++ b/drivers/net/wireless/realtek/rtl8188fu/include/usb_ops_linux.h @@ -81,9 +81,5 @@ int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); void usb_recv_tasklet(void *priv); -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE -void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs); -u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr); -#endif #endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/custom_gpio_linux.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/custom_gpio_linux.c deleted file mode 100644 index 418d7932e..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/custom_gpio_linux.c +++ /dev/null @@ -1,356 +0,0 @@ -/****************************************************************************** - * Customer code to add GPIO control during WLAN start/stop - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#include "drv_types.h" - -#ifdef CONFIG_PLATFORM_SPRD - -//gspi func & GPIO define -#include //0915 -#include - -#if !(defined ANDROID_2X) - -#ifdef CONFIG_RTL8188E -#include -#include -#endif // CONFIG_RTL8188E - -#ifndef GPIO_WIFI_POWER -#define GPIO_WIFI_POWER -1 -#endif // !GPIO_WIFI_POWER - -#ifndef GPIO_WIFI_RESET -#define GPIO_WIFI_RESET -1 -#endif // !GPIO_WIFI_RESET - -#ifndef GPIO_WIFI_PWDN -#define GPIO_WIFI_PWDN -1 -#endif // !GPIO_WIFI_RESET -#ifdef CONFIG_GSPI_HCI -extern unsigned int oob_irq; -#endif // CONFIG_GSPI_HCI - -#ifdef CONFIG_SDIO_HCI -extern int rtw_mp_mode; -#else // !CONFIG_SDIO_HCI -#endif // !CONFIG_SDIO_HCI - -int rtw_wifi_gpio_init(void) -{ -#ifdef CONFIG_GSPI_HCI - if (GPIO_WIFI_IRQ > 0) { - gpio_request(GPIO_WIFI_IRQ, "oob_irq"); - gpio_direction_input(GPIO_WIFI_IRQ); - - oob_irq = gpio_to_irq(GPIO_WIFI_IRQ); - - DBG_8192C("%s oob_irq:%d\n", __func__, oob_irq); - } -#endif - if (GPIO_WIFI_RESET > 0) - gpio_request(GPIO_WIFI_RESET , "wifi_rst"); - if (GPIO_WIFI_POWER > 0) - gpio_request(GPIO_WIFI_POWER, "wifi_power"); - -#ifdef CONFIG_SDIO_HCI -#if (defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1) - if(rtw_mp_mode==1){ - DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__); - if (GPIO_BT_RESET > 0) - gpio_request(GPIO_BT_RESET , "bt_rst"); - } -#endif -#endif - return 0; -} - -int rtw_wifi_gpio_deinit(void) -{ -#ifdef CONFIG_GSPI_HCI - if (GPIO_WIFI_IRQ > 0) - gpio_free(GPIO_WIFI_IRQ); -#endif - if (GPIO_WIFI_RESET > 0) - gpio_free(GPIO_WIFI_RESET ); - if (GPIO_WIFI_POWER > 0) - gpio_free(GPIO_WIFI_POWER); - -#ifdef CONFIG_SDIO_HCI -#if ( defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1) - if(rtw_mp_mode==1){ - DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__); - if (GPIO_BT_RESET > 0) - gpio_free(GPIO_BT_RESET); - } -#endif -#endif - return 0; -} - -/* Customer function to control hw specific wlan gpios */ -void rtw_wifi_gpio_wlan_ctrl(int onoff) -{ - switch (onoff) - { - case WLAN_PWDN_OFF: - DBG_8192C("%s: call customer specific GPIO(%d) to set wifi power down pin to 0\n", - __FUNCTION__, GPIO_WIFI_RESET); - -#ifndef CONFIG_DONT_BUS_SCAN - if (GPIO_WIFI_RESET > 0) - gpio_direction_output(GPIO_WIFI_RESET , 0); -#endif - break; - - case WLAN_PWDN_ON: - DBG_8192C("%s: callc customer specific GPIO(%d) to set wifi power down pin to 1\n", - __FUNCTION__, GPIO_WIFI_RESET); - - if (GPIO_WIFI_RESET > 0) - gpio_direction_output(GPIO_WIFI_RESET , 1); - break; - - case WLAN_POWER_OFF: - break; - - case WLAN_POWER_ON: - break; -#ifdef CONFIG_SDIO_HCI -#if ( defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1) - case WLAN_BT_PWDN_OFF: - if(rtw_mp_mode==1) - { - DBG_871X("%s: call customer specific GPIO to set wifi power down pin to 0\n", - __FUNCTION__); - if (GPIO_BT_RESET > 0) - gpio_direction_output(GPIO_BT_RESET , 0); - } - break; - - case WLAN_BT_PWDN_ON: - if(rtw_mp_mode==1) - { - DBG_871X("%s: callc customer specific GPIO to set wifi power down pin to 1 %x\n", - __FUNCTION__, GPIO_BT_RESET); - - if (GPIO_BT_RESET > 0) - gpio_direction_output(GPIO_BT_RESET , 1); - } - break; -#endif -#endif - } -} - -#else //ANDROID_2X - -#include - -#ifdef CONFIG_RTL8188E -extern int sprd_3rdparty_gpio_wifi_power; -#endif -extern int sprd_3rdparty_gpio_wifi_pwd; -#if defined(CONFIG_RTL8723B) -extern int sprd_3rdparty_gpio_bt_reset; -#endif - -int rtw_wifi_gpio_init(void) -{ -#if defined(CONFIG_RTL8723B) - if (sprd_3rdparty_gpio_bt_reset > 0) - gpio_direction_output(sprd_3rdparty_gpio_bt_reset, 1); -#endif - - return 0; -} - -int rtw_wifi_gpio_deinit(void) -{ - return 0; -} - -/* Customer function to control hw specific wlan gpios */ -void rtw_wifi_gpio_wlan_ctrl(int onoff) -{ - switch (onoff) - { - case WLAN_PWDN_OFF: - DBG_8192C("%s: call customer specific GPIO to set wifi power down pin to 0\n", - __FUNCTION__); - if (sprd_3rdparty_gpio_wifi_pwd > 0) - { - gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 0); - } - - if (sprd_3rdparty_gpio_wifi_pwd == 60) { - DBG_8192C("%s: turn off VSIM2 2.8V\n", __func__); - LDO_TurnOffLDO(LDO_LDO_SIM2); - } - break; - - case WLAN_PWDN_ON: - DBG_8192C("%s: callc customer specific GPIO to set wifi power down pin to 1\n", - __FUNCTION__); - if (sprd_3rdparty_gpio_wifi_pwd == 60) { - DBG_8192C("%s: turn on VSIM2 2.8V\n", __func__); - LDO_SetVoltLevel(LDO_LDO_SIM2, LDO_VOLT_LEVEL0); - LDO_TurnOnLDO(LDO_LDO_SIM2); - } - if (sprd_3rdparty_gpio_wifi_pwd > 0) - { - gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 1); - } - break; - - case WLAN_POWER_OFF: -#ifdef CONFIG_RTL8188E -#ifdef CONFIG_WIF1_LDO - DBG_8192C("%s: turn off VDD-WIFI0 1.2V\n", __FUNCTION__); - LDO_TurnOffLDO(LDO_LDO_WIF1); -#endif //CONFIG_WIF1_LDO - - DBG_8192C("%s: turn off VDD-WIFI0 3.3V\n", __FUNCTION__); - LDO_TurnOffLDO(LDO_LDO_WIF0); - - DBG_8192C("%s: call customer specific GPIO(%d) to turn off wifi power\n", - __FUNCTION__, sprd_3rdparty_gpio_wifi_power); - if (sprd_3rdparty_gpio_wifi_power != 65535) - gpio_set_value(sprd_3rdparty_gpio_wifi_power, 0); -#endif - break; - - case WLAN_POWER_ON: -#ifdef CONFIG_RTL8188E - DBG_8192C("%s: call customer specific GPIO(%d) to turn on wifi power\n", - __FUNCTION__, sprd_3rdparty_gpio_wifi_power); - if (sprd_3rdparty_gpio_wifi_power != 65535) - gpio_set_value(sprd_3rdparty_gpio_wifi_power, 1); - - DBG_8192C("%s: turn on VDD-WIFI0 3.3V\n", __FUNCTION__); - LDO_TurnOnLDO(LDO_LDO_WIF0); - LDO_SetVoltLevel(LDO_LDO_WIF0,LDO_VOLT_LEVEL1); - -#ifdef CONFIG_WIF1_LDO - DBG_8192C("%s: turn on VDD-WIFI1 1.2V\n", __func__); - LDO_TurnOnLDO(LDO_LDO_WIF1); - LDO_SetVoltLevel(LDO_LDO_WIF1,LDO_VOLT_LEVEL3); -#endif //CONFIG_WIF1_LDO -#endif - break; - - case WLAN_BT_PWDN_OFF: - DBG_8192C("%s: call customer specific GPIO to set bt power down pin to 0\n", - __FUNCTION__); -#if defined(CONFIG_RTL8723B) - if (sprd_3rdparty_gpio_bt_reset > 0) - gpio_set_value(sprd_3rdparty_gpio_bt_reset, 0); -#endif - break; - - case WLAN_BT_PWDN_ON: - DBG_8192C("%s: callc customer specific GPIO to set bt power down pin to 1\n", - __FUNCTION__); -#if defined(CONFIG_RTL8723B) - if (sprd_3rdparty_gpio_bt_reset > 0) - gpio_set_value(sprd_3rdparty_gpio_bt_reset, 1); -#endif - break; - } -} -#endif //ANDROID_2X - -#elif defined(CONFIG_PLATFORM_ARM_RK3066) -#include - -#define GPIO_WIFI_IRQ RK30_PIN2_PC2 -extern unsigned int oob_irq; -int rtw_wifi_gpio_init(void) -{ -#ifdef CONFIG_GSPI_HCI - if (GPIO_WIFI_IRQ > 0) { - rk30_mux_api_set(GPIO2C2_LCDC1DATA18_SMCBLSN1_HSADCDATA5_NAME, GPIO2C_GPIO2C2);//jacky_test - gpio_request(GPIO_WIFI_IRQ, "oob_irq"); - gpio_direction_input(GPIO_WIFI_IRQ); - - oob_irq = gpio_to_irq(GPIO_WIFI_IRQ); - - DBG_8192C("%s oob_irq:%d\n", __func__, oob_irq); - } -#endif - return 0; -} - - -int rtw_wifi_gpio_deinit(void) -{ -#ifdef CONFIG_GSPI_HCI - if (GPIO_WIFI_IRQ > 0) - gpio_free(GPIO_WIFI_IRQ); -#endif - return 0; -} - -void rtw_wifi_gpio_wlan_ctrl(int onoff) -{ -} - -#ifdef CONFIG_GPIO_API -//this is a demo for extending GPIO pin[7] as interrupt mode -struct net_device * rtl_net; -extern int rtw_register_gpio_interrupt(struct net_device *netdev, int gpio_num, void(*callback)(u8 level)); -extern int rtw_disable_gpio_interrupt(struct net_device *netdev, int gpio_num); -void gpio_int(u8 is_high) -{ - DBG_8192C("%s level=%d\n",__func__, is_high); -} -int register_net_gpio_init(void) -{ - rtl_net = dev_get_by_name(&init_net,"wlan0"); - if(!rtl_net) - { - DBG_871X_LEVEL(_drv_always_, "rtl_net init fail!\n"); - return -1; - } - return rtw_register_gpio_interrupt(rtl_net,7, gpio_int); -} -int unregister_net_gpio_init(void) -{ - rtl_net = dev_get_by_name(&init_net,"wlan0"); - if(!rtl_net) - { - DBG_871X_LEVEL(_drv_always_, "rtl_net init fail!\n"); - return -1; - } - return rtw_disable_gpio_interrupt(rtl_net,7); -} -#endif - -#else - -int rtw_wifi_gpio_init(void) -{ - return 0; -} - -void rtw_wifi_gpio_wlan_ctrl(int onoff) -{ -} -#endif //CONFIG_PLATFORM_SPRD diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_cfg80211.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_cfg80211.c index e6504810c..6101a9b2a 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_cfg80211.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_cfg80211.c @@ -825,8 +825,13 @@ check_bss: DBG_871X(FUNC_ADPT_FMT" call cfg80211_roamed\n", FUNC_ADPT_ARG(padapter)); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4,12,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)) + roam_info.links[0].channel = notify_channel; + roam_info.links[0].bssid = cur_network->network.MacAddress; +#else + roam_info.channel = notify_channel; roam_info.bssid = cur_network->network.MacAddress; - roam_info.req_ie = pmlmepriv->assoc_req+sizeof(struct rtw_ieee80211_hdr_3addr)+2; +#endif roam_info.req_ie_len = pmlmepriv->assoc_req_len-sizeof(struct rtw_ieee80211_hdr_3addr)-2; roam_info.resp_ie = pmlmepriv->assoc_rsp+sizeof(struct rtw_ieee80211_hdr_3addr)+6, roam_info.resp_ie_len = pmlmepriv->assoc_rsp_len-sizeof(struct rtw_ieee80211_hdr_3addr)-6; @@ -1541,6 +1546,9 @@ exit: } static int cfg80211_rtw_add_key(struct wiphy *wiphy, struct net_device *ndev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr, #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1692,6 +1700,9 @@ addkey_end: } static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr, #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1725,6 +1736,9 @@ static int cfg80211_rtw_get_key(struct wiphy *wiphy, struct net_device *ndev, } static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + int link_id, +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) u8 key_index, bool pairwise, const u8 *mac_addr) #else // (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) @@ -1745,8 +1759,11 @@ static int cfg80211_rtw_del_key(struct wiphy *wiphy, struct net_device *ndev, return 0; } -static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, - struct net_device *ndev, u8 key_index +static int cfg80211_rtw_set_default_key(struct wiphy *wiphy, struct net_device *ndev, +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + int link_id, +#endif + u8 key_index #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,38)) || defined(COMPAT_KERNEL_RELEASE) , bool unicast, bool multicast #endif @@ -2392,25 +2409,6 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy } #endif //CONFIG_CONCURRENT_MODE -#ifdef CONFIG_MP_INCLUDED -if (padapter->registrypriv.mp_mode == 1) -{ - DBG_871X(FUNC_ADPT_FMT ": MP mode block Scan request\n", FUNC_ADPT_ARG(padapter)); - ret = -EPERM; - goto exit; -} -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->pbuddy_adapter) { - if (padapter->pbuddy_adapter->registrypriv.mp_mode == 1) - { - DBG_871X(FUNC_ADPT_FMT ": MP mode block Scan request\n", FUNC_ADPT_ARG(padapter->pbuddy_adapter)); - ret = -EPERM; - goto exit; - } - } -#endif //CONFIG_CONCURRENT_MODE -#endif - _enter_critical_bh(&pwdev_priv->scan_req_lock, &irqL); pwdev_priv->scan_request = request; _exit_critical_bh(&pwdev_priv->scan_req_lock, &irqL); @@ -2451,18 +2449,12 @@ if (padapter->registrypriv.mp_mode == 1) #ifdef CONFIG_P2P if( pwdinfo->driver_interface == DRIVER_CFG80211 ) { - if(ssids->ssid != NULL - && _rtw_memcmp(ssids->ssid, "DIRECT-", 7) - && rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL) - ) - { - if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) - { + if (_rtw_memcmp(ssids->ssid, "DIRECT-", 7) && + rtw_get_p2p_ie((u8 *)request->ie, request->ie_len, NULL, NULL)) { + if(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { rtw_p2p_enable(padapter, P2P_ROLE_DEVICE); adapter_wdev_data(padapter)->p2p_enabled = _TRUE; - } - else - { + } else { rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); #ifdef CONFIG_DEBUG_CFG80211 DBG_8192C("%s, role=%d, p2p_state=%d\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo)); @@ -4346,7 +4338,11 @@ static int cfg80211_rtw_change_beacon(struct wiphy *wiphy, struct net_device *nd return ret; } +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2) static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev) +#else +static int cfg80211_rtw_stop_ap(struct wiphy *wiphy, struct net_device *ndev, unsigned int link_id) +#endif { DBG_871X(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(ndev)); return 0; @@ -5126,23 +5122,6 @@ static s32 cfg80211_rtw_remain_on_channel(struct wiphy *wiphy, DBG_871X(FUNC_ADPT_FMT" ch:%u duration:%d, cookie:0x%llx\n", FUNC_ADPT_ARG(padapter), remain_ch, duration, *cookie); -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) { - DBG_871X(FUNC_ADPT_FMT ": MP mode block remain_on_channel request\n", FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->pbuddy_adapter) { - if (padapter->pbuddy_adapter->registrypriv.mp_mode == 1) { - DBG_871X(FUNC_ADPT_FMT ": MP mode block remain_on_channel request\n", FUNC_ADPT_ARG(padapter->pbuddy_adapter)); - err = -EFAULT; - goto exit; - } - } -#endif -#endif - if(pcfg80211_wdinfo->is_ro_ch == _TRUE) { DBG_8192C("%s, cancel ro ch timer\n", __func__); @@ -5708,29 +5687,25 @@ cancel_ps_deny: exit: return ret; } - +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) +static void cfg80211_rtw_update_mgmt_frame_register(struct wiphy *wiphy, + struct wireless_dev *wdev, + struct mgmt_frame_regs *upd) +#else static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)) struct wireless_dev *wdev, #else struct net_device *ndev, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) - struct mgmt_frame_regs *upd) -#else u16 frame_type, bool reg) #endif { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6 ,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,6,0)) struct net_device *ndev = wdev_to_ndev(wdev); #endif _adapter *adapter; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) - u16 frame_type = BIT(upd->global_stypes << 4); - bool reg = false; -#endif - struct rtw_wdev_priv *pwdev_priv; if (ndev == NULL) @@ -5747,17 +5722,6 @@ static void cfg80211_rtw_mgmt_frame_register(struct wiphy *wiphy, /* Wait QC Verify */ return; - switch (frame_type) { - case IEEE80211_STYPE_PROBE_REQ: /* 0x0040 */ - SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_PROBE_REQ, reg); - break; - case IEEE80211_STYPE_ACTION: /* 0x00D0 */ - SET_CFG80211_REPORT_MGMT(pwdev_priv, IEEE80211_STYPE_ACTION, reg); - break; - default: - break; - } - exit: return; } @@ -6484,6 +6448,8 @@ void rtw_cfg80211_init_wiphy(_adapter *padapter) rtw_cfg80211_init_ht_capab(padapter, &bands->ht_cap, IEEE80211_BAND_5GHZ, rf_type); } #endif + /* init regulary domain */ + rtw_regd_init(padapter); /* copy mac_addr to wiphy */ _rtw_memcpy(wiphy->perm_addr, adapter_mac_addr(padapter), ETH_ALEN); @@ -6682,16 +6648,15 @@ static struct cfg80211_ops rtw_cfg80211_ops = { #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) .mgmt_tx = cfg80211_rtw_mgmt_tx, +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,8,0)) + .update_mgmt_frame_registrations = cfg80211_rtw_update_mgmt_frame_register, +#else + .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, +#endif #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,34) && LINUX_VERSION_CODE<=KERNEL_VERSION(2,6,35)) .action = cfg80211_rtw_mgmt_tx, #endif -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)) - .update_mgmt_frame_registrations = cfg80211_rtw_mgmt_frame_register, -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,37)) || defined(COMPAT_KERNEL_RELEASE) - .mgmt_frame_register = cfg80211_rtw_mgmt_frame_register, -#endif - #if defined(CONFIG_TDLS) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,2,0)) .tdls_mgmt = cfg80211_rtw_tdls_mgmt, .tdls_oper = cfg80211_rtw_tdls_oper, @@ -6719,9 +6684,6 @@ struct wiphy *rtw_wiphy_alloc(_adapter *padapter, struct device *dev) rtw_cfg80211_preinit_wiphy(padapter, wiphy); - /* init regulary domain */ - rtw_regd_init(wiphy); - DBG_871X(FUNC_WIPHY_FMT"\n", FUNC_WIPHY_ARG(wiphy)); exit: @@ -6847,7 +6809,11 @@ void rtw_wdev_unregister(struct wireless_dev *wdev) rtw_cfg80211_indicate_scan_done(adapter, _TRUE); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 19, 2) if (wdev->current_bss) { +#else + if (wdev->connected) { +#endif u8 locally_generated = 1; DBG_871X(FUNC_ADPT_FMT" clear current_bss by cfg80211_disconnected\n", FUNC_ADPT_ARG(adapter)); cfg80211_disconnected(adapter->pnetdev, 0, NULL, 0, locally_generated, GFP_ATOMIC); @@ -6977,3 +6943,4 @@ void rtw_cfg80211_dev_res_unregister(struct dvobj_priv *dvobj) } #endif /* CONFIG_IOCTL_CFG80211 */ + diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_linux.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_linux.c index 67400e84a..dc147fb5c 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_linux.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_linux.c @@ -2642,25 +2642,6 @@ _func_enter_; } #endif */ -#ifdef CONFIG_MP_INCLUDED - if (padapter->registrypriv.mp_mode == 1) - { - DBG_871X(FUNC_ADPT_FMT ": MP mode block Scan request\n", FUNC_ADPT_ARG(padapter)); - ret = -1; - goto exit; - } -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->pbuddy_adapter) { - if (padapter->pbuddy_adapter->registrypriv.mp_mode == 1) - { - DBG_871X(FUNC_ADPT_FMT ": MP mode block Scan request\n", FUNC_ADPT_ARG(padapter->pbuddy_adapter)); - ret = -1; - goto exit; - } - } -#endif //CONFIG_CONCURRENT_MODE -#endif - rtw_ps_deny(padapter, PS_DENY_SCAN); if(_FAIL == rtw_pwr_wakeup(padapter)) { @@ -4466,16 +4447,6 @@ static void rtw_dbg_mode_hdl(_adapter *padapter, u32 id, u8 *pdata, u32 len) DBG_871X("==> trigger gpio 0\n"); rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, 0); break; -#ifdef CONFIG_BT_COEXIST - case GEN_MP_IOCTL_SUBCODE(SET_DM_BT): - DBG_871X("==> set dm_bt_coexist:%x\n",*(u8 *)pdata); - rtw_hal_set_hwreg(padapter, HW_VAR_BT_SET_COEXIST, pdata); - break; - case GEN_MP_IOCTL_SUBCODE(DEL_BA): - DBG_871X("==> delete ba:%x\n",*(u8 *)pdata); - rtw_hal_set_hwreg(padapter, HW_VAR_BT_ISSUE_DELBA, pdata); - break; -#endif #ifdef DBG_CONFIG_ERROR_DETECT case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): *pdata = rtw_hal_sreset_get_wifi_status(padapter); @@ -4537,54 +4508,6 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info } //DBG_871X("%s: %d\n", __func__, poidparam->subcode); -#ifdef CONFIG_MP_INCLUDED -if (padapter->registrypriv.mp_mode == 1) -{ - phandler = mp_ioctl_hdl + poidparam->subcode; - - if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) - { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, - ("no matching drvext param size %d vs %d\r\n", - poidparam->len, phandler->paramsize)); - ret = -EINVAL; - goto _rtw_mp_ioctl_hdl_exit; - } - - if (phandler->handler) - { - oid_par.adapter_context = padapter; - oid_par.oid = phandler->oid; - oid_par.information_buf = poidparam->data; - oid_par.information_buf_len = poidparam->len; - oid_par.dbg = 0; - - BytesWritten = 0; - BytesNeeded = 0; - - if (bset) { - oid_par.bytes_rw = &BytesRead; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = SET_OID; - } else { - oid_par.bytes_rw = &BytesWritten; - oid_par.bytes_needed = &BytesNeeded; - oid_par.type_of_oid = QUERY_OID; - } - - status = phandler->handler(&oid_par); - - //todo:check status, BytesNeeded, etc. - } - else { - DBG_871X("rtw_mp_ioctl_hdl(): err!, subcode=%d, oid=%d, handler=%p\n", - poidparam->subcode, phandler->oid, phandler->handler); - ret = -EFAULT; - goto _rtw_mp_ioctl_hdl_exit; - } -} -else -#endif { rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); } @@ -10020,7 +9943,6 @@ exit: if (!err) wrqu->length = strlen(extra); - if (padapter->registrypriv.mp_mode == 0) { #ifdef CONFIG_IPS rtw_pm_set_ips(padapter, ips_mode); @@ -10669,7 +10591,11 @@ static int rtw_mp_efuse_set(struct net_device *dev, rtw_hal_read_chip_info(padapter); /* set mac addr*/ rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); - _rtw_memcpy(padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) + _rtw_memcpy((void *)padapter->pnetdev->dev_addr, get_hal_mac_addr(padapter), ETH_ALEN); /* set mac addr to net_device */ +#else + dev_addr_set(padapter->pnetdev, get_hal_mac_addr(padapter)); +#endif #ifdef CONFIG_P2P rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); @@ -10696,7 +10622,6 @@ exit: wrqu->length = strlen(extra); - if (padapter->registrypriv.mp_mode == 0) { #ifdef CONFIG_IPS rtw_pm_set_ips(padapter, ips_mode); @@ -10710,502 +10635,6 @@ exit: return err; } - -#ifdef CONFIG_MP_INCLUDED - -#ifdef CONFIG_SDIO_INDIRECT_ACCESS -#define DBG_MP_SDIO_INDIRECT_ACCESS 1 -static int rtw_mp_sd_iread(struct net_device *dev - , struct iw_request_info *info - , struct iw_point *wrqu - , char *extra) -{ - char input[16]; - u8 width; - unsigned long addr; - u32 ret = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - - if (wrqu->length > 16) { - DBG_871X(FUNC_ADPT_FMT" wrqu->length:%d\n", FUNC_ADPT_ARG(padapter), wrqu->length); - ret = -EINVAL; - goto exit; - } - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - DBG_871X(FUNC_ADPT_FMT" copy_from_user fail\n", FUNC_ADPT_ARG(padapter)); - ret = -EFAULT; - goto exit; - } - - _rtw_memset(extra, 0, wrqu->length); - - if (sscanf(input, "%hhu,%lx", &width, &addr) != 2) { - DBG_871X(FUNC_ADPT_FMT" sscanf fail\n", FUNC_ADPT_ARG(padapter)); - ret = -EINVAL; - goto exit; - } - - if (addr > 0x3FFF) { - DBG_871X(FUNC_ADPT_FMT" addr:0x%lx\n", FUNC_ADPT_ARG(padapter), addr); - ret = -EINVAL; - goto exit; - } - - if (DBG_MP_SDIO_INDIRECT_ACCESS) - DBG_871X(FUNC_ADPT_FMT" width:%u, addr:0x%lx\n", FUNC_ADPT_ARG(padapter), width, addr); - - switch (width) { - case 1: - sprintf(extra, "0x%02x", rtw_sd_iread8(padapter, addr)); - wrqu->length = strlen(extra); - break; - case 2: - sprintf(extra, "0x%04x", rtw_sd_iread16(padapter, addr)); - wrqu->length = strlen(extra); - break; - case 4: - sprintf(extra, "0x%08x", rtw_sd_iread32(padapter, addr)); - wrqu->length = strlen(extra); - break; - default: - wrqu->length = 0; - ret = -EINVAL; - break; - } - -exit: - return ret; -} - -static int rtw_mp_sd_iwrite(struct net_device *dev - , struct iw_request_info *info - , struct iw_point *wrqu - , char *extra) -{ - char width; - unsigned long addr, data; - int ret = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - char input[32]; - - if (wrqu->length > 32) { - DBG_871X(FUNC_ADPT_FMT" wrqu->length:%d\n", FUNC_ADPT_ARG(padapter), wrqu->length); - ret = -EINVAL; - goto exit; - } - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) { - DBG_871X(FUNC_ADPT_FMT" copy_from_user fail\n", FUNC_ADPT_ARG(padapter)); - ret = -EFAULT; - goto exit; - } - - _rtw_memset(extra, 0, wrqu->length); - - if (sscanf(input, "%hhu,%lx,%lx", &width, &addr, &data) != 3) { - DBG_871X(FUNC_ADPT_FMT" sscanf fail\n", FUNC_ADPT_ARG(padapter)); - ret = -EINVAL; - goto exit; - } - - if (addr > 0x3FFF) { - DBG_871X(FUNC_ADPT_FMT" addr:0x%lx\n", FUNC_ADPT_ARG(padapter), addr); - ret = -EINVAL; - goto exit; - } - - if (DBG_MP_SDIO_INDIRECT_ACCESS) - DBG_871X(FUNC_ADPT_FMT" width:%u, addr:0x%lx, data:0x%lx\n", FUNC_ADPT_ARG(padapter), width, addr, data); - - switch (width) { - case 1: - if (data > 0xFF) { - ret = -EINVAL; - break; - } - rtw_sd_iwrite8(padapter, addr, data); - break; - case 2: - if (data > 0xFFFF) { - ret = -EINVAL; - break; - } - rtw_sd_iwrite16(padapter, addr, data); - break; - case 4: - rtw_sd_iwrite32(padapter, addr, data); - break; - default: - wrqu->length = 0; - ret = -EINVAL; - break; - } - -exit: - return ret; -} -#endif /* CONFIG_SDIO_INDIRECT_ACCESS */ - -#ifdef CONFIG_RTW_CUSTOMER_STR -static int rtw_mp_customer_str( - struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - _adapter *adapter = rtw_netdev_priv(dev); - u32 len; - u8 *pbuf = NULL, *pch; - char *ptmp; - u8 param[RTW_CUSTOMER_STR_LEN]; - u8 count = 0; - u8 tmp; - u8 i; - u32 pos; - u8 ret; - u8 read = 0; - - if (adapter->registrypriv.mp_mode != 1 - || !adapter->registrypriv.mp_customer_str) - return -EFAULT; - - len = wrqu->data.length; - - pbuf = (u8 *)rtw_zmalloc(len); - if (pbuf == NULL) { - RTW_WARN("%s: no memory!\n", __func__); - return -ENOMEM; - } - - if (copy_from_user(pbuf, wrqu->data.pointer, len)) { - rtw_mfree(pbuf, len); - RTW_WARN("%s: copy from user fail!\n", __func__); - return -EFAULT; - } - RTW_INFO("%s: string=\"%s\"\n", __func__, pbuf); - - ptmp = (char *)pbuf; - pch = strsep(&ptmp, ","); - if ((pch == NULL) || (strlen(pch) == 0)) { - rtw_mfree(pbuf, len); - RTW_INFO("%s: parameter error(no cmd)!\n", __func__); - return -EFAULT; - } - - _rtw_memset(param, 0xFF, RTW_CUSTOMER_STR_LEN); - - if (strcmp(pch, "read") == 0) { - read = 1; - ret = rtw_hal_customer_str_read(adapter, param); - - } else if (strcmp(pch, "write") == 0) { - do { - pch = strsep(&ptmp, ":"); - if ((pch == NULL) || (strlen(pch) == 0)) - break; - if (strlen(pch) != 2 - || IsHexDigit(*pch) == _FALSE - || IsHexDigit(*(pch + 1)) == _FALSE - || sscanf(pch, "%hhx", &tmp) != 1 - ) { - RTW_WARN("%s: invalid 8-bit hex!\n", __func__); - rtw_mfree(pbuf, len); - return -EFAULT; - } - - param[count++] = tmp; - - } while (count < RTW_CUSTOMER_STR_LEN); - - if (count == 0) { - rtw_mfree(pbuf, len); - RTW_WARN("%s: no input!\n", __func__); - return -EFAULT; - } - ret = rtw_hal_customer_str_write(adapter, param); - } else { - rtw_mfree(pbuf, len); - RTW_INFO("%s: parameter error(unknown cmd)!\n", __func__); - return -EFAULT; - } - - pos = sprintf(extra, "%s: ", read ? "read" : "write"); - if (read == 0 || ret == _SUCCESS) { - for (i = 0; i < RTW_CUSTOMER_STR_LEN; i++) - pos += sprintf(extra + pos, "%02x:", param[i]); - extra[pos] = 0; - pos--; - } - pos += sprintf(extra + pos, " %s", ret == _SUCCESS ? "OK" : "FAIL"); - - wrqu->data.length = strlen(extra) + 1; - -free_buf: - rtw_mfree(pbuf, len); - return 0; -} -#endif /* CONFIG_RTW_CUSTOMER_STR */ - -static int rtw_mp_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct iw_point *wrqu = (struct iw_point *)wdata; - u32 subcmd = wrqu->flags; - PADAPTER padapter = rtw_netdev_priv(dev); - - if (padapter == NULL) - { - return -ENETDOWN; - } - - if((padapter->bup == _FALSE )) - { - DBG_871X(" %s fail =>(padapter->bup == _FALSE )\n",__FUNCTION__); - return -ENETDOWN; - } - - if (RTW_CANNOT_RUN(padapter)) { - DBG_871X("%s fail =>(bSurpriseRemoved == _TRUE) || ( bDriverStopped == _TRUE)\n", __func__); - return -ENETDOWN; - } - - - //_rtw_memset(extra, 0x00, IW_PRIV_SIZE_MASK); - - if (extra == NULL) - { - wrqu->length = 0; - return -EIO; - } - - switch(subcmd) - { - case CTA_TEST: - DBG_871X("set CTA_TEST\n"); - rtw_cta_test_start (dev, info, wdata, extra); - break; - case MP_DISABLE_BT_COEXIST: - DBG_871X("set case MP_DISABLE_BT_COEXIST \n"); - rtw_mp_disable_bt_coexist(dev, info, wdata, extra); - break; - } - - - return 0; -} - - -static int rtw_mp_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct iw_point *wrqu = (struct iw_point *)wdata; - u32 subcmd = wrqu->flags; - PADAPTER padapter = rtw_netdev_priv(dev); - - //DBG_871X("in mp_get extra= %s \n",extra); - - if (padapter == NULL) - { - return -ENETDOWN; - } - if((padapter->bup == _FALSE )) - { - DBG_871X(" %s fail =>(padapter->bup == _FALSE )\n",__FUNCTION__); - return -ENETDOWN; - } - - if (RTW_CANNOT_RUN(padapter)) { - DBG_871X("%s fail =>(padapter->bSurpriseRemoved == _TRUE) || ( padapter->bDriverStopped == _TRUE)\n", __func__); - return -ENETDOWN; - } - - if (extra == NULL) { - wrqu->length = 0; - return -EIO; - } - - switch (subcmd) { - case MP_START: - DBG_871X("set case mp_start \n"); - rtw_mp_start (dev,info,wrqu,extra); - break; - - case MP_STOP: - DBG_871X("set case mp_stop \n"); - rtw_mp_stop (dev,info,wrqu,extra); - break; - - case MP_BANDWIDTH: - DBG_871X("set case mp_bandwidth \n"); - rtw_mp_bandwidth (dev,info,wrqu,extra); - break; - - case MP_RESET_STATS: - DBG_871X("set case MP_RESET_STATS \n"); - rtw_mp_reset_stats (dev,info,wrqu,extra); - break; - - case MP_SetRFPathSwh: - DBG_871X("set MP_SetRFPathSwitch \n"); - rtw_mp_SetRFPath (dev,info,wrqu,extra); - break; - - case WRITE_REG: - rtw_mp_write_reg(dev, info, wrqu, extra); - break; - - case WRITE_RF: - rtw_mp_write_rf(dev, info, wrqu, extra); - break; - - case MP_PHYPARA: - DBG_871X("mp_get MP_PHYPARA\n"); - rtw_mp_phypara(dev, info, wrqu, extra); - break; - - case MP_CHANNEL: - DBG_871X("set case mp_channel\n"); - rtw_mp_channel(dev , info, wrqu, extra); - break; - - case READ_REG: - DBG_871X("mp_get READ_REG\n"); - rtw_mp_read_reg(dev, info, wrqu, extra); - break; - case READ_RF: - DBG_871X("mp_get READ_RF\n"); - rtw_mp_read_rf(dev, info, wrqu, extra); - break; - - case MP_RATE: - DBG_871X("set case mp_rate\n"); - rtw_mp_rate(dev, info, wrqu, extra); - break; - - case MP_TXPOWER: - DBG_871X("set case MP_TXPOWER\n"); - rtw_mp_txpower(dev, info, wrqu, extra); - break; - - case MP_ANT_TX: - DBG_871X("set case MP_ANT_TX\n"); - rtw_mp_ant_tx(dev, info, wrqu, extra); - break; - - case MP_ANT_RX: - DBG_871X("set case MP_ANT_RX\n"); - rtw_mp_ant_rx(dev, info, wrqu, extra); - break; - - case MP_QUERY: - rtw_mp_trx_query(dev, info, wrqu, extra); - break; - - case MP_CTX: - DBG_871X("set case MP_CTX\n"); - rtw_mp_ctx(dev, info, wrqu, extra); - break; - - case MP_ARX: - DBG_871X("set case MP_ARX\n"); - rtw_mp_arx(dev, info, wrqu, extra); - break; - - case EFUSE_GET: - DBG_871X("efuse get EFUSE_GET\n"); - rtw_mp_efuse_get(dev, info, wdata, extra); - break; - - case MP_DUMP: - DBG_871X("set case MP_DUMP\n"); - rtw_mp_dump(dev, info, wrqu, extra); - break; - case MP_PSD: - DBG_871X("set case MP_PSD\n"); - rtw_mp_psd(dev, info, wrqu, extra); - break; - case MP_THER: - DBG_871X("set case MP_THER\n"); - rtw_mp_thermal(dev, info, wrqu, extra); - break; - case MP_PwrCtlDM: - DBG_871X("set MP_PwrCtlDM\n"); - rtw_mp_PwrCtlDM(dev, info, wrqu, extra); - break; - case MP_QueryDrvStats: - DBG_871X("mp_get MP_QueryDrvStats\n"); - rtw_mp_QueryDrv(dev, info, wdata, extra); - break; - case MP_PWRTRK: - DBG_871X("set case MP_PWRTRK\n"); - rtw_mp_pwrtrk(dev, info, wrqu, extra); - break; - case EFUSE_SET: - DBG_871X("set case efuse set\n"); - rtw_mp_efuse_set(dev, info, wdata, extra); - break; - case MP_GET_TXPOWER_INX: - DBG_871X("mp_get MP_GET_TXPOWER_INX\n"); - rtw_mp_txpower_index(dev, info, wrqu, extra); - break; - case MP_GETVER: - DBG_871X("mp_get MP_GETVER\n"); - rtw_mp_getver(dev, info, wdata, extra); - break; - case MP_MON: - DBG_871X("mp_get MP_MON\n"); - rtw_mp_mon(dev, info, wdata, extra); - break; - case EFUSE_MASK: - DBG_871X("mp_get EFUSE_MASK\n"); - rtw_efuse_mask_file(dev, info, wdata, extra); - break; - case EFUSE_FILE: - DBG_871X("mp_get EFUSE_FILE\n"); - rtw_efuse_file_map(dev, info, wdata, extra); - break; - case MP_TX: - DBG_871X("mp_get MP_TX\n"); - rtw_mp_tx(dev, info, wdata, extra); - break; - case MP_RX: - DBG_871X("mp_get MP_RX\n"); - rtw_mp_rx(dev, info, wdata, extra); - break; - case MP_HW_TX_MODE: - DBG_871X("mp_get MP_HW_TX_MODE\n"); - rtw_mp_hwtx(dev, info, wdata, extra); - break; -#ifdef CONFIG_RTW_CUSTOMER_STR - case MP_CUSTOMER_STR: - RTW_INFO("customer str\n"); - rtw_mp_customer_str(dev, info, wdata, extra); - break; -#endif -#if defined(CONFIG_RTL8723B) - case MP_SetBT: - DBG_871X("set MP_SetBT\n"); - rtw_mp_SetBT(dev, info, wdata, extra); - break; -#endif -#ifdef CONFIG_SDIO_INDIRECT_ACCESS - case MP_SD_IREAD: - rtw_mp_sd_iread(dev, info, wrqu, extra); - break; - case MP_SD_IWRITE: - rtw_mp_sd_iwrite(dev, info, wrqu, extra); - break; -#endif - } - - rtw_msleep_os(10); //delay 5ms for sending pkt before exit adb shell operation -return 0; -} - -#endif /*#if defined(CONFIG_MP_INCLUDED)*/ - static int rtw_wx_tdls_wfd_enable(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -12770,16 +12199,6 @@ static int rtw_test( #endif -#ifdef CONFIG_BT_COEXIST - if (strcmp(pch, "bton") == 0) { - rtw_btcoex_SetManualControl(padapter, _FALSE); - goto free_buf; - } else if (strcmp(pch, "btoff") == 0) { - rtw_btcoex_SetManualControl(padapter, _TRUE); - goto free_buf; - } -#endif - if (strcmp(pch, "h2c") == 0) { u8 param[8]; u8 count = 0; @@ -13081,13 +12500,8 @@ static iw_handler rtw_private_handler[] = rtw_dbg_port, //0x0B rtw_wx_write_rf, //0x0C rtw_wx_read_rf, //0x0D -#ifdef CONFIG_MP_INCLUDED - rtw_mp_set, //0x0E - rtw_mp_get, //0x0F -#else rtw_wx_priv_null, //0x0E rtw_wx_priv_null, //0x0F -#endif rtw_p2p_set, //0x10 rtw_p2p_get, //0x11 NULL, //0x12 @@ -13100,13 +12514,8 @@ static iw_handler rtw_private_handler[] = rtw_wx_priv_null, //0x17 rtw_rereg_nd_name, //0x18 rtw_wx_priv_null, //0x19 -#ifdef CONFIG_MP_INCLUDED - rtw_wx_priv_null, //0x1A - rtw_wx_priv_null, //0x1B -#else rtw_mp_efuse_set, //0x1A rtw_mp_efuse_get, //0x1B -#endif NULL, // 0x1C is reserved for hostapd rtw_test, // 0x1D #ifdef CONFIG_INTEL_WIDI diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_mp.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_mp.c deleted file mode 100644 index a39979585..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/ioctl_mp.c +++ /dev/null @@ -1,2334 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#if defined(CONFIG_MP_INCLUDED) - -#include -#include -#include -#include "../../hal/phydm/phydm_precomp.h" - - -#if defined(CONFIG_RTL8723B) -#include -#endif - -/* - * Input Format: %s,%d,%d - * %s is width, could be - * "b" for 1 byte - * "w" for WORD (2 bytes) - * "dw" for DWORD (4 bytes) - * 1st %d is address(offset) - * 2st %d is data to write - */ -int rtw_mp_write_reg(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char *pch, *pnext, *ptmp; - char *width_str; - char width, buf[5]; - u32 addr, data; - int ret; - PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - _rtw_memset(extra, 0, wrqu->length); - - pch = input; - - pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) - return -EINVAL; - *pnext = 0; - width_str = pch; - - pch = pnext + 1; - pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) - return -EINVAL; - *pnext = 0; - /*addr = simple_strtoul(pch, &ptmp, 16); - _rtw_memset(buf, '\0', sizeof(buf)); - _rtw_memcpy(buf, pch, pnext-pch); - ret = kstrtoul(buf, 16, &addr);*/ - ret = sscanf(pch, "%x", &addr); - if (addr > 0x3FFF) - return -EINVAL; - - pch = pnext + 1; - pnext = strpbrk(pch, " ,.-"); - if ((pch - input) >= wrqu->length) - return -EINVAL; - /*data = simple_strtoul(pch, &ptmp, 16);*/ - ret = sscanf(pch, "%x", &data); - DBG_871X("data=%x,addr=%x\n", (u32)data, (u32)addr); - ret = 0; - width = width_str[0]; - switch (width) { - case 'b': - /* 1 byte*/ - if (data > 0xFF) { - ret = -EINVAL; - break; - } - rtw_write8(padapter, addr, data); - break; - case 'w': - /* 2 bytes*/ - if (data > 0xFFFF) { - ret = -EINVAL; - break; - } - rtw_write16(padapter, addr, data); - break; - case 'd': - /* 4 bytes*/ - rtw_write32(padapter, addr, data); - break; - default: - ret = -EINVAL; - break; - } - - return ret; -} - - -/* - * Input Format: %s,%d - * %s is width, could be - * "b" for 1 byte - * "w" for WORD (2 bytes) - * "dw" for DWORD (4 bytes) - * %d is address(offset) - * - * Return: - * %d for data readed - */ -int rtw_mp_read_reg(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char input[wrqu->length]; - char *pch, *pnext, *ptmp; - char *width_str; - char width; - char data[20], tmp[20], buf[3]; - u32 addr = 0, strtout = 0; - u32 i = 0, j = 0, ret = 0, data32 = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - - - if (wrqu->length > 128) - return -EFAULT; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - _rtw_memset(extra, 0, wrqu->length); - _rtw_memset(data, '\0', sizeof(data)); - _rtw_memset(tmp, '\0', sizeof(tmp)); - pch = input; - pnext = strpbrk(pch, " ,.-"); - if (pnext == NULL) - return -EINVAL; - *pnext = 0; - width_str = pch; - - pch = pnext + 1; - - ret = sscanf(pch, "%x", &addr); - if (addr > 0x3FFF) - return -EINVAL; - - ret = 0; - width = width_str[0]; - - switch (width) { - case 'b': - data32 = rtw_read8(padapter, addr); - DBG_871X("%x\n", data32); - sprintf(extra, "%d", data32); - wrqu->length = strlen(extra); - break; - case 'w': - /* 2 bytes*/ - sprintf(data, "%04x\n", rtw_read16(padapter, addr)); - - for (i = 0 ; i <= strlen(data) ; i++) { - if (i % 2 == 0) { - tmp[j] = ' '; - j++; - } - if (data[i] != '\0') - tmp[j] = data[i]; - - j++; - } - pch = tmp; - DBG_871X("pch=%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - if (!pnext || ((pnext - tmp) > 4)) - break; - - pnext++; - if (*pnext != '\0') { - /*strtout = simple_strtoul(pnext , &ptmp, 16);*/ - ret = sscanf(pnext, "%x", &strtout); - sprintf(extra, "%s %d" , extra , strtout); - } else - break; - pch = pnext; - } - wrqu->length = strlen(extra); - break; - case 'd': - /* 4 bytes */ - sprintf(data, "%08x", rtw_read32(padapter, addr)); - /*add read data format blank*/ - for (i = 0 ; i <= strlen(data) ; i++) { - if (i % 2 == 0) { - tmp[j] = ' '; - j++; - } - if (data[i] != '\0') - tmp[j] = data[i]; - - j++; - } - pch = tmp; - DBG_871X("pch=%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - if (!pnext) - break; - - pnext++; - if (*pnext != '\0') { - ret = sscanf(pnext, "%x", &strtout); - sprintf(extra, "%s %d" , extra , strtout); - } else - break; - pch = pnext; - } - wrqu->length = strlen(extra); - break; - - default: - wrqu->length = 0; - ret = -EINVAL; - break; - } - - return ret; -} - - -/* - * Input Format: %d,%x,%x - * %d is RF path, should be smaller than MAX_RF_PATH_NUMS - * 1st %x is address(offset) - * 2st %x is data to write - */ -int rtw_mp_write_rf(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - - u32 path, addr, data; - int ret; - PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; - - - _rtw_memset(input, 0, wrqu->length); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - - ret = sscanf(input, "%d,%x,%x", &path, &addr, &data); - if (ret < 3) - return -EINVAL; - - if (path >= GET_HAL_RFPATH_NUM(padapter)) - return -EINVAL; - if (addr > 0xFF) - return -EINVAL; - if (data > 0xFFFFF) - return -EINVAL; - - _rtw_memset(extra, 0, wrqu->length); - - write_rfreg(padapter, path, addr, data); - - sprintf(extra, "write_rf completed\n"); - wrqu->length = strlen(extra); - - return 0; -} - - -/* - * Input Format: %d,%x - * %d is RF path, should be smaller than MAX_RF_PATH_NUMS - * %x is address(offset) - * - * Return: - * %d for data readed - */ -int rtw_mp_read_rf(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - char input[wrqu->length]; - char *pch, *pnext, *ptmp; - char data[20], tmp[20], buf[3]; - u32 path, addr, strtou; - u32 ret, i = 0 , j = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - - if (wrqu->length > 128) - return -EFAULT; - _rtw_memset(input, 0, wrqu->length); - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - ret = sscanf(input, "%d,%x", &path, &addr); - if (ret < 2) - return -EINVAL; - - if (path >= GET_HAL_RFPATH_NUM(padapter)) - return -EINVAL; - if (addr > 0xFF) - return -EINVAL; - - _rtw_memset(extra, 0, wrqu->length); - - sprintf(data, "%08x", read_rfreg(padapter, path, addr)); - /*add read data format blank*/ - for (i = 0 ; i <= strlen(data) ; i++) { - if (i % 2 == 0) { - tmp[j] = ' '; - j++; - } - tmp[j] = data[i]; - j++; - } - pch = tmp; - DBG_871X("pch=%s", pch); - - while (*pch != '\0') { - pnext = strpbrk(pch, " "); - if (!pnext) - break; - pnext++; - if (*pnext != '\0') { - /*strtou =simple_strtoul(pnext , &ptmp, 16);*/ - ret = sscanf(pnext, "%x", &strtou); - sprintf(extra, "%s %d" , extra , strtou); - } else - break; - pch = pnext; - } - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_start(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - int ret = 0; - u8 val8; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct hal_ops *pHalFunc = &padapter->HalFunc; - - rtw_pm_set_ips(padapter, IPS_NONE); - LeaveAllPowerSaveMode(padapter); - - if (rtw_mp_cmd(padapter, MP_START, RTW_CMDF_WAIT_ACK) != _SUCCESS) - ret = -EPERM; - - - _rtw_memset(extra, 0, wrqu->length); - sprintf(extra, "mp_start %s\n", ret == 0 ? "ok" : "fail"); - wrqu->length = strlen(extra); - - return ret; -} - - - -int rtw_mp_stop(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - int ret = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - struct hal_ops *pHalFunc = &padapter->HalFunc; - - if (rtw_mp_cmd(padapter, MP_STOP, RTW_CMDF_WAIT_ACK) != _SUCCESS) - ret = -EPERM; - - _rtw_memset(extra, 0, wrqu->length); - sprintf(extra, "mp_stop %s\n", ret == 0 ? "ok" : "fail"); - wrqu->length = strlen(extra); - - return ret; -} - - -int rtw_mp_rate(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 rate = MPT_RATE_1M; - u8 input[wrqu->length]; - PADAPTER padapter = rtw_netdev_priv(dev); - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - rate = rtw_mpRateParseFunc(padapter, input); - padapter->mppriv.rateidx = rate; - - if (rate == 0 && strcmp(input, "1M") != 0) { - rate = rtw_atoi(input); - padapter->mppriv.rateidx = MRateToHwRate(rate); - /*if (rate <= 0x7f) - rate = wifirate2_ratetbl_inx((u8)rate); - else if (rate < 0xC8) - rate = (rate - 0x79 + MPT_RATE_MCS0); - HT rate 0x80(MCS0) ~ 0x8F(MCS15) ~ 0x9F(MCS31) 128~159 - VHT1SS~2SS rate 0xA0 (VHT1SS_MCS0 44) ~ 0xB3 (VHT2SS_MCS9 #63) 160~179 - VHT rate 0xB4 (VHT3SS_MCS0 64) ~ 0xC7 (VHT2SS_MCS9 #83) 180~199 - else - VHT rate 0x90(VHT1SS_MCS0) ~ 0x99(VHT1SS_MCS9) 144~153 - rate =(rate - MPT_RATE_VHT1SS_MCS0); - */ - } - _rtw_memset(extra, 0, wrqu->length); - - sprintf(extra, "Set data rate to %s index %d" , input, padapter->mppriv.rateidx); - DBG_871X("%s: %s rate index=%d\n", __func__, input, padapter->mppriv.rateidx); - - if (padapter->mppriv.rateidx >= DESC_RATEVHTSS4MCS9) - return -EINVAL; - - pMptCtx->MptRateIndex = HwRateToMPTRate(padapter->mppriv.rateidx); - SetDataRate(padapter); - - wrqu->length = strlen(extra); - return 0; -} - - -int rtw_mp_channel(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - u8 input[wrqu->length]; - u32 channel = 1; - int cur_ch_offset; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - channel = rtw_atoi(input); - /*DBG_871X("%s: channel=%d\n", __func__, channel);*/ - _rtw_memset(extra, 0, wrqu->length); - sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel , channel); - padapter->mppriv.channel = channel; - SetChannel(padapter); - pHalData->CurrentChannel = channel; - - wrqu->length = strlen(extra); - return 0; -} - - -int rtw_mp_bandwidth(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 bandwidth = 0, sg = 0; - int cur_ch_offset; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - u8 input[wrqu->length]; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - if (sscanf(input, "40M=%d,shortGI=%d", &bandwidth, &sg) > 0) - DBG_871X("%s: bw=%d sg=%d\n", __func__, bandwidth , sg); - - if (bandwidth == 1) - bandwidth = CHANNEL_WIDTH_40; - else if (bandwidth == 2) - bandwidth = CHANNEL_WIDTH_80; - - padapter->mppriv.bandwidth = (u8)bandwidth; - padapter->mppriv.preamble = sg; - _rtw_memset(extra, 0, wrqu->length); - sprintf(extra, "Change BW %d to BW %d\n", pHalData->CurrentChannelBW , bandwidth); - - SetBandwidth(padapter); - pHalData->CurrentChannelBW = bandwidth; - /*cur_ch_offset = rtw_get_offset_by_ch(padapter->mppriv.channel);*/ - /*set_channel_bwmode(padapter, padapter->mppriv.channel, cur_ch_offset, bandwidth);*/ - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_txpower_index(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; - u32 rfpath; - u32 txpower_inx; - - if (wrqu->length > 128) - return -EFAULT; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - rfpath = rtw_atoi(input); - txpower_inx = mpt_ProQueryCalTxPower(padapter, rfpath); - sprintf(extra, " %d", txpower_inx); - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_txpower(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 idx_a = 0, idx_b = 0, idx_c = 0, idx_d = 0, status = 0; - int MsetPower = 1; - u8 input[wrqu->length]; - - PADAPTER padapter = rtw_netdev_priv(dev); - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - MsetPower = strncmp(input, "off", 3); - if (MsetPower == 0) { - padapter->mppriv.bSetTxPower = 0; - sprintf(extra, "MP Set power off"); - } else { - if (sscanf(input, "patha=%d,pathb=%d,pathc=%d,pathd=%d", &idx_a, &idx_b, &idx_c, &idx_d) < 3) - DBG_871X("Invalid format on line %s ,patha=%d,pathb=%d,pathc=%d,pathd=%d\n", input , idx_a , idx_b , idx_c , idx_d); - - sprintf(extra, "Set power level path_A:%d path_B:%d path_C:%d path_D:%d", idx_a , idx_b , idx_c , idx_d); - padapter->mppriv.txpoweridx = (u8)idx_a; - - pMptCtx->TxPwrLevel[ODM_RF_PATH_A] = (u8)idx_a; - pMptCtx->TxPwrLevel[ODM_RF_PATH_B] = (u8)idx_b; - pMptCtx->TxPwrLevel[ODM_RF_PATH_C] = (u8)idx_c; - pMptCtx->TxPwrLevel[ODM_RF_PATH_D] = (u8)idx_d; - padapter->mppriv.bSetTxPower = 1; - - SetTxPower(padapter); - } - - wrqu->length = strlen(extra); - return 0; -} - - -int rtw_mp_ant_tx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 i; - u8 input[wrqu->length]; - u16 antenna = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - sprintf(extra, "switch Tx antenna to %s", input); - - for (i = 0; i < strlen(input); i++) { - switch (input[i]) { - case 'a': - antenna |= ANTENNA_A; - break; - case 'b': - antenna |= ANTENNA_B; - break; - case 'c': - antenna |= ANTENNA_C; - break; - case 'd': - antenna |= ANTENNA_D; - break; - } - } - /*antenna |= BIT(extra[i]-'a');*/ - DBG_871X("%s: antenna=0x%x\n", __func__, antenna); - padapter->mppriv.antenna_tx = antenna; - padapter->mppriv.antenna_rx = antenna; - /*DBG_871X("%s:mppriv.antenna_rx=%d\n", __func__, padapter->mppriv.antenna_tx);*/ - pHalData->AntennaTxPath = antenna; - - SetAntenna(padapter); - - wrqu->length = strlen(extra); - return 0; -} - - -int rtw_mp_ant_rx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 i; - u16 antenna = 0; - u8 input[wrqu->length]; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - /*DBG_871X("%s: input=%s\n", __func__, input);*/ - _rtw_memset(extra, 0, wrqu->length); - - sprintf(extra, "switch Rx antenna to %s", input); - - for (i = 0; i < strlen(input); i++) { - switch (input[i]) { - case 'a': - antenna |= ANTENNA_A; - break; - case 'b': - antenna |= ANTENNA_B; - break; - case 'c': - antenna |= ANTENNA_C; - break; - case 'd': - antenna |= ANTENNA_D; - break; - } - } - - DBG_871X("%s: antenna=0x%x\n", __func__, antenna); - padapter->mppriv.antenna_tx = antenna; - padapter->mppriv.antenna_rx = antenna; - pHalData->AntennaRxPath = antenna; - /*DBG_871X("%s:mppriv.antenna_rx=%d\n", __func__, padapter->mppriv.antenna_rx);*/ - SetAntenna(padapter); - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_set_ctx_destAddr(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - int jj, kk = 0; - - struct pkt_attrib *pattrib; - struct mp_priv *pmp_priv; - PADAPTER padapter = rtw_netdev_priv(dev); - - pmp_priv = &padapter->mppriv; - pattrib = &pmp_priv->tx.attrib; - - if (strlen(extra) < 5) - return _FAIL; - - DBG_871X("%s: in=%s\n", __func__, extra); - for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) - pattrib->dst[jj] = key_2char2num(extra[kk], extra[kk + 1]); - - DBG_871X("pattrib->dst:%x %x %x %x %x %x\n", pattrib->dst[0], pattrib->dst[1], pattrib->dst[2], pattrib->dst[3], pattrib->dst[4], pattrib->dst[5]); - return 0; -} - - - -int rtw_mp_ctx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 pkTx = 1; - int countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1; - u32 bStartTest = 1; - u32 count = 0, pktinterval = 0, pktlen = 0; - u8 status; - struct mp_priv *pmp_priv; - struct pkt_attrib *pattrib; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - pmp_priv = &padapter->mppriv; - pattrib = &pmp_priv->tx.attrib; - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) - return -EFAULT; - - DBG_871X("%s: in=%s\n", __func__, extra); -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->adapter_type == SECONDARY_ADAPTER) { - sprintf(extra, "Error: MP mode can't support Virtual Adapter, Please to use main Adapter.\n"); - wrqu->length = strlen(extra); - return 0; - } -#endif - countPkTx = strncmp(extra, "count=", 5); /* strncmp TRUE is 0*/ - cotuTx = strncmp(extra, "background", 20); - CarrSprTx = strncmp(extra, "background,cs", 20); - scTx = strncmp(extra, "background,sc", 20); - sgleTx = strncmp(extra, "background,stone", 20); - pkTx = strncmp(extra, "background,pkt", 20); - stop = strncmp(extra, "stop", 4); - if (sscanf(extra, "count=%d,pkt", &count) > 0) - DBG_871X("count= %d\n", count); - if (sscanf(extra, "pktinterval=%d", &pktinterval) > 0) - DBG_871X("pktinterval= %d\n", pktinterval); - - if (sscanf(extra, "pktlen=%d", &pktlen) > 0) - DBG_871X("pktlen= %d\n", pktlen); - - if (_rtw_memcmp(extra, "destmac=", 8)) { - wrqu->length -= 8; - rtw_set_ctx_destAddr(dev, info, wrqu, &extra[8]); - sprintf(extra, "Set dest mac OK !\n"); - return 0; - } - - /*DBG_871X("%s: count=%d countPkTx=%d cotuTx=%d CarrSprTx=%d scTx=%d sgleTx=%d pkTx=%d stop=%d\n", __func__, count, countPkTx, cotuTx, CarrSprTx, pkTx, sgleTx, scTx, stop);*/ - _rtw_memset(extra, '\0', strlen(extra)); - - if (pktinterval != 0) { - sprintf(extra, "Pkt Interval = %d", pktinterval); - padapter->mppriv.pktInterval = pktinterval; - wrqu->length = strlen(extra); - return 0; - } - if (pktlen != 0) { - sprintf(extra, "Pkt len = %d", pktlen); - pattrib->pktlen = pktlen; - wrqu->length = strlen(extra); - return 0; - } - if (stop == 0) { - bStartTest = 0; /* To set Stop*/ - pmp_priv->tx.stop = 1; - sprintf(extra, "Stop continuous Tx"); - ODM_Write_DIG(&pHalData->odmpriv, 0x20); - } else { - bStartTest = 1; - ODM_Write_DIG(&pHalData->odmpriv, 0x7f); - if (pmp_priv->mode != MP_ON) { - if (pmp_priv->tx.stop != 1) { - DBG_871X("%s: MP_MODE != ON %d\n", __func__, pmp_priv->mode); - return -EFAULT; - } - } - } - - pmp_priv->tx.count = count; - - if (pkTx == 0 || countPkTx == 0) - pmp_priv->mode = MP_PACKET_TX; - if (sgleTx == 0) - pmp_priv->mode = MP_SINGLE_TONE_TX; - if (cotuTx == 0) - pmp_priv->mode = MP_CONTINUOUS_TX; - if (CarrSprTx == 0) - pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; - if (scTx == 0) - pmp_priv->mode = MP_SINGLE_CARRIER_TX; - - status = rtw_mp_pretx_proc(padapter, bStartTest, extra); - - wrqu->length = strlen(extra); - return status; -} - - - -int rtw_mp_disable_bt_coexist(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = (PADAPTER)rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct hal_ops *pHalFunc = &padapter->HalFunc; - - u8 input[wrqu->data.length]; - u32 bt_coexist; - - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - bt_coexist = rtw_atoi(input); - - if (bt_coexist == 0) { - RT_TRACE(_module_mp_, _drv_info_, - ("Set OID_RT_SET_DISABLE_BT_COEXIST: disable BT_COEXIST\n")); - DBG_871X("Set OID_RT_SET_DISABLE_BT_COEXIST: disable BT_COEXIST\n"); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_HaltNotify(padapter); - rtw_btcoex_SetManualControl(padapter, _TRUE); - /* Force to switch Antenna to WiFi*/ - rtw_write16(padapter, 0x870, 0x300); - rtw_write16(padapter, 0x860, 0x110); -#endif - /* CONFIG_BT_COEXIST */ - } else { - RT_TRACE(_module_mp_, _drv_info_, - ("Set OID_RT_SET_DISABLE_BT_COEXIST: enable BT_COEXIST\n")); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_SetManualControl(padapter, _FALSE); -#endif - } - - return 0; -} - - -int rtw_mp_arx(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - int bStartRx = 0, bStopRx = 0, bQueryPhy = 0, bQueryMac = 0, bSetBssid = 0; - int bmac_filter = 0, bfilter_init = 0, bmon = 0, bSmpCfg = 0, bloopbk = 0; - u8 input[wrqu->length]; - char *pch, *ptmp, *token, *tmp[2] = {0x00, 0x00}; - u32 i = 0, ii = 0, jj = 0, kk = 0, cnts = 0, ret; - PADAPTER padapter = rtw_netdev_priv(dev); - struct mp_priv *pmppriv = &padapter->mppriv; - struct dbg_rx_counter rx_counter; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - DBG_871X("%s: %s\n", __func__, input); -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->adapter_type == SECONDARY_ADAPTER) { - sprintf(extra, "Error: MP mode can't support Virtual Adapter, Please to use main Adapter.\n"); - wrqu->length = strlen(extra); - return 0; - } -#endif - bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - bQueryMac = (strncmp(input, "mac", 3) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - bSetBssid = (strncmp(input, "setbssid=", 8) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - /*bfilter_init = (strncmp(input, "filter_init",11)==0)?1:0;*/ - bmac_filter = (strncmp(input, "accept_mac", 10) == 0) ? 1 : 0; - bmon = (strncmp(input, "mon=", 4) == 0) ? 1 : 0; - bSmpCfg = (strncmp(input , "smpcfg=" , 7) == 0) ? 1 : 0; - pmppriv->bloopback = (strncmp(input, "loopbk", 6) == 0) ? 1 : 0; /* strncmp TRUE is 0*/ - - if (bSetBssid == 1) { - pch = input; - while ((token = strsep(&pch, "=")) != NULL) { - if (i > 1) - break; - tmp[i] = token; - i++; - } - if ((tmp[0] != NULL) && (tmp[1] != NULL)) { - cnts = strlen(tmp[1]) / 2; - if (cnts < 1) - return -EFAULT; - DBG_871X("%s: cnts=%d\n", __func__, cnts); - DBG_871X("%s: data=%s\n", __func__, tmp[1]); - for (jj = 0, kk = 0; jj < cnts ; jj++, kk += 2) { - pmppriv->network_macaddr[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); - DBG_871X("network_macaddr[%d]=%x\n", jj, pmppriv->network_macaddr[jj]); - } - } else - return -EFAULT; - - pmppriv->bSetRxBssid = _TRUE; - } - - if (bmac_filter) { - pmppriv->bmac_filter = bmac_filter; - pch = input; - while ((token = strsep(&pch, "=")) != NULL) { - if (i > 1) - break; - tmp[i] = token; - i++; - } - if ((tmp[0] != NULL) && (tmp[1] != NULL)) { - cnts = strlen(tmp[1]) / 2; - if (cnts < 1) - return -EFAULT; - DBG_871X("%s: cnts=%d\n", __func__, cnts); - DBG_871X("%s: data=%s\n", __func__, tmp[1]); - for (jj = 0, kk = 0; jj < cnts ; jj++, kk += 2) { - pmppriv->mac_filter[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); - DBG_871X("%s mac_filter[%d]=%x\n", __func__, jj, pmppriv->mac_filter[jj]); - } - } else - return -EFAULT; - - } - - if (bStartRx) { - sprintf(extra, "start"); - SetPacketRx(padapter, bStartRx, _FALSE); - } else if (bStopRx) { - SetPacketRx(padapter, bStartRx, _FALSE); - pmppriv->bmac_filter = _FALSE; - sprintf(extra, "Received packet OK:%d CRC error:%d ,Filter out:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount, padapter->mppriv.rx_pktcount_filter_out); - } else if (bQueryPhy) { - _rtw_memset(&rx_counter, 0, sizeof(struct dbg_rx_counter)); - rtw_dump_phy_rx_counters(padapter, &rx_counter); - - DBG_871X("%s: OFDM_FA =%d\n", __func__, rx_counter.rx_ofdm_fa); - DBG_871X("%s: CCK_FA =%d\n", __func__, rx_counter.rx_cck_fa); - sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", rx_counter.rx_pkt_ok, rx_counter.rx_pkt_crc_error, rx_counter.rx_cck_fa + rx_counter.rx_ofdm_fa); - - - } else if (bQueryMac) { - _rtw_memset(&rx_counter, 0, sizeof(struct dbg_rx_counter)); - rtw_dump_mac_rx_counters(padapter, &rx_counter); - sprintf(extra, "Mac Received packet OK: %d , CRC error: %d , Drop Packets: %d\n", - rx_counter.rx_pkt_ok, rx_counter.rx_pkt_crc_error, rx_counter.rx_pkt_drop); - - } - - if (bmon == 1) { - ret = sscanf(input, "mon=%d", &bmon); - - if (bmon == 1) { - pmppriv->rx_bindicatePkt = _TRUE; - sprintf(extra, "Indicating Receive Packet to network start\n"); - } else { - pmppriv->rx_bindicatePkt = _FALSE; - sprintf(extra, "Indicating Receive Packet to network Stop\n"); - } - } - if (bSmpCfg == 1) { - ret = sscanf(input, "smpcfg=%d", &bSmpCfg); - - if (bSmpCfg == 1) { - pmppriv->bRTWSmbCfg = _TRUE; - sprintf(extra , "Indicate By Simple Config Format\n"); - SetPacketRx(padapter, _TRUE, _TRUE); - } else { - pmppriv->bRTWSmbCfg = _FALSE; - sprintf(extra , "Indicate By Normal Format\n"); - SetPacketRx(padapter, _TRUE, _FALSE); - } - } - - if (pmppriv->bloopback == _TRUE) { - sprintf(extra , "Enter MAC LoopBack mode\n"); - _rtw_write32(padapter, 0x100, 0xB0106FF); - DBG_871X("0x100 :0x%x" , _rtw_read32(padapter, 0x100)); - _rtw_write16(padapter, 0x608, 0x30c); - DBG_871X("0x100 :0x%x" , _rtw_read32(padapter, 0x608)); - } - - wrqu->length = strlen(extra) + 1; - - return 0; -} - - -int rtw_mp_trx_query(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u32 txok, txfail, rxok, rxfail, rxfilterout; - PADAPTER padapter = rtw_netdev_priv(dev); - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - RT_PMAC_TX_INFO PMacTxInfo = pMptCtx->PMacTxInfo; - - if (PMacTxInfo.bEnPMacTx == TRUE) - txok = hal_mpt_query_phytxok(padapter); - else - txok = padapter->mppriv.tx.sended; - - txfail = 0; - rxok = padapter->mppriv.rx_pktcount; - rxfail = padapter->mppriv.rx_crcerrpktcount; - rxfilterout = padapter->mppriv.rx_pktcount_filter_out; - - _rtw_memset(extra, '\0', 128); - - sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ,Rx Filter out:%d\n", txok, txfail, rxok, rxfail, rxfilterout); - - wrqu->length = strlen(extra) + 1; - - return 0; -} - - -int rtw_mp_pwrtrk(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 enable; - u32 thermal; - s32 ret; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - u8 input[wrqu->length]; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - _rtw_memset(extra, 0, wrqu->length); - - enable = 1; - if (wrqu->length > 1) { - /* not empty string*/ - if (strncmp(input, "stop", 4) == 0) { - enable = 0; - sprintf(extra, "mp tx power tracking stop"); - } else if (sscanf(input, "ther=%d", &thermal) == 1) { - ret = SetThermalMeter(padapter, (u8)thermal); - if (ret == _FAIL) - return -EPERM; - sprintf(extra, "mp tx power tracking start,target value=%d ok", thermal); - } else - return -EINVAL; - } - - ret = SetPowerTracking(padapter, enable); - if (ret == _FAIL) - return -EPERM; - - wrqu->length = strlen(extra); - - return 0; -} - - - -int rtw_mp_psd(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - u8 input[wrqu->length]; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - strcpy(extra, input); - - wrqu->length = mp_query_psd(padapter, extra); - - return 0; -} - - -int rtw_mp_thermal(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - u8 val; - int bwrite = 1; - -#ifdef CONFIG_RTL8188E - u16 addr = EEPROM_THERMAL_METER_88E; -#endif -#if defined(CONFIG_RTL8812A) || defined(CONFIG_RTL8821A) || defined(CONFIG_RTL8814A) - u16 addr = EEPROM_THERMAL_METER_8812; -#endif -#ifdef CONFIG_RTL8192E - u16 addr = EEPROM_THERMAL_METER_8192E; -#endif -#ifdef CONFIG_RTL8723B - u16 addr = EEPROM_THERMAL_METER_8723B; -#endif -#ifdef CONFIG_RTL8703B - u16 addr = EEPROM_THERMAL_METER_8703B; -#endif -#ifdef CONFIG_RTL8188F - u16 addr = EEPROM_THERMAL_METER_8188F; -#endif - u16 cnt = 1; - u16 max_available_size = 0; - PADAPTER padapter = rtw_netdev_priv(dev); - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) - return -EFAULT; - - bwrite = strncmp(extra, "write", 6);/* strncmp TRUE is 0*/ - - GetThermalMeter(padapter, &val); - - if (bwrite == 0) { - /*DBG_871X("to write val:%d",val);*/ - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (PVOID)&max_available_size, _FALSE); - if (2 > max_available_size) { - DBG_871X("no available efuse!\n"); - return -EFAULT; - } - if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { - DBG_871X("rtw_efuse_map_write error\n"); - return -EFAULT; - } - sprintf(extra, " efuse write ok :%d", val); - } else - sprintf(extra, "%d", val); - wrqu->length = strlen(extra); - - return 0; -} - - - -int rtw_mp_reset_stats(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct mp_priv *pmp_priv; - struct pkt_attrib *pattrib; - PADAPTER padapter = rtw_netdev_priv(dev); - - pmp_priv = &padapter->mppriv; - - pmp_priv->tx.sended = 0; - pmp_priv->tx_pktcount = 0; - pmp_priv->rx_pktcount = 0; - pmp_priv->rx_pktcount_filter_out = 0; - pmp_priv->rx_crcerrpktcount = 0; - - rtw_reset_phy_rx_counters(padapter); - rtw_reset_mac_rx_counters(padapter); - - _rtw_memset(extra, 0, wrqu->length); - sprintf(extra, "mp_reset_stats ok\n"); - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_dump(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - struct mp_priv *pmp_priv; - struct pkt_attrib *pattrib; - u32 value; - u8 input[wrqu->length]; - u8 rf_type, path_nums = 0; - u32 i, j = 1, path; - PADAPTER padapter = rtw_netdev_priv(dev); - - pmp_priv = &padapter->mppriv; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - if (strncmp(input, "all", 4) == 0) { - mac_reg_dump(RTW_DBGDUMP, padapter); - bb_reg_dump(RTW_DBGDUMP, padapter); - rf_reg_dump(RTW_DBGDUMP, padapter); - } - return 0; -} - - -int rtw_mp_phypara(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - char input[wrqu->length]; - u32 valxcap, ret; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - DBG_871X("%s:iwpriv in=%s\n", __func__, input); - - ret = sscanf(input, "xcap=%d", &valxcap); - - pHalData->CrystalCap = (u8)valxcap; - hal_set_crystal_cap(padapter , valxcap); - - sprintf(extra, "Set xcap=%d", valxcap); - wrqu->length = strlen(extra) + 1; - - return 0; - -} - - -int rtw_mp_SetRFPath(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->length]; - int bMain = 1, bTurnoff = 1; - - DBG_871X("%s:iwpriv in=%s\n", __func__, input); - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - bMain = strncmp(input, "1", 2); /* strncmp TRUE is 0*/ - bTurnoff = strncmp(input, "0", 3); /* strncmp TRUE is 0*/ - - _rtw_memset(extra, 0, wrqu->length); - - if (bMain == 0) { - MP_PHY_SetRFPathSwitch(padapter, _TRUE); - DBG_871X("%s:PHY_SetRFPathSwitch=TRUE\n", __func__); - sprintf(extra, "mp_setrfpath Main\n"); - } else if (bTurnoff == 0) { - MP_PHY_SetRFPathSwitch(padapter, _FALSE); - DBG_871X("%s:PHY_SetRFPathSwitch=FALSE\n", __func__); - sprintf(extra, "mp_setrfpath Aux\n"); - } - - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_QueryDrv(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - char input[wrqu->data.length]; - int qAutoLoad = 1; - - PHAL_DATA_TYPE pHalData = GET_HAL_DATA(padapter); - - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - DBG_871X("%s:iwpriv in=%s\n", __func__, input); - - qAutoLoad = strncmp(input, "autoload", 8); /* strncmp TRUE is 0*/ - - if (qAutoLoad == 0) { - DBG_871X("%s:qAutoLoad\n", __func__); - - if (pHalData->bautoload_fail_flag) - sprintf(extra, "fail"); - else - sprintf(extra, "ok"); - } - wrqu->data.length = strlen(extra) + 1; - return 0; -} - - -int rtw_mp_PwrCtlDM(struct net_device *dev, - struct iw_request_info *info, - struct iw_point *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - u8 input[wrqu->length]; - int bstart = 1; - - if (copy_from_user(input, wrqu->pointer, wrqu->length)) - return -EFAULT; - - bstart = strncmp(input, "start", 5); /* strncmp TRUE is 0*/ - if (bstart == 0) { - sprintf(extra, "PwrCtlDM start\n"); - MPT_PwrCtlDM(padapter, 1); - } else { - sprintf(extra, "PwrCtlDM stop\n"); - MPT_PwrCtlDM(padapter, 0); - } - wrqu->length = strlen(extra); - - return 0; -} - - -int rtw_mp_getver(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - struct mp_priv *pmp_priv; - - pmp_priv = &padapter->mppriv; - - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - sprintf(extra, "rtwpriv=%d\n", RTWPRIV_VER_INFO); - wrqu->data.length = strlen(extra); - return 0; -} - - -int rtw_mp_mon(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - struct mp_priv *pmp_priv = &padapter->mppriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct hal_ops *pHalFunc = &padapter->HalFunc; - NDIS_802_11_NETWORK_INFRASTRUCTURE networkType; - int bstart = 1, bstop = 1; - - networkType = Ndis802_11Infrastructure; - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - rtw_pm_set_ips(padapter, IPS_NONE); - LeaveAllPowerSaveMode(padapter); - -#ifdef CONFIG_MP_INCLUDED - if (init_mp_priv(padapter) == _FAIL) - DBG_871X("%s: initialize MP private data Fail!\n", __func__); - padapter->mppriv.channel = 6; - - bstart = strncmp(extra, "start", 5); /* strncmp TRUE is 0*/ - bstop = strncmp(extra, "stop", 4); /* strncmp TRUE is 0*/ - if (bstart == 0) { - mp_join(padapter, WIFI_FW_ADHOC_STATE); - SetPacketRx(padapter, _TRUE, _FALSE); - SetChannel(padapter); - pmp_priv->rx_bindicatePkt = _TRUE; - pmp_priv->bRTWSmbCfg = _TRUE; - sprintf(extra, "monitor mode start\n"); - } else if (bstop == 0) { - SetPacketRx(padapter, _FALSE, _FALSE); - pmp_priv->rx_bindicatePkt = _FALSE; - pmp_priv->bRTWSmbCfg = _FALSE; - padapter->registrypriv.mp_mode = 1; - pHalFunc->hal_deinit(padapter); - padapter->registrypriv.mp_mode = 0; - pHalFunc->hal_init(padapter); - /*rtw_disassoc_cmd(padapter, 0, _TRUE);*/ - if (check_fwstate(pmlmepriv, _FW_LINKED) == _TRUE) { - rtw_disassoc_cmd(padapter, 500, _TRUE); - rtw_indicate_disconnect(padapter, 0, _FALSE); - /*rtw_free_assoc_resources(padapter, 1);*/ - } - rtw_pm_set_ips(padapter, IPS_NORMAL); - sprintf(extra, "monitor mode Stop\n"); - } -#endif - wrqu->data.length = strlen(extra); - return 0; -} - -int rtw_mp_pretx_proc(PADAPTER padapter, u8 bStartTest, char *extra) -{ - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct mp_priv *pmp_priv = &padapter->mppriv; - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - - switch (pmp_priv->mode) { - - case MP_PACKET_TX: - if (bStartTest == 0) { - pmp_priv->tx.stop = 1; - pmp_priv->mode = MP_ON; - sprintf(extra, "Stop continuous Tx"); - } else if (pmp_priv->tx.stop == 1) { - sprintf(extra, "%s\nStart continuous DA=ffffffffffff len=1500 count=%u\n", extra, pmp_priv->tx.count); - pmp_priv->tx.stop = 0; - SetPacketTx(padapter); - } else { - return -EFAULT; - } - return 0; - case MP_SINGLE_TONE_TX: - if (bStartTest != 0) - sprintf(extra, "%s\nStart continuous DA=ffffffffffff len=1500\n infinite=yes.", extra); - SetSingleToneTx(padapter, (u8)bStartTest); - break; - case MP_CONTINUOUS_TX: - if (bStartTest != 0) - sprintf(extra, "%s\nStart continuous DA=ffffffffffff len=1500\n infinite=yes.", extra); - SetContinuousTx(padapter, (u8)bStartTest); - break; - case MP_CARRIER_SUPPRISSION_TX: - if (bStartTest != 0) { - if (HwRateToMPTRate(pmp_priv->rateidx) <= MPT_RATE_11M) - sprintf(extra, "%s\nStart continuous DA=ffffffffffff len=1500\n infinite=yes.", extra); - else - sprintf(extra, "%s\nSpecify carrier suppression but not CCK rate", extra); - } - SetCarrierSuppressionTx(padapter, (u8)bStartTest); - break; - case MP_SINGLE_CARRIER_TX: - if (bStartTest != 0) - sprintf(extra, "%s\nStart continuous DA=ffffffffffff len=1500\n infinite=yes.", extra); - SetSingleCarrierTx(padapter, (u8)bStartTest); - break; - - default: - sprintf(extra, "Error! Continuous-Tx is not on-going."); - return -EFAULT; - } - - if (bStartTest == 1 && pmp_priv->mode != MP_ON) { - struct mp_priv *pmp_priv = &padapter->mppriv; - - if (pmp_priv->tx.stop == 0) { - pmp_priv->tx.stop = 1; - rtw_msleep_os(5); - } -#ifdef CONFIG_80211N_HT - pmp_priv->tx.attrib.ht_en = 1; -#endif - pmp_priv->tx.stop = 0; - pmp_priv->tx.count = 1; - SetPacketTx(padapter); - } else - pmp_priv->mode = MP_ON; - -#if defined(CONFIG_RTL8812A) - if (IS_HARDWARE_TYPE_8812AU(padapter)) { - /* <20130425, Kordan> Turn off OFDM Rx to prevent from CCA causing Tx hang.*/ - if (pmp_priv->mode == MP_PACKET_TX) - PHY_SetBBReg(padapter, rCCAonSec_Jaguar, BIT3, 1); - else - PHY_SetBBReg(padapter, rCCAonSec_Jaguar, BIT3, 0); - } -#endif - - return 0; -} - - -int rtw_mp_tx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct mp_priv *pmp_priv = &padapter->mppriv; - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - struct registry_priv *pregistrypriv = &padapter->registrypriv; - - u32 bandwidth = 0, sg = 0, channel = 6, txpower = 40, rate = 108, ant = 0, txmode = 1, count = 0; - u8 i = 0, j = 0, bStartTest = 1, status = 0, Idx = 0, tmpU1B = 0; - u16 antenna = 0; - - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - DBG_871X("extra = %s\n", extra); -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->adapter_type == SECONDARY_ADAPTER) { - sprintf(extra, "Error: MP mode can't support Virtual Adapter, Please to use main Adapter.\n"); - wrqu->data.length = strlen(extra); - return 0; - } -#endif - - if (strncmp(extra, "stop", 3) == 0) { - bStartTest = 0; /* To set Stop*/ - pmp_priv->tx.stop = 1; - sprintf(extra, "Stop continuous Tx"); - status = rtw_mp_pretx_proc(padapter, bStartTest, extra); - wrqu->data.length = strlen(extra); - return status; - } else if (strncmp(extra, "count", 5) == 0) { - if (sscanf(extra, "count=%d", &count) < 1) - DBG_871X("Got Count=%d]\n", count); - pmp_priv->tx.count = count; - return 0; - } else if (strncmp(extra, "setting", 7) == 0) { - _rtw_memset(extra, 0, wrqu->data.length); - sprintf(extra, "Current Setting :\n Channel:%d", pmp_priv->channel); - sprintf(extra, "%s\n Bandwidth:%d", extra, pmp_priv->bandwidth); - sprintf(extra, "%s\n Rate index:%d", extra, pmp_priv->rateidx); - sprintf(extra, "%s\n TxPower index:%d", extra, pmp_priv->txpoweridx); - sprintf(extra, "%s\n Antenna TxPath:%d", extra, pmp_priv->antenna_tx); - sprintf(extra, "%s\n Antenna RxPath:%d", extra, pmp_priv->antenna_rx); - sprintf(extra, "%s\n MP Mode:%d", extra, pmp_priv->mode); - wrqu->data.length = strlen(extra); - return 0; -#ifdef CONFIG_MP_VHT_HW_TX_MODE - } else if (strncmp(extra, "pmact", 5) == 0) { - if (strncmp(extra, "pmact=", 6) == 0) { - _rtw_memset(&pMptCtx->PMacTxInfo, 0, sizeof(pMptCtx->PMacTxInfo)); - if (strncmp(extra, "pmact=start", 11) == 0) { - pMptCtx->PMacTxInfo.bEnPMacTx = _TRUE; - sprintf(extra, "Set PMac Tx Mode start\n"); - } else { - pMptCtx->PMacTxInfo.bEnPMacTx = _FALSE; - sprintf(extra, "Set PMac Tx Mode Stop\n"); - } - if (pMptCtx->bldpc == TRUE) - pMptCtx->PMacTxInfo.bLDPC = _TRUE; - - if (pMptCtx->bstbc == TRUE) - pMptCtx->PMacTxInfo.bSTBC = _TRUE; - - pMptCtx->PMacTxInfo.bSPreamble = pmp_priv->preamble; - pMptCtx->PMacTxInfo.bSGI = pmp_priv->preamble; - pMptCtx->PMacTxInfo.BandWidth = pmp_priv->bandwidth; - pMptCtx->PMacTxInfo.TX_RATE = HwRateToMPTRate(pmp_priv->rateidx); - - pMptCtx->PMacTxInfo.Mode = pMptCtx->HWTxmode; - - pMptCtx->PMacTxInfo.NDP_sound = FALSE;/*(Adapter.PacketType == NDP_PKT)?TRUE:FALSE;*/ - - if (padapter->mppriv.pktInterval == 0) - pMptCtx->PMacTxInfo.PacketPeriod = 100; - else - pMptCtx->PMacTxInfo.PacketPeriod = padapter->mppriv.pktInterval; - - if (padapter->mppriv.pktLength < 1000) - pMptCtx->PMacTxInfo.PacketLength = 1000; - else - pMptCtx->PMacTxInfo.PacketLength = padapter->mppriv.pktLength; - - pMptCtx->PMacTxInfo.PacketPattern = rtw_random32() % 0xFF; - - if (padapter->mppriv.tx_pktcount != 0) - pMptCtx->PMacTxInfo.PacketCount = padapter->mppriv.tx_pktcount; - - pMptCtx->PMacTxInfo.Ntx = 0; - for (Idx = 16; Idx < 20; Idx++) { - tmpU1B = (padapter->mppriv.antenna_tx >> Idx) & 1; - if (tmpU1B) - pMptCtx->PMacTxInfo.Ntx++; - } - - _rtw_memset(pMptCtx->PMacTxInfo.MacAddress, 0xFF, ETH_ALEN); - - PMAC_Get_Pkt_Param(&pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - - if (MPT_IS_CCK_RATE(pMptCtx->PMacTxInfo.TX_RATE)) { - - CCK_generator(&pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - } else { - PMAC_Nsym_generator(&pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - /* 24 BIT*/ - L_SIG_generator(pMptCtx->PMacPktInfo.N_sym, &pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - } - /* 48BIT*/ - if (MPT_IS_HT_RATE(pMptCtx->PMacTxInfo.TX_RATE)) - HT_SIG_generator(&pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - else if (MPT_IS_VHT_RATE(pMptCtx->PMacTxInfo.TX_RATE)) { - /* 48BIT*/ - VHT_SIG_A_generator(&pMptCtx->PMacTxInfo, &pMptCtx->PMacPktInfo); - - /* 26/27/29 BIT & CRC 8 BIT*/ - VHT_SIG_B_generator(&pMptCtx->PMacTxInfo); - - /* 32 BIT*/ - VHT_Delimiter_generator(&pMptCtx->PMacTxInfo); - } - - mpt_ProSetPMacTx(padapter); - - } else if (strncmp(extra, "pmact,mode=", 11) == 0) { - int txmode = 0; - - if (sscanf(extra, "pmact,mode=%d", &txmode) > 0) { - if (txmode == 1) { - pMptCtx->HWTxmode = CONTINUOUS_TX; - sprintf(extra, "\t Config HW Tx mode = CONTINUOUS_TX\n"); - } else if (txmode == 2) { - pMptCtx->HWTxmode = OFDM_Single_Tone_TX; - sprintf(extra, "\t Config HW Tx mode = OFDM_Single_Tone_TX\n"); - } else { - pMptCtx->HWTxmode = PACKETS_TX; - sprintf(extra, "\t Config HW Tx mode = PACKETS_TX\n"); - } - } else { - pMptCtx->HWTxmode = PACKETS_TX; - sprintf(extra, "\t Config HW Tx mode=\n 0 = PACKETS_TX\n 1 = CONTINUOUS_TX\n 2 = OFDM_Single_Tone_TX"); - } - } else if (strncmp(extra, "pmact,", 6) == 0) { - int PacketPeriod = 0, PacketLength = 0, PacketCout = 0; - int bldpc = 0, bstbc = 0; - - if (sscanf(extra, "pmact,period=%d", &PacketPeriod) > 0) { - padapter->mppriv.pktInterval = PacketPeriod; - DBG_871X("PacketPeriod=%d\n", padapter->mppriv.pktInterval); - sprintf(extra, "PacketPeriod [1~255]= %d\n", padapter->mppriv.pktInterval); - - } else if (sscanf(extra, "pmact,length=%d", &PacketLength) > 0) { - padapter->mppriv.pktLength = PacketLength; - DBG_871X("PacketPeriod=%d\n", padapter->mppriv.pktLength); - sprintf(extra, "PacketLength[~65535]=%d\n", padapter->mppriv.pktLength); - - } else if (sscanf(extra, "pmact,count=%d", &PacketCout) > 0) { - padapter->mppriv.tx_pktcount = PacketCout; - DBG_871X("Packet Cout =%d\n", padapter->mppriv.tx_pktcount); - sprintf(extra, "Packet Cout =%d\n", padapter->mppriv.tx_pktcount); - - } else if (sscanf(extra, "pmact,ldpc=%d", &bldpc) > 0) { - pMptCtx->bldpc = bldpc; - DBG_871X("Set LDPC =%d\n", pMptCtx->bldpc); - sprintf(extra, "Set LDPC =%d\n", pMptCtx->bldpc); - - } else if (sscanf(extra, "pmact,stbc=%d", &bstbc) > 0) { - pMptCtx->bstbc = bstbc; - DBG_871X("Set STBC =%d\n", pMptCtx->bstbc); - sprintf(extra, "Set STBC =%d\n", pMptCtx->bstbc); - } else - sprintf(extra, "\n period={1~255}\n length={1000~65535}\n count={0~}\n ldpc={0/1}\n stbc={0/1}"); - - } - - wrqu->data.length = strlen(extra); - return 0; -#endif - } else { - - if (sscanf(extra, "ch=%d,bw=%d,rate=%d,pwr=%d,ant=%d,tx=%d", &channel, &bandwidth, &rate, &txpower, &ant, &txmode) < 6) { - DBG_871X("Invalid format [ch=%d,bw=%d,rate=%d,pwr=%d,ant=%d,tx=%d]\n", channel, bandwidth, rate, txpower, ant, txmode); - _rtw_memset(extra, 0, wrqu->data.length); - sprintf(extra, "\n Please input correct format as bleow:\n"); - sprintf(extra, "%s\t ch=%d,bw=%d,rate=%d,pwr=%d,ant=%d,tx=%d\n", extra, channel, bandwidth, rate, txpower, ant, txmode); - sprintf(extra, "%s\n [ ch : BGN = <1~14> , A or AC = <36~165> ]", extra); - sprintf(extra, "%s\n [ bw : Bandwidth: 0 = 20M, 1 = 40M, 2 = 80M ]", extra); - sprintf(extra, "%s\n [ rate : CCK: 1 2 5.5 11M X 2 = < 2 4 11 22 >]", extra); - sprintf(extra, "%s\n [ OFDM: 6 9 12 18 24 36 48 54M X 2 = < 12 18 24 36 48 72 96 108>", extra); - sprintf(extra, "%s\n [ HT 1S2SS MCS0 ~ MCS15 : < [MCS0]=128 ~ [MCS7]=135 ~ [MCS15]=143 >", extra); - sprintf(extra, "%s\n [ HT 3SS MCS16 ~ MCS32 : < [MCS16]=144 ~ [MCS23]=151 ~ [MCS32]=159 >", extra); - sprintf(extra, "%s\n [ VHT 1SS MCS0 ~ MCS9 : < [MCS0]=160 ~ [MCS9]=169 >", extra); - sprintf(extra, "%s\n [ txpower : 1~63 power index", extra); - sprintf(extra, "%s\n [ ant : ,2T ex: AB=3 BC=6 CD=12", extra); - sprintf(extra, "%s\n [ txmode : < 0 = CONTINUOUS_TX, 1 = PACKET_TX, 2 = SINGLE_TONE_TX, 3 = CARRIER_SUPPRISSION_TX, 4 = SINGLE_CARRIER_TX>\n", extra); - wrqu->data.length = strlen(extra); - return status; - - } else { - DBG_871X("Got format [ch=%d,bw=%d,rate=%d,pwr=%d,ant=%d,tx=%d]\n", channel, bandwidth, rate, txpower, ant, txmode); - _rtw_memset(extra, 0, wrqu->data.length); - sprintf(extra, "Change Current channel %d to channel %d", padapter->mppriv.channel , channel); - padapter->mppriv.channel = channel; - SetChannel(padapter); - pHalData->CurrentChannel = channel; - - if (bandwidth == 1) - bandwidth = CHANNEL_WIDTH_40; - else if (bandwidth == 2) - bandwidth = CHANNEL_WIDTH_80; - sprintf(extra, "%s\nChange Current Bandwidth %d to Bandwidth %d", extra, padapter->mppriv.bandwidth , bandwidth); - padapter->mppriv.bandwidth = (u8)bandwidth; - padapter->mppriv.preamble = sg; - SetBandwidth(padapter); - pHalData->CurrentChannelBW = bandwidth; - - sprintf(extra, "%s\nSet power level :%d", extra, txpower); - padapter->mppriv.txpoweridx = (u8)txpower; - pMptCtx->TxPwrLevel[ODM_RF_PATH_A] = (u8)txpower; - pMptCtx->TxPwrLevel[ODM_RF_PATH_B] = (u8)txpower; - pMptCtx->TxPwrLevel[ODM_RF_PATH_C] = (u8)txpower; - pMptCtx->TxPwrLevel[ODM_RF_PATH_D] = (u8)txpower; - - DBG_871X("%s: bw=%d sg=%d\n", __func__, bandwidth, sg); - - if (rate <= 0x7f) - rate = wifirate2_ratetbl_inx((u8)rate); - else if (rate < 0xC8) - rate = (rate - 0x80 + MPT_RATE_MCS0); - /*HT rate 0x80(MCS0) ~ 0x8F(MCS15) ~ 0x9F(MCS31) 128~159 - VHT1SS~2SS rate 0xA0 (VHT1SS_MCS0 44) ~ 0xB3 (VHT2SS_MCS9 #63) 160~179 - VHT rate 0xB4 (VHT3SS_MCS0 64) ~ 0xC7 (VHT2SS_MCS9 #83) 180~199 - else - VHT rate 0x90(VHT1SS_MCS0) ~ 0x99(VHT1SS_MCS9) 144~153 - rate =(rate - MPT_RATE_VHT1SS_MCS0); - */ - DBG_871X("%s: rate index=%d\n", __func__, rate); - if (rate >= MPT_RATE_LAST) - return -EINVAL; - sprintf(extra, "%s\nSet data rate to %d index %d", extra, padapter->mppriv.rateidx, rate); - - padapter->mppriv.rateidx = rate; - pMptCtx->MptRateIndex = rate; - SetDataRate(padapter); - - sprintf(extra, "%s\nSet Antenna Path :%d", extra, ant); - switch (ant) { - case 1: - antenna = ANTENNA_A; - break; - case 2: - antenna = ANTENNA_B; - break; - case 4: - antenna = ANTENNA_C; - break; - case 8: - antenna = ANTENNA_D; - break; - case 3: - antenna = ANTENNA_AB; - break; - case 5: - antenna = ANTENNA_AC; - break; - case 9: - antenna = ANTENNA_AD; - break; - case 6: - antenna = ANTENNA_BC; - break; - case 10: - antenna = ANTENNA_BD; - break; - case 12: - antenna = ANTENNA_CD; - break; - case 7: - antenna = ANTENNA_ABC; - break; - case 14: - antenna = ANTENNA_BCD; - break; - case 11: - antenna = ANTENNA_ABD; - break; - case 15: - antenna = ANTENNA_ABCD; - break; - } - DBG_871X("%s: antenna=0x%x\n", __func__, antenna); - padapter->mppriv.antenna_tx = antenna; - padapter->mppriv.antenna_rx = antenna; - pHalData->AntennaTxPath = antenna; - SetAntenna(padapter); - - if (txmode == 0) { - pmp_priv->mode = MP_CONTINUOUS_TX; - } else if (txmode == 1) { - pmp_priv->mode = MP_PACKET_TX; - pmp_priv->tx.count = count; - } else if (txmode == 2) { - pmp_priv->mode = MP_SINGLE_TONE_TX; - } else if (txmode == 3) { - pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; - } else if (txmode == 4) { - pmp_priv->mode = MP_SINGLE_CARRIER_TX; - } - - status = rtw_mp_pretx_proc(padapter, bStartTest, extra); - } - - } - - wrqu->data.length = strlen(extra); - return status; -} - - -int rtw_mp_rx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct mp_priv *pmp_priv = &padapter->mppriv; - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - - u32 bandwidth = 0, sg = 0, channel = 6, ant = 0; - u16 antenna = 0; - u8 bStartRx = 0; - - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - -#ifdef CONFIG_CONCURRENT_MODE - if (padapter->adapter_type == SECONDARY_ADAPTER) { - sprintf(extra, "Error: MP mode can't support Virtual Adapter, Please to use main Adapter.\n"); - wrqu->data.length = strlen(extra); - return 0; - } -#endif - - if (strncmp(extra, "stop", 4) == 0) { - _rtw_memset(extra, 0, wrqu->data.length); - SetPacketRx(padapter, bStartRx, _FALSE); - pmp_priv->bmac_filter = _FALSE; - sprintf(extra, "Received packet OK:%d CRC error:%d ,Filter out:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount, padapter->mppriv.rx_pktcount_filter_out); - wrqu->data.length = strlen(extra); - return 0; - - } else if (sscanf(extra, "ch=%d,bw=%d,ant=%d", &channel, &bandwidth, &ant) < 3) { - DBG_871X("Invalid format [ch=%d,bw=%d,ant=%d]\n", channel, bandwidth, ant); - _rtw_memset(extra, 0, wrqu->data.length); - sprintf(extra, "\n Please input correct format as bleow:\n"); - sprintf(extra, "%s\t ch=%d,bw=%d,ant=%d\n", extra, channel, bandwidth, ant); - sprintf(extra, "%s\n [ ch : BGN = <1~14> , A or AC = <36~165> ]", extra); - sprintf(extra, "%s\n [ bw : Bandwidth: 0 = 20M, 1 = 40M, 2 = 80M ]", extra); - sprintf(extra, "%s\n [ ant : ,2T ex: AB=3 BC=6 CD=12", extra); - wrqu->data.length = strlen(extra); - return 0; - - } else { - bStartRx = 1; - DBG_871X("Got format [ch=%d,bw=%d,ant=%d]\n", channel, bandwidth, ant); - _rtw_memset(extra, 0, wrqu->data.length); - sprintf(extra, "Change Current channel %d to channel %d", padapter->mppriv.channel , channel); - padapter->mppriv.channel = channel; - SetChannel(padapter); - pHalData->CurrentChannel = channel; - - if (bandwidth == 1) - bandwidth = CHANNEL_WIDTH_40; - else if (bandwidth == 2) - bandwidth = CHANNEL_WIDTH_80; - sprintf(extra, "%s\nChange Current Bandwidth %d to Bandwidth %d", extra, padapter->mppriv.bandwidth , bandwidth); - padapter->mppriv.bandwidth = (u8)bandwidth; - padapter->mppriv.preamble = sg; - SetBandwidth(padapter); - pHalData->CurrentChannelBW = bandwidth; - - sprintf(extra, "%s\nSet Antenna Path :%d", extra, ant); - switch (ant) { - case 1: - antenna = ANTENNA_A; - break; - case 2: - antenna = ANTENNA_B; - break; - case 4: - antenna = ANTENNA_C; - break; - case 8: - antenna = ANTENNA_D; - break; - case 3: - antenna = ANTENNA_AB; - break; - case 5: - antenna = ANTENNA_AC; - break; - case 9: - antenna = ANTENNA_AD; - break; - case 6: - antenna = ANTENNA_BC; - break; - case 10: - antenna = ANTENNA_BD; - break; - case 12: - antenna = ANTENNA_CD; - break; - case 7: - antenna = ANTENNA_ABC; - break; - case 14: - antenna = ANTENNA_BCD; - break; - case 11: - antenna = ANTENNA_ABD; - break; - case 15: - antenna = ANTENNA_ABCD; - break; - } - DBG_871X("%s: antenna=0x%x\n", __func__, antenna); - padapter->mppriv.antenna_tx = antenna; - padapter->mppriv.antenna_rx = antenna; - pHalData->AntennaTxPath = antenna; - SetAntenna(padapter); - - sprintf(extra, "%s\nstart Rx", extra); - SetPacketRx(padapter, bStartRx, _FALSE); - } - wrqu->data.length = strlen(extra); - return 0; -} - - -int rtw_mp_hwtx(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - struct mp_priv *pmp_priv = &padapter->mppriv; - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - -#if defined(CONFIG_RTL8814A) || defined(CONFIG_RTL8821B) || defined(CONFIG_RTL8822B) - u8 input[wrqu->data.length]; - - if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - _rtw_memset(&pMptCtx->PMacTxInfo, 0, sizeof(RT_PMAC_TX_INFO)); - _rtw_memcpy((void *)&pMptCtx->PMacTxInfo, (void *)input, sizeof(RT_PMAC_TX_INFO)); - - mpt_ProSetPMacTx(padapter); - sprintf(extra, "Set PMac Tx Mode start\n"); - - wrqu->data.length = strlen(extra); -#endif - return 0; - -} - -int rtw_efuse_mask_file(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - char *rtw_efuse_mask_file_path; - u8 Status; - PADAPTER padapter = rtw_netdev_priv(dev); - - _rtw_memset(maskfileBuffer, 0x00, sizeof(maskfileBuffer)); - - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - if (strncmp(extra, "off", 3) == 0 && strlen(extra) < 4) { - padapter->registrypriv.boffefusemask = 1; - sprintf(extra, "Turn off Efuse Mask\n"); - wrqu->data.length = strlen(extra); - return 0; - } - if (strncmp(extra, "on", 2) == 0 && strlen(extra) < 3) { - padapter->registrypriv.boffefusemask = 0; - sprintf(extra, "Turn on Efuse Mask\n"); - wrqu->data.length = strlen(extra); - return 0; - } - rtw_efuse_mask_file_path = extra; - - if (rtw_is_file_readable(rtw_efuse_mask_file_path) == _TRUE) { - DBG_871X("%s do rtw_efuse_mask_file_read = %s! ,sizeof maskfileBuffer %zu\n", __func__, rtw_efuse_mask_file_path, sizeof(maskfileBuffer)); - Status = rtw_efuse_file_read(padapter, rtw_efuse_mask_file_path, maskfileBuffer, sizeof(maskfileBuffer)); - if (Status == _TRUE) - padapter->registrypriv.bFileMaskEfuse = _TRUE; - sprintf(extra, "efuse mask file read OK\n"); - } else { - padapter->registrypriv.bFileMaskEfuse = _FALSE; - sprintf(extra, "efuse mask file readable FAIL\n"); - DBG_871X("%s rtw_is_file_readable fail!\n", __func__); - } - wrqu->data.length = strlen(extra); - return 0; -} - - -int rtw_efuse_file_map(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - char *rtw_efuse_file_map_path; - u8 Status; - PEFUSE_HAL pEfuseHal; - PADAPTER padapter = rtw_netdev_priv(dev); - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - pEfuseHal = &pHalData->EfuseHal; - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - - rtw_efuse_file_map_path = extra; - - if (rtw_is_file_readable(rtw_efuse_file_map_path) == _TRUE) { - DBG_871X("%s do rtw_efuse_mask_file_read = %s!\n", __func__, rtw_efuse_file_map_path); - Status = rtw_efuse_file_read(padapter, rtw_efuse_file_map_path, pEfuseHal->fakeEfuseModifiedMap, sizeof(pEfuseHal->fakeEfuseModifiedMap)); - if (Status == _TRUE) - sprintf(extra, "efuse file file_read OK\n"); - else - sprintf(extra, "efuse file file_read FAIL\n"); - } else { - sprintf(extra, "efuse file readable FAIL\n"); - DBG_871X("%s rtw_is_file_readable fail!\n", __func__); - } - wrqu->data.length = strlen(extra); - return 0; -} - -#if defined(CONFIG_RTL8723B) -int rtw_mp_SetBT(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - PADAPTER padapter = rtw_netdev_priv(dev); - struct hal_ops *pHalFunc = &padapter->HalFunc; - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); - - BT_REQ_CMD BtReq; - PMPT_CONTEXT pMptCtx = &(padapter->mppriv.MptCtx); - PBT_RSP_CMD pBtRsp = (PBT_RSP_CMD)&pMptCtx->mptOutBuf[0]; - char input[128]; - char *pch, *ptmp, *token, *tmp[2] = {0x00, 0x00}; - u8 setdata[100]; - u8 resetbt = 0x00; - u8 tempval, BTStatus; - u8 H2cSetbtmac[6]; - u8 u1H2CBtMpOperParm[4] = {0x01}; - int testmode = 1, ready = 1, trxparam = 1, setgen = 1, getgen = 1, testctrl = 1, testbt = 1, readtherm = 1, setbtmac = 1; - u32 i = 0, ii = 0, jj = 0, kk = 0, cnts = 0, status = 0; - PRT_MP_FIRMWARE pBTFirmware = NULL; - - if (copy_from_user(extra, wrqu->data.pointer, wrqu->data.length)) - return -EFAULT; - if (strlen(extra) < 1) - return -EFAULT; - - DBG_871X("%s:iwpriv in=%s\n", __func__, extra); - ready = strncmp(extra, "ready", 5); - testmode = strncmp(extra, "testmode", 8); /* strncmp TRUE is 0*/ - trxparam = strncmp(extra, "trxparam", 8); - setgen = strncmp(extra, "setgen", 6); - getgen = strncmp(extra, "getgen", 6); - testctrl = strncmp(extra, "testctrl", 8); - testbt = strncmp(extra, "testbt", 6); - readtherm = strncmp(extra, "readtherm", 9); - setbtmac = strncmp(extra, "setbtmac", 8); - - if (strncmp(extra, "dlbt", 4) == 0) { - pHalData->LastHMEBoxNum = 0; - padapter->bBTFWReady = _FALSE; - rtw_write8(padapter, 0xa3, 0x05); - BTStatus = rtw_read8(padapter, 0xa0); - DBG_871X("%s: btwmap before read 0xa0 BT Status =0x%x\n", __func__, BTStatus); - if (BTStatus != 0x04) { - sprintf(extra, "BT Status not Active DLFW FAIL\n"); - goto exit; - } - - tempval = rtw_read8(padapter, 0x6B); - tempval |= BIT7; - rtw_write8(padapter, 0x6B, tempval); - - /* Attention!! Between 0x6A[14] and 0x6A[15] setting need 100us delay*/ - /* So don't write 0x6A[14]=1 and 0x6A[15]=0 together!*/ - rtw_usleep_os(100); - /* disable BT power cut*/ - /* 0x6A[14] = 0*/ - tempval = rtw_read8(padapter, 0x6B); - tempval &= ~BIT6; - rtw_write8(padapter, 0x6B, tempval); - rtw_usleep_os(100); - MPT_PwrCtlDM(padapter, 0); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) | 0x00000004)); - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) & 0xFFFFFFEF)); - rtw_msleep_os(600); - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) | 0x00000010)); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) & 0xFFFFFFFB)); - rtw_msleep_os(1200); - pBTFirmware = (PRT_MP_FIRMWARE)rtw_zmalloc(sizeof(RT_MP_FIRMWARE)); - if (pBTFirmware == NULL) - goto exit; - padapter->bBTFWReady = _FALSE; - FirmwareDownloadBT(padapter, pBTFirmware); - if (pBTFirmware) - rtw_mfree((u8 *)pBTFirmware, sizeof(RT_MP_FIRMWARE)); - - DBG_871X("Wait for FirmwareDownloadBT fw boot!\n"); - rtw_msleep_os(2000); - _rtw_memset(extra, '\0', wrqu->data.length); - BtReq.opCodeVer = 1; - BtReq.OpCode = 0; - BtReq.paraLength = 0; - mptbt_BtControlProcess(padapter, &BtReq); - rtw_msleep_os(100); - - DBG_8192C("FirmwareDownloadBT ready = 0x%x 0x%x", pMptCtx->mptOutBuf[4], pMptCtx->mptOutBuf[5]); - if ((pMptCtx->mptOutBuf[4] == 0x00) && (pMptCtx->mptOutBuf[5] == 0x00)) { - - if (padapter->mppriv.bTxBufCkFail == _TRUE) - sprintf(extra, "check TxBuf Fail.\n"); - else - sprintf(extra, "download FW Fail.\n"); - } else { - sprintf(extra, "download FW OK.\n"); - goto exit; - } - goto exit; - } - if (strncmp(extra, "dlfw", 4) == 0) { - pHalData->LastHMEBoxNum = 0; - padapter->bBTFWReady = _FALSE; - rtw_write8(padapter, 0xa3, 0x05); - BTStatus = rtw_read8(padapter, 0xa0); - DBG_871X("%s: btwmap before read 0xa0 BT Status =0x%x\n", __func__, BTStatus); - if (BTStatus != 0x04) { - sprintf(extra, "BT Status not Active DLFW FAIL\n"); - goto exit; - } - - tempval = rtw_read8(padapter, 0x6B); - tempval |= BIT7; - rtw_write8(padapter, 0x6B, tempval); - - /* Attention!! Between 0x6A[14] and 0x6A[15] setting need 100us delay*/ - /* So don't write 0x6A[14]=1 and 0x6A[15]=0 together!*/ - rtw_usleep_os(100); - /* disable BT power cut*/ - /* 0x6A[14] = 0*/ - tempval = rtw_read8(padapter, 0x6B); - tempval &= ~BIT6; - rtw_write8(padapter, 0x6B, tempval); - rtw_usleep_os(100); - - MPT_PwrCtlDM(padapter, 0); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) | 0x00000004)); - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) & 0xFFFFFFEF)); - rtw_msleep_os(600); - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) | 0x00000010)); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) & 0xFFFFFFFB)); - rtw_msleep_os(1200); - -#if defined(CONFIG_PLATFORM_SPRD) && (MP_DRIVER == 1) - /* Pull up BT reset pin.*/ - DBG_871X("%s: pull up BT reset pin when bt start mp test\n", __func__); - rtw_wifi_gpio_wlan_ctrl(WLAN_BT_PWDN_ON); -#endif - DBG_871X(" FirmwareDownload!\n"); - -#if defined(CONFIG_RTL8723B) - status = rtl8723b_FirmwareDownload(padapter, _FALSE); -#endif - DBG_871X("Wait for FirmwareDownloadBT fw boot!\n"); - rtw_msleep_os(1000); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_HaltNotify(padapter); - DBG_871X("SetBT btcoex HaltNotify !\n"); - /*hal_btcoex1ant_SetAntPath(padapter);*/ - rtw_btcoex_SetManualControl(padapter, _TRUE); -#endif - _rtw_memset(extra, '\0', wrqu->data.length); - BtReq.opCodeVer = 1; - BtReq.OpCode = 0; - BtReq.paraLength = 0; - mptbt_BtControlProcess(padapter, &BtReq); - rtw_msleep_os(200); - - DBG_8192C("FirmwareDownloadBT ready = 0x%x 0x%x", pMptCtx->mptOutBuf[4], pMptCtx->mptOutBuf[5]); - if ((pMptCtx->mptOutBuf[4] == 0x00) && (pMptCtx->mptOutBuf[5] == 0x00)) { - if (padapter->mppriv.bTxBufCkFail == _TRUE) - sprintf(extra, "check TxBuf Fail.\n"); - else - sprintf(extra, "download FW Fail.\n"); - } else { -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_SwitchBtTRxMask(padapter); -#endif - rtw_msleep_os(200); - sprintf(extra, "download FW OK.\n"); - goto exit; - } - goto exit; - } - - if (strncmp(extra, "down", 4) == 0) { - DBG_871X("SetBT down for to hal_init !\n"); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_SetManualControl(padapter, _FALSE); - rtw_btcoex_Initialize(padapter); -#endif - pHalFunc->read_adapter_info(padapter); - pHalFunc->hal_deinit(padapter); - pHalFunc->hal_init(padapter); - rtw_pm_set_ips(padapter, IPS_NONE); - LeaveAllPowerSaveMode(padapter); - MPT_PwrCtlDM(padapter, 0); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) | 0x00000004)); - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) & 0xFFFFFFEF)); - rtw_msleep_os(600); - /*rtw_write32(padapter, 0x6a, (rtw_read32(padapter, 0x6a)& 0xFFFFFFFE));*/ - rtw_write32(padapter, 0x6b, (rtw_read32(padapter, 0x6b) | 0x00000010)); - rtw_write32(padapter, 0xcc, (rtw_read32(padapter, 0xcc) & 0xFFFFFFFB)); - rtw_msleep_os(1200); - goto exit; - } - if (strncmp(extra, "disable", 7) == 0) { - DBG_871X("SetBT disable !\n"); - rtw_write32(padapter, 0x6a, (rtw_read32(padapter, 0x6a) & 0xFFFFFFFB)); - rtw_msleep_os(500); - goto exit; - } - if (strncmp(extra, "enable", 6) == 0) { - DBG_871X("SetBT enable !\n"); - rtw_write32(padapter, 0x6a, (rtw_read32(padapter, 0x6a) | 0x00000004)); - rtw_msleep_os(500); - goto exit; - } - if (strncmp(extra, "h2c", 3) == 0) { - DBG_871X("SetBT h2c !\n"); - padapter->bBTFWReady = _TRUE; - rtw_hal_fill_h2c_cmd(padapter, 0x63, 1, u1H2CBtMpOperParm); - goto exit; - } - if (strncmp(extra, "2ant", 4) == 0) { - DBG_871X("Set BT 2ant use!\n"); - PHY_SetMacReg(padapter, 0x67, BIT5, 0x1); - rtw_write32(padapter, 0x948, 0000); - - goto exit; - } - - if (ready != 0 && testmode != 0 && trxparam != 0 && setgen != 0 && getgen != 0 && testctrl != 0 && testbt != 0 && readtherm != 0 && setbtmac != 0) - return -EFAULT; - - if (testbt == 0) { - BtReq.opCodeVer = 1; - BtReq.OpCode = 6; - BtReq.paraLength = cnts / 2; - goto todo; - } - if (ready == 0) { - BtReq.opCodeVer = 1; - BtReq.OpCode = 0; - BtReq.paraLength = 0; - goto todo; - } - - pch = extra; - i = 0; - while ((token = strsep(&pch, ",")) != NULL) { - if (i > 1) - break; - tmp[i] = token; - i++; - } - - if ((tmp[0] != NULL) && (tmp[1] != NULL)) { - cnts = strlen(tmp[1]); - if (cnts < 1) - return -EFAULT; - - DBG_871X("%s: cnts=%d\n", __func__, cnts); - DBG_871X("%s: data=%s\n", __func__, tmp[1]); - - for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) { - BtReq.pParamStart[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); - /* DBG_871X("BtReq.pParamStart[%d]=0x%02x\n", jj, BtReq.pParamStart[jj]);*/ - } - } else - return -EFAULT; - - if (testmode == 0) { - BtReq.opCodeVer = 1; - BtReq.OpCode = 1; - BtReq.paraLength = 1; - } - if (trxparam == 0) { - BtReq.opCodeVer = 1; - BtReq.OpCode = 2; - BtReq.paraLength = cnts / 2; - } - if (setgen == 0) { - DBG_871X("%s: BT_SET_GENERAL\n", __func__); - BtReq.opCodeVer = 1; - BtReq.OpCode = 3;/*BT_SET_GENERAL 3*/ - BtReq.paraLength = cnts / 2; - } - if (getgen == 0) { - DBG_871X("%s: BT_GET_GENERAL\n", __func__); - BtReq.opCodeVer = 1; - BtReq.OpCode = 4;/*BT_GET_GENERAL 4*/ - BtReq.paraLength = cnts / 2; - } - if (readtherm == 0) { - DBG_871X("%s: BT_GET_GENERAL\n", __func__); - BtReq.opCodeVer = 1; - BtReq.OpCode = 4;/*BT_GET_GENERAL 4*/ - BtReq.paraLength = cnts / 2; - } - - if (testctrl == 0) { - DBG_871X("%s: BT_TEST_CTRL\n", __func__); - BtReq.opCodeVer = 1; - BtReq.OpCode = 5;/*BT_TEST_CTRL 5*/ - BtReq.paraLength = cnts / 2; - } - - DBG_871X("%s: Req opCodeVer=%d OpCode=%d paraLength=%d\n", - __func__, BtReq.opCodeVer, BtReq.OpCode, BtReq.paraLength); - - if (BtReq.paraLength < 1) - goto todo; - for (i = 0; i < BtReq.paraLength; i++) { - DBG_871X("%s: BtReq.pParamStart[%d] = 0x%02x\n", - __func__, i, BtReq.pParamStart[i]); - } - -todo: - _rtw_memset(extra, '\0', wrqu->data.length); - - if (padapter->bBTFWReady == _FALSE) { - sprintf(extra, "BTFWReady = FALSE.\n"); - goto exit; - } - - mptbt_BtControlProcess(padapter, &BtReq); - - if (readtherm == 0) { - sprintf(extra, "BT thermal="); - for (i = 4; i < pMptCtx->mptOutLen; i++) { - if ((pMptCtx->mptOutBuf[i] == 0x00) && (pMptCtx->mptOutBuf[i + 1] == 0x00)) - goto exit; - - sprintf(extra, "%s %d ", extra, (pMptCtx->mptOutBuf[i] & 0x1f)); - } - } else { - for (i = 4; i < pMptCtx->mptOutLen; i++) - sprintf(extra, "%s 0x%x ", extra, pMptCtx->mptOutBuf[i]); - } - -exit: - wrqu->data.length = strlen(extra) + 1; - DBG_871X("-%s: output len=%d data=%s\n", __func__, wrqu->data.length, extra); - - return status; -} - -#endif /*#ifdef CONFIG_RTL8723B*/ - -#endif diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/mlme_linux.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/mlme_linux.c index c3edb3a07..e46f3cc42 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/mlme_linux.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/mlme_linux.c @@ -92,15 +92,6 @@ void _dynamic_check_timer_handlder (void *FunctionContext) { _adapter *adapter = (_adapter *)FunctionContext; -#if (MP_DRIVER == 1) - if (adapter->registrypriv.mp_mode == 1 && adapter->mppriv.mp_dm ==0) //for MP ODM dynamic Tx power tracking - { - //DBG_871X("_dynamic_check_timer_handlder mp_dm =0 return \n"); - _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); - return; - } -#endif - #ifdef CONFIG_CONCURRENT_MODE if(adapter->pbuddy_adapter) rtw_dynamic_check_timer_handlder(adapter->pbuddy_adapter); @@ -582,8 +573,11 @@ int hostapd_mode_init(_adapter *padapter) mac[4]=0x11; mac[5]=0x12; +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) _rtw_memcpy(pnetdev->dev_addr, mac, ETH_ALEN); - +#else + dev_addr_set(pnetdev, mac); +#endif netif_carrier_off(pnetdev); diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/os_intfs.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/os_intfs.c index d48c62078..7574466c8 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/os_intfs.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/os_intfs.c @@ -85,14 +85,6 @@ int rtw_busy_thresh = 40; //int qos_enable = 0; //* int rtw_ack_policy = NORMAL_ACK; -int rtw_mp_mode = 0; - -#if defined(CONFIG_MP_INCLUDED) && defined(CONFIG_RTW_CUSTOMER_STR) -uint rtw_mp_customer_str = 0; -module_param(rtw_mp_customer_str, uint, 0644); -MODULE_PARM_DESC(rtw_mp_customer_str, "Whether or not to enable customer str support on MP mode"); -#endif - int rtw_software_encrypt = 0; int rtw_software_decrypt = 0; @@ -173,18 +165,6 @@ int rtw_full_ch_in_p2p_handshake = 1; /* reply full channel list*/ int rtw_full_ch_in_p2p_handshake = 0; /* reply only softap channel*/ #endif -#ifdef CONFIG_BT_COEXIST -int rtw_btcoex_enable = 1; -module_param(rtw_btcoex_enable, int, 0644); -MODULE_PARM_DESC(rtw_btcoex_enable, "Enable BT co-existence mechanism"); -int rtw_bt_iso = 2;// 0:Low, 1:High, 2:From Efuse -int rtw_bt_sco = 3;// 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter, 4.Busy, 5.OtherBusy -int rtw_bt_ampdu =1 ;// 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. -int rtw_ant_num = -1; // <0: undefined, >0: Antenna number -module_param(rtw_ant_num, int, 0644); -MODULE_PARM_DESC(rtw_ant_num, "Antenna number setting"); -#endif - int rtw_AcceptAddbaReq = _TRUE;// 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. int rtw_antdiv_cfg = 2; // 0:OFF , 1:ON, 2:decide by Efuse config @@ -270,7 +250,6 @@ module_param(rtw_rfintfs, int, 0644); module_param(rtw_lbkmode, int, 0644); module_param(rtw_network_mode, int, 0644); module_param(rtw_channel, int, 0644); -module_param(rtw_mp_mode, int, 0644); module_param(rtw_wmm_enable, int, 0644); module_param(rtw_vrtl_carrier_sense, int, 0644); module_param(rtw_vcs_type, int, 0644); @@ -487,26 +466,6 @@ module_param_array(rtw_target_tx_pwr_5g_d, int, &rtw_target_tx_pwr_5g_d_num, 064 MODULE_PARM_DESC(rtw_target_tx_pwr_5g_d, "5G target tx power (unit:dBm) of RF path D for each rate section, should match the real calibrate power, -1: undefined"); #endif /* CONFIG_IEEE80211_BAND_5GHZ */ -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE -char *rtw_phy_file_path = REALTEK_CONFIG_PATH; -module_param(rtw_phy_file_path, charp, 0644); -MODULE_PARM_DESC(rtw_phy_file_path, "The path of phy parameter"); -// PHY FILE Bit Map -// BIT0 - MAC, 0: non-support, 1: support -// BIT1 - BB, 0: non-support, 1: support -// BIT2 - BB_PG, 0: non-support, 1: support -// BIT3 - BB_MP, 0: non-support, 1: support -// BIT4 - RF, 0: non-support, 1: support -// BIT5 - RF_TXPWR_TRACK, 0: non-support, 1: support -// BIT6 - RF_TXPWR_LMT, 0: non-support, 1: support -int rtw_load_phy_file = (BIT2|BIT6); -module_param(rtw_load_phy_file, int, 0644); -MODULE_PARM_DESC(rtw_load_phy_file,"PHY File Bit Map"); -int rtw_decrypt_phy_file = 0; -module_param(rtw_decrypt_phy_file, int, 0644); -MODULE_PARM_DESC(rtw_decrypt_phy_file,"Enable Decrypt PHY File"); -#endif - int _netdev_open(struct net_device *pnetdev); int netdev_open (struct net_device *pnetdev); static int netdev_close (struct net_device *pnetdev); @@ -596,10 +555,6 @@ _func_enter_; registry_par->busy_thresh = (u16)rtw_busy_thresh; //registry_par->qos_enable = (u8)rtw_qos_enable; registry_par->ack_policy = (u8)rtw_ack_policy; - registry_par->mp_mode = (u8)rtw_mp_mode; -#if defined(CONFIG_MP_INCLUDED) && defined(CONFIG_RTW_CUSTOMER_STR) - registry_par->mp_customer_str = (u8)rtw_mp_customer_str; -#endif registry_par->software_encrypt = (u8)rtw_software_encrypt; registry_par->software_decrypt = (u8)rtw_software_decrypt; @@ -661,13 +616,6 @@ _func_enter_; registry_par->special_rf_path = (u8)rtw_special_rf_path; registry_par->full_ch_in_p2p_handshake = (u8)rtw_full_ch_in_p2p_handshake; -#ifdef CONFIG_BT_COEXIST - registry_par->btcoex = (u8)rtw_btcoex_enable; - registry_par->bt_iso = (u8)rtw_bt_iso; - registry_par->bt_sco = (u8)rtw_bt_sco; - registry_par->bt_ampdu = (u8)rtw_bt_ampdu; - registry_par->ant_num = (s8)rtw_ant_num; -#endif registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq; @@ -735,10 +683,6 @@ _func_enter_; registry_par->AmplifierType_2G = (u8)rtw_amplifier_type_2g; registry_par->AmplifierType_5G = (u8)rtw_amplifier_type_5g; registry_par->GLNA_Type = (u8)rtw_GLNA_type; -#ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - registry_par->load_phy_file = (u8)rtw_load_phy_file; - registry_par->RegDecryptCustomFile = (u8)rtw_decrypt_phy_file; -#endif registry_par->qos_opt_enable = (u8)rtw_qos_opt_enable; registry_par->hiq_filter = (u8)rtw_hiq_filter; @@ -811,7 +755,11 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *addr) } _rtw_memcpy(adapter_mac_addr(padapter), sa->sa_data, ETH_ALEN); /* set mac addr to adapter */ - _rtw_memcpy(pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) + _rtw_memcpy((void *)pnetdev->dev_addr, sa->sa_data, ETH_ALEN); /* set mac addr to net_device */ +#else + dev_addr_set(pnetdev, sa->sa_data); +#endif rtw_ps_deny(padapter, PS_DENY_IOCTL); LeaveAllPowerSaveModeDirect(padapter); /* leave PS mode for guaranteeing to access hw register successfully */ @@ -885,9 +833,11 @@ static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb #else , void *accel_priv #endif -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) && LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0) +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 2, 0) , select_queue_fallback_t fallback #endif +#endif #endif ) @@ -963,12 +913,6 @@ static int rtw_ndev_notifier_call(struct notifier_block * nb, unsigned long stat DBG_871X_LEVEL(_drv_info_, FUNC_NDEV_FMT" state:%lu\n", FUNC_NDEV_ARG(dev), state); - switch (state) { - case NETDEV_CHANGENAME: - rtw_adapter_proc_replace(dev); - break; - } - return NOTIFY_DONE; } @@ -995,7 +939,6 @@ int rtw_ndev_init(struct net_device *dev) , FUNC_ADPT_ARG(adapter), (adapter->iface_id+1), MAC_ARG(dev->dev_addr)); strncpy(adapter->old_ifname, dev->name, IFNAMSIZ); adapter->old_ifname[IFNAMSIZ-1] = '\0'; - rtw_adapter_proc_init(dev); return 0; } @@ -1006,7 +949,6 @@ void rtw_ndev_uninit(struct net_device *dev) DBG_871X_LEVEL(_drv_always_, FUNC_ADPT_FMT" if%d\n" , FUNC_ADPT_ARG(adapter), (adapter->iface_id+1)); - rtw_adapter_proc_deinit(dev); } #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,29)) @@ -1197,7 +1139,11 @@ int rtw_os_ndev_register(_adapter *adapter, char *name) /* alloc netdev name */ rtw_init_netdev_name(ndev, name); - _rtw_memcpy(ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) + _rtw_memcpy((void *)ndev->dev_addr, adapter_mac_addr(adapter), ETH_ALEN); +#else + dev_addr_set(ndev, adapter_mac_addr(adapter)); +#endif /* Tell the network stack we exist */ if (register_netdev(ndev) != 0) { @@ -2243,7 +2189,11 @@ int _netdev_if2_open(struct net_device *pnetdev) _rtw_memcpy(adapter_mac_addr(padapter), mac, ETH_ALEN); rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#else + dev_addr_set(pnetdev, adapter_mac_addr(padapter)); +#endif } #endif //CONFIG_PLATFORM_INTEL_BYT @@ -2687,9 +2637,6 @@ int _netdev_open(struct net_device *pnetdev) uint status; _adapter *padapter = (_adapter *)rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = adapter_to_pwrctl(padapter); -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX RT_TRACE(_module_os_intfs_c_,_drv_info_,("+871x_drv - dev_open\n")); DBG_871X("+871x_drv - drv_open, bup=%d\n", padapter->bup); @@ -2710,7 +2657,11 @@ int _netdev_open(struct net_device *pnetdev) #ifdef CONFIG_PLATFORM_INTEL_BYT rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); rtw_init_wifidirect_addrs(padapter, adapter_mac_addr(padapter), adapter_mac_addr(padapter)); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#else + dev_addr_set(pnetdev, adapter_mac_addr(padapter)); +#endif #endif //CONFIG_PLATFORM_INTEL_BYT rtw_clr_surprise_removed(padapter); @@ -2751,9 +2702,6 @@ int _netdev_open(struct net_device *pnetdev) pwrctrlpriv->bips_processing = _FALSE; #ifdef CONFIG_PLATFORM_INTEL_BYT -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IpsNotify(padapter, IPS_NONE); -#endif // CONFIG_BT_COEXIST #endif //CONFIG_PLATFORM_INTEL_BYT } padapter->net_closed = _FALSE; @@ -2771,18 +2719,6 @@ int _netdev_open(struct net_device *pnetdev) netdev_br_init(pnetdev); #endif // CONFIG_BR_EXT -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - if(is_primary_adapter(padapter) && _TRUE == pHalData->EEPROMBluetoothCoexist) - { - rtw_btcoex_init_socket(padapter); - padapter->coex_info.BtMgnt.ExtConfig.HCIExtensionVer = 0x04; - rtw_btcoex_SetHciVersion(padapter,0x04); - } - else - DBG_871X("CONFIG_BT_COEXIST: SECONDARY_ADAPTER\n"); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX - - netdev_open_normal_process: #ifdef CONFIG_CONCURRENT_MODE @@ -2965,9 +2901,6 @@ static int netdev_close(struct net_device *pnetdev) _adapter *padapter = (_adapter *)rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctl = adapter_to_pwrctl(padapter); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - HAL_DATA_TYPE *pHalData = GET_HAL_DATA(padapter); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX RT_TRACE(_module_os_intfs_c_,_drv_info_,("+871x_drv - drv_close\n")); @@ -3037,12 +2970,6 @@ static int netdev_close(struct net_device *pnetdev) #ifdef CONFIG_WAPI_SUPPORT rtw_wapi_disable_tx(padapter); #endif -#ifdef CONFIG_BT_COEXIST_SOCKET_TRX - if(is_primary_adapter(padapter) && _TRUE == pHalData->EEPROMBluetoothCoexist) - rtw_btcoex_close_socket(padapter); - else - DBG_871X("CONFIG_BT_COEXIST: SECONDARY_ADAPTER\n"); -#endif //CONFIG_BT_COEXIST_SOCKET_TRX #else //!CONFIG_PLATFORM_INTEL_BYT if (pwrctl->bInSuspend == _TRUE) @@ -3143,9 +3070,7 @@ static int route_dump(u32 *gw_addr ,int* gw_index) struct msghdr msg; struct iovec iov; struct sockaddr_nl nladdr; -#ifdef set_fs mm_segment_t oldfs; -#endif char *pg; int size = 0; @@ -3185,18 +3110,13 @@ static int route_dump(u32 *gw_addr ,int* gw_index) msg.msg_controllen = 0; msg.msg_flags = MSG_DONTWAIT; -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); -#endif + oldfs = get_fs(); set_fs(KERNEL_DS); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) err = sock_sendmsg(sock, &msg); #else err = sock_sendmsg(sock, &msg, sizeof(req)); #endif -#ifdef set_fs set_fs(oldfs); -#endif if (err < 0) goto out_sock; @@ -3222,14 +3142,9 @@ restart: iov_iter_init(&msg.msg_iter, READ, &iov, 1, PAGE_SIZE); #endif -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); -#endif + oldfs = get_fs(); set_fs(KERNEL_DS); err = sock_recvmsg(sock, &msg, PAGE_SIZE, MSG_DONTWAIT); -#ifdef set_fs set_fs(oldfs); -#endif if (err < 0) goto out_sock_pg; @@ -3305,18 +3220,13 @@ done: msg.msg_controllen = 0; msg.msg_flags=MSG_DONTWAIT; -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); -#endif + oldfs = get_fs(); set_fs(KERNEL_DS); #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) err = sock_sendmsg(sock, &msg); #else err = sock_sendmsg(sock, &msg, sizeof(req)); #endif -#ifdef set_fs set_fs(oldfs); -#endif if (err > 0) goto restart; @@ -3463,9 +3373,6 @@ void rtw_dev_unload(PADAPTER padapter) } if (!rtw_is_surprise_removed(padapter)) { -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_IpsNotify(padapter, pwrctl->ips_mode_req); -#endif { //amy modify 20120221 for power seq is different between driver open and ips rtw_hal_deinit(padapter); @@ -3657,22 +3564,6 @@ int rtw_suspend_common(_adapter *padapter) rtw_stop_cmd_thread(padapter); -#ifdef CONFIG_BT_COEXIST - // wait for the latest FW to remove this condition. - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE) { - rtw_btcoex_SuspendNotify(padapter, 0); - DBG_871X("WIFI_AP_STATE\n"); -#ifdef CONFIG_CONCURRENT_MODE - } else if (check_buddy_fwstate(padapter, WIFI_AP_STATE)) { - rtw_btcoex_SuspendNotify(padapter, 0); - DBG_871X("P2P_ROLE_GO\n"); -#endif //CONFIG_CONCURRENT_MODE - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == _TRUE) { - rtw_btcoex_SuspendNotify(padapter, 1); - DBG_871X("STATION\n"); - } -#endif // CONFIG_BT_COEXIST - rtw_ps_deny_cancel(padapter, PS_DENY_SUSPEND); if (check_fwstate(pmlmepriv,WIFI_STATION_STATE) == _TRUE @@ -3868,10 +3759,6 @@ int rtw_resume_common(_adapter *padapter) rtw_resume_process_normal(padapter); } - #ifdef CONFIG_BT_COEXIST - rtw_btcoex_SuspendNotify(padapter, 0); - #endif // CONFIG_BT_COEXIST - if (pwrpriv) { pwrpriv->bInSuspend = _FALSE; #ifdef CONFIG_PNO_SUPPORT diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.c deleted file mode 100644 index b55f9b43c..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.c +++ /dev/null @@ -1,2194 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -#include /* tolower() */ -#include -#include -#include "rtw_proc.h" -#ifdef CONFIG_BT_COEXIST -#include -#endif - -#ifdef CONFIG_PROC_DEBUG - -static struct proc_dir_entry *rtw_proc = NULL; - -inline struct proc_dir_entry *get_rtw_drv_proc(void) -{ - return rtw_proc; -} - -#define RTW_PROC_NAME DRV_NAME - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,9,0)) -#define file_inode(file) ((file)->f_dentry->d_inode) -#endif - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,10,0)) -#define PDE_DATA(inode) PDE((inode))->data -#define proc_get_parent_data(inode) PDE((inode))->parent->data -#endif - -#if(LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24)) -#define get_proc_net proc_net -#else -#define get_proc_net init_net.proc_net -#endif - -inline struct proc_dir_entry *rtw_proc_create_dir(const char *name, struct proc_dir_entry *parent, void *data) -{ - struct proc_dir_entry *entry; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,10,0)) - entry = proc_mkdir_data(name, S_IRUGO|S_IXUGO, parent, data); -#else - //entry = proc_mkdir_mode(name, S_IRUGO|S_IXUGO, parent); - entry = proc_mkdir(name, parent); - if (entry) - entry->data = data; -#endif - - return entry; -} - -inline struct proc_dir_entry *rtw_proc_create_entry(const char *name, struct proc_dir_entry *parent, -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) - const struct file_operations *fops, -#else - const struct proc_ops *fops, -#endif - void * data) -{ - struct proc_dir_entry *entry; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) - entry = proc_create_data(name, S_IFREG|S_IRUGO|S_IWUGO, parent, fops, data); -#else - entry = create_proc_entry(name, S_IFREG|S_IRUGO|S_IWUGO, parent); - if (entry) { - entry->data = data; - entry->proc_fops = fops; - } -#endif - - return entry; -} - -static int proc_get_dummy(struct seq_file *m, void *v) -{ - return 0; -} - -static int proc_get_drv_version(struct seq_file *m, void *v) -{ - dump_drv_version(m); - return 0; -} - -static int proc_get_log_level(struct seq_file *m, void *v) -{ - dump_log_level(m); - return 0; -} - -static int proc_get_drv_cfg(struct seq_file *m, void *v) -{ - dump_drv_cfg(m); - return 0; -} - -static ssize_t proc_set_log_level(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - char tmp[32]; - int log_level; - - if (count < 1) - return -EINVAL; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%d ", &log_level); - - if( log_level >= _drv_always_ && log_level <= _drv_debug_ ) - { - GlobalDebugLevel= log_level; - printk("%d\n", GlobalDebugLevel); - } - } else { - return -EFAULT; - } - - return count; -} - -#ifdef DBG_MEM_ALLOC -static int proc_get_mstat(struct seq_file *m, void *v) -{ - rtw_mstat_dump(m); - return 0; -} -#endif /* DBG_MEM_ALLOC */ - -static int proc_get_country_chplan_map(struct seq_file *m, void *v) -{ - dump_country_chplan_map(m); - return 0; -} - -static int proc_get_chplan_id_list(struct seq_file *m, void *v) -{ - dump_chplan_id_list(m); - return 0; -} - -static int proc_get_chplan_test(struct seq_file *m, void *v) -{ - dump_chplan_test(m); - return 0; -} - -/* -* rtw_drv_proc: -* init/deinit when register/unregister driver -*/ -const struct rtw_proc_hdl drv_proc_hdls [] = { - {"ver_info", proc_get_drv_version, NULL}, - {"log_level", proc_get_log_level, proc_set_log_level}, - {"drv_cfg", proc_get_drv_cfg, NULL}, -#ifdef DBG_MEM_ALLOC - {"mstat", proc_get_mstat, NULL}, -#endif /* DBG_MEM_ALLOC */ - {"country_chplan_map", proc_get_country_chplan_map, NULL}, - {"chplan_id_list", proc_get_chplan_id_list, NULL}, - {"chplan_test", proc_get_chplan_test, NULL}, -}; - -const int drv_proc_hdls_num = sizeof(drv_proc_hdls) / sizeof(struct rtw_proc_hdl); - -static int rtw_drv_proc_open(struct inode *inode, struct file *file) -{ - //struct net_device *dev = proc_get_parent_data(inode); - ssize_t index = (ssize_t)PDE_DATA(inode); - const struct rtw_proc_hdl *hdl = drv_proc_hdls+index; - return single_open(file, hdl->show, NULL); -} - -static ssize_t rtw_drv_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) -{ - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); - const struct rtw_proc_hdl *hdl = drv_proc_hdls+index; - ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; - - if (write) - return write(file, buffer, count, pos, NULL); - - return -EROFS; -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) -static const struct file_operations rtw_drv_proc_fops = { - .owner = THIS_MODULE, - .open = rtw_drv_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = rtw_drv_proc_write, -}; -#else -static const struct proc_ops rtw_drv_proc_fops = { - .proc_open = rtw_drv_proc_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_release = seq_release, - .proc_write = rtw_drv_proc_write, -}; -#endif - -int rtw_drv_proc_init(void) -{ - int ret = _FAIL; - ssize_t i; - struct proc_dir_entry *entry = NULL; - - if (rtw_proc != NULL) { - rtw_warn_on(1); - goto exit; - } - - rtw_proc = rtw_proc_create_dir(RTW_PROC_NAME, get_proc_net, NULL); - - if (rtw_proc == NULL) { - rtw_warn_on(1); - goto exit; - } - - for (i=0;iprivate; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - sd_f0_reg_dump(m, adapter); - - return 0; -} - -static int proc_get_sdio_local_reg_dump(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - sdio_local_reg_dump(m, adapter); - - return 0; -} -#endif /* CONFIG_SDIO_HCI */ - -static int proc_get_mac_reg_dump(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - mac_reg_dump(m, adapter); - - return 0; -} - -static int proc_get_bb_reg_dump(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - bb_reg_dump(m, adapter); - - return 0; -} - -static int proc_get_rf_reg_dump(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - rf_reg_dump(m, adapter); - - return 0; -} - -static int proc_get_dump_adapters_status(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_adapters_status(m, adapter_to_dvobj(adapter)); - - return 0; -} - -#ifdef CONFIG_RTW_CUSTOMER_STR -static int proc_get_customer_str(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - u8 cstr[RTW_CUSTOMER_STR_LEN]; - - rtw_ps_deny(adapter, PS_DENY_IOCTL); - if (rtw_pwr_wakeup(adapter) == _FAIL) - goto exit; - - if (rtw_hal_customer_str_read(adapter, cstr) != _SUCCESS) - goto exit; - - RTW_PRINT_SEL(m, RTW_CUSTOMER_STR_FMT"\n", RTW_CUSTOMER_STR_ARG(cstr)); - -exit: - rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL); - return 0; -} -#endif /* CONFIG_RTW_CUSTOMER_STR */ - -//gpio setting -#ifdef CONFIG_GPIO_API -static ssize_t proc_set_config_gpio(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]={0}; - int num=0,gpio_pin=0,gpio_mode=0;//gpio_mode:0 input 1:output; - - if (count < 2) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - num =sscanf(tmp, "%d %d",&gpio_pin,&gpio_mode); - DBG_871X("num=%d gpio_pin=%d mode=%d\n",num,gpio_pin,gpio_mode); - padapter->pre_gpio_pin=gpio_pin; - - if(gpio_mode==0 || gpio_mode==1 ) - rtw_hal_config_gpio(padapter, gpio_pin,gpio_mode); - } - return count; - -} -static ssize_t proc_set_gpio_output_value(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]={0}; - int num=0,gpio_pin=0,pin_mode=0;//pin_mode: 1 high 0:low - - if (count < 2) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - num =sscanf(tmp, "%d %d",&gpio_pin,&pin_mode); - DBG_871X("num=%d gpio_pin=%d pin_high=%d\n",num,gpio_pin,pin_mode); - padapter->pre_gpio_pin=gpio_pin; - - if(pin_mode==0 || pin_mode==1 ) - rtw_hal_set_gpio_output_value(padapter, gpio_pin,pin_mode); - } - return count; -} -static int proc_get_gpio(struct seq_file *m, void *v) -{ - u8 gpioreturnvalue=0; - struct net_device *dev = m->private; - - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - if(!padapter) - return -EFAULT; - gpioreturnvalue = rtw_hal_get_gpio(padapter, padapter->pre_gpio_pin); - DBG_871X_SEL_NL(m, "get_gpio %d:%d \n",padapter->pre_gpio_pin ,gpioreturnvalue); - - return 0; - -} -static ssize_t proc_set_gpio(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]={0}; - int num=0,gpio_pin=0; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - num =sscanf(tmp, "%d",&gpio_pin); - DBG_871X("num=%d gpio_pin=%d\n",num,gpio_pin); - padapter->pre_gpio_pin=gpio_pin; - - } - return count; -} -#endif -static int proc_get_current_tx_rate(struct seq_file *m, void *v) -{ - - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct macid_ctl_t *macid_ctl = dvobj_to_macidctl(dvobj); - u8 i; - u8 null_addr[ETH_ALEN] = {0}; - u8 *macaddr; - u8 current_rate_id = 0; - - DBG_871X_SEL_NL(m, "%-5s %-4s %-17s %-7s\n" - , "macid", "if_g", "macaddr", "tx_rate"); - - for (i = 0; i < macid_ctl->num; i++) { - if (rtw_macid_is_used(macid_ctl, i) || macid_ctl->h2c_msr[i]) { - if (macid_ctl->sta[i]) - macaddr = macid_ctl->sta[i]->hwaddr; - else - macaddr = null_addr; - current_rate_id = rtw_get_current_tx_rate(adapter, i); - if (!rtw_macid_is_bmc(macid_ctl, i)) { - DBG_871X_SEL_NL(m, "%5u %4u "MAC_FMT" %s\n" - , i - , rtw_macid_get_if_g(macid_ctl, i) - , MAC_ARG(macaddr) - , HDATA_RATE(current_rate_id) - ); - } - - - } - } - - -return 0; - -} - - -static int proc_get_linked_info_dump(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - if(padapter) - DBG_871X_SEL_NL(m, "linked_info_dump :%s \n", (padapter->bLinkInfoDump)?"enable":"disable"); - - return 0; -} - - -static ssize_t proc_set_linked_info_dump(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - - char tmp[32]={0}; - int mode=0,pre_mode=0; - int num=0; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - pre_mode=padapter->bLinkInfoDump; - DBG_871X("pre_mode=%d\n", pre_mode); - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - num =sscanf(tmp, "%d ", &mode); - DBG_871X("num=%d mode=%d\n",num,mode); - - if(num!=1) - { - DBG_871X("argument number is wrong\n"); - return -EFAULT; - } - - if(mode==1 || (mode==0 && pre_mode==1) ) //not consider pwr_saving 0: - { - padapter->bLinkInfoDump = mode; - - } - else if( (mode==2 ) || (mode==0 && pre_mode==2))//consider power_saving - { - //DBG_871X("linked_info_dump =%s \n", (padapter->bLinkInfoDump)?"enable":"disable") - linked_info_dump(padapter,mode); - } - } - return count; -} - -static int proc_get_mac_qinfo(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - rtw_hal_get_hwreg(adapter, HW_VAR_DUMP_MAC_QUEUE_INFO, (u8 *)m); - - return 0; -} - -int proc_get_wifi_spec(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - struct registry_priv *pregpriv = &padapter->registrypriv; - - DBG_871X_SEL_NL(m,"wifi_spec=%d\n",pregpriv->wifi_spec); - return 0; -} - -static int proc_get_chan_plan(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_cur_chset(m, adapter); - - return 0; -} - -static ssize_t proc_set_chan_plan(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u8 chan_plan = RTW_CHPLAN_MAX; - - if (!padapter) - return -EFAULT; - - if (count < 1) - { - DBG_871X("argument size is less than 1\n"); - return -EFAULT; - } - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - int num = sscanf(tmp, "%hhx", &chan_plan); - if (num != 1) - return count; - } - - rtw_set_channel_plan(padapter, chan_plan); - - return count; -} - -static int proc_get_country_code(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - if (adapter->mlmepriv.country_ent) - dump_country_chplan(m, adapter->mlmepriv.country_ent); - else - DBG_871X_SEL_NL(m, "unspecified\n"); - - return 0; -} - -static ssize_t proc_set_country_code(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - char alpha2[2]; - int num; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (!buffer || copy_from_user(tmp, buffer, count)) - goto exit; - - num = sscanf(tmp, "%c%c", &alpha2[0], &alpha2[1]); - if (num != 2) - return count; - - rtw_set_country(padapter, alpha2); - -exit: - return count; -} - -#ifdef CONFIG_DFS_MASTER -ssize_t proc_set_update_non_ocp(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct mlme_priv *mlme = &adapter->mlmepriv; - struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; - char tmp[32]; - u8 ch, bw = CHANNEL_WIDTH_20, offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - int ms = -1; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhu %hhu %hhu %d", &ch, &bw, &offset, &ms); - - if (num < 1 || (bw != CHANNEL_WIDTH_20 && num < 3)) - goto exit; - - if (bw == CHANNEL_WIDTH_20) - rtw_chset_update_non_ocp_ms(mlmeext->channel_set - , ch, bw, HAL_PRIME_CHNL_OFFSET_DONT_CARE, ms); - else - rtw_chset_update_non_ocp_ms(mlmeext->channel_set - , ch, bw, offset, ms); - } - -exit: - return count; -} - -ssize_t proc_set_radar_detect(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct rf_ctl_t *rfctl = adapter_to_rfctl(adapter); - char tmp[32]; - u8 fake_radar_detect_cnt = 0; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhu", &fake_radar_detect_cnt); - - if (num < 1) - goto exit; - - rfctl->dbg_dfs_master_fake_radar_detect_cnt = fake_radar_detect_cnt; - } - -exit: - return count; -} -#endif /* CONFIG_DFS_MASTER */ - -static int proc_get_udpport(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - struct recv_priv *precvpriv = &(padapter->recvpriv); - - DBG_871X_SEL_NL(m,"%d\n",precvpriv->sink_udpport); - return 0; -} -static ssize_t proc_set_udpport(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - struct recv_priv *precvpriv = &(padapter->recvpriv); - int sink_udpport = 0; - char tmp[32]; - - - if (!padapter) - return -EFAULT; - - if (count < 1) - { - DBG_871X("argument size is less than 1\n"); - return -EFAULT; - } - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%d", &sink_udpport); - - if (num != 1) { - DBG_871X("invalid input parameter number!\n"); - return count; - } - - } - precvpriv->sink_udpport = sink_udpport; - - return count; - -} - -static int proc_get_macid_info(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct macid_ctl_t *macid_ctl = dvobj_to_macidctl(dvobj); - u8 i; - u8 null_addr[ETH_ALEN] = {0}; - u8 *macaddr; - - DBG_871X_SEL_NL(m, "max_num:%u\n", macid_ctl->num); - DBG_871X_SEL_NL(m, "\n"); - - DBG_871X_SEL_NL(m, "used:\n"); - dump_macid_map(m, &macid_ctl->used, macid_ctl->num); - DBG_871X_SEL_NL(m, "\n"); - - DBG_871X_SEL_NL(m, "%-3s %-3s %-4s %-4s %-17s %s" - "\n" - , "id", "bmc", "if_g", "ch_g", "macaddr", "status" - ); - - for (i=0;inum;i++) { - if (rtw_macid_is_used(macid_ctl, i) - || macid_ctl->h2c_msr[i] - ) { - if (macid_ctl->sta[i]) - macaddr = macid_ctl->sta[i]->hwaddr; - else - macaddr = null_addr; - - DBG_871X_SEL_NL(m, "%3u %3u %4d %4d "MAC_FMT" "H2C_MSR_FMT" %s" - "\n" - , i - , rtw_macid_is_bmc(macid_ctl, i) - , rtw_macid_get_if_g(macid_ctl, i) - , rtw_macid_get_ch_g(macid_ctl, i) - , MAC_ARG(macaddr) - , H2C_MSR_ARG(&macid_ctl->h2c_msr[i]) - , rtw_macid_is_used(macid_ctl, i) ? "" : "[unused]" - ); - } - } - - return 0; -} - -static int proc_get_sec_cam(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl; - - DBG_871X_SEL_NL(m, "sec_cap:0x%02x\n", cam_ctl->sec_cap); - DBG_871X_SEL_NL(m, "flags:0x%08x\n", cam_ctl->flags); - DBG_871X_SEL_NL(m, "\n"); - - DBG_871X_SEL_NL(m, "max_num:%u\n", cam_ctl->num); - DBG_871X_SEL_NL(m, "used:\n"); - dump_sec_cam_map(m, &cam_ctl->used, cam_ctl->num); - DBG_871X_SEL_NL(m, "\n"); - - DBG_871X_SEL_NL(m, "reg_scr:0x%04x\n", rtw_read16(adapter, 0x680)); - DBG_871X_SEL_NL(m, "\n"); - - dump_sec_cam(m, adapter); - - return 0; -} - -static ssize_t proc_set_sec_cam(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl; - char tmp[32] = {0}; - char cmd[4]; - u8 id; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - /* c : clear specific cam entry */ - /* wfc : write specific cam entry from cam cache */ - - int num = sscanf(tmp, "%s %hhu", cmd, &id); - - if (num < 2) - return count; - - if (id >= cam_ctl->num) { - DBG_871X_LEVEL(_drv_err_, FUNC_ADPT_FMT" invalid id:%u\n", FUNC_ADPT_ARG(adapter), id); - return count; - } - - if (strcmp("c", cmd) == 0) { - _clear_cam_entry(adapter, id); - adapter->securitypriv.hw_decrypted = _FALSE; /* temporarily set this for TX path to use SW enc */ - } else if (strcmp("wfc", cmd) == 0) { - write_cam_from_cache(adapter, id); - } - } - - return count; -} - -static int proc_get_sec_cam_cache(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct dvobj_priv *dvobj = adapter_to_dvobj(adapter); - struct cam_ctl_t *cam_ctl = &dvobj->cam_ctl; - u8 i; - - DBG_871X_SEL_NL(m, "SW sec cam cache:\n"); - dump_sec_cam_ent_title(m, 1); - for (i = 0; i < cam_ctl->num; i++) { - if (dvobj->cam_cache[i].ctrl != 0) - dump_sec_cam_ent(m, &dvobj->cam_cache[i], i); - } - - return 0; -} - -static ssize_t proc_set_change_bss_chbw(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct mlme_priv *mlme = &(adapter->mlmepriv); - struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); - char tmp[32]; - u8 ch, bw = CHANNEL_WIDTH_20, offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhu %hhu %hhu", &ch, &bw, &offset); - - if (num < 1 || (bw != CHANNEL_WIDTH_20 && num < 3)) - goto exit; - - if (check_fwstate(mlme, WIFI_AP_STATE) && check_fwstate(mlme, WIFI_ASOC_STATE)) - rtw_change_bss_chbw_cmd(adapter, RTW_CMDF_WAIT_ACK, ch, bw, offset); - } - -exit: - return count; -} - -static int proc_get_target_tx_power(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_target_tx_power(m, adapter); - - return 0; -} - -static int proc_get_tx_power_by_rate(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_tx_power_by_rate(m, adapter); - - return 0; -} - -static int proc_get_tx_power_limit(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_tx_power_limit(m, adapter); - - return 0; -} - -static int proc_get_tx_power_ext_info(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_tx_power_ext_info(m, adapter); - - return 0; -} - -static ssize_t proc_set_tx_power_ext_info(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - char tmp[32] = {0}; - char cmd[16] = {0}; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%s", cmd); - - if (num < 1) - return count; - - #ifdef CONFIG_LOAD_PHY_PARA_FROM_FILE - phy_free_filebuf_mask(adapter, LOAD_BB_PG_PARA_FILE | LOAD_RF_TXPWR_LMT_PARA_FILE); - #endif - - rtw_ps_deny(adapter, PS_DENY_IOCTL); - LeaveAllPowerSaveModeDirect(adapter); - - if (strcmp("default", cmd) == 0) - rtw_run_in_thread_cmd(adapter, ((void *)(phy_reload_default_tx_power_ext_info)), adapter); - else - rtw_run_in_thread_cmd(adapter, ((void *)(phy_reload_tx_power_ext_info)), adapter); - - rtw_ps_deny_cancel(adapter, PS_DENY_IOCTL); - } - - return count; -} - -#ifdef CONFIG_RF_POWER_TRIM -static int proc_get_kfree_flag(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - - DBG_871X_SEL_NL(m, "0x%02x\n", kfree_data->flag); - - return 0; -} - -static ssize_t proc_set_kfree_flag(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - char tmp[32] = {0}; - u8 flag; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhx", &flag); - - if (num < 1) - return count; - - kfree_data->flag = flag; - } - - return count; -} - -static int proc_get_kfree_bb_gain(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - u8 i, j; - - for (i = 0; i < BB_GAIN_NUM; i++) { - if (i == 0) - DBG_871X_SEL(m, "2G: "); - else if (i == 1) - DBG_871X_SEL(m, "5GLB1: "); - else if (i == 2) - DBG_871X_SEL(m, "5GLB2: "); - else if (i == 3) - DBG_871X_SEL(m, "5GMB1: "); - else if (i == 4) - DBG_871X_SEL(m, "5GMB2: "); - else if (i == 5) - DBG_871X_SEL(m, "5GHB: "); - - for (j = 0; j < hal_data->NumTotalRFPath; j++) - DBG_871X_SEL(m, "%d ", kfree_data->bb_gain[i][j]); - DBG_871X_SEL(m, "\n"); - } - - return 0; -} - -static ssize_t proc_set_kfree_bb_gain(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - HAL_DATA_TYPE *hal_data = GET_HAL_DATA(adapter); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - char tmp[BB_GAIN_NUM * RF_PATH_MAX] = {0}; - u8 path, chidx; - s8 bb_gain[BB_GAIN_NUM]; - char ch_band_Group[6]; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - char *c, *next; - int i = 0; - - next = tmp; - c = strsep(&next, " \t"); - - if (sscanf(c, "%s", ch_band_Group) != 1) { - DBG_871X("Error Head Format, channel Group select\n,Please input:\t 2G , 5GLB1 , 5GLB2 , 5GMB1 , 5GMB2 , 5GHB\n"); - return count; - } - if (strcmp("2G", ch_band_Group) == 0) - chidx = BB_GAIN_2G; -#ifdef CONFIG_IEEE80211_BAND_5GHZ - else if (strcmp("5GLB1", ch_band_Group) == 0) - chidx = BB_GAIN_5GLB1; - else if (strcmp("5GLB2", ch_band_Group) == 0) - chidx = BB_GAIN_5GLB2; - else if (strcmp("5GMB1", ch_band_Group) == 0) - chidx = BB_GAIN_5GMB1; - else if (strcmp("5GMB2", ch_band_Group) == 0) - chidx = BB_GAIN_5GMB2; - else if (strcmp("5GHB", ch_band_Group) == 0) - chidx = BB_GAIN_5GHB; -#endif /*CONFIG_IEEE80211_BAND_5GHZ*/ - else { - DBG_871X("Error Head Format, channel Group select\n,Please input:\t 2G , 5GLB1 , 5GLB2 , 5GMB1 , 5GMB2 , 5GHB\n"); - return count; - } - c = strsep(&next, " \t"); - - while (c != NULL) { - if (sscanf(c, "%hhx", &bb_gain[i]) != 1) - break; - - kfree_data->bb_gain[chidx][i] = bb_gain[i]; - DBG_871X("%s,kfree_data->bb_gain[%d][%d]=%x\n", __func__, chidx, i, kfree_data->bb_gain[chidx][i]); - - c = strsep(&next, " \t"); - i++; - } - - } - - return count; - -} - -static int proc_get_kfree_thermal(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - - DBG_871X_SEL(m, "%d\n", kfree_data->thermal); - - return 0; -} - -static ssize_t proc_set_kfree_thermal(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - struct kfree_data_t *kfree_data = GET_KFREE_DATA(adapter); - char tmp[32] = {0}; - s8 thermal; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhd", &thermal); - - if (num < 1) - return count; - - kfree_data->thermal = thermal; - } - - return count; -} - -static ssize_t proc_set_tx_gain_offset(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter; - char tmp[32] = {0}; - u8 rf_path; - s8 offset; - - adapter = (_adapter *)rtw_netdev_priv(dev); - if (!adapter) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - u8 write_value; - int num = sscanf(tmp, "%hhu %hhd", &rf_path, &offset); - - if (num < 2) - return count; - - DBG_871X("write rf_path:%u tx gain offset:%d\n", rf_path, offset); - rtw_rf_set_tx_gain_offset(adapter, rf_path, offset); - } - - return count; -} -#endif /* CONFIG_RF_POWER_TRIM */ - -#ifdef CONFIG_BT_COEXIST -ssize_t proc_set_btinfo_evt(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u8 btinfo[8]; - - if (count < 6) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - int num = 0; - - _rtw_memset(btinfo, 0, 8); - - num = sscanf(tmp, "%hhx %hhx %hhx %hhx %hhx %hhx %hhx %hhx" - , &btinfo[0], &btinfo[1], &btinfo[2], &btinfo[3] - , &btinfo[4], &btinfo[5], &btinfo[6], &btinfo[7]); - - if (num < 6) - return -EINVAL; - - btinfo[1] = num-2; - - rtw_btinfo_cmd(padapter, btinfo, btinfo[1]+2); - } - - return count; -} - -static u8 btreg_read_type = 0; -static u16 btreg_read_addr = 0; -static int btreg_read_error = 0; -static u8 btreg_write_type = 0; -static u16 btreg_write_addr = 0; -static int btreg_write_error = 0; - -static u8 *btreg_type[] = { - "rf", - "modem", - "bluewize", - "vendor", - "le" -}; - -static int btreg_parse_str(char const *input, u8 *type, u16 *addr, u16 *val) -{ - u32 num; - u8 str[80] = {0}; - u8 t = 0; - u32 a, v; - u8 i, n; - u8 *p; - - - num = sscanf(input, "%s %x %x", str, &a, &v); - if (num < 2) { - DBG_871X("%s: INVALID input!(%s)\n", __FUNCTION__, input); - return -EINVAL; - } - if ((num < 3) && val) { - DBG_871X("%s: INVALID input!(%s)\n", __FUNCTION__, input); - return -EINVAL; - } - - /* convert to lower case for following type compare */ - p = str; - for ( ; *p; ++p) - *p = tolower(*p); - n = sizeof(btreg_type)/sizeof(btreg_type[0]); - for (i = 0; i < n; i++) { - if (!strcmp(str, btreg_type[i])) { - t = i; - break; - } - } - if (i == n) { - DBG_871X("%s: unknown type(%s)!\n", __FUNCTION__, str); - return -EINVAL; - } - - switch (t) { - case 0: - /* RF */ - if (a & 0xFFFFFF80) { - DBG_871X("%s: INVALID address(0x%X) for type %s(%d)!\n", - __FUNCTION__, a, btreg_type[t], t); - return -EINVAL; - } - break; - case 1: - /* Modem */ - if (a & 0xFFFFFE00) { - DBG_871X("%s: INVALID address(0x%X) for type %s(%d)!\n", - __FUNCTION__, a, btreg_type[t], t); - return -EINVAL; - } - break; - default: - /* Others(Bluewize, Vendor, LE) */ - if (a & 0xFFFFF000) { - DBG_871X("%s: INVALID address(0x%X) for type %s(%d)!\n", - __FUNCTION__, a, btreg_type[t], t); - return -EINVAL; - } - break; - } - - if (val) { - if (v & 0xFFFF0000) { - DBG_871X("%s: INVALID value(0x%x)!\n", __FUNCTION__, v); - return -EINVAL; - } - *val = (u16)v; - } - - *type = (u8)t; - *addr = (u16)a; - - return 0; -} - -int proc_get_btreg_read(struct seq_file *m, void *v) -{ - struct net_device *dev; - PADAPTER padapter; - u16 ret; - u32 data; - - - if (btreg_read_error) - return btreg_read_error; - - dev = m->private; - padapter = (PADAPTER)rtw_netdev_priv(dev); - - ret = rtw_btcoex_btreg_read(padapter, btreg_read_type, btreg_read_addr, &data); - if (CHECK_STATUS_CODE_FROM_BT_MP_OPER_RET(ret, BT_STATUS_BT_OP_SUCCESS)) - DBG_871X_SEL_NL(m, "BTREG read: (%s)0x%04X = 0x%08x\n", btreg_type[btreg_read_type], btreg_read_addr, data); - else - DBG_871X_SEL_NL(m, "BTREG read: (%s)0x%04X read fail. error code = 0x%04x.\n", btreg_type[btreg_read_type], btreg_read_addr, ret); - - return 0; -} - -ssize_t proc_set_btreg_read(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - PADAPTER padapter; - u8 tmp[80] = {0}; - u32 num; - int err; - - - padapter = (PADAPTER)rtw_netdev_priv(dev); - - if (NULL == buffer) { - DBG_871X(FUNC_ADPT_FMT ": input buffer is NULL!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - - if (count < 1) { - DBG_871X(FUNC_ADPT_FMT ": input length is 0!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - - num = count; - if (num > (sizeof(tmp) - 1)) - num = (sizeof(tmp) - 1); - - if (copy_from_user(tmp, buffer, num)) { - DBG_871X(FUNC_ADPT_FMT ": copy buffer from user space FAIL!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - /* [Coverity] sure tmp end with '\0'(string terminal) */ - tmp[sizeof(tmp) - 1] = 0; - - err = btreg_parse_str(tmp, &btreg_read_type, &btreg_read_addr, NULL); - if (err) - goto exit; - - DBG_871X(FUNC_ADPT_FMT ": addr=(%s)0x%X\n", - FUNC_ADPT_ARG(padapter), btreg_type[btreg_read_type], btreg_read_addr); - -exit: - btreg_read_error = err; - - return count; -} - -int proc_get_btreg_write(struct seq_file *m, void *v) -{ - struct net_device *dev; - PADAPTER padapter; - u16 ret; - u32 data; - - - if (btreg_write_error < 0) - return btreg_write_error; - else if (btreg_write_error > 0) { - DBG_871X_SEL_NL(m, "BTREG write: (%s)0x%04X write fail. error code = 0x%04x.\n", btreg_type[btreg_write_type], btreg_write_addr, btreg_write_error); - return 0; - } - - dev = m->private; - padapter = (PADAPTER)rtw_netdev_priv(dev); - - ret = rtw_btcoex_btreg_read(padapter, btreg_write_type, btreg_write_addr, &data); - if (CHECK_STATUS_CODE_FROM_BT_MP_OPER_RET(ret, BT_STATUS_BT_OP_SUCCESS)) - DBG_871X_SEL_NL(m, "BTREG read: (%s)0x%04X = 0x%08x\n", btreg_type[btreg_write_type], btreg_write_addr, data); - else - DBG_871X_SEL_NL(m, "BTREG read: (%s)0x%04X read fail. error code = 0x%04x.\n", btreg_type[btreg_write_type], btreg_write_addr, ret); - - return 0; -} - -ssize_t proc_set_btreg_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - PADAPTER padapter; - u8 tmp[80] = {0}; - u32 num; - u16 val; - u16 ret; - int err; - - - padapter = (PADAPTER)rtw_netdev_priv(dev); - - if (NULL == buffer) { - DBG_871X(FUNC_ADPT_FMT ": input buffer is NULL!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - - if (count < 1) { - DBG_871X(FUNC_ADPT_FMT ": input length is 0!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - - num = count; - if (num > (sizeof(tmp) - 1)) - num = (sizeof(tmp) - 1); - - if (copy_from_user(tmp, buffer, num)) { - DBG_871X(FUNC_ADPT_FMT ": copy buffer from user space FAIL!\n", - FUNC_ADPT_ARG(padapter)); - err = -EFAULT; - goto exit; - } - - err = btreg_parse_str(tmp, &btreg_write_type, &btreg_write_addr, &val); - if (err) - goto exit; - - DBG_871X(FUNC_ADPT_FMT ": Set (%s)0x%X = 0x%x\n", - FUNC_ADPT_ARG(padapter), btreg_type[btreg_write_type], btreg_write_addr, val); - - ret = rtw_btcoex_btreg_write(padapter, btreg_write_type, btreg_write_addr, val); - if (!CHECK_STATUS_CODE_FROM_BT_MP_OPER_RET(ret, BT_STATUS_BT_OP_SUCCESS)) - err = ret; - -exit: - btreg_write_error = err; - - return count; -} -#endif /* CONFIG_BT_COEXIST */ - -#ifdef CONFIG_AUTO_CHNL_SEL_NHM -static int proc_get_best_chan(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - u8 best_24g_ch = 0, best_5g_ch = 0; - - rtw_hal_get_odm_var(adapter, HAL_ODM_AUTO_CHNL_SEL, &(best_24g_ch), &(best_5g_ch)); - - DBG_871X_SEL_NL(m, "Best 2.4G CH:%u\n", best_24g_ch); - DBG_871X_SEL_NL(m, "Best 5G CH:%u\n", best_5g_ch); - return 0; -} - -static ssize_t proc_set_acs(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u8 acs_satae = 0; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%hhu", &acs_satae); - - if (num < 1) - return -EINVAL; - - if (1 == acs_satae) - rtw_acs_start(padapter, _TRUE); - else - rtw_acs_start(padapter, _FALSE); - - } - return count; -} -#endif - -static int proc_get_hal_spec(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - dump_hal_spec(m, adapter); - return 0; -} - -/* -* rtw_adapter_proc: -* init/deinit when register/unregister net_device -*/ -const struct rtw_proc_hdl adapter_proc_hdls [] = { - {"write_reg", proc_get_dummy, proc_set_write_reg}, - {"read_reg", proc_get_read_reg, proc_set_read_reg}, - {"adapters_status", proc_get_dump_adapters_status, NULL}, -#ifdef CONFIG_RTW_CUSTOMER_STR - {"customer_str", proc_get_customer_str, NULL}, -#endif - {"fwstate", proc_get_fwstate, NULL}, - {"sec_info", proc_get_sec_info, NULL}, - {"mlmext_state", proc_get_mlmext_state, NULL}, - {"qos_option", proc_get_qos_option, NULL}, - {"ht_option", proc_get_ht_option, NULL}, - {"rf_info", proc_get_rf_info, NULL}, - {"scan_param", proc_get_scan_param, proc_set_scan_param}, - {"scan_abort", proc_get_scan_abort, NULL}, -#ifdef CONFIG_SCAN_BACKOP - {"backop_flags_sta", proc_get_backop_flags_sta, proc_set_backop_flags_sta}, - {"backop_flags_ap", proc_get_backop_flags_ap, proc_set_backop_flags_ap}, -#endif - {"survey_info", proc_get_survey_info, proc_set_survey_info}, - {"ap_info", proc_get_ap_info, NULL}, - {"trx_info", proc_get_trx_info, proc_reset_trx_info}, - {"rate_ctl", proc_get_rate_ctl, proc_set_rate_ctl}, - {"dis_pwt_ctl", proc_get_dis_pwt, proc_set_dis_pwt}, - {"mac_qinfo", proc_get_mac_qinfo, NULL}, - {"macid_info", proc_get_macid_info, NULL}, - {"sec_cam", proc_get_sec_cam, proc_set_sec_cam}, - {"sec_cam_cache", proc_get_sec_cam_cache, NULL}, - {"suspend_info", proc_get_suspend_resume_info, NULL}, - {"wifi_spec",proc_get_wifi_spec,NULL}, -#ifdef CONFIG_LAYER2_ROAMING - {"roam_flags", proc_get_roam_flags, proc_set_roam_flags}, - {"roam_param", proc_get_roam_param, proc_set_roam_param}, - {"roam_tgt_addr", proc_get_dummy, proc_set_roam_tgt_addr}, -#endif /* CONFIG_LAYER2_ROAMING */ - -#ifdef CONFIG_SDIO_HCI - {"sd_f0_reg_dump", proc_get_sd_f0_reg_dump, NULL}, - {"sdio_local_reg_dump", proc_get_sdio_local_reg_dump, NULL}, -#endif /* CONFIG_SDIO_HCI */ - - {"fwdl_test_case", proc_get_dummy, proc_set_fwdl_test_case}, - {"del_rx_ampdu_test_case", proc_get_dummy, proc_set_del_rx_ampdu_test_case}, - {"wait_hiq_empty", proc_get_dummy, proc_set_wait_hiq_empty}, - - {"mac_reg_dump", proc_get_mac_reg_dump, NULL}, - {"bb_reg_dump", proc_get_bb_reg_dump, NULL}, - {"rf_reg_dump", proc_get_rf_reg_dump, NULL}, - -#ifdef CONFIG_AP_MODE - {"all_sta_info", proc_get_all_sta_info, NULL}, -#endif /* CONFIG_AP_MODE */ - -#ifdef DBG_MEMORY_LEAK - {"_malloc_cnt", proc_get_malloc_cnt, NULL}, -#endif /* DBG_MEMORY_LEAK */ - -#ifdef CONFIG_FIND_BEST_CHANNEL - {"best_channel", proc_get_best_channel, proc_set_best_channel}, -#endif - - {"rx_signal", proc_get_rx_signal, proc_set_rx_signal}, - {"hw_info", proc_get_hw_status, NULL}, - -#ifdef CONFIG_80211N_HT - {"ht_enable", proc_get_ht_enable, proc_set_ht_enable}, - {"bw_mode", proc_get_bw_mode, proc_set_bw_mode}, - {"ampdu_enable", proc_get_ampdu_enable, proc_set_ampdu_enable}, - {"rx_stbc", proc_get_rx_stbc, proc_set_rx_stbc}, - {"rx_ampdu", proc_get_rx_ampdu, proc_set_rx_ampdu}, - {"rx_ampdu_factor",proc_get_rx_ampdu_factor,proc_set_rx_ampdu_factor}, - {"rx_ampdu_density",proc_get_rx_ampdu_density,proc_set_rx_ampdu_density}, - {"tx_ampdu_density",proc_get_tx_ampdu_density,proc_set_tx_ampdu_density}, -#endif /* CONFIG_80211N_HT */ - - {"en_fwps", proc_get_en_fwps, proc_set_en_fwps}, - {"mac_rptbuf", proc_get_mac_rptbuf, NULL}, - - //{"path_rssi", proc_get_two_path_rssi, NULL}, -// {"rssi_disp",proc_get_rssi_disp, proc_set_rssi_disp}, - -#ifdef CONFIG_BT_COEXIST - {"btcoex_dbg", proc_get_btcoex_dbg, proc_set_btcoex_dbg}, - {"btcoex", proc_get_btcoex_info, NULL}, - {"btinfo_evt", proc_get_dummy, proc_set_btinfo_evt}, - {"btreg_read", proc_get_btreg_read, proc_set_btreg_read}, - {"btreg_write", proc_get_btreg_write, proc_set_btreg_write}, -#endif /* CONFIG_BT_COEXIST */ - -#if defined(DBG_CONFIG_ERROR_DETECT) - {"sreset", proc_get_sreset, proc_set_sreset}, -#endif /* DBG_CONFIG_ERROR_DETECT */ - {"trx_info_debug", proc_get_trx_info_debug, NULL}, - {"linked_info_dump",proc_get_linked_info_dump,proc_set_linked_info_dump}, - {"current_tx_rate", proc_get_current_tx_rate, NULL}, -#ifdef CONFIG_GPIO_API - {"gpio_info",proc_get_gpio,proc_set_gpio}, - {"gpio_set_output_value",proc_get_dummy,proc_set_gpio_output_value}, - {"gpio_set_direction",proc_get_dummy,proc_set_config_gpio}, -#endif - -#ifdef CONFIG_DBG_COUNTER - {"rx_logs", proc_get_rx_logs, NULL}, - {"tx_logs", proc_get_tx_logs, NULL}, - {"int_logs", proc_get_int_logs, NULL}, -#endif - -#ifdef CONFIG_PCI_HCI - {"rx_ring", proc_get_rx_ring, NULL}, - {"tx_ring", proc_get_tx_ring, NULL}, -#endif -#ifdef CONFIG_GPIO_WAKEUP - {"wowlan_gpio_info", proc_get_wowlan_gpio_info, - proc_set_wowlan_gpio_info}, -#endif -#ifdef CONFIG_P2P_WOWLAN - {"p2p_wowlan_info", proc_get_p2p_wowlan_info, NULL}, -#endif - {"country_code", proc_get_country_code, proc_set_country_code}, - {"chan_plan", proc_get_chan_plan, proc_set_chan_plan}, -#ifdef CONFIG_DFS_MASTER - {"dfs_master_test_case", proc_get_dfs_master_test_case, proc_set_dfs_master_test_case}, - {"update_non_ocp", proc_get_dummy, proc_set_update_non_ocp}, - {"radar_detect", proc_get_dummy, proc_set_radar_detect}, -#endif - {"new_bcn_max", proc_get_new_bcn_max, proc_set_new_bcn_max}, - {"sink_udpport",proc_get_udpport,proc_set_udpport}, -#ifdef DBG_RX_COUNTER_DUMP - {"dump_rx_cnt_mode",proc_get_rx_cnt_dump,proc_set_rx_cnt_dump}, -#endif - {"change_bss_chbw", NULL, proc_set_change_bss_chbw}, - {"target_tx_power", proc_get_target_tx_power, NULL}, - {"tx_power_by_rate", proc_get_tx_power_by_rate, NULL}, - {"tx_power_limit", proc_get_tx_power_limit, NULL}, - {"tx_power_ext_info", proc_get_tx_power_ext_info, proc_set_tx_power_ext_info}, -#ifdef CONFIG_RF_POWER_TRIM - {"tx_gain_offset", proc_get_dummy, proc_set_tx_gain_offset}, - {"kfree_flag", proc_get_kfree_flag, proc_set_kfree_flag}, - {"kfree_bb_gain", proc_get_kfree_bb_gain, proc_set_kfree_bb_gain}, - {"kfree_thermal", proc_get_kfree_thermal, proc_set_kfree_thermal}, -#endif -#ifdef CONFIG_POWER_SAVING - {"ps_info",proc_get_ps_info, NULL}, -#endif -#ifdef CONFIG_TDLS - {"tdls_info", proc_get_tdls_info, NULL}, -#endif - {"monitor", proc_get_monitor, proc_set_monitor}, - -#ifdef CONFIG_AUTO_CHNL_SEL_NHM - {"acs", proc_get_best_chan, proc_set_acs}, -#endif -#ifdef CONFIG_PREALLOC_RX_SKB_BUFFER - {"rtkm_info", proc_get_rtkm_info, NULL}, -#endif - {"efuse_map", proc_get_efuse_map, NULL}, -#ifdef CONFIG_IEEE80211W - {"11w_tx_sa_query", proc_get_tx_sa_query, proc_set_tx_sa_query}, - {"11w_tx_deauth", proc_get_tx_deauth, proc_set_tx_deauth}, - {"11w_tx_auth", proc_get_tx_auth, proc_set_tx_auth}, -#endif /* CONFIG_IEEE80211W */ - {"hal_spec", proc_get_hal_spec, NULL}, -}; - -const int adapter_proc_hdls_num = sizeof(adapter_proc_hdls) / sizeof(struct rtw_proc_hdl); - -static int rtw_adapter_proc_open(struct inode *inode, struct file *file) -{ - ssize_t index = (ssize_t)PDE_DATA(inode); - const struct rtw_proc_hdl *hdl = adapter_proc_hdls+index; - - return single_open(file, hdl->show, proc_get_parent_data(inode)); -} - -static ssize_t rtw_adapter_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) -{ - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); - const struct rtw_proc_hdl *hdl = adapter_proc_hdls+index; - ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; - - if (write) - return write(file, buffer, count, pos, ((struct seq_file *)file->private_data)->private); - - return -EROFS; -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) -static const struct file_operations rtw_adapter_proc_fops = { - .owner = THIS_MODULE, - .open = rtw_adapter_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = rtw_adapter_proc_write, -}; -#else -static const struct proc_ops rtw_adapter_proc_fops = { - .proc_open = rtw_adapter_proc_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_release = seq_release, - .proc_write = rtw_adapter_proc_write, -}; -#endif - -int proc_get_odm_dbg_comp(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - rtw_odm_dbg_comp_msg(m, adapter); - - return 0; -} - -ssize_t proc_set_odm_dbg_comp(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - - u64 dbg_comp; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%llx", &dbg_comp); - - if (num != 1) - return count; - - rtw_odm_dbg_comp_set(adapter, dbg_comp); - } - - return count; -} - -int proc_get_odm_dbg_level(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - rtw_odm_dbg_level_msg(m, adapter); - - return 0; -} - -ssize_t proc_set_odm_dbg_level(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - - u32 dbg_level; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%u", &dbg_level); - - if (num != 1) - return count; - - rtw_odm_dbg_level_set(adapter, dbg_level); - } - - return count; -} - -int proc_get_odm_ability(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - - rtw_odm_ability_msg(m, adapter); - - return 0; -} - -ssize_t proc_set_odm_ability(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *adapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - - u32 ability; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%x", &ability); - - if (num != 1) - return count; - - rtw_odm_ability_set(adapter, ability); - } - - return count; -} - -int proc_get_odm_adaptivity(struct seq_file *m, void *v) -{ - struct net_device *dev = m->private; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - - rtw_odm_adaptivity_parm_msg(m, padapter); - - return 0; -} - -ssize_t proc_set_odm_adaptivity(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *dev = data; - _adapter *padapter = (_adapter *)rtw_netdev_priv(dev); - char tmp[32]; - u32 TH_L2H_ini; - u32 TH_L2H_ini_mode2; - s8 TH_EDCCA_HL_diff; - s8 TH_EDCCA_HL_diff_mode2; - u8 EDCCA_enable; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) { - rtw_warn_on(1); - return -EFAULT; - } - - if (buffer && !copy_from_user(tmp, buffer, count)) { - - int num = sscanf(tmp, "%x %hhd %x %hhd %hhu", &TH_L2H_ini, &TH_EDCCA_HL_diff, &TH_L2H_ini_mode2, &TH_EDCCA_HL_diff_mode2, &EDCCA_enable); - - if (num != 5) - return count; - - rtw_odm_adaptivity_parm_set(padapter, (s8)TH_L2H_ini, TH_EDCCA_HL_diff, (s8)TH_L2H_ini_mode2, TH_EDCCA_HL_diff_mode2, EDCCA_enable); - } - - return count; -} - -static char *phydm_msg = NULL; -#define PHYDM_MSG_LEN 80*24 - -int proc_get_phydm_cmd(struct seq_file *m, void *v) -{ - struct net_device *netdev; - PADAPTER padapter; - PHAL_DATA_TYPE pHalData; - PDM_ODM_T phydm; - - - netdev = m->private; - padapter = (PADAPTER)rtw_netdev_priv(netdev); - pHalData = GET_HAL_DATA(padapter); - phydm = &pHalData->odmpriv; - - if (NULL == phydm_msg) { - phydm_msg = rtw_zmalloc(PHYDM_MSG_LEN); - if (NULL == phydm_msg) - return -ENOMEM; - - phydm_cmd(phydm, NULL, 0, 0, phydm_msg, PHYDM_MSG_LEN); - } - - DBG_871X_SEL(m, "%s\n", phydm_msg); - - rtw_mfree(phydm_msg, PHYDM_MSG_LEN); - phydm_msg = NULL; - - return 0; -} - -ssize_t proc_set_phydm_cmd(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data) -{ - struct net_device *netdev; - PADAPTER padapter; - PHAL_DATA_TYPE pHalData; - PDM_ODM_T phydm; - char tmp[64] = {0}; - - - netdev = (struct net_device*)data; - padapter = (PADAPTER)rtw_netdev_priv(netdev); - pHalData = GET_HAL_DATA(padapter); - phydm = &pHalData->odmpriv; - - if (count < 1) - return -EFAULT; - - if (count > sizeof(tmp)) - return -EFAULT; - - if (buffer && !copy_from_user(tmp, buffer, count)) { - if (NULL == phydm_msg) { - phydm_msg = rtw_zmalloc(PHYDM_MSG_LEN); - if (NULL == phydm_msg) - return -ENOMEM; - } else { - _rtw_memset(phydm_msg, 0, PHYDM_MSG_LEN); - } - - phydm_cmd(phydm, tmp, count, 1, phydm_msg, PHYDM_MSG_LEN); - - if (strlen(phydm_msg) == 0) { - rtw_mfree(phydm_msg, PHYDM_MSG_LEN); - phydm_msg = NULL; - } - } - - return count; -} - -/* -* rtw_odm_proc: -* init/deinit when register/unregister net_device, along with rtw_adapter_proc -*/ -const struct rtw_proc_hdl odm_proc_hdls [] = { - {"dbg_comp", proc_get_odm_dbg_comp, proc_set_odm_dbg_comp}, - {"dbg_level", proc_get_odm_dbg_level, proc_set_odm_dbg_level}, - {"ability", proc_get_odm_ability, proc_set_odm_ability}, - {"adaptivity", proc_get_odm_adaptivity, proc_set_odm_adaptivity}, - {"cmd", proc_get_phydm_cmd, proc_set_phydm_cmd}, -}; - -const int odm_proc_hdls_num = sizeof(odm_proc_hdls) / sizeof(struct rtw_proc_hdl); - -static int rtw_odm_proc_open(struct inode *inode, struct file *file) -{ - ssize_t index = (ssize_t)PDE_DATA(inode); - const struct rtw_proc_hdl *hdl = odm_proc_hdls+index; - - return single_open(file, hdl->show, proc_get_parent_data(inode)); -} - -static ssize_t rtw_odm_proc_write(struct file *file, const char __user *buffer, size_t count, loff_t *pos) -{ - ssize_t index = (ssize_t)PDE_DATA(file_inode(file)); - const struct rtw_proc_hdl *hdl = odm_proc_hdls+index; - ssize_t (*write)(struct file *, const char __user *, size_t, loff_t *, void *) = hdl->write; - - if (write) - return write(file, buffer, count, pos, ((struct seq_file *)file->private_data)->private); - - return -EROFS; -} - -#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 6, 0)) -static const struct file_operations rtw_odm_proc_fops = { - .owner = THIS_MODULE, - .open = rtw_odm_proc_open, - .read = seq_read, - .llseek = seq_lseek, - .release = single_release, - .write = rtw_odm_proc_write, -}; -#else -static const struct proc_ops rtw_odm_proc_fops = { - .proc_open = rtw_odm_proc_open, - .proc_read = seq_read, - .proc_lseek = seq_lseek, - .proc_release = seq_release, - .proc_write = rtw_odm_proc_write, -}; -#endif -struct proc_dir_entry *rtw_odm_proc_init(struct net_device *dev) -{ - struct proc_dir_entry *dir_odm = NULL; - struct proc_dir_entry *entry = NULL; - _adapter *adapter = rtw_netdev_priv(dev); - ssize_t i; - - if (adapter->dir_dev == NULL) { - rtw_warn_on(1); - goto exit; - } - - if (adapter->dir_odm != NULL) { - rtw_warn_on(1); - goto exit; - } - - dir_odm = rtw_proc_create_dir("odm", adapter->dir_dev, dev); - if (dir_odm == NULL) { - rtw_warn_on(1); - goto exit; - } - - adapter->dir_odm = dir_odm; - - for (i=0;idir_odm; - - if (dir_odm == NULL) { - rtw_warn_on(1); - return; - } - - for (i=0;idir_dev); - - adapter->dir_odm = NULL; - - if (phydm_msg) { - rtw_mfree(phydm_msg, PHYDM_MSG_LEN); - phydm_msg = NULL; - } -} - -struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev) -{ - struct proc_dir_entry *drv_proc = get_rtw_drv_proc(); - struct proc_dir_entry *dir_dev = NULL; - struct proc_dir_entry *entry = NULL; - _adapter *adapter = rtw_netdev_priv(dev); - u8 rf_type; - ssize_t i; - - if (drv_proc == NULL) { - rtw_warn_on(1); - goto exit; - } - - if (adapter->dir_dev != NULL) { - rtw_warn_on(1); - goto exit; - } - - dir_dev = rtw_proc_create_dir(dev->name, drv_proc, dev); - if (dir_dev == NULL) { - rtw_warn_on(1); - goto exit; - } - - adapter->dir_dev = dir_dev; - - for (i=0;idir_dev; - - if (dir_dev == NULL) { - rtw_warn_on(1); - return; - } - - for (i=0;iname, drv_proc); - - adapter->dir_dev = NULL; -} - -void rtw_adapter_proc_replace(struct net_device *dev) -{ - struct proc_dir_entry *drv_proc = get_rtw_drv_proc(); - struct proc_dir_entry *dir_dev = NULL; - _adapter *adapter = rtw_netdev_priv(dev); - int i; - - dir_dev = adapter->dir_dev; - - if (dir_dev == NULL) { - rtw_warn_on(1); - return; - } - - for (i=0;iold_ifname, drv_proc); - - adapter->dir_dev = NULL; - - rtw_adapter_proc_init(dev); - -} - -#endif /* CONFIG_PROC_DEBUG */ diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.h b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.h deleted file mode 100644 index 9aee7bf56..000000000 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/rtw_proc.h +++ /dev/null @@ -1,52 +0,0 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -#ifndef __RTW_PROC_H__ -#define __RTW_PROC_H__ - -#include -#include - -struct rtw_proc_hdl { - char *name; - int (*show)(struct seq_file *, void *); - ssize_t (*write)(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data); -}; - -#ifdef CONFIG_PROC_DEBUG - -struct proc_dir_entry *get_rtw_drv_proc(void); -int rtw_drv_proc_init(void); -void rtw_drv_proc_deinit(void); -struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev); -void rtw_adapter_proc_deinit(struct net_device *dev); -void rtw_adapter_proc_replace(struct net_device *dev); - -#else //!CONFIG_PROC_DEBUG - -#define get_rtw_drv_proc() NULL -#define rtw_drv_proc_init() 0 -#define rtw_drv_proc_deinit() do {} while (0) -#define rtw_adapter_proc_init(dev) NULL -#define rtw_adapter_proc_deinit(dev) do {} while (0) -#define rtw_adapter_proc_replace(dev) do {} while (0) - -#endif //!CONFIG_PROC_DEBUG - -#endif //__RTW_PROC_H__ diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_intf.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_intf.c index c10592bac..878c959b2 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_intf.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_intf.c @@ -833,25 +833,6 @@ int rtw_resume_process(_adapter *padapter) return -1; } -#if defined(CONFIG_BT_COEXIST) && defined(CONFIG_AUTOSUSPEND) //add by amy for 8723as-vau -#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,32)) - DBG_871X("%s...pm_usage_cnt(%d) pwrpriv->bAutoResume=%x. ....\n",__func__,atomic_read(&(adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt)),pwrpriv->bAutoResume); - pm_cnt=atomic_read(&(adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt)); -#else // kernel < 2.6.32 - DBG_871X("...pm_usage_cnt(%d).....\n", adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt); - pm_cnt = adapter_to_dvobj(padapter)->pusbintf->pm_usage_cnt; -#endif // kernel < 2.6.32 - - DBG_871X("pwrpriv->bAutoResume (%x)\n",pwrpriv->bAutoResume ); - if( _TRUE == pwrpriv->bAutoResume ){ - pwrpriv->bInternalAutoSuspend = _FALSE; - pwrpriv->bAutoResume=_FALSE; - DBG_871X("pwrpriv->bAutoResume (%x) pwrpriv->bInternalAutoSuspend(%x)\n",pwrpriv->bAutoResume,pwrpriv->bInternalAutoSuspend ); - - } -#endif //#ifdef CONFIG_BT_COEXIST &CONFIG_AUTOSUSPEND& - - ret = rtw_resume_common(padapter); #ifdef CONFIG_AUTOSUSPEND @@ -865,17 +846,7 @@ int rtw_resume_process(_adapter *padapter) rtw_interface_ps_func(padapter,HAL_USB_SELECT_SUSPEND,&bOpen); } #endif - #ifdef CONFIG_BT_COEXIST // for 8723as-vau - DBG_871X("pwrpriv->bAutoResume (%x)\n",pwrpriv->bAutoResume ); - if( _TRUE == pwrpriv->bAutoResume ){ pwrpriv->bInternalAutoSuspend = _FALSE; - pwrpriv->bAutoResume=_FALSE; - DBG_871X("pwrpriv->bAutoResume (%x) pwrpriv->bInternalAutoSuspend(%x)\n",pwrpriv->bAutoResume,pwrpriv->bInternalAutoSuspend ); - } - - #else //#ifdef CONFIG_BT_COEXIST - pwrpriv->bInternalAutoSuspend = _FALSE; - #endif //#ifdef CONFIG_BT_COEXIST pwrpriv->brfoffbyhw = _FALSE; } #endif//CONFIG_AUTOSUSPEND @@ -956,7 +927,6 @@ void autosuspend_enter(_adapter* padapter) if(rf_off == pwrpriv->change_rfpwrstate ) { -#ifndef CONFIG_BT_COEXIST #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)) usb_enable_autosuspend(dvobj->pusbdev); #else @@ -970,27 +940,6 @@ void autosuspend_enter(_adapter* padapter) #else usb_autosuspend_device(dvobj->pusbdev, 1); #endif -#else //#ifndef CONFIG_BT_COEXIST - if(1==pwrpriv->autopm_cnt){ - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35)) - usb_enable_autosuspend(dvobj->pusbdev); - #else - dvobj->pusbdev->autosuspend_disabled = 0;//autosuspend disabled by the user - #endif - - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,33)) - usb_autopm_put_interface(dvobj->pusbintf); - #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,20)) - usb_autopm_enable(dvobj->pusbintf); - #else - usb_autosuspend_device(dvobj->pusbdev, 1); - #endif - pwrpriv->autopm_cnt --; - } - else - DBG_871X("0!=pwrpriv->autopm_cnt[%d] didn't usb_autopm_put_interface\n", pwrpriv->autopm_cnt); - -#endif //#ifndef CONFIG_BT_COEXIST } #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,32)) DBG_871X("...pm_usage_cnt(%d).....\n", atomic_read(&(dvobj->pusbintf->pm_usage_cnt))); @@ -1014,7 +963,6 @@ int autoresume_enter(_adapter* padapter) if(rf_off == pwrpriv->rf_pwrstate ) { pwrpriv->ps_flag = _FALSE; -#ifndef CONFIG_BT_COEXIST #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,33)) if (usb_autopm_get_interface(dvobj->pusbintf) < 0) { @@ -1033,31 +981,6 @@ int autoresume_enter(_adapter* padapter) #else DBG_871X("...pm_usage_cnt(%d).....\n", dvobj->pusbintf->pm_usage_cnt); #endif -#else //#ifndef CONFIG_BT_COEXIST - pwrpriv->bAutoResume=_TRUE; - if(0==pwrpriv->autopm_cnt){ - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,33)) - if (usb_autopm_get_interface(dvobj->pusbintf) < 0) - { - DBG_871X( "can't get autopm: %d\n", result); - result = _FAIL; - goto error_exit; - } - #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,20)) - usb_autopm_disable(dvobj->pusbintf); - #else - usb_autoresume_device(dvobj->pusbdev, 1); - #endif - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,32)) - DBG_871X("...pm_usage_cnt(%d).....\n", atomic_read(&(dvobj->pusbintf->pm_usage_cnt))); - #else - DBG_871X("...pm_usage_cnt(%d).....\n", dvobj->pusbintf->pm_usage_cnt); - #endif - pwrpriv->autopm_cnt++; - } - else - DBG_871X("0!=pwrpriv->autopm_cnt[%d] didn't usb_autopm_get_interface\n",pwrpriv->autopm_cnt); -#endif //#ifndef CONFIG_BT_COEXIST } DBG_871X("<==== autoresume_enter \n"); error_exit: @@ -1130,10 +1053,6 @@ _adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, //step usb endpoint mapping rtw_hal_chip_configure(padapter); -#ifdef CONFIG_BT_COEXIST - rtw_btcoex_Initialize(padapter); -#endif // CONFIG_BT_COEXIST - //step read efuse/eeprom data and get mac_addr rtw_hal_read_chip_info(padapter); @@ -1190,9 +1109,6 @@ _adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, DBG_871X( "can't get autopm: \n"); } #endif -#ifdef CONFIG_BT_COEXIST - dvobj_to_pwrctl(dvobj)->autopm_cnt=1; -#endif // set mac addr rtw_macaddr_cfg(adapter_mac_addr(padapter), get_hal_mac_addr(padapter)); @@ -1240,19 +1156,6 @@ static void rtw_usb_if1_deinit(_adapter *if1) DBG_871X("+r871xu_dev_remove, hw_init_completed=%d\n", rtw_get_hw_init_completed(if1)); -#ifdef CONFIG_BT_COEXIST - if(1 == pwrctl->autopm_cnt){ - #if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,33)) - usb_autopm_put_interface(adapter_to_dvobj(if1)->pusbintf); - #elif (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,20)) - usb_autopm_enable(adapter_to_dvobj(if1)->pusbintf); - #else - usb_autosuspend_device(adapter_to_dvobj(if1)->pusbdev, 1); - #endif - pwrctl->autopm_cnt --; - } -#endif - rtw_free_drv_sw(if1); /* TODO: use rtw_os_ndevs_deinit instead at the first stage of driver's dev deinit function */ @@ -1415,10 +1318,6 @@ _func_enter_; rtw_drv_if2_stop(dvobj->padapters[IFACE_ID1]); #endif //CONFIG_CONCURRENT_MODE - #ifdef CONFIG_BT_COEXIST - rtw_btcoex_HaltNotify(padapter); - #endif - rtw_usb_if1_deinit(padapter); #ifdef CONFIG_CONCURRENT_MODE @@ -1469,7 +1368,6 @@ static int /*__init*/ rtw_drv_entry(void) usb_drv.drv_registered = _TRUE; rtw_suspend_lock_init(); - rtw_drv_proc_init(); rtw_ndev_notifier_register(); ret = usb_register(&usb_drv.usbdrv); @@ -1477,7 +1375,6 @@ static int /*__init*/ rtw_drv_entry(void) if (ret != 0) { usb_drv.drv_registered = _FALSE; rtw_suspend_lock_uninit(); - rtw_drv_proc_deinit(); rtw_ndev_notifier_unregister(); goto exit; } @@ -1496,7 +1393,6 @@ static void /*__exit*/ rtw_drv_halt(void) usb_deregister(&usb_drv.usbdrv); rtw_suspend_lock_uninit(); - rtw_drv_proc_deinit(); rtw_ndev_notifier_unregister(); DBG_871X_LEVEL(_drv_always_, "module exit success\n"); diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_ops_linux.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_ops_linux.c index a3e1ebbcf..83ba3d5c7 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_ops_linux.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/usb_ops_linux.c @@ -392,9 +392,6 @@ void usb_read_port_cancel(struct intf_hdl *pintfhdl) precvbuf++; } -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE - usb_kill_urb(padapter->recvpriv.int_in_urb); -#endif } static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) @@ -1111,90 +1108,3 @@ _func_exit_; } #endif // CONFIG_USE_USB_BUFFER_ALLOC_RX -#ifdef CONFIG_USB_INTERRUPT_IN_PIPE -void usb_read_interrupt_complete(struct urb *purb, struct pt_regs *regs) -{ - int err; - _adapter *padapter = (_adapter *)purb->context; - - if (RTW_CANNOT_RX(padapter)) { - DBG_8192C("%s() RX Warning! bDriverStopped(%s) OR bSurpriseRemoved(%s)\n" - , __func__ - , rtw_is_drv_stopped(padapter)?"True":"False" - , rtw_is_surprise_removed(padapter)?"True":"False"); - - return; - } - - if (purb->status == 0) {/*SUCCESS*/ - if (purb->actual_length > INTERRUPT_MSG_FORMAT_LEN) - DBG_8192C("usb_read_interrupt_complete: purb->actual_length > INTERRUPT_MSG_FORMAT_LEN(%d)\n", INTERRUPT_MSG_FORMAT_LEN); - - rtw_hal_interrupt_handler(padapter, purb->actual_length, purb->transfer_buffer); - - err = usb_submit_urb(purb, GFP_ATOMIC); - if ((err) && (err != (-EPERM))) - DBG_8192C("cannot submit interrupt in-token(err = 0x%08x),urb_status = %d\n", err, purb->status); - } else { - DBG_8192C("###=> usb_read_interrupt_complete => urb status(%d)\n", purb->status); - - switch (purb->status) { - case -EINVAL: - case -EPIPE: - case -ENODEV: - case -ESHUTDOWN: - /*rtw_set_surprise_removed(padapter);*/ - /*RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=TRUE\n"));*/ - case -ENOENT: - rtw_set_drv_stopped(padapter); - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=TRUE\n")); - break; - case -EPROTO: - break; - case -EINPROGRESS: - DBG_8192C("ERROR: URB IS IN PROGRESS!/n"); - break; - default: - break; - } - } -} - -u32 usb_read_interrupt(struct intf_hdl *pintfhdl, u32 addr) -{ - int err; - unsigned int pipe; - u32 ret = _SUCCESS; - _adapter *adapter = pintfhdl->padapter; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; - -_func_enter_; - - if (RTW_CANNOT_RX(adapter)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_interrupt:( RTW_CANNOT_RX )!!!\n")); - return _FAIL; - } - - /*translate DMA FIFO addr to pipehandle*/ - pipe = ffaddr2pipehdl(pdvobj, addr); - - usb_fill_int_urb(precvpriv->int_in_urb, pusbd, pipe, - precvpriv->int_in_buf, - INTERRUPT_MSG_FORMAT_LEN, - usb_read_interrupt_complete, - adapter, - 1); - - err = usb_submit_urb(precvpriv->int_in_urb, GFP_ATOMIC); - if ((err) && (err != (-EPERM))) { - DBG_8192C("cannot submit interrupt in-token(err = 0x%08x), urb_status = %d\n", err, precvpriv->int_in_urb->status); - ret = _FAIL; - } - -_func_exit_; - return ret; -} -#endif /* CONFIG_USB_INTERRUPT_IN_PIPE */ - diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/wifi_regd.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/wifi_regd.c index f4c179c7d..8f094e182 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/wifi_regd.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/wifi_regd.c @@ -484,12 +484,12 @@ void rtw_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request) #endif } -void rtw_reg_notify_by_driver(struct wiphy *wiphy) +void rtw_reg_notify_by_driver(_adapter *adapter) { - if (wiphy) { + if ((adapter->rtw_wdev != NULL) && (adapter->rtw_wdev->wiphy)) { struct regulatory_request request; request.initiator = NL80211_REGDOM_SET_BY_DRIVER; - rtw_reg_notifier(wiphy, &request); + rtw_reg_notifier(adapter->rtw_wdev->wiphy, &request); } } @@ -529,9 +529,28 @@ static struct country_code_to_enum_rd *_rtw_regd_find_country(u16 countrycode) return NULL; } -void rtw_regd_init(struct wiphy *wiphy) +int rtw_regd_init(_adapter * padapter) { + struct wiphy *wiphy = padapter->rtw_wdev->wiphy; + +#if 0 + if (rtw_regd == NULL) { + rtw_regd = (struct rtw_regulatory *) + rtw_malloc(sizeof(struct rtw_regulatory)); + + rtw_regd->alpha2[0] = '9'; + rtw_regd->alpha2[1] = '9'; + + rtw_regd->country_code = COUNTRY_CODE_USER; + } + + DBG_8192C("%s: Country alpha2 being used: %c%c\n", + __func__, rtw_regd->alpha2[0], rtw_regd->alpha2[1]); +#endif + _rtw_regd_init_wiphy(NULL, wiphy); + + return 0; } #endif //CONFIG_IOCTL_CFG80211 diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/xmit_linux.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/xmit_linux.c index 129269948..086808aff 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/xmit_linux.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/linux/xmit_linux.c @@ -458,11 +458,6 @@ int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev) _func_enter_; - if(padapter->registrypriv.mp_mode) - { - DBG_871X("MP_TX_DROP_OS_FRAME\n"); - goto drop_packet; - } DBG_COUNTER(padapter->tx_logs.os_tx); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); diff --git a/drivers/net/wireless/realtek/rtl8188fu/os_dep/osdep_service.c b/drivers/net/wireless/realtek/rtl8188fu/os_dep/osdep_service.c index 8bdc8611a..543f3795e 100644 --- a/drivers/net/wireless/realtek/rtl8188fu/os_dep/osdep_service.c +++ b/drivers/net/wireless/realtek/rtl8188fu/os_dep/osdep_service.c @@ -32,10 +32,6 @@ atomic_t _malloc_size = ATOMIC_INIT(0); #endif #endif /* DBG_MEMORY_LEAK */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) -#define __vfs_read vfs_read -#endif - #if defined(PLATFORM_LINUX) /* @@ -1867,208 +1863,6 @@ inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) } -#ifdef PLATFORM_LINUX -/* -* Open a file with the specific @param path, @param flag, @param mode -* @param fpp the pointer of struct file pointer to get struct file pointer while file opening is success -* @param path the path of the file to open -* @param flag file operation flags, please refer to linux document -* @param mode please refer to linux document -* @return Linux specific error code -*/ -static int openFile(struct file **fpp, char *path, int flag, int mode) -{ - struct file *fp; - - fp=filp_open(path, flag, mode); - if(IS_ERR(fp)) { - *fpp=NULL; - return PTR_ERR(fp); - } - else { - *fpp=fp; - return 0; - } -} - -/* -* Close the file with the specific @param fp -* @param fp the pointer of struct file to close -* @return always 0 -*/ -static int closeFile(struct file *fp) -{ - filp_close(fp,NULL); - return 0; -} - -static int readFile(struct file *fp,char *buf,int len) -{ - int rlen=0, sum=0; - -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 0)) - if (!(fp->f_mode & FMODE_CAN_READ)) -#else - if (!fp->f_op || !fp->f_op->read) -#endif - return -EPERM; - - while(sum= KERNEL_VERSION(4, 1, 0)) - rlen = __vfs_read(fp, buf+sum, len-sum, &fp->f_pos); -#else - rlen = fp->f_op->read(fp, buf+sum, len-sum, &fp->f_pos); -#endif - if(rlen>0) - sum+=rlen; - else if(0 != rlen) - return rlen; - else - break; - } - - return sum; - -} - -static int writeFile(struct file *fp,char *buf,int len) -{ - int wlen=0, sum=0; - - if (!fp->f_op || !fp->f_op->write) - return -EPERM; - - while(sumf_op->write(fp,buf+sum,len-sum, &fp->f_pos); - if(wlen>0) - sum+=wlen; - else if(0 != wlen) - return wlen; - else - break; - } - - return sum; - -} - -/* -* Test if the specifi @param path is a file and readable -* @param path the path of the file to test -* @return Linux specific error code -*/ -static int isFileReadable(char *path) -{ - struct file *fp; - int ret = 0; -#ifdef set_fs - mm_segment_t oldfs; -#endif - char buf; - - fp=filp_open(path, O_RDONLY, 0); - if(IS_ERR(fp)) { - ret = PTR_ERR(fp); - } - else { -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); -#endif - - if(1!=readFile(fp, &buf, 1)) - ret = PTR_ERR(fp); - -#ifdef set_fs - set_fs(oldfs); -#endif - filp_close(fp,NULL); - } - return ret; -} - -/* -* Open the file with @param path and retrive the file content into memory starting from @param buf for @param sz at most -* @param path the path of the file to open and read -* @param buf the starting address of the buffer to store file content -* @param sz how many bytes to read at most -* @return the byte we've read, or Linux specific error code -*/ -static int retriveFromFile(char *path, u8* buf, u32 sz) -{ - int ret =-1; -#ifdef set_fs - mm_segment_t oldfs; -#endif - struct file *fp; - - if(path && buf) { - if( 0 == (ret=openFile(&fp,path, O_RDONLY, 0)) ){ - DBG_871X("%s openFile path:%s fp=%p\n",__FUNCTION__, path ,fp); - -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); - ret=readFile(fp, buf, sz); - set_fs(oldfs); -#else - ret=readFile(fp, buf, sz); -#endif - closeFile(fp); - - DBG_871X("%s readFile, ret:%d\n",__FUNCTION__, ret); - - } else { - DBG_871X("%s openFile path:%s Fail, ret:%d\n",__FUNCTION__, path, ret); - } - } else { - DBG_871X("%s NULL pointer\n",__FUNCTION__); - ret = -EINVAL; - } - return ret; -} - -/* -* Open the file with @param path and wirte @param sz byte of data starting from @param buf into the file -* @param path the path of the file to open and write -* @param buf the starting address of the data to write into file -* @param sz how many bytes to write at most -* @return the byte we've written, or Linux specific error code -*/ -static int storeToFile(char *path, u8* buf, u32 sz) -{ - int ret =0; -#ifdef set_fs - mm_segment_t oldfs; -#endif - struct file *fp; - - if(path && buf) { - if( 0 == (ret=openFile(&fp, path, O_CREAT|O_WRONLY, 0666)) ) { - DBG_871X("%s openFile path:%s fp=%p\n",__FUNCTION__, path ,fp); - -#ifdef set_fs - oldfs = get_fs(); - set_fs(KERNEL_DS); - ret=writeFile(fp, buf, sz); - set_fs(oldfs); -#else - ret=writeFile(fp, buf, sz); -#endif - closeFile(fp); - - DBG_871X("%s writeFile, ret:%d\n",__FUNCTION__, ret); - - } else { - DBG_871X("%s openFile path:%s Fail, ret:%d\n",__FUNCTION__, path, ret); - } - } else { - DBG_871X("%s NULL pointer\n",__FUNCTION__); - ret = -EINVAL; - } - return ret; -} -#endif //PLATFORM_LINUX /* * Test if the specifi @param path is a file and readable @@ -2216,7 +2010,11 @@ int rtw_change_ifname(_adapter *padapter, const char *ifname) rtw_init_netdev_name(pnetdev, ifname); - _rtw_memcpy(pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) + _rtw_memcpy((void *)pnetdev->dev_addr, adapter_mac_addr(padapter), ETH_ALEN); +#else + dev_addr_set(pnetdev, adapter_mac_addr(padapter)); +#endif #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26)) if(!rtnl_is_locked()) @@ -2343,7 +2141,11 @@ inline u32 rtw_random32(void) { #ifdef PLATFORM_LINUX #if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,8,0)) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0) + return get_random_u32(); +#else return prandom_u32(); +#endif #elif (LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)) u32 random_int; get_random_bytes( &random_int , 4 ); @@ -2539,3 +2341,4 @@ inline char alpha_to_upper(char c) c = 'A' + (c - 'a'); return c; } +