rtlwifi: btcoex: 21a 2ant: check if wifi status changed
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Thu, 13 Apr 2017 18:07:02 +0000 (13:07 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 20 Apr 2017 07:24:06 +0000 (10:24 +0300)
Monitor wifi status and check if it is changed.

Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Pkshih <pkshih@realtek.com>
Cc: Birming Chiu <birming@realtek.com>
Cc: Shaofu <shaofu@realtek.com>
Cc: Steven Ting <steventing@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.c
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a2ant.h

index 4d69955fbebc6d4b908032d497165388841c6327..4030b6429c1d6c7192c6bbcf0823372179126f14 100644 (file)
@@ -359,6 +359,47 @@ static void btc8821a2ant_query_bt_info(struct btc_coexist *btcoexist)
        btcoexist->btc_fill_h2c(btcoexist, 0x61, 1, h2c_parameter);
 }
 
+bool btc8821a2ant_is_wifi_status_changed(struct btc_coexist *btcoexist)
+{
+       static bool pre_wifi_busy = true;
+       static bool pre_under_4way = true;
+       static bool pre_bt_hs_on = true;
+       bool wifi_busy = false, under_4way = false, bt_hs_on = false;
+       bool wifi_connected = false;
+       u8 wifi_rssi_state = BTC_RSSI_STATE_HIGH;
+
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
+                          &wifi_connected);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_HS_OPERATION, &bt_hs_on);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_4_WAY_PROGRESS,
+                          &under_4way);
+
+       if (wifi_connected) {
+               if (wifi_busy != pre_wifi_busy) {
+                       pre_wifi_busy = wifi_busy;
+                       return true;
+               }
+               if (under_4way != pre_under_4way) {
+                       pre_under_4way = under_4way;
+                       return true;
+               }
+               if (bt_hs_on != pre_bt_hs_on) {
+                       pre_bt_hs_on = bt_hs_on;
+                       return true;
+               }
+
+               wifi_rssi_state = btc8821a2ant_wifi_rssi_state(btcoexist, 3, 2,
+                               BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES, 0);
+
+               if ((wifi_rssi_state == BTC_RSSI_STATE_HIGH) ||
+                   (wifi_rssi_state == BTC_RSSI_STATE_LOW))
+                       return true;
+       }
+
+       return false;
+}
+
 static void btc8821a2ant_update_bt_link_info(struct btc_coexist *btcoexist)
 {
        struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
index 6db96cf4403421db5ef47e7358da640fd1476e45..603e446b59539f6dff71d267fa10de051a15c547 100644 (file)
 
 #define        BTC_RSSI_COEX_THRESH_TOL_8821A_2ANT     2
 
+/* WiFi RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */
+#define BT_8821A_2ANT_WIFI_RSSI_COEXSWITCH_THRES 42
+/* BT RSSI Threshold for 2-Ant TDMA/1-Ant PS-TDMA translation */
+#define BT_8821A_2ANT_BT_RSSI_COEXSWITCH_THRES 46
+
 enum _BT_INFO_SRC_8821A_2ANT {
        BT_INFO_SRC_8821A_2ANT_WIFI_FW          = 0x0,
        BT_INFO_SRC_8821A_2ANT_BT_RSP           = 0x1,