From patchwork Sat Jan 17 00:56:52 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1556 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=1768611500; bh=R1I4aWsCO65ni8waCIJ+vDM7HOed1EZxzgdwUyChi5I=; 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=svNUHir2cOoZBvGvRUaKfyEN0Vonc5mw85sWZmPcViAAOt3w3tKCdWxEhXn6VeQmB LuhRqfN7psV80krRjlpdKqMFad3UJ7v9W3utiJgMi+fCmb7htQWrEQDMBKHT4EBZ5F ur1/ck4vLffxdmbI/j1Ho+Cn2MnVnIa18zlB3XyNkmWRIAVaFKbDp7N4iIvZLN1Qp0 FVuU/9R/9xfnzo0NGJzYID9F+5oFo/I0l6JrXVXDaxWr3q5d3O51pCV3rdmjfwrpuT ObfiO3M+HRt93eekmQsvrPMYG0AINPC8gf9vxVfO0uaDZZniVXT4zofitQwEWD/i8b aJaKkRQ+I3dAg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D3A76693E6 for ; Fri, 16 Jan 2026 17:58:20 -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 hczMvnmpWcLz for ; Fri, 16 Jan 2026 17:58:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611499; bh=R1I4aWsCO65ni8waCIJ+vDM7HOed1EZxzgdwUyChi5I=; 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=kvyEEsDGQIlhAH9Ir/nFSpl5PfEVDgHdBLv8CDB9p7FcGVm47lqwIaL7dSUkoycMv UewhL864GuZT7MSuGKzIj0neJNB4Us6m9q0085MAKQmu5v0/r0XXKnPzRep/UePIXb gXBd7PW7LaNc0kFWxXQTwGWRhWkNNNFMPd2LiRVhdGo5j7eRjjYGRws7GMMCz+0tGf U7VJ26s6ldnidhhXGLxjUyjxTNC156NUtPYRYI+0zsD/FoRRQv+58N1szNUN/K/n2R yXt+N+dxMs1F4BqP9R62csHSMm1J4CM8/YN1rdZv4yhD24IlmTXEovcUDfQcl3xaYI GXXdVoWjYyhcQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3A7E1693B1 for ; Fri, 16 Jan 2026 17:58:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611496; bh=aV5QlZ0GLchTE9WJR850uYRK36GuoXaKGTfhLKtjKlE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BNd9S9OpXTbNyi8mcJWwxqHgrac4ZEu1xa80V2kOfA+DNgNukMZZ5+gQw5EQZXNPF ZNzESVRbI/W3wE6u89NJB6XZHPZwD++qiqAceIrrgfcQUtyKI+a7D6oTtK+91FGcAl pIyH/UiL3UdZdSClJMWkSOmmHpxhe4yC8bUIzoZHmeLe19PHK6tEAVj33qeCtpjOQH PPgxgfgeWERHMrLGD6vwkvtl1LJgb5R7U3iPw5axTwm1ESY40a3YgZ3KLv2rceXnur UVH/yoIrA8nXI/fMJugm2FY1BHweGXfk0IWJS8fbs2xDboaCuUMXTcHuBLMAblw906 YiCiTt0zmGa8w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E9D19693B1; Fri, 16 Jan 2026 17:58:16 -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 JlMAqjUWlVjB; Fri, 16 Jan 2026 17:58:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611496; bh=2bOZOZCcwVR1UcXFFs6uagZF6136BojMD6Vf9YXwZ7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GHpz50hlc/6QIbfkTQnIQIEWnUxd5D394KJRZ4EdEYrtZLZAa4zfeBcSM9WRWh1O+ gLhlwShcHQ6iA4ag6oFZXWVzFcCaPvMF1hY3D2g+sQuNd8sqvmEh0rEBU9KFC8TVic QjGaNMDLLrtLoTAyC8kC8wPPqICZx3iTVfvJVDI5IoXXnmJoq9n5VWsP9ZELsKbAUc bdJTtYc8QSLfeEOaVMkwzcJlHFz94Lvbyt0e5nko4gSZW+h88OT+z6BheZyLHM+Zsn qDCgpYZ5SLTRqPZsSBodtkAyg0GH5fsUXU/IaBJikZxMzZ9sZM90xkilAtpHKTFT7C mhcRkGe3fl5Vw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4AEBD693D7; Fri, 16 Jan 2026 17:58:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 17:56:52 -0700 Message-ID: <20260117005702.1684841-15-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: P2LCBGCPAPWODMIYFEHY62HA46OFS7X7 X-Message-ID-Hash: P2LCBGCPAPWODMIYFEHY62HA46OFS7X7 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/18] video: Move cur_fontdata to console_tt_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 cur_fontdata pointer from console_tt_priv to console_tt_ctx so that it can be tracked per-context rather than per-device. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 38 ++++++++++++++------------------ 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 32d31b6d8cc..2ab4f7dcb25 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -221,6 +221,7 @@ struct console_tt_metrics { struct console_tt_ctx { struct vidconsole_ctx com; struct console_tt_metrics *cur_met; + struct video_fontdata *cur_fontdata; int pos_ptr; int pos_start; int pos_count; @@ -232,7 +233,6 @@ struct console_tt_ctx { * * @metrics: List metrics that can be used * @num_metrics: Number of available metrics - * @cur_fontdata: Current fixed font data (NULL if using TrueType) * @glyph_buf: Pre-allocated buffer for rendering glyphs. If a glyph fits, * this avoids malloc/free per character. Allocated lazily after * relocation to avoid using early malloc space. @@ -243,7 +243,6 @@ struct console_tt_ctx { struct console_tt_priv { struct console_tt_metrics metrics[CONFIG_CONSOLE_TRUETYPE_MAX_METRICS]; int num_metrics; - struct video_fontdata *cur_fontdata; u8 *glyph_buf; int glyph_buf_size; struct stbtt_scratch scratch; @@ -266,13 +265,12 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; - struct console_tt_priv *priv = dev_get_priv(dev); void *end, *line; int font_height; /* Get font height from current font type */ - if (priv->cur_fontdata) - font_height = priv->cur_fontdata->height; + if (ctx->cur_fontdata) + font_height = ctx->cur_fontdata->height; else font_height = ctx->cur_met->font_size; @@ -324,16 +322,15 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, uint count) { struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); - struct vidconsole_ctx *com = vidconsole_ctx(dev); - struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct vidconsole_ctx *com = &ctx->com; void *dst; void *src; int i, diff, font_height; /* Get font height from current font type */ - if (priv->cur_fontdata) - font_height = priv->cur_fontdata->height; + if (ctx->cur_fontdata) + font_height = ctx->cur_fontdata->height; else font_height = ctx->cur_met->font_size; @@ -430,8 +427,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, bool use_buf; /* Use fixed font if selected */ - if (priv->cur_fontdata) - return console_fixed_putc_xy(dev, x, y, cp, priv->cur_fontdata); + if (ctx->cur_fontdata) + return console_fixed_putc_xy(dev, x, y, cp, ctx->cur_fontdata); /* Reset scratch buffer for this character */ stbtt_scratch_reset(&priv->scratch); @@ -916,9 +913,8 @@ static void set_bitmap_font(struct udevice *dev, { struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; - struct console_tt_priv *priv = dev_get_priv(dev); - priv->cur_fontdata = fontdata; + ctx->cur_fontdata = fontdata; ctx->cur_met = NULL; vidconsole_set_bitmap_font(dev, fontdata); @@ -989,7 +985,7 @@ static int get_metrics(struct udevice *dev, const char *name, uint size, static int truetype_select_font(struct udevice *dev, const char *name, uint size) { - struct console_tt_priv *priv = dev_get_priv(dev); + struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct console_tt_metrics *met; struct video_fontdata *fontdata; int ret; @@ -1006,7 +1002,7 @@ static int truetype_select_font(struct udevice *dev, const char *name, } /* Continue with TrueType font selection */ - priv->cur_fontdata = NULL; + ctx->cur_fontdata = NULL; ret = get_metrics(dev, name, size, &met); if (ret) return log_msg_ret("sel", ret); @@ -1216,7 +1212,6 @@ static int truetype_get_cursor_info(struct udevice *dev) { struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; - struct console_tt_priv *priv = dev_get_priv(dev); struct vidconsole_cursor *curs = &com->curs; int x, y, index; uint height; @@ -1241,8 +1236,8 @@ static int truetype_get_cursor_info(struct udevice *dev) y = com->ycur; /* Get font height from current font type */ - if (priv->cur_fontdata) - height = priv->cur_fontdata->height; + if (ctx->cur_fontdata) + height = ctx->cur_fontdata->height; else height = ctx->cur_met->font_size; @@ -1258,12 +1253,11 @@ static int truetype_get_cursor_info(struct udevice *dev) const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep) { struct console_tt_ctx *ctx = vidconsole_ctx(dev); - struct console_tt_priv *priv = dev_get_priv(dev); - if (priv->cur_fontdata) { + if (ctx->cur_fontdata) { /* Using fixed font */ - *sizep = priv->cur_fontdata->height; - return priv->cur_fontdata->name; + *sizep = ctx->cur_fontdata->height; + return ctx->cur_fontdata->name; } else { /* Using TrueType font */ struct console_tt_metrics *met = ctx->cur_met;