From patchwork Tue Jan 20 23:17:30 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1676 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=1768951128; bh=2qfLrisKJ9SsNzQtDkPy+rGliqAlS6A7axZCrAk2MB8=; 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=r30WdBS7QCEfEojtQIx+qaYdqgilvxYv0H6mbjmIvrv3cM9sKfS9nIFukmyZIylnv wqfWrCUtfEICLuiKrda6BSRAFsyQett8tZf1e8MGWYMrtdSPzg0SYiOYAGqgFT3X0T l/0O4CS5DG03v7oBxVZOFi0QtsUUjQbHE7Tmgr9F9r5zPO8fIZA1+jD3dl7m3652Yb t0cJxnV1BLeRCxsYRAlTSoL8DM97JG4LR8rvWbIRc5XP3/mRFGENgqQqMMRvdhbTLI xIw8Wjx0xcXQRyVOTP2E3Rq1G6xC6nmYeKDAcuHx6n+ziGwRt1ZvCeGPV39qJbfceD md63RG9F3oNHw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 972F969581 for ; Tue, 20 Jan 2026 16:18:48 -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 T_1nhRZrIa4k for ; Tue, 20 Jan 2026 16:18:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951128; bh=2qfLrisKJ9SsNzQtDkPy+rGliqAlS6A7axZCrAk2MB8=; 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=r30WdBS7QCEfEojtQIx+qaYdqgilvxYv0H6mbjmIvrv3cM9sKfS9nIFukmyZIylnv wqfWrCUtfEICLuiKrda6BSRAFsyQett8tZf1e8MGWYMrtdSPzg0SYiOYAGqgFT3X0T l/0O4CS5DG03v7oBxVZOFi0QtsUUjQbHE7Tmgr9F9r5zPO8fIZA1+jD3dl7m3652Yb t0cJxnV1BLeRCxsYRAlTSoL8DM97JG4LR8rvWbIRc5XP3/mRFGENgqQqMMRvdhbTLI xIw8Wjx0xcXQRyVOTP2E3Rq1G6xC6nmYeKDAcuHx6n+ziGwRt1ZvCeGPV39qJbfceD md63RG9F3oNHw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 868C769572 for ; Tue, 20 Jan 2026 16:18:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951126; bh=lvFKPI1aDYpZGcKYZo76tUOOoFB7B4eCM/563FuR+t8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qGs919D7AOk85ZkBeeU0zhUxM7YLTRdcRVJGB/lBi+LIjiaO+IGtvw4wlK6MWT+ur 9mg2tWJ3T07Q+wMcWn6kyvYatKIDiM5TZuLjrY99IPJYrUDnlPPlcLRCHrmrx/PPbc 86NARUnJCiL09pDUUVCtr/YThqcKbrhsjiuTO9z9RoBxzJ8HnVzKzMcNRxxFSllSN/ cL2vHf9jrQ3E5BNjOPywZmlybDLgQmCQ0Ax9DUCB6AHTxOFWpu6W9C4fF3yVTml3Cn oJ8WHHIeG9UL9xFTaezFjEembZXEzDF9qACNlppd/YxzJ1T2LKTXSNOtkn/tttV7bm /fOaMM+uns6hw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D4E3B69441; Tue, 20 Jan 2026 16:18:46 -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 YDa3jq2m5EQw; Tue, 20 Jan 2026 16:18:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951122; bh=0EeFdNAI/fUBNtJTTz98khzzhxTOg1OcigoKniB+UX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T2Zm6oeMbqYAj6IIoBw8FsmtG0Zt7ZqTjLloRbpTUMBayoWwZ4oSPrtw+McXLps5Z uqOwRPXJVDOP3svtI0UvhM+FrBZW/doxs2gxyfqoHaIZYdK1ULUv+6z3fRPZEPBKE4 BaXKWcEYYiw92vm36Y61PjOHI3q7t3MgR2b6DZtqt9IkUT3DRtymFt1v/GTAWceTn8 Ft1i0SBBIuZVCcuidtLV7nmc2HB9Ssq6pxKRQE1NidxRnmbHWlQMzqjw9Xlw3gRf1S YEwhbJ+08t5j0dlmwN6ffoQQtdBqoFE9CjeCWKXAYX9UFy/5E4mxA4opbbDGVJl/CE hyccQRc2xWWrA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 807916913F; Tue, 20 Jan 2026 16:18:42 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:30 -0700 Message-ID: <20260120231814.2033069-4-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: 3E6BUWCGISRSOCVI2CL3FACBKAQOORSX X-Message-ID-Hash: 3E6BUWCGISRSOCVI2CL3FACBKAQOORSX 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 03/36] video: Pass context to vidconsole_entry_start() 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 ctx parameter to vidconsole_entry_start() to allow callers to specify which vidconsole context to use. If NULL is passed, the function falls back to using the default context from vidconsole_priv. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 2 +- drivers/video/console_truetype.c | 4 ++-- drivers/video/vidconsole-uclass.c | 14 ++++++++------ include/video_console.h | 6 ++++-- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index fd7cefa1d5b..4f9230f931d 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -127,7 +127,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, return log_msg_ret("cur", -ENOENT); vidconsole_set_cursor_pos(cons, NULL, txt->obj.bbox.x0, txt->obj.bbox.y0); - vidconsole_entry_start(cons); + vidconsole_entry_start(cons, NULL); cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars); scn->cls.insert = true; scn->cls.putch = scene_txtin_putch; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 98356de2fd2..106da0e086d 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -697,9 +697,9 @@ static int console_truetype_backspace(struct udevice *dev) return 0; } -static int console_truetype_entry_start(struct udevice *dev) +static int console_truetype_entry_start(struct udevice *dev, void *vctx) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; struct vidconsole_ctx *com = &ctx->com; /* A new input line has start, so clear our history */ diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 17366d2de40..679d5d46f81 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -50,13 +50,15 @@ int vidconsole_set_row(struct udevice *dev, uint row, int clr) return ops->set_row(dev, row, clr); } -int vidconsole_entry_start(struct udevice *dev) +int vidconsole_entry_start(struct udevice *dev, void *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); + if (!ctx) + ctx = vidconsole_ctx_from_priv(dev_get_uclass_priv(dev)); if (!ops->entry_start) return -ENOSYS; - return ops->entry_start(dev); + return ops->entry_start(dev, ctx); } /* Move backwards one space */ @@ -130,10 +132,10 @@ static char *parsenum(char *s, int *num) return end; } -void vidconsole_set_cursor_pos(struct udevice *dev, void *ctxp, int x, int y) +void vidconsole_set_cursor_pos(struct udevice *dev, void *vctx, int x, int y) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = ctxp ? ctxp : vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = vctx ? vctx : vidconsole_ctx_from_priv(priv); /* Hide cursor at old position if it's visible */ vidconsole_hide_cursor(dev); @@ -144,7 +146,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, void *ctxp, int x, int y) /* make sure not to kern against the previous character */ ctx->last_ch = 0; - vidconsole_entry_start(dev); + vidconsole_entry_start(dev, NULL); } /** @@ -511,7 +513,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; case '\n': vidconsole_newline(dev); - vidconsole_entry_start(dev); + vidconsole_entry_start(dev, NULL); break; case '\t': /* Tab (8 chars alignment) */ ctx->xcur_frac = ((ctx->xcur_frac / ctx->tab_width_frac) diff --git a/include/video_console.h b/include/video_console.h index a91b2a510b4..bb0445dc7c9 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -278,6 +278,7 @@ struct vidconsole_ops { * entry_start() - Indicate that text entry is starting afresh * * @dev: Device to adjust + * @ctx: Vidconsole context to use * Returns: 0 on success, -ve on error * * Consoles which use proportional fonts need to track the position of @@ -287,7 +288,7 @@ struct vidconsole_ops { * command). The driver can use this signal to empty its list of * positions. */ - int (*entry_start)(struct udevice *dev); + int (*entry_start)(struct udevice *dev, void *ctx); /** * backspace() - Handle erasing the last character @@ -695,8 +696,9 @@ int vidconsole_set_row(struct udevice *dev, uint row, int clr); * Marks the current cursor position as the start of a line * * @dev: Device to adjust + * @ctx: vidconsole context to use, or NULL to use the default */ -int vidconsole_entry_start(struct udevice *dev); +int vidconsole_entry_start(struct udevice *dev, void *ctx); /** * vidconsole_put_char() - Output a character to the current console position