linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/7] asus-wireless: LED control
@ 2016-06-13 20:57 João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 1/7] asus-wireless: Toggle airplane mode LED João Paulo Rechi Vita
                   ` (7 more replies)
  0 siblings, 8 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

This series adds support for controlling the airplane-mode indicator LED
present in some Asus laptops. It also creates a quirk in asus-wmi so it does not
create RFKill devices for platforms that use asus-wireless and where there is a
competition for the LED control (see "asus-wmi: Create quirk for airplane_mode
LED" for more details).

João Paulo Rechi Vita (7):
  asus-wireless: Toggle airplane mode LED
  asus-wmi: Create quirk for airplane_mode LED
  asus-wmi: Add quirk_no_rfkill for the Asus N552VW
  asus-wmi: Add quirk_no_rfkill for the Asus U303LB
  asus-wmi: Add quirk_no_rfkill for the Asus Z550MA
  asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF
  asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA

 drivers/platform/x86/Kconfig         |  2 +
 drivers/platform/x86/asus-nb-wmi.c   | 49 ++++++++++++++++++-
 drivers/platform/x86/asus-wireless.c | 91 +++++++++++++++++++++++++++++++++++-
 drivers/platform/x86/asus-wmi.c      |  8 ++--
 drivers/platform/x86/asus-wmi.h      |  1 +
 5 files changed, 145 insertions(+), 6 deletions(-)

-- 
2.5.0

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/7] asus-wireless: Toggle airplane mode LED
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED João Paulo Rechi Vita
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

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 does 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>
---
 drivers/platform/x86/Kconfig         |  2 +
 drivers/platform/x86/asus-wireless.c | 91 +++++++++++++++++++++++++++++++++++-
 2 files changed, 92 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index c06bb85..e9d0144 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -604,6 +604,8 @@ config ASUS_WIRELESS
 	tristate "Asus Wireless Radio Control Driver"
 	depends on ACPI
 	depends on INPUT
+	select NEW_LEDS
+	select LEDS_CLASS
 	---help---
 	  The Asus Wireless Radio Control handles the airplane mode hotkey
 	  present on some Asus laptops.
diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c
index 9ec721e..d617dfd 100644
--- a/drivers/platform/x86/asus-wireless.c
+++ b/drivers/platform/x86/asus-wireless.c
@@ -15,11 +15,78 @@
 #include <linux/acpi.h>
 #include <linux/input.h>
 #include <linux/pci_ids.h>
+#include <linux/leds.h>
+
+#define ASUS_WIRELESS_LED_STATUS 0x2
+#define ASUS_WIRELESS_LED_OFF 0x4
+#define ASUS_WIRELESS_LED_ON 0x5
 
 struct asus_wireless_data {
 	struct input_dev *idev;
+	struct acpi_device *adev;
+	struct workqueue_struct *wq;
+	struct work_struct led_work;
+	struct led_classdev led;
+	int led_state;
 };
 
+static u64 asus_wireless_method(acpi_handle handle, const char *method,
+				int param)
+{
+	union acpi_object obj;
+	struct acpi_object_list p;
+	acpi_status s;
+	u64 ret;
+
+	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;
+
+	s = acpi_evaluate_integer(handle, (acpi_string) method, &p, &ret);
+	if (ACPI_FAILURE(s))
+		acpi_handle_err(handle,
+				"Failed to eval method %s, param %#x (%d)\n",
+				method, param, s);
+	acpi_handle_debug(handle, "%s returned %#x\n", method, (uint) ret);
+	return ret;
+}
+
+static enum led_brightness led_state_get(struct led_classdev *led)
+{
+	struct asus_wireless_data *data;
+	int s;
+
+	data = container_of(led, struct asus_wireless_data, led);
+	s = asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
+				 ASUS_WIRELESS_LED_STATUS);
+	if (s == ASUS_WIRELESS_LED_ON)
+		return LED_FULL;
+	return LED_OFF;
+}
+
+static void led_state_update(struct work_struct *work)
+{
+	struct asus_wireless_data *data;
+
+	data = container_of(work, struct asus_wireless_data, led_work);
+	asus_wireless_method(acpi_device_handle(data->adev), "HSWC",
+			     data->led_state);
+}
+
+static void led_state_set(struct led_classdev *led,
+				  enum led_brightness value)
+{
+	struct asus_wireless_data *data;
+
+	data = container_of(led, struct asus_wireless_data, led);
+	data->led_state = value == LED_OFF ? ASUS_WIRELESS_LED_OFF :
+					     ASUS_WIRELESS_LED_ON;
+	queue_work(data->wq, &data->led_work);
+}
+
 static void asus_wireless_notify(struct acpi_device *adev, u32 event)
 {
 	struct asus_wireless_data *data = acpi_driver_data(adev);
@@ -37,6 +104,7 @@ static void asus_wireless_notify(struct acpi_device *adev, u32 event)
 static int asus_wireless_add(struct acpi_device *adev)
 {
 	struct asus_wireless_data *data;
+	int err;
 
 	data = devm_kzalloc(&adev->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
@@ -52,11 +120,32 @@ static int asus_wireless_add(struct acpi_device *adev)
 	data->idev->id.vendor = PCI_VENDOR_ID_ASUSTEK;
 	set_bit(EV_KEY, data->idev->evbit);
 	set_bit(KEY_RFKILL, data->idev->keybit);
-	return input_register_device(data->idev);
+	err = input_register_device(data->idev);
+	if (err)
+		return err;
+
+	data->adev = adev;
+	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;
+	err = devm_led_classdev_register(&adev->dev, &data->led);
+	if (err)
+		destroy_workqueue(data->wq);
+	return err;
 }
 
 static int asus_wireless_remove(struct acpi_device *adev)
 {
+	struct asus_wireless_data *data = acpi_driver_data(adev);
+
+	if (data->wq)
+		destroy_workqueue(data->wq);
 	return 0;
 }
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 1/7] asus-wireless: Toggle airplane mode LED João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-19  7:13   ` Corentin Chary
  2016-06-13 20:57 ` [PATCH 3/7] asus-wmi: Add quirk_no_rfkill for the Asus N552VW João Paulo Rechi Vita
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

Some Asus laptops that have an airplane-mode indicator LED, also have
the WMI WLAN user bit set, and the following bits in their DSDT:

Scope (_SB)
{
  (...)
  Device (ATKD)
  {
    (...)
    Method (WMNB, 3, Serialized)
    {
      (...)
      If (LEqual (IIA0, 0x00010002))
      {
        OWGD (IIA1)
        Return (One)
      }
    }
  }
}

So when asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store the
wlan state, it drives the airplane-mode indicator LED (through the call
to OWGD) in an inverted fashion: the LED is ON when airplane mode is OFF
(since wlan is ON), and vice-versa.

This commit creates a quirk to not register a RFKill switch at all for
these laptops, to allow the asus-wireless driver to drive the airplane
mode LED correctly through the ASHS ACPI device. It also adds a match to
that quirk for the Asus X555UB, which is affected by this problem.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 13 +++++++++++++
 drivers/platform/x86/asus-wmi.c    |  8 +++++---
 drivers/platform/x86/asus-wmi.h    |  1 +
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 091ca7a..90c8f41 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -78,6 +78,10 @@ static struct quirk_entry quirk_asus_x200ca = {
 	.wapf = 2,
 };
 
+static struct quirk_entry quirk_no_rfkill = {
+	.no_rfkill = true,
+};
+
 static int dmi_matched(const struct dmi_system_id *dmi)
 {
 	quirks = dmi->driver_data;
@@ -306,6 +310,15 @@ static const struct dmi_system_id asus_quirks[] = {
 		},
 		.driver_data = &quirk_asus_x200ca,
 	},
+	{
+		.callback = dmi_matched,
+		.ident = "ASUSTeK COMPUTER INC. X555UB",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"),
+		},
+		.driver_data = &quirk_no_rfkill,
+	},
 	{},
 };
 
diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index a26dca3..7c093a0 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -2069,9 +2069,11 @@ static int asus_wmi_add(struct platform_device *pdev)
 	if (err)
 		goto fail_leds;
 
-	err = asus_wmi_rfkill_init(asus);
-	if (err)
-		goto fail_rfkill;
+	if (!asus->driver->quirks->no_rfkill) {
+		err = asus_wmi_rfkill_init(asus);
+		if (err)
+			goto fail_rfkill;
+	}
 
 	/* Some Asus desktop boards export an acpi-video backlight interface,
 	   stop this from showing up */
diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
index 4da4c8b..5de1df5 100644
--- a/drivers/platform/x86/asus-wmi.h
+++ b/drivers/platform/x86/asus-wmi.h
@@ -38,6 +38,7 @@ struct key_entry;
 struct asus_wmi;
 
 struct quirk_entry {
+	bool no_rfkill;
 	bool hotplug_wireless;
 	bool scalar_panel_brightness;
 	bool store_backlight_power;
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/7] asus-wmi: Add quirk_no_rfkill for the Asus N552VW
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 1/7] asus-wireless: Toggle airplane mode LED João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 4/7] asus-wmi: Add quirk_no_rfkill for the Asus U303LB João Paulo Rechi Vita
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The Asus N552VW has an airplane-mode indicator LED and the WMI WLAN user
bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
the wlan state, which has a side-effect of driving the airplane mode
indicator LED in an inverted fashion. quirk_no_rfkill prevents asus-wmi
from registering RFKill switches at all for this laptop and allows
asus-wireless to drive the LED through the ASHS ACPI device.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 90c8f41..31fcde1 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -319,6 +319,15 @@ static const struct dmi_system_id asus_quirks[] = {
 		},
 		.driver_data = &quirk_no_rfkill,
 	},
+	{
+		.callback = dmi_matched,
+		.ident = "ASUSTeK COMPUTER INC. N552VW",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "N552VW"),
+		},
+		.driver_data = &quirk_no_rfkill,
+	},
 	{},
 };
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 4/7] asus-wmi: Add quirk_no_rfkill for the Asus U303LB
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
                   ` (2 preceding siblings ...)
  2016-06-13 20:57 ` [PATCH 3/7] asus-wmi: Add quirk_no_rfkill for the Asus N552VW João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 5/7] asus-wmi: Add quirk_no_rfkill for the Asus Z550MA João Paulo Rechi Vita
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The Asus U303LB has an airplane-mode indicator LED and the WMI WLAN user
bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
the wlan state, which has a side-effect of driving the airplane mode
indicator LED in an inverted fashion. quirk_no_rfkill prevents asus-wmi
from registering RFKill switches at all for this laptop and allows
asus-wireless to drive the LED through the ASHS ACPI device.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reported-by: Mousou Yuu <guogaishiwo@gmail.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 31fcde1..efae467 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -328,6 +328,15 @@ static const struct dmi_system_id asus_quirks[] = {
 		},
 		.driver_data = &quirk_no_rfkill,
 	},
+	{
+		.callback = dmi_matched,
+		.ident = "ASUSTeK COMPUTER INC. U303LB",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "U303LB"),
+		},
+		.driver_data = &quirk_no_rfkill,
+	},
 	{},
 };
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 5/7] asus-wmi: Add quirk_no_rfkill for the Asus Z550MA
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
                   ` (3 preceding siblings ...)
  2016-06-13 20:57 ` [PATCH 4/7] asus-wmi: Add quirk_no_rfkill for the Asus U303LB João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 6/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF João Paulo Rechi Vita
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The Asus Z550MA has an airplane-mode indicator LED and the WMI WLAN user
bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
the wlan state, which has a side-effect of driving the airplane mode
indicator LED in an inverted fashion. quirk_no_rfkill prevents asus-wmi
from registering RFKill switches at all for this laptop and allows
asus-wireless to drive the LED through the ASHS ACPI device.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reported-by: Ming Shuo Chiu <chiu@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index efae467..7b5c444 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -337,6 +337,15 @@ static const struct dmi_system_id asus_quirks[] = {
 		},
 		.driver_data = &quirk_no_rfkill,
 	},
+	{
+		.callback = dmi_matched,
+		.ident = "ASUSTeK COMPUTER INC. Z550MA",
+		.matches = {
+			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "Z550MA"),
+		},
+		.driver_data = &quirk_no_rfkill,
+	},
 	{},
 };
 
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 6/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
                   ` (4 preceding siblings ...)
  2016-06-13 20:57 ` [PATCH 5/7] asus-wmi: Add quirk_no_rfkill for the Asus Z550MA João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-06-13 20:57 ` [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA João Paulo Rechi Vita
  2016-06-19  7:19 ` [PATCH 0/7] asus-wireless: LED control Corentin Chary
  7 siblings, 0 replies; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The Asus X456UF has an airplane-mode indicator LED and the WMI WLAN user
bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
the wlan state, which has a side-effect of driving the airplane mode
indicator LED in an inverted fashion.

quirk_no_rfkill prevents asus-wmi from registering RFKill switches at
all for this laptop and allows asus-wireless to drive the LED through
the ASHS ACPI device.  This laptop already has a quirk for setting
WAPF=4, so this commit creates a new quirk, quirk_no_rfkill_wapf4, which
both disables rfkill and sets WAPF=4.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reported-by: Carlo Caione <carlo@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 7b5c444..87cd60b 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -82,6 +82,11 @@ static struct quirk_entry quirk_no_rfkill = {
 	.no_rfkill = true,
 };
 
+static struct quirk_entry quirk_no_rfkill_wapf4 = {
+	.wapf = 4,
+	.no_rfkill = true,
+};
+
 static int dmi_matched(const struct dmi_system_id *dmi)
 {
 	quirks = dmi->driver_data;
@@ -146,7 +151,7 @@ static const struct dmi_system_id asus_quirks[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 			DMI_MATCH(DMI_PRODUCT_NAME, "X456UF"),
 		},
-		.driver_data = &quirk_asus_wapf4,
+		.driver_data = &quirk_no_rfkill_wapf4,
 	},
 	{
 		.callback = dmi_matched,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
                   ` (5 preceding siblings ...)
  2016-06-13 20:57 ` [PATCH 6/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF João Paulo Rechi Vita
@ 2016-06-13 20:57 ` João Paulo Rechi Vita
  2016-07-01 23:07   ` Darren Hart
  2016-06-19  7:19 ` [PATCH 0/7] asus-wireless: LED control Corentin Chary
  7 siblings, 1 reply; 11+ messages in thread
From: João Paulo Rechi Vita @ 2016-06-13 20:57 UTC (permalink / raw)
  To: Darren Hart, Corentin Chary
  Cc: platform-driver-x86, acpi4asus-user, linux-kernel, linux,
	João Paulo Rechi Vita

The Asus X456UA has an airplane-mode indicator LED and the WMI WLAN user
bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
the wlan state, which has a side-effect of driving the airplane mode
indicator LED in an inverted fashion.

quirk_no_rfkill prevents asus-wmi from registering RFKill switches at
all for this laptop and allows asus-wireless to drive the LED through
the ASHS ACPI device.  This laptop already has a quirk for setting
WAPF=4, so this commit creates a new quirk, quirk_no_rfkill_wapf4, which
both disables rfkill and sets WAPF=4.

Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
Reported-by: Angela Traeger <angie@endlessm.com>
---
 drivers/platform/x86/asus-nb-wmi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
index 87cd60b..87d618f 100644
--- a/drivers/platform/x86/asus-nb-wmi.c
+++ b/drivers/platform/x86/asus-nb-wmi.c
@@ -142,7 +142,7 @@ static const struct dmi_system_id asus_quirks[] = {
 			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
 			DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"),
 		},
-		.driver_data = &quirk_asus_wapf4,
+		.driver_data = &quirk_no_rfkill_wapf4,
 	},
 	{
 		.callback = dmi_matched,
-- 
2.5.0

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED
  2016-06-13 20:57 ` [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED João Paulo Rechi Vita
@ 2016-06-19  7:13   ` Corentin Chary
  0 siblings, 0 replies; 11+ messages in thread
From: Corentin Chary @ 2016-06-19  7:13 UTC (permalink / raw)
  To: João Paulo Rechi Vita
  Cc: Darren Hart, platform-driver-x86, acpi4asus-user, LKML, linux,
	João Paulo Rechi Vita

On Mon, Jun 13, 2016 at 10:57 PM, João Paulo Rechi Vita
<jprvita@gmail.com> wrote:
>
> Some Asus laptops that have an airplane-mode indicator LED, also have
> the WMI WLAN user bit set, and the following bits in their DSDT:
>
> Scope (_SB)
> {
>   (...)
>   Device (ATKD)
>   {
>     (...)
>     Method (WMNB, 3, Serialized)
>     {
>       (...)
>       If (LEqual (IIA0, 0x00010002))
>       {
>         OWGD (IIA1)
>         Return (One)
>       }
>     }
>   }
> }
>
> So when asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store the
> wlan state, it drives the airplane-mode indicator LED (through the call
> to OWGD) in an inverted fashion: the LED is ON when airplane mode is OFF
> (since wlan is ON), and vice-versa.

Have you tried check the values of SFUN for these laptops ? It's
supposed to have 1 bit per "feature"
maybe there is a bit that we could use to enable this quirk (this can
clearly be done after this whole series).

>
> This commit creates a quirk to not register a RFKill switch at all for
> these laptops, to allow the asus-wireless driver to drive the airplane
> mode LED correctly through the ASHS ACPI device. It also adds a match to
> that quirk for the Asus X555UB, which is affected by this problem.
>
> Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
> ---
>  drivers/platform/x86/asus-nb-wmi.c | 13 +++++++++++++
>  drivers/platform/x86/asus-wmi.c    |  8 +++++---
>  drivers/platform/x86/asus-wmi.h    |  1 +
>  3 files changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
> index 091ca7a..90c8f41 100644
> --- a/drivers/platform/x86/asus-nb-wmi.c
> +++ b/drivers/platform/x86/asus-nb-wmi.c
> @@ -78,6 +78,10 @@ static struct quirk_entry quirk_asus_x200ca = {
>         .wapf = 2,
>  };
>
> +static struct quirk_entry quirk_no_rfkill = {
> +       .no_rfkill = true,
> +};
> +
>  static int dmi_matched(const struct dmi_system_id *dmi)
>  {
>         quirks = dmi->driver_data;
> @@ -306,6 +310,15 @@ static const struct dmi_system_id asus_quirks[] = {
>                 },
>                 .driver_data = &quirk_asus_x200ca,
>         },
> +       {
> +               .callback = dmi_matched,
> +               .ident = "ASUSTeK COMPUTER INC. X555UB",
> +               .matches = {
> +                       DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
> +                       DMI_MATCH(DMI_PRODUCT_NAME, "X555UB"),
> +               },
> +               .driver_data = &quirk_no_rfkill,
> +       },
>         {},
>  };
>
> diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
> index a26dca3..7c093a0 100644
> --- a/drivers/platform/x86/asus-wmi.c
> +++ b/drivers/platform/x86/asus-wmi.c
> @@ -2069,9 +2069,11 @@ static int asus_wmi_add(struct platform_device *pdev)
>         if (err)
>                 goto fail_leds;
>
> -       err = asus_wmi_rfkill_init(asus);
> -       if (err)
> -               goto fail_rfkill;
> +       if (!asus->driver->quirks->no_rfkill) {
> +               err = asus_wmi_rfkill_init(asus);
> +               if (err)
> +                       goto fail_rfkill;
> +       }
>
>         /* Some Asus desktop boards export an acpi-video backlight interface,
>            stop this from showing up */
> diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wmi.h
> index 4da4c8b..5de1df5 100644
> --- a/drivers/platform/x86/asus-wmi.h
> +++ b/drivers/platform/x86/asus-wmi.h
> @@ -38,6 +38,7 @@ struct key_entry;
>  struct asus_wmi;
>
>  struct quirk_entry {
> +       bool no_rfkill;
>         bool hotplug_wireless;
>         bool scalar_panel_brightness;
>         bool store_backlight_power;
> --
> 2.5.0
>



-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/7] asus-wireless: LED control
  2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
                   ` (6 preceding siblings ...)
  2016-06-13 20:57 ` [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA João Paulo Rechi Vita
@ 2016-06-19  7:19 ` Corentin Chary
  7 siblings, 0 replies; 11+ messages in thread
From: Corentin Chary @ 2016-06-19  7:19 UTC (permalink / raw)
  To: João Paulo Rechi Vita
  Cc: Darren Hart, platform-driver-x86, acpi4asus-user, LKML, linux,
	João Paulo Rechi Vita

On Mon, Jun 13, 2016 at 10:57 PM, João Paulo Rechi Vita
<jprvita@gmail.com> wrote:
> This series adds support for controlling the airplane-mode indicator LED
> present in some Asus laptops. It also creates a quirk in asus-wmi so it does not
> create RFKill devices for platforms that use asus-wireless and where there is a
> competition for the LED control (see "asus-wmi: Create quirk for airplane_mode
> LED" for more details).
>
> João Paulo Rechi Vita (7):
>   asus-wireless: Toggle airplane mode LED
>   asus-wmi: Create quirk for airplane_mode LED
>   asus-wmi: Add quirk_no_rfkill for the Asus N552VW
>   asus-wmi: Add quirk_no_rfkill for the Asus U303LB
>   asus-wmi: Add quirk_no_rfkill for the Asus Z550MA
>   asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF
>   asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA
>
>  drivers/platform/x86/Kconfig         |  2 +
>  drivers/platform/x86/asus-nb-wmi.c   | 49 ++++++++++++++++++-
>  drivers/platform/x86/asus-wireless.c | 91 +++++++++++++++++++++++++++++++++++-
>  drivers/platform/x86/asus-wmi.c      |  8 ++--
>  drivers/platform/x86/asus-wmi.h      |  1 +
>  5 files changed, 145 insertions(+), 6 deletions(-)
>
> --
> 2.5.0
>

Looks good to me. I hope that we can get rid of all these quirks in
the near future.

Reviewed-by: Corentin Chary <corentin.chary@gmail.com>

-- 
Corentin Chary
http://xf.iksaif.net

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA
  2016-06-13 20:57 ` [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA João Paulo Rechi Vita
@ 2016-07-01 23:07   ` Darren Hart
  0 siblings, 0 replies; 11+ messages in thread
From: Darren Hart @ 2016-07-01 23:07 UTC (permalink / raw)
  To: João Paulo Rechi Vita
  Cc: Corentin Chary, platform-driver-x86, acpi4asus-user,
	linux-kernel, linux, João Paulo Rechi Vita

On Mon, Jun 13, 2016 at 04:57:36PM -0400, João Paulo Rechi Vita wrote:
> The Asus X456UA has an airplane-mode indicator LED and the WMI WLAN user
> bit set, so asus-wmi uses ASUS_WMI_DEVID_WLAN_LED (0x00010002) to store
> the wlan state, which has a side-effect of driving the airplane mode
> indicator LED in an inverted fashion.
> 
> quirk_no_rfkill prevents asus-wmi from registering RFKill switches at
> all for this laptop and allows asus-wireless to drive the LED through
> the ASHS ACPI device.  This laptop already has a quirk for setting
> WAPF=4, so this commit creates a new quirk, quirk_no_rfkill_wapf4, which
> both disables rfkill and sets WAPF=4.

Corrected this last bit of the comment to say "use" instead of "creates a new
quirk" since that was done in 6/7.

Otherwise, all is well, and thank you for sticking with this and seeing it
through João, much appreciated. Queued to testing for 4.8.

> 
> Signed-off-by: João Paulo Rechi Vita <jprvita@endlessm.com>
> Reported-by: Angela Traeger <angie@endlessm.com>
> ---
>  drivers/platform/x86/asus-nb-wmi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus-nb-wmi.c
> index 87cd60b..87d618f 100644
> --- a/drivers/platform/x86/asus-nb-wmi.c
> +++ b/drivers/platform/x86/asus-nb-wmi.c
> @@ -142,7 +142,7 @@ static const struct dmi_system_id asus_quirks[] = {
>  			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."),
>  			DMI_MATCH(DMI_PRODUCT_NAME, "X456UA"),
>  		},
> -		.driver_data = &quirk_asus_wapf4,
> +		.driver_data = &quirk_no_rfkill_wapf4,
>  	},
>  	{
>  		.callback = dmi_matched,
> -- 
> 2.5.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

-- 
Darren Hart
Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2016-07-01 23:07 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-13 20:57 [PATCH 0/7] asus-wireless: LED control João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 1/7] asus-wireless: Toggle airplane mode LED João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 2/7] asus-wmi: Create quirk for airplane_mode LED João Paulo Rechi Vita
2016-06-19  7:13   ` Corentin Chary
2016-06-13 20:57 ` [PATCH 3/7] asus-wmi: Add quirk_no_rfkill for the Asus N552VW João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 4/7] asus-wmi: Add quirk_no_rfkill for the Asus U303LB João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 5/7] asus-wmi: Add quirk_no_rfkill for the Asus Z550MA João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 6/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UF João Paulo Rechi Vita
2016-06-13 20:57 ` [PATCH 7/7] asus-wmi: Add quirk_no_rfkill_wapf4 for the Asus X456UA João Paulo Rechi Vita
2016-07-01 23:07   ` Darren Hart
2016-06-19  7:19 ` [PATCH 0/7] asus-wireless: LED control Corentin Chary

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).