From patchwork Mon Oct 6 23:21:47 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 536 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792994; bh=ax+Dsvg0SYFiwgp8yL3bFkjcO+U0dN1Dt5PMZwxarXY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YNJjxoFkJTGKKzTPx/3XoKeDHCGU+M32cxGPEfKPDHZ5+z1Z8wYqo80Mrr0nMPz24 nIDuE8FTHhJzQgClZ/Rf2O43pN8WcXY4kR4vus9UI/ylcku6XSyUeOHaz+h/lYxl70 E7Vvg2UL8A+odjguViAPGdaoEA36G/hYoN4CQjenqMikoRjHuGxhxZJm844gSOUfyF bOqTq6fZPibpp3Rsarc0cVqVgMCQk5ZCMxpL+pP0DxiVkhUuc+0lnxyG2GyM71IZGu Npy8QFYL9ohetS7DL0MaI7/Ir18QmcJXvA3JGlQSbXkp/c3aVP8H6vUsjkWGyhD6lD wkP3ojtAH2brA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1301467FC6 for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id kdWWwPMa3lOT for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792994; bh=ax+Dsvg0SYFiwgp8yL3bFkjcO+U0dN1Dt5PMZwxarXY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=YNJjxoFkJTGKKzTPx/3XoKeDHCGU+M32cxGPEfKPDHZ5+z1Z8wYqo80Mrr0nMPz24 nIDuE8FTHhJzQgClZ/Rf2O43pN8WcXY4kR4vus9UI/ylcku6XSyUeOHaz+h/lYxl70 E7Vvg2UL8A+odjguViAPGdaoEA36G/hYoN4CQjenqMikoRjHuGxhxZJm844gSOUfyF bOqTq6fZPibpp3Rsarc0cVqVgMCQk5ZCMxpL+pP0DxiVkhUuc+0lnxyG2GyM71IZGu Npy8QFYL9ohetS7DL0MaI7/Ir18QmcJXvA3JGlQSbXkp/c3aVP8H6vUsjkWGyhD6lD wkP3ojtAH2brA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0337567F1D for ; Mon, 6 Oct 2025 17:23:14 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792991; bh=JAdAVzzwTmGfRffADrpU6A6AjORY1N4WPNUKz2Y/hR0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AwwDBMmKopfdm7WQ1LZ4RgNHigKrN4nxgaqH5JCKJ9ylkpzfgm9xDf4ejqct3CIps txKqLuycgL00UxRjM1Zaj2o+MfNFl9uUWsYWp78VX6n1aKEMU+3M2fzL5br/DhCor4 /qpmuK/BzYgjy30mlSwHU+Z1ALDYuO36nWkyJj9Hw9uMMR8BNICpuQ40HejKMOnNSU D1LV13P6WCe2U+HVRW7dc398FbTGEWexOLF1GZe0dclA1R5akkPZE/ZJJCfUwDdKlW l5yynzUiRjzzI6JXhxetSeNKsZx4O7nAZCVApbWDMqxSN47ubnQjLufWNK0GRy5vUs CKwfperWZF9Jg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DC06F67DB4; Mon, 6 Oct 2025 17:23:11 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id HvGpP2khfR2Q; Mon, 6 Oct 2025 17:23:11 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759792987; bh=hpGXOz/BkZCfMUqtiYT+hf4+k9w8R4YJ0sy+cqMbdKM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nm6VIhzbFrvPIMXMN5eem4eGp9m25jBNeM43iJZ+n0iVQzvY9eCWQKc0lF6BBVYLU nxsvCjk9YtvV1uDrgm/qIXwk/A7aaHP+tuFA0OYhBcHFbbS+csnh9EsCXjsD4LKMbQ CgFQUiliI7jmOODpVhNWAg6xu5rahrd6Fp4sZlVMLR0BkXNyjZW+XClrociNDmkndq ZEXO0bzuhxvjVi31oyCE2Xz6lrw4hBDUd1RX5RTpxAhTleXE8wa1Wpesed4jhOwERQ 3I8Iack6EcjoKgpjkB4RCiSe1X0Nk7rKh58efMfwAtHosC65mf0rd1QXxD+D8/mEeX kO07BA2Y5SbUA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 1E72C67FC6; Mon, 6 Oct 2025 17:23:07 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 6 Oct 2025 17:21:47 -0600 Message-ID: <20251006232236.2091941-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251006232236.2091941-1-sjg@u-boot.org> References: <20251006232236.2091941-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: K5EFZPT3YCOHPFEGCZOU7NV7WRFOKCOY X-Message-ID-Hash: K5EFZPT3YCOHPFEGCZOU7NV7WRFOKCOY X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/17] expo: Speed up polling the keyboard List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass The current algorithm spends 10ms or more looking for keyboard input. Since we expect the frame rate to be 50 or more, it should be OK to only check once. Handle the timeout by recording the timestamp of the last key and timing out the CLI entry after 10ms. This allows an 'Escape' key to work, rather than it just waiting forever for a terminal sequence that starts with escape. Signed-off-by: Simon Glass --- boot/expo.c | 16 ++++++++-------- include/expo.h | 2 ++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/boot/expo.c b/boot/expo.c index ebe31059e87..5704dd9fecc 100644 --- a/boot/expo.c +++ b/boot/expo.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -45,6 +46,7 @@ int expo_new(const char *name, void *priv, struct expo **expp) INIT_LIST_HEAD(&exp->str_head); exp->next_id = EXPOID_BASE_ID; cli_ch_init(&exp->cch); + exp->last_key_ms = get_timer(0); *expp = exp; @@ -488,21 +490,19 @@ static int poll_keys(struct expo *exp) ichar = cli_ch_process(&exp->cch, 0); if (!ichar) { - int i; - - for (i = 0; i < 10 && !ichar && !tstc(); i++) { - schedule(); - mdelay(2); - ichar = cli_ch_process(&exp->cch, -ETIMEDOUT); - } - while (!ichar && tstc()) { + /* Check once for available input */ + if (tstc()) { ichar = getchar(); ichar = cli_ch_process(&exp->cch, ichar); } + + if (!ichar && get_timer(exp->last_key_ms) >= 10) + ichar = cli_ch_process(&exp->cch, -ETIMEDOUT); } key = 0; if (ichar) { + exp->last_key_ms = get_timer(0); key = bootmenu_conv_key(ichar); if (key == BKEY_NONE || key >= BKEY_FIRST_EXTRA) key = ichar; diff --git a/include/expo.h b/include/expo.h index e9e71f4fe36..b51d946f367 100644 --- a/include/expo.h +++ b/include/expo.h @@ -146,6 +146,7 @@ struct expo_theme { * @scene_head: List of scenes * @str_head: list of strings * @cch: Keyboard context for input + * @last_key_ms: timestamp of the last key received */ struct expo { char *name; @@ -173,6 +174,7 @@ struct expo { struct list_head scene_head; struct list_head str_head; struct cli_ch_state cch; + ulong last_key_ms; }; /**