From patchwork Tue Jan 20 23:17:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1674 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=1768951118; bh=8FlTjAXlqG/Sc4A/3brATOqTZn9BjHJQBPUbPErIZPc=; 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=LwJeXo3XQesW2VjNPCkVbs3DkhWFeFmwbWay2yTGwHBqOykfuBOtH480GHwWkkl/F DP5BLnNidZKh+5udQkq7sEuehAY05DE4CouUPahiLIq3Az1Xc7sIlIpIYATzNJ1EEw bI1bQMiahMNerkzHMwxmPlcIAklgyki5ZcDAE3wEcEFJEwlq5ijdAJgs08otEvNqTb A140YJ+W3hQ8g+zW6ew10Qf9icdMks0qj7hEOlllfeUbvDaFkg0WQ/ZYm9fHitIiw5 cTlJTtRDF/SrDPb3AQ75WOYhfEbbgXGt1KysAScMfBYdHew2m/X7jWBJMPUUVnt6oP 6Ij0HXdBUVPgg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 588AB69589 for ; Tue, 20 Jan 2026 16:18:38 -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 rTImhIeDv0j1 for ; Tue, 20 Jan 2026 16:18:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951118; bh=8FlTjAXlqG/Sc4A/3brATOqTZn9BjHJQBPUbPErIZPc=; 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=LwJeXo3XQesW2VjNPCkVbs3DkhWFeFmwbWay2yTGwHBqOykfuBOtH480GHwWkkl/F DP5BLnNidZKh+5udQkq7sEuehAY05DE4CouUPahiLIq3Az1Xc7sIlIpIYATzNJ1EEw bI1bQMiahMNerkzHMwxmPlcIAklgyki5ZcDAE3wEcEFJEwlq5ijdAJgs08otEvNqTb A140YJ+W3hQ8g+zW6ew10Qf9icdMks0qj7hEOlllfeUbvDaFkg0WQ/ZYm9fHitIiw5 cTlJTtRDF/SrDPb3AQ75WOYhfEbbgXGt1KysAScMfBYdHew2m/X7jWBJMPUUVnt6oP 6Ij0HXdBUVPgg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3EF8169583 for ; Tue, 20 Jan 2026 16:18:38 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951117; bh=PusqgzgAa41wfroRF9+/NH27LYX1xDlrDHaDmo47364=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lm4Yd+BxFGlaR0CcYrHjNPj9Cc95i+qDmvFa3RsLE+OtcKMfvOgDgRk8yeVbI7ygQ K6t9YEWhhlMXoFAqLvJS+rCs13zj837VOaGZmTs4kRRUzFhpYJ6i8gKEcG7bnGNK6b vCEUClhZsrjK4K6pF7+2KM1wOuMnete+VktmQjsa/9PiOpw73BmxGqCvRYnJ67G27W 3ZLU6MHMtTXq7gxJQ154ux3w8qgIooBFDR1LnEGLBVZ13+eswpQd0qex7Qpr1u8NEw ZkDPHv0sj2d0SJhPOlagYEb1gLN4HaqcIH7AAV36YrLUvjFj4zBmubSzSvpXyXVZOq eSEypYTrvpBkw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8D29B6957E; Tue, 20 Jan 2026 16:18: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 PxL46tWjypXZ; Tue, 20 Jan 2026 16:18:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951113; bh=UeSGs6dpKOJg6V0qTnaLnZhZMtQCLK5uNU7YTi9pj1k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=esNcMiNd0ySk4cfM0hFxi4awKNqpc8aj/HKKnu4V0v+x2CSa8vdhoAjZHy5HO5Vus xzSBzNHYJSRrblHJPyycdzTN7plSHIpC4c9r9iWJfe5hAvUuu6YegpUlTZmAdAvlGb OKRTQmSAkGhr8bu8thNn2drII6nP/oK1+fDGPXWTt91KBLFVwy9OlqD1Zy8IuJIJ5C xHL4ipIt8Qx0+gojkwhOdyUUxVxo7RGtVOjkpJMRu1mBuBE4g4vfU0m2Xkux8oVmkN LUti1Kw1DYqrh49juFo21KC8jkm87k8AFUArK16FLNYI3bzREQntzwKSrZ9QxlETN2 kb+XaZZ/sBkxQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2C15C6913F; Tue, 20 Jan 2026 16:18:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:28 -0700 Message-ID: <20260120231814.2033069-2-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: SK4KDQM7FD5ACQNMTFXXG76W6WC7QB7P X-Message-ID-Hash: SK4KDQM7FD5ACQNMTFXXG76W6WC7QB7P 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 01/36] test: Fix LUKS device-name collision in CI environments 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 In CI environments where process IDs are reused quickly, the LUKS device name (luks_test_) can collide with a stale device from a previous test run. This causes cryptsetup to fail with "Device already exists". Add a timestamp component to the device name to ensure uniqueness even when PIDs are reused. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- test/py/tests/fs_helper.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/test/py/tests/fs_helper.py b/test/py/tests/fs_helper.py index ccde6683534..269b1c2d10f 100644 --- a/test/py/tests/fs_helper.py +++ b/test/py/tests/fs_helper.py @@ -11,6 +11,7 @@ import shutil from subprocess import call, check_call, check_output, CalledProcessError, run from subprocess import DEVNULL import tempfile +import time class FsHelper: @@ -269,9 +270,11 @@ class FsHelper: 'kernel module is loaded and you have permission to use ' 'device-mapper. This is required for LUKS encryption tests.') - device_name = f'luks_test_{os.getpid()}' + # Use PID and timestamp for uniqueness in CI environments where PIDs + # get reused + device_name = f'luks_test_{os.getpid()}_{int(time.time() * 1000) % 100000}' - # Clean up any stale device with the same name + # Clean up any stale device with the same name (unlikely with timestamp) run(['sudo', 'cryptsetup', 'close', device_name], stdout=DEVNULL, stderr=DEVNULL, check=False) From patchwork Tue Jan 20 23:17:29 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1675 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=1768951124; bh=gy74UkNJwgAdk3wDYCIdmz5th2oa8O02cUMxoYrlAFQ=; 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=wAsNJowi4zpxlRSQSrG7bb3+AnNPABdHxO0Yb0zRd+0e4Mwqbh90FNyns1qp+tyJB ItGDkrhT//UIkZLzRBrE+hIuElBW27tHfCV13xWFoOydlfLT5y9/ZKOtbo4MCQRxdF UrCuc0uFEDr1+8hVPyqpWJ/GCduBJPNY+jWKBDWMF3gLxN9jgUKfWvC8ILUKLnb6QJ NdLDjykUQE86Xp4fbTn+SFCb/oVpvgGB7F1creB6rdk+pFalcKroVO4faOwJWQYyhl 6px4gvDkRyZ78Jde2v69e2tT9lnl9DlsT/XAw7b03a65+rQgI8nzyWhJoRaq+7q3aD uDaaqzftg65/g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2741869587 for ; Tue, 20 Jan 2026 16:18:44 -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 iATBV4UFOPCq for ; Tue, 20 Jan 2026 16:18:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951124; bh=gy74UkNJwgAdk3wDYCIdmz5th2oa8O02cUMxoYrlAFQ=; 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=wAsNJowi4zpxlRSQSrG7bb3+AnNPABdHxO0Yb0zRd+0e4Mwqbh90FNyns1qp+tyJB ItGDkrhT//UIkZLzRBrE+hIuElBW27tHfCV13xWFoOydlfLT5y9/ZKOtbo4MCQRxdF UrCuc0uFEDr1+8hVPyqpWJ/GCduBJPNY+jWKBDWMF3gLxN9jgUKfWvC8ILUKLnb6QJ NdLDjykUQE86Xp4fbTn+SFCb/oVpvgGB7F1creB6rdk+pFalcKroVO4faOwJWQYyhl 6px4gvDkRyZ78Jde2v69e2tT9lnl9DlsT/XAw7b03a65+rQgI8nzyWhJoRaq+7q3aD uDaaqzftg65/g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 14EEB6957E for ; Tue, 20 Jan 2026 16:18:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951122; bh=pYZVjntZpIJnrgH/TNVo9OpdAOC7cr3et2uNheyahH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V56PRKPamsJR0N2rWlnHBodVpmK/mHIbr37Rc3v8fyVy8vtb9DhRZZ8rdDD5uN9js lg++AYp42Tar5epcePGrdzHg54wesdcb9ZVM8Q1oo0QokAgZDU5vCv9LwZ8ub5f6Sy VpRG/m4zg3wBLOP3wUisdmO+oHndtkVCy+Vh5Qtxou8YKnQaQZFnXXb4l/FnC1veKF 5EjOQYXzswdqjj3nSoW88SaMljOZ1gqydyJoNrFwFAPuxiBMxL2Y1c51agxu9n6sqb u7hOmfOdxIzCpFV0BX7/DQM1BScEy18E+jg1xhfigWz9CuLkLlcH81N5Z4l+3imnlg UmTyUTkiZ1PQg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 376D869572; Tue, 20 Jan 2026 16:18:42 -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 sn_PpAuBM88h; Tue, 20 Jan 2026 16:18:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951118; bh=Wn2aJ5ZhpgDHu3VyrWld6oPi5aQoKUyEY1a83q2UZkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKLNk3bjkcdC7Ig7yO9YqExlFKaG67n7VHgR6UAkqr5Ffc5NOXIHbgwsiwtyJ1YTb ha2I7pBCjHUkvSsxQXrY3tLz5eOXIfwIm4nDedGAgXis4tbCG1pi0pLqY0pLWSNSFL i8Hre3qkHcoK4qGggPvCjRxEULy9dFbESu8gJ2E0TbJKjl5OS40yRjNVRRRVzOzBR/ zn0EZ0tNHEKBg4s452PH49MTSoI94jZsbRTzOMcg8bq8ioSxyVWQI7oyyHU4NeveRB QaR5mC29MTcO00kYMWteB/PGI8epmAXHHO508NJqhSfwJqquN5yFbg4tVM9onh+SrV fO86/kYeQxCkQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id CF1516913F; Tue, 20 Jan 2026 16:18:37 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:29 -0700 Message-ID: <20260120231814.2033069-3-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: 44UNPXOZQB3JZDM5K2JNGM5H5LWKUJGU X-Message-ID-Hash: 44UNPXOZQB3JZDM5K2JNGM5H5LWKUJGU 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 02/36] video: Pass context to vidconsole_set_cursor_pos() 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_set_cursor_pos() 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. This enables text-input objects to use their own context for cursor positioning. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/expo_test.c | 10 +++++----- boot/scene.c | 4 ++-- boot/scene_txtin.c | 2 +- cmd/video.c | 2 +- drivers/video/vidconsole-uclass.c | 6 +++--- include/video_console.h | 3 ++- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/boot/expo_test.c b/boot/expo_test.c index a5ad571eedb..ae4e70ceede 100644 --- a/boot/expo_test.c +++ b/boot/expo_test.c @@ -180,14 +180,14 @@ int expo_test_render(struct expo *exp) snprintf(buf, sizeof(buf), "frame %6d", test->render_count); x = vid_priv->xsize - 18 * ctx->x_charsize; y = 10; - vidconsole_set_cursor_pos(exp->cons, x, y); + vidconsole_set_cursor_pos(exp->cons, NULL, x, y); vidconsole_put_string(exp->cons, buf); /* Display FPS on next line (only if non-zero) */ if (test->fps_last > 0) { snprintf(buf, sizeof(buf), "fps %6d", test->fps_last); y += ctx->y_charsize; - vidconsole_set_cursor_pos(exp->cons, x, y); + vidconsole_set_cursor_pos(exp->cons, NULL, x, y); vidconsole_put_string(exp->cons, buf); } @@ -196,7 +196,7 @@ int expo_test_render(struct expo *exp) test->render_avg_us / 1000, (test->render_avg_us % 1000) / 100); y += ctx->y_charsize; - vidconsole_set_cursor_pos(exp->cons, x, y); + vidconsole_set_cursor_pos(exp->cons, NULL, x, y); vidconsole_put_string(exp->cons, buf); /* Display average sync time in milliseconds on next line */ @@ -204,7 +204,7 @@ int expo_test_render(struct expo *exp) test->sync_avg_us / 1000, (test->sync_avg_us % 1000) / 100); y += ctx->y_charsize; - vidconsole_set_cursor_pos(exp->cons, x, y); + vidconsole_set_cursor_pos(exp->cons, NULL, x, y); vidconsole_put_string(exp->cons, buf); /* Display average poll time in milliseconds on next line */ @@ -212,7 +212,7 @@ int expo_test_render(struct expo *exp) test->poll_avg_us / 1000, (test->poll_avg_us % 1000) / 100); y += ctx->y_charsize; - vidconsole_set_cursor_pos(exp->cons, x, y); + vidconsole_set_cursor_pos(exp->cons, NULL, x, y); vidconsole_put_string(exp->cons, buf); return 0; diff --git a/boot/scene.c b/boot/scene.c index 306625361b4..16814d53b65 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -685,7 +685,7 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, bbox.y1 = obj->bbox.y1; if (!mline) { - vidconsole_set_cursor_pos(cons, x, y); + vidconsole_set_cursor_pos(cons, NULL, x, y); draw_string(cons, str, strlen(str), obj->flags & SCENEOF_PASSWORD); } @@ -704,7 +704,7 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, y = obj->bbox.y0 + offset.yofs + mline->bbox.y0; if (y > bbox.y1) break; /* clip this line and any following */ - vidconsole_set_cursor_pos(cons, x, y); + vidconsole_set_cursor_pos(cons, NULL, x, y); draw_string(cons, str + mline->start, mline->len, obj->flags & SCENEOF_PASSWORD); } diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index d1aa24dac9f..fd7cefa1d5b 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -126,7 +126,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, if (!txt) return log_msg_ret("cur", -ENOENT); - vidconsole_set_cursor_pos(cons, txt->obj.bbox.x0, txt->obj.bbox.y0); + vidconsole_set_cursor_pos(cons, NULL, txt->obj.bbox.x0, txt->obj.bbox.y0); vidconsole_entry_start(cons); cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars); scn->cls.insert = true; diff --git a/cmd/video.c b/cmd/video.c index 4f00ffa2f77..5c228b48058 100644 --- a/cmd/video.c +++ b/cmd/video.c @@ -85,7 +85,7 @@ static int do_video_write(struct cmd_tbl *cmdtp, int flag, int argc, row = hextoul(colon + 1, NULL); if (use_pixels) - vidconsole_set_cursor_pos(dev, col, row); + vidconsole_set_cursor_pos(dev, NULL, col, row); else vidconsole_position_cursor(dev, col, row); diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 05426138b09..17366d2de40 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -130,10 +130,10 @@ static char *parsenum(char *s, int *num) return end; } -void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) +void vidconsole_set_cursor_pos(struct udevice *dev, void *ctxp, int x, int y) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); + struct vidconsole_ctx *ctx = ctxp ? ctxp : vidconsole_ctx_from_priv(priv); /* Hide cursor at old position if it's visible */ vidconsole_hide_cursor(dev); @@ -964,7 +964,7 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row) x = min_t(short, col * ctx->x_charsize, vid_priv->xsize - 1); y = min_t(short, row * ctx->y_charsize, vid_priv->ysize - 1); - vidconsole_set_cursor_pos(dev, x, y); + vidconsole_set_cursor_pos(dev, NULL, x, y); } void vidconsole_set_quiet(struct udevice *dev, bool quiet) diff --git a/include/video_console.h b/include/video_console.h index 0e9784c8e3c..a91b2a510b4 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -774,10 +774,11 @@ int vidconsole_clear_and_reset(struct udevice *dev); * updated to the same position, so that a newline will return to @x * * @dev: video console device to update + * @ctx: vidconsole context to use, or NULL to use the default * @x: x position from left in pixels * @y: y position from top in pixels */ -void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y); +void vidconsole_set_cursor_pos(struct udevice *dev, void *ctx, int x, int y); /** * vidconsole_list_fonts() - List the available fonts 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 From patchwork Tue Jan 20 23:17:31 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1677 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=1768951133; bh=Eevv5fPKXytyFozgtuiia2qVLlAvAtsxpMcm7xXLQNg=; 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=ruNATsW2WbZ0+N/a7HjDnv1+lXBy8RBaCHGmoc6EhLprpyuYZsVLacKEtANmGB4j2 KHZRvtMkF9CFtUfwg5n7DiEsjA/cryBTF3VTo8/3MSQyiyx/I1WER4M6g7COfWdzsk RO4Hxl5U+j+C1cwXotaaxj4BwxT+8XLUTX+W/IQmEDHtHcphCtvBCVYhSnhpn/QCHj Bjc5CpQOhfPPVURk5GFGGghIRFonis/g0vtOHs8abXWyAQ2IxNXZzk8/2QTwUstMyV j9Qi+ROwUf2yL5GTXV7jAmZ/29WLXMNHWWExahWMejDYFcfVknecrWhT58OfYDa3sc H15WnYDNhc2qg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 132A969581 for ; Tue, 20 Jan 2026 16:18: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 LqfPjKmvVdLH for ; Tue, 20 Jan 2026 16:18:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951133; bh=Eevv5fPKXytyFozgtuiia2qVLlAvAtsxpMcm7xXLQNg=; 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=ruNATsW2WbZ0+N/a7HjDnv1+lXBy8RBaCHGmoc6EhLprpyuYZsVLacKEtANmGB4j2 KHZRvtMkF9CFtUfwg5n7DiEsjA/cryBTF3VTo8/3MSQyiyx/I1WER4M6g7COfWdzsk RO4Hxl5U+j+C1cwXotaaxj4BwxT+8XLUTX+W/IQmEDHtHcphCtvBCVYhSnhpn/QCHj Bjc5CpQOhfPPVURk5GFGGghIRFonis/g0vtOHs8abXWyAQ2IxNXZzk8/2QTwUstMyV j9Qi+ROwUf2yL5GTXV7jAmZ/29WLXMNHWWExahWMejDYFcfVknecrWhT58OfYDa3sc H15WnYDNhc2qg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 014D369572 for ; Tue, 20 Jan 2026 16:18:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951131; bh=q9HbK0LjsYjz/plSV2tFfBLn0+09Ki8TxfJzlFfXE+0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HMiV1u518r7n4oCgzY7L79o5lOttzvtQyKhNgTgGSFP5tFO5OUPKr+oSMGyDiRC75 iwC68pYh/eaGU8oj0jvyDZ8aagWFEL+3b97HgqCfn/oDEQLZFE42A4fczFqIgPKYdM E9mywiCa44wBso2mka2wS7+rPCb9E1ZUG2PJMFKbGZbKS3j7WyBVrcjdqBkDJe5xz/ f98GzbKqAwKA4T4cAZly/I5gcOTICwInnNFX+N0LOWKNPPHTdiKHb1rpvqdG3HQm8j pSnB0KkMF93yFqa0s/4K6REl1eaoGU7/USb4LtX8oEH0mzkGMsDsBicGVCcCLCMY2x Fc+heAv+9QyFg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 708C269441; Tue, 20 Jan 2026 16:18:51 -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 EY-ZyTUAn1L2; Tue, 20 Jan 2026 16:18:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951127; bh=/b/KV0zUH+C73bP35PDGbiy7V1Cnke8HNwAzUTHSmF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JxFg1lJSM04nlsDQLqn4fNtlF9XU5FFs6ZxZ8SmGnwYSzgh8ZWNy5wgRiKVP1OlVX e6EnJbaibPSMBL10+pSGghNokbo2cH55YWMRt9ZZoXVA9BuA1Fhj7q1xlU4acaSVQB wgBMNAulk1kpEgB7c+4NpQ0QrEyaoXzOKOrGEc/tDTF1IGsACxP5X3Xtu1C7DY7J9N zngpAlsye06lZeRNqpGyN0jexH7r/8igTTnV/j5m5NZbxs/HsDb9CL2yBL1WONkD8u XqBsbNPuEnfchAT7aHhkvr9qyYC746ImCljmNIIDf/k3bGAJiKXz1EmrErREO1tLg6 hJqYMWGY25pDA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 276D16913F; Tue, 20 Jan 2026 16:18:47 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:31 -0700 Message-ID: <20260120231814.2033069-5-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: QPPLGSJLYFDNVUR22WQXIWRGURJHHLRT X-Message-ID-Hash: QPPLGSJLYFDNVUR22WQXIWRGURJHHLRT 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 04/36] cli: Split initial-text output from cli_cread_init() 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 initial-text output from cli_cread_init() into a new function cli_cread_add_initial(). This allows callers to set up additional state (like the putch callback) before the initial text is output. Update cread_line() and scene_txtin_open() to call the new function. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 1 + common/cli_readline.c | 12 ++++++++---- include/cli.h | 10 ++++++++++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 4f9230f931d..b5413dc145f 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -131,6 +131,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, cli_cread_init(&scn->cls, abuf_data(&tin->buf), tin->line_chars); scn->cls.insert = true; scn->cls.putch = scene_txtin_putch; + cli_cread_add_initial(&scn->cls); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); diff --git a/common/cli_readline.c b/common/cli_readline.c index 4eb34d7cf7c..0173072109b 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -470,16 +470,19 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar) void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size) { - int init_len = strlen(buf); - memset(cls, '\0', sizeof(struct cli_line_state)); cls->insert = true; cls->buf = buf; cls->len = buf_size; +} + +void cli_cread_add_initial(struct cli_line_state *cls) +{ + int init_len = strlen(cls->buf); if (init_len) - cread_add_str(cls, buf, init_len, 0, &cls->num, &cls->eol_num, - buf, buf_size); + cread_add_str(cls, cls->buf, init_len, 0, &cls->num, + &cls->eol_num, cls->buf, cls->len); } static int cread_line(const char *const prompt, char *buf, unsigned int *len, @@ -492,6 +495,7 @@ static int cread_line(const char *const prompt, char *buf, unsigned int *len, cli_ch_init(cch); cli_cread_init(cls, buf, *len); + cli_cread_add_initial(cls); cls->prompt = prompt; cls->history = true; cls->cmd_complete = true; diff --git a/include/cli.h b/include/cli.h index 88f96c03cb3..ec0f5d31046 100644 --- a/include/cli.h +++ b/include/cli.h @@ -279,6 +279,16 @@ int cread_line_process_ch(struct cli_line_state *cls, char ichar); */ void cli_cread_init(struct cli_line_state *cls, char *buf, uint buf_size); +/** + * cli_cread_add_initial() - Output initial buffer contents + * + * Called after cli_cread_init() to output the initial text in the buffer and + * set up the line state accordingly + * + * @cls: CLI line state + */ +void cli_cread_add_initial(struct cli_line_state *cls); + /** cread_print_hist_list() - Print the command-line history list */ void cread_print_hist_list(void); From patchwork Tue Jan 20 23:17:32 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1678 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=1768951138; bh=6KBTv7ZW07mjwekShSbuH8LK1Cc0A5E0wAwIr0T5G0Q=; 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=Rt7/MtErhgbT3zTtRBEQlmcP8i2Xwap5jcfflMWdglC0C2qmWZ2GZesZtCfY7vtXu UgugUvGqG1cYoX0xlvSB+Ttncjhxx2RAVNmAQX37I23JkTjs74tLZ6BE6dlEWiT477 8mfROjan3pXWxWFyWXWm90lidUYHI4/KdZMGGT7rkapyJW9MIb3NyprMQd1YoGTqeQ QfAjiIpWHNUm4kSn1uorGcDYGADIX1jXBtnYHa13gXjUVz9DSkfLD4HclGptbW9lmR DjKb3cUGLHpmofzwDvhrJy1VfFaLWcR0J+zQ/IkaHJWpJgUO7WOffRXMNt5AURQ8JF zGW53FFzwCBgQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1515769588 for ; Tue, 20 Jan 2026 16:18:58 -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 nfxco82yTgUt for ; Tue, 20 Jan 2026 16:18:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951137; bh=6KBTv7ZW07mjwekShSbuH8LK1Cc0A5E0wAwIr0T5G0Q=; 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=HW6Sjz3roUzzw6Os9MEgYPq0+CRnRAlKR+C/WjL9AeOSX/oapGTLB7jG7ndksOts1 UCgm7RHBqMAb7htKmwrbFTDBQQ4F/pXBeR0mF7STpGpGWEmxWLJae02atrfv7n048Z bH+MUIRwb8JbkEb4yYpWqDHxjTA2j/7Y2YfB5YxwZbBRU8EcAHovUt6+kAKH+Geijz dqRK8W7aWFymlS6lDnMTxDjaLOYDpbpJr91ohMz+/atvqO8+/jMR6jqML3A34YXAgH oSqehs6W08xgo3QzZSRzuJDPyaI27IioE6D6Oq6ACSpJTezwwc9sr4uko+cFAZLH+W 8oLaqPCQGLo6Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F34496957E for ; Tue, 20 Jan 2026 16:18:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951136; bh=zYzqlCGkLg88bU0yx7YxlrvT27oHSxMOL1HfFyGPkRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mpYRS3Ty+jM/Jdtx07YfqrnUaOueIBD5EVC7x66Sml5HDS/trZY61YP63umFmKb0b QdRBf46ckFVRqYmH9n/8v7ZDvwZ+3CUuwIfpewMMqV1rsMpBf2HWfIofk7Sh6Ko9tB V3Sw+uEITVmqaW0RA8zVybvsFMFD3Sa+3u/jdKzhlUtC0qpV3UR2AIHHz3Hgmq/f28 TjSozYMUlqwhr82mH5i123RlqEr4thQgKT5fEWXjjl5lQYTJ5hzUbsouSaRiLgL8ZF /PEQTWtp9JilwR/9lF1hkgS07RWNvHH1dIqtzoCXzohhnmV2hPfXRr+vpwNLGhzTuY S4Z1Xox403lwA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 19EDC69572; Tue, 20 Jan 2026 16:18:56 -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 RW6LaRLuAdkn; Tue, 20 Jan 2026 16:18:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951132; bh=8s3VurdgQDfe8Tr8RP0JRjYguLIZgVWB6cMyNBPUbM4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8sCqhFUwRt1eAftoMlo1sCF2UWk2e4I6bxCP9lG1ckuIh2emvxUnkKmhRSJ+3yGI 4kfjwJuxd2X52N7qZi4fzGBxkOVUPIaPkSJmWa0UKq5OWMVbV+5P3uZ892kHMeEx7Y DsljhZ5We9wO2/KMCsy1eeZK1kRhsmFxxf8IQlltwWyBjL0BQmpj/aXy+fnKy27A3C lm7bYP2UpXnk1qIzZx/h4FhRnp0PXexDGN69QqNM+LFC2G+L7PRSXpuGekpLLqW057 4QAnlkYUXpZnciFeQ/XltWKKYjfEioUzAvdnDo7/JknGBzfeECHwB3QkwUbVyRRRB5 Yeo/jw+lZDy4w== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B47206913F; Tue, 20 Jan 2026 16:18:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:32 -0700 Message-ID: <20260120231814.2033069-6-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: 4IDZFQKGDAXA5C6NROU342LCG363Q7YN X-Message-ID-Hash: 4IDZFQKGDAXA5C6NROU342LCG363Q7YN 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 05/36] video: Add per-device vidconsole_readline_start/end() 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 vidconsole_readline_start() and vidconsole_readline_end() functions that operate on a single device. Rename the existing functions that iterate all consoles to have an _all suffix. Update scene_txtin.c to use the per-device versions with the expo's console, and cli_readline.c to use the _all versions. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 4 ++-- common/cli_readline.c | 4 ++-- drivers/video/vidconsole-uclass.c | 36 +++++++++++++++++----------- include/video_console.h | 39 ++++++++++++++++++++++++++----- 4 files changed, 59 insertions(+), 24 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index b5413dc145f..2b72ecaed39 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -107,7 +107,7 @@ static void scene_txtin_putch(struct cli_line_state *cls, int ch) void scene_txtin_close(struct scene *scn) { /* cursor is not needed now */ - vidconsole_readline_end(); + vidconsole_readline_end(scn->expo->cons); } int scene_txtin_open(struct scene *scn, struct scene_obj *obj, @@ -137,7 +137,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, return log_msg_ret("sav", ret); /* make sure the cursor is visible */ - vidconsole_readline_start(true); + vidconsole_readline_start(cons, true); return 0; } diff --git a/common/cli_readline.c b/common/cli_readline.c index 0173072109b..27fecd835a0 100644 --- a/common/cli_readline.c +++ b/common/cli_readline.c @@ -710,7 +710,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, puts(prompt); /* tell the vidconsole the cursor is at its start position */ - vidconsole_readline_start(false); + vidconsole_readline_start_all(false); rc = cread_line(prompt, p, &len, timeout); rc = rc < 0 ? rc : len; @@ -721,7 +721,7 @@ int cli_readline_into_buffer(const char *const prompt, char *buffer, pager_set_bypass(gd_pager(), old_bypass); pager_reset(gd_pager()); - vidconsole_readline_end(); + vidconsole_readline_end_all(); return rc; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 679d5d46f81..200bc60c55b 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -1019,30 +1019,38 @@ void vidconsole_idle(struct udevice *dev) } #ifdef CONFIG_CURSOR -void vidconsole_readline_start(bool indent) +void vidconsole_readline_start(struct udevice *dev, bool indent) { - struct uclass *uc; - struct udevice *dev; + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); - uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + ctx->curs.indent = indent; + ctx->curs.enabled = true; + vidconsole_mark_start(dev); +} - ctx->curs.indent = indent; - ctx->curs.enabled = true; - vidconsole_mark_start(dev); - } +void vidconsole_readline_end(struct udevice *dev) +{ + struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + + ctx->curs.enabled = false; } -void vidconsole_readline_end(void) +void vidconsole_readline_start_all(bool indent) { struct uclass *uc; struct udevice *dev; - uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) + vidconsole_readline_start(dev, indent); +} - ctx->curs.enabled = false; - } +void vidconsole_readline_end_all(void) +{ + struct uclass *uc; + struct udevice *dev; + + uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) + vidconsole_readline_end(dev); } #endif /* CURSOR */ diff --git a/include/video_console.h b/include/video_console.h index bb0445dc7c9..663f89b25f2 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -591,22 +591,41 @@ int vidconsole_show_cursor(struct udevice *dev); int vidconsole_hide_cursor(struct udevice *dev); /** - * vidconsole_readline_start() - Enable cursor for all video consoles + * vidconsole_readline_start() - Enable cursor for a video console + * + * Called at the start of command line input to show the cursor + * + * @dev: vidconsole device + * @indent: indent subsequent lines to the same position as the first line + */ +void vidconsole_readline_start(struct udevice *dev, bool indent); + +/** + * vidconsole_readline_end() - Disable cursor for a video console + * + * Called at the end of command line input to hide the cursor + * + * @dev: vidconsole device + */ +void vidconsole_readline_end(struct udevice *dev); + +/** + * vidconsole_readline_start_all() - Enable cursor for all video consoles * * Called at the start of command line input to show cursors on all * active video consoles * * @indent: indent subsequent lines to the same position as the first line */ -void vidconsole_readline_start(bool indent); +void vidconsole_readline_start_all(bool indent); /** - * vidconsole_readline_end() - Disable cursor for all video consoles + * vidconsole_readline_end_all() - Disable cursor for all video consoles * * Called at the end of command line input to hide cursors on all * active video consoles */ -void vidconsole_readline_end(void); +void vidconsole_readline_end_all(void); #else static inline int vidconsole_show_cursor(struct udevice *dev) { @@ -618,11 +637,19 @@ static inline int vidconsole_hide_cursor(struct udevice *dev) return 0; } -static inline void vidconsole_readline_start(bool indent) +static inline void vidconsole_readline_start(struct udevice *dev, bool indent) +{ +} + +static inline void vidconsole_readline_end(struct udevice *dev) +{ +} + +static inline void vidconsole_readline_start_all(bool indent) { } -static inline void vidconsole_readline_end(void) +static inline void vidconsole_readline_end_all(void) { } #endif /* CONFIG_CURSOR */ From patchwork Tue Jan 20 23:17:33 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1679 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=1768951142; bh=qR/r1T6JVFaDRO71ax0N6IZ/4nggg1WgRKibfcRiQxU=; 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=RgeZuXp2LMevwqjxdhLm1LQznSQHzkHFCsD++xT5tYZJB6LDO7wMbRzLI8pcMeq/g QKj4zq3eUaUuRHg3XV8OXQu2WgeLc1Es9r6Entempxa/VbsBsjsWFRB9JgPI6pjP2L CbqEOxqWVAVPbpDdf74RMf78wdssFzKq+7V4OnqlVILi59capvm3jC8giWGLW2aA4o 4woZ1tdMrK7RBlty1IBAQ9ifFoSAjfaRfeOTISTPkoU9OM5u/bN9fEYcWEtF3WtySd YH782jpHY+KIIdqO8qr3BCWrY4fLtRRVlrNgS/v2OaYerD8v1O+6Nhk9T/sq4gOyid iw5/6++BOqoyw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9FD5069589 for ; Tue, 20 Jan 2026 16:19:02 -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 AFQQrpoiSAhG for ; Tue, 20 Jan 2026 16:19:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951142; bh=qR/r1T6JVFaDRO71ax0N6IZ/4nggg1WgRKibfcRiQxU=; 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=RgeZuXp2LMevwqjxdhLm1LQznSQHzkHFCsD++xT5tYZJB6LDO7wMbRzLI8pcMeq/g QKj4zq3eUaUuRHg3XV8OXQu2WgeLc1Es9r6Entempxa/VbsBsjsWFRB9JgPI6pjP2L CbqEOxqWVAVPbpDdf74RMf78wdssFzKq+7V4OnqlVILi59capvm3jC8giWGLW2aA4o 4woZ1tdMrK7RBlty1IBAQ9ifFoSAjfaRfeOTISTPkoU9OM5u/bN9fEYcWEtF3WtySd YH782jpHY+KIIdqO8qr3BCWrY4fLtRRVlrNgS/v2OaYerD8v1O+6Nhk9T/sq4gOyid iw5/6++BOqoyw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8C71369587 for ; Tue, 20 Jan 2026 16:19:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951140; bh=r6xG5cnvYkkFGXGnEJsQjUZACIQ+N8Ns/7QS7x7zOk0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vYsE0UXuMIQMynvEsZ6ElVHq9tMquBrcz4egjHDT5GgLhR0xM/1voRVQX5MWg9Wca 1n8VbuoHyfr/KH29RqUrrqVFqTN9QuYyvGj1VZmIYfDK+pwXqZI61DYhEeMUCkywcN SXAN8Ar7MMfDLzdPWJesKlbnf+i6dVUeLJfAIuJuJ2Uji4+P1vgLaBG2rT8SMvOxiZ 1NE1hUigwQGP1EHioTTC+ZE7Dvcl8If3TO2cFXgvmvuhlhQ2GSotqoirKvZ1MXuy90 LdOGCFtHnsQ2qG/jB15EyDUimIiMybLCd5WrfnylHj62wlnuiuWS4aRdCYOjQaLcbi mDf8dYa1iZZ9A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A28F16957E; Tue, 20 Jan 2026 16:19:00 -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 V864MLiTEB8P; Tue, 20 Jan 2026 16:19:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951136; bh=9BEl8l9mGZV09O2xsiQhY+J8gkbvilHkQaQUBYsmtRI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ktp6GybDYMo3HIAv7RX3F64PLf+yY1OGSZWibBdR5u83mRc7NPVwXnfSpb1pib3QU wKvPbj+dFa4MUjCHBjVpJdkbqL1YniDl8IfwTrc9yeKMGMBxFTwqAuQspB0lSiP8W7 /1yRc4MP2m8L1TFlRYQ/UQwSPq5Y9/05sNlTdMW82bxNiWTpC3oHr0yDvro+Wa6ukF u81kuRUBtOqGJiw57BRfGuO3tDHkd9fyN4nMaCVEZ1v7c7MAo3VX1XlOVa2z6lZZD1 rRc4nXPDYo83Y0RQUW6qqkPmTltClvvBYoGQwozQ5COOKvoxJwe77jbEwlYhN+5dQf J/9sg2D6bVNjg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 5913A6913F; Tue, 20 Jan 2026 16:18:56 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:33 -0700 Message-ID: <20260120231814.2033069-7-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: E4LN5HT7E5PU7KNXA7DYG54KBD53US7P X-Message-ID-Hash: E4LN5HT7E5PU7KNXA7DYG54KBD53US7P 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 06/36] video: Pass context to vidconsole_readline_start/end() 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_readline_start() and vidconsole_readline_end() to allow callers to specify which vidconsole context to use. If NULL is passed, the function falls back to using the default context from the device. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 4 ++-- drivers/video/vidconsole-uclass.c | 12 ++++++------ include/video_console.h | 13 ++++++++----- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 2b72ecaed39..3944bce9a96 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -107,7 +107,7 @@ static void scene_txtin_putch(struct cli_line_state *cls, int ch) void scene_txtin_close(struct scene *scn) { /* cursor is not needed now */ - vidconsole_readline_end(scn->expo->cons); + vidconsole_readline_end(scn->expo->cons, NULL); } int scene_txtin_open(struct scene *scn, struct scene_obj *obj, @@ -137,7 +137,7 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, return log_msg_ret("sav", ret); /* make sure the cursor is visible */ - vidconsole_readline_start(cons, true); + vidconsole_readline_start(cons, NULL, true); return 0; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 200bc60c55b..ca21cb8154f 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -1019,18 +1019,18 @@ void vidconsole_idle(struct udevice *dev) } #ifdef CONFIG_CURSOR -void vidconsole_readline_start(struct udevice *dev, bool indent) +void vidconsole_readline_start(struct udevice *dev, void *vctx, bool indent) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx(dev); ctx->curs.indent = indent; ctx->curs.enabled = true; vidconsole_mark_start(dev); } -void vidconsole_readline_end(struct udevice *dev) +void vidconsole_readline_end(struct udevice *dev, void *vctx) { - struct vidconsole_ctx *ctx = vidconsole_ctx(dev); + struct vidconsole_ctx *ctx = vctx ?: vidconsole_ctx(dev); ctx->curs.enabled = false; } @@ -1041,7 +1041,7 @@ void vidconsole_readline_start_all(bool indent) struct udevice *dev; uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) - vidconsole_readline_start(dev, indent); + vidconsole_readline_start(dev, NULL, indent); } void vidconsole_readline_end_all(void) @@ -1050,7 +1050,7 @@ void vidconsole_readline_end_all(void) struct udevice *dev; uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) - vidconsole_readline_end(dev); + vidconsole_readline_end(dev, NULL); } #endif /* CURSOR */ diff --git a/include/video_console.h b/include/video_console.h index 663f89b25f2..c6cc050e054 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -278,7 +278,7 @@ struct vidconsole_ops { * entry_start() - Indicate that text entry is starting afresh * * @dev: Device to adjust - * @ctx: Vidconsole context to use + * @ctx: Vidconsole context to use (cannot be NULL) * Returns: 0 on success, -ve on error * * Consoles which use proportional fonts need to track the position of @@ -596,9 +596,10 @@ int vidconsole_hide_cursor(struct udevice *dev); * Called at the start of command line input to show the cursor * * @dev: vidconsole device + * @vctx: vidconsole context to use, or NULL to use the default * @indent: indent subsequent lines to the same position as the first line */ -void vidconsole_readline_start(struct udevice *dev, bool indent); +void vidconsole_readline_start(struct udevice *dev, void *vctx, bool indent); /** * vidconsole_readline_end() - Disable cursor for a video console @@ -606,8 +607,9 @@ void vidconsole_readline_start(struct udevice *dev, bool indent); * Called at the end of command line input to hide the cursor * * @dev: vidconsole device + * @vctx: vidconsole context to use, or NULL to use the default */ -void vidconsole_readline_end(struct udevice *dev); +void vidconsole_readline_end(struct udevice *dev, void *vctx); /** * vidconsole_readline_start_all() - Enable cursor for all video consoles @@ -637,11 +639,12 @@ static inline int vidconsole_hide_cursor(struct udevice *dev) return 0; } -static inline void vidconsole_readline_start(struct udevice *dev, bool indent) +static inline void vidconsole_readline_start(struct udevice *dev, void *vctx, + bool indent) { } -static inline void vidconsole_readline_end(struct udevice *dev) +static inline void vidconsole_readline_end(struct udevice *dev, void *vctx) { } From patchwork Tue Jan 20 23:17:34 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1680 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=1768951147; bh=mEt4sGvy+AtVzN/lng26f5hqoAxgKPreI8/lxLoj1WM=; 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=DDN085TM9IzJacQQILxlVAnm/r+u5UglbIHWtJVUnNaNDuESUu4ctZdBYj+EwqKa9 tmzqwx1wWQtn7cy0eboVPJHSQDRFpdZuCKjonsPj2r/sQbyLHkLuE4PUp7qZp+KKkO F5BC/uFgJTMANEmzXmYu8UDA9N6bp6Ht0cIflQlkF6hhCnUXzNtXFjeid7M+gyXZ72 kvC3sjw3g07DZqaSJuZCFKPZVb9TfkCSTnb3S5HBbj0kSx2b0GlG7fU5vx/Pq1AOcR Z720J4eNicSLN7oFMhS8ZpUiKMQlLtigEw/ykuH3/rDVC2qc92BX5qWBFCYzaDQmWG HhdxBzvZXi9zg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15D7D69588 for ; Tue, 20 Jan 2026 16:19:07 -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 abPlrAvNtpEO for ; Tue, 20 Jan 2026 16:19:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951147; bh=mEt4sGvy+AtVzN/lng26f5hqoAxgKPreI8/lxLoj1WM=; 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=DDN085TM9IzJacQQILxlVAnm/r+u5UglbIHWtJVUnNaNDuESUu4ctZdBYj+EwqKa9 tmzqwx1wWQtn7cy0eboVPJHSQDRFpdZuCKjonsPj2r/sQbyLHkLuE4PUp7qZp+KKkO F5BC/uFgJTMANEmzXmYu8UDA9N6bp6Ht0cIflQlkF6hhCnUXzNtXFjeid7M+gyXZ72 kvC3sjw3g07DZqaSJuZCFKPZVb9TfkCSTnb3S5HBbj0kSx2b0GlG7fU5vx/Pq1AOcR Z720J4eNicSLN7oFMhS8ZpUiKMQlLtigEw/ykuH3/rDVC2qc92BX5qWBFCYzaDQmWG HhdxBzvZXi9zg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 04ADB6957E for ; Tue, 20 Jan 2026 16:19:07 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951145; bh=Fm4xLSZNT8JQEkjs/pyu6Z3rrRpINtJmk34VyvqtckQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gDo63qh4CS7zpdWlVrOc8bjy+2RSAeRJfFJpcPkfM86Q/NIkIZDI5mTjEw6z50Fch QfS7fxpHhbWO0TDj8I4GDHnQQN64MWimCUU6Wt0MGUBIP406a4D4QjQR8covkT8Q9r jn7TNljIHFOLRk5VOj1YxLc+cjq2eBHEuta5PMpQzFyIOHJ8iviG7NYB07kFepyRyE ULbIle1ClkzU0Qgm3q2olatI+fe4U2fzrwjwA1OV4yNJAGXmyyyvqVeGByU0lQI2sZ dwnJB+Epgrrn1ByOh2EG/74rkwT2xPa2QbVFfL2tBSQgLj65jyl/kWvdb3Mxw3c6OJ 0vqyVT/VvYyPw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 621DC69572; Tue, 20 Jan 2026 16:19:05 -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 ZMV0kehX6_53; Tue, 20 Jan 2026 16:19:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951141; bh=ck2P98deKa9hcQfmAlEpJyd3xMfOMC2XH/KkNzSuTw4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c48N0bxk/WqyD5gDrG0WR7OnDzBBA1AKfpdSLeKOUdR/fTCD+Phhq7bdsmlxjxlQG BWVUQYZ+1a0SQS2zvMkwjDnS1KrKbsB4BYpOuqzSnoet73cwH77plotBN3x6C9i9D5 VzR2eLU5kDLzbJkElPFdfl8/6fE9znCTbukDOHBnSq2h3/R12akHZ/xKjO8ibJjWj1 LJiRHq0NlgaqogmIjX26y620xbNk26fnWwcjh1WWRIHWaywBfb4jEpRRkGaVB70yNQ bMmO1FxhPoC1WGHBKMBZfm3JHlMeq09KuaJcGD379jBxvFqfUF7MsneKWFgU8pnoMI /oi0m1cFnGiIg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id E5E9A6913F; Tue, 20 Jan 2026 16:19:00 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:34 -0700 Message-ID: <20260120231814.2033069-8-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: AHRCLKOF3HLGYR6CKOUUTHMDILVMO3YB X-Message-ID-Hash: AHRCLKOF3HLGYR6CKOUUTHMDILVMO3YB 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 07/36] expo: Move and generalise scene_textline_send_key() 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 scene_textline_send_key() from scene_textline.c to scene_txtin.c and rename it to scene_txtin_send_key(). Change the signature to take a scene_obj and scene_txtin instead of scene_obj_textline, allowing it to be used for both textline and textedit objects. The scene is now obtained from obj->scene rather than being passed as a separate parameter. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 22 +++++++------------ boot/scene_internal.h | 10 ++++----- boot/scene_textline.c | 47 ----------------------------------------- boot/scene_txtin.c | 49 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 66 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 16814d53b65..2627335c0e8 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -1176,27 +1176,21 @@ int scene_send_key(struct scene *scn, int key, struct expo_action *event) return log_msg_ret("key", ret); break; } - case SCENEOBJT_TEXTLINE: { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)cur, - ret = scene_textline_send_key(scn, tline, key, event); + case SCENEOBJT_TEXTLINE: + case SCENEOBJT_TEXTEDIT: + ret = scene_txtin_send_key(cur, scene_obj_txtin(cur), + key, event); if (ret) return log_msg_ret("key", ret); break; } - case SCENEOBJT_TEXTEDIT: - /* TODO(sjg@chromium.org): Implement this */ - break; - } return 0; } - if (cur && cur->type == SCENEOBJT_TEXTLINE) { - struct scene_obj_textline *tline; - - tline = (struct scene_obj_textline *)cur; - ret = scene_textline_send_key(scn, tline, key, event); + if (cur && (cur->type == SCENEOBJT_TEXTLINE || + cur->type == SCENEOBJT_TEXTEDIT)) { + ret = scene_txtin_send_key(cur, scene_obj_txtin(cur), + key, event); if (ret) return log_msg_ret("key", ret); return 0; diff --git a/boot/scene_internal.h b/boot/scene_internal.h index e732650b99f..733f0c0f6ca 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -227,16 +227,16 @@ int scene_menu_send_click(struct scene *scn, struct scene_obj_menu *menu, int x, int y, struct expo_action *event); /** - * scene_textline_send_key() - Send a key to a textline for processing + * scene_txtin_send_key() - Send a key to a text-input object for processing * - * @scn: Scene to use - * @tline: textline to use + * @obj: Object to use + * @tin: Text-input info * @key: Key code to send (KEY_...) * @event: Place to put any event which is generated by the key * Returns: 0 if OK (always) */ -int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, - int key, struct expo_action *event); +int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, + int key, struct expo_action *event); /** * scene_menu_destroy() - Destroy a menu in a scene diff --git a/boot/scene_textline.c b/boot/scene_textline.c index 9b5c40462fd..304a6d914cd 100644 --- a/boot/scene_textline.c +++ b/boot/scene_textline.c @@ -98,53 +98,6 @@ int scene_textline_arrange(struct scene *scn, struct expo_arrange_info *arr, return 0; } -int scene_textline_send_key(struct scene *scn, struct scene_obj_textline *tline, - int key, struct expo_action *event) -{ - const bool open = tline->obj.flags & SCENEOF_OPEN; - - log_debug("key=%d\n", key); - switch (key) { - case BKEY_QUIT: - if (open) { - event->type = EXPOACT_CLOSE; - event->select.id = tline->obj.id; - - /* Copy the backup text from the scene buffer */ - memcpy(abuf_data(&tline->tin.buf), abuf_data(&scn->buf), - abuf_size(&scn->buf)); - - scene_txtin_close(scn); - } else { - event->type = EXPOACT_QUIT; - log_debug("menu quit\n"); - } - break; - case BKEY_SELECT: - if (!open) - break; - event->type = EXPOACT_CLOSE; - event->select.id = tline->obj.id; - key = '\n'; - fallthrough; - default: { - struct udevice *cons = scn->expo->cons; - int ret; - - ret = vidconsole_entry_restore(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); - ret = cread_line_process_ch(&scn->cls, key); - ret = vidconsole_entry_save(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); - break; - } - } - - return 0; -} - bool scene_textline_within(const struct scene *scn, struct scene_obj_textline *tline, int x, int y) { diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 3944bce9a96..d08b9e4ff0f 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -8,6 +8,7 @@ #define LOG_CATEGORY LOGC_EXPO +#include #include #include #include @@ -157,3 +158,51 @@ void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, edit_bbox->valid = false; scene_bbox_union(scn, tin->edit_id, inset, edit_bbox); } + +int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, + int key, struct expo_action *event) +{ + const bool open = obj->flags & SCENEOF_OPEN; + struct scene *scn = obj->scene; + + log_debug("key=%d\n", key); + switch (key) { + case BKEY_QUIT: + if (open) { + event->type = EXPOACT_CLOSE; + event->select.id = obj->id; + + /* Copy the backup text from the scene buffer */ + memcpy(abuf_data(&tin->buf), abuf_data(&scn->buf), + abuf_size(&scn->buf)); + + scene_txtin_close(scn); + } else { + event->type = EXPOACT_QUIT; + log_debug("menu quit\n"); + } + break; + case BKEY_SELECT: + if (!open) + break; + event->type = EXPOACT_CLOSE; + event->select.id = obj->id; + key = '\n'; + fallthrough; + default: { + struct udevice *cons = scn->expo->cons; + int ret; + + ret = vidconsole_entry_restore(cons, &scn->entry_save); + if (ret) + return log_msg_ret("sav", ret); + ret = cread_line_process_ch(&scn->cls, key); + ret = vidconsole_entry_save(cons, &scn->entry_save); + if (ret) + return log_msg_ret("sav", ret); + break; + } + } + + return 0; +} From patchwork Tue Jan 20 23:17:35 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1681 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=1768951151; bh=+lZx3+iofh9NXfB2OxQLB27G420kGAaTDN1WzzfEG5U=; 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=Bq1x41qrkLihtCQYvLahfedZiSuw1tAlDeRfix0V8cda1Rjkgpqm+dak520UC5KL5 +2sIbdPSXQt5y+sfzLwGtwxFpgak0P9sYuitDeRawsdkcBzHwv+euxDVhNjQrmrL7t uEJ6C37CpohL1EFBVKPD5wJEABi0GGlMkn6u/Yw3wMl+GMD+vR1oQlcagJdpUHfmqb mPJiktyjrp7n3FlPd+TcbP1qfG09vl+wP9E97k+K3qh03XGyg2xGGAEg2yhZ9dLjza UxxD896bNY60FLNn1wjM/KoK+Uoup58yHHUBBtQ7nhlEtGM99FSKRUQDlrrCXtPJkN ob5/C5x/G2Ojg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D9E5769589 for ; Tue, 20 Jan 2026 16:19:11 -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 QhnfP_hMbpvR for ; Tue, 20 Jan 2026 16:19:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951151; bh=+lZx3+iofh9NXfB2OxQLB27G420kGAaTDN1WzzfEG5U=; 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=Bq1x41qrkLihtCQYvLahfedZiSuw1tAlDeRfix0V8cda1Rjkgpqm+dak520UC5KL5 +2sIbdPSXQt5y+sfzLwGtwxFpgak0P9sYuitDeRawsdkcBzHwv+euxDVhNjQrmrL7t uEJ6C37CpohL1EFBVKPD5wJEABi0GGlMkn6u/Yw3wMl+GMD+vR1oQlcagJdpUHfmqb mPJiktyjrp7n3FlPd+TcbP1qfG09vl+wP9E97k+K3qh03XGyg2xGGAEg2yhZ9dLjza UxxD896bNY60FLNn1wjM/KoK+Uoup58yHHUBBtQ7nhlEtGM99FSKRUQDlrrCXtPJkN ob5/C5x/G2Ojg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C68D16957E for ; Tue, 20 Jan 2026 16:19:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951149; bh=YK8YL4GetUHaDCy5qihuZHOqvioJZtBytOv80tgsQyU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H4bYsJLLde0lm3jobEjfeW7DRzWJtN84P3QJpOogQm7xBMlHfa6hUIbtPtSEetrjM Nn6PxS8NbgioznLtWjwT5Tb2KxJ8lQvglF+LeFWYDp9+/6usXQ/YcnbZ19wEoG3WCt LERhJWQ60THPQ6tnwC/reLrd2lFK7sEnfB8aVy78zvzbOQ1MpAdraifHNdvfqKzGeo mS7HisPpp2dlPUKiRVYIMlAF8DNh/dt9AoJHq2NltHfSDYrJCxTtmg1HFzlizJHVU0 pJfxft0gVFhJpnmtYb5dv3+UIPnKF4DVgDUoI5Znlyf/8QPspyHmbfxxtuL1Yr8sUF oqileqyIKT/Eg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB5C069572; Tue, 20 Jan 2026 16:19:09 -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 B3iTT4Dq42Wb; Tue, 20 Jan 2026 16:19:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951145; bh=yXx0DRMLvCot3JlgT21whY/7PK/8y0c2dEOpDtXrheM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tdpevGCKPW9QSxVI5SgeGYYrHYrLurR7yB6M/xgOvxP09RJUQ+fqD9XO+5BUk6CNE AT60QdPMeoF4uY4U8BW3JiDy/NCGCd/is0ngQWpuU9F876y3KqZ+L+F9OcVfJmlepV Zd3Yc+U1ZYM4K6UAJDUP/ZjSjgqspBLKltIJgH9CX7Dxyy9X3qDI3ErqwnN6g6GEik XCG+uC3VR4tO9/rpvFHgvVM91fEmcmgaWnweLsnN/MClGz/KM9hLRTMGrGMqvDRihV TfblXIpF5Wb912VfTVvlaOfxf6Cs+5FxJNhotycogtra5uLBUe5VQRvmY3VeA5rQ5x 9JPeFWLNcwffQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id A60AE6913F; Tue, 20 Jan 2026 16:19:05 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:35 -0700 Message-ID: <20260120231814.2033069-9-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: SZVHUZDKBEY5VII3TUVC3DKGJWXUIIV6 X-Message-ID-Hash: SZVHUZDKBEY5VII3TUVC3DKGJWXUIIV6 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 08/36] expo: Add CLI line state to text-input objects 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 struct cli_line_state member to struct scene_txtin to hold the line-editing state for each text-input object. This allows each object to maintain its own editing context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- include/expo.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/expo.h b/include/expo.h index 248f2363fe1..afaf1e8d107 100644 --- a/include/expo.h +++ b/include/expo.h @@ -509,12 +509,14 @@ struct scene_menitem { * @edit_id: ID of the editable text object (not string ID) * @line_chars: Nominal number of characters in a line * @buf: Text buffer containing current text + * @cls: CLI line state for text editing */ struct scene_txtin { uint label_id; uint edit_id; uint line_chars; struct abuf buf; + struct cli_line_state cls; }; /** From patchwork Tue Jan 20 23:17:36 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1682 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=1768951156; bh=RlQy3N3oaThD7xX9SHJewQdKaH9HpSTeulD/VycWUfo=; 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=gACNymlq0PMt7uzM2dJULOXE3pgeBxnoorxr22R3PsK7Qe6r9S3Xxaql55xFgAU8h wCGyEz0cV6kPGWItp5eAIEV8l+QMu5Sno4HEdHj28CEQOp7U/3nRVjsFCI5OFbyIC5 iyf2kmquO8wF5jFdVkXNulomxGuYt7cWKLZNlEm6M1ShpkCvf+Dj+GTIeCFxFtiIE9 XnChpV762j6j4qGKsDndZUZynSXHdMum7hmKo4HTquqMiUhm5yUtnO1zyHHTyXuXWI GV5asPZA1kK5cdtqOm1E6Ur8aCgIdWg6Wpjt06i2ZdUvPrCB71jaegvKKPbNYChT6K melil8NEakw2g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5E65769589 for ; Tue, 20 Jan 2026 16:19: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 10024) with ESMTP id vdWe4jP_N-oU for ; Tue, 20 Jan 2026 16:19:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951156; bh=RlQy3N3oaThD7xX9SHJewQdKaH9HpSTeulD/VycWUfo=; 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=gACNymlq0PMt7uzM2dJULOXE3pgeBxnoorxr22R3PsK7Qe6r9S3Xxaql55xFgAU8h wCGyEz0cV6kPGWItp5eAIEV8l+QMu5Sno4HEdHj28CEQOp7U/3nRVjsFCI5OFbyIC5 iyf2kmquO8wF5jFdVkXNulomxGuYt7cWKLZNlEm6M1ShpkCvf+Dj+GTIeCFxFtiIE9 XnChpV762j6j4qGKsDndZUZynSXHdMum7hmKo4HTquqMiUhm5yUtnO1zyHHTyXuXWI GV5asPZA1kK5cdtqOm1E6Ur8aCgIdWg6Wpjt06i2ZdUvPrCB71jaegvKKPbNYChT6K melil8NEakw2g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4C43E6957E for ; Tue, 20 Jan 2026 16:19:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951154; bh=rTSRL2ebK+l3r8jYjHcMCzTr6mlIuQkGxRKs00Wglas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sMN0heGg7clUDrDLZmJ4H6VvxG1Frgl2Z/OQNT5MAhCv+NB6gkIrd8WfNcAP0PFP6 UmO+axBT+QX6q2gK85Xpv9PJumfXDmR7c1f0Q1rVS/IIdBLp+yu2dIhcmOIYR6xhVx LGZ8lS4+FBflqVFABNGYRcjBz07Cad4ZZ3BTry3JGtRc3vYiq5OYDfn9WrBpjzroEG hkqADQG29FoNTWEjE8ARWzJBj3F+eH1R24eYZzCnf85V5JBp8vQ3WNWtT1QFFKRRQJ fIcdR3Uxx4sWycDCpkCsmWQTJbx1dBbUjibmPLmGDQGzgxbq1OqawkY3/OQ7EePaUt OEigR4Giqm+Rg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9823E69572; Tue, 20 Jan 2026 16:19:14 -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 QHpVlbrQEdzZ; Tue, 20 Jan 2026 16:19:14 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951150; bh=59WcpGtiT0yY2IOHceMK+8dSMsamgT7XthqtVdHOjc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BnvFba834Wq+R6xyxwppDfFgeUzalVyB2G+iGX4NwjCuljjbWpj/auN7UfqsF/qRj g/BEqGjZMLjzEMZm/9uuBYZA/UFTZ7d3scYlQvFqZMAU2suWIK5xXPUKwiM4WAGg21 uRtckav4LRcQeuma8kj+8TOAKJz/dmtePW1szIe2M0H6qt2A/XFXlSURYf5+u+TnxH eIRfGuYJ2RZ0KHrqaWNa4UohFVbC1WbMcsI9L3VXyZGOdD5wCKF3v9sFIggevz6pZ/ V6ckGUltR3bEap3vHj//QHz+LMsBuXp+da2o6bV7mBMU+WbA/Bah9Kt45SPGtpminl Tnd/GZpd/NwlA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 414716913F; Tue, 20 Jan 2026 16:19:10 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:36 -0700 Message-ID: <20260120231814.2033069-10-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: JWKIJFAPWLZZNOEHN4DIBFORTYAKE6PF X-Message-ID-Hash: JWKIJFAPWLZZNOEHN4DIBFORTYAKE6PF 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 09/36] expo: Use text-input CLI line state instead of scene's 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 scene_txtin to use tin->cls instead of scn->cls, so that each text-input object maintains its own CLI line-editing state. Add a priv pointer to struct cli_line_state so the putch callback can access the scene without using container_of. This is necessary because the cls is now embedded in scene_txtin rather than scene. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene_txtin.c | 18 +++++++++++------- include/cli.h | 2 ++ test/boot/expo.c | 12 ++++++------ 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index d08b9e4ff0f..296b2fb1a1b 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -63,6 +63,7 @@ int scene_txtin_arrange(struct scene *scn, struct expo_arrange_info *arr, int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, struct scene_txtin *tin) { + struct cli_line_state *cls = &tin->cls; const bool open = obj->flags & SCENEOF_OPEN; struct udevice *cons = scn->expo->cons; uint i; @@ -77,7 +78,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, scene_render_obj(scn, tin->edit_id); /* move cursor back to the correct position */ - for (i = scn->cls.num; i < scn->cls.eol_num; i++) + for (i = cls->num; i < cls->eol_num; i++) vidconsole_put_char(cons, '\b'); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) @@ -100,7 +101,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, */ static void scene_txtin_putch(struct cli_line_state *cls, int ch) { - struct scene *scn = container_of(cls, struct scene, cls); + struct scene *scn = cls->priv; vidconsole_put_char(scn->expo->cons, ch); } @@ -114,6 +115,7 @@ void scene_txtin_close(struct scene *scn) int scene_txtin_open(struct scene *scn, struct scene_obj *obj, struct scene_txtin *tin) { + struct cli_line_state *cls = &tin->cls; struct udevice *cons = scn->expo->cons; struct scene_obj_txt *txt; int ret; @@ -129,10 +131,11 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, vidconsole_set_cursor_pos(cons, NULL, txt->obj.bbox.x0, txt->obj.bbox.y0); 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; - cli_cread_add_initial(&scn->cls); + cli_cread_init(cls, abuf_data(&tin->buf), tin->line_chars); + cls->insert = true; + cls->putch = scene_txtin_putch; + cls->priv = scn; + cli_cread_add_initial(cls); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); @@ -162,6 +165,7 @@ void scene_txtin_calc_bbox(struct scene_obj *obj, struct scene_txtin *tin, int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, int key, struct expo_action *event) { + struct cli_line_state *cls = &tin->cls; const bool open = obj->flags & SCENEOF_OPEN; struct scene *scn = obj->scene; @@ -196,7 +200,7 @@ int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, ret = vidconsole_entry_restore(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); - ret = cread_line_process_ch(&scn->cls, key); + ret = cread_line_process_ch(cls, key); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); diff --git a/include/cli.h b/include/cli.h index ec0f5d31046..a02e228bf8a 100644 --- a/include/cli.h +++ b/include/cli.h @@ -37,6 +37,7 @@ struct cli_ch_state { * @buf: Buffer containing line * @prompt: Prompt for the line * @putch: Function to call to output a character (NULL to use putc()) + * @priv: Private data for putch callback */ struct cli_line_state { uint num; @@ -48,6 +49,7 @@ struct cli_line_state { char *buf; const char *prompt; void (*putch)(struct cli_line_state *cls, int ch); + void *priv; }; /** diff --git a/test/boot/expo.c b/test/boot/expo.c index d7430dc4284..f94927eb6b7 100644 --- a/test/boot/expo.c +++ b/test/boot/expo.c @@ -1481,8 +1481,8 @@ static int expo_render_textline(struct unit_test_state *uts) ut_assertok(expo_send_key(exp, CTL_CH('b'))); /* check cursor moved back one position, before 'a' */ - ut_asserteq(14, scn->cls.num); - ut_asserteq(15, scn->cls.eol_num); + ut_asserteq(14, tline->tin.cls.num); + ut_asserteq(15, tline->tin.cls.eol_num); ut_asserteq_str("sample hopwinda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); @@ -1493,8 +1493,8 @@ static int expo_render_textline(struct unit_test_state *uts) ut_assertok(expo_send_key(exp, CTL_CH('b'))); /* check cursor moved back three more positions, before 'i' */ - ut_asserteq(11, scn->cls.num); - ut_asserteq(15, scn->cls.eol_num); + ut_asserteq(11, tline->tin.cls.num); + ut_asserteq(15, tline->tin.cls.eol_num); ut_asserteq_str("sample hopwinda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); @@ -1504,8 +1504,8 @@ static int expo_render_textline(struct unit_test_state *uts) ut_assertok(expo_send_key(exp, CTL_CH('d'))); /* check character deleted at cursor position */ - ut_asserteq(11, scn->cls.num); - ut_asserteq(14, scn->cls.eol_num); + ut_asserteq(11, tline->tin.cls.num); + ut_asserteq(14, tline->tin.cls.eol_num); ut_asserteq_str("sample hopwnda", abuf_data(&tline->tin.buf)); ut_assertok(scene_arrange(scn)); ut_assertok(expo_render(exp)); From patchwork Tue Jan 20 23:17:37 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1683 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=1768951161; bh=sklq7ZUEj7ty5riRgLBsYB8huMO9assezynhvNevpxY=; 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=SCE7D9NWpjRdHPHKhgXNdoMYmB7SoGhz2S3iKjmubkYODV7cc2JJ5flO0aJR4zboX 5qkbnSduJhhGGyINdPzpKeMNStcYxNubpkZKgoVpCIAp8l2UBHTe/HY4Kjx2DMOvQQ X4huEoEO3ygKK0viqQwOWECJ7y8NohLVyzlI74PsMA3MRFdUBiXLzv6PoI6U4AW/lq GBUhR1sSal86B3tNiejC2dfBGC3auGBNftaSuyrYSxleZGhf/sEJqcX4KHOTT5VvSY KhWR7YB3k8uF73uijBrV5WTyznSbMMFB4c2JoQWbZJslhybQG/HWiA+M+Q3N2xexU/ qUSd5J00SsGGQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD9C969572 for ; Tue, 20 Jan 2026 16:19:21 -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 1kvv3WFmUNQJ for ; Tue, 20 Jan 2026 16:19:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951161; bh=sklq7ZUEj7ty5riRgLBsYB8huMO9assezynhvNevpxY=; 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=SCE7D9NWpjRdHPHKhgXNdoMYmB7SoGhz2S3iKjmubkYODV7cc2JJ5flO0aJR4zboX 5qkbnSduJhhGGyINdPzpKeMNStcYxNubpkZKgoVpCIAp8l2UBHTe/HY4Kjx2DMOvQQ X4huEoEO3ygKK0viqQwOWECJ7y8NohLVyzlI74PsMA3MRFdUBiXLzv6PoI6U4AW/lq GBUhR1sSal86B3tNiejC2dfBGC3auGBNftaSuyrYSxleZGhf/sEJqcX4KHOTT5VvSY KhWR7YB3k8uF73uijBrV5WTyznSbMMFB4c2JoQWbZJslhybQG/HWiA+M+Q3N2xexU/ qUSd5J00SsGGQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id BD03A6957E for ; Tue, 20 Jan 2026 16:19:21 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951159; bh=FIAdY4QS9jKC+Vqs8xqgPXQppKIczjccJxO9N7O1Wb4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QOPXW73lJqSJvzmwoMgd/5hSCiqm26hkO3F9nAYz+3K6ciRS3bzBOJBKMBiCrXJxJ j3EmhDitvJbH+xhpderSNnTItUBzpmAFhn+fZayua/0p62nHMdiepEEr9TT0xYZ/1M LnS/2GwwM1DxmByV2g40lGorgQ0AKbGrw3LQGpu9PfMlvAJcU2lkg01rwFZQl+2UWQ inDh+r0fxNQ3q1YtI//jNrpCbw4wfBj8XEJdFE7rB2DeIKrQOSjCppJzAO0Nu5Sl1/ 9OteXeXqcKSeKx00S9atlVPQSiQbIK+ey7zLUk9IVnmrIGflKhKzEnySrKJUmnMRan S1jsGmIZqD0Ew== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2DA8D69572; Tue, 20 Jan 2026 16:19:19 -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 oKnXWlbR0liJ; Tue, 20 Jan 2026 16:19:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951155; bh=W7H3e+KqNy7ebe6Ge4rp7jRiFgBpY6cqsc2hFF/pGfA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UOONvE5ZIL5DX1rD6gEPu5ZMg4CHClraw4VsTJxlf9KFnbBrafWVxffZ0+X0EPcf5 8abIRk+SloBj33T61h5ab/v3qa3ao1/5vhYPT5nGu8m+JsgfPrWT62kML2oeoq+0rH DAo8M2MEgpJLKIZMuXe1VtOG3iOcVaXyHgReEHs33RNVezNEz0gYz6OpuP+Fm9QGxq LMD5nwcCIX05d2jT+McPMpfMZy6Lc4TF5qKKv/qpEG7i29JYnqLIgAlS/6iwHA49UT FSlfawbfZBkdF0wEanIMVgQGNYCCcS9ND/ZqdMrcQaH+tYDDRgXnkPVbljbz4VkHIF 0CRjISJlhvcAQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id D73306913F; Tue, 20 Jan 2026 16:19:14 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:37 -0700 Message-ID: <20260120231814.2033069-11-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: MJQQ5EQLEPRDRTLGMBJST34XGK3IDYWP X-Message-ID-Hash: MJQQ5EQLEPRDRTLGMBJST34XGK3IDYWP 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 10/36] video: Pass context to backspace() method 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 The backspace() driver method currently uses the default context. Update it to accept a context parameter so callers can specify which context to use for the backspace operation. This is needed for text-input objects which have their own vidconsole context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 5 +++-- drivers/video/vidconsole-uclass.c | 10 ++++------ include/video_console.h | 3 ++- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 106da0e086d..519b8f88843 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -660,12 +660,13 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, * not been entered. * * @dev: Device to update + * @vctx: Vidconsole context to use * Return: 0 if OK, -ENOSYS if not supported */ -static int console_truetype_backspace(struct udevice *dev) +static int console_truetype_backspace(struct udevice *dev, void *vctx) { struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; struct vidconsole_ctx *com = &ctx->com; struct pos_info *pos; int xend; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index ca21cb8154f..8590219ae64 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -61,16 +61,14 @@ int vidconsole_entry_start(struct udevice *dev, void *ctx) return ops->entry_start(dev, ctx); } -/* Move backwards one space */ -static int vidconsole_back(struct udevice *dev) +/* Move backwards one space, ctx must be non-NULL */ +static int vidconsole_back(struct udevice *dev, struct vidconsole_ctx *ctx) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct vidconsole_ops *ops = vidconsole_get_ops(dev); int ret; if (ops->backspace) { - ret = ops->backspace(dev); + ret = ops->backspace(dev, ctx); if (ret != -ENOSYS) return ret; } @@ -523,7 +521,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) vidconsole_newline(dev); break; case '\b': - vidconsole_back(dev); + vidconsole_back(dev, ctx); ctx->last_ch = 0; break; default: diff --git a/include/video_console.h b/include/video_console.h index c6cc050e054..3390d4fe1a7 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -294,6 +294,7 @@ struct vidconsole_ops { * backspace() - Handle erasing the last character * * @dev: Device to adjust + * @ctx: Vidconsole context to use * Returns: 0 on success, -ve on error * * With proportional fonts the vidconsole uclass cannot itself erase @@ -305,7 +306,7 @@ struct vidconsole_ops { * If not implement, default behaviour will work for fixed-width * characters. */ - int (*backspace)(struct udevice *dev); + int (*backspace)(struct udevice *dev, void *ctx); /** * get_font() - Obtain information about a font (optional) From patchwork Tue Jan 20 23:17:38 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1684 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=1768951165; bh=2SoBBksW7bW9Xi+VyfBaGWDE+C3Z733c2XAXcen0/zU=; 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=QRloLnb0BHYhjjZLE1J4eaDa50c3L9Z1YxUBfCeEsmEM5E7rU/m2k4xFpPyU+7BtF 7hUSnU7h4Op+s2CjHSGN7tObbkVhH0lU8pjqW2BaqxY7YrF3iECjbUMRu/oNADA8NC V3dyKAwP+FWtXSY2Qr9DB5RjnWJpjtzQTssT6pz1nXmjNhQFJIS3HLf0kWL+AMKUGu vb5froJDXNMdy8S0f2aPuz3JhIN8reeWRoZ080O5jAXmv4HLzznawLnC4HhHh0lZxr cmgwN7kP5+S+wBwXbUL3rFJRNAKncSVwLdnrfiWboY1kz7yWKHr9/WIrzmIn0ljLGm aVvbBVEYukneg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D677E69589 for ; Tue, 20 Jan 2026 16:19:25 -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 GsgUX7TOAiag for ; Tue, 20 Jan 2026 16:19:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951165; bh=2SoBBksW7bW9Xi+VyfBaGWDE+C3Z733c2XAXcen0/zU=; 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=QRloLnb0BHYhjjZLE1J4eaDa50c3L9Z1YxUBfCeEsmEM5E7rU/m2k4xFpPyU+7BtF 7hUSnU7h4Op+s2CjHSGN7tObbkVhH0lU8pjqW2BaqxY7YrF3iECjbUMRu/oNADA8NC V3dyKAwP+FWtXSY2Qr9DB5RjnWJpjtzQTssT6pz1nXmjNhQFJIS3HLf0kWL+AMKUGu vb5froJDXNMdy8S0f2aPuz3JhIN8reeWRoZ080O5jAXmv4HLzznawLnC4HhHh0lZxr cmgwN7kP5+S+wBwXbUL3rFJRNAKncSVwLdnrfiWboY1kz7yWKHr9/WIrzmIn0ljLGm aVvbBVEYukneg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C14CF69572 for ; Tue, 20 Jan 2026 16:19:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951163; bh=RgPjryMay7vIYwGG4I3VH5PlYN3OpDCeBUHgS/s8njI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jp0YPioQoiNIZ1Dks/3Qv4jMvqzYZKlNcZnn4YIdiQ2axWpZPtrsnZoN/pgM5KWZe R7M8uOO0Nu9YFdf+8pq3bxJHOzr4LUulH42d4Lu93TdCDeYtBd4lyGuETZzbRPPM6G YWrRSa+8T4B+EVfVJPT+x5kZ8tfzTCqfav9nTJvWSIixGqepY0Cm8+VdeCPh9ClzZE hztiigDnoPtOpukul6RzCjlbq8n64sCxfa4tn1Z3V+5vSKVXCI0WRGjO0mnb0X8FgS hwMGiR/25MBV9Z5gEAeysOdDUypam6O6IfIRYdJa2zYM//tGlqZR31gWvRYtsadg2X o+aDS/RlkvCqQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C11186957E; Tue, 20 Jan 2026 16:19:23 -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 PqoR6Xr1pltL; Tue, 20 Jan 2026 16:19:23 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951159; bh=WyIUf37/ecF2dqB/srzSLKdFBxaS9sMNOZBf3H1prqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RWpPTrcOG6QnS5fdLV+HeQhyCC65qgMwzFRBZrakZYpV0lasmiuLclfprfkqggTlO +IySyg2SvJnwq3IGE5Xtm2WoC+l4ZanZuqi/4SvfoQBdH1qrMq+whJZgCIDNijL9hZ 1DJIFdDFczy7s3ghndPdEzfbuVEfL11W34TWaCDKpSZdL1wOs2cAnMNQrYXRAGXMJ5 ZsFCR+BL5g3OUzN/yo329VCEG2KgsFP8/SsF9CpNNGEyio9rO0ci3/hMY2OK+GBKK9 0VE/CDZGlKEZWt94FQ7mVUfcMEqMhae5t6QsrN4rzpKl0/OjWKmdIZYAKOlkZywSMZ bsF8u4Zdgi5Eg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 742446913F; Tue, 20 Jan 2026 16:19:19 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:38 -0700 Message-ID: <20260120231814.2033069-12-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: BQMCF3YERKK2UBKWEC75JY3W7JBDLUZ3 X-Message-ID-Hash: BQMCF3YERKK2UBKWEC75JY3W7JBDLUZ3 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 11/36] video: Pass context to vidconsole_newline/back() 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 the internal vidconsole_newline() and vidconsole_back() functions to allow passing in a specific vidconsole context. This prepares for supporting per-object contexts in the expo text-input code. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 8590219ae64..29a1accb64c 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -90,11 +90,12 @@ static int vidconsole_back(struct udevice *dev, struct vidconsole_ctx *ctx) return video_sync(dev->parent, false); } -/* Move to a newline, scrolling the display if necessary */ -static void vidconsole_newline(struct udevice *dev) +/* + * Move to a newline, scrolling the display if necessary. + * ctx must be non-NULL + */ +static void vidconsole_newline(struct udevice *dev, struct vidconsole_ctx *ctx) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct udevice *vid_dev = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); const int rows = CONFIG_VAL(CONSOLE_SCROLL_LINES); @@ -469,7 +470,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) */ ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch); if (ret == -EAGAIN) { - vidconsole_newline(dev); + vidconsole_newline(dev, ctx); ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch); } if (ret < 0) @@ -477,7 +478,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) ctx->xcur_frac += ret; ctx->last_ch = ch; if (ctx->xcur_frac >= ctx->xsize_frac) - vidconsole_newline(dev); + vidconsole_newline(dev, ctx); cli_index_adjust(ctx, 1); return 0; @@ -510,7 +511,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) ctx->xcur_frac = ctx->xstart_frac; break; case '\n': - vidconsole_newline(dev); + vidconsole_newline(dev, ctx); vidconsole_entry_start(dev, NULL); break; case '\t': /* Tab (8 chars alignment) */ @@ -518,7 +519,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) + 1) * ctx->tab_width_frac; if (ctx->xcur_frac >= ctx->xsize_frac) - vidconsole_newline(dev); + vidconsole_newline(dev, ctx); break; case '\b': vidconsole_back(dev, ctx); From patchwork Tue Jan 20 23:17:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1685 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=1768951171; bh=kF/NY4ESyV0rAZ9c+tIVN35V2umzzGzLWPHH8xJVSUo=; 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=q/dstcHDZnIJZIrANejs78HkYw9TAi1ZaTDGozyBh9wW0d2Unm0vAN3owW6GfawI2 HzW8pnmiOk6Y6kJETP1EI8spz00Kp3pwcpk7O0wGModugUEjUZqiT5z7mQtqyn7XDs 6Y07pI+yL8rdxcJ66xb5jc+NscIIeYQ8784cOaRUixafrbL0eAmT01ERZBb6Deo5/k zHN79epO/a7ASoogHwYxTIojAYZ6fuu4wZjz8GOa7LejIVrOJsSgiY+cunQdfujWO8 cUhUod0iocfKEh25AarpQTKbA0kK4M66rG/So6ew2ypBP1rWTxtkthZSX8fs7iOP1j 3HdeqcuAFNprw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9E8E469572 for ; Tue, 20 Jan 2026 16:19:31 -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 cm80KuIZE02D for ; Tue, 20 Jan 2026 16:19:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951171; bh=kF/NY4ESyV0rAZ9c+tIVN35V2umzzGzLWPHH8xJVSUo=; 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=q/dstcHDZnIJZIrANejs78HkYw9TAi1ZaTDGozyBh9wW0d2Unm0vAN3owW6GfawI2 HzW8pnmiOk6Y6kJETP1EI8spz00Kp3pwcpk7O0wGModugUEjUZqiT5z7mQtqyn7XDs 6Y07pI+yL8rdxcJ66xb5jc+NscIIeYQ8784cOaRUixafrbL0eAmT01ERZBb6Deo5/k zHN79epO/a7ASoogHwYxTIojAYZ6fuu4wZjz8GOa7LejIVrOJsSgiY+cunQdfujWO8 cUhUod0iocfKEh25AarpQTKbA0kK4M66rG/So6ew2ypBP1rWTxtkthZSX8fs7iOP1j 3HdeqcuAFNprw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 853896957E for ; Tue, 20 Jan 2026 16:19:31 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951168; bh=vGBseWRLzZSZ4mxUnVLEPVCgwvQYHWDHxvnTc6NNkQ4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YORQ7tCOqIDGNv6dpc5XGEVxTrWvt7E1vYS3bV7LOgATbVwiik8i72qWA5VPA5xPf 751UDV/nvsRw8G6qc930Fv1e3itUTrYfbxBsiIVj6v3AniT+1G1mgEfevQsrkAKgkN qnBX2OXL62HBHg/pttliALmd1Of1a/YLTRJ1jIQ+Bf0H5jW4TvDL0/1Fgb3TEsncJB eNWJkAwnZkQ9Ih8zmb5MWPvz+UbUDa2P7pRLO+1s48xN9aZYLDIV/78FeeaoWoQJJA xM7b0/PSnZxl+Av5FNmPOaLJjOKBivPGkYO1/N6IQjntvVjMpKVsS/svI/7G2huQ5q LXtec7i7/1Jug== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 59D4569572; Tue, 20 Jan 2026 16:19:28 -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 txuvaEMVFkwm; Tue, 20 Jan 2026 16:19:28 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951164; bh=xuGsyqeIjESKfcbwMFG5fCH8gOQfbnBNRXZgiWX8fds=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Op5TEgt//Ec5ioSUIs2uVw/RMwgr6hLOC2hYTXy3AiPAzWUPICjDSLzSSmws1MgJV gVoRu8QzvHjeQ3WAeZ7wGFB+G2QlNe3IWGms+ai81w4JZGa/ZdSxPDydhTGPqXfAJw ZQCc0pGTKwr83dR/7GWywn7f+SzADw3xR3Xr3r+x4PLW3bC/YbNx3ZTzHJi0G8/evB 8El+brq8AJZkTyqsaGu2GPxJz0vsqBxgH+xlFMpkT2aa6r8i6bG2HtuQa9yyHhrrOY T8gmG90b+0G/SNuBs9BXxzXk2aI4uOIXwGIr6Ij6LfK2k0U4VNaCv9dMrfN+Zt/GY5 hWGKm4Bw5lz2A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 0DF9C6913F; Tue, 20 Jan 2026 16:19:23 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:39 -0700 Message-ID: <20260120231814.2033069-13-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: QGGEDLLLRRFOAFH4DKV5HMFDZP3PWHXS X-Message-ID-Hash: QGGEDLLLRRFOAFH4DKV5HMFDZP3PWHXS 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 12/36] video: Pass context to console_fixed_putc_xy() 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 console_fixed_putc_xy() 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 --- drivers/video/console_core.c | 7 +++---- drivers/video/console_normal.c | 4 +++- drivers/video/console_truetype.c | 3 ++- drivers/video/vidconsole_internal.h | 5 +++-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 18edc14bcd7..ecb0b9dab89 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -336,11 +336,10 @@ int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *i return info->name ? 0 : -ENOENT; } -int console_fixed_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp, - struct video_fontdata *fontdata) +int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y, + int cp, struct video_fontdata *fontdata) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_ctx *ctx = vctx; struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); int pbytes = VNBYTES(vid_priv->bpix); diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index fa9d496ef86..5b6f0f0ce86 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -81,9 +81,11 @@ static int console_move_rows(struct udevice *dev, uint rowdst, int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) { + struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); struct console_simple_priv *priv = dev_get_priv(dev); - return console_fixed_putc_xy(dev, x_frac, y, cp, priv->fontdata); + return console_fixed_putc_xy(dev, vidconsole_ctx_from_priv(vc_priv), + x_frac, y, cp, priv->fontdata); } static __maybe_unused int console_get_cursor_info(struct udevice *dev) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 519b8f88843..b4b491039ae 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -417,7 +417,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, /* Use fixed font if selected */ if (ctx->cur_fontdata) - return console_fixed_putc_xy(dev, x, y, cp, ctx->cur_fontdata); + return console_fixed_putc_xy(dev, &ctx->com, x, y, cp, + ctx->cur_fontdata); /* Reset scratch buffer for this character */ stbtt_scratch_reset(&priv->scratch); diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 241be149ac9..ef864a7c858 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -198,14 +198,15 @@ int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp); * Fixed font putc_xy function that can be called with explicit font data * * @param dev console device + * @param vctx vidconsole context to use (cannot be NULL) * @param x_frac fractional X position * @param y Y position in pixels * @param cp Unicode code point * @param fontdata font data to use for rendering * @returns width in fractional pixels, or -ve on error */ -int console_fixed_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp, - struct video_fontdata *fontdata); +int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y, + int cp, struct video_fontdata *fontdata); /** * Internal function to convert Unicode code points to code page 437. From patchwork Tue Jan 20 23:17:40 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1686 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=1768951175; bh=Ep9cGuQt8qrDQhpZpmBkueC64bBi8tRSow7OmnsyuwA=; 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=RhZUhS68OqovsDMNKtrDPPFtkBNCa/TGFA9pR9WG6YHuwpa23UKWt3UlDAeLYHzTY AHUrnMNiU8CahkR4aw3ZBcvbu+J2l36FTCPRC7AxUREs328BeUcV0tX5WGPwK2/Cot bGocJNFHTEWkCBWDjUl1DE+6VSMKW/bYQW7VNyIzA6EJc4+4oBXvT1v2RVwzg6SBmP mvYWVsgtKHSCdQx/WXY1K0+SbDw6L3cinQh9R87psplQum+FyZ/dOE/x27XLE2j1+x csB/THjhviKrR2X7B6u34D1/JGs5qR4+BpSUcz7LCaixEtAx1iX/NGksBvDncKACSN hmIRRfrFS5eNw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A1F2769572 for ; Tue, 20 Jan 2026 16:19:35 -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 f41_yklRPq1i for ; Tue, 20 Jan 2026 16:19:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951175; bh=Ep9cGuQt8qrDQhpZpmBkueC64bBi8tRSow7OmnsyuwA=; 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=RhZUhS68OqovsDMNKtrDPPFtkBNCa/TGFA9pR9WG6YHuwpa23UKWt3UlDAeLYHzTY AHUrnMNiU8CahkR4aw3ZBcvbu+J2l36FTCPRC7AxUREs328BeUcV0tX5WGPwK2/Cot bGocJNFHTEWkCBWDjUl1DE+6VSMKW/bYQW7VNyIzA6EJc4+4oBXvT1v2RVwzg6SBmP mvYWVsgtKHSCdQx/WXY1K0+SbDw6L3cinQh9R87psplQum+FyZ/dOE/x27XLE2j1+x csB/THjhviKrR2X7B6u34D1/JGs5qR4+BpSUcz7LCaixEtAx1iX/NGksBvDncKACSN hmIRRfrFS5eNw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 907506957E for ; Tue, 20 Jan 2026 16:19:35 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951173; bh=//UbhMJQW9UrH2ipPrwlpP+8T/W67MOzvyv4HeQQPk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r+dsLEUiUyLE6ZoHcvTbR8de1D5VRVBHyFVV+kIaLSJD5JVHRlU26x9bgIhspsMOP nffz7jlJZdRo6TIshTy6Rr2z0YWgRoAD/FT8i9cH4rUoRlxF6FvQqmfahGzrJmlBER D0za8CZGLbDPTT6Tjo1j4Gvzs3sLwlT07o8kutVyebWr84tHswdwcnze4Or0vuKPtj vFt750YNiLSaOBuMCYkfcd8qgD7TENwb1X+AgFnsokDydBeVPpjO9l91tzihqiyh+O WZrMAlKLZeGFqEzFxVVFb8cDV8zCStE/+OSXjq0BTie7x3PgHZHKi1t9RyR1zF5Srh z693fUu+D48OQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F07169572; Tue, 20 Jan 2026 16:19:33 -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 vv1ls-B6_FIJ; Tue, 20 Jan 2026 16:19:33 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951169; bh=i+3fYrLptDYWkkoqq7xGVUjl709KlmoNk1fJJXeWdZ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ym2BVxoOO3cO49XrxvXtLBgopuda32MeIImjARIbNU0F84VD+Q5D7ClJvQB75xRro XtmrLWzHMY5bVaa1tQZ8gSxQ+2tKifsdcOXZ5AQu31RRAFy1maWGg3O1rZFAPJwCJg XGTxNCnVVAOGG4TxlbgpY2nS9TDx6ceDSP/ciOMmp1RdyxJBlzwyFAdUixjMUm576j 2eJjsSFGy9rk44FL6kuMIn4loTOi6umdxPxOn2MF0hr85SlfaC9eTFQybSqUHpc1Uz 8o5k5YH15WCTsW0bnsC23h8UfpYSkXp6bJzXDf9BBOziuFrjBlrpOz0LxG7FvtHnIT MBUIzJCoB2//A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id C670D6913F; Tue, 20 Jan 2026 16:19:28 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:40 -0700 Message-ID: <20260120231814.2033069-14-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: NDIB753HATRR5H25XKGFOQNLUVPD7CCG X-Message-ID-Hash: NDIB753HATRR5H25XKGFOQNLUVPD7CCG 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/36] video: Pass context to vidconsole_putc_xy() 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_putc_xy() and its driver method to allow passing in a specific vidconsole context. If NULL, the default context from priv is used. Update all driver implementations and callers accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_normal.c | 12 ++++++------ drivers/video/console_rotate.c | 18 +++++++++--------- drivers/video/console_truetype.c | 6 +++--- drivers/video/vidconsole-uclass.c | 10 ++++++---- drivers/video/vidconsole_internal.h | 4 +++- include/video_console.h | 7 +++++-- test/dm/video.c | 18 +++++++++--------- 7 files changed, 41 insertions(+), 34 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 5b6f0f0ce86..5f84896699d 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -79,13 +79,12 @@ static int console_move_rows(struct udevice *dev, uint rowdst, return 0; } -int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) +int console_normal_putc_xy(struct udevice *dev, void *vctx, uint x_frac, + uint y, int cp) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); struct console_simple_priv *priv = dev_get_priv(dev); - return console_fixed_putc_xy(dev, vidconsole_ctx_from_priv(vc_priv), - x_frac, y, cp, priv->fontdata); + return console_fixed_putc_xy(dev, vctx, x_frac, y, cp, priv->fontdata); } static __maybe_unused int console_get_cursor_info(struct udevice *dev) @@ -172,9 +171,10 @@ static __maybe_unused int normal_entry_restore(struct udevice *dev, return 0; } -static int console_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp) +static int console_putc_xy(struct udevice *dev, void *vctx, uint x_frac, + uint y, int cp) { - return console_normal_putc_xy(dev, x_frac, y, cp); + return console_normal_putc_xy(dev, vctx, x_frac, y, cp); } static int console_simple_ctx_new(struct udevice *dev, void **ctxp) diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c index 378c7ec6fc7..42c9de888d8 100644 --- a/drivers/video/console_rotate.c +++ b/drivers/video/console_rotate.c @@ -72,10 +72,10 @@ static int console_move_rows_1(struct udevice *dev, uint rowdst, uint rowsrc, return 0; } -static int console_putc_xy_1(struct udevice *dev, uint x_frac, uint y, int cp) +static int console_putc_xy_1(struct udevice *dev, void *vctx, uint x_frac, + uint y, int cp) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_ctx *ctx = vctx; struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); struct console_simple_priv *priv = dev_get_priv(dev); @@ -161,10 +161,10 @@ static int console_move_rows_2(struct udevice *dev, uint rowdst, uint rowsrc, return 0; } -static int console_putc_xy_2(struct udevice *dev, uint x_frac, uint y, int cp) +static int console_putc_xy_2(struct udevice *dev, void *vctx, uint x_frac, + uint y, int cp) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_ctx *ctx = vctx; struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); struct console_simple_priv *priv = dev_get_priv(dev); @@ -252,10 +252,10 @@ static int console_move_rows_3(struct udevice *dev, uint rowdst, uint rowsrc, return 0; } -static int console_putc_xy_3(struct udevice *dev, uint x_frac, uint y, int cp) +static int console_putc_xy_3(struct udevice *dev, void *vctx, uint x_frac, + uint y, int cp) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_ctx *ctx = vctx; struct udevice *vid = dev->parent; struct video_priv *vid_priv = dev_get_uclass_priv(vid); struct console_simple_priv *priv = dev_get_priv(dev); diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index b4b491039ae..a72e2342010 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -395,11 +395,11 @@ static void clear_from(struct udevice *dev, int index) } } -static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, - int cp) +static int console_truetype_putc_xy(struct udevice *dev, void *vctx, uint x, + uint y, int cp) { struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; struct vidconsole_ctx *com = &ctx->com; struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_metrics *met = ctx->cur_met; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 29a1accb64c..ec78068f734 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -22,13 +22,15 @@ #include /* Bitmap font for code page 437 */ #include -int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int ch) +int vidconsole_putc_xy(struct udevice *dev, void *vctx, uint x, uint y, int ch) { + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ops *ops = vidconsole_get_ops(dev); if (!ops->putc_xy) return -ENOSYS; - return ops->putc_xy(dev, x, y, ch); + return ops->putc_xy(dev, vctx ?: vidconsole_ctx_from_priv(priv), x, y, + ch); } int vidconsole_move_rows(struct udevice *dev, uint rowdst, uint rowsrc, @@ -468,10 +470,10 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) * colour depth. Check this and return an error to help with * diagnosis. */ - ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch); + ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch); if (ret == -EAGAIN) { vidconsole_newline(dev, ctx); - ret = vidconsole_putc_xy(dev, ctx->xcur_frac, ctx->ycur, ch); + ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch); } if (ret < 0) return ret; diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index ef864a7c858..8b598b26b13 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -187,12 +187,14 @@ int console_simple_select_font(struct udevice *dev, const char *name, uint size) * Normal console putc_xy function that can be called by other console drivers * * @param dev console device + * @param ctx vidconsole context to use, or NULL for default * @param x_frac fractional X position * @param y Y position in pixels * @param cp Unicode code point * @returns width in fractional pixels, or -ve on error */ -int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp); +int console_normal_putc_xy(struct udevice *dev, void *ctx, uint x_frac, + uint y, int cp); /** * Fixed font putc_xy function that can be called with explicit font data diff --git a/include/video_console.h b/include/video_console.h index 3390d4fe1a7..9627d645189 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -240,6 +240,7 @@ struct vidconsole_ops { * putc_xy() - write a single character to a position * * @dev: Device to write to + * @ctx: Vidconsole context to use (cannot be NULL) * @x_frac: Fractional pixel X position (0=left-most pixel) which * is the X position multipled by VID_FRAC_DIV. * @y: Pixel Y position (0=top-most pixel) @@ -248,7 +249,8 @@ struct vidconsole_ops { * if all is OK, -EAGAIN if we ran out of space on this line, other -ve * on error */ - int (*putc_xy)(struct udevice *dev, uint x_frac, uint y, int cp); + int (*putc_xy)(struct udevice *dev, void *ctx, uint x_frac, uint y, + int cp); /** * move_rows() - Move text rows from one place to another @@ -687,6 +689,7 @@ void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old); * vidconsole_putc_xy() - write a single character to a position * * @dev: Device to write to + * @ctx: Vidconsole context to use, or NULL to use default * @x_frac: Fractional pixel X position (0=left-most pixel) which * is the X position multipled by VID_FRAC_DIV. * @y: Pixel Y position (0=top-most pixel) @@ -695,7 +698,7 @@ void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old); * if all is OK, -EAGAIN if we ran out of space on this line, other -ve * on error */ -int vidconsole_putc_xy(struct udevice *dev, uint x, uint y, int cp); +int vidconsole_putc_xy(struct udevice *dev, void *ctx, uint x, uint y, int cp); /** * vidconsole_move_rows() - Move text rows from one place to another diff --git a/test/dm/video.c b/test/dm/video.c index 97778a70559..e4599be30a8 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -264,16 +264,16 @@ static int dm_test_video_text(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); + vidconsole_putc_xy(con, NULL, 0, 0, 'a'); ut_asserteq(79, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); - vidconsole_putc_xy(con, 0, 0, ' '); + vidconsole_putc_xy(con, NULL, 0, 0, ' '); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i); ut_asserteq(273, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -282,7 +282,7 @@ static int dm_test_video_text(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i); ut_asserteq(273, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -306,16 +306,16 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_putc_xy(con, 0, 0, 'a'); + vidconsole_putc_xy(con, NULL, 0, 0, 'a'); ut_asserteq(89, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); - vidconsole_putc_xy(con, 0, 0, ' '); + vidconsole_putc_xy(con, NULL, 0, 0, ' '); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i); ut_asserteq(363, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -324,7 +324,7 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); for (i = 0; i < 20; i++) - vidconsole_putc_xy(con, VID_TO_POS(i * 8), 0, ' ' + i); + vidconsole_putc_xy(con, NULL, VID_TO_POS(i * 8), 0, ' ' + i); ut_asserteq(363, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -1442,7 +1442,7 @@ static int dm_test_video_sync_damage(struct unit_test_state *uts) ut_assert(!vid_bbox_valid(&priv->damage)); /* Write a small piece of text at a specific position */ - vidconsole_putc_xy(con, VID_TO_POS(400), 67, 'T'); + vidconsole_putc_xy(con, NULL, VID_TO_POS(400), 67, 'T'); /* Check priv->damage before sync - should have text damage */ ut_assert(vid_bbox_valid(&priv->damage)); From patchwork Tue Jan 20 23:17:41 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1687 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=1768951179; bh=VFZMJVGGgMH6FrD2QIzjWOi1jMNhYIh48k0aipRqLYk=; 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=of4tSKu6vWGoZoshPLFiMbEaw9UYbtAyOtFGM64mtFb3D4skKrRsKztd+AdJBHN8V 1WFgg89trCgl1HO59pzcUbyPyJEjdzsIpt/k3noXx7L7WpuRBxhHgXRAuPbg5UMRbV Ux6QJbprCQaFknQNbK9J5ONw9Ipt7Z7Trboy+Jw38CE2ysdsvA3MvMvfxjIzU91DK4 oBy21iv4ZYNc5/b31A3mEW4LJhpHMV7outenMLwkPH7QJuwQfneokoGgFBOgWiObHj dudIUQiAOcLoiieKyHKJ7BxUYPuCYlZbi/PSHCjuHpooiSGdpbuXmR/AwAMC2bpZo0 Fb16bdHglqdeA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 209D86958D for ; Tue, 20 Jan 2026 16:19: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 fy1xD5F_UUoK for ; Tue, 20 Jan 2026 16:19:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951179; bh=VFZMJVGGgMH6FrD2QIzjWOi1jMNhYIh48k0aipRqLYk=; 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=of4tSKu6vWGoZoshPLFiMbEaw9UYbtAyOtFGM64mtFb3D4skKrRsKztd+AdJBHN8V 1WFgg89trCgl1HO59pzcUbyPyJEjdzsIpt/k3noXx7L7WpuRBxhHgXRAuPbg5UMRbV Ux6QJbprCQaFknQNbK9J5ONw9Ipt7Z7Trboy+Jw38CE2ysdsvA3MvMvfxjIzU91DK4 oBy21iv4ZYNc5/b31A3mEW4LJhpHMV7outenMLwkPH7QJuwQfneokoGgFBOgWiObHj dudIUQiAOcLoiieKyHKJ7BxUYPuCYlZbi/PSHCjuHpooiSGdpbuXmR/AwAMC2bpZo0 Fb16bdHglqdeA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 100106957E for ; Tue, 20 Jan 2026 16:19:39 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951178; bh=tLU4hhZpO1Flbf7j39DgSATsaJgMKfpvVzcqz5L9YnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HrgXmsTsFmaccAKYJFLU0VYB1tAYB3OKcKGrGwlOYr/VXOAY4PZM3xvkLnyGNk8df VfINAMpXVHVB1MkM4v6RuSormILTllkhVb7gIPkYZCyOGu52PpXM/O1FRn+wWZAqxs KketD6G2HEYYenCT2+qW3zSMhiFbl+xihoVwDGNT9INoYNyAie4gjIfQ+d/DAtQ5L4 kTNDXAQPFcjAe2s8k6oeOfnoMd+5wadHtUF9s42vDfonJw1CvzwrIF6cDLSsho+/+p lwMr4ZSbQWbeqkVgaNmW1AyUxsMX8P5vMsNCkNakmvilOECTwTskCxvZgTeCmp5w/u 1sxNM29npIMcw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0832069572; Tue, 20 Jan 2026 16:19:38 -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 8F9RePWF0IVG; Tue, 20 Jan 2026 16:19:37 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951174; bh=7/pfM64jOnwUY3yhP9FBN8Yp9lusM4NzHZnPALpT8ac=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZyVGRKAVQr1u5IeK/r6X/ZmZWd7kPZ+AVGvw76lvp7RAu0HNh02DViO+kNC6fFoTz KfdFccam85x2OVJNIQ0eITayU47XWkgueaFEz+jcPEBDdfDlQCtYUUrW/HfRJWFOfU wImLKoZMxKcAkZOGuMz8fvuE2G3pYKmCCDvXs1zfX4Ksa+AkwXMu+aWgaukIe9LGna 9zOYsORV96LyALW8J4hTSceq4WCbXQd7pTaAteC3YVIEK3O45JXh0EXyu6mgOvrjAy 6SrIbW+coFCtdC89F18K1p5z3XYvOoPwporX78POGFxW+gVe43ihc7jNlisoagRcUV SW6a1tb4I2dZQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AFF436913F; Tue, 20 Jan 2026 16:19:33 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:41 -0700 Message-ID: <20260120231814.2033069-15-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: JENZL3HG2GZU4LSB27ILTHYMQPYSSG3E X-Message-ID-Hash: JENZL3HG2GZU4LSB27ILTHYMQPYSSG3E 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/36] video: Pass context to vidconsole_output_glyph() 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 the internal vidconsole_output_glyph() function to allow passing in a specific vidconsole context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index ec78068f734..cc244a3aad7 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -454,10 +454,9 @@ error: } /* Put that actual character on the screen (using the UTF-32 code points). */ -static int vidconsole_output_glyph(struct udevice *dev, int ch) +static int vidconsole_output_glyph(struct udevice *dev, + struct vidconsole_ctx *ctx, int ch) { - struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); int ret; if (_DEBUG) { @@ -473,7 +472,8 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch); if (ret == -EAGAIN) { vidconsole_newline(dev, ctx); - ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, ch); + ret = vidconsole_putc_xy(dev, ctx, ctx->xcur_frac, ctx->ycur, + ch); } if (ret < 0) return ret; @@ -535,7 +535,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) } else { cp = ch; } - ret = vidconsole_output_glyph(dev, cp); + ret = vidconsole_output_glyph(dev, ctx, cp); if (ret < 0) return ret; break; From patchwork Tue Jan 20 23:17:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1688 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=1768951184; bh=xnLJXZPOcgOg9IgXDY8oOrfDdpINZ66V5cC6+OPsVoo=; 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=s95xzhTJiuuuOrbOi53m0bZ7ZMA68VhhoMBZU8A3QRyHVg0xaOy1D4O4lP+oqP31m Ucd2SYVWrA/TF9Bsd6h1I3ayBpOfiK4/hQJxYtpGt3ivT50DybTPPfCN3GqFdCtIWW JA48fPwUitVMVXV3JEpg2484gY+Duj6G45jIvJGvTkOgUsM8VOJV1s4O+E6dD13+HZ ev+qNsx/CxRI6J+s6UabOiY8dPW1+mir3zbnkd687ThS4UI2oPeIv0P4D6USqTNReH pnd+mZ6Ased8BmiWnQ13ryre/l0FnpJAzFmFq7wFgSBLiEcZhBNwXrufaBszNBfsGK EEpoGBEEnyk0g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93AA169572 for ; Tue, 20 Jan 2026 16:19:44 -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 HbmgWQJG6PPq for ; Tue, 20 Jan 2026 16:19:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951184; bh=xnLJXZPOcgOg9IgXDY8oOrfDdpINZ66V5cC6+OPsVoo=; 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=s95xzhTJiuuuOrbOi53m0bZ7ZMA68VhhoMBZU8A3QRyHVg0xaOy1D4O4lP+oqP31m Ucd2SYVWrA/TF9Bsd6h1I3ayBpOfiK4/hQJxYtpGt3ivT50DybTPPfCN3GqFdCtIWW JA48fPwUitVMVXV3JEpg2484gY+Duj6G45jIvJGvTkOgUsM8VOJV1s4O+E6dD13+HZ ev+qNsx/CxRI6J+s6UabOiY8dPW1+mir3zbnkd687ThS4UI2oPeIv0P4D6USqTNReH pnd+mZ6Ased8BmiWnQ13ryre/l0FnpJAzFmFq7wFgSBLiEcZhBNwXrufaBszNBfsGK EEpoGBEEnyk0g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 818ED6957E for ; Tue, 20 Jan 2026 16:19:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951182; bh=p9F1XMg+5jDirk55/1AVx2TMdutBJobJl1T1y8M71R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0U/Dp1VnWNMRgobnzev4j+/UxBjajmh3Oba6OiYOSwbeoddt+bZhaHkrEc8tf3yv n7RUZoBpf8PISrnRQi3X86o/5BJFwuH1sla29olXCJEdJE0GxcQOTHS1+0sGi+T4zt ztqynRQeGtE83TQV6td7Qhp8KIIHpLHjBZIDxZ7xlb5W6ah9374Q/L5op9Q91Dbkwh +P3EXgCJTXlzhavXi8jlnAoju16K2q9/DpkFbYAwIfKQarxjxRdyv1h8VgzptMIDbA Ek/Mv/rCqA1geyOVfh4LjZwl9ka1CSR63u2Mn497uR7Z7IUqVierkHYZmTWjOdqbS4 wyhDpdH713bxA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C75CE69572; Tue, 20 Jan 2026 16:19:42 -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 I1pT4-KQgPdy; Tue, 20 Jan 2026 16:19:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951178; bh=VuGmP1E1Noi/ICJbSEBadn7rHGW7YTJubauVISHOkt4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v3kPQVvBlezPK5oRteTNFi7kYhSRrsnu/xzoW5BprKl2+INjU/a5rgYBIUjzfESka meKs06cNZo4M6zt6DQx7+iVxLtfL2le28Yc4LHyS/iUVVXokzA9wXOMNbmW3rewv1m +A72i5MQSP96i2qLvcT27FrU4UevbTCpKg7nmJ3uMIF1Q1vvIEJK7rnLIjOfqBSJrr CTIufk3bqxMzFIsKhfftyTBzM0IKaZgUe4uiQyFmG41oZPCK43bW+7unHSGFcpuzC+ OjI83FYz9mklOQAw25udB5iN9dnGzw1Fnmm/JVCVGTmVjMTgURM3cVudZhOJuag1yn +ZmpI33HEYLyQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 7EDA26913F; Tue, 20 Jan 2026 16:19:38 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:42 -0700 Message-ID: <20260120231814.2033069-16-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: 3522R5AHD7GRPLLAGVFIJOULSU3P35V7 X-Message-ID-Hash: 3522R5AHD7GRPLLAGVFIJOULSU3P35V7 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 15/36] video: Pass context to vidconsole_escape_char() 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 the internal vidconsole_escape_char() function to allow passing in a specific vidconsole context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index cc244a3aad7..51db3200e86 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -194,10 +194,10 @@ static void get_cursor_position(struct vidconsole_priv *priv, * accumulated into escape_buf until the end of escape sequence is * found, at which point the sequence is parsed and processed. */ -static void vidconsole_escape_char(struct udevice *dev, char ch) +static void vidconsole_escape_char(struct udevice *dev, + struct vidconsole_ctx *ctx, char ch) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct vidconsole_ansi *ansi = &ctx->ansi; if (!IS_ENABLED(CONFIG_VIDEO_ANSI)) @@ -497,7 +497,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) vidconsole_hide_cursor(dev); if (ansi->escape) { - vidconsole_escape_char(dev, ch); + vidconsole_escape_char(dev, ctx, ch); return 0; } From patchwork Tue Jan 20 23:17:43 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1689 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=1768951189; bh=+biS6qAv/rcLtSDnnpNrRNKDwdLPvDx1oMjKMMD+hS0=; 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=gWN5o4OhcDvIWEskDKNt+re3ZxrIg6UVcTxwKYhtNZuwpkI67fHW+7mEYznQCdZUN T157eAHU6dZKtxO0souTJSq7l6djHt1POgp5HaH8k1kG5kqUfnuLrj7/UuF9x97tus K8HIynXL5jIK29t3dFap9xWWABy291+tKvliTGprsCHEspjxIQvAI85/56TrCuIJ1T PnD/7XgIm6i8FWKerqXddWRBvHCn9wjZYTSLawFCFxt0pAniaE/0FMVQMbJCFSzXEL lUX29iDfDnaDWtO1DylUKxmiBi9CkIfBzVvrTrsYwP8YVWq9HbQXtzxEN7wlS+SWCy U4KOc0KaAXX1g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0ED2569572 for ; Tue, 20 Jan 2026 16:19:49 -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 VmiWEycKBBqM for ; Tue, 20 Jan 2026 16:19:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951188; bh=+biS6qAv/rcLtSDnnpNrRNKDwdLPvDx1oMjKMMD+hS0=; 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=qv7PnbIapvMSXRivXB3Rf8Uy0zL94k+KrSfiOSqJ7p18Sk+HRseoV/by+Cbhote7q qFHxNdZhtv+w9Nf81IhP8aDUNkKVJVu0fru4DKNbJ99G4BMWi25zDxY2esPqvde9j4 hLX6hAh4H1Se7HoegX74bPOPHgvi+DkMlvasrhzA012zJfYnKG8J6d7n5CLpDD7x1v UffXW3AzqoldLXl62xnKDKvmyDaCwxa4i/dqwaeE8BJY4BOP8jaGYCs+Ljm3MqrBxe WrMilZMLohpwHZhgU//csqqs2e6RCRx+ijURVe0SGE0Z9Fsh7sov12TWFT7WHqTjcy +aWiB9uIeL4aQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id F27CB6957E for ; Tue, 20 Jan 2026 16:19:48 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951187; bh=f0tMsyNIUmHuBDSBSaZtK0kihyxPwybH0xv7uAySZZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cnCN50p3U8UX2XFGDTjZ59BpnupaC/nbVODKY3hRfBAWCbjIhmHGHuPzGmdJV5Muz 3zdo0mq+J66vvHiANDIhPqHEgGsFZTkUdA60diEEOHm6uALdN5teiUtKGoZHYSeMFG UAqfRxxU0+BJfete1w7VzIVAXjKHTaLNa3eP6+8rIKeKlZUnhcJ9Ic6JTUvzPVw754 UbMo7eh8awuvhx97OoTcptuaxe1AhUOM5PP3tUSkOU9tFi1zu3xMcwVzdcLx9fGbD0 CSPksS+6pm98YenOffYxW+vYqpVMgwDRJNhtFcGoPIihBlITSySyhfpYNnpXtfUV/g YpsV+Hf9OWWZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F02969572; Tue, 20 Jan 2026 16:19:47 -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 3Fqa9H9sf_TE; Tue, 20 Jan 2026 16:19:47 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951183; bh=1as3RP0CLwZW4pa+QyGkwueR9AvwgISB07Nlkt2sONI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EFpaVHGqTPzmmOMejcnIi362u0eVJQ2344VwwY9yoieAa0ktuaIzYB5ljkTcvwVRR eEW2VR0k1ZriNSiGEDvycIqv3wkyAKGxUYkfd3VgOTAHl9Vg1e42EyuE8QFkgoOEqQ 3wx4D+qMcsXbcIjAMqiXOJ1pxpTO6P/Ewf9kx+g7dyhW6ytJhTpY77AwaIDITZwKw3 QB9oLbbNpiTssYjbleUhNNt7CXrpB9gzhDoe0DAuE6G6dXQ1lsBgJMTj1oEXMsCZ4d Pi7Alrhmys4tm5jJP+1cJfKGU+RJ+ZvHeMD3Lc2ARFJEN1lnO0oqUWDMEfxyF3GpDb lPzv1H0xjVkhA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 55B086913F; Tue, 20 Jan 2026 16:19:43 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:43 -0700 Message-ID: <20260120231814.2033069-17-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: XYRJLMY5XSYLSF3GZASSABYZT65AAEUG X-Message-ID-Hash: XYRJLMY5XSYLSF3GZASSABYZT65AAEUG 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 16/36] video: Pass context to get_cursor_info() method 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 The get_cursor_info() driver method currently uses the default context. Update it to accept a context parameter so callers can specify which context to use for obtaining cursor position info. This is needed for text-input objects which have their own vidconsole context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_normal.c | 6 +++--- drivers/video/console_truetype.c | 4 ++-- drivers/video/vidconsole-uclass.c | 2 +- include/video_console.h | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 5f84896699d..5f57b3403f1 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -87,10 +87,10 @@ int console_normal_putc_xy(struct udevice *dev, void *vctx, uint x_frac, return console_fixed_putc_xy(dev, vctx, x_frac, y, cp, priv->fontdata); } -static __maybe_unused int console_get_cursor_info(struct udevice *dev) +static __maybe_unused int console_get_cursor_info(struct udevice *dev, + void *vctx) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); + struct vidconsole_ctx *ctx = vctx; struct console_simple_priv *priv = dev_get_priv(dev); struct video_fontdata *fontdata = priv->fontdata; struct vidconsole_cursor *curs = &ctx->curs; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index a72e2342010..5453e5d9776 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1192,9 +1192,9 @@ static int truetype_entry_restore(struct udevice *dev, struct abuf *buf) return 0; } -static int truetype_get_cursor_info(struct udevice *dev) +static int truetype_get_cursor_info(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; struct vidconsole_cursor *curs = &com->curs; int x, y, index; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 51db3200e86..6258513b07e 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -779,7 +779,7 @@ int vidconsole_show_cursor(struct udevice *dev) if (!ops->get_cursor_info) return -ENOSYS; - ret = ops->get_cursor_info(dev); + ret = ops->get_cursor_info(dev, ctx); if (ret) return ret; diff --git a/include/video_console.h b/include/video_console.h index 9627d645189..2b299661e1b 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -431,9 +431,10 @@ struct vidconsole_ops { * @xmark_frac, @ymark and @index * * @dev: Console device to use + * @ctx: Vidconsole context to use (cannot be NULL) * Return: 0 if OK, -ve on error */ - int (*get_cursor_info)(struct udevice *dev); + int (*get_cursor_info)(struct udevice *dev, void *ctx); /** * mark_start() - Mark the current position as the state of CLI entry 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); From patchwork Tue Jan 20 23:17:45 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1691 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=1768951198; bh=ttiD2nCXXX9gytDBgmtNVb9NvUT+RsPbiMEWo+87WgA=; 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=Rg3iUFLBlWFTo2RM9jzBfCYWdsQFQewudEXkeg5BHsPtVv4OMDnbWEbn5G4H4q1ek F3e376c/CAb/rnQY0VjUsv6AbunpoDvnrAdm7snjNTEDMousbFSi94ykuCSZX4BI72 8XE72uge9TnvWJL0MMPvGetJAkh1JaJLsxZJhwrFcxDszd25TJQqGkTI7jn3aHPPSM 0VPXgo2UQgUJMrot72YTOS2i98UaI4g1aA5BQUJMWlM3IWWsulBvu0cIieP1QPbVcG lNiWNU5f9dAQIOB0rCjeom2sLaXuGF9ERYrRAqQTjXeQ8kgiUz69Dc7YGz7d0Lw+7z c7mY+Db+XmwOQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51B4C6957E for ; Tue, 20 Jan 2026 16:19:58 -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 KZUV8FPT6M1j for ; Tue, 20 Jan 2026 16:19:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951198; bh=ttiD2nCXXX9gytDBgmtNVb9NvUT+RsPbiMEWo+87WgA=; 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=Rg3iUFLBlWFTo2RM9jzBfCYWdsQFQewudEXkeg5BHsPtVv4OMDnbWEbn5G4H4q1ek F3e376c/CAb/rnQY0VjUsv6AbunpoDvnrAdm7snjNTEDMousbFSi94ykuCSZX4BI72 8XE72uge9TnvWJL0MMPvGetJAkh1JaJLsxZJhwrFcxDszd25TJQqGkTI7jn3aHPPSM 0VPXgo2UQgUJMrot72YTOS2i98UaI4g1aA5BQUJMWlM3IWWsulBvu0cIieP1QPbVcG lNiWNU5f9dAQIOB0rCjeom2sLaXuGF9ERYrRAqQTjXeQ8kgiUz69Dc7YGz7d0Lw+7z c7mY+Db+XmwOQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3DD7F69587 for ; Tue, 20 Jan 2026 16:19:58 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951197; bh=6K7GnWOq1oVw3FWzTiQyxxlWDJMWyP0MADcFOcLAqV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kUII4hhyLZfXLGRffQC0ess2fli8W+gl7E5+MFg1cOtU+qP6GFS4LY7Ylzy0it6Bu MPruov7qDKLwX5dIQDSd/RFnoDRPpA2FpbRNSXxyBTo3ZIE7JOB1H8DoHr26o40Dun JafGL1IkK0gORDqxtTyxp+p4gZdeBq1x8JorKPvMx1Em8AFzFjDNHftBb2M5ed6YYd /4EBsD/owD+y28kBnWexQIsf45hM1iVnhwlBXannUWripKuwb7t8aIYbkHsgpA8zj4 EV3LGCHjZjHPjdvs73TksR0JDN4NKTagHBYCMTyyTlWMF+95qToznVt22haDBhOmku 0j6jbzbTjfguA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 434616957E; Tue, 20 Jan 2026 16:19:57 -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 iq9MBsc1dq2P; Tue, 20 Jan 2026 16:19:57 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951193; bh=EVv7M+hhdIV8T5GeGr3SEMQjJXovS6rsTXVYd8X4on0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nz/CA5HOm2UsZlU59juW/L3rJy8BouuvPU2wD5mutkHxZivYqs2/q4yy6mU1zWWav /orA1ZwI6/WIW6gWZkuVKDqbJOf1TzNRp3YiMkqEbaoO6nfSYf8bSMcuqahWvGhScH MH5oTekJsusY6yEPT/FWi6U9gQGWDX90ezvb1VqsntvREUvLAqpW16bqN+fQjjofzv H4UuN5CoEqhQD3P/3pMwl9qEuNVjvv4kuc/TQJpxZrcazDmI9YhI08RHYsD2933lRg G87vVLuROjxqQPUZujA3MKOG9zSVED4x7iEveAyFR0HRb4NHp/Qlzz3vCO1q6MlHHb izi4VL85hs28g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DC7516913F; Tue, 20 Jan 2026 16:19:52 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:45 -0700 Message-ID: <20260120231814.2033069-19-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: JTD6V4BGQNTLJKN4CGLJ32I6TTQ43MTP X-Message-ID-Hash: JTD6V4BGQNTLJKN4CGLJ32I6TTQ43MTP 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 18/36] video: Pass context to vidconsole_put_char() 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_put_char() 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 --- board/atmel/common/video_display.c | 2 +- boot/scene.c | 2 +- boot/scene_txtin.c | 4 ++-- drivers/video/vidconsole-uclass.c | 10 +++++----- include/video_console.h | 3 ++- test/dm/video.c | 14 +++++++------- 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/board/atmel/common/video_display.c b/board/atmel/common/video_display.c index 55a49b45f16..5d87d456399 100644 --- a/board/atmel/common/video_display.c +++ b/board/atmel/common/video_display.c @@ -71,7 +71,7 @@ int at91_video_show_board_info(void) priv->ctx->y_charsize - 1) / priv->ctx->y_charsize); for (s = buf, i = 0; i < len; s++, i++) - vidconsole_put_char(con, *s); + vidconsole_put_char(con, NULL, *s); return 0; } diff --git a/boot/scene.c b/boot/scene.c index 2627335c0e8..ed25ffdffa3 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -623,7 +623,7 @@ static void draw_string(struct udevice *cons, const char *str, int len, int i; for (i = 0; i < len; i++) - vidconsole_put_char(cons, '*'); + vidconsole_put_char(cons, NULL, '*'); } else { vidconsole_put_stringn(cons, str, len); } diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 007f827f776..da42f364f39 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -79,7 +79,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, /* move cursor back to the correct position */ for (i = cls->num; i < cls->eol_num; i++) - vidconsole_put_char(cons, '\b'); + vidconsole_put_char(cons, NULL, '\b'); ret = vidconsole_entry_save(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); @@ -103,7 +103,7 @@ static void scene_txtin_putch(struct cli_line_state *cls, int ch) { struct scene *scn = cls->priv; - vidconsole_put_char(scn->expo->cons, ch); + vidconsole_put_char(scn->expo->cons, NULL, ch); } void scene_txtin_close(struct scene *scn) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 7b23a0a68ac..45f39db99b0 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -486,10 +486,10 @@ static int vidconsole_output_glyph(struct udevice *dev, return 0; } -int vidconsole_put_char(struct udevice *dev, char ch) +int vidconsole_put_char(struct udevice *dev, void *vctx, char ch) { 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_ansi *ansi = &ctx->ansi; int cp, ret; @@ -514,7 +514,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; case '\n': vidconsole_newline(dev, ctx); - vidconsole_entry_start(dev, NULL); + vidconsole_entry_start(dev, ctx); break; case '\t': /* Tab (8 chars alignment) */ ctx->xcur_frac = ((ctx->xcur_frac / ctx->tab_width_frac) @@ -552,7 +552,7 @@ int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen) if (maxlen != -1) end = str + maxlen; for (s = str; *s && (maxlen == -1 || s < end); s++) { - ret = vidconsole_put_char(dev, *s); + ret = vidconsole_put_char(dev, NULL, *s); if (ret) return ret; } @@ -573,7 +573,7 @@ static void vidconsole_putc(struct stdio_dev *sdev, const char ch) if (priv->quiet) return; - ret = vidconsole_put_char(dev, ch); + ret = vidconsole_put_char(dev, NULL, ch); if (ret) { #ifdef DEBUG console_puts_select_stderr(true, "[vc err: putc]"); diff --git a/include/video_console.h b/include/video_console.h index 6b8278123da..16c01718bd9 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -748,10 +748,11 @@ int vidconsole_entry_start(struct udevice *dev, void *ctx); * can be adjusted manually using vidconsole_position_cursor(). * * @dev: Device to adjust + * @vctx: Vidconsole context to use, or NULL to use default * @ch: Character to write * Return: 0 if OK, -ve on error */ -int vidconsole_put_char(struct udevice *dev, char ch); +int vidconsole_put_char(struct udevice *dev, void *vctx, char ch); /** * vidconsole_put_stringn() - Output part of a string to the current console pos diff --git a/test/dm/video.c b/test/dm/video.c index ef0c0c5265b..ede09a432a2 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -420,21 +420,21 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, /* Check display wrap */ for (i = 0; i < 120; i++) - vidconsole_put_char(con, 'A' + i % 50); + vidconsole_put_char(con, NULL, 'A' + i % 50); ut_asserteq(wrap_size, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* Check display scrolling */ for (i = 0; i < SCROLL_LINES; i++) { - vidconsole_put_char(con, 'A' + i % 50); - vidconsole_put_char(con, '\n'); + vidconsole_put_char(con, NULL, 'A' + i % 50); + vidconsole_put_char(con, NULL, '\n'); } ut_asserteq(scroll_size, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* If we scroll enough, the screen becomes blank again */ for (i = 0; i < SCROLL_LINES; i++) - vidconsole_put_char(con, '\n'); + vidconsole_put_char(con, NULL, '\n'); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -1193,8 +1193,8 @@ static int check_cursor_backspace(struct unit_test_state *uts, ut_assert(!curs->enabled); ut_assert(!curs->saved); ut_assert(!curs->height); - ut_assertok(vidconsole_put_char(con, ' ')); - ut_assertok(vidconsole_put_char(con, 'a')); + ut_assertok(vidconsole_put_char(con, NULL, ' ')); + ut_assertok(vidconsole_put_char(con, NULL, 'a')); with_a = video_compress_fb(uts, dev, false); /* Show cursor at current position (after 'a') */ @@ -1208,7 +1208,7 @@ static int check_cursor_backspace(struct unit_test_state *uts, curs->enabled = true; /* Do backspace - the cursor will be hidden */ - ut_assertok(vidconsole_put_char(con, '\b')); + ut_assertok(vidconsole_put_char(con, NULL, '\b')); ut_assert(!curs->visible); ut_assert(!curs->saved); after_backspace = video_compress_fb(uts, dev, false); From patchwork Tue Jan 20 23:17:46 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1692 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=1768951203; bh=x/6d7+CbQ6mzpKU4ArFFncWB1HL78tkL1YTaPEOYsOc=; 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=ErfVKyFJq1vDD3ze/p2aJh09KlO27MNW2CDSSyQ2Siz3aYMKvsA+9DgWsLf3oZ3fd Htk8ofgCqDAh0JyFDWI1T4XwiQL5gueIFCJlbvXZXT46y4DP30pJAZH6YBFzTkBK/I oNUSDK28RcS6jcJ3BtxsbTCvQ5fw04KT3tE8elDK6CmdZzYqUqlpXZ3lfE2ifURtxw o6io1HNuPr+1CKUz/dUdLfwnrX2VrMI+dmLpwJgjhHxHSgMgJH2jDZaIizj/071dDb niNDzs+hutknr1EQs4rG0A4FGo8TN6sgXZUh1vBosyDR2ZynLeQbHOQIZOYqVkY6zY NhG8Wf/N9QCqw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EB6E86957E for ; Tue, 20 Jan 2026 16:20:03 -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 OQQ2hUZP8d7l for ; Tue, 20 Jan 2026 16:20:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951203; bh=x/6d7+CbQ6mzpKU4ArFFncWB1HL78tkL1YTaPEOYsOc=; 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=ErfVKyFJq1vDD3ze/p2aJh09KlO27MNW2CDSSyQ2Siz3aYMKvsA+9DgWsLf3oZ3fd Htk8ofgCqDAh0JyFDWI1T4XwiQL5gueIFCJlbvXZXT46y4DP30pJAZH6YBFzTkBK/I oNUSDK28RcS6jcJ3BtxsbTCvQ5fw04KT3tE8elDK6CmdZzYqUqlpXZ3lfE2ifURtxw o6io1HNuPr+1CKUz/dUdLfwnrX2VrMI+dmLpwJgjhHxHSgMgJH2jDZaIizj/071dDb niNDzs+hutknr1EQs4rG0A4FGo8TN6sgXZUh1vBosyDR2ZynLeQbHOQIZOYqVkY6zY NhG8Wf/N9QCqw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id D300F69587 for ; Tue, 20 Jan 2026 16:20:03 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951202; bh=JdNmJM+eErX2FMg4DajGESCWosKXg38BvWhQsT6mBfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuJBDEW2dvnZWJOeoy9BItUNwS67HgPrO65XO7+bNg6Ayp75RWgRCEAYipayA3yJq i1tL3RG5AmJjTa74kdXsmx3Cr7DNs/6DEXCw4ikCT0n44RLROQ7tzdxBrCsMPkEWt+ 7wX0ASDzAAK8ZR5iDOcZqGhGeVvRnhs3ET78Gqu5D7cW3/rcXQiiA/8r/rrzU4E+G+ l+TTrAzJd9MWsnRIIG6pO4TyNToSTxM/2jGFWlgVTmNEc4MmnFT8ze5TX3xkBSTviz 4UhYTlGIMbEzpFxiTKTfXUWb+HIAQo4jTCp3skQPRiAkIGP+VWJ0Nt/aGMPTJ9qgev XHscSnoRTnL1w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 225A169587; Tue, 20 Jan 2026 16:20:02 -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 eWZ4WKSLDI7Y; Tue, 20 Jan 2026 16:20:02 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951198; bh=mlAlrh3yrhulaafhfqIdRvXotezXeBgvJOO/GLGLL1U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r2LSDpMJbv2IsBRJ+GpyW2JCPl87S1iwbvFQVpFK9omLYPtdPAwt4A0wJM0FDoCAv P0Ws3Z+FeCeWffsnftsrn4GMvhUozZlTqumkg8ADKtFSUGyFvCwe2DJU7jC0TIouGB V/Gdz5KEeKLKyokPGRy032MrNASPvFKW+PiR8ebtW/VT1pCyVWAd7xVSZBbJ84Z1lX l5Cg822X1E/W0XsSZGFEuDvhQDp2Qvzky0PcKcGCYky4ofPhGaAGAwMUvhEGTB/B50 a8mjt3Bg3jkfKsZQlr38ycoy1G+O0+YdiwpofOG3ctJRCQGzGyKYYQZQbLZqhbVHdV lvA6KrxCLHLxg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B33BD6913F; Tue, 20 Jan 2026 16:19:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:46 -0700 Message-ID: <20260120231814.2033069-20-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: DRFEJOBWY5DWW5HAZ5YGWFWWKGEN3ZC5 X-Message-ID-Hash: DRFEJOBWY5DWW5HAZ5YGWFWWKGEN3ZC5 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 19/36] video: Pass context to vidconsole_put_string() et al 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_put_stringn() and vidconsole_put_string() 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 --- board/kosagi/novena/novena.c | 2 +- boot/expo_test.c | 10 +++--- boot/scene.c | 2 +- cmd/video.c | 4 +-- common/splash.c | 2 +- drivers/video/vidconsole-uclass.c | 11 ++++--- include/video_console.h | 7 +++-- test/dm/video.c | 52 +++++++++++++++---------------- 8 files changed, 47 insertions(+), 43 deletions(-) diff --git a/board/kosagi/novena/novena.c b/board/kosagi/novena/novena.c index f65551ece5e..a1f177265cb 100644 --- a/board/kosagi/novena/novena.c +++ b/board/kosagi/novena/novena.c @@ -79,7 +79,7 @@ int board_late_init(void) display_options_get_banner(false, buf, sizeof(buf)); vidconsole_position_cursor(con, 0, 0); - vidconsole_put_string(con, buf); + vidconsole_put_string(con, NULL, buf); #endif return 0; } diff --git a/boot/expo_test.c b/boot/expo_test.c index ae4e70ceede..2d5ba7c0f4c 100644 --- a/boot/expo_test.c +++ b/boot/expo_test.c @@ -181,14 +181,14 @@ int expo_test_render(struct expo *exp) x = vid_priv->xsize - 18 * ctx->x_charsize; y = 10; vidconsole_set_cursor_pos(exp->cons, NULL, x, y); - vidconsole_put_string(exp->cons, buf); + vidconsole_put_string(exp->cons, NULL, buf); /* Display FPS on next line (only if non-zero) */ if (test->fps_last > 0) { snprintf(buf, sizeof(buf), "fps %6d", test->fps_last); y += ctx->y_charsize; vidconsole_set_cursor_pos(exp->cons, NULL, x, y); - vidconsole_put_string(exp->cons, buf); + vidconsole_put_string(exp->cons, NULL, buf); } /* Display average render time in milliseconds on next line */ @@ -197,7 +197,7 @@ int expo_test_render(struct expo *exp) (test->render_avg_us % 1000) / 100); y += ctx->y_charsize; vidconsole_set_cursor_pos(exp->cons, NULL, x, y); - vidconsole_put_string(exp->cons, buf); + vidconsole_put_string(exp->cons, NULL, buf); /* Display average sync time in milliseconds on next line */ snprintf(buf, sizeof(buf), "sync %6lu.%01lums", @@ -205,7 +205,7 @@ int expo_test_render(struct expo *exp) (test->sync_avg_us % 1000) / 100); y += ctx->y_charsize; vidconsole_set_cursor_pos(exp->cons, NULL, x, y); - vidconsole_put_string(exp->cons, buf); + vidconsole_put_string(exp->cons, NULL, buf); /* Display average poll time in milliseconds on next line */ snprintf(buf, sizeof(buf), "poll %6lu.%01lums", @@ -213,7 +213,7 @@ int expo_test_render(struct expo *exp) (test->poll_avg_us % 1000) / 100); y += ctx->y_charsize; vidconsole_set_cursor_pos(exp->cons, NULL, x, y); - vidconsole_put_string(exp->cons, buf); + vidconsole_put_string(exp->cons, NULL, buf); return 0; } diff --git a/boot/scene.c b/boot/scene.c index ed25ffdffa3..e504cb29d51 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -625,7 +625,7 @@ static void draw_string(struct udevice *cons, const char *str, int len, for (i = 0; i < len; i++) vidconsole_put_char(cons, NULL, '*'); } else { - vidconsole_put_stringn(cons, str, len); + vidconsole_put_stringn(cons, NULL, str, len); } } diff --git a/cmd/video.c b/cmd/video.c index 5c228b48058..cdd5804a172 100644 --- a/cmd/video.c +++ b/cmd/video.c @@ -41,7 +41,7 @@ static int do_video_puts(struct cmd_tbl *cmdtp, int flag, int argc, if (uclass_first_device_err(UCLASS_VIDEO_CONSOLE, &dev)) return CMD_RET_FAILURE; - ret = vidconsole_put_string(dev, argv[1]); + ret = vidconsole_put_string(dev, NULL, argv[1]); if (!ret) ret = video_sync(dev->parent, false); @@ -89,7 +89,7 @@ static int do_video_write(struct cmd_tbl *cmdtp, int flag, int argc, else vidconsole_position_cursor(dev, col, row); - ret = vidconsole_put_string(dev, argv[i + 1]); + ret = vidconsole_put_string(dev, NULL, argv[i + 1]); if (ret) return CMD_RET_FAILURE; } diff --git a/common/splash.c b/common/splash.c index c5591293634..7bdf2927d1e 100644 --- a/common/splash.c +++ b/common/splash.c @@ -149,7 +149,7 @@ void splash_display_banner(void) display_options_get_banner(false, buf, sizeof(buf)); vidconsole_position_cursor(dev, col, 1); - vidconsole_put_string(dev, buf); + vidconsole_put_string(dev, NULL, buf); vidconsole_position_cursor(dev, 0, row); } #endif /* CONFIG_VIDEO && !CONFIG_HIDE_LOGO_VERSION */ diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 45f39db99b0..9b29b742740 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -544,7 +544,8 @@ int vidconsole_put_char(struct udevice *dev, void *vctx, char ch) return 0; } -int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen) +int vidconsole_put_stringn(struct udevice *dev, void *ctx, const char *str, + int maxlen) { const char *s, *end = NULL; int ret; @@ -552,7 +553,7 @@ int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen) if (maxlen != -1) end = str + maxlen; for (s = str; *s && (maxlen == -1 || s < end); s++) { - ret = vidconsole_put_char(dev, NULL, *s); + ret = vidconsole_put_char(dev, ctx, *s); if (ret) return ret; } @@ -560,9 +561,9 @@ int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen) return 0; } -int vidconsole_put_string(struct udevice *dev, const char *str) +int vidconsole_put_string(struct udevice *dev, void *ctx, const char *str) { - return vidconsole_put_stringn(dev, str, -1); + return vidconsole_put_stringn(dev, ctx, str, -1); } static void vidconsole_putc(struct stdio_dev *sdev, const char ch) @@ -595,7 +596,7 @@ static void vidconsole_puts(struct stdio_dev *sdev, const char *s) if (priv->quiet) return; - ret = vidconsole_put_string(dev, s); + ret = vidconsole_put_string(dev, NULL, s); if (ret) { #ifdef DEBUG char str[30]; diff --git a/include/video_console.h b/include/video_console.h index 16c01718bd9..4bb6974edcc 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -765,11 +765,13 @@ int vidconsole_put_char(struct udevice *dev, void *vctx, char ch); * can be adjusted manually using vidconsole_position_cursor(). * * @dev: Device to adjust + * @ctx: Vidconsole context, or NULL to use default * @str: String to write * @maxlen: Maximum chars to output, or -1 for all * Return: 0 if OK, -ve on error */ -int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen); +int vidconsole_put_stringn(struct udevice *dev, void *ctx, const char *str, + int maxlen); /** * vidconsole_put_string() - Output a string to the current console position @@ -782,10 +784,11 @@ int vidconsole_put_stringn(struct udevice *dev, const char *str, int maxlen); * can be adjusted manually using vidconsole_position_cursor(). * * @dev: Device to adjust + * @ctx: Vidconsole context, or NULL to use default * @str: String to write * Return: 0 if OK, -ve on error */ -int vidconsole_put_string(struct udevice *dev, const char *str); +int vidconsole_put_string(struct udevice *dev, void *ctx, const char *str); /** * vidconsole_position_cursor() - Move the text cursor diff --git a/test/dm/video.c b/test/dm/video.c index ede09a432a2..7a58a64c0f9 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -343,7 +343,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); ut_assertok(vidconsole_select_font(con, "8x16", 0)); - vidconsole_put_string(con, test_string); + vidconsole_put_string(con, NULL, test_string); ut_asserteq(466, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -370,18 +370,18 @@ static int dm_test_video_ansi(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); /* test clear escape sequence: [2J */ - vidconsole_put_string(con, "A\tB\tC"ANSI_ESC"[2J"); + vidconsole_put_string(con, NULL, "A\tB\tC" ANSI_ESC "[2J"); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* test set-cursor: [%d;%df */ - vidconsole_put_string(con, "abc"ANSI_ESC"[2;2fab"ANSI_ESC"[4;4fcd"); + vidconsole_put_string(con, NULL, "abc" ANSI_ESC "[2;2fab" ANSI_ESC "[4;4fcd"); ut_asserteq(143, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); /* test colors (30-37 fg color, 40-47 bg color) */ - vidconsole_put_string(con, ANSI_ESC"[30;41mfoo"); /* black on red */ - vidconsole_put_string(con, ANSI_ESC"[33;44mbar"); /* yellow on blue */ + vidconsole_put_string(con, NULL, ANSI_ESC "[30;41mfoo"); /* black on red */ + vidconsole_put_string(con, NULL, ANSI_ESC "[33;44mbar"); /* yellow on blue */ ut_asserteq(272, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -770,8 +770,8 @@ static int dm_test_video_truetype(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); - vidconsole_put_stringn(con, test_string, 30); + vidconsole_put_string(con, NULL, test_string); + vidconsole_put_stringn(con, NULL, test_string, 30); ut_asserteq(13073, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -799,7 +799,7 @@ static int dm_test_video_truetype_scroll(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); + vidconsole_put_string(con, NULL, test_string); ut_asserteq(34248, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -825,7 +825,7 @@ static int dm_test_video_truetype_bs(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, test_string); + vidconsole_put_string(con, NULL, test_string); ut_asserteq(29310, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -862,9 +862,9 @@ static int dm_test_video_copy(struct unit_test_state *uts) ut_assertok(video_bmp_display(dev, addr, 0, 0, false)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - vidconsole_put_string(con, "\n\n\n\n\n"); - vidconsole_put_string(con, test_string); - vidconsole_put_string(con, test_string); + vidconsole_put_string(con, NULL, "\n\n\n\n\n"); + vidconsole_put_string(con, NULL, test_string); + vidconsole_put_string(con, NULL, test_string); ut_asserteq(6884, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -888,8 +888,8 @@ static int dm_test_video_copy(struct unit_test_state *uts) * ./u-boot -Tl * ut dm dm_test_video_copy */ - vidconsole_put_string(con, test_string); - vidconsole_put_string(con, test_string); + vidconsole_put_string(con, NULL, test_string); + vidconsole_put_string(con, NULL, test_string); video_sync(dev, true); ut_asserteq(7621, video_compress_fb(uts, dev, false)); ut_asserteq(7741, video_compress_fb(uts, dev, true)); @@ -925,21 +925,21 @@ static int dm_test_video_damage(struct unit_test_state *uts) damage = &priv->damage; vidconsole_position_cursor(con, 14, 10); - vidconsole_put_string(con, test_string_2); + vidconsole_put_string(con, NULL, test_string_2); ut_asserteq(449, damage->x0); ut_asserteq(325, damage->y0); ut_asserteq(661, damage->x1); ut_asserteq(350, damage->y1); vidconsole_position_cursor(con, 7, 5); - vidconsole_put_string(con, test_string_1); + vidconsole_put_string(con, NULL, test_string_1); ut_asserteq(225, damage->x0); ut_asserteq(164, damage->y0); ut_asserteq(661, damage->x1); ut_asserteq(350, damage->y1); vidconsole_position_cursor(con, 21, 15); - vidconsole_put_string(con, test_string_3); + vidconsole_put_string(con, NULL, test_string_3); ut_asserteq(225, damage->x0); ut_asserteq(164, damage->y0); ut_asserteq(1280, damage->x1); @@ -1091,15 +1091,15 @@ static int dm_test_video_silence(struct unit_test_state *uts) ut_unsilence_console(uts); printf("message 1: console\n"); - vidconsole_put_string(con, "message 1: video\n"); + vidconsole_put_string(con, NULL, "message 1: video\n"); vidconsole_set_quiet(con, true); printf("second message: console\n"); - vidconsole_put_string(con, "second message: video\n"); + vidconsole_put_string(con, NULL, "second message: video\n"); vidconsole_set_quiet(con, false); printf("final message: console\n"); - vidconsole_put_string(con, "final message: video\n"); + vidconsole_put_string(con, NULL, "final message: video\n"); ut_asserteq(3944, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -1162,15 +1162,15 @@ static int dm_test_video_font_switch(struct unit_test_state *uts) ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); /* Start with TrueType font and write multi-line text */ - vidconsole_put_string(con, truetype_text); + vidconsole_put_string(con, NULL, truetype_text); /* Switch to bitmap font */ ut_assertok(vidconsole_select_font(con, "8x16", 0)); - vidconsole_put_string(con, bitmap_text); + vidconsole_put_string(con, NULL, bitmap_text); /* Switch back to TrueType font */ ut_assertok(vidconsole_select_font(con, NULL, 0)); - vidconsole_put_string(con, final_truetype_text); + vidconsole_put_string(con, NULL, final_truetype_text); ut_asserteq(14892, video_compress_fb(uts, dev, false)); @@ -1332,7 +1332,7 @@ static int dm_test_video_manual_sync(struct unit_test_state *uts) priv = dev_get_uclass_priv(dev); /* Write some text and verify it appears in the framebuffer */ - vidconsole_put_string(con, "Test"); + vidconsole_put_string(con, NULL, "Test"); ut_asserteq(118, video_compress_fb(uts, dev, false)); /* Sync to copy buffer before enabling manual-sync mode */ @@ -1343,7 +1343,7 @@ static int dm_test_video_manual_sync(struct unit_test_state *uts) /* Clear and write new text - auto-sync should not happen */ video_clear(dev); - vidconsole_put_string(con, "Manual Sync"); + vidconsole_put_string(con, NULL, "Manual Sync"); /* should do nothing in manual-sync mode */ ut_assertok(video_sync(dev, false)); @@ -1377,7 +1377,7 @@ static int dm_test_video_manual_sync(struct unit_test_state *uts) ut_assertok(video_check_copy_fb(uts, dev)); /* Write new text again */ - vidconsole_put_string(con, "Test2"); + vidconsole_put_string(con, NULL, "Test2"); /* without VIDSYNC_FLUSH or COPY - should do nothing */ ut_assertok(video_manual_sync(dev, 0)); From patchwork Tue Jan 20 23:17:47 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1693 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=1768951208; bh=lvcBPuTwIylGMYXp0IssrGGK3yl6IrXyGSwrD4oRDFU=; 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=vBUqZuCKLPnP70p9Oeqe6xiNNktoYfLk1aZThOeHWX/htyKyvsxuyF9+bwRmM/pPd 5ZD7BJbnXwvw46GtgEYDUd/Hfg1FeOGrj/CSEtPCQd4ntYRlpKPQXzljiUgz5cECXZ yhZaw7Fn7aBrg+6EXhxPWEaxrBGX8XAVIXc1mfw5ufsB27G0/Frv1DOY9sMVLDBGw8 5OovZ0SXOxSavg++MuVba0TqFmbQIL1Ork73EsLk2VmtpQ4JZVk8Qpq+l+AicqpT0Z 1xuKQnWb3+j8orAQycm+7X9V1EQIE7DDy2nNAjxwjnOGwZIVZew198zlERZssipy16 YAGmrH1vGhxvg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 89DB669594 for ; Tue, 20 Jan 2026 16:20:08 -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 0DgntpQ0_hkb for ; Tue, 20 Jan 2026 16:20:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951208; bh=lvcBPuTwIylGMYXp0IssrGGK3yl6IrXyGSwrD4oRDFU=; 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=vBUqZuCKLPnP70p9Oeqe6xiNNktoYfLk1aZThOeHWX/htyKyvsxuyF9+bwRmM/pPd 5ZD7BJbnXwvw46GtgEYDUd/Hfg1FeOGrj/CSEtPCQd4ntYRlpKPQXzljiUgz5cECXZ yhZaw7Fn7aBrg+6EXhxPWEaxrBGX8XAVIXc1mfw5ufsB27G0/Frv1DOY9sMVLDBGw8 5OovZ0SXOxSavg++MuVba0TqFmbQIL1Ork73EsLk2VmtpQ4JZVk8Qpq+l+AicqpT0Z 1xuKQnWb3+j8orAQycm+7X9V1EQIE7DDy2nNAjxwjnOGwZIVZew198zlERZssipy16 YAGmrH1vGhxvg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 794706957E for ; Tue, 20 Jan 2026 16:20:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951206; bh=Rskj7jKSNlXlsLazelQiIjfTo/0MVObTqXlXaJAnOxw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lGN3aPra1njEv0cEVhgSH/bta3N5jPhajxtofyGZPMhnUGmaphoqb19VLXobyYXXA p+FJ893YuMJKPJ2fBEVebRMkPpL5Jmkzd+GzFWclgz5qqb8F2wj2wxaFvfgcqItyM2 xXKS0u34wU7h39sOa/jhiK8heFdoTdxY5AAVVrGqCLfQdEStaX68PIdAY75KkM4Y/2 d0LeF/L+9g3CCYsRWryLOdSeL5o3OmfnJfptl+fPJ1JGBGgot7nHfAHykUWPfZSqp6 zuYJgvYvcctlKrOK9U31c2s6k9QExyt3lNyDsOHpa/5omPHebJ4n1s+YnA8HN0M1SV /tWSqdXIxjEIg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E8EF469591; Tue, 20 Jan 2026 16:20:06 -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 5Z4BWMaalja2; Tue, 20 Jan 2026 16:20:06 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951202; bh=M5chgMIRajBcChqVyuhs/8V4bD3LXEL9eiQtms4IP/A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jM6/Zi8QAiWM+VH5FKSVifwdgbe/YK6BLhkMCf+VUijNNAnPAsRmQQqqY5AgZFELy Jf0cqfxthuJu/3Rf8flEozVeJsv8MoTrIL6pLCxKgZ4xwmW1lCV2q6WJ8YwOS1o9Bn l4sbuBkB/FJvwyuWvuw+6dZAaOeWkgJ2iVfD855vBfbkMEQc6rqYcKE+upvzFgGQ4y X6YVA6GAn/o8enSPSKfvlEipoOIS2Obg59xnvE8vFinvvOV49zrgvVJ+5lU244POE9 CNK6gIIBAt/6dFYbrgRODxkWYT1tAEaJixQSPVrezxq+tSsSNS72QvIrFmcwwoWv7z 2QfodbISnG8bg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 95A446913F; Tue, 20 Jan 2026 16:20:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:47 -0700 Message-ID: <20260120231814.2033069-21-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: TYR4P7VKNO3XFYDKNQM4XC2G4Q7XE6TB X-Message-ID-Hash: TYR4P7VKNO3XFYDKNQM4XC2G4Q7XE6TB 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 20/36] video: Pass context to mark_start() method 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 The mark_start() driver method currently uses the default context. Update it to accept a context parameter so callers can specify which context to use for marking the start position. This is needed for text-input objects which have their own vidconsole context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 4 ++-- drivers/video/vidconsole-uclass.c | 8 ++++---- include/video_console.h | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 5453e5d9776..b3884bddd72 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1251,9 +1251,9 @@ const char *console_truetype_get_font_size(struct udevice *dev, uint *sizep) } } -static int truetype_mark_start(struct udevice *dev) +static int truetype_mark_start(struct udevice *dev, void *vctx) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; ctx->pos_start = ctx->pos_ptr; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 9b29b742740..6ef86abc4ce 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -839,10 +839,10 @@ int vidconsole_hide_cursor(struct udevice *dev, void *vctx) } #endif /* CONFIG_CURSOR */ -int vidconsole_mark_start(struct udevice *dev) +int vidconsole_mark_start(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); ctx->xmark_frac = ctx->xcur_frac; @@ -851,7 +851,7 @@ int vidconsole_mark_start(struct udevice *dev) if (ops->mark_start) { int ret; - ret = ops->mark_start(dev); + ret = ops->mark_start(dev, ctx); if (ret != -ENOSYS) return ret; } @@ -1027,7 +1027,7 @@ void vidconsole_readline_start(struct udevice *dev, void *vctx, bool indent) ctx->curs.indent = indent; ctx->curs.enabled = true; - vidconsole_mark_start(dev); + vidconsole_mark_start(dev, ctx); } void vidconsole_readline_end(struct udevice *dev, void *vctx) diff --git a/include/video_console.h b/include/video_console.h index 4bb6974edcc..297049cb851 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -444,8 +444,9 @@ struct vidconsole_ops { * the beginning point for the cursor. * * @dev: Console device to use + * @ctx: Vidconsole context to use (cannot be NULL) */ - int (*mark_start)(struct udevice *dev); + int (*mark_start)(struct udevice *dev, void *ctx); }; /* Get a pointer to the driver operations for a video console device */ From patchwork Tue Jan 20 23:17:48 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1694 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=1768951213; bh=85esZ88RJ/0/6S8C6mi9vs0nXq5hD/xCaIIuLQM+yTI=; 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=Mn0vpzICV24F5DfsDsfiYLWsXWuVusP5OOx5JeAYaDjFaVuubfhOfPdD90HY0ln6n A3LzmZs+b9kAEOAa7SifAi6BXkKKxLNBKo2dtRyG4WZR6NwOWER5hWQHFcZb2OTGlc E7xgaYZPgxcxaTZ8GGpY6RgQM7zh3I2IyI4dC1GTEegboHcV0WMSXqrtDMuPAUxuXq t2+/aJ6rSaCIhhgZD2fFeLs7mUKv8+6LS8Bb3Uxw4TjySMDeE1ttdK9iy1UoqREPQw dShebte7cx8EPt+9g4CL49rIlX5hYIUJTxq1u2hKLx7GQREDXXGe29wGe/dadXiN5B 880AmRi9QmgHw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 6A99C693E3 for ; Tue, 20 Jan 2026 16:20:13 -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 LHgjnBlRJmyS for ; Tue, 20 Jan 2026 16:20:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951213; bh=85esZ88RJ/0/6S8C6mi9vs0nXq5hD/xCaIIuLQM+yTI=; 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=Mn0vpzICV24F5DfsDsfiYLWsXWuVusP5OOx5JeAYaDjFaVuubfhOfPdD90HY0ln6n A3LzmZs+b9kAEOAa7SifAi6BXkKKxLNBKo2dtRyG4WZR6NwOWER5hWQHFcZb2OTGlc E7xgaYZPgxcxaTZ8GGpY6RgQM7zh3I2IyI4dC1GTEegboHcV0WMSXqrtDMuPAUxuXq t2+/aJ6rSaCIhhgZD2fFeLs7mUKv8+6LS8Bb3Uxw4TjySMDeE1ttdK9iy1UoqREPQw dShebte7cx8EPt+9g4CL49rIlX5hYIUJTxq1u2hKLx7GQREDXXGe29wGe/dadXiN5B 880AmRi9QmgHw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 58B736957E for ; Tue, 20 Jan 2026 16:20:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951211; bh=Wk8rO8y+xZNBlEk4u5nYRwrFb7eTFNPnJCkaccieZSA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E+7qM2UTioWk6JufJgfZXpS4omtfh346bqoOUKi1lf1nIrHIVQOe/2ZVWseSAbgri RGC1jQz9goL2OC8Ckk8uxPQ0fH6+NovnPqlhbflmq184IEiZai+Pe73l40z7uv8mzv SVRZYWJCjH8Avlq9v0y7gmn2fuPMj0GnR0fnKkZC/LYpH3IWnHIPAIdtUef46V3/1e kaSskt6c0dC3DhrJUY3IrX67lWZEYt/gSqY1Ye+f3IiligZNtEzar1dkDDs9rZ5DFV PmyCFwrZZ52HzWgf9UWtUHrhYbaqRDiNIW++HaqaW2k6OjJom3APARPl4dWUaoVDOt Cqux52rKLJBWA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B7E80693E3; Tue, 20 Jan 2026 16:20:11 -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 kJq7A54vJz4B; Tue, 20 Jan 2026 16:20:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951207; bh=4Leim3ewp7owwvrYCv0LNS0oT7+eozcOhOysuGn1l3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nn1mvlXDspTZa6eYM+wyY4unZK8zp+umHZtrFPrkpLopyBOFOv5Ik1zwd6rS0o9KP 5E5ELjkwfCb0aOnaWtsPTqZ3g92ff+n50F8T83ypOdj6lLZlvRxjCTCVpV849QcYb3 T1AZWd1uTnXHzhWKcXrkC6kBJzDD1HqezcSvsPXr/jV40EDKwa4TmPObyqrONUDHHF 8SHHrjb9jrWapR7Tx7D6bPy1it23Fr3f0s7aRfCoQEwHxka1+ZY29EyG66Ml2/lT6e drXY/MAOGzUvcoCdFfP9fIPpSwLY+0CIJhEuk1xkS9btaub+8eP1mxJ5HyZygsClWB zh1jIViosqFgw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 61EDC6913F; Tue, 20 Jan 2026 16:20:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:48 -0700 Message-ID: <20260120231814.2033069-22-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: V2NP6B5HUNKRWZOECVFVUOAGBA52QPCU X-Message-ID-Hash: V2NP6B5HUNKRWZOECVFVUOAGBA52QPCU 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 21/36] video: Pass context to select_font() method 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 context parameter to the select_font() method so that font selection can be done for a specific context rather than always using the default. The vidconsole_select_font() wrapper handles NULL by using the default context, so callers can pass NULL if they don't have a specific context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/expo_test.c | 2 +- boot/scene.c | 4 ++-- cmd/font.c | 4 ++-- drivers/video/console_core.c | 3 ++- drivers/video/console_truetype.c | 6 +++--- drivers/video/vidconsole-uclass.c | 7 +++++-- drivers/video/vidconsole_internal.h | 3 ++- include/video_console.h | 8 ++++++-- test/dm/video.c | 26 +++++++++++++------------- 9 files changed, 36 insertions(+), 27 deletions(-) diff --git a/boot/expo_test.c b/boot/expo_test.c index 2d5ba7c0f4c..1de597ea603 100644 --- a/boot/expo_test.c +++ b/boot/expo_test.c @@ -135,7 +135,7 @@ int expo_test_render(struct expo *exp) test->render_delta_us = get_timer_us(test->base_time_us); /* Select 8x16 font for test display */ - ret = vidconsole_select_font(exp->cons, "8x16", 0); + ret = vidconsole_select_font(exp->cons, NULL, "8x16", 0); if (ret && ret != -ENOSYS) return log_msg_ret("font", ret); diff --git a/boot/scene.c b/boot/scene.c index e504cb29d51..58be46cb7ee 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -647,10 +647,10 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, return -ENOTSUPP; if (gen->font_name || gen->font_size) { - ret = vidconsole_select_font(cons, gen->font_name, + ret = vidconsole_select_font(cons, NULL, gen->font_name, gen->font_size); } else { - ret = vidconsole_select_font(cons, NULL, 0); + ret = vidconsole_select_font(cons, NULL, NULL, 0); } if (ret && ret != -ENOSYS) return log_msg_ret("font", ret); diff --git a/cmd/font.c b/cmd/font.c index 79218779a2d..ca759df79a3 100644 --- a/cmd/font.c +++ b/cmd/font.c @@ -46,7 +46,7 @@ static int do_font_select(struct cmd_tbl *cmdtp, int flag, int argc, name = argv[1]; if (argc == 3) size = dectoul(argv[2], NULL); - ret = vidconsole_select_font(dev, name, size); + ret = vidconsole_select_font(dev, NULL, name, size); if (ret) { printf("Failed (error %d)\n", ret); return CMD_RET_FAILURE; @@ -75,7 +75,7 @@ static int do_font_size(struct cmd_tbl *cmdtp, int flag, int argc, } else { size = dectoul(argv[1], NULL); - ret = vidconsole_select_font(dev, font_name, size); + ret = vidconsole_select_font(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 ecb0b9dab89..5cb1b3fb2b7 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -369,7 +369,8 @@ int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y, return VID_TO_POS(fontdata->width); } -int console_simple_select_font(struct udevice *dev, const char *name, uint size) +int console_simple_select_font(struct udevice *dev, void *ctx, const char *name, + uint size) { struct video_fontdata *font; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index b3884bddd72..af880ad5597 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -973,10 +973,10 @@ static int get_metrics(struct udevice *dev, const char *name, uint size, return 0; } -static int truetype_select_font(struct udevice *dev, const char *name, - uint size) +static int truetype_select_font(struct udevice *dev, void *vctx, + const char *name, uint size) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); + struct console_tt_ctx *ctx = vctx; struct console_tt_metrics *met; struct video_fontdata *fontdata; int ret; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 6ef86abc4ce..c0eee7d75fd 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -647,14 +647,17 @@ int vidconsole_get_font_size(struct udevice *dev, const char **name, uint *sizep return 0; } -int vidconsole_select_font(struct udevice *dev, const char *name, uint size) +int vidconsole_select_font(struct udevice *dev, void *ctx, const char *name, + uint size) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); + if (!ctx) + ctx = vidconsole_ctx(dev); if (!ops->select_font) return -ENOSYS; - return ops->select_font(dev, name, size); + return ops->select_font(dev, ctx, name, size); } int vidconsole_measure(struct udevice *dev, const char *name, uint size, diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 8b598b26b13..e1e89f6524a 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -181,7 +181,8 @@ int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *i * Internal function to be used in as ops. * See details in video_console.h select_font function **/ -int console_simple_select_font(struct udevice *dev, const char *name, uint size); +int console_simple_select_font(struct udevice *dev, void *ctx, const char *name, + uint size); /** * Normal console putc_xy function that can be called by other console drivers diff --git a/include/video_console.h b/include/video_console.h index 297049cb851..c5fc0577670 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -334,11 +334,13 @@ struct vidconsole_ops { * select_font() - Select a particular font by name / size * * @dev: Device to adjust + * @ctx: Context to use * @name: Font name to use (NULL to use default) * @size: Font size to use (0 to use default) * Returns: 0 on success, -ENOENT if no such font */ - int (*select_font)(struct udevice *dev, const char *name, uint size); + int (*select_font)(struct udevice *dev, void *ctx, const char *name, + uint size); /** * measure() - Measure the bounding box of some text @@ -487,10 +489,12 @@ int vidconsole_get_font(struct udevice *dev, int seq, * vidconsole_select_font() - Select a particular font by name / size * * @dev: Device to adjust + * @ctx: Context to use (NULL to use default) * @name: Font name to use (NULL to use default) * @size: Font size to use (0 to use default) */ -int vidconsole_select_font(struct udevice *dev, const char *name, uint size); +int vidconsole_select_font(struct udevice *dev, void *ctx, const char *name, + uint size); /** * vidconsole_measure() - Measure the bounding box of some text diff --git a/test/dm/video.c b/test/dm/video.c index 7a58a64c0f9..b4a1200e481 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -259,7 +259,7 @@ static int dm_test_video_text(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -301,7 +301,7 @@ static int dm_test_video_text_12x22(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "12x22", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "12x22", 0)); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -342,7 +342,7 @@ static int dm_test_video_chars(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); vidconsole_put_string(con, NULL, test_string); ut_asserteq(466, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -361,7 +361,7 @@ static int dm_test_video_ansi(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); /* reference clear: */ video_clear(con->parent); @@ -414,7 +414,7 @@ static int check_vidconsole_output(struct unit_test_state *uts, int rot, ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); ut_asserteq(46, video_compress_fb(uts, dev, false)); ut_assertok(video_check_copy_fb(uts, dev)); @@ -1165,11 +1165,11 @@ static int dm_test_video_font_switch(struct unit_test_state *uts) vidconsole_put_string(con, NULL, truetype_text); /* Switch to bitmap font */ - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); vidconsole_put_string(con, NULL, bitmap_text); /* Switch back to TrueType font */ - ut_assertok(vidconsole_select_font(con, NULL, 0)); + ut_assertok(vidconsole_select_font(con, NULL, NULL, 0)); vidconsole_put_string(con, NULL, final_truetype_text); ut_asserteq(14892, video_compress_fb(uts, dev, false)); @@ -1242,7 +1242,7 @@ static int dm_test_video_backspace_normal(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); ut_assertok(check_cursor_backspace(uts, dev, con, 16)); return 0; @@ -1256,7 +1256,7 @@ static int dm_test_video_backspace_truetype(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, NULL, 30)); + ut_assertok(vidconsole_select_font(con, NULL, NULL, 30)); ut_assertok(check_cursor_backspace(uts, dev, con, 30)); return 0; @@ -1271,7 +1271,7 @@ static int dm_test_video_cmd(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); ut_assertok(run_command("setcurs 10 5", 0)); @@ -1412,7 +1412,7 @@ static int dm_test_video_sync_damage(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); priv = dev_get_uclass_priv(dev); /* Use manual sync to prevent interference with the test */ @@ -1561,7 +1561,7 @@ static int dm_test_video_entry_save(struct unit_test_state *uts) ut_assertok(select_vidconsole(uts, "vidconsole0")); ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, "8x16", 0)); + ut_assertok(vidconsole_select_font(con, NULL, "8x16", 0)); ut_assertok(check_entry_save(uts, con)); @@ -1576,7 +1576,7 @@ static int dm_test_video_entry_save_tt(struct unit_test_state *uts) ut_assertok(video_get_nologo(uts, &dev)); ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, NULL, 30)); + ut_assertok(vidconsole_select_font(con, NULL, NULL, 30)); ut_assertok(check_entry_save(uts, con)); From patchwork Tue Jan 20 23:17:49 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1695 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=1768951218; bh=6qXxHN1NgzsQD8/3pEQZpiQmyJvVSrtHb0M3eXJVbzI=; 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=cV0162ti5kN5bsfaJ5r43+9nmaFKgYFO3BGczZIhqCnPJgBVmwTyFKD2LevCnBGC8 PPGV31vkxh1vATzbepr9MjQMLbQls7FcYM4f4cf5X28J2TicSkffYt+keXcsHyJH+z 2lEIEfyEzLB4/IPavuWV8CBtUlqopTzzAyWsbiXmlPeXEX8PsF1V5YGJBL3fXljc6m KB7P9hb4dKL20kDDSuDb8XRpAE4Xy85hz5DrqFF8qL1HQlKvJXg+SrT7MKWwX5N3TW alIN+2K1sz2MujQWhRJJqw+4bhqiFf83V2uU/0bgN0lIHkVF2DtCPDCcm8IrNkXXd4 aRYz76YSrMqOw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 036A46913F for ; Tue, 20 Jan 2026 16:20: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 Wh5EBa_iI5K1 for ; Tue, 20 Jan 2026 16:20:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951217; bh=6qXxHN1NgzsQD8/3pEQZpiQmyJvVSrtHb0M3eXJVbzI=; 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=RjyjwvXPT7MIBBAuZ4jjBv4pxdREg0tmf/6oH/hNqUCnCQtZm+mtS9TrRFe+yGO+0 10gGhXki40CIIcEKvgegD2j004KAXvfJT0KCn7x+qnPNq6aJDP72Vp08+o4q6/TasV 0Qqff0pNE28FFEDF3T5V23dI7Jl0U78CVXKEO8jOcWN7Q7Hn0YVEyTNV/yTPHuhqvq uA9g/narZzA/YHayBfVl9Jkbsi0+ogwPs+n+bhro15N5+T21AAGfvoiXUX0HZfwiF/ AUrCsunFfymcJjW/MTtZBPOgtzAVMjPgHLfdCoKiIhNlYlMl0HiAcUt0SSL/Ok8Uz5 BaJG5lxS7OrZA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E63826957E for ; Tue, 20 Jan 2026 16:20:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951216; bh=o1oRVYIAS9pDKHvNSnNSIpw6eME8DD3xoNn/A1twpGA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NjcjoUMrYbeB+UFPwiewbhnfsXAB6qEcYA6h4pNKWbJ+hxOjhqbuiSwNrkNxK7pCb AnQ3271ibM7D4VK4bfSK+WEftHtDww5ql8A6D5H8gvvL1Fh+SF+iXB112HzODHewqU 8PIeUDqBg8bX1gqtng0F3khjHyNkZStxVDIHBOhkmIE5ChcwFMK9g9MGoKLxIVyAHC V19wVlOyozAY8xkd1Q0ZmhoGoYyUEW3NhTUp8PrqDY86aTTZulefe6kSt0tH+7rEh9 Re+w0mxARKMWLgRTQR6Z/+KJ6TzNZ9ZuXYKXlgGXEUE1F6TsEQtcujqLpdELtRtaQk d35BT2mx3EC6A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7B277693E3; Tue, 20 Jan 2026 16:20: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 Frx0KTVws9cA; Tue, 20 Jan 2026 16:20:16 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951212; bh=1OUOe2zjfTaOgRakAzcaEECFp2Ux4PCYkoYkCPrGXmQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bp9Gy1sXKIFpHvQ5lKU6VxfBD6Oj6NLuHXe9nAT+PIkcpM405vNGbFqUk0hYLrBJ7 vJlKIiNw3iTXPEhDjHlZagsMzLJyu3mZmqAEMw6ixHUrLY5zWqoieCFg/FCzwcAL/P RSnEBPfG3PUvPmzWtx3s9kBbTO7mc9872HE9Lq+5dKK+3A+leyHtUbGZiMYJqUtsGn +QuwoWL01R18cEzBhgMvzPhj14XnRYayufsJp7zDfaONQkANi2kKVKl0Xik/+/hNm5 pt7xq6PvQgGMzpof9cgc87NmA74wDH4qTwud5g5UqR45df9QSiZmndZC5nuApGSWLS uU93/dFCd8a4g== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 326D36913F; Tue, 20 Jan 2026 16:20:12 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:49 -0700 Message-ID: <20260120231814.2033069-23-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: L54V3EQQ3FLRYUPIDYQHJUCODZ3OES7W X-Message-ID-Hash: L54V3EQQ3FLRYUPIDYQHJUCODZ3OES7W 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 22/36] video: Pass context to select_metrics() 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 select_metrics() to take a context parameter so it can operate on a specific context rather than always using the default. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index af880ad5597..4dd382055b2 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -913,9 +913,9 @@ static void set_bitmap_font(struct udevice *dev, com->tab_width_frac = VID_TO_POS(fontdata->width) * 8 / 2; } -static void select_metrics(struct udevice *dev, struct console_tt_metrics *met) +static void select_metrics(struct udevice *dev, struct console_tt_ctx *ctx, + struct console_tt_metrics *met) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; struct udevice *vid_dev = dev_get_parent(dev); struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev); @@ -998,7 +998,7 @@ static int truetype_select_font(struct udevice *dev, void *vctx, if (ret) return log_msg_ret("sel", ret); - select_metrics(dev, met); + select_metrics(dev, ctx, met); return 0; } @@ -1297,7 +1297,7 @@ static int console_truetype_probe(struct udevice *dev) return log_msg_ret("add", ret); ctx->cur_met = &priv->metrics[ret]; - select_metrics(dev, &priv->metrics[ret]); + select_metrics(dev, ctx, &priv->metrics[ret]); debug("%s: ready\n", __func__); From patchwork Tue Jan 20 23:17:50 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1696 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=1768951220; bh=U8EFa3iWw+VgnFyUdZMbRu0cBkiWB6604K52Y7i8QK8=; 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=B+GjM8shBL5QGh8moAa+dhb5T2Kwej4I68gvr3y0z8j7LATKxhO6le+KtbFJwmzF0 8YewTlTAiWeGcdgKHMbTYEYNdQc5Aau7TCdI2XHxkLBu7LRHrV7yOyy/dxqIM0s1fo XDCphDST9jNKXTfIQv1PIg3OXi7Mwj1306JMuGoz9sQcYFZxOVoE6Ups5wYaBhrSXo xhBwVAW+Yhc7zJ/VVcjXXttsoGQp/IhygJQvEZm0YHoOkU3WP9CvswCyo7j7HnfuHw rrmB0aI9DFDe+r1MbpE0tH3xIX6X2mGVrZmC9ExPEKLg++bvaed34F2dyrN7iLp3G6 6fvbJCCeqXtBQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 65456695A0 for ; Tue, 20 Jan 2026 16:20: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 pCR0G-lBGeA8 for ; Tue, 20 Jan 2026 16:20:20 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951219; bh=U8EFa3iWw+VgnFyUdZMbRu0cBkiWB6604K52Y7i8QK8=; 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=mapK2VqJEwrK8zs3sq34pmk/+L7P37/OWYMMjy2Avvnp72M+6piJC581qDtYSSuZI gkpoLuzrnwf987YZNlGNDfoAx1QGbzyNPNJ86yb8WhrSIM9zdCTyWTffpK08KWfSu7 uFbQRFrmE6DFl9qdEUqqHO4vRXHODeDOOSxMNP0DHT6HLLXexiF4nYAhuVvphA8LEZ /1WJrpYIPSnjKTiM9SZeEzuMvf4xuMNcLBSnOtzq2BirUYErQRYhkyH5nTC10j+n9a rn2FV8CWS80m+2xn/IFy3A3lS1/Q/ZQC2Sfs24wBXfPmrAvzYZ09hfJ1fkbYOAWDD0 3WFAa6pa8xsmA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5EB76693E3 for ; Tue, 20 Jan 2026 16:20:19 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951217; bh=cr41DeUE3ykdhkVMMgUZfjdnelW1PtiwpYGl8pl50uE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1F8l83KfHPu539u4FnM2BRF3xCBcNxn2Hy6rotkGkTT+c6pq28H5Yd4Ujj1NfcPd hGpE4hJ+SoMZh829O6Y/3EKBt4SDuozPveFS/edJ8jXTIxIPTkjFIDsZ7vDrg7Q+5a bVTzWluZioeU51sMjFfxIgtezjhnPrHG6M6qHFKhtbqTHj+Oh5Y0Ur1pzPWhIyGkEv M1IPCYi3wjSuk1GJ27m1dCCN3ON2shDOwcOR8jD+28EOktsfm/9H9CvZ51OToW0KFK 1xQbv8FFfHgrl68Lh1LDDLGyke+C2S4gDezEbb/kvt8kSk+CHDYJN7krbgBgsRtXeA J+e8cUfQGfG+w== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 932AD693E3; Tue, 20 Jan 2026 16:20:17 -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 fQvQDTPcNeIh; Tue, 20 Jan 2026 16:20:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951217; bh=iwAQr/SL6gJbm0fQDRnYwwz/omYFIuGEXrVUtiUAP7k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P6oK1RZXCznUPSn1RbdS4/Zx0CNDWBy/90SN0sKkaIukIlUosk5SxKXke4bobIjYH leYiYY5LH1oREZ2h6hhTtL1ib/NSyfznnZw99y9sOoamTzXiv/RptHqdqeebL5TOug SOg08bNVhHwHyQPcui65syqWSH70F0NTVn+PM9hI+aCNYSGs8z14uIkmiHqWdXiPmh Nq/ab5keMio6MRuiLIV+Zi4oQsO0q+Dpmsv7fUmcxZIdAE5H/fckvZG7sLhyV1uGLu sRbmBcaiRjtn5eOthR7o+7kdQA4OyyjNeXffFw+qLTF7pA45VAyp6I/7ognyllmaYA jWaUHud1SZKug== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 01EED6913F; Tue, 20 Jan 2026 16:20:16 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:50 -0700 Message-ID: <20260120231814.2033069-24-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: XHLSOIVUNW3TFXDO2UFVLF4HBBGS4UVK X-Message-ID-Hash: XHLSOIVUNW3TFXDO2UFVLF4HBBGS4UVK 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 23/36] video: Pass context to console_alloc_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 Update console_alloc_cursor() to take a context parameter so it can allocate cursor memory for a specific context rather than always using the default. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 7 ++----- drivers/video/console_truetype.c | 2 +- drivers/video/vidconsole_internal.h | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 5cb1b3fb2b7..dba47af4eb5 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -278,9 +278,8 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, return 0; } -int console_alloc_cursor(struct udevice *dev) +int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) { - struct vidconsole_ctx *ctx; struct vidconsole_cursor *curs; struct video_priv *vid_priv; struct udevice *vid; @@ -288,8 +287,6 @@ int console_alloc_cursor(struct udevice *dev) if (!CONFIG_IS_ENABLED(CURSOR) || xpl_phase() < PHASE_BOARD_R) return 0; - - ctx = vidconsole_ctx(dev); vid = dev_get_parent(dev); vid_priv = dev_get_uclass_priv(vid); curs = &ctx->curs; @@ -312,7 +309,7 @@ int console_probe(struct udevice *dev) return ret; if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev); + ret = console_alloc_cursor(dev, vidconsole_ctx(dev)); if (ret) return ret; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 4dd382055b2..9b835437031 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1301,7 +1301,7 @@ static int console_truetype_probe(struct udevice *dev) debug("%s: ready\n", __func__); - ret = console_alloc_cursor(dev); + ret = console_alloc_cursor(dev, &ctx->com); if (ret) return ret; diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index e1e89f6524a..60ff7bed758 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -152,9 +152,10 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, * Allocates memory for saving pixels under the cursor * * @dev: vidconsole device + * @ctx: vidconsole context * Return: 0 if success, -ENOMEM if allocation fails */ -int console_alloc_cursor(struct udevice *dev); +int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx); /** * console probe function. From patchwork Tue Jan 20 23:17: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: 1697 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=1768951224; bh=KxYwsKs32t6VhC+KpgcEjq5T+aLeWazHfgerCrfKmlM=; 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=oQzXO9UGNqeC24T26HY//VuuxgXR0Ywl7xshwI8Ez714P888ZU6gd+8gad4dvZBEI zwxkoRxJ6siYpMPIPgSKcdVammv7QGv+6o+Fl8Eleal4mR/62e+sy2OZKalYoHOgO+ 5V1OQrZneT5nGDRqr7oor3AS20nQ5NhWPppf6Ed/tHXtw0G90OPFiFnGiyJEbLcALj XjBTF1mPrn1GhlHotLsHNmpuiwu6jiIFN7hhSo1jpZtmAXZdicgB5Z1FArktgWjSDA uNuO9GjIMw4JCf66+NvyYrg572rAUp5A/z38ktgBp0tIs9mSegO9dDxiXiN+6Vcl77 T6bkbVLov+mkg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 676896959E for ; Tue, 20 Jan 2026 16:20:24 -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 u8-s8g5MGXEV for ; Tue, 20 Jan 2026 16:20:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951224; bh=KxYwsKs32t6VhC+KpgcEjq5T+aLeWazHfgerCrfKmlM=; 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=oQzXO9UGNqeC24T26HY//VuuxgXR0Ywl7xshwI8Ez714P888ZU6gd+8gad4dvZBEI zwxkoRxJ6siYpMPIPgSKcdVammv7QGv+6o+Fl8Eleal4mR/62e+sy2OZKalYoHOgO+ 5V1OQrZneT5nGDRqr7oor3AS20nQ5NhWPppf6Ed/tHXtw0G90OPFiFnGiyJEbLcALj XjBTF1mPrn1GhlHotLsHNmpuiwu6jiIFN7hhSo1jpZtmAXZdicgB5Z1FArktgWjSDA uNuO9GjIMw4JCf66+NvyYrg572rAUp5A/z38ktgBp0tIs9mSegO9dDxiXiN+6Vcl77 T6bkbVLov+mkg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51A18693E3 for ; Tue, 20 Jan 2026 16:20:24 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951222; bh=0mDNyn+L0udqPru3vCRMlQNxL3vzzcJhM8j5Ss2RWTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lWBUzTKxzswEeprsxKMpM47MxY7YVC9BDcASFy5JYI3n9KL/p++Y9BlmsG9On8JNi Id65DcrjfcX3dHIaos7ShEXxVAIgZLMr9zc3dz7pbZHCJQpzM8pGYS4xs7eGrnpIDx 9q3T18MW3k5SzeJjkKLuqBUsVb0rT7SnV8WwiuxmnqT9LJMsYRmdwHXf8S6O+DG1AG hNh6YmOsTJMWTByMtgrkJ0fDlVdFMhvuxDXtJ/OLSWY8IReDMw6RLPwiGlIN6tOqvw XQpr7UYlaVyJyk4Nd6hLTSO/ew5TRghlxDSv5I6XnLZkufp0/w/luBKSZzzbw4BGBM TUmo7+CYJMidQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B9B6B6913F; Tue, 20 Jan 2026 16:20:22 -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 8GzHZ1WyHTfy; Tue, 20 Jan 2026 16:20:22 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951218; bh=boIGURNi/5UhIDzMyAx0+XO598m1zSQup4KS8LolPH0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DhcInwQDQf1l5QtGys7rucO1kxR6E6EriP7P6Z2kFPaDS6D+/QW+cLin7zy+XqzZm 1PoC3IhhlXtxu7uOVMrIliLoVaEQTlTeFvcRmUu0s+2NLBouFz90nCx/WFe1XB3ZGF 3sG6mPKwx5wV96OFosgQyzm7uxa9f/E/Zj9052prN1uQmUJeIu12mOiigROoZBfM24 BPIS/+JUfkKyEAWkC6aJTGICrsVpVdlY6OVZlN7OoRzacM3K9onHV82KGxBEJR+xgb VEtIRelOi4exCa4VArtk9L39Wvo+IrzhBeVCInOGFmjv0M9FqiexehO5tT793oALEx 4+imr1fQN2qUg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 173A66959F; Tue, 20 Jan 2026 16:20:18 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:51 -0700 Message-ID: <20260120231814.2033069-25-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: U74MRCP4YY3ZUE52ARPZUXVAVDF3Y5IG X-Message-ID-Hash: U74MRCP4YY3ZUE52ARPZUXVAVDF3Y5IG 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 24/36] video: Pass context to vidconsole_set_bitmap_font() 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 vidconsole_set_bitmap_font() to take a context parameter so it can set font properties for a specific context rather than always using the default. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 2 +- drivers/video/console_truetype.c | 2 +- drivers/video/vidconsole-uclass.c | 4 +--- include/video_console.h | 3 ++- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index dba47af4eb5..ff5d9f5964a 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -25,7 +25,7 @@ static int console_set_font(struct udevice *dev, struct video_fontdata *fontdata struct console_simple_priv *priv = dev_get_priv(dev); priv->fontdata = fontdata; - vidconsole_set_bitmap_font(dev, fontdata); + vidconsole_set_bitmap_font(dev, vidconsole_ctx(dev), fontdata); return 0; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 9b835437031..7a5588bf419 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -908,7 +908,7 @@ static void set_bitmap_font(struct udevice *dev, ctx->cur_fontdata = fontdata; ctx->cur_met = NULL; - vidconsole_set_bitmap_font(dev, fontdata); + vidconsole_set_bitmap_font(dev, com, fontdata); com->tab_width_frac = VID_TO_POS(fontdata->width) * 8 / 2; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index c0eee7d75fd..b5a129d82b7 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -981,11 +981,9 @@ void vidconsole_set_quiet(struct udevice *dev, bool quiet) priv->quiet = quiet; } -void vidconsole_set_bitmap_font(struct udevice *dev, +void vidconsole_set_bitmap_font(struct udevice *dev, struct vidconsole_ctx *ctx, struct video_fontdata *fontdata) { - struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv); struct video_priv *vid_priv = dev_get_uclass_priv(dev->parent); log_debug("console_simple: setting %s font\n", fontdata->name); diff --git a/include/video_console.h b/include/video_console.h index c5fc0577670..500a5974a57 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -860,9 +860,10 @@ void vidconsole_set_quiet(struct udevice *dev, bool quiet); * vidconsole_set_bitmap_font() - prepare vidconsole for chosen bitmap font * * @dev vidconsole device + * @ctx vidconsole context * @fontdata pointer to font data struct */ -void vidconsole_set_bitmap_font(struct udevice *dev, +void vidconsole_set_bitmap_font(struct udevice *dev, struct vidconsole_ctx *ctx, struct video_fontdata *fontdata); /* From patchwork Tue Jan 20 23:17: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: 1698 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=1768951230; bh=YB3l+En19Jsl976HCyLIq/2sAPN50zPXEUfDeKDjfqA=; 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=SBHQFV+EuB+PRri4Ln4gnB81UU2ovmChqhupgrGkxK7GvXedq7TMYzvn8vCuLB24J vAFdoF/p+RFRrPm+Fmf9QqbZ22/HsQ8AvOtXIYANPWJjERZxqoUB4lwBRB0AZlUdb0 jjcdB8La1w25FqlcC9SbYquWkvfcR4NvR5ywOHEwF3MGK8FojHhKVVEir0diRpV6wG 3d1bhifjG9GXPnKcy2UNXqOB4ixQaFdxBVop2GFZCO3/jJgvKf2KRmRvRw1bHI9T12 z+79pbpB7ax5naX/dGKi5ktsangIQZEdYl95O7Z3Vdw1XHzpDZVM3X6t+LNeL3R554 NS6ukiFxeUraw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0F44A6959F for ; Tue, 20 Jan 2026 16:20:30 -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 3jwQA7ym3a3O for ; Tue, 20 Jan 2026 16:20:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951229; bh=YB3l+En19Jsl976HCyLIq/2sAPN50zPXEUfDeKDjfqA=; 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=msUq7qHBqLo6pAv3TzYa7b7aOTE6vlAcdYJagm6uPSI6P42jEzBXSddtm5vfWXUn4 MHgQLmk+K3o3uaYxRNuxPtEYZnLTfnO37Wn/vJ253N33xsgoKcwQ0UXNOOkbu1P/ZQ qRslEcobm12TKHu1SVp2C8J3CSm+LVPFh0Ua48tiq8WMuJ8+flyDtBTaHJ0n9iFzC4 PFjU9yXAw9U43sWVW6GODo5JtzjkNpoOCSveCpAwJEVPNmEufgK/Vb6HCI3y2eOIK1 +vAyiIV2jC3YBb57ZrJffj8FRBQcGNYLbb2Jt1XtHgO+zkeUMFF2ZPJ7aQhDmGyX0W C+hRdux74MVIw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EE45D6959D for ; Tue, 20 Jan 2026 16:20:29 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951227; bh=X+cwBZHUw30CpI89Anv3HFJN7i7NVaYGWZXJmtBddPM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rm4qyKWJfWT6DSrBKZU+/x+1yCE5dmov4jkkovuHR/0qn2zaop0Mawi9kXSCc9Sek fP+P6/ipG3VBd6Hv8udp8iihU6ACTBQ+8bhNH4MDPJmtNjQoCPlZk++wbmkrVZAOVB 7HIGNS2f4JYK58NOApeKj8eG9X6SBwikvlEgDqbIch4wFmrPoBzzRDPYz4ES4f0o+i wmEhm+NpkWEzNCTehhLHfNYt53jN/K9jqqwS15uaGVn0uUI7quKmsQdczj2eyh//SD dfRnWlQD9c0ymrzR1E9BPDKMjhlWmmTD6A74ri6sXQ7scgx1fctT83AIsbX8sB0Gfy cZe2SPYFZQvng== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 37D0E6913F; Tue, 20 Jan 2026 16:20:27 -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 SrDdfVgDNVQE; Tue, 20 Jan 2026 16:20:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951223; bh=HRB2xsruXVfKrfrxk34LXmw6ZT3/WUCkq5hF/jnAsps=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKntwSE2e9qKQDGp6cEwRyM2x/sLUGPTHUHJlcDTPg1RpnKXXVWMjLwrw2Cm9awtM 8B4Rux6rLYxrW6TnUHcKPtRJeqxCesuPWLxfN8RbYojPlMWVk6EWiNzMfEFLi6oH0X yDSvDaUwv8o8kFMwgymf76ytBi7ZCvB3RXmE9WCsi/CyxkT4ofLvXEYHC4lByKZNTo DmAYaDPgKJgxpwx7KWx9tZN5zX3JeEDxqsukBTfRZNI3zjNtJFo1HW1U3B8qtnSp5i 9SmEBV9ebbgZrE0R/g1sVFNY68G1Yjnjqmtf326ykVoLCGXQklMGoR+webGzqPF7Ye ZcSsTajyCqc2Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id DFE5F69597; Tue, 20 Jan 2026 16:20:22 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:52 -0700 Message-ID: <20260120231814.2033069-26-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: 2DE5YPP67IBUBT6EQKE3YPT7NRBCERIX X-Message-ID-Hash: 2DE5YPP67IBUBT6EQKE3YPT7NRBCERIX 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 25/36] video: Pass context to set_bitmap_font() 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 set_bitmap_font() to take a context parameter so it can set bitmap font properties for a specific context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_truetype.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 7a5588bf419..de2992ec748 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -896,13 +896,13 @@ static struct console_tt_metrics *find_metrics(struct udevice *dev, * set_bitmap_font() - Set up console to use a fixed font * * @dev: Console device + * @ctx: Console context * @fontdata: Fixed font data to use * Return: 0 if OK, -ve on error */ -static void set_bitmap_font(struct udevice *dev, +static void set_bitmap_font(struct udevice *dev, struct console_tt_ctx *ctx, struct video_fontdata *fontdata) { - struct console_tt_ctx *ctx = vidconsole_ctx(dev); struct vidconsole_ctx *com = &ctx->com; ctx->cur_fontdata = fontdata; @@ -986,7 +986,7 @@ static int truetype_select_font(struct udevice *dev, void *vctx, for (fontdata = fonts; fontdata->name; fontdata++) { if (!strcmp(name, fontdata->name)) { /* Switch to fixed-font mode */ - set_bitmap_font(dev, fontdata); + set_bitmap_font(dev, ctx, fontdata); return 0; } } From patchwork Tue Jan 20 23:17:53 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1699 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=1768951234; bh=37kEozS83s7+0UN0uHV/qKZMrNS+tp7xWcnXbEXsj/w=; 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=VMCx4Tz8EMJdTXKiWSihowj1zS3UcEMGNmZImnB/M6zbq2Z/qR7OJGNo0i7W0Waf8 WH+0K8elahsH3ZjHSbIB/wZw+ReDiqz6G0Z/IGAVkLhGS1/RnM/yN9y9eOpO0zEtR6 VSgMEPy4TinsirV5vObCdwwaUwmZ+AMaFB6OIiTs+/WSq/MkSHPLXt45H1ddNBg4hN oNG7uMbh0Ea2YLUMhLVG2MNhi6oCHXIVBhYYJwhj8wSYUH6Ak2dil9HxcjsvUHJoFP pShLsfQabpEwx/b/8vtvYXj/C4qP53CgzAzOhjjdQducqhYAY0mO9ub8EJ52ec013/ YgOCepJ1PJU4Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CABE86959F for ; Tue, 20 Jan 2026 16:20:34 -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 Py-FcwOJ0nJO for ; Tue, 20 Jan 2026 16:20:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951234; bh=37kEozS83s7+0UN0uHV/qKZMrNS+tp7xWcnXbEXsj/w=; 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=VMCx4Tz8EMJdTXKiWSihowj1zS3UcEMGNmZImnB/M6zbq2Z/qR7OJGNo0i7W0Waf8 WH+0K8elahsH3ZjHSbIB/wZw+ReDiqz6G0Z/IGAVkLhGS1/RnM/yN9y9eOpO0zEtR6 VSgMEPy4TinsirV5vObCdwwaUwmZ+AMaFB6OIiTs+/WSq/MkSHPLXt45H1ddNBg4hN oNG7uMbh0Ea2YLUMhLVG2MNhi6oCHXIVBhYYJwhj8wSYUH6Ak2dil9HxcjsvUHJoFP pShLsfQabpEwx/b/8vtvYXj/C4qP53CgzAzOhjjdQducqhYAY0mO9ub8EJ52ec013/ YgOCepJ1PJU4Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B8A3069597 for ; Tue, 20 Jan 2026 16:20:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951232; bh=8c48OIqxHOflB9NIm9EaOAo6DPT4kcChmgCnM9eSOdg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FPS1UhJiV4wHIjTDE6mwaFqitA40JBOmkFaAJ1bgJ3ITsiHy01gkB+DIzQrCMTNgr VqUP7d3jvQ2leYCfP3PQLc9EQScIcday9dTJ3QLdF8Yum3Jb+FzQ+wwIruzJdi/tlj LOzYScCQlFSNMnJdt4iv2IX6NHlj5VG3yQHxGe5nAe2dfCI4RqlNem3hm3x6TIHRK9 vKdf8LnosLjuUV7mj0bMjkAyVA2ZypCXTBk++kh4mS/dJZHSxz8qo/5pxxBa0P+jDP KC6LhB6mLnKWdEX97/xwGCxUUR8Z+jbQbIIZl/NtxPdDFY+pNOaLue0ivMZMNZVqKa xODLbsjCubecQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 850676959D; Tue, 20 Jan 2026 16:20:32 -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 6TSn-0sP9SqO; Tue, 20 Jan 2026 16:20:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951228; bh=DbBWfAOUiid/ScAFMFxjht3B2ejR+7u3XF5h4w5U9Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJ79d3BQqcE9YnTyf704AyafU8ouuEBf1dAlNANf/JvjqHGbZPAjaqneSa2MkwjA/ i7NkdC4UyfMaKkAK1SAlTrIEzp5KRwoCP6to/7CMIak1aA2ogyiZ6v6YduH2tJpu0f ceONnikwCHFZTeKsUN9ACTmXiAVl28KMVo1cV3G+juEMQypskcfbxiZzST8CPP/YJ1 qCbXuf0ccUEdA5giEzNEkoEotzkb7LFSoFpcWJd6o7qb4clD3XBTXfJWP4Z+0FOZgt t5TsWt2DMX6SdlBY4i7M7bAJV1+KvzaRgwWLr+EaYrDucZ+cU5BzgOUBCYQepImMwk NPofSF8Sfb/VA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AD79369597; Tue, 20 Jan 2026 16:20:27 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:53 -0700 Message-ID: <20260120231814.2033069-27-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: BBG5U2U3PAKTYB7UWSSZUZI5UYOLLDKC X-Message-ID-Hash: BBG5U2U3PAKTYB7UWSSZUZI5UYOLLDKC 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 26/36] video: Pass context to console_set_font() 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 console_set_font() to take a context parameter so it can set font properties for a specific context. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index ff5d9f5964a..483639e65c4 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -18,14 +18,16 @@ * console_set_font() - prepare vidconsole for chosen font. * * @dev vidconsole device + * @ctx vidconsole context * @fontdata pointer to font data struct */ -static int console_set_font(struct udevice *dev, struct video_fontdata *fontdata) +static int console_set_font(struct udevice *dev, struct vidconsole_ctx *ctx, + struct video_fontdata *fontdata) { struct console_simple_priv *priv = dev_get_priv(dev); priv->fontdata = fontdata; - vidconsole_set_bitmap_font(dev, vidconsole_ctx(dev), fontdata); + vidconsole_set_bitmap_font(dev, ctx, fontdata); return 0; } @@ -304,7 +306,7 @@ int console_probe(struct udevice *dev) { int ret; - ret = console_set_font(dev, fonts); + ret = console_set_font(dev, vidconsole_ctx(dev), fonts); if (ret) return ret; @@ -373,13 +375,13 @@ int console_simple_select_font(struct udevice *dev, void *ctx, const char *name, if (!name) { if (fonts->name) - console_set_font(dev, fonts); + console_set_font(dev, ctx, fonts); return 0; } for (font = fonts; font->name; font++) { if (!strcmp(name, font->name)) { - console_set_font(dev, font); + console_set_font(dev, ctx, font); return 0; } }; 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); From patchwork Tue Jan 20 23:17:55 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1701 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=1768951243; bh=kcllm0gHdWIU5L1qCl/84WYKYfmw65nVBzLBUUm0ZJA=; 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=YrtBJAdGmSwd0zKV7CsKEytpvx1iI2ToEWqpUlVxx9javmec7JYhZqgU4EJ4Xglsb vAP19lw00ljrZecgW0KqmonXbcuPIW3xSbldwSmhEfVVt+8n4K6pafEDrESHgwUt9t wu4UgIWoylzQivgYYZGbeCloqEimXFYETc9P20ihfskPfv0DcTcWP7Ml74HXNxlTLD VyVdG321MO/727kG6+1GhQi7Xk9jP1//KeMbqBHWInc9Y5Rd8WYjSns3hEZtrAxkaV MtP4qVbJg1KciAvR4jF7t6icjnAxYWAydX9iGO3J8s8TJFNoymY30yS5uMX5YUhAgR jvDew+bAp7AJw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B6F0B6959F for ; Tue, 20 Jan 2026 16:20:43 -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 Mv0Ulg4dN_fu for ; Tue, 20 Jan 2026 16:20:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951243; bh=kcllm0gHdWIU5L1qCl/84WYKYfmw65nVBzLBUUm0ZJA=; 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=YrtBJAdGmSwd0zKV7CsKEytpvx1iI2ToEWqpUlVxx9javmec7JYhZqgU4EJ4Xglsb vAP19lw00ljrZecgW0KqmonXbcuPIW3xSbldwSmhEfVVt+8n4K6pafEDrESHgwUt9t wu4UgIWoylzQivgYYZGbeCloqEimXFYETc9P20ihfskPfv0DcTcWP7Ml74HXNxlTLD VyVdG321MO/727kG6+1GhQi7Xk9jP1//KeMbqBHWInc9Y5Rd8WYjSns3hEZtrAxkaV MtP4qVbJg1KciAvR4jF7t6icjnAxYWAydX9iGO3J8s8TJFNoymY30yS5uMX5YUhAgR jvDew+bAp7AJw== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A70946959D for ; Tue, 20 Jan 2026 16:20:43 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951241; bh=MHHHIZHbNS1afvChQ0wc1Z5NiHqC6KjuKTbHjv9BhV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jhHnrn1oapNoZrbFTn79fzkzYP/oru2o9PvCcX6Ljt8fHTIrCmZN0LdlVybPcXJ+r LGfewa3wyIm7Sumb29P/OeNC+GgJjvnr+I9FoLgBUxQpaABRE/VGGemjA1wKq/eCxT aHdNuxgggPobr7OgsMfZbMsXODHJ76TkWVzWuq0q2ZsTz71Mo6nCNXjWEKuV+7Qx9j /4RaLHla+EHae9sHW49xQT910Uu9vP7nTcZpCcz6m5fxy1OXOSmRyp2V2kqZjIuS6d UN7K7u19uSMvlk+Sm1IihDXh8QlkkH8DUnr27n76Lf68eKmNWhy5DO1wSD8w9Ym7hY /1S4k3vICWFvw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AEA166913F; Tue, 20 Jan 2026 16:20:41 -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 hV4i_Yw7wuCr; Tue, 20 Jan 2026 16:20:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951237; bh=3i0pc+GTkSRCw66zEuBQksnbiK3lZVal/nt9QpPk4BE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A9n16om7EFFE2PYIA+iXijzTaG1g+z+3g0i+BjX4zQPKK9cAkz0mcUDWRiD93rnJ9 xumeMQFSQ+5NQ9i9nBDPS932EdaYzynvabwYGG0Jk9Kvkl617AJnq/i28MsdbOLWzR qptvQS6C5ruk4nfdqClyKwlmOYkrogIY5tpxOdRpGKxuI6OeLInEt3Oddqd5LwImXh kFLFMGladefV5AGZuRrIGFT50mJErwb4GJzQBIICEHzGfOpACsM71C+EBOhRibnyBA mY3xNNgCYzBg8fVcjYYYPHSf1YatN3dgoEl+xLgEapXq3QDzFbp6CBifpDAx6LFqyn eOCCl8a6P8d0Q== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 36B5969597; Tue, 20 Jan 2026 16:20:37 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:55 -0700 Message-ID: <20260120231814.2033069-29-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: L2UQ63QYR2JBYVG7Y2RD2BEUDAR25YA7 X-Message-ID-Hash: L2UQ63QYR2JBYVG7Y2RD2BEUDAR25YA7 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 28/36] expo: Pass context to draw_string() 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 draw_string() to allow passing in a specific vidconsole context. If NULL, the default context is used. Update all callers accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 58be46cb7ee..6c70bd9038c 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -616,16 +616,25 @@ static void scene_render_background(struct scene_obj *obj, bool box_only, } } -static void draw_string(struct udevice *cons, const char *str, int len, - bool password) +/** + * draw_string() - Draw a string to the vidconsole + * + * @cons: Vidconsole device to draw to + * @ctx: Vidconsole context, or NULL to use default + * @str: String to draw + * @len: Length of string to draw + * @password: true to draw asterisks instead of actual characters + */ +static void draw_string(struct udevice *cons, void *ctx, const char *str, + int len, bool password) { if (password) { int i; for (i = 0; i < len; i++) - vidconsole_put_char(cons, NULL, '*'); + vidconsole_put_char(cons, ctx, '*'); } else { - vidconsole_put_stringn(cons, NULL, str, len); + vidconsole_put_stringn(cons, ctx, str, len); } } @@ -686,7 +695,7 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, if (!mline) { vidconsole_set_cursor_pos(cons, NULL, x, y); - draw_string(cons, str, strlen(str), + draw_string(cons, NULL, str, strlen(str), obj->flags & SCENEOF_PASSWORD); } @@ -705,7 +714,7 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, if (y > bbox.y1) break; /* clip this line and any following */ vidconsole_set_cursor_pos(cons, NULL, x, y); - draw_string(cons, str + mline->start, mline->len, + draw_string(cons, NULL, str + mline->start, mline->len, obj->flags & SCENEOF_PASSWORD); } if (obj->flags & SCENEOF_POINT) From patchwork Tue Jan 20 23:17:56 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1702 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=1768951249; bh=Dn+bquUkHOZuJO7OnCgn46sRMHqjlZxqFOKe3kgfUlE=; 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=hQxokMsQzKVtDsLezCuR1TknutJhvXtz/qwKLaAfiXgaG4eQYGqrExmWI52WuC0dk 2OzwG4TzXlPgKqO/W3FQl3gOQ8l1/18I6UpZriUyWLTPPiSlvhvhnJf2N19+m/rUI8 ef2dpKkl6JJ/lH67DaULP0u8b6C+7GiYTgRBk+ZTfIU7VqlgoAMF+KnjeYoefPHySf Ab9L1AG0VZxGZfVrNFHpGr+s9Hq+BoV8A3Egu6dUn1cdfRa3/WsBOiIB4zl1l6ecKc Zq4BjGEEIg5n6BqTEJYn3+HHHOG/krEsxEi6lfGbhG/fDRulo6tFvuTAZBUXsgnrx8 oaP1JBvyQzNYg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 27A726959F for ; Tue, 20 Jan 2026 16:20:49 -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 SACvWyyrN24m for ; Tue, 20 Jan 2026 16:20:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951249; bh=Dn+bquUkHOZuJO7OnCgn46sRMHqjlZxqFOKe3kgfUlE=; 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=hQxokMsQzKVtDsLezCuR1TknutJhvXtz/qwKLaAfiXgaG4eQYGqrExmWI52WuC0dk 2OzwG4TzXlPgKqO/W3FQl3gOQ8l1/18I6UpZriUyWLTPPiSlvhvhnJf2N19+m/rUI8 ef2dpKkl6JJ/lH67DaULP0u8b6C+7GiYTgRBk+ZTfIU7VqlgoAMF+KnjeYoefPHySf Ab9L1AG0VZxGZfVrNFHpGr+s9Hq+BoV8A3Egu6dUn1cdfRa3/WsBOiIB4zl1l6ecKc Zq4BjGEEIg5n6BqTEJYn3+HHHOG/krEsxEi6lfGbhG/fDRulo6tFvuTAZBUXsgnrx8 oaP1JBvyQzNYg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 15D9C6959D for ; Tue, 20 Jan 2026 16:20:49 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951246; bh=dYAz81otcuT2uQEMXYyF5gBodduTkPj/VSi156YO0Yc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DU7h68cXgA9fHeeYF66CtobGx3aedbUiOnG1HiU9O6XgB7lePyXGvbvpx68LX5VCD PWkprhVcnOkb30/NEqUVQ5N3N9uWqY+FsxDw3jYnLAbB1I2RpLng0mdvpsKSw4NHCx aLybflDyv5X9eJCzd7L9j7q54lUrJE0NiMUEDg4umvSnJm44ieqZ6uI3S/pWkXfeX6 XY9lJrFhBKBxX/aR5GR814TfL9ZlQv9iWG7xb0T/mTGtnfffUqIaBy+0C9Yxa8IQOp X2sF4nua4pGZbGtUdOi9NpxUAQxw2Utjj6auNeWCdqPLqREcw7zjP0FCoW+2hmshxJ Y1sBc7o6foHNA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 45BD36913F; Tue, 20 Jan 2026 16:20: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 tGW8dwgZrhN6; Tue, 20 Jan 2026 16:20:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951242; bh=U/oHIbhIUeThaxL6NUYDqwpupirQlr1jHC41R2iQ4qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QkkK5PYS6e2Nq1h1TNoekQBwnRKr6DRGVWP7rLtUv7bib866It/Nx+2j72o5axmZE jXQB0FM4oShOoYD1D1ZjndCcc65i/vlklMPdD4uKEQQzyASzByyljEr0/2xR82MyKU HeQge9LzHSFphsv28hr+Z6NTVcxUheSoMI5vCim8aGY4FzvI7/rYMLCSNxlR7kbpMb PDLmtrJ11xDr2T3EbGsH2J/pJ7GlaRaC8iGVyK0Q93Epq0lYOA2+XTcKIE7cZHmuaJ XyldiI0ixw3bbZr2iuoqb4W/Kxol4zHLYOErpLrJu5/S217kyekJxXTOByJMpssGi/ jYcdSJkDJ/3sw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EE4B369597; Tue, 20 Jan 2026 16:20:41 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:56 -0700 Message-ID: <20260120231814.2033069-30-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: HBJ7NCN7D4XQ2MYYKOPYWQHU3T2J34CM X-Message-ID-Hash: HBJ7NCN7D4XQ2MYYKOPYWQHU3T2J34CM 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 29/36] expo: Pass context to scene_txt_render() 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 scene_txt_render() to allow passing in a specific vidconsole context. If NULL, the default context is used. Update the caller accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 6c70bd9038c..b6879315563 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -638,8 +638,23 @@ static void draw_string(struct udevice *cons, void *ctx, const char *str, } } +/** + * scene_txt_render() - Render text to the vidconsole + * + * @exp: Expo to use + * @dev: Video device + * @cons: Vidconsole device + * @ctx: Vidconsole context, or NULL to use default + * @obj: Object to render + * @gen: Generic text info + * @x: X position in pixels + * @y: Y position in pixels + * @menu_inset: Inset for menu items + * Return: 0 if OK, -ve on error + */ static int scene_txt_render(struct expo *exp, struct udevice *dev, - struct udevice *cons, struct scene_obj *obj, + struct udevice *cons, void *ctx, + struct scene_obj *obj, struct scene_txt_generic *gen, int x, int y, int menu_inset) { @@ -656,10 +671,10 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, return -ENOTSUPP; if (gen->font_name || gen->font_size) { - ret = vidconsole_select_font(cons, NULL, gen->font_name, + ret = vidconsole_select_font(cons, ctx, gen->font_name, gen->font_size); } else { - ret = vidconsole_select_font(cons, NULL, NULL, 0); + ret = vidconsole_select_font(cons, ctx, NULL, 0); } if (ret && ret != -ENOSYS) return log_msg_ret("font", ret); @@ -694,8 +709,8 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, bbox.y1 = obj->bbox.y1; if (!mline) { - vidconsole_set_cursor_pos(cons, NULL, x, y); - draw_string(cons, NULL, str, strlen(str), + vidconsole_set_cursor_pos(cons, ctx, x, y); + draw_string(cons, ctx, str, strlen(str), obj->flags & SCENEOF_PASSWORD); } @@ -713,8 +728,8 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, y = obj->bbox.y0 + offset.yofs + mline->bbox.y0; if (y > bbox.y1) break; /* clip this line and any following */ - vidconsole_set_cursor_pos(cons, NULL, x, y); - draw_string(cons, NULL, str + mline->start, mline->len, + vidconsole_set_cursor_pos(cons, ctx, x, y); + draw_string(cons, ctx, str + mline->start, mline->len, obj->flags & SCENEOF_PASSWORD); } if (obj->flags & SCENEOF_POINT) @@ -761,8 +776,8 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) case SCENEOBJT_TEXT: { struct scene_obj_txt *txt = (struct scene_obj_txt *)obj; - ret = scene_txt_render(exp, dev, cons, obj, &txt->gen, x, y, - theme->menu_inset); + ret = scene_txt_render(exp, dev, cons, NULL, obj, &txt->gen, + x, y, theme->menu_inset); break; } case SCENEOBJT_MENU: { From patchwork Tue Jan 20 23:17:57 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1703 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=1768951254; bh=NUCqh3w34hI3p4hMxi1+aOYSsdZJU9DWRbeL43bGW6M=; 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=IYPiXE20GYsIiogGIlNPRiEKgLEnCsCslGjyoeFPGPyFfb9Wyr5fEunnO4i47kxDE +mlYz3YAZTc8wIs4uWQNDNZhgaCwmDxcUxi5ikubxMKis4XKuUhPUB+BQX+hFbg6ZI RW+abXC4TN6vGnyLCdFSjCR6jzCWmv6fMo92b9/a5r8LRMSjDxrFKKhFCob/dEk+nM 9g3oaVhCk3ak4pCE0mbETwlwQTf1JQeQfDK1Pi9kWtQFju01W09tVzLFOxM9dym9Q+ G8ISmLQv1dDF/HYgxB+zBqkxFGTwWSHEJIDYnKwb4eOzg7b2GsMRMDEUt9XEQPD1i0 a90eKteg2svHA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1273969463 for ; Tue, 20 Jan 2026 16:20:54 -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 GosD3ttQnkh3 for ; Tue, 20 Jan 2026 16:20:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951253; bh=NUCqh3w34hI3p4hMxi1+aOYSsdZJU9DWRbeL43bGW6M=; 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=KmhOpePi6RbpQNhHwE5AxxFeaC5kJPE8YdkE+tFbHzi0MBGP2dc/dt/25G0zeM/CG IODDkCWT8px7UCc5sZ3bod8G0iw+Ty2kOSZU8RdrWdXdVGkK/GjhYAibwod01SG8/l rZ9PLZyw/4Ab4h6L8zTFi0nhQ3vNbl5FbQISrogULygUwOVIuJ4veNlKK0U0fqQ46N gG0s6os/j+OdCgKWBGUyiaa3RmiUaTiw5iXYb+OZFeL4FS4FtaPJ2Lrew6FQiUcZ1Y eMk5549+jHuBdw24Ur1v34LJJJfhDLb1I9/3kEvn0OZ13TnPcSeZO9FIT/spiB9dMp S5eU21+hSncGA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECFB469597 for ; Tue, 20 Jan 2026 16:20:53 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951251; bh=sU3+NopE5wbEhbGGFgWtDaEB5z4u8ihYFh4/oivMdzU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MBWliP5S0Dc+KGzIOfBXdO5FE5zQV8w41qd0ZxvxoJwPMy8t3xBLfzhEruUB4u1wp UVXle4T3AcB1l/qNIdldb3oCw6s+MOGqZlzmtTJdbIHWEuQKWPfnCpaXoFcYlFU9G1 N4SLgtliaP1yX6uyMpYpRdX7Qqj7X1jUZFa4N1MsEwcoUlRni+WYrFHUWD2NxCcMH5 vhYS3fdkaB2SVvKLoJYPu/LFLfpK4HoeqPyvUKbVVoCQS5Qvk8A5ydAkEtGg/DroD+ FXwXcDrNA2tlEAXnjo3HuIFfv8oGvDY7WV6IXSnMieoXP5Q/4qO69CkU5QSEEl+1dc /uwEKg8uHu5bQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id CD94869463; Tue, 20 Jan 2026 16:20:51 -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 P1XzGW_CEGt0; Tue, 20 Jan 2026 16:20:51 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951247; bh=mBD3Z9xfG4zCxUuhpuTXjnA5B9gAHW/ePnE/pQNLing=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A4q2TWV24a45rhE1veGVHzTXnSZelOclUpvyrzpMtfxaT/V55b0gNjPuN5pymD33a Ra5s6O50bDxH8StUYVSE7Pyc653umUoXCqlUGvPzW1EyTYvzhkhpdDRUuP08yRULPw 7v7fAwO5GKdclCS1X4UJ58nsBNaMZDgeHVIp7NILnT9S+tquXWNldzkXooSmIlxpNn MhsPAfP9pii0jSBABZYC0Sm4tfIsqEWVlo2yv0Av4VJH5ljRkYFyAB11b/i8c25bHH 2Qf5jpC6hIwmnhha+9pGrqPKI46bYiIbzCfaYI2o3DwYAXLJS51KUVqvUSQW2Pg9jE pEomTwpIHRkoQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B82E469597; Tue, 20 Jan 2026 16:20:46 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:57 -0700 Message-ID: <20260120231814.2033069-31-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: SK3VFNOREDIFATIT4TJRY4KMEG47O5BM X-Message-ID-Hash: SK3VFNOREDIFATIT4TJRY4KMEG47O5BM 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 30/36] expo: Pass context to scene_obj_render() 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 scene_obj_render() to allow passing in a specific vidconsole context. If NULL, the default context is used. Update all callers accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index b6879315563..45550326d07 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -742,10 +742,11 @@ static int scene_txt_render(struct expo *exp, struct udevice *dev, * scene_obj_render() - Render an object * * @obj: Object to render + * @ctx: Vidconsole context, or NULL to use default * @text_mode: true to use text mode * Return: 0 if OK, -ve on error */ -static int scene_obj_render(struct scene_obj *obj, bool text_mode) +static int scene_obj_render(struct scene_obj *obj, void *ctx, bool text_mode) { struct scene *scn = obj->scene; struct expo *exp = scn->expo; @@ -776,7 +777,7 @@ static int scene_obj_render(struct scene_obj *obj, bool text_mode) case SCENEOBJT_TEXT: { struct scene_obj_txt *txt = (struct scene_obj_txt *)obj; - ret = scene_txt_render(exp, dev, cons, NULL, obj, &txt->gen, + ret = scene_txt_render(exp, dev, cons, ctx, obj, &txt->gen, x, y, theme->menu_inset); break; } @@ -978,7 +979,7 @@ int scene_render_obj(struct scene *scn, uint id) return log_msg_ret("obj", -ENOENT); if (!(obj->flags & SCENEOF_HIDE)) { - ret = scene_obj_render(obj, false); + ret = scene_obj_render(obj, NULL, false); if (ret && ret != -ENOTSUPP) return log_msg_ret("ren", ret); } @@ -998,7 +999,7 @@ int scene_render_deps(struct scene *scn, uint id) return log_msg_ret("obj", -ENOENT); if (!(obj->flags & SCENEOF_HIDE)) { - ret = scene_obj_render(obj, false); + ret = scene_obj_render(obj, NULL, false); if (ret && ret != -ENOTSUPP) return log_msg_ret("ren", ret); @@ -1094,7 +1095,7 @@ int scene_render(struct scene *scn, bool dirty_only) render = bbox_intersects(&obj->bbox, &dirty_bbox); if (render) { - ret = scene_obj_render(obj, exp->text_mode); + ret = scene_obj_render(obj, NULL, exp->text_mode); if (ret && ret != -ENOTSUPP) return log_msg_ret("ren", ret); } From patchwork Tue Jan 20 23:17:58 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1704 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=1768951259; bh=Ms/3xzN8PISHow7+CVA5ovzzCPU05+P7uJzQET0zCOg=; 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=k6WsAbI6XN+lviC914g6bNyeEUYCXgdiqqeDT8drE95UKlDmIL/t41HPazLVKYyKM 0Fxk1zQ7sRa4KN9h8XyhpNb4IXFnrzZapryJs7tvxxqsM0wpVZ4UJ/WryQEWXY6mCI zD0+1ET3qk72yIzPQKLfLPj1EASPASuEdv5ByZQkkXK74tBDlM86XIV37pFMsNE05M E3tY/fnR//DPxp4vktzY0LNiHoH+170wCeX0q7DfqszG/KzSYM5g6YivIqQTI5JFdG MmpnQENKpuKeF+aCMrDy3A2ENQOOdvI7Fn/OAq4gElucFDUdvv1iXcxiST7C4VNGs1 7Y59Jx8qWIn/A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 92F52695A0 for ; Tue, 20 Jan 2026 16:20:59 -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 m5a_jRCU9fnA for ; Tue, 20 Jan 2026 16:20:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951259; bh=Ms/3xzN8PISHow7+CVA5ovzzCPU05+P7uJzQET0zCOg=; 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=k6WsAbI6XN+lviC914g6bNyeEUYCXgdiqqeDT8drE95UKlDmIL/t41HPazLVKYyKM 0Fxk1zQ7sRa4KN9h8XyhpNb4IXFnrzZapryJs7tvxxqsM0wpVZ4UJ/WryQEWXY6mCI zD0+1ET3qk72yIzPQKLfLPj1EASPASuEdv5ByZQkkXK74tBDlM86XIV37pFMsNE05M E3tY/fnR//DPxp4vktzY0LNiHoH+170wCeX0q7DfqszG/KzSYM5g6YivIqQTI5JFdG MmpnQENKpuKeF+aCMrDy3A2ENQOOdvI7Fn/OAq4gElucFDUdvv1iXcxiST7C4VNGs1 7Y59Jx8qWIn/A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 82A016959D for ; Tue, 20 Jan 2026 16:20:59 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951256; bh=yhug/X0/PY4gZqct3RAxtoQsyUkqwRTj14PgNX7DPbI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q/r1N8E9ZFiok7ZA3JwTY39r+X9Ryz5U8Bd72/TbkDI40NA0jQ1TK7YQk9yDtwNxg tusrlTgemL4UDOgPBabx+DHTpn5gq8HoQYfoOTMwEN8oTY9AE63MePqbk9SqfVK63o CayB0Xt63b7TbHaiLPsl+fH0TFxpvHb424u0RxtYbK5Xurk0nIwlney8aIGc/fDoU/ 3IdUUWG6kjMsQAg/EkEankB164qN0j8jjr3Xpusis3MghBZEVNCEYBeN7Yw9VMxYI+ 3QAVZOz+jDT7f3/qipe0xy2OFHVuhJsXecqh8x4qWtnXvBYRckdLolmLG9B8GH8pRs y7RAbh4sbBpcQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 825A869597; Tue, 20 Jan 2026 16:20:56 -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 77JsgAgPFBpJ; Tue, 20 Jan 2026 16:20:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951251; bh=E4Gpt8BpQI+821kfm/K8i3U9aaoIzgkf1j4Ew2pVTZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IFFXIAr/b/PCpYXHftXqVHEHsVgvNode+ndahaSVDUcvR6UW4ZEkFw09ctLzX3wfn z3d22eQNnp2xj71xlUDJQqmPF+FB6VGrZMWKWKcjLZKYYVl9mB7is9T90AHb2jBznx Y/H7RVPJ4LavO5+NOrrstQG8ZbEFELMvYaeH+lFJ3onYln49iT5mNI1PdKe40BlVTV roXcLz9Ja2PrkE7ouQaQwsA5LdFnME3l1KpM2gq+Lzh+l2IwaAjGnvE45sWdPgUTSq KCj2dWtzwl+zeK3NJ4PiPaiBmLBE8M0s9CXJ3fETs9mgz9y3pObAyF86LDR5zGPGYE Z9DGK5fLbiXaA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 84C6A6959F; Tue, 20 Jan 2026 16:20:51 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:58 -0700 Message-ID: <20260120231814.2033069-32-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: C6N2TTZCEJ44HYQN2ZVZ4NLYRSNVEYIP X-Message-ID-Hash: C6N2TTZCEJ44HYQN2ZVZ4NLYRSNVEYIP 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 31/36] expo: Pass context to scene_render_obj() 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 scene_render_obj() to allow passing in a specific vidconsole context. If NULL, the default context is used. Update the caller accordingly. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 4 ++-- boot/scene_internal.h | 3 ++- boot/scene_txtin.c | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 45550326d07..7cef20dbb1b 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -969,7 +969,7 @@ int scene_arrange(struct scene *scn) return 0; } -int scene_render_obj(struct scene *scn, uint id) +int scene_render_obj(struct scene *scn, uint id, void *ctx) { struct scene_obj *obj; int ret; @@ -979,7 +979,7 @@ int scene_render_obj(struct scene *scn, uint id) return log_msg_ret("obj", -ENOENT); if (!(obj->flags & SCENEOF_HIDE)) { - ret = scene_obj_render(obj, NULL, false); + ret = scene_obj_render(obj, ctx, false); if (ret && ret != -ENOTSUPP) return log_msg_ret("ren", ret); } diff --git a/boot/scene_internal.h b/boot/scene_internal.h index 733f0c0f6ca..d9ca1fef90e 100644 --- a/boot/scene_internal.h +++ b/boot/scene_internal.h @@ -348,9 +348,10 @@ int scene_send_click(struct scene *scn, int x, int y, struct expo_action *event) * * @scn: Scene containing the object * @id: Object ID to render + * @ctx: Vidconsole context, or NULL to use default * Returns: 0 if OK, -ENOENT if object not found, -ve on other error */ -int scene_render_obj(struct scene *scn, uint id); +int scene_render_obj(struct scene *scn, uint id, void *ctx); /** * scene_render_deps() - Render an object and its dependencies diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index da42f364f39..9b8edcc6439 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -75,7 +75,7 @@ int scene_txtin_render_deps(struct scene *scn, struct scene_obj *obj, ret = vidconsole_entry_restore(cons, &scn->entry_save); if (ret) return log_msg_ret("sav", ret); - scene_render_obj(scn, tin->edit_id); + scene_render_obj(scn, tin->edit_id, NULL); /* move cursor back to the correct position */ for (i = cls->num; i < cls->eol_num; i++) From patchwork Tue Jan 20 23:17:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1705 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=1768951262; bh=gCCnqdZoMLZBB3QkjxZdo1B6e0rFNT1SOpXTyKHNiP0=; 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=CQD6ossdD5X0RBhscpJ/XroKu1b9BlRVadwmlngoyiQgGi/gq+uJOEz2kaM5jnigA le3q5+Pmeum6R4JwVLZCClLLRM2+WkQP8kfpALLZ/TVMyeNF0tOxmbGMVhZbMT1rh3 5H/cb8RDSYo4xf+T7Ke2JYe0ol2ghaICUQtI+K2ITRAcJBa6Va9Cyke0zLHgesl/Ca XRhphsgW471Nm19gPcaJm3MZTENOpozcWp/XKC7ujhVUmxWVGlhs90zvyJ5dk04LIm 9N+cH/hf9O5eFTohN18uRkeVnew6kQhGq1IFF4cgf8UuMC72W3HNxodtgCYrfeuKL/ UZN6TG8LvXgHg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 09F98695A0 for ; Tue, 20 Jan 2026 16:21:02 -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 MXihxgpV3iaB for ; Tue, 20 Jan 2026 16:21:01 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951260; bh=gCCnqdZoMLZBB3QkjxZdo1B6e0rFNT1SOpXTyKHNiP0=; 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=s8zdiAUEkJzE8yE3l8h4WamSYIKFtZx7Fs+ycGvXmJ0vTi5qU/79FEddT+/THsR6N ymvUH50MZHFRegre6mfRKc5GV2V60qSvEXTBEoYxhZ6FOU92icuoAuBLRN567RmIV/ WTTOXOWK1FiW79YJf+oWwFNwjMT/ScNwJSQTUsn+qJkoQzdoQ+I+M06Pmg9yBXjnkO kAtA4aO07zclBXogiirjI2IEOIl48Xo/xlIoxG2YwrBa31GvHwgD/Xe4mpQjoMPoEF 4AqLf3DVB9Ey9MVD1GRY8JSxUW28KfVBaNDCwEprib5UxuA+Y8hYyMHhVoaBg/RTjY lyc8ZEQglgoTg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0BB1269597 for ; Tue, 20 Jan 2026 16:21:00 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951256; bh=Ti/8VCe2AazINSlWmUq/B/imMhv8e1CCO2e90tnRmy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UIKmF9HzGI7vE2xHmFZdNiRMyjdMSep0e8DpgnaJQ9X+FcVTuQ04TnuY7EPdJWwl1 W3uwP85V7yOBg79U0HdLhgcv6evEX67sGCmGNbxSZh9OgFbupxvmu/fREz1p1YyUfT M9/AUvfXVbMk09czqregHF0pEr6wugQ4Pt7UyUEB0c8tjSQbCyI28yJQObxcZ9rqpf WedTM2dVqsW6kGTXB8C2IqYt/uZG9sm64V3bdcQ7Qg2q3jzeImU7K6aSj27PwgIL7+ 4H0ZYbF2SFuC9LlMmn34WIH8VszG0D6EJ7qJWsQQ1pTntTHnLFQ3q70CRm000sJpKO ClrY7ry44mHdA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DEAEE6959D; Tue, 20 Jan 2026 16:20:56 -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 4tRwHn2Ly67r; Tue, 20 Jan 2026 16:20:56 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951256; bh=1Alz1H6kEuGsMPK5c4YC4cGgchC8r0vTpGPST1mqRZY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uHYsANwSbb+s6sqgc2EDQH7Rvn8xnjIteWqWmRqyXY9J0XIBfBk40DmPcxu2qIHq/ ZVC9yvSeJZY+TBsx8RUsQEmZhm0duS2qxwlUe2zqYbIP7kqHeCf8bLvRshydvvHHlY WRbH/6qgpt9F/D/fwJxVZwDzL93XxokMk9uxdR5zpJlxHjwM4J6qL+CU0wppDnGFZk dt9nhzdYkGwejRdFzyCU4M2fP4MO2qOXiosgpF6daHrfjORYn95/Dy3MP7iVsi26H1 5ju3LnWfXHpU0FG6nRo0A5dwDjaafq4ctXZJcSVjzMrLEU47FZ0NRXUQ19qPFTEpa1 TxtC5pRqlyGGw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 4D3CE69463; Tue, 20 Jan 2026 16:20:56 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:17:59 -0700 Message-ID: <20260120231814.2033069-33-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: XY6RP2UDYDLZLHMRB4SWLNCUWH3SEATM X-Message-ID-Hash: XY6RP2UDYDLZLHMRB4SWLNCUWH3SEATM 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 32/36] video: Maintain a list of contexts in vidconsole 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 an alist to track all client-allocated contexts in the vidconsole. This ensures that contexts can be properly cleaned up when the device is removed. Update vidconsole_ctx_new() to add newly created contexts to the list and vidconsole_ctx_dispose() to remove them. Init the list in vidconsole_pre_probe() and dispose of any remaining contexts in vidconsole_pre_remove() Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/vidconsole-uclass.c | 65 ++++++++++++++++++++++++------- include/video_console.h | 2 + 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 83872b54b5d..4433920ecb6 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -712,32 +712,64 @@ int vidconsole_nominal(struct udevice *dev, const char *name, uint size, int vidconsole_ctx_new(struct udevice *dev, void **ctxp) { + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ops *ops = vidconsole_get_ops(dev); - void *ctx; + void **ptr; int ret; if (!ops->ctx_new) return -ENOSYS; - ret = ops->ctx_new(dev, &ctx); - if (ret) + /* reserve space first so ctx_new failure doesn't need cleanup */ + ptr = alist_add_placeholder(&priv->ctx_list); + if (!ptr) + return -ENOMEM; + + ret = ops->ctx_new(dev, ptr); + if (ret) { + priv->ctx_list.count--; return ret; - *ctxp = ctx; + } + *ctxp = *ptr; return 0; } -int vidconsole_ctx_dispose(struct udevice *dev, void *ctx) +/** + * vidconsole_free_ctx() - Free a context without removing it from the list + * + * This calls the driver's ctx_dispose method and frees the save_data, but + * does not remove the context from the alist. + * + * @dev: Vidconsole device + * @ctx: Context to free + */ +static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); - int ret; - if (!ops->ctx_dispose) - return -ENOSYS; + if (ops->ctx_dispose) + ops->ctx_dispose(dev, ctx); + free(ctx->curs.save_data); +} - ret = ops->ctx_dispose(dev, ctx); - if (ret) - return ret; +int vidconsole_ctx_dispose(struct udevice *dev, void *vctx) +{ + struct vidconsole_priv *priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *ctx = vctx; + void **ptr, **from; + + if (!ctx) + return 0; + + /* remove the context from the list */ + alist_for_each_filter(ptr, from, &priv->ctx_list) { + if (*ptr != ctx) + *from++ = *ptr; + } + alist_update_end(&priv->ctx_list, from); + + vidconsole_free_ctx(dev, ctx); return 0; } @@ -903,6 +935,9 @@ static int vidconsole_pre_probe(struct udevice *dev) ctx->xsize_frac = VID_TO_POS(vid_priv->xsize); + alist_init_struct(&priv->ctx_list, void *); + alist_add(&priv->ctx_list, ctx); + return 0; } @@ -934,10 +969,12 @@ static int vidconsole_post_probe(struct udevice *dev) static int vidconsole_pre_remove(struct udevice *dev) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = priv->ctx; + void **ptr; - free(ctx->curs.save_data); - free(ctx); + /* free all contexts in the list, including the default ctx */ + alist_for_each(ptr, &priv->ctx_list) + vidconsole_free_ctx(dev, *ptr); + alist_uninit(&priv->ctx_list); priv->ctx = NULL; return 0; diff --git a/include/video_console.h b/include/video_console.h index 6d635fd5971..8d2f0510534 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -166,11 +166,13 @@ struct vidconsole_uc_plat { * * @sdev: stdio device, acting as an output sink * @ctx: Per-client context (allocated by the uclass) + * @ctx_list: List of additional contexts allocated by clients * @quiet: Suppress all output from stdio */ struct vidconsole_priv { struct stdio_dev sdev; struct vidconsole_ctx *ctx; + struct alist ctx_list; bool quiet; }; From patchwork Tue Jan 20 23:18:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1706 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=1768951265; bh=kPP/HT3IWyyFacFZ7H9rlNDSY/RwOhE8Rlr41kKzg10=; 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=cAbX51XHbHccwQXRXVv1qjLN69oK1lS/L7nmGAOUiRFaklPREhduWcu4EY/4DNXqp d7pFLhQu4XEeGVQnw+tagIVpSVKDaGT84JfcMvhfPut4u6n/KgUSChnzX2RzGOzcFz fGwTqBoxC7oXdxnBWFRWlrsNo5TcK3Cbfq+VOeZu33ZRJ3tQG8FAnAjXl3Wr/nLuVU 3nPgWb037ctZsEbC/UOyA6AgcNL6jzKZBshZ2MdPC/+ouyCKrsbwkFeFjt8vckhT+n +qd0KbFS8UgcgcBCqF8QLJCDec9k3oMlvj9VQY4XtkRDUpoEcXj5UCKw03yBWs2rsx Vx7XBcN/9i4lQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 79DED69463 for ; Tue, 20 Jan 2026 16:21:05 -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 LMGj_3Kzf_bP for ; Tue, 20 Jan 2026 16:21:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951265; bh=kPP/HT3IWyyFacFZ7H9rlNDSY/RwOhE8Rlr41kKzg10=; 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=cAbX51XHbHccwQXRXVv1qjLN69oK1lS/L7nmGAOUiRFaklPREhduWcu4EY/4DNXqp d7pFLhQu4XEeGVQnw+tagIVpSVKDaGT84JfcMvhfPut4u6n/KgUSChnzX2RzGOzcFz fGwTqBoxC7oXdxnBWFRWlrsNo5TcK3Cbfq+VOeZu33ZRJ3tQG8FAnAjXl3Wr/nLuVU 3nPgWb037ctZsEbC/UOyA6AgcNL6jzKZBshZ2MdPC/+ouyCKrsbwkFeFjt8vckhT+n +qd0KbFS8UgcgcBCqF8QLJCDec9k3oMlvj9VQY4XtkRDUpoEcXj5UCKw03yBWs2rsx Vx7XBcN/9i4lQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 69A1469597 for ; Tue, 20 Jan 2026 16:21:05 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951264; bh=gOePhU8eU3HZUsUZejsbH4p1WPBJcWP+dxJoIT+g2wk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mlcFj+6FU0uH+J2K/+llsSTaPOUC3q1WyUp3FOvtwAjuXpPQya1Kx8XSRRa7yiHiF aTB91eJU9p4aebgVHQVisQOHFnFlIemMx2SGZnBjpORP84Xwy2kkuyP7KhBeAP19e3 WVXQ4SUfxkOoSEVGcorEh/YqdTOGzPPtWXc4JP1IZtUWKn7QiakbHT+XBdV02lKStX I/DUBZIbgLGebeTqZgTjXH4gC0nsb3Akc8lQfEMzYwxQUVixC2MhAN4wQDoplYN2UB RZPrYLijoxEfe46Y1AGnOpYw6T1cpuxjdXfv5MSYn4wouIAtZXSaKXldHJCUAOmKe/ IVzwFbvUaUBCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 587D56959D; Tue, 20 Jan 2026 16:21:04 -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 1PfZVRq1Isgz; Tue, 20 Jan 2026 16:21:04 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951257; bh=h0KPhNvn2yyHJ4jNiCnumo4g3lWd0rZ1JZ+gnfnQ+Xk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YlKJYDF6LsH8vm+GUyWbuX3f7fl/dT37IGOwzMFLw8Sg9LG5kj8UbJoGxf6dm61aT oSKFk/uZIXMGCWSRHKUsfFUIVOe3+r63+T9Og0sq+8EQ6aj6APRAufrXlDvsTT6N3J ug2vjjZ2J5knvCKbG2EXkwUQlrnsVWQashq4AJngC8milsjgoKEUzVHvbgJIrGcIss qkWJe2NfpSNXLOdqArmmci6gLrxLql7Zb2mUi+JJNYAE3s71j8SAm9R9zDNPiMhHYv BgRLaj1eMaUqBJocq+beW1q2XgKG1vlkReZtW/KODk2neEt7Xk+rjDFCntAyFvu+NJ 8PHVP3IVbhpnA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 626EF69463; Tue, 20 Jan 2026 16:20:57 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:00 -0700 Message-ID: <20260120231814.2033069-34-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: XPFAXX5LCZEOAJWCYCZUX5VYUXYO3TN5 X-Message-ID-Hash: XPFAXX5LCZEOAJWCYCZUX5VYUXYO3TN5 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 33/36] video: Allocate the cursor in the uclass 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 Both console_core.c and console_truetype.c call console_alloc_cursor() to set up the cursor-save buffer. This duplication can be avoided by moving the call into vidconsole_post_probe() where it benefits all drivers. Move cursor allocation into the uclass and remove the calls from the individual drivers. Also reorder vidconsole_free_ctx() to free the cursor save_data before calling ctx_dispose(), since the cursor is now owned by the uclass rather than the driver. Signed-off-by: Simon Glass --- drivers/video/console_core.c | 6 ------ drivers/video/console_truetype.c | 4 ---- drivers/video/vidconsole-uclass.c | 12 ++++++++++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index c26a35e435d..0580e2661de 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -310,12 +310,6 @@ int console_probe(struct udevice *dev) if (ret) return ret; - if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev, vidconsole_ctx(dev)); - if (ret) - return ret; - } - return 0; } diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index f797dbe16f9..ae7e7d0ec58 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1302,10 +1302,6 @@ static int console_truetype_probe(struct udevice *dev) debug("%s: ready\n", __func__); - ret = console_alloc_cursor(dev, &ctx->com); - if (ret) - return ret; - return 0; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 4433920ecb6..83cd1651205 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -13,9 +13,10 @@ #include #include #include +#include #include #include -#include +#include #include #include #include "vidconsole_internal.h" @@ -748,9 +749,9 @@ static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); + free(ctx->curs.save_data); if (ops->ctx_dispose) ops->ctx_dispose(dev, ctx); - free(ctx->curs.save_data); } int vidconsole_ctx_dispose(struct udevice *dev, void *vctx) @@ -947,6 +948,13 @@ static int vidconsole_post_probe(struct udevice *dev) struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct stdio_dev *sdev = &priv->sdev; + int ret; + + if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { + ret = console_alloc_cursor(dev, ctx); + if (ret) + return ret; + } if (!ctx->tab_width_frac) ctx->tab_width_frac = VID_TO_POS(ctx->x_charsize) * 8; From patchwork Tue Jan 20 23:18:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1707 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=1768951269; bh=18ye/pmBNOkXBeibRK8noNNShp3jy5I3jYgs1usaRTo=; 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=OpHuXM0OeMT1dXvFKMBbtdifEq++k1ejP2t1lz7uwiuBsiCzXwkDgfdEm8MyIgRgU WcE9kjWBQFIWUeJGSwTU7NPu2S0hnB/iIpWsw7fi4cgYQfStxbR6FbfXyrpkR+moVo g4wk8+Qi4xv+dRd17jUF7YFIurxjjSBMgLsJHJ1K2BdvA+qr8f8SW4fubDG/y+ZnCn bsn44QsmLgcVJ5/opcpMGaAAjkCpAP197O7uZ2rWikil8px2LtI0tJejRzDwdalx/B GCIWj6AmDfcusT2YwsuBPmQzjvixWDgJphZw/oGe2hy8iDPz2PeX+blendoxN23lbh kq7/tuTjx958A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 36E086959F for ; Tue, 20 Jan 2026 16:21:09 -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 12dOjLU6bvoe for ; Tue, 20 Jan 2026 16:21:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951269; bh=18ye/pmBNOkXBeibRK8noNNShp3jy5I3jYgs1usaRTo=; 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=OpHuXM0OeMT1dXvFKMBbtdifEq++k1ejP2t1lz7uwiuBsiCzXwkDgfdEm8MyIgRgU WcE9kjWBQFIWUeJGSwTU7NPu2S0hnB/iIpWsw7fi4cgYQfStxbR6FbfXyrpkR+moVo g4wk8+Qi4xv+dRd17jUF7YFIurxjjSBMgLsJHJ1K2BdvA+qr8f8SW4fubDG/y+ZnCn bsn44QsmLgcVJ5/opcpMGaAAjkCpAP197O7uZ2rWikil8px2LtI0tJejRzDwdalx/B GCIWj6AmDfcusT2YwsuBPmQzjvixWDgJphZw/oGe2hy8iDPz2PeX+blendoxN23lbh kq7/tuTjx958A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 26DFD6959D for ; Tue, 20 Jan 2026 16:21:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951268; bh=HFGMZUyMC66EqekrNDPcDw+7aN9sUSpKCbP7ZVTv23A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c9a5Bwq8HtxCdL7cCsn6UZy8QWlgapqlt5vwYarBaKTcLteUlKG3VBZmIedwVzCO9 PR9sXX2QbQdbTGN3hrzm7Th5gmoEmLwgQRfYJwnaZXmn0AYcLhjew/nbbWOEr8pbgv 7OmDq8lc18CC/36v7MOF0v4/AuSkER1TV8f25aGYqYJOaXgAZc/u9UwyYOhWvoSTXO LbbESlwRKaTlO0b+hQXQS5GGMQB0PLM5erjv8RtADvqCoUZuD789D+S7XUAoMiQob0 eA/EVtogFvRlVrX2Uxexsvh1EOp5wm8mf4vN/6rJ5iEDLSi0QqHKmmosQ+8mH/hycg 2W30yXl8y1r9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3040069597; Tue, 20 Jan 2026 16:21:08 -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 2OTAs3jXI0Tr; Tue, 20 Jan 2026 16:21:08 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951262; bh=iqpiEIjOlDx890TEiZmdfM6Fz80DgIXWBlvGB3DOW/4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bF0dOttLIDtCn+gHHJT8TiDPoW9ixVl9VLxm63DXKk/lP/SEs7jpK0bWIpkFLl6ej q07ZcDdZoxvyRcI//3IkacwNJ5pVfYMMOodoOvwIJmr5DQxF4/PlBkUTlYaJIZfq1z Cxchx8brzd7AdrWikre1ZfYl4/gicuyKXl+zAjkeMeI6d3INqFL3boJC4BJRhAB1ks lxum1iiBm/0dhrYjn9bCjcuxmTfIIHouENFhsRzC/Orm1+HUlzjOvOfrIFkol5DhM/ DzXb2ULcFQ80KyMuPsspISvYPOgIG2/smgKaCBQuzvH4KF9twTRTm4d8bMWRpScE+D ABhciOfICpL/A== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 2CE026959E; Tue, 20 Jan 2026 16:21:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:01 -0700 Message-ID: <20260120231814.2033069-35-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: H5GZWU3IV25GXLFEB6UHPL6XVA4QRXYR X-Message-ID-Hash: H5GZWU3IV25GXLFEB6UHPL6XVA4QRXYR 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 34/36] video: Pass a cursor pointer to console_alloc_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 Change console_alloc_cursor() to take a struct vidconsole_cursor pointer directly instead of the full context, since that is not needed. This allows the function to be used a cursor embedded in a larger struct. Add a matching console_free_cursor() function to free the cursor's save_data buffer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_core.c | 9 ++++++--- drivers/video/vidconsole-uclass.c | 4 ++-- drivers/video/vidconsole_internal.h | 13 +++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 0580e2661de..6bd7dc263e6 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -280,9 +280,8 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, return 0; } -int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) +int console_alloc_cursor(struct udevice *dev, struct vidconsole_cursor *curs) { - struct vidconsole_cursor *curs; struct video_priv *vid_priv; struct udevice *vid; int save_count; @@ -291,7 +290,6 @@ int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) return 0; vid = dev_get_parent(dev); vid_priv = dev_get_uclass_priv(vid); - curs = &ctx->curs; /* Allocate cursor save buffer for maximum possible cursor height */ save_count = vid_priv->ysize * VIDCONSOLE_CURSOR_WIDTH; @@ -302,6 +300,11 @@ int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx) return 0; } +void console_free_cursor(struct vidconsole_cursor *curs) +{ + free(curs->save_data); +} + int console_probe(struct udevice *dev) { int ret; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 83cd1651205..b22408dc2a4 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -749,7 +749,7 @@ static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); - free(ctx->curs.save_data); + console_free_cursor(&ctx->curs); if (ops->ctx_dispose) ops->ctx_dispose(dev, ctx); } @@ -951,7 +951,7 @@ static int vidconsole_post_probe(struct udevice *dev) int ret; if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev, ctx); + ret = console_alloc_cursor(dev, &ctx->curs); if (ret) return ret; } diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index 23d29fea081..b5ffdfad4da 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -152,10 +152,19 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv, * Allocates memory for saving pixels under the cursor * * @dev: vidconsole device - * @ctx: vidconsole context + * @curs: cursor to set up * Return: 0 if success, -ENOMEM if allocation fails */ -int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx); +int console_alloc_cursor(struct udevice *dev, struct vidconsole_cursor *curs); + +/** + * console_free_cursor() - Free cursor memory + * + * Free the memory used by a cursor + * + * @curs: cursor to set up + */ +void console_free_cursor(struct vidconsole_cursor *curs); /** * console probe function. From patchwork Tue Jan 20 23:18:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1708 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=1768951273; bh=aviROIrURAAoMJeShQNjlL9+2kQNikABuZ4YCw2i108=; 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=IHZmMTEmMqENanw5Dc6jUrpL1RsY19xFjzGqxiRf7H0oxrBbA+YleEYnjIuM1y9Ba t+Y13huE2r3uJ7bhwD2zpOAUzepqdT73OIZCUKrkw8tbSE+QYAbbTYEWVc/z5BUUhx XoNGGEb8Css7YJctfJlWQybNM/koKh77l952ZIsTCtwNSbcgzYuOfx+739TukbXOTe nxFm69N1S8bKQk1JZAmJL2AyDF9ijvmGdeU4XDGbiLQfiAW7mD5EGZcv6dDr+9SoYM R+zSthLYZZnj5drdKKAIgDAM6eySAsPmWIv0E1VPCE+YDa+cuuMYhDyl1i9QiWYmEw EacCtWfXE8U5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id A68816959F for ; Tue, 20 Jan 2026 16:21:13 -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 lhV6CF-gpypJ for ; Tue, 20 Jan 2026 16:21:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951273; bh=aviROIrURAAoMJeShQNjlL9+2kQNikABuZ4YCw2i108=; 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=IHZmMTEmMqENanw5Dc6jUrpL1RsY19xFjzGqxiRf7H0oxrBbA+YleEYnjIuM1y9Ba t+Y13huE2r3uJ7bhwD2zpOAUzepqdT73OIZCUKrkw8tbSE+QYAbbTYEWVc/z5BUUhx XoNGGEb8Css7YJctfJlWQybNM/koKh77l952ZIsTCtwNSbcgzYuOfx+739TukbXOTe nxFm69N1S8bKQk1JZAmJL2AyDF9ijvmGdeU4XDGbiLQfiAW7mD5EGZcv6dDr+9SoYM R+zSthLYZZnj5drdKKAIgDAM6eySAsPmWIv0E1VPCE+YDa+cuuMYhDyl1i9QiWYmEw EacCtWfXE8U5A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 967F76959E for ; Tue, 20 Jan 2026 16:21:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951271; bh=zEKdRAEQrEeTW8JPXNKeRkb/oV12pDr4cfiC8/nj+mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AuZ9Xn8pQ3Wy9roOigMs4ZRpudauQQl99+NmPTNx2/VcjNssdXDjq0NwYbhMQJOSR BO/bSu/PLP8r/Wzh2MuXw6wwp8OAp7LDqBrUyutWvsVpr8mgHJgztezssiU2v2NQm6 X6+a1HJ/S1LQu0arNEM6KWkIctJ0pdNqRVA3f8ae0+pQ+1b8dsuWi5rLFhANrTJdfV d+tfvKlep1NeWxHuj2gTPxQVudjHWxBm/PiVas+kyHIc79BXRLl8w27mGvGpJYq2eY FGvGWmhBuJ22K2zeNJjhB8P9VglpN7k3UxGIWiMARz4rQpKbGH0QSslgGOIifM2lMs woceY2+NE6sJg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9919369597; Tue, 20 Jan 2026 16:21:11 -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 D-CnoWDWdzJU; Tue, 20 Jan 2026 16:21:11 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951267; bh=UalgBh17F8RuFx2se3Pxyh99mjEAMZlClv4GH4yYlOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KKckPmuwVtF14fPQnN8c72Y2AMmbGKKzEKBLlA7FU2wnzVVhunNQpCJjIesxHxrEL DWVOLiNG11WGstDozNUv5/0Cny7N/bnKFY3exqxvlPdmUc5cwh13gan+AmsHiuN1JQ x9cR4EN4b88LmzLYYYWfNaumcxdWROHFTK+9l5oAkWl3SSlZPRmO6Gd07cj5vS9ujb ST1chtB4HhNIx8Jsy+mZ7LlglsMkeKjCKSB4ZUbtmVAQfIJctYaRGRy+WjRWRRfgtd OXcgbDS78GrlSj8ni1uoOdJblALVdq/3zQkJkHfhWeqc4cEF/ejzOJFfMOCZ3t0dZ0 vWfu51UD1o9gQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id ECCD869463; Tue, 20 Jan 2026 16:21:06 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:02 -0700 Message-ID: <20260120231814.2033069-36-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: LJYNKEGG75RK4BHDTUE3CQ2WGGFYN5BD X-Message-ID-Hash: LJYNKEGG75RK4BHDTUE3CQ2WGGFYN5BD 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 35/36] video: Move context freeing to uclass 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 responsibility for freeing context memory from the driver's ctx_dispose() method to the uclass's vidconsole_free_ctx(). This simplifies the drivers since they no longer need to implement ctx_dispose() just to call free(). The ctx_dispose() method is still called if present, but only needs to handle driver-specific cleanup. The uclass handles freeing the cursor and the context memory. Also remove the console_probe() reference from console_normal since the uclass handles all probe setup. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- drivers/video/console_normal.c | 9 --------- drivers/video/console_truetype.c | 8 -------- drivers/video/vidconsole-uclass.c | 3 ++- 3 files changed, 2 insertions(+), 18 deletions(-) diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index 5f57b3403f1..c3b7f848b43 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -191,13 +191,6 @@ static int console_simple_ctx_new(struct udevice *dev, void **ctxp) return 0; } -static int console_simple_ctx_dispose(struct udevice *dev, void *ctx) -{ - free(ctx); - - return 0; -} - struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, @@ -206,7 +199,6 @@ struct vidconsole_ops console_ops = { .get_font = console_simple_get_font, .select_font = console_simple_select_font, .ctx_new = console_simple_ctx_new, - .ctx_dispose = console_simple_ctx_dispose, #ifdef CONFIG_CURSOR .get_cursor_info = console_get_cursor_info, .entry_save = normal_entry_save, @@ -218,6 +210,5 @@ U_BOOT_DRIVER(vidconsole_normal) = { .name = "vidconsole0", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_ops, - .probe = console_probe, .priv_auto = sizeof(struct console_simple_priv), }; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index ae7e7d0ec58..4cf7ffebef3 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1157,13 +1157,6 @@ static int truetype_ctx_new(struct udevice *dev, void **ctxp) return 0; } -static int truetype_ctx_dispose(struct udevice *dev, void *ctx) -{ - free(ctx); - - return 0; -} - static int truetype_entry_save(struct udevice *dev, struct abuf *buf) { struct console_tt_ctx *ctx = vidconsole_ctx(dev); @@ -1327,7 +1320,6 @@ struct vidconsole_ops console_truetype_ops = { .measure = truetype_measure, .nominal = truetype_nominal, .ctx_new = truetype_ctx_new, - .ctx_dispose = truetype_ctx_dispose, .entry_save = truetype_entry_save, .entry_restore = truetype_entry_restore, .get_cursor_info = truetype_get_cursor_info, diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index b22408dc2a4..147063c4d38 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -749,9 +749,10 @@ static void vidconsole_free_ctx(struct udevice *dev, struct vidconsole_ctx *ctx) { struct vidconsole_ops *ops = vidconsole_get_ops(dev); - console_free_cursor(&ctx->curs); if (ops->ctx_dispose) ops->ctx_dispose(dev, ctx); + console_free_cursor(&ctx->curs); + free(ctx); } int vidconsole_ctx_dispose(struct udevice *dev, void *vctx) From patchwork Tue Jan 20 23:18:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1709 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=1768951277; bh=CnWaYaLBf4hjJwrUlsWy3flu2iCb7Z1NLVhxVsYqE2s=; 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=opqI81M4EMYmwIF5wPEv+q2gQ3EStX3ZVQT2fxDg+w8RmHuNupimzeuLRv11gPGkh Jp95sgM6qW2trHoyFfMZTBVMd3YQcFobUaAA1rQXrnK/9J64fPybnvyzXhdliLv8z9 pSwweuqAXKo6a4o6d0rEZ9wz1Z89GAWyYvOgVdhQJ3umUbHju9Umi3mpKNJ6LFHdjo GIUXRSvaFdeHjJeMpS3F2TO5ZquzFHjmFp0DyjVOxVpvz8s4FEKKOdtVCG/wQ18lxr n/+izTPFvRwzDii4KdZqd2MazuAhNzvgfXp/Me9sEDZuGz0tPxBmHO3JBZjnR3eU4t QadLv0UP4qgAg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1C03F6959E for ; Tue, 20 Jan 2026 16:21:17 -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 uPC3anKQ7f1s for ; Tue, 20 Jan 2026 16:21:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951277; bh=CnWaYaLBf4hjJwrUlsWy3flu2iCb7Z1NLVhxVsYqE2s=; 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=opqI81M4EMYmwIF5wPEv+q2gQ3EStX3ZVQT2fxDg+w8RmHuNupimzeuLRv11gPGkh Jp95sgM6qW2trHoyFfMZTBVMd3YQcFobUaAA1rQXrnK/9J64fPybnvyzXhdliLv8z9 pSwweuqAXKo6a4o6d0rEZ9wz1Z89GAWyYvOgVdhQJ3umUbHju9Umi3mpKNJ6LFHdjo GIUXRSvaFdeHjJeMpS3F2TO5ZquzFHjmFp0DyjVOxVpvz8s4FEKKOdtVCG/wQ18lxr n/+izTPFvRwzDii4KdZqd2MazuAhNzvgfXp/Me9sEDZuGz0tPxBmHO3JBZjnR3eU4t QadLv0UP4qgAg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0B4A069597 for ; Tue, 20 Jan 2026 16:21:17 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951276; bh=CL9xlqWVZpgUNRv9U4TLgBJc9IubwuHFIEV1CSkh4cA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tik/3D9sDsKCdbSaLE4Fl8boOTv3CuXLrVon/LILLmMqEvCGVF1ZfKtZFloHzyG9D /ZOzb1Udvd8Jvf1PDmC8FIf0jbF06N3Wslek1OFPJhGFKk8MpAXoK2Xo0/XvgV7kGQ aNPk7nng9p+MJfZJ1UrABHYxymj3eDLNcWjHmO+C/Fg+QYd3FRIasT/XMK4b9vfokb SvXiY5+OdwUe8yKJE/961hQ/u9+uQjDjDUiPI+cZ9/07hrtMc6PkCTN0McE6+ZaR40 LAkiElok6XusiX7BNS+mtYZW3jo5blbfKUT1OiMOUeuk17m3kxlDKxEgsOtI9rPyth dtoqukPVbTB2A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 0E55A69597; Tue, 20 Jan 2026 16:21: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 T0j3nANhTNH9; Tue, 20 Jan 2026 16:21:15 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768951271; bh=cLuktDKNulRnxBx1u+8F3j01uFc1CMw37NokYd1sm6M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UVaSDU+ZBJ/5klTq/z5VYHnHX5VkVDnkKhWScXbK9Ux/1TLZiJRMnjjvamoUCaTb3 gxsWjfvyja3GALh4weXkOdr9JPCg+utab4NDKOd/eyIVDgYni5YEoByZZorBOavoWm MF6mSfYO0gwmUB54ajb9Sapf25prc+U+PTi8U3l9q9qFnfRoA8p5IXIQPdAwQMlME2 sCYSil9+26JZ89bKIkxAWsXVvCBRl9aK9jHwEhZDa4Fu8VW+EtmBG3HJTJS6f/+CkA citbiaMg7zxGoG4UDfbBFm4zughfsaSAWuVZ0drg2uXHUfQTiFSBjvKqw+0XKB/rDc rCkJZ/+R+KyYA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id B9D1D69463; Tue, 20 Jan 2026 16:21:11 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Tue, 20 Jan 2026 16:18:03 -0700 Message-ID: <20260120231814.2033069-37-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: LGYLHJODYBP7WBVOBB2O5H54W7SLKPQE X-Message-ID-Hash: LGYLHJODYBP7WBVOBB2O5H54W7SLKPQE 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 X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 36/36] video: Move context allocation from drivers to uclass 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 Currently each driver allocates its own vidconsole context in its ctx_new() method. This leads to duplication and makes it harder to ensure consistent context setup. Move the responsibility for allocating contexts to the uclass. The ctx_new() ops method now receives an already-allocated context and just needs to initialise driver-specific fields. The uclass now handles: - Allocating memory using plat->ctx_size - Setting up xsize_frac from the video device - Allocating the cursor-save buffer if cursor support is enabled - Calling the driver's ctx_new() for driver-specific initialisation Move the default context creation from vidconsole_pre_probe() to vidconsole_post_probe() using vidconsole_ctx_new(). This allows additional contexts to be set up by calling the same function. For bitmap font drivers, rename console_probe() to console_simple_ctx_new() and move struct console_ctx to vidconsole_internal.h so it can be shared. For the truetype driver, move font selection from console_truetype_probe() to truetype_ctx_new(), using the first font initially. Also fix vidconsole_set_bitmap_font() to always set xsize_frac rather than relying on it being set in vidconsole_pre_probe(). This is a rather large 'flag day' change but it has resisted being broken up further. Signed-off-by: Simon Glass --- drivers/video/console_core.c | 5 ++- drivers/video/console_normal.c | 22 ---------- drivers/video/console_rotate.c | 6 +-- drivers/video/console_truetype.c | 17 +++----- drivers/video/vidconsole-uclass.c | 64 +++++++++++++++++------------ drivers/video/vidconsole_internal.h | 22 ++++++++++ include/video_console.h | 12 +++--- 7 files changed, 77 insertions(+), 71 deletions(-) diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c index 6bd7dc263e6..ee07ffc98e4 100644 --- a/drivers/video/console_core.c +++ b/drivers/video/console_core.c @@ -305,11 +305,12 @@ void console_free_cursor(struct vidconsole_cursor *curs) free(curs->save_data); } -int console_probe(struct udevice *dev) +int console_simple_ctx_new(struct udevice *dev, void *vctx) { + struct console_ctx *ctx = vctx; int ret; - ret = console_set_font(dev, vidconsole_ctx(dev), fonts); + ret = console_set_font(dev, &ctx->com, fonts); if (ret) return ret; diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index c3b7f848b43..d36a5c0ff8f 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -15,14 +15,6 @@ #include /* Get font data, width and height */ #include "vidconsole_internal.h" -/** - * struct console_ctx - context for the normal console - * - * @com: Common fields from the vidconsole uclass - */ -struct console_ctx { - struct vidconsole_ctx com; -}; static int console_set_row(struct udevice *dev, uint row, int clr) { @@ -177,20 +169,6 @@ static int console_putc_xy(struct udevice *dev, void *vctx, uint x_frac, return console_normal_putc_xy(dev, vctx, x_frac, y, cp); } -static int console_simple_ctx_new(struct udevice *dev, void **ctxp) -{ - struct console_ctx *ctx; - - ctx = malloc(sizeof(*ctx)); - if (!ctx) - return -ENOMEM; - - memset(ctx, '\0', sizeof(*ctx)); - *ctxp = ctx; - - return 0; -} - struct vidconsole_ops console_ops = { .putc_xy = console_putc_xy, .move_rows = console_move_rows, diff --git a/drivers/video/console_rotate.c b/drivers/video/console_rotate.c index 42c9de888d8..77c814fa09e 100644 --- a/drivers/video/console_rotate.c +++ b/drivers/video/console_rotate.c @@ -294,6 +294,7 @@ struct vidconsole_ops console_ops_1 = { .get_font_size = console_simple_get_font_size, .get_font = console_simple_get_font, .select_font = console_simple_select_font, + .ctx_new = console_simple_ctx_new, }; struct vidconsole_ops console_ops_2 = { @@ -303,6 +304,7 @@ struct vidconsole_ops console_ops_2 = { .get_font_size = console_simple_get_font_size, .get_font = console_simple_get_font, .select_font = console_simple_select_font, + .ctx_new = console_simple_ctx_new, }; struct vidconsole_ops console_ops_3 = { @@ -312,13 +314,13 @@ struct vidconsole_ops console_ops_3 = { .get_font_size = console_simple_get_font_size, .get_font = console_simple_get_font, .select_font = console_simple_select_font, + .ctx_new = console_simple_ctx_new, }; U_BOOT_DRIVER(vidconsole_1) = { .name = "vidconsole1", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_ops_1, - .probe = console_probe, .priv_auto = sizeof(struct console_simple_priv), }; @@ -326,7 +328,6 @@ U_BOOT_DRIVER(vidconsole_2) = { .name = "vidconsole2", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_ops_2, - .probe = console_probe, .priv_auto = sizeof(struct console_simple_priv), }; @@ -334,6 +335,5 @@ U_BOOT_DRIVER(vidconsole_3) = { .name = "vidconsole3", .id = UCLASS_VIDEO_CONSOLE, .ops = &console_ops_3, - .probe = console_probe, .priv_auto = sizeof(struct console_simple_priv), }; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 4cf7ffebef3..25cc8241bf7 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1143,16 +1143,15 @@ static int truetype_nominal(struct udevice *dev, const char *name, uint size, return 0; } -static int truetype_ctx_new(struct udevice *dev, void **ctxp) +static int truetype_ctx_new(struct udevice *dev, void *vctx) { - struct console_tt_ctx *ctx; + struct console_tt_priv *priv = dev_get_priv(dev); + struct console_tt_ctx *ctx = vctx; - ctx = malloc(sizeof(*ctx)); - if (!ctx) - return -ENOMEM; + /* use the first set of metrics by default */ + ctx->cur_met = &priv->metrics[0]; - memset(ctx, '\0', sizeof(*ctx)); - *ctxp = ctx; + select_metrics(dev, ctx, ctx->cur_met); return 0; } @@ -1256,7 +1255,6 @@ static int truetype_mark_start(struct udevice *dev, void *vctx) 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); @@ -1289,9 +1287,6 @@ 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); - ctx->cur_met = &priv->metrics[ret]; - - select_metrics(dev, ctx, &priv->metrics[ret]); debug("%s: ready\n", __func__); diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 147063c4d38..b6bd3133037 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -713,10 +713,14 @@ int vidconsole_nominal(struct udevice *dev, const char *name, uint size, int vidconsole_ctx_new(struct udevice *dev, void **ctxp) { + struct udevice *vid = dev->parent; + struct video_priv *vid_priv = dev_get_uclass_priv(vid); + struct vidconsole_uc_plat *plat = dev_get_uclass_plat(dev); struct vidconsole_priv *priv = dev_get_uclass_priv(dev); struct vidconsole_ops *ops = vidconsole_get_ops(dev); + struct vidconsole_ctx *ctx; + int ret = -ENOMEM, size; void **ptr; - int ret; if (!ops->ctx_new) return -ENOSYS; @@ -726,14 +730,35 @@ int vidconsole_ctx_new(struct udevice *dev, void **ctxp) if (!ptr) return -ENOMEM; - ret = ops->ctx_new(dev, ptr); - if (ret) { - priv->ctx_list.count--; - return ret; + size = plat->ctx_size ?: sizeof(struct vidconsole_ctx); + ctx = calloc(1, size); + if (!ctx) + goto err_alloc; + *ptr = ctx; + + if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { + ret = console_alloc_cursor(dev, &ctx->curs); + if (ret) + goto err_curs; } - *ctxp = *ptr; + + ctx->xsize_frac = VID_TO_POS(vid_priv->xsize); + + ret = ops->ctx_new(dev, ctx); + if (ret) + goto err_new; + *ctxp = ctx; return 0; + +err_new: + console_free_cursor(&ctx->curs); +err_curs: +err_alloc: + priv->ctx_list.count--; + free(ctx); + + return ret; } /** @@ -922,23 +947,9 @@ void vidconsole_pop_colour(struct udevice *dev, struct vidconsole_colour *old) /* Set up the number of rows and colours (rotated drivers override this) */ static int vidconsole_pre_probe(struct udevice *dev) { - struct vidconsole_uc_plat *plat = dev_get_uclass_plat(dev); struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct udevice *vid = dev->parent; - struct video_priv *vid_priv = dev_get_uclass_priv(vid); - struct vidconsole_ctx *ctx; - uint size; - - size = plat->ctx_size ?: sizeof(struct vidconsole_ctx); - ctx = calloc(1, size); - if (!ctx) - return -ENOMEM; - priv->ctx = ctx; - - ctx->xsize_frac = VID_TO_POS(vid_priv->xsize); alist_init_struct(&priv->ctx_list, void *); - alist_add(&priv->ctx_list, ctx); return 0; } @@ -947,15 +958,14 @@ static int vidconsole_pre_probe(struct udevice *dev) static int vidconsole_post_probe(struct udevice *dev) { struct vidconsole_priv *priv = dev_get_uclass_priv(dev); - struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv); struct stdio_dev *sdev = &priv->sdev; + struct vidconsole_ctx *ctx; int ret; - if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) { - ret = console_alloc_cursor(dev, &ctx->curs); - if (ret) - return ret; - } + ret = vidconsole_ctx_new(dev, (void **)&ctx); + if (ret) + return ret; + priv->ctx = ctx; if (!ctx->tab_width_frac) ctx->tab_width_frac = VID_TO_POS(ctx->x_charsize) * 8; @@ -1049,7 +1059,7 @@ void vidconsole_set_bitmap_font(struct udevice *dev, struct vidconsole_ctx *ctx, } else { ctx->cols = vid_priv->xsize / fontdata->width; ctx->rows = vid_priv->ysize / fontdata->height; - /* xsize_frac is set in vidconsole_pre_probe() */ + ctx->xsize_frac = VID_TO_POS(vid_priv->xsize); } ctx->xstart_frac = 0; } diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h index b5ffdfad4da..439192ecc1e 100644 --- a/drivers/video/vidconsole_internal.h +++ b/drivers/video/vidconsole_internal.h @@ -8,6 +8,7 @@ #include #include +#include struct udevice; struct vidconsole_cursor; @@ -25,6 +26,15 @@ struct console_simple_priv { struct video_fontdata *fontdata; }; +/** + * struct console_ctx - context for the normal console + * + * @com: Common fields from the vidconsole uclass + */ +struct console_ctx { + struct vidconsole_ctx com; +}; + /** * Checks if bits per pixel supported. * @@ -237,3 +247,15 @@ static inline u8 console_utf_to_cp437(int codepoint) } return codepoint; } + +/** + * console_simple_ctx_new() - Set up a new context for bitmap-font consoles + * + * Initialises the context with the default bitmap font. This is the ctx_new() + * method for bitmap-font console drivers. + * + * @dev: Vidconsole device + * @ctx: Context to initialise (allocated by the uclass) + * Return: 0 on success, -ve on error + */ +int console_simple_ctx_new(struct udevice *dev, void *ctx); diff --git a/include/video_console.h b/include/video_console.h index 8d2f0510534..c047d45cf53 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -384,16 +384,16 @@ struct vidconsole_ops { uint num_chars, struct vidconsole_bbox *bbox); /** - * ctx_new() - Create a new context for a client + * ctx_new() - Initialise a new context for a client * - * Allocates and initialises a context for a client of the vidconsole. - * The driver determines what information is stored in the context. + * Initialises driver-specific fields of a pre-allocated context. The + * base vidconsole_ctx fields are already initialised by the uclass. * * @dev: Console device to use - * @ctxp: Returns new context, on success - * Return: 0 on success, -ENOMEM if out of memory + * @ctx: Pre-allocated context to initialise + * Return: 0 on success, -ve on error */ - int (*ctx_new)(struct udevice *dev, void **ctxp); + int (*ctx_new)(struct udevice *dev, void *ctx); /** * ctx_dispose() - Dispose of a context