]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
rtlwifi: btcoex: 21a 1ant: consider more cases when bt inquiry
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Mon, 10 Apr 2017 16:23:07 +0000 (11:23 -0500)
committerKalle Valo <kvalo@codeaurora.org>
Thu, 13 Apr 2017 14:11:02 +0000 (17:11 +0300)
With bt inquiry, the wifi may start as a softap or the wifi and bt are
busy, we take these scenarios into consider to avoid bt inquiry to
degrade the performance of the network

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/halbtc8821a1ant.c
drivers/net/wireless/realtek/rtlwifi/btcoexist/halbtc8821a1ant.h

index c6114b32c0ca06e8c03a65c753dc88a76b4081c4..6b08051614eb595cef9eb2bfc7f533faf5fe338d 100644 (file)
@@ -1139,8 +1139,8 @@ static void btc8821a1ant_ps_tdma(struct btc_coexist *btcoexist,
                                                    0x18, 0x0, 0x10);
                        break;
                case 14:
-                       btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x21,
-                                                   0x3, 0x10, 0x10);
+                       btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x51, 0x1e,
+                                                   0x3, 0x10, 0x14);
                        break;
                case 15:
                        btc8821a1ant_set_fw_ps_tdma(btcoexist, 0x13, 0xa,
@@ -1519,27 +1519,46 @@ static void btc8821a1ant_action_bt_inquiry(struct btc_coexist *btcoexist)
 {
        struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
        bool wifi_connected = false;
+       bool ap_enable = false;
+       bool wifi_busy = false, bt_busy = false;
 
-       btcoexist->btc_get(btcoexist,
-                BTC_GET_BL_WIFI_CONNECTED, &wifi_connected);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_CONNECTED,
+                          &wifi_connected);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_AP_MODE_ENABLE,
+                          &ap_enable);
+       btcoexist->btc_get(btcoexist, BTC_GET_BL_WIFI_BUSY, &wifi_busy);
+       btcoexist->btc_set(btcoexist, BTC_SET_BL_BT_TRAFFIC_BUSY, &bt_busy);
 
-       if (!wifi_connected) {
+       if (!wifi_connected && !coex_sta->wifi_is_high_pri_task) {
                btc8821a1ant_power_save_state(btcoexist,
                                              BTC_PS_WIFI_NATIVE, 0x0, 0x0);
-               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 5);
-               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
-       } else if ((bt_link_info->sco_exist) ||
+               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 0);
+       } else if ((bt_link_info->sco_exist) || (bt_link_info->a2dp_exist) ||
                   (bt_link_info->hid_only)) {
                /* SCO/HID-only busy */
                btc8821a1ant_power_save_state(btcoexist,
                                              BTC_PS_WIFI_NATIVE, 0x0, 0x0);
                btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 32);
+               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
+       } else if ((bt_link_info->a2dp_exist) && (bt_link_info->hid_exist)) {
+               /* A2DP+HID busy */
+               btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+                                             0x0, 0x0);
+               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+
                btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+       } else if ((bt_link_info->pan_exist) || (wifi_busy)) {
+               btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+                                             0x0, 0x0);
+               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+
+               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 4);
        } else {
-               btc8821a1ant_power_save_state(btcoexist, BTC_PS_LPS_ON,
-                                             0x50, 0x4);
-               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 30);
-               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+               btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE,
+                                             0x0, 0x0);
+               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 7);
        }
 }
 
@@ -1629,11 +1648,35 @@ void btc8821a1ant_action_wifi_not_connected(struct btc_coexist *btcoexist)
 
 static void btc8821a1ant_act_wifi_not_conn_scan(struct btc_coexist *btcoexist)
 {
-       btc8821a1ant_power_save_state(btcoexist,
-                                     BTC_PS_WIFI_NATIVE, 0x0, 0x0);
+       struct btc_bt_link_info *bt_link_info = &btcoexist->bt_link_info;
+
+       btc8821a1ant_power_save_state(btcoexist, BTC_PS_WIFI_NATIVE, 0x0, 0x0);
 
-       btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
-       btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 1);
+       /* tdma and coex table */
+       if (coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_ACL_BUSY) {
+               if (bt_link_info->a2dp_exist) {
+                       btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 14);
+                       btc8821a1ant_coex_table_with_type(btcoexist,
+                                                         NORMAL_EXEC, 1);
+               } else if (bt_link_info->a2dp_exist &&
+                          bt_link_info->pan_exist) {
+                       btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 22);
+                       btc8821a1ant_coex_table_with_type(btcoexist,
+                                                         NORMAL_EXEC, 4);
+               } else {
+                       btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, true, 20);
+                       btc8821a1ant_coex_table_with_type(btcoexist,
+                                                         NORMAL_EXEC, 4);
+               }
+       } else if ((coex_dm->bt_status == BT_8821A_1ANT_BT_STATUS_SCO_BUSY) ||
+                  (BT_8821A_1ANT_BT_STATUS_ACL_SCO_BUSY ==
+                   coex_dm->bt_status)) {
+               btc8821a1ant_act_bt_sco_hid_only_busy(btcoexist,
+                               BT_8821A_1ANT_WIFI_STATUS_CONNECTED_SCAN);
+       } else {
+               btc8821a1ant_ps_tdma(btcoexist, NORMAL_EXEC, false, 8);
+               btc8821a1ant_coex_table_with_type(btcoexist, NORMAL_EXEC, 2);
+       }
 }
 
 static
index 2dec38ab774672d39d7eb3434220701c8094a8c4..1bd1ebe3364ebe3e0ac44e17cce0507a9aba566e 100644 (file)
@@ -161,6 +161,7 @@ struct coex_sta_8821a_1ant {
        u8      bt_info_c2h[BT_INFO_SRC_8821A_1ANT_MAX][10];
        u32     bt_info_c2h_cnt[BT_INFO_SRC_8821A_1ANT_MAX];
        bool    c2h_bt_inquiry_page;
+       bool    wifi_is_high_pri_task;
        u8      bt_retry_cnt;
        u8      bt_info_ext;
 };