2016-01-06 00:16:53 +08:00
|
|
|
/*
|
|
|
|
* Asus Wireless Radio Control Driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015-2016 Endless Mobile, Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/acpi.h>
|
|
|
|
#include <linux/input.h>
|
|
|
|
#include <linux/pci_ids.h>
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
#include <linux/leds.h>
|
|
|
|
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
struct hswc_params {
|
|
|
|
u8 on;
|
|
|
|
u8 off;
|
|
|
|
u8 status;
|
|
|
|
};
|
2016-01-06 00:16:53 +08:00
|
|
|
|
|
|
|
struct asus_wireless_data {
|
|
|
|
struct input_dev *idev;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
struct acpi_device *adev;
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
const struct hswc_params *hswc_params;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
struct workqueue_struct *wq;
|
|
|
|
struct work_struct led_work;
|
|
|
|
struct led_classdev led;
|
|
|
|
int led_state;
|
2016-01-06 00:16:53 +08:00
|
|
|
};
|
|
|
|
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
static const struct hswc_params atk4001_id_params = {
|
|
|
|
.on = 0x0,
|
|
|
|
.off = 0x1,
|
|
|
|
.status = 0x2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct hswc_params atk4002_id_params = {
|
|
|
|
.on = 0x5,
|
|
|
|
.off = 0x4,
|
|
|
|
.status = 0x2,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct acpi_device_id device_ids[] = {
|
|
|
|
{"ATK4001", (kernel_ulong_t)&atk4001_id_params},
|
|
|
|
{"ATK4002", (kernel_ulong_t)&atk4002_id_params},
|
|
|
|
{"", 0},
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(acpi, device_ids);
|
|
|
|
|
2018-06-30 06:12:46 +08:00
|
|
|
static acpi_status asus_wireless_method(acpi_handle handle, const char *method,
|
|
|
|
int param, u64 *ret)
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
{
|
|
|
|
struct acpi_object_list p;
|
|
|
|
union acpi_object obj;
|
|
|
|
acpi_status s;
|
|
|
|
|
|
|
|
acpi_handle_debug(handle, "Evaluating method %s, parameter %#x\n",
|
|
|
|
method, param);
|
|
|
|
obj.type = ACPI_TYPE_INTEGER;
|
|
|
|
obj.integer.value = param;
|
|
|
|
p.count = 1;
|
|
|
|
p.pointer = &obj;
|
|
|
|
|
2018-06-30 06:12:46 +08:00
|
|
|
s = acpi_evaluate_integer(handle, (acpi_string) method, &p, ret);
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
if (ACPI_FAILURE(s))
|
|
|
|
acpi_handle_err(handle,
|
|
|
|
"Failed to eval method %s, param %#x (%d)\n",
|
|
|
|
method, param, s);
|
2018-06-30 06:12:46 +08:00
|
|
|
else
|
|
|
|
acpi_handle_debug(handle, "%s returned %#llx\n", method, *ret);
|
|
|
|
|
|
|
|
return s;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static enum led_brightness led_state_get(struct led_classdev *led)
|
|
|
|
{
|
|
|
|
struct asus_wireless_data *data;
|
2018-06-30 06:12:46 +08:00
|
|
|
acpi_status s;
|
|
|
|
u64 ret;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
|
|
|
|
data = container_of(led, struct asus_wireless_data, led);
|
|
|
|
s = asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
|
2018-06-30 06:12:46 +08:00
|
|
|
data->hswc_params->status, &ret);
|
|
|
|
if (ACPI_SUCCESS(s) && ret == data->hswc_params->on)
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
return LED_FULL;
|
|
|
|
return LED_OFF;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void led_state_update(struct work_struct *work)
|
|
|
|
{
|
|
|
|
struct asus_wireless_data *data;
|
2018-06-30 06:12:46 +08:00
|
|
|
u64 ret;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
|
|
|
|
data = container_of(work, struct asus_wireless_data, led_work);
|
|
|
|
asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
|
2018-06-30 06:12:46 +08:00
|
|
|
data->led_state, &ret);
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
}
|
|
|
|
|
2017-02-06 23:20:21 +08:00
|
|
|
static void led_state_set(struct led_classdev *led, enum led_brightness value)
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
{
|
|
|
|
struct asus_wireless_data *data;
|
|
|
|
|
|
|
|
data = container_of(led, struct asus_wireless_data, led);
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
data->led_state = value == LED_OFF ? data->hswc_params->off :
|
|
|
|
data->hswc_params->on;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
queue_work(data->wq, &data->led_work);
|
|
|
|
}
|
|
|
|
|
2016-01-06 00:16:53 +08:00
|
|
|
static void asus_wireless_notify(struct acpi_device *adev, u32 event)
|
|
|
|
{
|
|
|
|
struct asus_wireless_data *data = acpi_driver_data(adev);
|
|
|
|
|
|
|
|
dev_dbg(&adev->dev, "event=%#x\n", event);
|
|
|
|
if (event != 0x88) {
|
|
|
|
dev_notice(&adev->dev, "Unknown ASHS event: %#x\n", event);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
input_report_key(data->idev, KEY_RFKILL, 1);
|
2017-12-04 08:26:17 +08:00
|
|
|
input_sync(data->idev);
|
2016-01-06 00:16:53 +08:00
|
|
|
input_report_key(data->idev, KEY_RFKILL, 0);
|
|
|
|
input_sync(data->idev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int asus_wireless_add(struct acpi_device *adev)
|
|
|
|
{
|
|
|
|
struct asus_wireless_data *data;
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
const struct acpi_device_id *id;
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
int err;
|
2016-01-06 00:16:53 +08:00
|
|
|
|
|
|
|
data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
|
|
|
|
if (!data)
|
|
|
|
return -ENOMEM;
|
|
|
|
adev->driver_data = data;
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
data->adev = adev;
|
2016-01-06 00:16:53 +08:00
|
|
|
|
|
|
|
data->idev = devm_input_allocate_device(&adev->dev);
|
|
|
|
if (!data->idev)
|
|
|
|
return -ENOMEM;
|
|
|
|
data->idev->name = "Asus Wireless Radio Control";
|
|
|
|
data->idev->phys = "asus-wireless/input0";
|
|
|
|
data->idev->id.bustype = BUS_HOST;
|
|
|
|
data->idev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
|
|
|
|
set_bit(EV_KEY, data->idev->evbit);
|
|
|
|
set_bit(KEY_RFKILL, data->idev->keybit);
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
err = input_register_device(data->idev);
|
|
|
|
if (err)
|
|
|
|
return err;
|
|
|
|
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
for (id = device_ids; id->id[0]; id++) {
|
|
|
|
if (!strcmp((char *) id->id, acpi_device_hid(adev))) {
|
|
|
|
data->hswc_params =
|
|
|
|
(const struct hswc_params *)id->driver_data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!data->hswc_params)
|
|
|
|
return 0;
|
|
|
|
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
data->wq = create_singlethread_workqueue("asus_wireless_workqueue");
|
|
|
|
if (!data->wq)
|
|
|
|
return -ENOMEM;
|
|
|
|
INIT_WORK(&data->led_work, led_state_update);
|
|
|
|
data->led.name = "asus-wireless::airplane";
|
|
|
|
data->led.brightness_set = led_state_set;
|
|
|
|
data->led.brightness_get = led_state_get;
|
|
|
|
data->led.flags = LED_CORE_SUSPENDRESUME;
|
|
|
|
data->led.max_brightness = 1;
|
2018-06-30 08:11:38 +08:00
|
|
|
data->led.default_trigger = "rfkill-none";
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
err = devm_led_classdev_register(&adev->dev, &data->led);
|
|
|
|
if (err)
|
|
|
|
destroy_workqueue(data->wq);
|
platform/x86: asus-wireless: Use per-HID HSWC parameters
Some Asus machines use 0x4/0x5 as their LED on/off values, while others
use 0x0/0x1, as shown in the DSDT excerpts below. Luckily it seems this
behavior is tied to different HIDs, after looking at 44 DSDTs from
different Asus models.
Another small difference is that a few of them call GWBL instead of
OWGS, and SWBL instead of OWGD. That does not seem to make a difference
for asus-wireless, and is additional reasoning to not try to call these
methods directly.
Device (ASHS) | Device (ASHS)
{ | {
Name (_HID, "ATK4002") | Name (_HID, "ATK4001")
Method (HSWC, 1, Serialized) | Method (HSWC, 1, Serialized)
{ | {
If ((Arg0 < 0x02)) | If ((Arg0 < 0x02))
{ | {
OWGD (Arg0) | OWGD (Arg0)
Return (One) | Return (One)
} | }
If ((Arg0 == 0x02)) |
{ | If ((Arg0 == 0x02))
Local0 = OWGS () | {
If (Local0) | Return (OWGS ())
{ | }
Return (0x05) |
} | If ((Arg0 == 0x03))
Else | {
{ | Return (0xFF)
Return (0x04) | }
} |
} | If ((Arg0 == 0x80))
If ((Arg0 == 0x03)) | {
{ | Return (One)
Return (0xFF) | }
} | }
If ((Arg0 == 0x04)) | Method (_STA, 0, NotSerialized)
{ | {
OWGD (Zero) | If ((MSOS () >= OSW8))
Return (One) | {
} | Return (0x0F)
If ((Arg0 == 0x05)) | }
{ | Else
OWGD (One) | {
Return (One) | Return (Zero)
} | }
If ((Arg0 == 0x80)) | }
{ | }
Return (One) |
} |
} |
Method (_STA, 0, NotSerialized) |
{ |
If ((MSOS () >= OSW8)) |
{ |
Return (0x0F) |
} |
Else |
{ |
Return (Zero) |
} |
} |
} |
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
2017-02-08 05:45:10 +08:00
|
|
|
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
return err;
|
2016-01-06 00:16:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int asus_wireless_remove(struct acpi_device *adev)
|
|
|
|
{
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
struct asus_wireless_data *data = acpi_driver_data(adev);
|
|
|
|
|
2018-04-19 22:04:34 +08:00
|
|
|
if (data->wq) {
|
|
|
|
devm_led_classdev_unregister(&adev->dev, &data->led);
|
asus-wireless: Toggle airplane mode LED
In the ASHS device we have the HSWC method, which calls either OWGD or
OWGS, depending on its parameter:
Device (ASHS)
{
Name (_HID, "ATK4002") // _HID: Hardware ID
Method (HSWC, 1, Serialized)
{
If ((Arg0 < 0x02))
{
OWGD (Arg0)
Return (One)
}
If ((Arg0 == 0x02))
{
Local0 = OWGS ()
If (Local0)
{
Return (0x05)
}
Else
{
Return (0x04)
}
}
If ((Arg0 == 0x03))
{
Return (0xFF)
}
If ((Arg0 == 0x04))
{
OWGD (Zero)
Return (One)
}
If ((Arg0 == 0x05))
{
OWGD (One)
Return (One)
}
If ((Arg0 == 0x80))
{
Return (One)
}
}
Method (_STA, 0, NotSerialized) // _STA: Status
{
If ((MSOS () >= OSW8))
{
Return (0x0F)
}
Else
{
Return (Zero)
}
}
}
On the Asus laptops that do not have an airplane mode LED, OWGD has an
empty implementation and OWGS simply returns 0. On the ones that have an
airplane mode LED these methods have the following implementation:
Method (OWGD, 1, Serialized)
{
SGPL (0x0203000F, Arg0)
SGPL (0x0203000F, Arg0)
}
Method (OWGS, 0, Serialized)
{
Store (RGPL (0x0203000F), Local0)
Return (Local0)
}
Where OWGD(1) sets the airplane mode LED ON, OWGD(0) set it off, and
OWGS() returns its state.
This commit exposes the airplane mode indicator LED to userspace under
the name asus-wireless::airplane, so it can be driven according to
userspace's policy.
Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reviewed-by: Corentin Chary <corentin.chary@gmail.com>
Signed-off-by: Darren Hart <dvhart@linux.intel.com>
2016-06-14 04:57:30 +08:00
|
|
|
destroy_workqueue(data->wq);
|
2018-04-19 22:04:34 +08:00
|
|
|
}
|
2016-01-06 00:16:53 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct acpi_driver asus_wireless_driver = {
|
|
|
|
.name = "Asus Wireless Radio Control Driver",
|
|
|
|
.class = "hotkey",
|
|
|
|
.ids = device_ids,
|
|
|
|
.ops = {
|
|
|
|
.add = asus_wireless_add,
|
|
|
|
.remove = asus_wireless_remove,
|
|
|
|
.notify = asus_wireless_notify,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
module_acpi_driver(asus_wireless_driver);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Asus Wireless Radio Control Driver");
|
|
|
|
MODULE_AUTHOR("João Paulo Rechi Vita <jprvita@gmail.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|