Bug 214675 - Unable to get an event on tablet mode on Asus Vivobook Flip TM420IA
Summary: Unable to get an event on tablet mode on Asus Vivobook Flip TM420IA
Status: NEW
Alias: None
Product: Platform Specific/Hardware
Classification: Unclassified
Component: x86-64 (show other bugs)
Hardware: x86-64 Linux
: P1 normal
Assignee: platform_x86_64@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-10-10 15:51 UTC by Marco
Modified: 2024-01-15 11:55 UTC (History)
4 users (show)

See Also:
Kernel Version: 6.6.10-1
Subsystem:
Regression: No
Bisected commit-id:


Attachments
dmesg log (69.24 KB, text/plain)
2021-10-10 15:55 UTC, Marco
Details
DSDT and SSDTs of TM420IA (73.03 KB, application/gzip)
2021-10-10 15:56 UTC, Marco
Details
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - AMD Sensor Fusion Hub (1.28 KB, text/plain)
2024-01-15 10:44 UTC, Lukáš Drahník
Details
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - AMD UMDF Sensor (1.33 KB, text/plain)
2024-01-15 10:45 UTC, Lukáš Drahník
Details
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - Simple Device Orientation Sensor (1.26 KB, text/plain)
2024-01-15 10:46 UTC, Lukáš Drahník
Details

Description Marco 2021-10-10 15:51:56 UTC
I've recently bought this laptop for pen usage for taking class notes, and daily driver for a week with a Windows installation, and as soon as I had time I've tried with a Linux installation (Arch in my case). I would expect that touchscreen and pen input under Linux was a no go, since AFAICS the only well supported pen input methods was Wacom Digitizer, while this system has a MPP implementation from Microsoft, that was decent under Windows but not perfect with handling palm rejection from the touchscreen.

With my suprise, touchscreen and pen input works better under linux, buttons from the stylus works, and palm rejection is even better, almost perfect.

Rotation works, since the accelerometer in the display is detected with some custom software.

The issue is the automatic switch off for the keyboard and the trackpad while it is used with the display only. The inputs are still triggered, the hack from me was to use xinput to manually disable the keyboard and mouse with a script, but that's just a temporary fix.

I've taken quite a look to get where the event should come from and why it's not working here. As far as I have traced the problem, the issue is probably coming from asus-wmi and asus-nb-wmi. I've tried to force tablet mode as a parameter for the second module, but the module at boot complains with:
This device has lid_flip quirk but got ENODEV checking it. This is a bug.
At row https://github.com/torvalds/linux/blob/7fd2bf83d59a2d32e0d596c5d3e623b9a0e7e2d5/drivers/platform/x86/asus-wmi.c#L403

From the code is searching for an event called ASUS_WMI_DEVID_LID_FLIP, with the WMI id of 0x00060062, as of https://github.com/torvalds/linux/blob/7ba88a2a09f47e2e4f3e34215677a1d78a9e6a73/include/linux/platform_data/x86/asus-wmi.h#L66

From there I've dumped the DSDT for my machine, did a search for that specific ID, and I found an actual entry in the WMI table (one with a return(one), the other with a return(Zero), so I'm assuming that the call should work fine? Even if it's returning always 1 or 0, it should be possible to read anyway?). I'll attach a complete DSDT and SSDT dump for this machine to this post.



I've tried to force _OSI to Windows 2015 to see if the issue it's a DSDT platform bug or what but this hasn't changed anything.

