From patchwork Sat Jan 17 00:56:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1544 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=1768611448; bh=TwAHtf8ACmHOkV+iQJ9s+IG74TIqMQCy292izkal6xg=; 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=o1mO8XaKpqrL5lOV0QvZDRp1w9PvHbhL5tbgjJOkDkhOScpcM5j7WAwleWVoend40 pLZg7+jA9+7VIrJLgc5NzThXKwJuJr0sm0HF2U7kxSsRsdtUSDle9xPovPuFBTsOwx db6R+3cBzX58/RVqal8xljqiN+8udldJPSC+DJxs8wp7PagwLabseOc4ewDvlNZ+b4 fIY0Aw+B3+z4C7hwaSJSfysdrmCmvRQTNyDiOEzgzdLDkoEhLBXfysZc0J7YSXBsHd ZnLq2QokhJuuU3vUW5EygOwzj7bkZJy+1opCfdFL6e7V55ABT8B1k8nugnM6iGZIGh yww73VTVauFbQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A239693E7 for ; Fri, 16 Jan 2026 17:57:28 -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 r6FlEDUif6vK for ; Fri, 16 Jan 2026 17:57:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611448; bh=TwAHtf8ACmHOkV+iQJ9s+IG74TIqMQCy292izkal6xg=; 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=o1mO8XaKpqrL5lOV0QvZDRp1w9PvHbhL5tbgjJOkDkhOScpcM5j7WAwleWVoend40 pLZg7+jA9+7VIrJLgc5NzThXKwJuJr0sm0HF2U7kxSsRsdtUSDle9xPovPuFBTsOwx db6R+3cBzX58/RVqal8xljqiN+8udldJPSC+DJxs8wp7PagwLabseOc4ewDvlNZ+b4 fIY0Aw+B3+z4C7hwaSJSfysdrmCmvRQTNyDiOEzgzdLDkoEhLBXfysZc0J7YSXBsHd ZnLq2QokhJuuU3vUW5EygOwzj7bkZJy+1opCfdFL6e7V55ABT8B1k8nugnM6iGZIGh yww73VTVauFbQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3A41F693E6 for ; Fri, 16 Jan 2026 17:57:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611445; bh=VBLa5sNzTPlLLEAZWJz//t2np9dDIDth3dYe/peNVEI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lPHn9BUnBqzuzPUxJD/PQ0+WWM1/xooUF4GeoTEHQXqzXNZiqiIpoKa0VCVrAe6zf 8ZCn900M5mOGgGo8ZzCeC+EPJqI7xnZ7Dv1VO8Y2GMV+/o+lRt6sCkjsYzZdGRXyJz f5sUCjUthua3XTW60SL5lSxVnBBWZpClBQF2OetsMZJlO/ZEyQSoDrTjIi04PahVfX QK5LDQ8XFGgq8mXrSvp6m0+ObsrINil/pOawrhZZncU2TO0x8ZT+zgJLnT+NCyO5NM l4G9njM9W7JYl32o3mrNpMjfSCzFscj1zJ8aDs/x3dy/LiU0jbI7G2C9NnoeJn7M88 9otSm7dDjAZbA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 63E9D693B1; Fri, 16 Jan 2026 17:57:25 -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 o_ZSsxyR7bEr; Fri, 16 Jan 2026 17:57:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611441; bh=xUc01BwAARn0py0vAye68RIeQQi/fQVDHhJW3Md/yXw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N5hyZKUhx2/WOdgOIYuy2mW69O9TcKoBc4kED5muXRDhK4h+YMALDek2+vyjnGmtH VYAMMyPE19KSQOxHSPHFKEYPdApCgop+ReFsVb6ZTOnRpXrNSIl/ytO3RfY3umcWbx Eluh19FEv9HzL7307+ekXFIbCrXP1nTTNZ16tdlgjsyaJUzTM/i+pThunSqXE0mab7 bBnynVOc1dAp2yAefzBpLE9Q44oEuLw/j3fgj5+Vvy51vUD8INFDSV7Jk2mUike4af Mye8Ry+S8olKEJErIpW8QBpLyDiK9zneQ08q57eVxr2+Ub3kuEzgVI9mze/Q2wFXV2 hExHcdkT+yHUw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 10C79693D7; Fri, 16 Jan 2026 17:57:21 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 17:56:40 -0700 Message-ID: <20260117005702.1684841-3-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260117005702.1684841-1-sjg@u-boot.org> References: <20260117005702.1684841-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NO5QVYGTISWRQMV7FN6OEQ3XK5FUASWX X-Message-ID-Hash: NO5QVYGTISWRQMV7FN6OEQ3XK5FUASWX 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 02/18] video: Move curs into vidconsole_ctx 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 cursor state should be per-context so that different clients can maintain their own cursor information. Move the curs field from vidconsole_priv into vidconsole_ctx. Update all access to use the vidconsole_ctx() or vidconsole_ctx_from_priv() helpers for consistency. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 6 +++--- drivers/video/console_normal.c | 2 +- drivers/video/console_truetype.c | 2 +- drivers/video/vidconsole-uclass.c | 24 +++++++++++++----------- include/video_console.h | 4 ++-- test/dm/video.c | 3 ++- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 9cf5831b562..50f67ffcf83 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -280,7 +280,7 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, int console_alloc_cursor(struct udevice *dev) { - struct vidconsole_priv *vc_priv; + struct vidconsole_ctx *ctx; struct vidconsole_cursor *curs; struct video_priv *vid_priv; struct udevice *vid; @@ -289,10 +289,10 @@ int console_alloc_cursor(struct udevice *dev) if (!CONFIG_IS_ENABLED(CURSOR) || xpl_phase() < PHASE_BOARD_R) return 0; - vc_priv = dev_get_uclass_priv(dev); + ctx = vidconsole_ctx(dev); vid = dev_get_parent(dev); vid_priv = dev_get_uclass_priv(vid); - curs = &vc_priv->curs; + curs = &ctx->curs; /* Allocate cursor save buffer for maximum possible cursor height */ save_count = vid_priv->ysize * VIDCONSOLE_CURSOR_WIDTH; diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 73bf3a7ebe8..4854e953e58 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -98,7 +98,7 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev) struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); struct console_simple_priv *priv = dev_get_priv(dev); struct video_fontdata *fontdata = priv->fontdata; - struct vidconsole_cursor *curs = &vc_priv->curs; + struct vidconsole_cursor *curs = &ctx->curs; int x, y, index, xspace, xpos; /* for now, this is not used outside expo */ diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 37cc1f0fc5d..978e81a9350 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1233,7 +1233,7 @@ static int truetype_get_cursor_info(struct udevice *dev) struct vidconsole_ctx *com = vidconsole_ctx_from_priv(vc_priv); struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_ctx *ctx = &priv->ctx; - struct vidconsole_cursor *curs = &vc_priv->curs; + struct vidconsole_cursor *curs = &com->curs; int x, y, index; uint height; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 2136253b15e..71bcb0d9c91 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -767,8 +767,9 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf) int vidconsole_show_cursor(struct udevice *dev) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct vidconsole_ops *ops = vidconsole_get_ops(dev); - struct vidconsole_cursor *curs = &priv->curs; + struct vidconsole_cursor *curs = &ctx->curs; int ret; /* find out where the cursor should be drawn */ @@ -807,7 +808,8 @@ int vidconsole_show_cursor(struct udevice *dev) int vidconsole_hide_cursor(struct udevice *dev) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_cursor *curs = &priv->curs; + struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); + struct vidconsole_cursor *curs = &ctx->curs; int ret; if (!curs->visible) @@ -912,9 +914,9 @@ static int vidconsole_post_probe(struct udevice *dev) static int vidconsole_pre_remove(struct udevice *dev) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); - free(vc_priv->curs.save_data); + free(ctx->curs.save_data); return 0; } @@ -987,8 +989,8 @@ void vidconsole_set_bitmap_font(struct udevice *dev, void vidconsole_idle(struct udevice *dev) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_cursor *curs = &priv->curs; + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + struct vidconsole_cursor *curs = &ctx->curs; /* Only handle cursor if it's enabled */ if (curs->enabled && !curs->visible) { @@ -1008,10 +1010,10 @@ void vidconsole_readline_start(bool indent) struct udevice *dev; uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); - priv->curs.indent = indent; - priv->curs.enabled = true; + ctx->curs.indent = indent; + ctx->curs.enabled = true; vidconsole_mark_start(dev); } } @@ -1022,9 +1024,9 @@ void vidconsole_readline_end(void) struct udevice *dev; uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); - priv->curs.enabled = false; + ctx->curs.enabled = false; } } #endif /* CURSOR */ diff --git a/include/video_console.h b/include/video_console.h index bc468d753d4..5b90a5cf160 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -112,6 +112,7 @@ struct vidconsole_ansi { * @ymark: Y position of start of CLI text * @ansi: ANSI escape-sequence state * @utf8_buf: Buffer to accumulate UTF-8 byte sequence + * @curs: Cursor state and management */ struct vidconsole_ctx { int rows; @@ -126,6 +127,7 @@ struct vidconsole_ctx { int ymark; struct vidconsole_ansi ansi; char utf8_buf[5]; + struct vidconsole_cursor curs; }; /** @@ -148,7 +150,6 @@ struct vidconsole_ctx { * @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units * @quiet: Suppress all output from stdio - * @curs: Cursor state and management */ struct vidconsole_priv { struct stdio_dev sdev; @@ -157,7 +158,6 @@ struct vidconsole_priv { int xsize_frac; int xstart_frac; bool quiet; - struct vidconsole_cursor curs; }; /** diff --git a/test/dm/video.c b/test/dm/video.c index d802a5cc24d..d3978f4b00c 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1185,7 +1185,8 @@ static int check_cursor_backspace(struct unit_test_state *uts, { int with_a, with_cursor, after_backspace, after_idle, after_hide; struct vidconsole_priv *vc_priv = dev_get_uclass_priv(con); - struct vidconsole_cursor *curs = &vc_priv->curs; + struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_cursor *curs = &ctx->curs; /* Output chars without cursor */ ut_assert(!curs->visible);