Skip to content

Commit a50bd12

Browse files
acelanMatthew Garrett
authored andcommitted
asus-wmi: record wlan status while controlled by userapp
If the user bit is set, that mean BIOS can't set and record the wlan status, it will report the value read from id ASUS_WMI_DEVID_WLAN_LED (0x00010012) while we query the wlan status by id ASUS_WMI_DEVID_WLAN (0x00010011) through WMI. So, we have to record wlan status in id ASUS_WMI_DEVID_WLAN_LED (0x00010012) while setting the wlan status through WMI. This is also the behavior that windows app will do. Quote from ASUS application engineer === When you call WMIMethod(DSTS, 0x00010011) to get WLAN status, it may return (1) 0x00050001 (On) (2) 0x00050000 (Off) (3) 0x00030001 (On) (4) 0x00030000 (Off) (5) 0x00000002 (Unknown) (1), (2) means that the model has hardware GPIO for WLAN, you can call WMIMethod(DEVS, 0x00010011, 1 or 0) to turn WLAN on/off. (3), (4) means that the model doesn’t have hardware GPIO, you need to use API or driver library to turn WLAN on/off, and call WMIMethod(DEVS, 0x00010012, 1 or 0) to set WLAN LED status. After you set WLAN LED status, you can see the WLAN status is changed with WMIMethod(DSTS, 0x00010011). Because the status is recorded lastly (ex: Windows), you can use it for synchronization. (5) means that the model doesn’t have WLAN device. WLAN is the ONLY special case with upper rule. For other device, like Bluetooth, you just need use WMIMethod(DSTS, 0x00010013) to get, and WMIMethod(DEVS, 0x00010013, 1 or 0) to set. === Signed-off-by: AceLan Kao <[email protected]> Signed-off-by: Matthew Garrett <[email protected]>
1 parent 9f6f955 commit a50bd12

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

drivers/platform/x86/asus-wmi.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ MODULE_LICENSE("GPL");
101101
#define ASUS_WMI_DEVID_WIRELESS_LED 0x00010002
102102
#define ASUS_WMI_DEVID_CWAP 0x00010003
103103
#define ASUS_WMI_DEVID_WLAN 0x00010011
104+
#define ASUS_WMI_DEVID_WLAN_LED 0x00010012
104105
#define ASUS_WMI_DEVID_BLUETOOTH 0x00010013
105106
#define ASUS_WMI_DEVID_GPS 0x00010015
106107
#define ASUS_WMI_DEVID_WIMAX 0x00010017
@@ -731,8 +732,21 @@ static int asus_rfkill_set(void *data, bool blocked)
731732
{
732733
struct asus_rfkill *priv = data;
733734
u32 ctrl_param = !blocked;
735+
u32 dev_id = priv->dev_id;
734736

735-
return asus_wmi_set_devstate(priv->dev_id, ctrl_param, NULL);
737+
/*
738+
* If the user bit is set, BIOS can't set and record the wlan status,
739+
* it will report the value read from id ASUS_WMI_DEVID_WLAN_LED
740+
* while we query the wlan status through WMI(ASUS_WMI_DEVID_WLAN).
741+
* So, we have to record wlan status in id ASUS_WMI_DEVID_WLAN_LED
742+
* while setting the wlan status through WMI.
743+
* This is also the behavior that windows app will do.
744+
*/
745+
if ((dev_id == ASUS_WMI_DEVID_WLAN) &&
746+
priv->asus->driver->wlan_ctrl_by_user)
747+
dev_id = ASUS_WMI_DEVID_WLAN_LED;
748+
749+
return asus_wmi_set_devstate(dev_id, ctrl_param, NULL);
736750
}
737751

738752
static void asus_rfkill_query(struct rfkill *rfkill, void *data)
@@ -1653,6 +1667,7 @@ static int asus_wmi_add(struct platform_device *pdev)
16531667
struct asus_wmi *asus;
16541668
acpi_status status;
16551669
int err;
1670+
u32 result;
16561671

16571672
asus = kzalloc(sizeof(struct asus_wmi), GFP_KERNEL);
16581673
if (!asus)
@@ -1711,6 +1726,10 @@ static int asus_wmi_add(struct platform_device *pdev)
17111726
if (err)
17121727
goto fail_debugfs;
17131728

1729+
asus_wmi_get_devstate(asus, ASUS_WMI_DEVID_WLAN, &result);
1730+
if (result & (ASUS_WMI_DSTS_PRESENCE_BIT | ASUS_WMI_DSTS_USER_BIT))
1731+
asus->driver->wlan_ctrl_by_user = 1;
1732+
17141733
return 0;
17151734

17161735
fail_debugfs:

drivers/platform/x86/asus-wmi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct quirk_entry {
4646
struct asus_wmi_driver {
4747
int brightness;
4848
int panel_power;
49+
int wlan_ctrl_by_user;
4950

5051
const char *name;
5152
struct module *owner;

0 commit comments

Comments
 (0)