From patchwork Fri Jan 16 17:14:13 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1539 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=1768583732; bh=LSIYfEavN4RLFyuV4j6j3FYJGxE/BEuUiv+QW9/oDDQ=; 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=b7pRn1sJ/u0QAoFUGZ8h7fOFCX61BHc+vwicNd4UHmtPpeKdAdX4k1BmNXmZGhq+x 5++kN1XV7fHgHjQ3cC72cUzihxAC4cOO8WjNHNuA7gSgfK86vsaEbTS+jcn/EFIkyZ oQpe1Z41bWJLaIGK4nUbqKw4CP9fDWBA92UyQNTkg3rNKobwZarRUCpkQY2+jS9vB3 yjlGEWaTdPvWS25SXJ6TuFzKl23wR4z/LzF3tg7bTcVhkKym2TMH/q9n5uLgBONN9G +FQ7si6XfAaZfYktQrTtQgTO8wTkJIPYZG5Otxh6bEPbwJfROGAwLte24a0EIHESq9 6BvICY2CtGecQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9D0B2693B2 for ; Fri, 16 Jan 2026 10:15:32 -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 C6VoZwAhz1nD for ; Fri, 16 Jan 2026 10:15:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583732; bh=LSIYfEavN4RLFyuV4j6j3FYJGxE/BEuUiv+QW9/oDDQ=; 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=b7pRn1sJ/u0QAoFUGZ8h7fOFCX61BHc+vwicNd4UHmtPpeKdAdX4k1BmNXmZGhq+x 5++kN1XV7fHgHjQ3cC72cUzihxAC4cOO8WjNHNuA7gSgfK86vsaEbTS+jcn/EFIkyZ oQpe1Z41bWJLaIGK4nUbqKw4CP9fDWBA92UyQNTkg3rNKobwZarRUCpkQY2+jS9vB3 yjlGEWaTdPvWS25SXJ6TuFzKl23wR4z/LzF3tg7bTcVhkKym2TMH/q9n5uLgBONN9G +FQ7si6XfAaZfYktQrTtQgTO8wTkJIPYZG5Otxh6bEPbwJfROGAwLte24a0EIHESq9 6BvICY2CtGecQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8CB16693B0 for ; Fri, 16 Jan 2026 10:15:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583730; bh=dvGlgPsWnPqYtnMlGPH4zxoav8A6tVfU3RAZC7GIq6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uF5/Fv6bl9/ZMty7rUrt4dFDaLq0xFLyqZ1KZxRscoOYDyry5k/HLBfTH1VSj0IDB UGMQg7xWs4Yk8RggIOeFz0s5igP34ocM6TjOUj+1feTqU8Qk9N3p+UYH2a86gLqEMX rqDvjZqivPE0Ajbp8+aOP5ynmegMVdhMJTggMe7Wd6ip8IdljYkoXjLH7Otji9qnLc B+NkUf+XgF8FSL/dMN01ROOYAQKF6+c/iwXVsYgIZhu5Wklpq+FzZdP2KlGOONOFft qiM/bCVtyKL8TzwPc0uGP3BHW+RAN+xnFq289i8cQY5q+pK41xTwTzZmfaMWP8jlG9 x4xFukwF/sYyw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9A90A6932E; Fri, 16 Jan 2026 10:15:30 -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 6POJS-Kp81Db; Fri, 16 Jan 2026 10:15:30 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768583726; bh=f4TtYDj8DlgekYE/WJXZZnFfN8mf+38+z8+w9kZ8wQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GTcXghILCcbXkU1vO9sp3B9W30Lyda9o2z1peIqw8/VnaqfpYxImYNhG8qogbYdu7 8yxbIghM3uLa9JdFCaANdjO/61eh12eQdmqlj14I7N/ai4+c2P04ZGgWcbHeeDMjHc b7uGc73v38vmwuQM49ICc7Xi7dT7ZjeljslyB/OGUU5HUB/Gc6QuknxdeUhx/ejUJ5 SwKGC6kX1ZpkPgw364h34e7s9SQWuVW1LV69WStxw2H7g7vd5KfThEAsh5H9/kWKce eKGTbDvl4VoambROBKKWR9KxIdBoC7PoEw0btqOyGKamXD4jcESLWjMJYCGjG1H5Vr pALM4y9ZZUHWg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 510926913F; Fri, 16 Jan 2026 10:15:26 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 10:14:13 -0700 Message-ID: <20260116171424.398597-12-sjg@u-boot.org> 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: GY7EDAPXXVPH32Y6DCWNV7OXYL4LBNUW X-Message-ID-Hash: GY7EDAPXXVPH32Y6DCWNV7OXYL4LBNUW 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 11/14] video: Move last_ch 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 last_ch field from vidconsole_priv into vidconsole_ctx as part of the per-client context refactoring. This field tracks the last character written, used for kerning in truetype fonts. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 7 ++++--- drivers/video/vidconsole-uclass.c | 10 +++++----- include/video_console.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 233154cfeea..e607dff0aea 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -452,8 +452,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, pos = ctx->pos_ptr < ctx->pos_count ? &ctx->pos[ctx->pos_ptr] : NULL; xpos = frac(VID_TO_PIXEL((double)x)); kern = 0; - if (vc_priv->last_ch) { - int last_cp = vc_priv->last_ch; + if (vc_ctx->last_ch) { + int last_cp = vc_ctx->last_ch; if (pos) last_cp = pos->cp; @@ -722,13 +722,14 @@ static int console_truetype_backspace(struct udevice *dev) static int console_truetype_entry_start(struct udevice *dev) { struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *vc_ctx = vidconsole_ctx_from_priv(vc_priv); struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_ctx *ctx = &priv->ctx; /* A new input line has start, so clear our history */ ctx->pos_ptr = 0; ctx->pos_count = 0; - vc_priv->last_ch = 0; + vc_ctx->last_ch = 0; return 0; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 29caaf34fc0..1e9c0b4b730 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -113,7 +113,7 @@ static void vidconsole_newline(struct udevice *dev) vid_priv->colour_bg); ctx->ycur -= rows * ctx->y_charsize; } - priv->last_ch = 0; + ctx->last_ch = 0; ret = video_sync(dev->parent, false); if (ret) { @@ -143,7 +143,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) ctx->ycur = y; /* make sure not to kern against the previous character */ - priv->last_ch = 0; + ctx->last_ch = 0; vidconsole_entry_start(dev); } @@ -460,7 +460,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) if (_DEBUG) { console_printf_select_stderr(true, "glyph last_ch '%c': ch '%c' (%02x): ", - priv->last_ch, ch >= ' ' ? ch : ' ', ch); + ctx->last_ch, ch >= ' ' ? ch : ' ', ch); } /* * Failure of this function normally indicates an unsupported @@ -475,7 +475,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) if (ret < 0) return ret; ctx->xcur_frac += ret; - priv->last_ch = ch; + ctx->last_ch = ch; if (ctx->xcur_frac >= priv->xsize_frac) vidconsole_newline(dev); cli_index_adjust(priv, 1); @@ -522,7 +522,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; case '\b': vidconsole_back(dev); - priv->last_ch = 0; + ctx->last_ch = 0; break; default: if (CONFIG_IS_ENABLED(CHARSET)) { diff --git a/include/video_console.h b/include/video_console.h index c2656ec452d..6dfa2214448 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -85,6 +85,7 @@ struct vidconsole_cursor { * @y_charsize: Character height in pixels * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) * @ycur: Current Y position in pixels (0=top) + * @last_ch: Last character written to the text console on this line */ struct vidconsole_ctx { int rows; @@ -93,6 +94,7 @@ struct vidconsole_ctx { int y_charsize; int xcur_frac; int ycur; + int last_ch; }; /** @@ -135,7 +137,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 - * @last_ch: Last character written to the text console on this line * @xmark_frac: X position of start of CLI text entry, in fractional units * @ymark: Y position of start of CLI text * @cli_index: Character index into the CLI text (0=start) @@ -150,7 +151,6 @@ struct vidconsole_priv { int tab_width_frac; int xsize_frac; int xstart_frac; - int last_ch; int xmark_frac; int ymark; int cli_index;