Bug 216824 - Some laptop hotkeys don't work
Summary: Some laptop hotkeys don't work
Status: RESOLVED CODE_FIX
Alias: None
Product: Drivers
Classification: Unclassified
Component: Platform_x86 (show other bugs)
Hardware: Intel Linux
: P1 normal
Assignee: drivers_platform_x86@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-20 22:32 UTC by André Barata
Modified: 2023-03-27 14:50 UTC (History)
1 user (show)

See Also:
Kernel Version: 6.0
Subsystem:
Regression: No
Bisected commit-id:


Attachments
Laptop hotkeys (784.60 KB, image/jpeg)
2022-12-20 22:32 UTC, André Barata
Details
evtest (8.31 KB, text/plain)
2022-12-20 22:32 UTC, André Barata
Details
smesg (117.27 KB, text/plain)
2022-12-20 22:33 UTC, André Barata
Details
60-keyboard.hwdb (94.67 KB, text/plain)
2022-12-21 11:38 UTC, Hans de Goede
Details
key led (695.74 KB, image/jpeg)
2022-12-21 13:18 UTC, André Barata
Details
key led 2 (886.19 KB, image/jpeg)
2022-12-21 13:18 UTC, André Barata
Details

Description André Barata 2022-12-20 22:32:22 UTC
Created attachment 303436 [details]
Laptop hotkeys

This bug was filed at the request of Hans de Goede, he as been super helpful: 
https://gitlab.freedesktop.org/libinput/libinput/-/issues/822


I have a couple of hotkeys on my MSI Summit E16 Flip laptop that don't work. I attached a picture with the keys in question.
 
Keys number in the picture:

1. This button doesn't work: mute/unmute the microfone;

2. This button works: enable/disable webcam. There's also a physical switch on the side of the laptop that enables/disables the webcam and it also works;

3. This button doesn't work: changes between power modes on Windows using the provided MSI app MSIControl Center Pro;

4. This button doesn't work: rotate the screen 45º/90ª/180ª.



I also booted with wmi.debug_dump_wdg=1 and wmi.debug_event=1 on the kernel commandline to check if there was any events.
I did the sudo evtest test and the hotkeys in question registered. I selected number 3 in the list (see evtest.txt).

These are the events of the hotkeys in question:

Hotkey number 1 Microphone:

Event: time 1671569327.276408, type 4 (EV_MSC), code 4 (MSC_SCAN), value f1
Event: time 1671569327.276408, -------------- SYN_REPORT ------------
Event: time 1671569327.349220, type 4 (EV_MSC), code 4 (MSC_SCAN), value f1

Hotkey number 2 Camera:

Event: time 1671569327.656812, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671569327.656812, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 1
Event: time 1671569327.656812, -------------- SYN_REPORT ------------
Event: time 1671569327.729626, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671569327.729626, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 0

(Note, ignore this one since the key actually works)

Hotkey number 3 Power Mode:

Event: time 1671569328.108543, type 4 (EV_MSC), code 4 (MSC_SCAN), value 91
Event: time 1671569328.108543, -------------- SYN_REPORT ------------
Event: time 1671569328.110873, type 4 (EV_MSC), code 4 (MSC_SCAN), value 91

Hotkey number 4 Screen Rotation:

Event: time 1671569329.374406, type 4 (EV_MSC), code 4 (MSC_SCAN), value f2
Event: time 1671569329.374406, -------------- SYN_REPORT ------------
Event: time 1671569329.446527, type 4 (EV_MSC), code 4 (MSC_SCAN), value f2 



MSI Summit E16 Flip (A12UCT model) Alder Lake generation
OS Fedora 37
KDE Plasma Version: 5.26.4
KDE Frameworks Version: 5.101.0
Qt Version: 5.15.7
Kernel: 6.0.13
Wayland
Comment 1 André Barata 2022-12-20 22:32:44 UTC
Created attachment 303437 [details]
evtest
Comment 2 André Barata 2022-12-20 22:33:02 UTC
Created attachment 303438 [details]
smesg
Comment 3 André Barata 2022-12-20 22:33:51 UTC
3 files annexed: image, evtest.txt and dmseg.txt
Comment 4 Hans de Goede 2022-12-21 11:38:19 UTC
Thank you for the bug report.

Getting the 3 keys which don't send any events to work should be a matter of adding mappings for the MSI custom atkbd scancodes for these.

I'm going to attach a 60-keyboard.hwdb file here. Please copy this file to /etc/udev/hwdb.d and then run:

sudo systemd-hwdb update
sudo udevadm trigger /dev/input/event*

After this run "sudo evtest" again and select the "AT Translated Set 2 keyboard" again. Now all 4 keys should generate events.

And hopefully your desktop-environment will also respond to these events.
Comment 5 Hans de Goede 2022-12-21 11:38:40 UTC
Created attachment 303443 [details]
60-keyboard.hwdb
Comment 6 Hans de Goede 2022-12-21 11:45:53 UTC
About the camera on/off hotkey, when I asked you to see if there are any changes in evtest when toggling the camera on/off I meant any changes in the output of evtest for input3 / the "AT Translated Set 2 keyboard" input device.

I expect there won't be any changes there, which would be unfortunate because it would be nice if we could send different events for camera on vs camera off.

