From patchwork Sat Jan 17 00:56:51 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1555 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=1768611498; bh=PzzZhxj9inFQVVx9fyjhM1o7tkFWrqjL8QyHsoTv0vo=; 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=KAP5FCWO6xEpjXUwhTmZv7e89EmQr3W2632D/Jkzv9+Qxs1nmozxS5F+3T68n1XNJ R/9Iy3cIIVKtnbqen4TBveKYjMw5VCHmU68RBMiDPjC79P88RBqcy2Fp6UEWW8+E1i dwnLaFb9J0nfcgJsoljo43NPP1gRzQloNUVXj9ePwRZjycuA8CCNbHfgoT2IpqK3P7 ++Ckxk334Gwe97lFhXMlcvG1HEAt3c+iZHoiKio6BI6e7ce4pqSOLZ2xTYob8kOQQs WI4sOG8Oylg29vrrxGCHojz10u1P0dwvpHrJx/JqwuteEsN76EUOS2zox/kRxY3FKD RVbo4cRuFqF3w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 621F9693B1 for ; Fri, 16 Jan 2026 17:58:18 -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 xV7MM8HiW-Db for ; Fri, 16 Jan 2026 17:58:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611498; bh=PzzZhxj9inFQVVx9fyjhM1o7tkFWrqjL8QyHsoTv0vo=; 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=KAP5FCWO6xEpjXUwhTmZv7e89EmQr3W2632D/Jkzv9+Qxs1nmozxS5F+3T68n1XNJ R/9Iy3cIIVKtnbqen4TBveKYjMw5VCHmU68RBMiDPjC79P88RBqcy2Fp6UEWW8+E1i dwnLaFb9J0nfcgJsoljo43NPP1gRzQloNUVXj9ePwRZjycuA8CCNbHfgoT2IpqK3P7 ++Ckxk334Gwe97lFhXMlcvG1HEAt3c+iZHoiKio6BI6e7ce4pqSOLZ2xTYob8kOQQs WI4sOG8Oylg29vrrxGCHojz10u1P0dwvpHrJx/JqwuteEsN76EUOS2zox/kRxY3FKD RVbo4cRuFqF3w== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 504E7693E0 for ; Fri, 16 Jan 2026 17:58:18 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768611496; bh=XQ5IEBvnB1x+8jHGLJ0FoTOQxYC+3jgpbvCrkiwrsJY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=suOr8/2MXB+6L2Q3vGn7ezjBDw6N/RwxxZaVH8ejyDhUu7+CGEJHz9lxNY2t6Mwgp 9IP4C1oxACZTrGTZYvfDyZqzPsTnvUOVYcFk60lS0g1PAntF40m7BMDBHKc6BoT1ws z6jOQ/Cyx4gMn1bqjzbgsToQRhltiBBXmGdeTd+o9E55MVkk0f+raczHCU0mF5ywBb rCu2yDezuWVnGHXP1CNwqMAkZkeujSM1+F8pqqvNfLgbRCzDU0lREOuAsVDIerFcEk hsz+3q23M8R4r+oqKgHDZpjnudUesilGheNxKQ00/jZ2/7tao+GqLdHArQsSueldQs kIWXKsLDMcrrQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 560C3693E0; 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 Gnbi58fef4Ae; 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=1768611491; bh=UxTp6wSV0B3KY0xm2/M72jvbP2PWeop3H2aUBdypEcw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SGGYr6y0vYFFaj99YVXXY/qV94KMsGpRiKZkYy8PTkQm8F7RGNRS/LJqm/5EMKail UUhCtfmp+ZpfimiVGNDH916mS9bStwuBjHwoE2xu6XJc48tZivewAbbqVO7wtQDogV HY1fIEMJ/ZTMc0N0g7fJRSUt5J7eS6ay9e8nyPicoVrYvGpEnxM4GUMW4stGqe0gXA 4dwTH7MoZlJjVid/q7RlVcEPZ8d9Dmifv8473h5mG4gsm4yZz0FCpfGd4Pdp7ylmD9 uKwaynVF/lum03GKLUWs7f/gLfuof8cwjpX09HNUS3/jYuXSQ7BjZXzlMWAcNzIawL RazPdt7DW56fA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A3657693B1; Fri, 16 Jan 2026 17:58:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 16 Jan 2026 17:56:51 -0700 Message-ID: <20260117005702.1684841-14-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: PXE4Q527QYHYZECIRCGKDXKWJ6RJS7ER X-Message-ID-Hash: PXE4Q527QYHYZECIRCGKDXKWJ6RJS7ER 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 13/18] video: Move cur_met 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_met 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 | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index db9f89797bf..32d31b6d8cc 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -207,6 +207,7 @@ struct console_tt_metrics { * struct console_tt_ctx - Per-client context for this driver * * @com: Common fields from the vidconsole uclass + * @cur_met: Current metrics being used * @pos_ptr: Current position in the position history * @pos_start: Value of pos_ptr when the cursor is at the start of the text * being entered by the user @@ -219,6 +220,7 @@ struct console_tt_metrics { */ struct console_tt_ctx { struct vidconsole_ctx com; + struct console_tt_metrics *cur_met; int pos_ptr; int pos_start; int pos_count; @@ -228,7 +230,6 @@ struct console_tt_ctx { /** * struct console_tt_priv - Private data for this driver * - * @cur_met: Current metrics being used * @metrics: List metrics that can be used * @num_metrics: Number of available metrics * @cur_fontdata: Current fixed font data (NULL if using TrueType) @@ -240,7 +241,6 @@ struct console_tt_ctx { * @scratch_buf: Memory for scratch buffer */ struct console_tt_priv { - struct console_tt_metrics *cur_met; struct console_tt_metrics metrics[CONFIG_CONSOLE_TRUETYPE_MAX_METRICS]; int num_metrics; struct video_fontdata *cur_fontdata; @@ -274,7 +274,7 @@ static int console_truetype_set_row(struct udevice *dev, uint row, int clr) if (priv->cur_fontdata) font_height = priv->cur_fontdata->height; else - font_height = priv->cur_met->font_size; + font_height = ctx->cur_met->font_size; line = vid_priv->fb + row * font_height * vid_priv->line_length; end = line + font_height * vid_priv->line_length; @@ -335,7 +335,7 @@ static int console_truetype_move_rows(struct udevice *dev, uint rowdst, if (priv->cur_fontdata) font_height = priv->cur_fontdata->height; else - font_height = priv->cur_met->font_size; + font_height = ctx->cur_met->font_size; dst = vid_priv->fb + rowdst * font_height * vid_priv->line_length; src = vid_priv->fb + rowsrc * font_height * vid_priv->line_length; @@ -416,7 +416,7 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; struct console_tt_priv *priv = dev_get_priv(dev); - struct console_tt_metrics *met = priv->cur_met; + struct console_tt_metrics *met = ctx->cur_met; stbtt_fontinfo *font; int width, height, xoff, yoff; double xpos, x_shift; @@ -919,7 +919,7 @@ static void set_bitmap_font(struct udevice *dev, struct console_tt_priv *priv = dev_get_priv(dev); priv->cur_fontdata = fontdata; - priv->cur_met = NULL; + ctx->cur_met = NULL; vidconsole_set_bitmap_font(dev, fontdata); @@ -930,11 +930,10 @@ static void select_metrics(struct udevice *dev, struct console_tt_metrics *met) { struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; - struct console_tt_priv *priv = dev_get_priv(dev); struct udevice *vid_dev = dev_get_parent(dev); struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); - priv->cur_met = met; + ctx->cur_met = met; com->x_charsize = met->font_size; com->y_charsize = met->font_size; com->xstart_frac = VID_TO_POS(2); @@ -1245,7 +1244,7 @@ static int truetype_get_cursor_info(struct udevice *dev) if (priv->cur_fontdata) height = priv->cur_fontdata->height; else - height = priv->cur_met->font_size; + height = ctx->cur_met->font_size; /* Store line pointer and height in cursor struct */ curs->x = x; @@ -1258,6 +1257,7 @@ 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) { @@ -1266,7 +1266,7 @@ const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep) return priv->cur_fontdata->name; } else { /* Using TrueType font */ - struct console_tt_metrics *met = priv->cur_met; + struct console_tt_metrics *met = ctx->cur_met; *sizep = met->font_size; return met->font_name; @@ -1284,6 +1284,7 @@ static int truetype_mark_start(struct udevice *dev) static int console_truetype_probe(struct udevice *dev) { + struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct console_tt_priv *priv = dev_get_priv(dev); struct udevice *vid_dev = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); @@ -1316,7 +1317,7 @@ static int console_truetype_probe(struct udevice *dev) ret = truetype_add_metrics(dev, tab->name, font_size, tab->begin); if (ret < 0) return log_msg_ret("add", ret); - priv->cur_met = &priv->metrics[ret]; + ctx->cur_met = &priv->metrics[ret]; select_metrics(dev, &priv->metrics[ret]);