diff mbox

platform/x86: asus-wmi: try to set als by default

Message ID 20170421152434.3834-1-linux@rempel-privat.de (mailing list archive)
State Changes Requested, archived
Headers show

Commit Message

Oleksij Rempel April 21, 2017, 3:24 p.m. UTC
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 == 0x53545344)
                {
		...
                    If (IIA0 == 0x00050001)
                    {
                        If (!ALSP)
                        {
                            Return (0x02)
                        }

                        Local0 = (GALS & 0x10)    <<<---- bug,
                                                    should be: (GALS () & 0x10)
                        If (Local0)
                        {
                            Return (0x00050001)
                        }
                        Else
                        {
                            Return (0x00050000)
                        }
                    }

             .....
                If (Local0 == 0x53564544)
                {
		...
                    If (IIA0 == 0x00050001)
                    {
                        Return (ALSC (IIA1))
                    }

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 ON.

This patch will do the same. Turn ALS on by default.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
---
 drivers/platform/x86/asus-wmi.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Andy Shevchenko April 21, 2017, 7:06 p.m. UTC | #1
On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> some laptops, for example ASUS UX330UAK, have brocken als_get function
> but working als_set funktion. In this case, ALS will stay turned off.

Please, spell check the above.

some -> Some
brocken -> broken
funktion -> function

>
>              Method (WMNB, 3, Serialized)
>             {
>             ...
>                If (Local0 == 0x53545344)
>                 {
>                 ...
>                     If (IIA0 == 0x00050001)
>                     {
>                         If (!ALSP)
>                         {
>                             Return (0x02)
>                         }
>
>                         Local0 = (GALS & 0x10)    <<<---- bug,
>                                                     should be: (GALS () & 0x10)

How GALS is defined in ASL?

> 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 ON.
>
> This patch will do the same. Turn ALS on by default.

It would be good to see if there is no regression added.
Oleksij Rempel April 22, 2017, 6:14 a.m. UTC | #2
Am 21.04.2017 um 21:06 schrieb Andy Shevchenko:
> On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>> some laptops, for example ASUS UX330UAK, have brocken als_get function
>> but working als_set funktion. In this case, ALS will stay turned off.
> 
> Please, spell check the above.
> 
> some -> Some
> brocken -> broken
> funktion -> function

ok. thank you.

>>
>>              Method (WMNB, 3, Serialized)
>>             {
>>             ...
>>                If (Local0 == 0x53545344)
>>                 {
>>                 ...
>>                     If (IIA0 == 0x00050001)
>>                     {
>>                         If (!ALSP)
>>                         {
>>                             Return (0x02)
>>                         }
>>
>>                         Local0 = (GALS & 0x10)    <<<---- bug,
>>                                                     should be: (GALS () & 0x10)
> 
> How GALS is defined in ASL?

                    Method (GALS, 0, NotSerialized)
                    {
                        Local0 = Zero
                        Local0 |= 0x20
                        If (ALAE)
                        {
                            Local0 |= 0x10
                        }

                        Local1 = 0x0A
                        Local1 <<= 0x08
                        Local0 |= Local1
                        Return (Local0)
                    }


beside, same part of code on ASUS UX32A, which works just fine:

                    If ((IIA0 == 0x00050001))
                    {
                        If (!ALSP)
                        {
                            Return (0x02)
                        }

                        Local0 = (GALS () & 0x10)
                        If (Local0)
                        {
                            Return (0x00050001)
                        }
                        Else
                        {
                            Return (0x00050000)
                        }
                    }

                    If ((IIA0 == 0x00050013))
                    {
                        Local0 = (GALS () & 0x0F0F)
                        Return (Local0)
                    }

....
            Method (GALS, 0, NotSerialized)
            {
                Local0 = (LBTN & 0x0F)
                Local0 |= 0x20
                If (ALAE)
                {
                    Local0 |= 0x10
                }

                Local1 = (0x0B - One)
                Local1 <<= 0x08
                Local0 |= 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 ON.
>>
>> This patch will do the same. Turn ALS on by default.
> 
> It would be good to see if there is no regression added.

sure. Is there anything i can do for this, except continue to use this
patch with my HW?
Oleksij Rempel April 22, 2017, 6:55 a.m. UTC | #3
Am 21.04.2017 um 21:06 schrieb Andy Shevchenko:
> On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>> some laptops, for example ASUS UX330UAK, have brocken als_get function
>> but working als_set funktion. In this case, ALS will stay turned off.
> 
> Please, spell check the above.
> 
> some -> Some
> brocken -> broken
> funktion -> function
> 
>>
>>              Method (WMNB, 3, Serialized)
>>             {
>>             ...
>>                If (Local0 == 0x53545344)
>>                 {
>>                 ...
>>                     If (IIA0 == 0x00050001)
>>                     {
>>                         If (!ALSP)
>>                         {
>>                             Return (0x02)
>>                         }
>>
>>                         Local0 = (GALS & 0x10)    <<<---- bug,
>>                                                     should be: (GALS () & 0x10)
> 
> How GALS is defined in ASL?
> 
>> 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 ON.
>>
>> This patch will do the same. Turn ALS on by default.
> 
> It would be good to see if there is no regression added.

I just send this email to ASUS support, may be some thing will happen:
https://pastebin.com/TLjbbNMc
Andy Shevchenko April 25, 2017, 12:25 p.m. UTC | #4
On Sat, Apr 22, 2017 at 9:55 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Am 21.04.2017 um 21:06 schrieb Andy Shevchenko:
>> On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>>> some laptops, for example ASUS UX330UAK, have brocken als_get function
>>> but working als_set funktion. In this case, ALS will stay turned off.

>>> This patch will do the same. Turn ALS on by default.
>>
>> It would be good to see if there is no regression added.
>
> I just send this email to ASUS support, may be some thing will happen:
> https://pastebin.com/TLjbbNMc

Okay, let's wait a bit and if there no answer submit v2 based on review.
Oleksij Rempel April 25, 2017, 6:42 p.m. UTC | #5
Am 25.04.2017 um 14:25 schrieb Andy Shevchenko:
> On Sat, Apr 22, 2017 at 9:55 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>> Am 21.04.2017 um 21:06 schrieb Andy Shevchenko:
>>> On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>>>> some laptops, for example ASUS UX330UAK, have brocken als_get function
>>>> but working als_set funktion. In this case, ALS will stay turned off.
> 
>>>> This patch will do the same. Turn ALS on by default.
>>>
>>> It would be good to see if there is no regression added.
>>
>> I just send this email to ASUS support, may be some thing will happen:
>> https://pastebin.com/TLjbbNMc
> 
> Okay, let's wait a bit and if there no answer submit v2 based on review.

Oh well, the answer is like usual. We support Windows 10, make shit and
bla bla...

I'll send v2 ASAP.
Andy Shevchenko April 25, 2017, 7:26 p.m. UTC | #6
On Tue, Apr 25, 2017 at 9:42 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
> Am 25.04.2017 um 14:25 schrieb Andy Shevchenko:
>> On Sat, Apr 22, 2017 at 9:55 AM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>>> Am 21.04.2017 um 21:06 schrieb Andy Shevchenko:
>>>> On Fri, Apr 21, 2017 at 6:24 PM, Oleksij Rempel <linux@rempel-privat.de> wrote:
>>>>> some laptops, for example ASUS UX330UAK, have brocken als_get function
>>>>> but working als_set funktion. In this case, ALS will stay turned off.
>>
>>>>> This patch will do the same. Turn ALS on by default.
>>>>
>>>> It would be good to see if there is no regression added.
>>>
>>> I just send this email to ASUS support, may be some thing will happen:
>>> https://pastebin.com/TLjbbNMc
>>
>> Okay, let's wait a bit and if there no answer submit v2 based on review.
>
> Oh well, the answer is like usual. We support Windows 10, make shit and
> bla bla...

I see.

> I'll send v2 ASAP.

One more comment. I think it would be better to make it as a quirk and
call only on certain platforms (based by DMI / etc).
diff mbox

Patch

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index 8fe5890bf539..6b3aef40431c 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -1109,6 +1109,15 @@  static void asus_wmi_set_xusb2pr(struct asus_wmi *asus)
 }
 
 /*
+ * 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
  */
 static int asus_hwmon_agfn_fan_speed_read(struct asus_wmi *asus, int fan,
@@ -2117,6 +2126,8 @@  static int asus_wmi_add(struct platform_device *pdev)
 			goto fail_rfkill;
 	}
 
+	asus_wmi_set_als();
+
 	/* Some Asus desktop boards export an acpi-video backlight interface,
 	   stop this from showing up */
 	chassis_type = dmi_get_system_info(DMI_CHASSIS_TYPE);