CO-1/asus-flow-x13-linux

Tablet mode

IvanDovgal opened this issue Β· 38 comments

After a little research I found way to deactivate keyboard on tablet mode.
It is necessary to activate the device hid with the index 15 on the amd sensor fusion hub and I wrote little patch for this.
After it keyboard should automatically disabling when laptop lid flip out and wmi recieve key event wth 0xBD code witch mapped to KEY_PROG2.
But there remains the problem of detecting the current state of the laptop (tablet / laptop) for the correct installation of SW_TABLET_MODE. gist

Any information regarding sw _tablet_mode would be welcome

So, I found way to get full-featured sw_tablet_mode support.
You can download patch here.
This patch a bit ugly, but it works!

CO-1 commented

Thank you for your contribution. I will hope to find some time to look into it and make a dkms mod.

Hello, I'm on ubuntu 20 LTS. I upgraded the kernel to version 5.15 and the screen is now correctly rotated to match device orientation, but the keyboard + touchpad remain active when on tablet / tent mode. Your patch fixes this? How can I apply it?

@siferati Yes, my patch should fix it. You can apply patch according your distro, something like this

@IvanDovgal can you please upstream this patch? If you need help I can give you a hand, or if you don't want to deal with it I can submit it for you (with credit).

Do you know if this would help more Laptops with AMD SFH? (In my case Asus Zeenbook Flip).

Any news on this? @IvanDovgal

I'm going to begin upstreaming this to the kernel due to no response from the author. Many people are requesting this now.

@flukejones I tested your patch on platform-asus-nb-wmi-event and that works amazingly now the driver catches the screen rotation and the lid closing. I have only to write the script that control these events.

Thank you so much for your contribution and I hope that it will be added soon to the new kernel.

For those of you requiring @IvanDovgal's patch I've taken the time to clean it up and submit upstream.

Here is a blog post of my recent submissions https://asus-linux.org/blog/updates-2022-08-03/

Thanks for this patch. I just stumbled on this after 2 days of trying to get the tablet mode switch on a Lenovo ThinkPad L13 Yoga Gen2 (AMD) to work and can confirm that it also works there without any additional changes.

EDIT: Not quite without additional changes. It breaks after suspend on my laptop. See my response on lkml for the fix if you run into the same issue: https://lkml.org/lkml/2022/8/6/211

