From patchwork Tue Jan 20 23:17:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1678 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=1768951138; bh=6KBTv7ZW07mjwekShSbuH8LK1Cc0A5E0wAwIr0T5G0Q=; 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=Rt7/MtErhgbT3zTtRBEQlmcP8i2Xwap5jcfflMWdglC0C2qmWZ2GZesZtCfY7vtXu UgugUvGqG1cYoX0xlvSB+Ttncjhxx2RAVNmAQX37I23JkTjs74tLZ6BE6dlEWiT477 8mfROjan3pXWxWFyWXWm90lidUYHI4/KdZMGGT7rkapyJW9MIb3NyprMQd1YoGTqeQ QfAjiIpWHNUm4kSn1uorGcDYGADIX1jXBtnYHa13gXjUVz9DSkfLD4HclGptbW9lmR DjKb3cUGLHpmofzwDvhrJy1VfFaLWcR0J+zQ/IkaHJWpJgUO7WOffRXMNt5AURQ8JF zGW53FFzwCBgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1515769588 for ; Tue, 20 Jan 2026 16:18:58 -0700 (MST) 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 nfxco82yTgUt for ; Tue, 20 Jan 2026 16:18:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951137; bh=6KBTv7ZW07mjwekShSbuH8LK1Cc0A5E0wAwIr0T5G0Q=; 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=HW6Sjz3roUzzw6Os9MEgYPq0+CRnRAlKR+C/WjL9AeOSX/oapGTLB7jG7ndksOts1 UCgm7RHBqMAb7htKmwrbFTDBQQ4F/pXBeR0mF7STpGpGWEmxWLJae02atrfv7n048Z bH+MUIRwb8JbkEb4yYpWqDHxjTA2j/7Y2YfB5YxwZbBRU8EcAHovUt6+kAKH+Geijz dqRK8W7aWFymlS6lDnMTxDjaLOYDpbpJr91ohMz+/atvqO8+/jMR6jqML3A34YXAgH oSqehs6W08xgo3QzZSRzuJDPyaI27IioE6D6Oq6ACSpJTezwwc9sr4uko+cFAZLH+W 8oLaqPCQGLo6Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F34496957E for ; Tue, 20 Jan 2026 16:18:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951136; bh=zYzqlCGkLg88bU0yx7YxlrvT27oHSxMOL1HfFyGPkRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mpYRS3Ty+jM/Jdtx07YfqrnUaOueIBD5EVC7x66Sml5HDS/trZY61YP63umFmKb0b QdRBf46ckFVRqYmH9n/8v7ZDvwZ+3CUuwIfpewMMqV1rsMpBf2HWfIofk7Sh6Ko9tB V3Sw+uEITVmqaW0RA8zVybvsFMFD3Sa+3u/jdKzhlUtC0qpV3UR2AIHHz3Hgmq/f28 TjSozYMUlqwhr82mH5i123RlqEr4thQgKT5fEWXjjl5lQYTJ5hzUbsouSaRiLgL8ZF /PEQTWtp9JilwR/9lF1hkgS07RWNvHH1dIqtzoCXzohhnmV2hPfXRr+vpwNLGhzTuY S4Z1Xox403lwA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19EDC69572; Tue, 20 Jan 2026 16:18:56 -0700 (MST) 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 RW6LaRLuAdkn; Tue, 20 Jan 2026 16:18:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951132; bh=8s3VurdgQDfe8Tr8RP0JRjYguLIZgVWB6cMyNBPUbM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8sCqhFUwRt1eAftoMlo1sCF2UWk2e4I6bxCP9lG1ckuIh2emvxUnkKmhRSJ+3yGI 4kfjwJuxd2X52N7qZi4fzGBxkOVUPIaPkSJmWa0UKq5OWMVbV+5P3uZ892kHMeEx7Y DsljhZ5We9wO2/KMCsy1eeZK1kRhsmFxxf8IQlltwWyBjL0BQmpj/aXy+fnKy27A3C lm7bYP2UpXnk1qIzZx/h4FhRnp0PXexDGN69QqNM+LFC2G+L7PRSXpuGekpLLqW057 4QAnlkYUXpZnciFeQ/XltWKKYjfEioUzAvdnDo7/JknGBzfeECHwB3QkwUbVyRRRB5 Yeo/jw+lZDy4w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B47206913F; Tue, 20 Jan 2026 16:18:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:32 -0700 Message-ID: <20260120231814.2033069-6-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260120231814.2033069-1-sjg@u-boot.org> References: <20260120231814.2033069-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 4IDZFQKGDAXA5C6NROU342LCG363Q7YN X-Message-ID-Hash: 4IDZFQKGDAXA5C6NROU342LCG363Q7YN 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: Simon Glass , "Claude Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 05/36] video: Add per-device vidconsole_readline_start/end() 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 Add vidconsole_readline_start() and vidconsole_readline_end() functions that operate on a single device. Rename the existing functions that iterate all consoles to have an _all suffix. Update scene_txtin.c to use the per-device versions with the expo's console, and cli_readline.c to use the _all versions. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 4 ++-- common/cli_readline.c | 4 ++-- drivers/video/vidconsole-uclass.c | 36 +++++++++++++++++----------- include/video_console.h | 39 ++++++++++++++++++++++++++----- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index b5413dc145f..2b72ecaed39 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -107,7 +107,7 @@ static void scene_txtin_putch(struct cli_line_state *cls, int ch) void scene_txtin_close(struct scene *scn) { /* cursor is not needed now */ - vidconsole_readline_end(); + vidconsole_readline_end(scn->expo->cons); } int scene_txtin_open(struct scene *scn, struct scene_obj *obj, @@ -137,7 +137,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, return log_msg_ret("sav", ret); /* make sure the cursor is visible */ - vidconsole_readline_start(true); + vidconsole_readline_start(cons, true); return 0; } diff --git a/common/cli_readline.c b/common/cli_readline.c index 0173072109b..27fecd835a0 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -710,7 +710,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, puts(prompt); /* tell the vidconsole the cursor is at its start position */ - vidconsole_readline_start(false); + vidconsole_readline_start_all(false); rc = cread_line(prompt, p, &len, timeout); rc = rc < 0 ? rc : len; @@ -721,7 +721,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, pager_set_bypass(gd_pager(), old_bypass); pager_reset(gd_pager()); - vidconsole_readline_end(); + vidconsole_readline_end_all(); return rc; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 679d5d46f81..200bc60c55b 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -1019,30 +1019,38 @@ void vidconsole_idle(struct udevice *dev) } #ifdef CONFIG_CURSOR -void vidconsole_readline_start(bool indent) +void vidconsole_readline_start(struct udevice *dev, bool indent) { - struct uclass *uc; - struct udevice *dev; + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); - uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + ctx->curs.indent = indent; + ctx->curs.enabled = true; + vidconsole_mark_start(dev); +} - ctx->curs.indent = indent; - ctx->curs.enabled = true; - vidconsole_mark_start(dev); - } +void vidconsole_readline_end(struct udevice *dev) +{ + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + + ctx->curs.enabled = false; } -void vidconsole_readline_end(void) +void vidconsole_readline_start_all(bool indent) { struct uclass *uc; struct udevice *dev; - uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) + vidconsole_readline_start(dev, indent); +} - ctx->curs.enabled = false; - } +void vidconsole_readline_end_all(void) +{ + struct uclass *uc; + struct udevice *dev; + + uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) + vidconsole_readline_end(dev); } #endif /* CURSOR */ diff --git a/include/video_console.h b/include/video_console.h index bb0445dc7c9..663f89b25f2 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -591,22 +591,41 @@ int vidconsole_show_cursor(struct udevice *dev); int vidconsole_hide_cursor(struct udevice *dev); /** - * vidconsole_readline_start() - Enable cursor for all video consoles + * vidconsole_readline_start() - Enable cursor for a video console + * + * Called at the start of command line input to show the cursor + * + * @dev: vidconsole device + * @indent: indent subsequent lines to the same position as the first line + */ +void vidconsole_readline_start(struct udevice *dev, bool indent); + +/** + * vidconsole_readline_end() - Disable cursor for a video console + * + * Called at the end of command line input to hide the cursor + * + * @dev: vidconsole device + */ +void vidconsole_readline_end(struct udevice *dev); + +/** + * vidconsole_readline_start_all() - Enable cursor for all video consoles * * Called at the start of command line input to show cursors on all * active video consoles * * @indent: indent subsequent lines to the same position as the first line */ -void vidconsole_readline_start(bool indent); +void vidconsole_readline_start_all(bool indent); /** - * vidconsole_readline_end() - Disable cursor for all video consoles + * vidconsole_readline_end_all() - Disable cursor for all video consoles * * Called at the end of command line input to hide cursors on all * active video consoles */ -void vidconsole_readline_end(void); +void vidconsole_readline_end_all(void); #else static inline int vidconsole_show_cursor(struct udevice *dev) { @@ -618,11 +637,19 @@ static inline int vidconsole_hide_cursor(struct udevice *dev) return 0; } -static inline void vidconsole_readline_start(bool indent) +static inline void vidconsole_readline_start(struct udevice *dev, bool indent) +{ +} + +static inline void vidconsole_readline_end(struct udevice *dev) +{ +} + +static inline void vidconsole_readline_start_all(bool indent) { } -static inline void vidconsole_readline_end(void) +static inline void vidconsole_readline_end_all(void) { } #endif /* CONFIG_CURSOR */