From 15790b1e1adca68a0c943bcac78c6badce601ea6 Mon Sep 17 00:00:00 2001 From: Connor-GH Date: Tue, 10 Mar 2026 14:19:11 -0500 Subject: [PATCH] ps2d: disable keyboard before running self test Beforehand, if you spammed 'enter' (or any key) upon startup, your self test would fail with 1C or 9C (the scancodes for pressing and releasing enter respectively). We now disable the keyboard earlier, and this fixes the issue. --- drivers/input/ps2d/src/controller.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/drivers/input/ps2d/src/controller.rs b/drivers/input/ps2d/src/controller.rs index 28982cccd3..7a34e5b604 100644 --- a/drivers/input/ps2d/src/controller.rs +++ b/drivers/input/ps2d/src/controller.rs @@ -291,17 +291,6 @@ impl Ps2 { } } - self.retry(format_args!("keyboard defaults"), 4, |x| { - // Set defaults and disable scanning - let b = x.keyboard_command(KeyboardCommand::SetDefaultsDisable)?; - if b != 0xFA { - error!("keyboard failed to set defaults: {:02X}", b); - return Err(Error::CommandRetry); - } - - Ok(b) - })?; - { // Set scancode set to 2 let scancode_set = 2; @@ -334,6 +323,19 @@ impl Ps2 { self.set_config(config)?; } + // The keyboard seems to still collect bytes even when we disable + // the port, so we must disable the keyboard too + self.retry(format_args!("keyboard defaults"), 4, |x| { + // Set defaults and disable scanning + let b = x.keyboard_command(KeyboardCommand::SetDefaultsDisable)?; + if b != 0xFA { + error!("keyboard failed to set defaults: {:02X}", b); + return Err(Error::CommandRetry); + } + + Ok(b) + })?; + { // Perform the self test self.command(Command::TestController)?;