Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1982ed4d authored by Dundi Raviteja's avatar Dundi Raviteja
Browse files

wlan: Add support to send BT advertisement via bt_profile

Add support to send BT advertisement via bt_profile.

Usaage:
Enable BT advertisement:
echo BT_ENABLED 1 BT_ADV 1 BLE 0 A2DP 0 SCO 0 >
	/sys/devices/platform/soc/a000000.qcom,wcnss-wlan/bt_profile

Disable BT advertisement:
echo BT_ENABLED 1 BT_ADV 0 BLE 0 A2DP 0 SCO 0 >
	/sys/devices/platform/soc/a000000.qcom,wcnss-wlan/bt_profile

Change-Id: I234a71cc251b2c0f103aea492ab3b3b223779ff6
CRs-Fixed: 2813885
parent c04b4e72
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -2439,13 +2439,18 @@ void hdd_fill_last_rx(hdd_adapter_t *adapter);
/**
 * hdd_process_bt_sco_profile - process BT SCO profile
 * @hdd_ctx: pointer to HDD context
 * @bt_enabled: status of BT
 * @bt_sco: status of SCO
 * @bt_enabled: BT status
 * @bt_adv: BT advertisement status
 * @ble_enabled: BLE status
 * @bt_a2dp: BT A2DP status
 * @bt_sco: BT SCO status
 *
 * Return: 0 on success, error on failure
 */
int hdd_process_bt_sco_profile(hdd_context_t *hdd_ctx,
			       bool bt_enabled, bool bt_sco);
			       bool bt_enabled, bool bt_adv,
			       bool ble_enabled, bool bt_a2dp,
			       bool bt_sco);

/**
 * hdd_is_sw_pta_enabled - is sw pta enabled
+22 −68
Original line number Diff line number Diff line
@@ -3893,7 +3893,7 @@ int hdd_get_disable_ch_list(hdd_context_t *hdd_ctx, tANI_U8 *buf,
}
#ifdef FEATURE_WLAN_SW_PTA
static void hdd_sco_resp_callback(uint8_t sco_status)
static void hdd_sw_pta_resp_callback(uint8_t sw_pta_status)
{
	hdd_context_t *hdd_ctx = NULL;
	v_CONTEXT_t vos_ctx = NULL;
@@ -3913,12 +3913,12 @@ static void hdd_sco_resp_callback(uint8_t sco_status)
		return;
	}
	hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: Response status %d",
	       __func__, sco_status);
	hddLog(VOS_TRACE_LEVEL_DEBUG, "%s: sw pta response status %d",
	       __func__, sw_pta_status);
	if (sco_status) {
		hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid sco status %d",
		       __func__, sco_status);
	if (sw_pta_status) {
		hddLog(VOS_TRACE_LEVEL_FATAL, "%s: Invalid sw pta status %d",
		       __func__, sw_pta_status);
		return;
	}
@@ -3926,15 +3926,15 @@ static void hdd_sco_resp_callback(uint8_t sco_status)
}
int hdd_process_bt_sco_profile(hdd_context_t *hdd_ctx,
			       bool bt_enabled, bool bt_sco)
			       bool bt_enabled, bool bt_adv,
			       bool ble_enabled, bool bt_a2dp,
			       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;
	eHalStatus hal_status;
	bool sco_status;
	int rc;
	if (!mac_ctx) {
@@ -3942,30 +3942,11 @@ int hdd_process_bt_sco_profile(hdd_context_t *hdd_ctx,
		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);
	hal_status = sme_sw_pta_req(hdd_ctx->hHal, hdd_sw_pta_resp_callback,
				    adapter->sessionId, bt_enabled,
				    bt_adv, ble_enabled, bt_a2dp, bt_sco);
	if (!HAL_STATUS_SUCCESS(hal_status)) {
		hddLog(VOS_TRACE_LEVEL_ERROR,
		       "%s: Error sending sme sco indication request",
@@ -3981,45 +3962,18 @@ int hdd_process_bt_sco_profile(hdd_context_t *hdd_ctx,
		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,
			       "%s: BT SCO is already enabled", __func__);
			return 0;
		}
		sco_status = true;
	} else {
		if (!hdd_ctx->is_sco_enabled) {
			hddLog(VOS_TRACE_LEVEL_ERROR,
			       "%s: BT SCO is already disabled", __func__);
			return 0;
		}
		sco_status = false;
	}
	hal_status = sme_sco_req(hdd_ctx->hHal,
				 hdd_sco_resp_callback,
				 adapter->sessionId, sco_status);
	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;
	}
	if (!bt_sco) {
		hdd_ctx->is_sco_enabled = false;
		mac_ctx->isCoexScoIndSet = 0;
		return 0;
+10 −6
Original line number Diff line number Diff line
@@ -6518,14 +6518,18 @@ enum sir_sw_pta_param_type {
#define SW_PTA_COEX_PARAMS_MAX_LEN 32
/**
 * struct sir_sw_pta_req - sw pta coex params request
 * @param_type: sw pta coex param type
 * @length: sw pta coex params value length
 * @value: sw pta coex params value
 * @bt_enabled: BT status
 * @bt_adv: BT advertisement status
 * @ble_enabled: BLE status
 * @bt_a2dp: BT A2DP status
 * @bt_sco: BT SCO status
 */
