Skip to content

Commit 31456ff

Browse files
committed
platform/x86: thinkpad_acpi: Use correct keycodes for volume and brightness keys
Change the default keymap to report the correct keycodes for the volume and brightness keys. Reporting key events for these is already filtered out by the hotkey_reserved_mask which masks these keys out of hotkey_user_mask at initialization time, so there is no need to also map them to KEY_RESERVED. This avoids users, who want these to be reported, having to also remap the keycodes on top of overriding hotkey_user_mask to report these and Linux userspace has already been overriding the KEY_RESERVED mappings with the correct keycodes through udev/hwdb/60-keyboard.hwdb for years now. Also drop hotkey_unmap() it was only used to dynamically map the brightness keys to KEY_RESERVED and after removing that it has no remaining users. Tested-by: Mark Pearson <[email protected]> Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Mark Pearson <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent d3272c7 commit 31456ff

File tree

1 file changed

+21
-24
lines changed

1 file changed

+21
-24
lines changed

drivers/platform/x86/thinkpad_acpi.c

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3097,15 +3097,6 @@ static void hotkey_exit(void)
30973097
mutex_unlock(&hotkey_mutex);
30983098
}
30993099

3100-
static void __init hotkey_unmap(const unsigned int scancode)
3101-
{
3102-
if (hotkey_keycode_map[scancode] != KEY_RESERVED) {
3103-
clear_bit(hotkey_keycode_map[scancode],
3104-
tpacpi_inputdev->keybit);
3105-
hotkey_keycode_map[scancode] = KEY_RESERVED;
3106-
}
3107-
}
3108-
31093100
/*
31103101
* HKEY quirks:
31113102
* TPACPI_HK_Q_INIMASK: Supports FN+F3,FN+F4,FN+F12
@@ -3224,22 +3215,28 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
32243215
KEY_UNKNOWN, /* 0x0D: FN+INSERT */
32253216
KEY_UNKNOWN, /* 0x0E: FN+DELETE */
32263217

3227-
/* brightness: firmware always reacts to them */
3228-
KEY_RESERVED, /* 0x0F: FN+HOME (brightness up) */
3229-
KEY_RESERVED, /* 0x10: FN+END (brightness down) */
3218+
/* brightness: firmware always reacts to them.
3219+
* Suppressed by default through hotkey_reserved_mask.
3220+
*/
3221+
KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */
3222+
KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */
32303223

3231-
/* Thinklight: firmware always react to it */
3232-
KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
3224+
/* Thinklight: firmware always react to it.
3225+
* Suppressed by default through hotkey_reserved_mask.
3226+
*/
3227+
KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */
32333228

32343229
KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
32353230
KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
32363231

32373232
/* Volume: firmware always react to it and reprograms
32383233
* the built-in *extra* mixer. Never map it to control
3239-
* another mixer by default. */
3240-
KEY_RESERVED, /* 0x14: VOLUME UP */
3241-
KEY_RESERVED, /* 0x15: VOLUME DOWN */
3242-
KEY_RESERVED, /* 0x16: MUTE */
3234+
* another mixer by default.
3235+
* Suppressed by default through hotkey_reserved_mask.
3236+
*/
3237+
KEY_VOLUMEUP, /* 0x14: VOLUME UP */
3238+
KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */
3239+
KEY_MUTE, /* 0x16: MUTE */
32433240

32443241
KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
32453242

@@ -3282,7 +3279,8 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
32823279
KEY_BRIGHTNESSUP, /* 0x0F: FN+HOME (brightness up) */
32833280
KEY_BRIGHTNESSDOWN, /* 0x10: FN+END (brightness down) */
32843281

3285-
KEY_RESERVED, /* 0x11: FN+PGUP (thinklight toggle) */
3282+
/* Suppressed by default through hotkey_reserved_mask. */
3283+
KEY_KBDILLUMTOGGLE, /* 0x11: FN+PGUP (thinklight toggle) */
32863284

32873285
KEY_UNKNOWN, /* 0x12: FN+PGDOWN */
32883286
KEY_ZOOM, /* 0x13: FN+SPACE (zoom) */
@@ -3297,10 +3295,11 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
32973295
* change unless you get test reports from all Lenovo
32983296
* models. May cause the BIOS to interfere with the
32993297
* HDA mixer.
3298+
* Suppressed by default through hotkey_reserved_mask.
33003299
*/
3301-
KEY_RESERVED, /* 0x14: VOLUME UP */
3302-
KEY_RESERVED, /* 0x15: VOLUME DOWN */
3303-
KEY_RESERVED, /* 0x16: MUTE */
3300+
KEY_VOLUMEUP, /* 0x14: VOLUME UP */
3301+
KEY_VOLUMEDOWN, /* 0x15: VOLUME DOWN */
3302+
KEY_MUTE, /* 0x16: MUTE */
33043303

33053304
KEY_VENDOR, /* 0x17: Thinkpad/AccessIBM/Lenovo */
33063305

@@ -3599,8 +3598,6 @@ static int __init hotkey_init(struct ibm_init_struct *iibm)
35993598
* for userspace to do something even remotely sane */
36003599
hotkey_reserved_mask |= TP_ACPI_HKEY_BRGHTUP_MASK |
36013600
TP_ACPI_HKEY_BRGHTDWN_MASK;
3602-
hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNHOME);
3603-
hotkey_unmap(TP_ACPI_HOTKEYSCAN_FNEND);
36043601
}
36053602

36063603
#ifdef CONFIG_THINKPAD_ACPI_HOTKEY_POLL

0 commit comments

Comments
 (0)