wlan: Update BT enable/disable status to firmware
Update BT enable/disable status coming from
wcnss to firmware.
Usage:
Enable BT:
$ echo BT_ENABLED 1 BLE 0 A2DP 0 SCO 0 >
/sys/devices/platform/soc/a000000.qcom,wcnss-wlan/bt_profile
Disable BT:
$ echo BT_ENABLED 0 BLE 0 A2DP 0 SCO 0 >
/sys/devices/platform/soc/a000000.qcom,wcnss-wlan/bt_profile
Change-Id: I57df353427cb33bef9ebe904db071692294e4c86
CRs-Fixed: 2807024
diff --git a/CORE/HDD/inc/wlan_hdd_main.h b/CORE/HDD/inc/wlan_hdd_main.h
index c4c33ae..3512714 100644
--- a/CORE/HDD/inc/wlan_hdd_main.h
+++ b/CORE/HDD/inc/wlan_hdd_main.h
@@ -1796,6 +1796,7 @@
v_BOOL_t btCoexModeSet;
v_BOOL_t isPnoEnable;
bool is_sco_enabled;
+ bool is_bt_enabled;
macAddrSpoof_t spoofMacAddr;
/* flag to decide if driver need to scan DFS channels or not */
v_BOOL_t disable_dfs_flag;
diff --git a/CORE/HDD/src/wlan_hdd_main.c b/CORE/HDD/src/wlan_hdd_main.c
index 9c44e86..ffa18d0 100644
--- a/CORE/HDD/src/wlan_hdd_main.c
+++ b/CORE/HDD/src/wlan_hdd_main.c
@@ -3929,6 +3929,7 @@
bool bt_enabled, bool bt_sco)
{
tpAniSirGlobal mac_ctx = PMAC_STRUCT(hdd_ctx->hHal);
+ uint8_t no_of_states_changed = 0;
hdd_station_ctx_t *hdd_sta_ctx;
eConnectionState conn_state;
hdd_adapter_t *adapter;
@@ -3941,6 +3942,49 @@
return -EINVAL;
}
+ /**
+ * At a time only one status can be changed compared to
+ * previous command (BT_ENABLED/SCO)
+ * If no.of states changed is greater than one it is
+ * an invalid command.
+ */
+ if (bt_enabled != hdd_ctx->is_bt_enabled)
+ no_of_states_changed++;
+
+ if (bt_sco != hdd_ctx->is_sco_enabled)
+ no_of_states_changed++;
+
+ if (no_of_states_changed > 1) {
+ hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Multiple states changed",
+ __func__);
+ return -EINVAL;
+ }
+
+ INIT_COMPLETION(hdd_ctx->sw_pta_comp);
+
+ if (bt_enabled != hdd_ctx->is_bt_enabled) {
+ hal_status = sme_bt_req(hdd_ctx->hHal,
+ hdd_sco_resp_callback,
+ adapter->sessionId, bt_enabled);
+ if (!HAL_STATUS_SUCCESS(hal_status)) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ "%s: Error sending sme sco indication request",
+ __func__);
+ return -EINVAL;
+ }
+
+ rc = wait_for_completion_timeout(&hdd_ctx->sw_pta_comp,
+ msecs_to_jiffies(WLAN_WAIT_TIME_SW_PTA));
+ if (!rc) {
+ hddLog(VOS_TRACE_LEVEL_ERROR,
+ FL("Target response timed out for sw_pta_comp"));
+ return -EINVAL;
+ }
+
+ hdd_ctx->is_bt_enabled = bt_enabled;
+ return 0;
+ }
+
if (bt_sco) {
if (hdd_ctx->is_sco_enabled) {
hddLog(VOS_TRACE_LEVEL_ERROR,
@@ -3957,8 +4001,6 @@
sco_status = false;
}
- INIT_COMPLETION(hdd_ctx->sw_pta_comp);
-
hal_status = sme_sco_req(hdd_ctx->hHal,
hdd_sco_resp_callback,
adapter->sessionId, sco_status);
diff --git a/CORE/SME/inc/sme_Api.h b/CORE/SME/inc/sme_Api.h
index 9c5d509..d695c9b 100644
--- a/CORE/SME/inc/sme_Api.h
+++ b/CORE/SME/inc/sme_Api.h
@@ -4218,5 +4218,18 @@
eHalStatus sme_sco_req(tHalHandle hal,
void (*resp_callback)(uint8_t resp_status),
uint8_t session_id, uint8_t req_status);
+
+/**
+ * sme_bt_req() - Send bt status to sme
+ * @hal: The handle returned by mac_open
+ * @resp_callback: callback to indicate sco response to hdd
+ * @session_id: session id
+ * @req_status: sco request status
+ *
+ * Return: HAL_STATUS
+ */
+eHalStatus sme_bt_req(tHalHandle hal,
+ void (*resp_callback)(uint8_t resp_status),
+ uint8_t session_id, uint8_t req_status);
#endif /* FEATURE_WLAN_SW_PTA */
#endif //#if !defined( __SME_API_H )
diff --git a/CORE/SME/src/sme_common/sme_Api.c b/CORE/SME/src/sme_common/sme_Api.c
index 3382ed1..3b538c9 100644
--- a/CORE/SME/src/sme_common/sme_Api.c
+++ b/CORE/SME/src/sme_common/sme_Api.c
@@ -15745,4 +15745,12 @@
return sme_sw_pta_req(hal, resp_callback, session_id,
SCO_STATUS, sizeof(req_status), &req_status);
}
+
+eHalStatus sme_bt_req(tHalHandle hal,
+ void (*resp_callback)(uint8_t resp_status),
+ uint8_t session_id, uint8_t req_status)
+{
+ return sme_sw_pta_req(hal, resp_callback, session_id,
+ BT_STATUS, sizeof(req_status), &req_status);
+}
#endif /* FEATURE_WLAN_SW_PTA */