struct sir_sw_pta_req {
	enum sir_sw_pta_param_type param_type;
	uint8_t length;
	uint8_t value[SW_PTA_COEX_PARAMS_MAX_LEN];
	bool bt_enabled;
	bool bt_adv;
	bool ble_enabled;
	bool bt_a2dp;
	bool bt_sco;
};
#endif
#endif /* __SIR_API_H */
+7 −31
Original line number Diff line number Diff line
@@ -4195,41 +4195,17 @@ eHalStatus sme_update_olpc_mode(tHalHandle hHal, bool enable);
 * @hal: The handle returned by mac_open
 * @resp_callback: callback to indicate sw pta response to hdd
 * @session_id: session id
 * @type: sw pta coex param type
 * @length: length of sw pta coex param value
 * @value: sw pta coex params value
 * @bt_enabled: BT status
 * @bt_adv: BT advertisement status
 * @ble_enabled: BLE status
 * @bt_a2dp: BT A2DP status
 * @bt_sco: BT SCO status
 *
 * Return: HAL_STATUS
 */
eHalStatus sme_sw_pta_req(tHalHandle hal,
			  void (*resp_callback)(uint8_t resp_status),
			  uint8_t session_id, enum sir_sw_pta_param_type type,
			  uint8_t length, uint8_t *value);

/**
 * sme_sco_req() - Send sco request 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_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);
			  uint8_t session_id, bool bt_enabled, bool bt_adv,
			  bool ble_enabled, bool bt_a2dp, bool bt_sco);
#endif /* FEATURE_WLAN_SW_PTA */
#endif //#if !defined( __SME_API_H )
+7 −26
Original line number Diff line number Diff line
@@ -15679,19 +15679,14 @@ eHalStatus sme_update_olpc_mode(tHalHandle hHal, bool enable)
#ifdef FEATURE_WLAN_SW_PTA
eHalStatus sme_sw_pta_req(tHalHandle hal,
			  void (*resp_callback)(uint8_t resp_status),
			  uint8_t session_id, enum sir_sw_pta_param_type type,
			  uint8_t length, uint8_t *value)
			  uint8_t session_id, bool bt_enabled, bool bt_adv,
			  bool ble_enabled, bool bt_a2dp, bool bt_sco)
{
	tpAniSirGlobal mac = PMAC_STRUCT(hal);
	struct sir_sw_pta_req *sw_pta_req;
	eHalStatus status;
	tSmeCmd *sme_cmd;
	if (length > SW_PTA_COEX_PARAMS_MAX_LEN) {
		smsLog(mac, LOGE, FL("Invalid length"));
		return eHAL_STATUS_FAILURE;
	}
	sme_cmd = csrGetCommandBuffer(mac);
	if (!sme_cmd) {
		smsLog(mac, LOGE, FL("Failed to get buffer for sw pta req"));
@@ -15705,9 +15700,11 @@ eHalStatus sme_sw_pta_req(tHalHandle hal,
		return eHAL_STATUS_RESOURCES;
	}
	sw_pta_req->param_type = type;
	sw_pta_req->length = length;
	memcpy(sw_pta_req->value, value, length);
	sw_pta_req->bt_enabled = bt_enabled;
	sw_pta_req->bt_adv = bt_adv;
	sw_pta_req->ble_enabled = ble_enabled;
	sw_pta_req->bt_a2dp = bt_a2dp;
	sw_pta_req->bt_sco = bt_sco;
	status = sme_AcquireGlobalLock(&mac->sme);
	if (HAL_STATUS_SUCCESS(status)) {
@@ -15737,20 +15734,4 @@ eHalStatus sme_sw_pta_req(tHalHandle hal,
	sme_ReleaseGlobalLock(&mac->sme);
	return eHAL_STATUS_SUCCESS;
}
eHalStatus sme_sco_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,
			      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 */
Loading