From patchwork Fri Jan 16 17:14:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1542 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=1768583743; bh=wvW7J0jMSjI4cngoEFyxdaJbcAYVYTzBYDVAw3mAfxY=; 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=nDjKVCvsmt0Wiz4M/IMUBu9XZmvTW7jqJzcHts7/+vDDKZYPwGjnKTx7DGuSPW6ls YayJoTrr4EggR/xy0DRfJ8Z+gocnyWbNTeNLZcZpY3h53kHYetKUnwytycoo5FicOF wua2gOq6J+Cpv5Z1J7GcINNn8y3ylusgdD6QeS5WkBHY3op8x6vLqKxGfas2scxXAM 1gBrp8E9kOxYeHToJaLcxxTPLIMpRercjXE2LOfRbIlaOtTgLB/EeQaMkiqB7XksAL EWJ0LF099Ja7tlIXyFZUsNtskRQSMbELSkPuy+DZ3f+JZ6gWUQTa2RZy9Ayg2K9jAo uYjpvvDImIjjw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 96692693B1 for ; Fri, 16 Jan 2026 10:15:43 -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 lnDZDIgvAE3d for ; Fri, 16 Jan 2026 10:15:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583743; bh=wvW7J0jMSjI4cngoEFyxdaJbcAYVYTzBYDVAw3mAfxY=; 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=nDjKVCvsmt0Wiz4M/IMUBu9XZmvTW7jqJzcHts7/+vDDKZYPwGjnKTx7DGuSPW6ls YayJoTrr4EggR/xy0DRfJ8Z+gocnyWbNTeNLZcZpY3h53kHYetKUnwytycoo5FicOF wua2gOq6J+Cpv5Z1J7GcINNn8y3ylusgdD6QeS5WkBHY3op8x6vLqKxGfas2scxXAM 1gBrp8E9kOxYeHToJaLcxxTPLIMpRercjXE2LOfRbIlaOtTgLB/EeQaMkiqB7XksAL EWJ0LF099Ja7tlIXyFZUsNtskRQSMbELSkPuy+DZ3f+JZ6gWUQTa2RZy9Ayg2K9jAo uYjpvvDImIjjw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 852FF6932E for ; Fri, 16 Jan 2026 10:15:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583741; bh=7O26K89EkLEisPAFk2GJTufUOhsnCLPfkMyvSMyyp2A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gE4CXeyWAqUzbhtTV1E7b1vC+pTcFIujt1uvg4E0r5E8Ipg41nMaeSodYm67dGdmW VBvY+mQfX9619+beL5PIffxyKs9btIBWNzaz5osWjZr7pJSbp54PkV50N9TxWqe3m6 3iHBYyfQU8v3Rhfs8Y2EOmCNigCQ/C+Atp+SABiL5n89V4BjX0ZY/aMiN2Cl85ssKH TO1KrJgu0vi7u9y2ZHoD5GXjwyuXfEqhADnRuFbNT8ym+ndZynLJTlUNi5cyWla1bZ SxqzvsovoUucMF1gmqIG1VQUqdau12ISo67bsBg1hCQ7fH2K09g5BbPYTZA5T95ssC nHBePuvwnXTdg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AF0726932E; Fri, 16 Jan 2026 10:15:41 -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 GfP_Rbrt6NXN; Fri, 16 Jan 2026 10:15:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583736; bh=0W1sCuVqkqzbrZY6ZKLC85fDc2uOsAvKGnKq2dWB2mQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ERU1vbRfqQkYhDnISo0POCMko0i2XyekemmchhUyHbShSJmDHmt14w16aGYkOWoAh 44WoefMkUnW/T7J0GKyLHojOi4XeCkPM4K+1hzWgth0BonACjDtYgUDlVIquXWSGe4 VaOb603jmk5lLZaoYWBVAAqNqihL0kOrId3D1KTCWpRreE5fINQyhGojWIUjkr9WSA NkLpwoClBAMjbPma/g1SqSsNTkn4i7Pp0sdPNxk4o+rwY4BNtF6LqYS6qpr6w5yoHX QwG7NTcsvLXzyiCKUtB2dffossYjL8hsFFgfxTQIaINDutRAX80XIEZn257SGeVqhN ba74L64Yh0MAw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 59EE56913F; Fri, 16 Jan 2026 10:15:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 10:14:16 -0700 Message-ID: <20260116101415.14.I33b9868999de00f88d957f23cf1d62a5fe0e9cff@changeid> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260116171424.398597-1-sjg@u-boot.org> References: <20260116171424.398597-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: NTL4G3CBFERUODOXC6CD4ZRMDUTA7S6M X-Message-ID-Hash: NTL4G3CBFERUODOXC6CD4ZRMDUTA7S6M 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 14/14] video: Move ansi and utf8_buf 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 Move the ansi struct and utf8_buf array from vidconsole_priv into vidconsole_ctx as part of the per-client context refactoring. These fields hold parsing state for ANSI escape sequences and UTF-8 byte accumulation, which need to be per-client to avoid interference when multiple clients send interleaved data. Also move struct vidconsole_ansi definition before struct vidconsole_ctx since the latter now contains the former. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 6 ++-- include/video_console.h | 50 +++++++++++++++---------------- 2 files changed, 28 insertions(+), 28 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 182505d1056..2136253b15e 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -195,7 +195,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); - struct vidconsole_ansi *ansi = &priv->ansi; + struct vidconsole_ansi *ansi = &ctx->ansi; if (!IS_ENABLED(CONFIG_VIDEO_ANSI)) goto error; @@ -487,7 +487,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); - struct vidconsole_ansi *ansi = &priv->ansi; + struct vidconsole_ansi *ansi = &ctx->ansi; int cp, ret; /* Hide cursor to avoid artifacts */ @@ -526,7 +526,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; default: if (CONFIG_IS_ENABLED(CHARSET)) { - cp = utf8_to_utf32_stream(ch, priv->utf8_buf); + cp = utf8_to_utf32_stream(ch, ctx->utf8_buf); if (cp == 0) return 0; } else { diff --git a/include/video_console.h b/include/video_console.h index 73c4f54f62c..bc468d753d4 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -73,6 +73,27 @@ struct vidconsole_cursor { uint index; }; +/** + * struct vidconsole_ansi - ANSI escape-sequence state + * + * ANSI escape sequences are accumulated character by character, starting after + * the ESC char (0x1b) until the entire sequence is consumed, at which point it + * is acted upon. + * + * @escape: True if currently accumulating an ANSI escape sequence + * @escape_len: Length of accumulated escape sequence so far + * @row_saved: Saved Y position in pixels (0=top) + * @col_saved: Saved X position, in fractional units (VID_TO_POS(x)) + * @escape_buf: Buffer to accumulate escape sequence + */ +struct vidconsole_ansi { + int escape; + int escape_len; + int row_saved; + int col_saved; + char escape_buf[32]; +}; + /** * struct vidconsole_ctx - per-client context for a video console * @@ -89,6 +110,8 @@ struct vidconsole_cursor { * @cli_index: Character index into the CLI text (0=start) * @xmark_frac: X position of start of CLI text entry, in fractional units * @ymark: Y position of start of CLI text + * @ansi: ANSI escape-sequence state + * @utf8_buf: Buffer to accumulate UTF-8 byte sequence */ struct vidconsole_ctx { int rows; @@ -101,27 +124,8 @@ struct vidconsole_ctx { int cli_index; int xmark_frac; int ymark; -}; - -/** - * struct vidconsole_ansi - ANSI escape-sequence state - * - * ANSI escape sequences are accumulated character by character, starting after - * the ESC char (0x1b) until the entire sequence is consumed, at which point it - * is acted upon. - * - * @escape: True if currently accumulating an ANSI escape sequence - * @escape_len: Length of accumulated escape sequence so far - * @row_saved: Saved Y position in pixels (0=top) - * @col_saved: Saved X position, in fractional units (VID_TO_POS(x)) - * @escape_buf: Buffer to accumulate escape sequence - */ -struct vidconsole_ansi { - int escape; - int escape_len; - int row_saved; - int col_saved; - char escape_buf[32]; + struct vidconsole_ansi ansi; + char utf8_buf[5]; }; /** @@ -143,8 +147,6 @@ struct vidconsole_ansi { * @tab_width_frac: Tab width in fractional units * @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units - * @ansi: ANSI escape-sequence state - * @utf8_buf: Buffer to accumulate UTF-8 byte sequence * @quiet: Suppress all output from stdio * @curs: Cursor state and management */ @@ -154,8 +156,6 @@ struct vidconsole_priv { int tab_width_frac; int xsize_frac; int xstart_frac; - struct vidconsole_ansi ansi; - char utf8_buf[5]; bool quiet; struct vidconsole_cursor curs; };