From patchwork Tue Jan 20 23:17:44 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1690 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=1768951193; bh=GQqAbnZa2YxkcuZlK4sNBJVk5gNNYTJimAG5GqrHY/8=; 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=Jx20cUDvM1B0mhT2ZlVe76aRUUFvFwuCLJMH4wyLviTxlgJxrMzqQ9EmcOw6A2E8v 1INDZtjVTDfWXYIouJNF0vgwVOKVOlOl2BCojs64ptLUhhgOz5E0tSDEyXuzEQPd4u 4/c2pwJ0Ye8uqujDyZ1CJ/aDrBEVIaKIXG2ZmWdALqyaFxuHC81AtIBcTfQeuvYAks skEM54Cj4aZ1z64wj+9Yd08mopyfrqIQgC4qv8rVlV49t7HSAEkHppPuogkKE7GdZY JC54SIr8up0sq1H+eiWjgANCtHEHoKdavSp3K8HLecs06fqYCGC5Yip6pyZ9l5Jnoh 5DC7uU288Rbcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C7E6869591 for ; Tue, 20 Jan 2026 16:19:53 -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 CgfyQDs25_1Z for ; Tue, 20 Jan 2026 16:19:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951193; bh=GQqAbnZa2YxkcuZlK4sNBJVk5gNNYTJimAG5GqrHY/8=; 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=Jx20cUDvM1B0mhT2ZlVe76aRUUFvFwuCLJMH4wyLviTxlgJxrMzqQ9EmcOw6A2E8v 1INDZtjVTDfWXYIouJNF0vgwVOKVOlOl2BCojs64ptLUhhgOz5E0tSDEyXuzEQPd4u 4/c2pwJ0Ye8uqujDyZ1CJ/aDrBEVIaKIXG2ZmWdALqyaFxuHC81AtIBcTfQeuvYAks skEM54Cj4aZ1z64wj+9Yd08mopyfrqIQgC4qv8rVlV49t7HSAEkHppPuogkKE7GdZY JC54SIr8up0sq1H+eiWjgANCtHEHoKdavSp3K8HLecs06fqYCGC5Yip6pyZ9l5Jnoh 5DC7uU288Rbcw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B75B76957E for ; Tue, 20 Jan 2026 16:19:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951192; bh=l9uN6xoMRTOEfsc3rdvYCmTix50S4N241OSPxnB0zFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cL3tGR/b5PN0LustXwd4ChPedTFYEWfpv0whqCRKnjRPz6MKjLM02jmv7D1lwspE1 6erkwWegGoFkGv71/rSTy1oJWlxls60kKAuDVtZ1hEGHtdvFGQ1oul6vUPT9bJ/XVD B+CF0+4BDt15oHxLTFFjm6EAP/kmdzwKh7mqca0XlEF2mqspesl8kCBUdlAlULZ5Wi wPtPo/l6gyaWRvbqGwkWkjj2YJjbzj3GJZ63EjmZ6+MlQ974vtYJCB4SLjF3kwfOdR 7gLlI4Iv9QlXbM0sitPpu36LKhaK/6f7h8SHii4fdI/sNHug10mC7qWj9vZ/LChoGW 8c6/BvPzKmPNg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A12369572; Tue, 20 Jan 2026 16:19:52 -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 gUZSK2WnzThx; Tue, 20 Jan 2026 16:19:52 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951188; bh=RLhFokF9v46OB00+x6MYpkhT+/OX7z5lvNHT+ppdpZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WYcKjRVy33r8dQLue+J4D8N9BhYEDSk8hCimNNO/kAdIayuOQbsmwbFqCDon58Ivb e4CwvJGyX+5+STLmm48lImDolFwjKexd9t/gVQ2DUx/3FqyW6zt2cTWCiIQGZGKwgc bhukx3OfTUpfwRnxzpk/iLBAvgXjmfIl4uW2HMeAKnRiOr2zxQ6BCL55ogPz1FfAGZ hGStQOkZ2M+9rjF5gm6SAV6hXyUUxJAMi634zyUW8yz2kDBlxziDI39Mlkg+mNhPTI OHhPsNscd8nW1qZ3oSxldbTuuxho8HNm6b5WVt6lr0tcFiO/7Yt/Rz2q16aHvAQW4P pVgyBz0AJloLQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 207ED6913F; Tue, 20 Jan 2026 16:19:48 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:44 -0700 Message-ID: <20260120231814.2033069-18-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: J64A23TC4SNH4D5SWSF7FV72RR3ZIFAV X-Message-ID-Hash: J64A23TC4SNH4D5SWSF7FV72RR3ZIFAV 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 17/36] video: Pass context to vidconsole_show/hide_cursor() 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 vctx parameter to vidconsole_show_cursor() and vidconsole_hide_cursor() to allow passing in a specific vidconsole context. If NULL, the default context from priv is used. Update all callers accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 2 +- drivers/video/vidconsole-uclass.c | 20 ++++++++++---------- include/video_console.h | 10 ++++++---- test/dm/video.c | 4 ++-- 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 296b2fb1a1b..007f827f776 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -84,7 +84,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, if (ret) return log_msg_ret("sav", ret); - vidconsole_show_cursor(cons); + vidconsole_show_cursor(cons, NULL); } return 0; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 6258513b07e..7b23a0a68ac 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -76,7 +76,7 @@ static int vidconsole_back(struct udevice *dev, struct vidconsole_ctx *ctx) } /* Hide cursor at old position if it's visible */ - vidconsole_hide_cursor(dev); + vidconsole_hide_cursor(dev, ctx); ctx->xcur_frac -= VID_TO_POS(ctx->x_charsize); if (ctx->xcur_frac < ctx->xstart_frac) { @@ -136,10 +136,10 @@ static char *parsenum(char *s, int *num) 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 = vctx ? vctx : vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx_from_priv(priv); /* Hide cursor at old position if it's visible */ - vidconsole_hide_cursor(dev); + vidconsole_hide_cursor(dev, ctx); ctx->xcur_frac = VID_TO_POS(x); ctx->xstart_frac = ctx->xcur_frac; @@ -147,7 +147,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, void *vctx, int x, int y) /* make sure not to kern against the previous character */ ctx->last_ch = 0; - vidconsole_entry_start(dev, NULL); + vidconsole_entry_start(dev, ctx); } /** @@ -494,7 +494,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) int cp, ret; /* Hide cursor to avoid artifacts */ - vidconsole_hide_cursor(dev); + vidconsole_hide_cursor(dev, ctx); if (ansi->escape) { vidconsole_escape_char(dev, ctx, ch); @@ -767,10 +767,10 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf) } #ifdef CONFIG_CURSOR -int vidconsole_show_cursor(struct udevice *dev) +int vidconsole_show_cursor(struct udevice *dev, void *vctx) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx_from_priv(priv); struct vidconsole_ops *ops = vidconsole_get_ops(dev); struct vidconsole_cursor *curs = &ctx->curs; int ret; @@ -808,10 +808,10 @@ int vidconsole_show_cursor(struct udevice *dev) return 0; } -int vidconsole_hide_cursor(struct udevice *dev) +int vidconsole_hide_cursor(struct udevice *dev, void *vctx) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx_from_priv(priv); struct vidconsole_cursor *curs = &ctx->curs; int ret; @@ -1015,7 +1015,7 @@ void vidconsole_idle(struct udevice *dev) * but vidconsole_show_cursor() calls get_cursor_info() to * recalc the position anyway. */ - vidconsole_show_cursor(dev); + vidconsole_show_cursor(dev, ctx); } } diff --git a/include/video_console.h b/include/video_console.h index 2b299661e1b..6b8278123da 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -580,9 +580,10 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf); * Shows a cursor at the current position. * * @dev: Console device to use + * @vctx: Vidconsole context to use, or NULL to use default * Return: 0 if OK, -ve on error */ -int vidconsole_show_cursor(struct udevice *dev); +int vidconsole_show_cursor(struct udevice *dev, void *vctx); /** * vidconsole_hide_cursor() - Hide the cursor @@ -590,9 +591,10 @@ int vidconsole_show_cursor(struct udevice *dev); * Hides the cursor if it's currently visible * * @dev: Console device to use + * @vctx: Vidconsole context to use, or NULL to use default * Return: 0 if OK, -ve on error */ -int vidconsole_hide_cursor(struct udevice *dev); +int vidconsole_hide_cursor(struct udevice *dev, void *vctx); /** * vidconsole_readline_start() - Enable cursor for a video console @@ -633,12 +635,12 @@ void vidconsole_readline_start_all(bool indent); */ void vidconsole_readline_end_all(void); #else -static inline int vidconsole_show_cursor(struct udevice *dev) +static inline int vidconsole_show_cursor(struct udevice *dev, void *vctx) { return 0; } -static inline int vidconsole_hide_cursor(struct udevice *dev) +static inline int vidconsole_hide_cursor(struct udevice *dev, void *vctx) { return 0; } diff --git a/test/dm/video.c b/test/dm/video.c index e4599be30a8..ef0c0c5265b 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1198,7 +1198,7 @@ static int check_cursor_backspace(struct unit_test_state *uts, with_a = video_compress_fb(uts, dev, false); /* Show cursor at current position (after 'a') */ - ut_assertok(vidconsole_show_cursor(con)); + ut_assertok(vidconsole_show_cursor(con, NULL)); ut_assert(curs->visible); ut_assert(curs->saved); ut_asserteq(exp_height, curs->height); @@ -1223,7 +1223,7 @@ static int check_cursor_backspace(struct unit_test_state *uts, ut_assert(after_idle != with_a); /* Hide the cursor */ - ut_assertok(vidconsole_hide_cursor(con)); + ut_assertok(vidconsole_hide_cursor(con, NULL)); ut_assert(curs->enabled); ut_assert(!curs->visible); ut_assert(!curs->saved);