From patchwork Tue Jan 20 23:17:54 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1700 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=1768951239; bh=vBv6azX7Vxsbg2KLsvgn3IxKx5NZqWbMGffO8ynnZX0=; 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=NaYxe6qYOhDCFTzwlzlhrcVa/Wuzrz3Oh9g3ndc8eEv/cc46TZHd8ZDacJZCUdt4J /avyPUrtrKw2ygaXGKEfBCTbkZ76IV/W55MEXFgW4UksIwAuW6og5DsgJWrbIBCrxP Vj+H17KieR9x9JvdlWsicnsR7Cl6NJ5prsUs3zLTTdKeOikOX3EiS4AHbBkemqG84d 1LcVfJV28A6geNozpt2tuCUT4c2MTg/vJnehQWV3JuqXlaHGaw6CzfbzgNIbNBMDRE /rofbZ1GJWorAx2Hv1Zb5/GfQrFkXVIx+qoXnOeX5UqQKZloB4/9qWCZ6Tu1u7QKL3 0+YY84jEqSYwA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4A5D76913F for ; Tue, 20 Jan 2026 16:20:39 -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 UiBmBnQscoG5 for ; Tue, 20 Jan 2026 16:20:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951239; bh=vBv6azX7Vxsbg2KLsvgn3IxKx5NZqWbMGffO8ynnZX0=; 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=NaYxe6qYOhDCFTzwlzlhrcVa/Wuzrz3Oh9g3ndc8eEv/cc46TZHd8ZDacJZCUdt4J /avyPUrtrKw2ygaXGKEfBCTbkZ76IV/W55MEXFgW4UksIwAuW6og5DsgJWrbIBCrxP Vj+H17KieR9x9JvdlWsicnsR7Cl6NJ5prsUs3zLTTdKeOikOX3EiS4AHbBkemqG84d 1LcVfJV28A6geNozpt2tuCUT4c2MTg/vJnehQWV3JuqXlaHGaw6CzfbzgNIbNBMDRE /rofbZ1GJWorAx2Hv1Zb5/GfQrFkXVIx+qoXnOeX5UqQKZloB4/9qWCZ6Tu1u7QKL3 0+YY84jEqSYwA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 391366959D for ; Tue, 20 Jan 2026 16:20:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951237; bh=x7m8ndRNWnnKq8pdpw9j+HY0Q3Z8cPo90yYtuBIDePw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OYdngUVu7fbhnwiY9DqEB7amLX0y/3wVPyQkUt2TruvYZqPTwSIAizw9aGxVZELLq Rz/jr6CNBRl7dc8ITp5AfLbH8LkQYalsVGKA/T1X/czoAhbScn2V6X+pnA1CzBP7IZ TgQsV/yv4cB+xDcQ7lOHo818oXkHLJVbj0zcTItNMMX7chnnGupSXGs3kpAtOArD8K z1q/28jTtIcb2AZcyrvlBj5+fcBO83jFbtk0H5V1oJQkwFGDUHtN7gh1hDdmKUQvNy mYoO3/UAax9+fQgK2fb3Xt68UwwYF6QlDukrIyuhnJFJ2aMRzsZLIMFhbjL3htB49J wOXtKTC6nm0DQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3EAEA6959D; Tue, 20 Jan 2026 16:20:37 -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 00wrszMVZtM5; Tue, 20 Jan 2026 16:20:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951232; bh=5C8M/5Eja1SotqRDAl+tziDHmmJWnJKzGDem5PWv7mw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nmV99prZfKvneIjjlL25fyhnPgVKO5GUu+mQfQ+MLYgbRh01BILmfEYBVQki9+bsC IIKtxyCNEF30Da8h0XlilDP7bnLgxj9h7XnCuimWH3pukCJSlbOmfZOwx6iLQyqAGc KX/5MipxOe45EF0src9w7L7LDWQQXNAUgHHpIGdUdb2aBcg4HSGh2eL73QZ/wCtEgj XGOZBt64pPyFV1t1ogSJw4dLmjVgSR5oZj9VVFMAkn8sKUXx3rAH1567c/pthfHeEC vudd5jgdm5U6PX7klTvQYFkrhQTLXhJCqWOoDSOULKe0I91YEcCa5F9B5SxHMi2AZy i4Lr44Cb4q9GQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6C40F6913F; Tue, 20 Jan 2026 16:20:32 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:54 -0700 Message-ID: <20260120231814.2033069-28-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: MFGHOEDTRWZIOGTRKGUBMYJHXS4JXQH2 X-Message-ID-Hash: MFGHOEDTRWZIOGTRKGUBMYJHXS4JXQH2 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 27/36] video: Pass context to get_font_size() 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 Update the get_font_size() ops method and vidconsole_get_font_size() wrapper to take a context parameter. This allows callers to query the font size for a specific context rather than always using the default. The wrapper gets the default context if NULL is passed, while the driver implementations expect a valid context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- cmd/font.c | 2 +- drivers/video/console_core.c | 3 ++- drivers/video/console_truetype.c | 5 +++-- drivers/video/vidconsole-uclass.c | 7 +++++-- drivers/video/vidconsole_internal.h | 3 ++- include/video_console.h | 8 ++++++-- test/cmd/font.c | 6 +++--- 7 files changed, 22 insertions(+), 12 deletions(-) diff --git a/cmd/font.c b/cmd/font.c index ca759df79a3..6607fcc1373 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -64,7 +64,7 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; - ret = vidconsole_get_font_size(dev, &font_name, &size); + ret = vidconsole_get_font_size(dev, NULL, &font_name, &size); if (ret) { printf("Failed (error %d)\n", ret); return CMD_RET_FAILURE; diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 483639e65c4..c26a35e435d 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -319,7 +319,8 @@ int console_probe(struct udevice *dev) return 0; } -const char *console_simple_get_font_size(struct udevice *dev, uint *sizep) +const char *console_simple_get_font_size(struct udevice *dev, void *ctx, + uint *sizep) { struct console_simple_priv *priv = dev_get_priv(dev); diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index de2992ec748..f797dbe16f9 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1234,9 +1234,10 @@ static int truetype_get_cursor_info(struct udevice *dev, void *vctx) return 0; } -const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep) +const char *console_truetype_get_font_size(struct udevice *dev, void *vctx, + uint *sizep) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; if (ctx->cur_fontdata) { /* Using fixed font */ diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index b5a129d82b7..83872b54b5d 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -636,14 +636,17 @@ int vidconsole_get_font(struct udevice *dev, int seq, return ops->get_font(dev, seq, info); } -int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep) +int vidconsole_get_font_size(struct udevice *dev, void *ctx, const char **name, + uint *sizep) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); + if (!ctx) + ctx = vidconsole_ctx(dev); if (!ops->get_font_size) return -ENOSYS; - *name = ops->get_font_size(dev, sizep); + *name = ops->get_font_size(dev, ctx, sizep); return 0; } diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 60ff7bed758..23d29fea081 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -170,7 +170,8 @@ int console_probe(struct udevice *dev); * Internal function to be used in as ops. * See details in video_console.h get_font_size function **/ -const char *console_simple_get_font_size(struct udevice *dev, uint *sizep); +const char *console_simple_get_font_size(struct udevice *dev, void *ctx, + uint *sizep); /** * Internal function to be used in as ops. diff --git a/include/video_console.h b/include/video_console.h index 500a5974a57..6d635fd5971 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -325,10 +325,12 @@ struct vidconsole_ops { * get_font_size() - get the current font name and size * * @dev: vidconsole device + * @ctx: vidconsole context to use (cannot be NULL) * @sizep: Place to put the font size (nominal height in pixels) * Returns: Current font name */ - const char *(*get_font_size)(struct udevice *dev, uint *sizep); + const char *(*get_font_size)(struct udevice *dev, void *ctx, + uint *sizep); /** * select_font() - Select a particular font by name / size @@ -842,11 +844,13 @@ void vidconsole_list_fonts(struct udevice *dev); * vidconsole_get_font_size() - get the current font name and size * * @dev: vidconsole device + * @ctx: vidconsole context to use (NULL to use default) * @sizep: Place to put the font size (nominal height in pixels) * @name: pointer to font name, a placeholder for result * Return: 0 if OK, -ENOSYS if not implemented in driver */ -int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep); +int vidconsole_get_font_size(struct udevice *dev, void *ctx, const char **name, + uint *sizep); /** * vidconsole_set_quiet() - Select whether the console should output stdio diff --git a/test/cmd/font.c b/test/cmd/font.c index 4991608e267..eab832347cb 100644 --- a/test/cmd/font.c +++ b/test/cmd/font.c @@ -43,7 +43,7 @@ static int font_test_base(struct unit_test_state *uts) ut_assert_console_end(); - ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_assertok(vidconsole_get_font_size(dev, NULL, &name, &size)); if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_ANKACODER)) ut_asserteq_str("ankacoder_c75_r", name); else if (IS_ENABLED(CONFIG_CONSOLE_TRUETYPE_NIMBUS)) @@ -71,7 +71,7 @@ static int font_test_base(struct unit_test_state *uts) ut_assertok(ret); ut_assert_console_end(); - ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_assertok(vidconsole_get_font_size(dev, NULL, &name, &size)); ut_asserteq_str("cantoraone_regular", name); ut_asserteq(40, size); ut_assertok(ut_check_console_end(uts)); @@ -90,7 +90,7 @@ static int font_test_base(struct unit_test_state *uts) ut_assertok(run_command("font select", 0)); ut_assertok(ut_check_console_end(uts)); - ut_assertok(vidconsole_get_font_size(dev, &name, &size)); + ut_assertok(vidconsole_get_font_size(dev, NULL, &name, &size)); ut_asserteq_str("nimbus_sans_l_regular", name); ut_asserteq(CONFIG_CONSOLE_TRUETYPE_SIZE, size);