Skip to contentSkip to conversation

drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER

PATCH In review Mario Limonciello 2 participants 3 messages Apr 28, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v5 1/1 drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER

From: Mario Limonciello <[email protected]>

Screen lock actions are ignored by popular desktop environments currently. This is because KEY_SCREENLOCK is not one of the legacy keys that popular desktop environments listen to by default, KEY_SCREENSAVER is.

Adjust the PMF driver to use the correct keycode.

Cc Hans de Goede <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Armin Wolf <[email protected]>
Fixes 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")

---
v5:
* As Dmitry pointed out that GNOME listens to multiple keys even if not advertised it meant there was a bug either in GNOME or the PMF driver. Turns out it's in the PMF driver! Switch key combinations instead of using META+L

---
 drivers/platform/x86/amd/pmf/tee-if.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/amd/pmf/tee-if.c +2 -2
index 7d6404ab9f041..a182a3a6daf11 100644
@@ -172,7 +172,7 @@ static void amd_pmf_apply_policies(struct amd_pmf_dev *dev, struct ta_pmf_enact_
 				amd_pmf_update_uevents(dev, KEY_SUSPEND);
 				break;
 			case 2:
-				amd_pmf_update_uevents(dev, KEY_SCREENLOCK);
+				amd_pmf_update_uevents(dev, KEY_SCREENSAVER);
 				break;
 			default:
 				dev_err(dev->dev, "Invalid PMF policy system state: %d\n", val);
@@ -458,7 +458,7 @@ int amd_pmf_register_input_device(struct amd_pmf_dev *dev)
 	dev->pmf_idev->phys = "amd-pmf/input0";
 
 	input_set_capability(dev->pmf_idev, EV_KEY, KEY_SLEEP);
-	input_set_capability(dev->pmf_idev, EV_KEY, KEY_SCREENLOCK);
+	input_set_capability(dev->pmf_idev, EV_KEY, KEY_SCREENSAVER);
 	input_set_capability(dev->pmf_idev, EV_KEY, KEY_SUSPEND);
 
 	err = input_register_device(dev->pmf_idev);
Signature · 1 line
2.43.0
#1 lore raw

Hi Mario,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

Screen lock actions are ignored by popular desktop environments currently. This is because KEY_SCREENLOCK is not one of the legacy keys that popular desktop environments listen to by default, KEY_SCREENSAVER is.

Adjust the PMF driver to use the correct keycode.

Cc Hans de Goede <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Armin Wolf <[email protected]>
Fixes 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")
Quoted 5 lines

---
v5:
* As Dmitry pointed out that GNOME listens to multiple keys even if not advertised it meant there was a bug either in GNOME or the PMF driver. Turns out it's in the PMF driver! Switch key combinations instead of using META+L

No, KEY_SCREENLOCK is the proper keycode, as you can infer from multiple instances of it in the kernel sources and only single KEY_SCREENSAVER in the code for an infrared remote controller.

X for ages mapped keycode 160 (152 KEY_SCREENSAVER/KEY_COFFEE + 8 evdev offset compared to legacy XKB numbering) to COFFEE aka XF86ScreenSaver, and I still see it mapped on my system(s):

KeyRelease event, serial 42, synthetic NO, window 0x5200001,
root 0x4f4, subw 0x0, time 491884600, (89,58), root:(1920,1044), state 0x0, keycode 160 (keysym 0x1008ff2d, XF86ScreenSaver), same_screen YES, XLookupString gives 0 bytes:
XFilterEvent returns: False

And I also see it working in both KDE X11 and KDE Wayland. So again, it is either Gnome breakage or something wrong with your system. The change to PMF driver should not be necessary.

Thanks.

Signature · 1 line
Dmitry
#2 lore raw
Quoted 36 lines · Dmitry Torokhov

Hi Mario,

Quoted 13 lines · Mario Limonciello

From: Mario Limonciello <[email protected]>

Screen lock actions are ignored by popular desktop environments currently. This is because KEY_SCREENLOCK is not one of the legacy keys that popular desktop environments listen to by default, KEY_SCREENSAVER is.

Adjust the PMF driver to use the correct keycode.

Cc Hans de Goede <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Armin Wolf <[email protected]>
Fixes 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")
Quoted 5 lines

---
v5:
* As Dmitry pointed out that GNOME listens to multiple keys even if not advertised it meant there was a bug either in GNOME or the PMF driver. Turns out it's in the PMF driver! Switch key combinations instead of using META+L

No, KEY_SCREENLOCK is the proper keycode, as you can infer from multiple instances of it in the kernel sources and only single KEY_SCREENSAVER in the code for an infrared remote controller.

X for ages mapped keycode 160 (152 KEY_SCREENSAVER/KEY_COFFEE + 8 evdev offset compared to legacy XKB numbering) to COFFEE aka XF86ScreenSaver, and I still see it mapped on my system(s):

KeyRelease event, serial 42, synthetic NO, window 0x5200001,
root 0x4f4, subw 0x0, time 491884600, (89,58), root:(1920,1044), state 0x0, keycode 160 (keysym 0x1008ff2d, XF86ScreenSaver), same_screen YES, XLookupString gives 0 bytes:
XFilterEvent returns: False

Quoted 6 lines

And I also see it working in both KDE X11 and KDE Wayland. So again, it is either Gnome breakage or something wrong with your system. The change to PMF driver should not be necessary.

Thanks.

OK in that case let me first move over to a newer version of GNOME than comes with Ubuntu LTS.