I'm currently using a Lenovo Thinkpad X1 Yoga 2nd Gen which is a convertible. If I fold it into tablet mode, go to hibernate / suspend, fold it back to laptop mode (while powered off) and resume the system the tablet mode on/off is not reported anymore until I fold it into tablet mode and back one time. I debugged this via evemu-record which does not show 0 for SW_TABLET_MODE when I resume in laptop mode. I also tested if normal sleep / suspend to RAM is affected but there SW_TABLET_MODE was correctly reported after resuming.
Yeah, the only thing that is missing here should be a call to dytc_lapmode_refresh at resume time. i.e. should be as simple as: * Adding a resume handler into dytc_driver_data * Add a call to dytc_lapmode_refresh there
Er, sorry, this is tablet mode, not lapmode … So, it looks like we already have a call to hotkey_tablet_mode_notify_change in the resume handler. So I suspect that the sysfs file "hotkey_tablet_mode" has the correct value. If that is the case, we'll need to add a call to tpacpi_input_send_tabletsw into hotkey_resume.
Is there a way I could find out if this sysfs file has the correct value? I'm not very experienced with Kernel internals so I don't really know how to find out such stuff.
If I see it correctly cat /sys/devices/platform/thinkpad_acpi/hotkey_tablet_mode should be the value you're looking for.
Yup, that should be the file (which will actually query ACPI for the status each time you read it). Julian, would you be able to test a patch for the thinkpad module? I could create a kernel scratch build for Fedora, not sure about other distros.
Yeah Benjamin I could test a patch
Just checked it and the sysfs file does contain a 0 after wakeup as you said Benjamin.
Created attachment 293737 [details] Trivial patch to send the switch key event I wonder if we should only do this if the switch actually changed. But I suspect the input layer will already take care of that case.
Your patch seems to fix the problem Benjamin, thanks.
(In reply to Benjamin Berg from comment #8) > I wonder if we should only do this if the switch actually changed. But I > suspect the input layer will already take care of that case. There is no need to check if the switch actually changed, as you already presumed the input layer will filter out the event if there is no change. (In reply to Julian from comment #9) > Your patch seems to fix the problem Benjamin, thanks. Awesome, thank you for testing. Benjamin, can you submit the fix for this upstream please ? Then I'll pick it up and merge it for the 5.11 cycle. Note please add the following tags to the commit msg: Fixes: dda3ec0aa631 ("platform/x86: thinkpad_acpi: Implement tablet mode using GMMS method") BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=210269