From patchwork Tue Oct 7 17:05:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 555 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=1759856798; bh=Vl+vcAwRVnxUzPXmo3tJmEI5dUNo1RwzEYdspQv0XeA=; 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=Aj+JHK6bojO/ObwVz/BeaBrz/wq8uX+j7nMAE2ZXtGI/vL4sXQwdcQ+XBD0K+8cBX SmTbCskEeXZrYRxxXB/pb3Rn+qbEt8ljwyy6zt5stLrVYFI16ad8H3i20bJ/EIVP2a VwgxfjLMUuNLoMkvwAt9PuoNuUmx/By6D/gaCI5wrq0i1C6TiAKdcrDu82fycPHc9F NXWU/k1dVspwTVgwejrD3NLxKZD2CfpXN1P41S9Dqx1aWBFf+xchc0jJny2KeCE+TX HlJbkqGW4WUR2sNMAwvnVrEl9BpnAhkIB9ISTnVV0vShe5CMNpF2n7tQ8/AS46JxgC t+lNWnS6t/gGw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EDD2967EE5 for ; Tue, 7 Oct 2025 11:06:38 -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 u8w86EUwQAEB for ; Tue, 7 Oct 2025 11:06:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856797; bh=Vl+vcAwRVnxUzPXmo3tJmEI5dUNo1RwzEYdspQv0XeA=; 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=hl8BM7VSUmFJ71X1sSAB+Uf9l+EEtiXLc+hE6VeJo2PsSe6UwxadmSi3OGGbMkSGh CtSxCdq7ZbrmZSCGVnJUEzTsbtquHR+VDr1MGYlcxCgHw2fug0fHlp3w8KrWPHz/EZ AxbA5uKS1J/fynUST+AUYIoAGJP7rDrJrSzKl6+dlyh9DuOKYB9o6zOrR9dJcr7wvu ZGOkaR26eJG5DK2lMbTV2BVHa1S+gRP4if+ymMpBjtEYbcZqZRdpsf31oPqenea2ds FIcd9AEhLUEGQxTg08ooYIpQAnihrf1/TodZOQOsZnnKjm84M/i7MNKyF5mFXaglSx wy0/hBbEfaoFA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 49E7A67F1E for ; Tue, 7 Oct 2025 11:06:37 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856795; bh=9y/RFK9Xxmn3CypdcSHMz6nvPGH3UFO6UXxX9x1wzok=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZiZNI7ZW9wnOXyoZtErOdHm43ReSqMQwQ3wG6C3RW1vUbONom2xbN/froUl2crk/ aq/1+yjufQJHJUr/6Xec6e85dHVM71V0PB4/r7iGu5b+pyBfqbiOaKFwXBwDy9VJ14 B7w6L8tJQPHGmV/Vw/8jE9MOWJoK9f7llaGAE/DuVdtSO4zpA1Ow/11fyXlVuMcXQT ROv7syhYhcICm9MQpiaMs4AKyrrtJEqOjc+AwqKCEpqHgAP5uvlL5Pdq6nQKdj5rnq r1CohcV20E4tUR455Z+wg21+ubGkvuRuPQzpZYoqyM6XT/qlZD7cEhIzA2jJKN/+wD 296rr5zhqR7Vw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E543D67F72; Tue, 7 Oct 2025 11:06:35 -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 wCn1mFcp5-PF; Tue, 7 Oct 2025 11:06:35 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759856793; bh=Jm7L6PMvDeappSLVVeQkylLoWAh7rp5+cekUV/hLRr0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RFH7rfTmHqlyoI+IMLtYWwrzH42plyCqzTzM0m0sxHKlVU3dBUY3NMhdTYggI4dbu L9xK1qbxU4aA71io4C+bq5uQYxCwtc/6meDF3alOA1koWzQZeBdhIw1Ourhvcy1x9o 7xnKMjETB9A/e/o6wbuVj2TyW1kI1GVKZon0IfaiW2BNVcws3e/mESQtygZDBBOcf8 26LBo/gyW02Uf3HjS2iHTxjVPdwdHje2nDAmcbceD5XqUqJoJL6TU4H5WCH/AhKSt8 zMcYq/Smw/DHUll3+jKdlXc6+JIz3ZIhFUuqTKZD+cHLIGJme0Ve0HRf2vKiRjicfD 3SUKkhfj2bbOw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D9BA367F1E; Tue, 7 Oct 2025 11:06:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 7 Oct 2025 11:05:22 -0600 Message-ID: <20251007170549.541981-9-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251007170549.541981-1-sjg@u-boot.org> References: <20251007170549.541981-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: BUZIKCG44UT2U776Y6HFF3U3PTPZYNLZ X-Message-ID-Hash: BUZIKCG44UT2U776Y6HFF3U3PTPZYNLZ 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 v2 08/20] 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 --- (no changes since v1) 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; }; /**