@flukejones Do you have any update on the amd_sfh patch? As far as I can tell there have been no additional reviews or comments other than mine (And you haven't addressed the problems I mentioned in my review yet).

Are you planning on submitting a V2 or would you be ok with me submitting a version with my review comments addressed?

Maybe a new/updated submission would get the attention of a maintainer.

Also a minor rebase is needed to make it build on recent kernels.

@freundTech it would be much better if you can if you have the hardware to test with. If you can ping me with the update I'll include it in the fedora kernel and a few other places :)

(sorry i didn't see your response til now)

@flukejones I don't have an Asus flow x13, but I do have another device with amd_sfh based tablet mode switch (Lenovo ThinkPad L13 Yoga Gen2 (AMD)), where I tested the patch.

Might be good to have someone with the flow x13 test my updated patch just in case there are slight differences.

I'll submitted an updated version to the mailing list then (probably under a more generic title to make clear that this doesn't affect just the flow x13).

@freundTech sounds good mate, it'll make a lot of folks happy :)

Here's my updated version of the patch, confirmed working on ThinkPad L13 Yoga Gen2.
Would be great if someone with the Asus Flow x13 could test it before I submit it upstream.
Make sure to

  1. Build and install a kernel with the patch applied (clone kernel repo, git am filename.patch)
  2. Reboot and make sure tablet mode is working
  3. Send the device to sleep mode, wake it up and check if tablet mode is still working (important!)
  4. Respond here with your results (Leave your name and email address if you want to be mentioned as a tester in the submission)

https://gist.github.com/freundTech/6c0e4bf130a43aaea31dddaf95205f09

If it works I'll submit it to the mailing list next week (or today if you test fast enough πŸ˜‰ )

If it works before, but not after sleep mode we might have a problem, as the behavior varies between devices (The original patch didn't work on my device after sleep, so I hope my fixed version still works on your device after sleep)

I can try it next week, I don't have the laptop with me these days

Any updates? @Juasmis @flukejones

Building the kernel right now, my computer is on πŸ”₯

Ok so I just tried it out, a couple of comments:

  • There is no feedback that the tablet mode is getting activated, should there be such thing in gnome?
  • Keyboard gets deactivated correctly and after waking up from suspend it still deactivates when the lid is rotated
  • Touchpad remains always active
  • Screen rotation does not work, but I think this was part of a different patch, is this correct @flukejones?

I installed the patch following the instructions from here and this is my system:

             .',;::::;,'.                patomareao@juasmisrogflow 
         .';:cccccccccccc:;,.            ------------------------- 
      .;cccccccccccccccccccccc;.         OS: Fedora release 37 (Thirty Seven) x 
    .:cccccccccccccccccccccccccc:.       Host: ROG Flow X13 GV301QH_GV301QH 1.0 
  .;ccccccccccccc;.:dddl:.;ccccccc;.     Kernel: 6.0.12-300.fc37.x86_64+debug 
 .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Uptime: 7 mins 
.:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Packages: 7259 (rpm), 111 (flatpak) 
,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Shell: zsh 5.9 
:cccccccccccccc;MMM.;cccccccccccccccc:   Resolution: 1920x1200 
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   DE: GNOME 43.2 
cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM: Mutter 
ccccc:XM0';cccc;MMM.;cccccccccccccccc'   WM Theme: MonoThemeDark 
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Theme: adw-gtk3 [GTK2/3] 
ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Icons: Adwaita [GTK2/3] 
cccccc;dNMWXXXWM0::cccccccccccccc:,      Terminal: gnome-terminal 
cccccccc;.:odl:.;cccccccccccccc:,.       CPU: AMD Ryzen 7 5800HS with Radeon Gr 
:cccccccccccccccccccccccccccc:'.         GPU: AMD ATI Radeon Vega Series / Rade 
.:cccccccccccccccccccccc:;,..            Memory: 3400MiB / 15335MiB 
  '::

Thanks. I think gnome not giving feedback is normal.

Is the touchpad not getting deactivated a regression? Was that working on Luke's version of the patch or did that never work?

@Juasmis I maintain a fedora build here https://gitlab.com/asus-linux/fedora-kernel which includes a lot of patches. Almost all of these are in 6.1 kernel. Copr here https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/

And do please check out https://asus-linux.org/ plus associated projects.

I'm waiting for feedback from others

Okay, I will try again tomorrow and report back

Asus Flow X13 GV301QH on Fedora 37 GNOME user here. Using the ROG Kernel by flukejones. It seems to work fine for me, rotation and keyguard / touchpad disabling but perhaps not 100% reliably. I did have it rotate just once and then not rotating back again, unless I flipped the lid open and back again. Not sure if somehow auto-rotation is disabled by itself for some reason. And also at first the touchpad and keys were active for a bit and then stopped. Not sure if I'm doing something wrong or not. Other times it works perfectly from the start.

It also works after sleep mode it seems, but sleep mode does not seem to work for me at all if I'm on battery power, it just never boots back up. Plugged works fine though.

Thanks. I'll send it to the mailing list later today.

One more question that might help me with a problem on another device:

When you run sudo libinput debug-events it should first list all your input devices with number (eventX) and name, then print all input events from all devices. When you put your laptop into or out of tablet mode you should see an input event for that (I think it's called tablet-mode-switch or something like that).

What is the name of the device producing that event? (libinput shows the device number at the start of the event line. You can look up the name at the start of the libinput output or using cat /sys/class/input/eventX/device/name

I think it's Asus WMI hotkeys. It said event18 SWITCH_TOGGLE +7.408s switch tablet-mode state 1 and when I ran cat /sys/class/input/event18/device/name it said Asus WMI hotkeys.

@Juasmis I maintain a fedora build here https://gitlab.com/asus-linux/fedora-kernel which includes a lot of patches. Almost all of these are in 6.1 kernel. Copr here https://copr.fedorainfracloud.org/coprs/lukenukem/asus-kernel/

And do please check out https://asus-linux.org/ plus associated projects.

Luke I tried cloning the repo and just replacing the patch with the updated version from @freundTech. Everything works perfectly!

  • If the lid is rotated now the touchpad gets deactivated as well and the behaviour remains after waking up from sleep (I am not facing the wake-up problems as @krysztofz, I have not had any in a while).
  • Also the screen rotation works

Just one behaviour I am not sure whether is intentional or not, when the laptop is rotated 90ΒΊ (not in tablet mode, but maintaining the laptop form factor) the keyboard and touchpad* get deactivated as well.

Thanks to both of you guys for your great work @flukejones @freundTech

      .;cccccccccccccccccccccc;.         OS: Fedora release 37 (Thirty Seven) x 
    .:cccccccccccccccccccccccccc:.       Host: ROG Flow X13 GV301QH_GV301QH 1.0 
  .;ccccccccccccc;.:dddl:.;ccccccc;.     Kernel: 6.0.12-308.rog.fc37.x86_64 
 .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Uptime: 13 mins 
.:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Packages: 7262 (rpm), 111 (flatpak) 
,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Shell: zsh 5.9 
:cccccccccccccc;MMM.;cccccccccccccccc:   Resolution: 1920x1200 
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   DE: GNOME 43.2 
cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM: Mutter 
ccccc:XM0';cccc;MMM.;cccccccccccccccc'   WM Theme: MonoThemeDark 
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Theme: adw-gtk3 [GTK2/3] 
ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Icons: Adwaita [GTK2/3] 
cccccc;dNMWXXXWM0::cccccccccccccc:,      Terminal: gnome-terminal 
cccccccc;.:odl:.;cccccccccccccc:,.       CPU: AMD Ryzen 7 5800HS with Radeon Gr 
:cccccccccccccccccccccccccccc:'.         GPU: AMD ATI Radeon Vega Series / Rade 
.:cccccccccccccccccccccc:;,..            Memory: 3904MiB / 15392MiB 
  '::cccccccccccccc::;,.

*EDIT: Touchpad is active

@Juasmis Might be something specific to my setup, although I don't tinker to be honest. I tried rotating 90 degrees in laptop mode as you said and for me only the keyboard was deactivated, but the touchpad worked.

I just checked, you are right the touchpad remains active is just the keyboard.

About the suspend problems when I had them was because of the GPU driver not being properly installed, maybe at some point you installed something that is conflicting

Hello,
What is current status of this issue?

@pktiuk try the kernel 6.3 RC. I think the work was merged in there.

pktiuk commented

@flukejones
I am on 6.4.6 and my keyboard is still active in tablet mode. Is it a bug on my side, or is not merged yet? I use Pop OS 22.04 (x11 session).

Not merged yet. There's some issues with it. I'll be working on this soon.

pktiuk commented

There's some issues with it. I'll be working on this soon.

@flukejones
Let us know if you need any additional assistance with this issue.