On Tue, Feb 28, 2023 at 8:45 PM Andrew Kallmeyer <kallmeyeras@xxxxxxxxx> wrote: > > Hello, I'm interested in detecting tablet mode switching for my Lenovo > Yoga laptop properly in the kernel. Ultimately I'd like to provide the > SW_TABLET_MODE input event. > > I have found that there are ACPI events fired when the tablet mode is > toggled (both directions send the same event). Here are the logs: > > kernel: ACPI BIOS Error (bug): Could not resolve symbol > [\_SB.PC00.LPCB.EC0._Q44.WM00], AE_NOT_FOUND (20221020/psargs-330) > kernel: ACPI Error: Aborting method \_SB.PC00.LPCB.EC0._Q44 due to > previous error (AE_NOT_FOUND) (20221020/psparse-529) > root[10258]: ACPI group/action undefined: 06129D99-6083- / 000000d0 > > When I looked at the code I found TP_HKEY_EV_TABLET_CHANGED in the > thinkpad_acpi.c driver which seems to have exactly the behavior I'm > looking for but with a different ACPI event number. Would it be > possible to do something like this in the ideapad_laptop driver? I've made some progress! After some very helpful pointers about ACPI from Maximilian Luz I was able to create a small module printks on screen flip events! It finds the _SB.PC00.LPCB.EC0.VPC0 acpi_handle and calls acpi_install_notify_handler on it and receives the events. I'm still wondering about that AE_NOT_FOUND error about the WM00 device though. It seems that the ACPI expects the kernel to define this WM00 device as an extension point. In the DSDT I found: External (_SB_.WM00, DeviceObj) ... Scope (\_SB.PC00.LPCB.EC0) { Method (_Q44, 0, NotSerialized) // _Qxx: EC Query, xx=0x00-0xFF { P80B = 0x44 Notify (VPC0, 0x80) // Status Change WEID = 0xF4 Notify (WM00, 0x80) // Status Change } ... Device (VPC0) { Name (_HID, "VPC2004") // _HID: Hardware ID Name (_UID, Zero) // _UID: Unique ID Name (_VPC, 0x7C0DE114) Name (VPCD, Zero) Additionally two other _Qxx methods (11 and 12) Notify the same two devices. These other two are the brightness up and down keys. The only difference is they set those two variables differently so I'll have to read those variables as well to differentiate screen flips. Right now my module actually detects both screen flips and brightness key presses. I haven't been able to figure out how to create the WM00 device, I'm not even sure that's a thing in ACPI. I also haven't seen how to read those variables. Is it okay to reuse the events sent to this VPC0 device or am I intercepting the events from some other functionality? Any pointers would be greatly appreciated. - Andrew Kallmeyer