I always see SSDTs errors at boot time, so some SSDTs has some parsing issues as always (Quite a lot on EC related stuff, but I'm not sure if that is the issue here).

Can anyone help me debug where the issue lies here?
Comment 1 Marco 2021-10-10 15:55:25 UTC
Created attachment 299163 [details]
dmesg log
Comment 2 Marco 2021-10-10 15:56:23 UTC
Created attachment 299165 [details]
DSDT and SSDTs of TM420IA
Comment 3 Tom 2023-11-19 11:48:34 UTC
Are there any tests we can do or logging that we can acquire to help debug this issue. Unfortunately also having this issue.
Comment 4 Marco 2023-11-19 11:56:08 UTC
(In reply to Tom from comment #3)
> Are there any tests we can do or logging that we can acquire to help debug
> this issue. Unfortunately also having this issue.

I do not have this laptop anymore for other unrelated issues, so I don't really need this issue fixed anymore. You can kinda workaround this by using accelerometer data and estimating the display position, but that wasn't that great all the time.

AFAIK the issue rely on the fact that amd-sfh do not support lid angle sensors as of today, but I'm not sure if this laptop use that driver or ASUS has invented something else for handling it and therefore the driver is fully missing.

Marco.
Comment 5 Tom 2023-11-19 12:03:00 UTC
Thanks for the update
Comment 6 Lukáš Drahník 2024-01-11 22:18:20 UTC
I have dual boot Windows 11 and I can confirm WMI id `0x00060062` changes each flip:

```
# laptop mode - returns 0
$ (Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DSTS -Arguments @{Device_ID=0x00060062} | Select-Object -ExpandProperty device_status) - 65536
0

# tablet mode - returns 1
# read tablet mode (no keyboard, because of that is used sleep)
$ Start-Sleep -Seconds 5 ; (Invoke-CimMethod (Get-CimInstance -Namespace root/wmi -ClassName AsusAtkWmi_WMNB) -MethodName DSTS -Arguments @{Device_ID=0x00060062} | Select-Object -ExpandProperty device_status) - 65536
1
```

What I tried also was flipping to tablet mode on Windows and then shutdown with pressing power button and boot to Linux and read value, but was `0`:

```
$ sudo -s
$ cd /sys/kernel/debug/asus-nb-wmi
$ echo "0x60062" > dev_id
$ cat dsts
```

On Linux I also tried to do is execute method `_SB.PCI0.SBRG.EC0.RPIN` but value what was succesfully written was only 1, do not know how to understand value `0x0E` in the brackets in `DSDT.dsl` table below:

```
$ sudo acpidbg
$ 
$ find RPIN
$        \_SB.PCI0.SBRG.EC0.RPIN Method       000000003537b063 001 Args 1 Len 0009 Aml 0000000074b8092b
$ evaluate _SB.PCI0.SBRG.EC0.RPIN 1
Evaluating \_SB.PCI0.SBRG.EC0.RPIN
Evaluation of \_SB.PCI0.SBRG.EC0.RPIN returned object 000000005df55307, external buffer length 18
 [Integer] = 0000000000000001
```

Then I tried to read `0x60062`, was still zero.

Related parts of ACPI table (I found `PCI0.SBRG.EC0.RPIN (0x0E)` on two places only):

```
     Scope (\_SB.ATKD)
            {
                Method (FANL, 1, Serialized)
                {
                    FANF = Arg0
                    If ((^^ != One))
                    {
                        ^^PCI0.SBRG.EC0.MPLI (0x05, Zero)
                        ^^PCI0.SBRG.EC0.MPLI (One, Zero)
                        ^^PCI0.SBRG.EC0.MPLI (0x07, Zero)
                        ^^PCI0.SBRG.EC0.MPLI (0x06, Zero)
                        ^^PCI0.SBRG.EC0.MPLI (0x08, Zero)
                        ^^PCI0.SBRG.EC0.MPLI (0x03, 0x05)
                        If (ACPF)
                        {
                            ^^PCI0.SBRG.EC0.STTM (0x0B, 0xE290)
                            ^^PCI0.SBRG.EC0.STTM (0x0C, 0x0001ADB0)
                        }
                        Else
                        {
                            ^^PCI0.SBRG.EC0.STTM (0x0B, 0xE290)
                            ^^PCI0.SBRG.EC0.STTM (0x0C, 0x0001ADB0)
                        }

                        ^^PCI0.SBRG.EC0.STTF ()
                    }

                    TEMF = One
                    If ((^^PCI0.SBRG.EC0.RPIN (0x0E) != One))
                    {
                        SMIF = 0x05
                        FANF = Arg0
                    }

                    Return (ASMI (Arg0))
            }
     }

...

If ((IIA0 == 0x00060062))
{
       If (^^PCI0.SBRG.EC0.RPIN (0x0E))
       {
              Local0 = 0x00010001
       }
       Else
       {
              Local0 = 0x00010000
       }

       Return (Local0)
}
```
Comment 7 Lukáš Drahník 2024-01-11 22:28:01 UTC
Using logs from G-helper (open source Armoury Crate alternative for Asus laptops - https://github.com/seerge/g-helper) during flipping

```
...
11.01.2024 15:03:17: WMI event 250
11.01.2024 15:03:21: WMI event 250
11.01.2024 15:03:33: WMI event 250
11.01.2024 15:03:37: WMI event 250
11.01.2024 15:04:21: WMI event 250
...
```

I can confirm that Windows uses value 250 dec which is `0xFA` in hexa, already associated in `asus-nb-wmi` with `KEY_PROG2`


```
...
>       { KE_KEY, 0xC5, { KEY_KBDILLUMDOWN } },
>       { KE_IGNORE, 0xC6, },  /* Ambient Light Sensor notification */
>       { KE_KEY, 0xFA, { KEY_PROG2 } },           /* Lid flip action */
>       { KE_KEY, 0xBD, { KEY_PROG2 } },           /* Lid flip action on rog
> flow laptops */
...
```

Laptop Zenbook UN5401QAB_UN5401QA
Comment 8 Lukáš Drahník 2024-01-11 22:36:07 UTC
I created a driver https://github.com/asus-linux-drivers/asus-accel-tablet-mode-driver which sends appropriate events (`EV_KEY.KEY_PROG2` and `EV_SW.SW_TABLET_MODE`) based on accelerometer data as a solution that may be sufficient for someone:

```
$ sudo libinput debug-events
...
-event7   DEVICE_ADDED            Asus WMI accel tablet mode        seat0 default group9  cap:kS
...
 event7   KEYBOARD_KEY            +0.000s	KEY_PROG2 (149) pressed
 event7   KEYBOARD_KEY            +0.000s	KEY_PROG2 (149) released
 event7   SWITCH_TOGGLE           +0.000s	switch tablet-mode state 1
 event7   KEYBOARD_KEY            +1.004s	KEY_PROG2 (149) pressed
 event7   KEYBOARD_KEY            +1.004s	KEY_PROG2 (149) released
 event7   SWITCH_TOGGLE           +1.004s	switch tablet-mode state 0
```

```
$ sudo acpi_listen
video/tabletmode TBLT 0000008A 00000001
video/tabletmode TBLT 0000008A 00000000
```
Comment 9 Lukáš Drahník 2024-01-12 14:45:24 UTC
On Windows, I can confirm that flip stops working when I disable AMD Sensor Fusion HUB in Device Manager.
Comment 10 Lukáš Drahník 2024-01-15 10:44:45 UTC
Created attachment 305713 [details]
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - AMD Sensor Fusion Hub
Comment 11 Lukáš Drahník 2024-01-15 10:45:37 UTC
Created attachment 305714 [details]
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - AMD UMDF Sensor
Comment 12 Lukáš Drahník 2024-01-15 10:46:33 UTC
Created attachment 305715 [details]
Laptop Zenbook UN5401QAB_UN5401QA - Device manager - Simple Device Orientation Sensor
Comment 13 Matej Starc 2024-01-15 11:32:25 UTC
Marco, please change the kernel version to 6.6.10-1 (this is what I am currently using).
Comment 14 Marco 2024-01-15 11:55:30 UTC
Done, but I'll tick ignore bug mail now since I don't have the laptop in question and being the submitter make me unable to remove myself from it. I would like to be able to have a feature like the AUR disown package here, so at least other people could pick up the issue without having to open a complete separate one, but that's sadly not the case.

Anyway, good luck in fixing this :)

Marco.

Note You need to log in before you can comment on or make changes to this bug.