X86 platform drivers
 help / color / mirror / Atom feed
* [PATCH v5] drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER
@ 2025-04-28 20:03 Mario Limonciello
  2025-04-28 22:05 ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Mario Limonciello @ 2025-04-28 20:03 UTC (permalink / raw)
  To: mario.limonciello, Shyam-sundar.S-k, hdegoede, ilpo.jarvinen,
	Patil.Reddy
  Cc: Dmitry Torokhov, Armin Wolf, platform-driver-x86

From: Mario Limonciello <mario.limonciello@amd.com>

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 <hdegoede@redhat.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Armin Wolf <W_Armin@gmx.de>
Fixes: 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
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(-)

diff --git a/drivers/platform/x86/amd/pmf/tee-if.c b/drivers/platform/x86/amd/pmf/tee-if.c
index 7d6404ab9f041..a182a3a6daf11 100644
--- a/drivers/platform/x86/amd/pmf/tee-if.c
+++ b/drivers/platform/x86/amd/pmf/tee-if.c
@@ -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);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER
  2025-04-28 20:03 [PATCH v5] drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER Mario Limonciello
@ 2025-04-28 22:05 ` Dmitry Torokhov
  2025-04-28 22:41   ` Mario Limonciello
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2025-04-28 22:05 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: mario.limonciello, Shyam-sundar.S-k, hdegoede, ilpo.jarvinen,
	Patil.Reddy, Armin Wolf, platform-driver-x86

Hi Mario,

On Mon, Apr 28, 2025 at 03:03:57PM -0500, Mario Limonciello wrote:
> From: Mario Limonciello <mario.limonciello@amd.com>
> 
> 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 <hdegoede@redhat.com>
> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> Cc: Armin Wolf <W_Armin@gmx.de>
> Fixes: 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> 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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v5] drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER
  2025-04-28 22:05 ` Dmitry Torokhov
@ 2025-04-28 22:41   ` Mario Limonciello
  0 siblings, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2025-04-28 22:41 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: mario.limonciello, Shyam-sundar.S-k, hdegoede, ilpo.jarvinen,
	Patil.Reddy, Armin Wolf, platform-driver-x86

On 4/28/2025 5:05 PM, Dmitry Torokhov wrote:
> Hi Mario,
> 
> On Mon, Apr 28, 2025 at 03:03:57PM -0500, Mario Limonciello wrote:
>> From: Mario Limonciello <mario.limonciello@amd.com>
>>
>> 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 <hdegoede@redhat.com>
>> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
>> Cc: Armin Wolf <W_Armin@gmx.de>
>> Fixes: 4c92d448e3e61 ("platform/x86/amd/pmf: Use existing input event codes to update system states")
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>> 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.
> 


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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-04-28 22:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-28 20:03 [PATCH v5] drivers/platform/x86/amd: pmf: Update screen lock actions to KEY_SCREENSAVER Mario Limonciello
2025-04-28 22:05 ` Dmitry Torokhov
2025-04-28 22:41   ` Mario Limonciello

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox