Return-Path: Received: from mail-bl2nam02on0104.outbound.protection.outlook.com ([104.47.38.104]:33440 "EHLO NAM02-BL2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755369AbeCHFCb (ORCPT ); Thu, 8 Mar 2018 00:02:31 -0500 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Oleksij Rempel , Andy Shevchenko , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 114/190] platform/x86: asus-wmi: try to set als by default Date: Thu, 8 Mar 2018 04:59:42 +0000 Message-ID: <20180308045810.8041-114-alexander.levin@microsoft.com> References: <20180308045810.8041-1-alexander.levin@microsoft.com> In-Reply-To: <20180308045810.8041-1-alexander.levin@microsoft.com> Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org List-ID: From: Oleksij Rempel [ Upstream commit e9b615186805e2c18a0ac76aca62c1543ecfdbb8 ] some laptops, for example ASUS UX330UAK, have brocken als_get function but working als_set funktion. In this case, ALS will stay turned off. Method (WMNB, 3, Serialized) { ... If (Local0 =3D=3D 0x53545344) { ... If (IIA0 =3D=3D 0x00050001) { If (!ALSP) { Return (0x02) } Local0 =3D (GALS & 0x10) <<<---- bug, should be: (GALS () & 0= x10) If (Local0) { Return (0x00050001) } Else { Return (0x00050000) } } ..... If (Local0 =3D=3D 0x53564544) { ... If (IIA0 =3D=3D 0x00050001) { Return (ALSC (IIA1)) } ...... Method (GALS, 0, NotSerialized) { Local0 =3D Zero Local0 |=3D 0x20 If (ALAE) { Local0 |=3D 0x10 } Local1 =3D 0x0A Local1 <<=3D 0x08 Local0 |=3D Local1 Return (Local0) } Since it works without problems on Windows I assume ASUS WMI driver for Win never trying to get ALS state, and instead it is setting it by default to O= N. This patch will do the same. Turn ALS on by default. Signed-off-by: Oleksij Rempel Signed-off-by: Andy Shevchenko Signed-off-by: Sasha Levin --- drivers/platform/x86/asus-nb-wmi.c | 13 +++++++++++++ drivers/platform/x86/asus-wmi.c | 12 ++++++++++++ drivers/platform/x86/asus-wmi.h | 1 + 3 files changed, 26 insertions(+) diff --git a/drivers/platform/x86/asus-nb-wmi.c b/drivers/platform/x86/asus= -nb-wmi.c index ab44326ea3e7..687cc5b922ee 100644 --- a/drivers/platform/x86/asus-nb-wmi.c +++ b/drivers/platform/x86/asus-nb-wmi.c @@ -120,6 +120,10 @@ static struct quirk_entry quirk_asus_x550lb =3D { .xusb2pr =3D 0x01D9, }; =20 +static struct quirk_entry quirk_asus_ux330uak =3D { + .wmi_force_als_set =3D true, +}; + static int dmi_matched(const struct dmi_system_id *dmi) { quirks =3D dmi->driver_data; @@ -420,6 +424,15 @@ static const struct dmi_system_id asus_quirks[] =3D { }, .driver_data =3D &quirk_asus_ux303ub, }, + { + .callback =3D dmi_matched, + .ident =3D "ASUSTeK COMPUTER INC. UX330UAK", + .matches =3D { + DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), + DMI_MATCH(DMI_PRODUCT_NAME, "UX330UAK"), + }, + .driver_data =3D &quirk_asus_ux330uak, + }, { .callback =3D dmi_matched, .ident =3D "ASUSTeK COMPUTER INC. X550LB", diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wm= i.c index 8499d3ae4257..8a1bfd489c26 100644 --- a/drivers/platform/x86/asus-wmi.c +++ b/drivers/platform/x86/asus-wmi.c @@ -1108,6 +1108,15 @@ static void asus_wmi_set_xusb2pr(struct asus_wmi *as= us) orig_ports_available, ports_available); } =20 +/* + * Some devices dont support or have borcken get_als method + * but still support set method. + */ +static void asus_wmi_set_als(void) +{ + asus_wmi_set_devstate(ASUS_WMI_DEVID_ALS_ENABLE, 1, NULL); +} + /* * Hwmon device */ @@ -2120,6 +2129,9 @@ static int asus_wmi_add(struct platform_device *pdev) goto fail_rfkill; } =20 + if (asus->driver->quirks->wmi_force_als_set) + asus_wmi_set_als(); + /* Some Asus desktop boards export an acpi-video backlight interface, stop this from showing up */ chassis_type =3D dmi_get_system_info(DMI_CHASSIS_TYPE); diff --git a/drivers/platform/x86/asus-wmi.h b/drivers/platform/x86/asus-wm= i.h index fdff626c3b51..5db052d1de1e 100644 --- a/drivers/platform/x86/asus-wmi.h +++ b/drivers/platform/x86/asus-wmi.h @@ -45,6 +45,7 @@ struct quirk_entry { bool store_backlight_power; bool wmi_backlight_power; bool wmi_backlight_native; + bool wmi_force_als_set; int wapf; /* * For machines with AMD graphic chips, it will send out WMI event --=20 2.14.1