Skip to content

Instantly share code, notes, and snippets.

@surhudm
Last active May 1, 2022 10:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save surhudm/fd85edc531cdc41ca9ccda3b418e2a90 to your computer and use it in GitHub Desktop.
Save surhudm/fd85edc531cdc41ca9ccda3b418e2a90 to your computer and use it in GitHub Desktop.

Solving HP 1040 G6 Elitebook keyboard issues in Linux

Got a new HP 1040 G6. Most things work out of the box with Fedora, but I saw the following issues

  • Input from the keyboard.
    • Brightness keys do not work.
    • Mute button does not work.
    • Calendar button does not work.
    • Presentation button does not work.
    • Call receive and call end buttons do not work.
  • Fingerprint sensor does not work.

I looked at the keycodes that were being registered when these keys are pressed by doing the following:

sudo evtest

After selecting the input keyboard, test the scan codes sent by each key.

# Brightness key up/down
Event: time xxxxx.xxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 81
Event: time xxxxx.xxxxx, type 1 (EV_KEY), code 465 (KEY_FN_ESC), value 1
Event: time xxxxx.xxxxx, -------------- SYN_REPORT ------------
Event: time xxxxx.xxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 81
Event: time xxxxx.xxxxx, type 1 (EV_KEY), code 465 (KEY_FN_ESC), value 0
# Mic mute button
Event: time xxxxx.xxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 81
Event: time xxxxx.xxxxx, type 1 (EV_KEY), code 465 (KEY_FN_ESC), value 1
Event: time xxxxx.xxxxx, -------------- SYN_REPORT ------------
Event: time xxxxx.xxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 81
Event: time xxxxx.xxxxx, type 1 (EV_KEY), code 465 (KEY_FN_ESC), value 0
Event: time xxxxx.xxxxx, -------------- SYN_REPORT ------------
Event: time xxxxx.xxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 42
# Monitor
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 64
# Call receive 
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 66
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value db
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 1
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 66
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value db
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 125 (KEY_LEFTMETA), value 0
# Call end
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 1
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 1
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 65
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 1d
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 29 (KEY_LEFTCTRL), value 0
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 38
Event: time xxxxxx.xxxxxx, type 1 (EV_KEY), code 56 (KEY_LEFTALT), value 0
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------
Event: time xxxxxx.xxxxxx, type 4 (EV_MSC), code 4 (MSC_SCAN), value 65
Event: time xxxxxx.xxxxxx, -------------- SYN_REPORT ------------

Running dmesgthrows up the following output:

[17682.423746] atkbd serio0: Unknown key pressed (translated set 2, code 0x6d on isa0060/serio0).
[17682.423750] atkbd serio0: Use 'setkeycodes 6d <keycode>' to make it known.
[17682.559728] atkbd serio0: Unknown key released (translated set 2, code 0x6d on isa0060/serio0).
[17682.559733] atkbd serio0: Use 'setkeycodes 6d <keycode>' to make it known.
[17693.041406] atkbd serio0: Unknown key pressed (translated set 2, code 0x66 on isa0060/serio0).
[17693.041411] atkbd serio0: Use 'setkeycodes 66 <keycode>' to make it known.
[17693.194005] atkbd serio0: Unknown key released (translated set 2, code 0x66 on isa0060/serio0).
[17693.194010] atkbd serio0: Use 'setkeycodes 66 <keycode>' to make it known.
[17696.985813] atkbd serio0: Unknown key pressed (translated set 2, code 0x65 on isa0060/serio0).
[17696.985818] atkbd serio0: Use 'setkeycodes 65 <keycode>' to make it known.
[17697.127398] atkbd serio0: Unknown key released (translated set 2, code 0x65 on isa0060/serio0).
[17697.127404] atkbd serio0: Use 'setkeycodes 65 <keycode>' to make it known.

Thus I observed the following:

  1. Pressing either of brightness up/down keys generates the same exact key sequence.
  2. Pressing Mic mute, Monitor, Call recv and Call end buttons produces multiple key sequences.

