From patchwork Tue Jan 20 23:17:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1691 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=1768951198; bh=ttiD2nCXXX9gytDBgmtNVb9NvUT+RsPbiMEWo+87WgA=; 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=Rg3iUFLBlWFTo2RM9jzBfCYWdsQFQewudEXkeg5BHsPtVv4OMDnbWEbn5G4H4q1ek F3e376c/CAb/rnQY0VjUsv6AbunpoDvnrAdm7snjNTEDMousbFSi94ykuCSZX4BI72 8XE72uge9TnvWJL0MMPvGetJAkh1JaJLsxZJhwrFcxDszd25TJQqGkTI7jn3aHPPSM 0VPXgo2UQgUJMrot72YTOS2i98UaI4g1aA5BQUJMWlM3IWWsulBvu0cIieP1QPbVcG lNiWNU5f9dAQIOB0rCjeom2sLaXuGF9ERYrRAqQTjXeQ8kgiUz69Dc7YGz7d0Lw+7z c7mY+Db+XmwOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51B4C6957E for ; Tue, 20 Jan 2026 16:19: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 KZUV8FPT6M1j for ; Tue, 20 Jan 2026 16:19:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951198; bh=ttiD2nCXXX9gytDBgmtNVb9NvUT+RsPbiMEWo+87WgA=; 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=Rg3iUFLBlWFTo2RM9jzBfCYWdsQFQewudEXkeg5BHsPtVv4OMDnbWEbn5G4H4q1ek F3e376c/CAb/rnQY0VjUsv6AbunpoDvnrAdm7snjNTEDMousbFSi94ykuCSZX4BI72 8XE72uge9TnvWJL0MMPvGetJAkh1JaJLsxZJhwrFcxDszd25TJQqGkTI7jn3aHPPSM 0VPXgo2UQgUJMrot72YTOS2i98UaI4g1aA5BQUJMWlM3IWWsulBvu0cIieP1QPbVcG lNiWNU5f9dAQIOB0rCjeom2sLaXuGF9ERYrRAqQTjXeQ8kgiUz69Dc7YGz7d0Lw+7z c7mY+Db+XmwOQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3DD7F69587 for ; Tue, 20 Jan 2026 16:19:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951197; bh=6K7GnWOq1oVw3FWzTiQyxxlWDJMWyP0MADcFOcLAqV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUII4hhyLZfXLGRffQC0ess2fli8W+gl7E5+MFg1cOtU+qP6GFS4LY7Ylzy0it6Bu MPruov7qDKLwX5dIQDSd/RFnoDRPpA2FpbRNSXxyBTo3ZIE7JOB1H8DoHr26o40Dun JafGL1IkK0gORDqxtTyxp+p4gZdeBq1x8JorKPvMx1Em8AFzFjDNHftBb2M5ed6YYd /4EBsD/owD+y28kBnWexQIsf45hM1iVnhwlBXannUWripKuwb7t8aIYbkHsgpA8zj4 EV3LGCHjZjHPjdvs73TksR0JDN4NKTagHBYCMTyyTlWMF+95qToznVt22haDBhOmku 0j6jbzbTjfguA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 434616957E; Tue, 20 Jan 2026 16:19:57 -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 iq9MBsc1dq2P; Tue, 20 Jan 2026 16:19:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951193; bh=EVv7M+hhdIV8T5GeGr3SEMQjJXovS6rsTXVYd8X4on0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nz/CA5HOm2UsZlU59juW/L3rJy8BouuvPU2wD5mutkHxZivYqs2/q4yy6mU1zWWav /orA1ZwI6/WIW6gWZkuVKDqbJOf1TzNRp3YiMkqEbaoO6nfSYf8bSMcuqahWvGhScH MH5oTekJsusY6yEPT/FWi6U9gQGWDX90ezvb1VqsntvREUvLAqpW16bqN+fQjjofzv H4UuN5CoEqhQD3P/3pMwl9qEuNVjvv4kuc/TQJpxZrcazDmI9YhI08RHYsD2933lRg G87vVLuROjxqQPUZujA3MKOG9zSVED4x7iEveAyFR0HRb4NHp/Qlzz3vCO1q6MlHHb izi4VL85hs28g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DC7516913F; Tue, 20 Jan 2026 16:19:52 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:45 -0700 Message-ID: <20260120231814.2033069-19-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: JTD6V4BGQNTLJKN4CGLJ32I6TTQ43MTP X-Message-ID-Hash: JTD6V4BGQNTLJKN4CGLJ32I6TTQ43MTP 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 18/36] video: Pass context to vidconsole_put_char() 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 a vctx parameter to vidconsole_put_char() to allow passing in a specific vidconsole context. If NULL, the default context from priv is used. Update all callers accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- board/atmel/common/video_display.c | 2 +- boot/scene.c | 2 +- boot/scene_txtin.c | 4 ++-- drivers/video/vidconsole-uclass.c | 10 +++++----- include/video_console.h | 3 ++- test/dm/video.c | 14 +++++++------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c index 55a49b45f16..5d87d456399 100644 --- a/board/atmel/common/video_display.c +++ b/board/atmel/common/video_display.c @@ -71,7 +71,7 @@ int at91_video_show_board_info(void) priv->ctx->y_charsize - 1) / priv->ctx->y_charsize); for (s = buf, i = 0; i < len; s++, i++) - vidconsole_put_char(con, *s); + vidconsole_put_char(con, NULL, *s); return 0; } diff --git a/boot/scene.c b/boot/scene.c index 2627335c0e8..ed25ffdffa3 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -623,7 +623,7 @@ static void draw_string(struct udevice *cons, const char *str, int len, int i; for (i = 0; i < len; i++) - vidconsole_put_char(cons, '*'); + vidconsole_put_char(cons, NULL, '*'); } else { vidconsole_put_stringn(cons, str, len); } diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 007f827f776..da42f364f39 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -79,7 +79,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, /* move cursor back to the correct position */ for (i = cls->num; i < cls->eol_num; i++) - vidconsole_put_char(cons, '\b'); + vidconsole_put_char(cons, NULL, '\b'); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); @@ -103,7 +103,7 @@ static void scene_txtin_putch(struct cli_line_state *cls, int ch) { struct scene *scn = cls->priv; - vidconsole_put_char(scn->expo->cons, ch); + vidconsole_put_char(scn->expo->cons, NULL, ch); } void scene_txtin_close(struct scene *scn) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 7b23a0a68ac..45f39db99b0 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -486,10 +486,10 @@ static int vidconsole_output_glyph(struct udevice *dev, return 0; } -int vidconsole_put_char(struct udevice *dev, char ch) +int vidconsole_put_char(struct udevice *dev, void *vctx, char ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx_from_priv(priv); struct vidconsole_ansi *ansi = &ctx->ansi; int cp, ret; @@ -514,7 +514,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; case '\n': vidconsole_newline(dev, ctx); - vidconsole_entry_start(dev, NULL); + vidconsole_entry_start(dev, ctx); break; case '\t': /* Tab (8 chars alignment) */ ctx->xcur_frac = ((ctx->xcur_frac / ctx->tab_width_frac) @@ -552,7 +552,7 @@ int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen) if (maxlen != -1) end = str + maxlen; for (s = str; *s && (maxlen == -1 || s < end); s++) { - ret = vidconsole_put_char(dev, *s); + ret = vidconsole_put_char(dev, NULL, *s); if (ret) return ret; } @@ -573,7 +573,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) if (priv->quiet) return; - ret = vidconsole_put_char(dev, ch); + ret = vidconsole_put_char(dev, NULL, ch); if (ret) { #ifdef DEBUG console_puts_select_stderr(true, "[vc err: putc]"); diff --git a/include/video_console.h b/include/video_console.h index 6b8278123da..16c01718bd9 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -748,10 +748,11 @@ int vidconsole_entry_start(struct udevice *dev, void *ctx); * can be adjusted manually using vidconsole_position_cursor(). * * @dev: Device to adjust + * @vctx: Vidconsole context to use, or NULL to use default * @ch: Character to write * Return: 0 if OK, -ve on error */ -int vidconsole_put_char(struct udevice *dev, char ch); +int vidconsole_put_char(struct udevice *dev, void *vctx, char ch); /** * vidconsole_put_stringn() - Output part of a string to the current console pos diff --git a/test/dm/video.c b/test/dm/video.c index ef0c0c5265b..ede09a432a2 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -420,21 +420,21 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, /* Check display wrap */ for (i = 0; i < 120; i++) - vidconsole_put_char(con, 'A' + i % 50); + vidconsole_put_char(con, NULL, 'A' + i % 50); ut_asserteq(wrap_size, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* Check display scrolling */ for (i = 0; i < SCROLL_LINES; i++) { - vidconsole_put_char(con, 'A' + i % 50); - vidconsole_put_char(con, '\n'); + vidconsole_put_char(con, NULL, 'A' + i % 50); + vidconsole_put_char(con, NULL, '\n'); } ut_asserteq(scroll_size, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* If we scroll enough, the screen becomes blank again */ for (i = 0; i < SCROLL_LINES; i++) - vidconsole_put_char(con, '\n'); + vidconsole_put_char(con, NULL, '\n'); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -1193,8 +1193,8 @@ static int check_cursor_backspace(struct unit_test_state *uts, ut_assert(!curs->enabled); ut_assert(!curs->saved); ut_assert(!curs->height); - ut_assertok(vidconsole_put_char(con, ' ')); - ut_assertok(vidconsole_put_char(con, 'a')); + ut_assertok(vidconsole_put_char(con, NULL, ' ')); + ut_assertok(vidconsole_put_char(con, NULL, 'a')); with_a = video_compress_fb(uts, dev, false); /* Show cursor at current position (after 'a') */ @@ -1208,7 +1208,7 @@ static int check_cursor_backspace(struct unit_test_state *uts, curs->enabled = true; /* Do backspace - the cursor will be hidden */ - ut_assertok(vidconsole_put_char(con, '\b')); + ut_assertok(vidconsole_put_char(con, NULL, '\b')); ut_assert(!curs->visible); ut_assert(!curs->saved); after_backspace = video_compress_fb(uts, dev, false);