Talking about the camera, how does Fn + F6 work with the slider/switch on the side? I guess that if you turn of the camera with the slider that then Fn + F6 simply does not do anything?  IOW the slider overrides the Fn + F6 setting when the slider is in the camera-off position?
Comment 7 André Barata 2022-12-21 12:12:58 UTC
(In reply to Hans de Goede from comment #4)
> Thank you for the bug report.
> 
> Getting the 3 keys which don't send any events to work should be a matter of
> adding mappings for the MSI custom atkbd scancodes for these.
> 
> I'm going to attach a 60-keyboard.hwdb file here. Please copy this file to
> /etc/udev/hwdb.d and then run:
> 
> sudo systemd-hwdb update
> sudo udevadm trigger /dev/input/event*
> 
> After this run "sudo evtest" again and select the "AT Translated Set 2
> keyboard" again. Now all 4 keys should generate events.
> 
> And hopefully your desktop-environment will also respond to these events.

Thank you for responding!

So i did those steps but the desktop environment didn't respond and nothing happened (example: mute/unmute mic).

evtest showed the events though

Related to the camera, you are right the output is always the same when pressing the hotkey:

vent: time 1671624629.967592, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671624629.967592, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 1
Event: time 1671624629.967592, -------------- SYN_REPORT ------------
Event: time 1671624630.042611, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671624630.042611, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 0

Using the switch on the side of the keyboard gives me this:

Event: time 1671624717.066109, type 4 (EV_MSC), code 4 (MSC_SCAN), value d9
Event: time 1671624717.066109, -------------- SYN_REPORT ------------
Event: time 1671624717.068528, type 4 (EV_MSC), code 4 (MSC_SCAN), value d9
Event: time 1671624717.068528, -------------- SYN_REPORT ------------
Event: time 1671624718.487656, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671624718.487656, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 1
Event: time 1671624718.487656, -------------- SYN_REPORT ------------
Event: time 1671624718.490199, type 4 (EV_MSC), code 4 (MSC_SCAN), value ee
Event: time 1671624718.490199, type 1 (EV_KEY), code 212 (KEY_CAMERA), value 0

Off: d9, On: value 1 and 0
Comment 8 André Barata 2022-12-21 12:50:34 UTC
Oh yes, turning the camera switch off the hotkey does nothing. I guess it physicaly disconects the camera.
Comment 9 André Barata 2022-12-21 13:00:48 UTC
EDIT:

Restarted the computer and some of the hotkeys started working! 

The microphone hotkey (number 1 in the image) works now. The hotkey number 2 also works, it opens up system settings.

The screen rotation hotkey does nothing.
Comment 10 André Barata 2022-12-21 13:18:00 UTC
I found out that the rotation screen key now also works but it's not associated with any keyboard shortcut in system settings.

So to summarize, hotkeys that now work: 1. Mute/Unmute Microphone, 2. Camera On/Off (KDE doesn't notify the change), 3. Opens up System Settings (as a keyboard shortcut), 4. Screen Rotation Hotkey (Nothing happens because it's probably not associated with any keyboard shortcut).


So i think they are all working now Hans!

Just noticed something else (it's not that important). Some of the hotkeys have a led that doesn't turn on when i press them (see the led.jpg and led 2.jpg images).
Comment 11 André Barata 2022-12-21 13:18:23 UTC
Created attachment 303445 [details]
key led
Comment 12 André Barata 2022-12-21 13:18:39 UTC
Created attachment 303446 [details]
key led 2
Comment 13 Hans de Goede 2022-12-21 15:33:56 UTC
Good to hear that the hotkeys work now.

As for the mic/speaker mute LEDs, those are tricky. They can be either attached to the embedded-controller and then we would need support to register them under /sys/class/leds with their default triggers setup correctly, after which the kernel's HDA code shoould control them for us.

Or they may be directly connected to some GPIOs on the HDA part of the main SoC or on the codec.

And the Fn-lock LED typically just works automatically (controller by the EC) if you toggle the Fn-lock by pressing Fn + escape?  Although sometimes it too needs to be controller in software.

Figuring out the LEDs really requires someone with significant hw-enablement experience to actually have the laptop in their hands and then they will hopefully be able to figure things out.

I have submitted the fixes for the hotkeys upstream here:
https://github.com/systemd/systemd/pull/25824
Comment 14 André Barata 2022-12-21 15:51:06 UTC
(In reply to Hans de Goede from comment #13)
> Good to hear that the hotkeys work now.
> 
> As for the mic/speaker mute LEDs, those are tricky. They can be either
> attached to the embedded-controller and then we would need support to
> register them under /sys/class/leds with their default triggers setup
> correctly, after which the kernel's HDA code shoould control them for us.
> 
> Or they may be directly connected to some GPIOs on the HDA part of the main
> SoC or on the codec.
> 
> And the Fn-lock LED typically just works automatically (controller by the
> EC) if you toggle the Fn-lock by pressing Fn + escape?  Although sometimes
> it too needs to be controller in software.
> 
> Figuring out the LEDs really requires someone with significant hw-enablement
> experience to actually have the laptop in their hands and then they will
> hopefully be able to figure things out.
> 
> I have submitted the fixes for the hotkeys upstream here:
> https://github.com/systemd/systemd/pull/25824

Yeah if i FN + Escape tu led turns on :)

Well, what mattered was the hotkeys themselves and they are working now!

Thank you Hans!
Comment 15 André Barata 2023-03-22 13:58:17 UTC
Hi hans, sorry for bringing this issue again. 

Recently I switched desktop environments, specifically Fedora 37 Gnome from KDE. Since the 37 version of Fedora is using an older version of systemd i had to install the patch you provided here and the function keys are working (Fedora 38 has the latest systemd version with the patch included).

So the strange thing is, the disable/enable the touchpad function key F4 stopped working in Gnome for some reason. 

evtest detects the input but it doesn't do anything in gnome:

Event: time 1679493260.452112, -------------- SYN_REPORT ------------
Event: time 1679493265.334443, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time 1679493265.334443, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time 1679493265.334443, -------------- SYN_REPORT ------------
Event: time 1679493265.336519, type 4 (EV_MSC), code 4 (MSC_SCAN), value db
Event: time 1679493265.336519, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 1
Event: time 1679493265.336519, -------------- SYN_REPORT ------------
Event: time 1679493265.337277, type 4 (EV_MSC), code 4 (MSC_SCAN), value 76
Event: time 1679493265.337277, type 1 (EV_KEY), code 85 (KEY_ZENKAKUHANKAKU), value 1
Event: time 1679493265.337277, -------------- SYN_REPORT ------------
Event: time 1679493265.339611, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time 1679493265.339611, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time 1679493265.339611, -------------- SYN_REPORT ------------
Event: time 1679493265.342147, type 4 (EV_MSC), code 4 (MSC_SCAN), value db
Event: time 1679493265.342147, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 0
Event: time 1679493265.342147, -------------- SYN_REPORT ------------
Event: time 1679493265.343741, type 4 (EV_MSC), code 4 (MSC_SCAN), value 76
Event: time 1679493265.343741, type 1 (EV_KEY), code 85 (KEY_ZENKAKUHANKAKU), value 0
Event: time 1679493265.343741, -------------- SYN_REPORT ------------


How can i had this key to the patch you created for systemd here: https://github.com/systemd/systemd/pull/25824



Thank you Hans!
Comment 16 Hans de Goede 2023-03-27 13:31:53 UTC
That is weird.

You could try adding the following line to the list MSI keys in hwdb:

 KEYBOARD_KEY_55=f21

But as the evtest output shows scancode 85 / 0x55 is normally used for a key found on some Japanese keyboards and the Fn + F4 keypress is not just sending 0x55 it is sending windows-key + ctrl + 0x55 .

You say this did work under KDE ?
Comment 17 André Barata 2023-03-27 13:43:23 UTC
(In reply to Hans de Goede from comment #16)
> That is weird.
> 
> You could try adding the following line to the list MSI keys in hwdb:
> 
>  KEYBOARD_KEY_55=f21
> 
> But as the evtest output shows scancode 85 / 0x55 is normally used for a key
> found on some Japanese keyboards and the Fn + F4 keypress is not just
> sending 0x55 it is sending windows-key + ctrl + 0x55 .
> 
> You say this did work under KDE ?

Thanks for replying Hans!

Yes, it the shortcut worked on KDE but not in Gnome for some reason.


I updated the 60-keyboard.hwdb with the KEYBOARD_KEY_55=f21 line in the MSI section.

Then i did:
sudo systemd-hwdb update
sudo udevadm trigger /dev/input/event*

It still does nothing
Comment 18 André Barata 2023-03-27 13:45:37 UTC
I'am mainly using that key to turn off the touchpad when i'm using the laptop in tablet mode since it doesn't turn it off in that mode.
Comment 19 Hans de Goede 2023-03-27 14:05:49 UTC
Ugh, I got it wrong, the new line should be:

 KEYBOARD_KEY_76=f21

please give that a try I expect it will fix things.
Comment 20 André Barata 2023-03-27 14:13:39 UTC
(In reply to Hans de Goede from comment #19)
> Ugh, I got it wrong, the new line should be:
> 
>  KEYBOARD_KEY_76=f21
> 
> please give that a try I expect it will fix things.

Yep it's working now!

:)
Comment 21 André Barata 2023-03-27 14:36:09 UTC
Should i create a pull request in here?

https://github.com/systemd/systemd/pull/25824

cheers
Comment 22 Hans de Goede 2023-03-27 14:40:06 UTC
Great I have submitted a pull-request adding this here:

https://github.com/systemd/systemd/pull/27017
Comment 23 Hans de Goede 2023-03-27 14:41:22 UTC
I did not see your earlier comment, no need to create a pull-request since I just already did so myself :)
Comment 24 André Barata 2023-03-27 14:50:29 UTC
(In reply to Hans de Goede from comment #23)
> I did not see your earlier comment, no need to create a pull-request since I
> just already did so myself :)

Thank you Hans!!

Note You need to log in before you can comment on or make changes to this bug.