The keys 65, 66, 6d corresponding to call end, call recv and monitor are not even mapped to anything. First find out the vendor product, version for the keyboard, so that we can make a new remapping. My idea would be to try to get the mic mute to work by itself. But remap the Call recv and Call end buttons to Brightness up/down buttons.

cat /proc/bus/input/devices

Search Vendor, production and version. Create a hwdb file.

#HWDB file: Save as /etc/udev/hwdb.d/99-ATK-keyboard.hwdb, replace your own bus number, vendor number and production number
evdev:input:b{bus number}v{vendor number}p{production number}*
 KEYBOARD_KEY_66=brightnessdown
 KEYBOARD_KEY_65=brightnessup
 KEYBOARD_KEY_81=f20

After this run:

sudo systemd-hwdb update && sudo udevadm trigger

Now the mic mute button will start working (however since the original brightness buttons are generating the same scancode (81), they also get mapped to micmute.

For getting the brightnessup/down keys recognized (remember we are going to remap the Call Recv and Call End keys now to brightness keys), I had to use acpi. Enable acpid at boot.

sudo systemctl enable acpid.service

Now let us set up acpi scripts to deal with brightness. These have been modified from here.

Save this file as /etc/acpi/actions/CallEnd-brightnessup.sh

#!/bin/bash 
  
# Set the static increment value.  Keep in mind that this will 
# be done twice. 
IncVal=2000

# Get the Maximum value for use. 
#MaxVal=$(cat /sys/class/backlight/intel_backlight/max_brightness); 
read -r MaxVal < "/sys/class/backlight/intel_backlight/max_brightness"

# Get the current brightness value. 
#CurrVal=$(cat /sys/class/backlight/intel_backlight/brightness); 
read -r CurrVal < "/sys/class/backlight/intel_backlight/brightness"

# Set the new value minus the decrement value. 
NewVal=$(($CurrVal + $IncVal));
echo $NewVal 

# Set it to the threshold of the max value. 
ThresholdVal=$(($NewVal<$MaxVal?$NewVal:$MaxVal))
echo $ThresholdVal 

# Set the new value directly. 
echo -n $ThresholdVal > /sys/class/backlight/intel_backlight/brightness

logger "[ACPI] brightnessup |$CurrVal| |$NewVal| |$ThresholdVal|"

Save this file as /etc/acpi/actions/CallRecv-brightnessdown.sh


# Set the static decrement value.  Keep in mind that this will 
# be done twice. 
DecVal=2000

# Set the Minimum we will accept. 
MinVal=0 

# Get the current brightness value. 
#CurrVal=$(cat /sys/class/backlight/intel_backlight/brightness); 
read -r CurrVal < "/sys/class/backlight/intel_backlight/brightness"

# Set the new value minus the decrement value. 
NewVal=$(($CurrVal - $DecVal)); 
echo $NewVal 

# Set it to the threshold of the min value. 
ThresholdVal=$(($NewVal>$MinVal?$NewVal:$MinVal)) 
echo $ThresholdVal 

# Set the new value directly. 
echo -n $ThresholdVal > /sys/class/backlight/intel_backlight/brightness 

logger "[ACPI] brightnessdown |$CurrVal| |$NewVal| |$ThresholdVal|"

Add the following events to the acpi actions.

Save this file as /etc/acpi/events/CallRecv-brightnessdown

event=video/brightnessdown
action=/etc/acpi/actions/CallRecv-brightnessdown.sh

Save this file as /etc/acpi/events/CallEnd-brightnessup

event=video/brightnessup
action=/etc/acpi/actions/CallEnd-brightnessup.sh

After reboot, I could see that I could use the mic mute button, and the call receive and call end buttons to control the brightness of the screen. Yay! At least some usability.

The fingerprint sensor does not work, Synaptics does not provide a linux driver for it 06cb:00b7 :(, hopefully someone will reverse engineer it some day. Please let me know if you find someone doing it.

@Masteroduo
Copy link

Hi, Did you manage to make the brightness key work for brightness instead of using a different key for it? even I have a similar laptop and the both the brightness keys show the same scan code so I have resorted to using Super+F2 and Super+F3 to change brightness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment