Skip to content

Commit 936e4d4

Browse files
jwrdegoededtor
authored andcommitted
Input: atkbd - skip ATKBD_CMD_GETID in translated mode
There have been multiple reports of keyboard issues on recent laptop models which can be worked around by setting i8042.dumbkbd, with the downside being this breaks the capslock LED. It seems that these issues are caused by recent laptops getting confused by ATKBD_CMD_GETID. Rather then adding and endless growing list of quirks for this, just skip ATKBD_CMD_GETID alltogether on laptops in translated mode. The main goal of sending ATKBD_CMD_GETID is to skip binding to ps/2 mice/touchpads and those are never used in translated mode. Examples of laptop models which benefit from skipping ATKBD_CMD_GETID: * "HP Laptop 15s-fq2xxx", "HP laptop 15s-fq4xxx" and "HP Laptop 15-dy2xxx" models the kbd stops working for the first 2 - 5 minutes after boot (waiting for EC watchdog reset?) * On "HP Spectre x360 13-aw2xxx" atkbd fails to probe the keyboard * At least 9 different Lenovo models have issues with ATKBD_CMD_GETID, see: https://github.com/yescallop/atkbd-nogetid This has been tested on: 1. A MSI B550M PRO-VDH WIFI desktop, where the i8042 controller is not in translated mode when no keyboard is plugged in and with a ps/2 kbd a "AT Translated Set 2 keyboard" /dev/input/event# node shows up 2. A Lenovo ThinkPad X1 Yoga gen 8 (always has a translated set 2 keyboard) Reported-by: Shang Ye <[email protected]> Closes: https://lore.kernel.org/linux-input/[email protected]/ Closes: https://github.com/yescallop/atkbd-nogetid Reported-by: gurevitch <[email protected]> Closes: https://lore.kernel.org/linux-input/2iAJTwqZV6lQs26cTb38RNYqxvsink6SRmrZ5h0cBUSuf9NT0tZTsf9fEAbbto2maavHJEOP8GA1evlKa6xjKOsaskDhtJWxjcnrgPigzVo=@gurevit.ch/ Reported-by: Egor Ignatov <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Reported-by: Anton Zhilyaev <[email protected]> Closes: https://lore.kernel.org/linux-input/[email protected]/ Closes: https://bugzilla.redhat.com/show_bug.cgi?id=2086156 Signed-off-by: Hans de Goede <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Torokhov <[email protected]>
1 parent c1f342f commit 936e4d4

File tree

1 file changed

+42
-4
lines changed

1 file changed

+42
-4
lines changed

drivers/input/keyboard/atkbd.c

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -765,6 +765,44 @@ static void atkbd_deactivate(struct atkbd *atkbd)
765765
ps2dev->serio->phys);
766766
}
767767

768+
#ifdef CONFIG_X86
769+
static bool atkbd_is_portable_device(void)
770+
{
771+
static const char * const chassis_types[] = {
772+
"8", /* Portable */
773+
"9", /* Laptop */
774+
"10", /* Notebook */
775+
"14", /* Sub-Notebook */
776+
"31", /* Convertible */
777+
"32", /* Detachable */
778+
};
779+
int i;
780+
781+
for (i = 0; i < ARRAY_SIZE(chassis_types); i++)
782+
if (dmi_match(DMI_CHASSIS_TYPE, chassis_types[i]))
783+
return true;
784+
785+
return false;
786+
}
787+
788+
/*
789+
* On many modern laptops ATKBD_CMD_GETID may cause problems, on these laptops
790+
* the controller is always in translated mode. In this mode mice/touchpads will
791+
* not work. So in this case simply assume a keyboard is connected to avoid
792+
* confusing some laptop keyboards.
793+
*
794+
* Skipping ATKBD_CMD_GETID ends up using a fake keyboard id. Using a fake id is
795+
* ok in translated mode, only atkbd_select_set() checks atkbd->id and in
796+
* translated mode that is a no-op.
797+
*/
798+
static bool atkbd_skip_getid(struct atkbd *atkbd)
799+
{
800+
return atkbd->translated && atkbd_is_portable_device();
801+
}
802+
#else
803+
static inline bool atkbd_skip_getid(struct atkbd *atkbd) { return false; }
804+
#endif
805+
768806
/*
769807
* atkbd_probe() probes for an AT keyboard on a serio port.
770808
*/
@@ -794,12 +832,12 @@ static int atkbd_probe(struct atkbd *atkbd)
794832
*/
795833

796834
param[0] = param[1] = 0xa5; /* initialize with invalid values */
797-
if (ps2_command(ps2dev, param, ATKBD_CMD_GETID)) {
835+
if (atkbd_skip_getid(atkbd) || ps2_command(ps2dev, param, ATKBD_CMD_GETID)) {
798836

799837
/*
800-
* If the get ID command failed, we check if we can at least set the LEDs on
801-
* the keyboard. This should work on every keyboard out there. It also turns
802-
* the LEDs off, which we want anyway.
838+
* If the get ID command was skipped or failed, we check if we can at least set
839+
* the LEDs on the keyboard. This should work on every keyboard out there.
840+
* It also turns the LEDs off, which we want anyway.
803841
*/
804842
param[0] = 0;
805843
if (ps2_command(ps2dev, param, ATKBD_CMD_SETLEDS))

0 commit comments

Comments
 (0)