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

Commit ebbe2720 authored by Liangwei Dong's avatar Liangwei Dong Committed by Madan Koyyalamudi
Browse files

qcacld-3.0: notify reg change event once wifi on from GUI

Add regulatory notify event when wifi ON by GUI.
In new framework test, When turning on Wi-Fi, it is
expecting driver to indicate NL80211_CMD_[WIPHY]_ REG_CHANGE
event with country code to wificond.

Change-Id: Icb0bdec097db14905de6234573d05fffbe0e4500
CRs-Fixed: 3186188
parent 9d77af0b
Loading
Loading
Loading
Loading
+39 −4
Original line number Diff line number Diff line
@@ -15490,6 +15490,36 @@ void hdd_init_start_completion(void)
	INIT_COMPLETION(wlan_start_comp);
}

#if defined CFG80211_USER_HINT_CELL_BASE_SELF_MANAGED || \
                    (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0))
static void hdd_inform_wifi_on(void)
{
	int ret;
	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
	struct osif_psoc_sync *psoc_sync;

	hdd_nofl_debug("inform regdomain for wifi on");
	ret = wlan_hdd_validate_context(hdd_ctx);
	if (ret)
		return;
	if (!wlan_hdd_validate_modules_state(hdd_ctx))
		return;
	if (!hdd_ctx->wiphy)
		return;
	ret = osif_psoc_sync_op_start(wiphy_dev(hdd_ctx->wiphy), &psoc_sync);
	if (ret)
		return;
	if (hdd_ctx->wiphy->registered)
		hdd_send_wiphy_regd_sync_event(hdd_ctx);

	osif_psoc_sync_op_stop(psoc_sync);
}
#else
static void hdd_inform_wifi_on(void)
{
}
#endif

static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
						const char __user *user_buf,
						size_t count,
@@ -15501,6 +15531,7 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
	int ret;
	unsigned long rc;
	struct hdd_context *hdd_ctx = cds_get_context(QDF_MODULE_ID_HDD);
	bool turning_on = false;

	if (copy_from_user(buf, user_buf, 3)) {
		pr_err("Failed to read buffer\n");
@@ -15508,13 +15539,15 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
	}

	if (strncmp(buf, wlan_off_str, strlen(wlan_off_str)) == 0) {
		pr_debug("Wifi turning off from UI\n");
		hdd_info("Wifi turning off from UI\n");
		hdd_inform_wifi_off();
		goto exit;
	}

	if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0)
		pr_info("Wifi Turning On from UI\n");
	if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) == 0) {
		hdd_info("Wifi Turning On from UI\n");
		turning_on = true;
	}

	if (strncmp(buf, wlan_on_str, strlen(wlan_on_str)) != 0) {
		pr_err("Invalid value received from framework");
@@ -15537,8 +15570,10 @@ static ssize_t wlan_hdd_state_ctrl_param_write(struct file *filp,
	 */
	if (hdd_ctx)
		hdd_psoc_idle_timer_stop(hdd_ctx);

exit:
	if (turning_on)
		hdd_inform_wifi_on();

	return count;
}