From patchwork Thu Jan 22 04:11: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: 1765 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=1769055154; bh=yU3a3MlPq7gazTJYLQMphCXYWAriegr+URxvLV882WE=; 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=J6QnOC47Yn3hfCkcj/gZxqIxJfYstEgTEq6UkrSwTE75NP4vZzx3ljyAXjRrGRuZx WMgBCJtZFCfmbdvLdjZktx1NvHIL9pqoSiMLrqORBWm5f/2LouPDR7uP8ld+CjjzQK cXURI65yfIiQFkBxRSC2kLqWzxKPyBaej04c04QCbWB2hYaN40VDDSMRzDtDP1gqwv 8TT2tj7sgKz0Od2ihmsnB6FglxsbRw90QYfWsfrH8uVJfLau+EkCzdDhFzZrgUPwOL P+DNLCxUXtw33f/MJV+5Wuf8HUoIiypwpAaWtol4QkW05YigpcOArKKVGCdIT3Qskh 5uTI3mqelGH0A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id ECAE66962C for ; Wed, 21 Jan 2026 21:12: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 2rOkn1MEQTGu for ; Wed, 21 Jan 2026 21:12:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055154; bh=yU3a3MlPq7gazTJYLQMphCXYWAriegr+URxvLV882WE=; 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=J6QnOC47Yn3hfCkcj/gZxqIxJfYstEgTEq6UkrSwTE75NP4vZzx3ljyAXjRrGRuZx WMgBCJtZFCfmbdvLdjZktx1NvHIL9pqoSiMLrqORBWm5f/2LouPDR7uP8ld+CjjzQK cXURI65yfIiQFkBxRSC2kLqWzxKPyBaej04c04QCbWB2hYaN40VDDSMRzDtDP1gqwv 8TT2tj7sgKz0Od2ihmsnB6FglxsbRw90QYfWsfrH8uVJfLau+EkCzdDhFzZrgUPwOL P+DNLCxUXtw33f/MJV+5Wuf8HUoIiypwpAaWtol4QkW05YigpcOArKKVGCdIT3Qskh 5uTI3mqelGH0A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id DA6E369627 for ; Wed, 21 Jan 2026 21:12:34 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055152; bh=JMCqpWLMsik3+i6znb73Z6sQrUt2fzfNLDMR8nBaj2U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uQ9KoSt2Q1fEFGQyuRAiDmvB0dbvTiTByGEf6eqJPAx1erzudX9jI2Mm0xsHJJM8u 4Ffbvxa1EjijQiq/pQYL99D706rhpMQYomsbKzHjuAML74l0dMueGy72qG8qKCTTEL oWeNXy7Ht9eQ7eMoB5zyYLKL14n2zpQ6B15jzLbGBPw8FC2JFSfEuYxHqPB/Uu4bLP zgTyghpSVUxvGYx0ERK0zxmGKjfQyc/R7C55URKNlygsv9/irwYFmQXEpwNuf8E1sh lUBQDTymSIQahE0+R6SMzew8awQ3J860liX+DWvanij81zJEumMFm7ckwgGGoffPxY 8vCGAfNQ0GiGQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E5FF4694CC; Wed, 21 Jan 2026 21:12: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 jmhmaHpDBw9Z; Wed, 21 Jan 2026 21:12:32 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1769055148; bh=rChJZPLeGddmB5Wkf3itQGSffOMMpRd74mdjh/VA0TY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=etDX4sBEq2OvXL5Q2n3O5/ACCMhybKQL64Ll4yGmG6EYLwlKDwSzvTs9E6N/x+Ie1 K1RdldzeGV3z9ziIPR/DITqrxGAaBcNDGrRREcGBMyJbbAa+kkuXEm1lKjIv1pfZp8 RfEgsiF/GuWH9WiNKNDYO05TJ8Ci/5Np7hEFu6RoYy81a2UoVkIl8xFkRcadu/QAaf IbTcDAoJe/o7MyA/XLknwVztYFU17E/Udrk/aI2dGHt7n+eqcqZX354VJPGV6RCffW Vh3LIrTJrH/vtX4+kSDnx/LJgiA2jz6A+/aP64f/u1ViDpMipHCFnGhWmgrlWWx7L1 oJ/DnUZobnyIg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 195AE69616; Wed, 21 Jan 2026 21:12:28 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 21 Jan 2026 21:11:34 -0700 Message-ID: <20260122041155.174721-7-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260122041155.174721-1-sjg@u-boot.org> References: <20260122041155.174721-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: PNQ5FSYWOZZUYXAS2TYCI2QTN7RCW7QN X-Message-ID-Hash: PNQ5FSYWOZZUYXAS2TYCI2QTN7RCW7QN 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/16] video: Remove vidconsole_entry_save/restore() 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 With per-object vidconsole contexts, entry save/restore is no longer needed. Each text-input object maintains its own context which persists across renders and key handling. Remove vidconsole_entry_save() and vidconsole_entry_restore() along with the entry_save and entry_restore ops from vidconsole drivers. Also remove the entry_save field from struct scene and the associated tests. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/scene.c | 2 - boot/scene_txtin.c | 17 +------- drivers/video/console_normal.c | 32 --------------- drivers/video/console_truetype.c | 34 +--------------- drivers/video/vidconsole-uclass.c | 31 -------------- include/expo.h | 2 - include/video_console.h | 48 ---------------------- test/dm/video.c | 67 ------------------------------- 8 files changed, 3 insertions(+), 230 deletions(-) diff --git a/boot/scene.c b/boot/scene.c index 1ea0d1b1c46..52cb7055eb3 100644 --- a/boot/scene.c +++ b/boot/scene.c @@ -92,7 +92,6 @@ int scene_new(struct expo *exp, const char *name, uint id, struct scene **scnp) free(scn); return log_msg_ret("buf", -ENOMEM); } - abuf_init(&scn->entry_save); INIT_LIST_HEAD(&scn->obj_head); scn->id = resolve_id(exp, id); @@ -122,7 +121,6 @@ void scene_destroy(struct scene *scn) list_for_each_entry_safe(obj, next, &scn->obj_head, sibling) scene_obj_destroy(obj); - abuf_uninit(&scn->entry_save); abuf_uninit(&scn->buf); free(scn->name); free(scn); diff --git a/boot/scene_txtin.c b/boot/scene_txtin.c index 1829fabf9cc..da8d49af04f 100644 --- a/boot/scene_txtin.c +++ b/boot/scene_txtin.c @@ -147,9 +147,6 @@ int scene_txtin_open(struct scene *scn, struct scene_obj *obj, 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); /* make sure the cursor is visible */ vidconsole_readline_start(cons, ctx, true); @@ -204,20 +201,10 @@ int scene_txtin_send_key(struct scene_obj *obj, struct scene_txtin *tin, 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(cls, key); - ret = vidconsole_entry_save(cons, &scn->entry_save); - if (ret) - return log_msg_ret("sav", ret); + default: + cread_line_process_ch(cls, key); break; } - } return 0; } diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c index d36a5c0ff8f..303900d73cb 100644 --- a/drivers/video/console_normal.c +++ b/drivers/video/console_normal.c @@ -133,36 +133,6 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev, return 0; } -static __maybe_unused int normal_entry_save(struct udevice *dev, - struct abuf *buf) -{ - struct console_ctx *ctx = vidconsole_ctx(dev); - const uint size = sizeof(*ctx); - - if (xpl_phase() <= PHASE_SPL) - return -ENOSYS; - - if (!abuf_realloc(buf, size)) - return log_msg_ret("sav", -ENOMEM); - - memcpy(abuf_data(buf), ctx, size); - - return 0; -} - -static __maybe_unused int normal_entry_restore(struct udevice *dev, - struct abuf *buf) -{ - struct console_ctx *ctx = vidconsole_ctx(dev); - - if (xpl_phase() <= PHASE_SPL) - return -ENOSYS; - - memcpy(ctx, abuf_data(buf), sizeof(*ctx)); - - return 0; -} - static int console_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y, int cp) { @@ -179,8 +149,6 @@ struct vidconsole_ops console_ops = { .ctx_new = console_simple_ctx_new, #ifdef CONFIG_CURSOR .get_cursor_info = console_get_cursor_info, - .entry_save = normal_entry_save, - .entry_restore = normal_entry_restore, #endif }; diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 25cc8241bf7..78683f8de13 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -1156,34 +1156,6 @@ static int truetype_ctx_new(struct udevice *dev, void *vctx) return 0; } -static int truetype_entry_save(struct udevice *dev, struct abuf *buf) -{ - struct console_tt_ctx *ctx = vidconsole_ctx(dev); - const uint size = sizeof(*ctx); - - if (xpl_phase() <= PHASE_SPL) - return -ENOSYS; - - if (!abuf_realloc(buf, size)) - return log_msg_ret("sav", -ENOMEM); - - memcpy(abuf_data(buf), ctx, size); - - return 0; -} - -static int truetype_entry_restore(struct udevice *dev, struct abuf *buf) -{ - struct console_tt_ctx *ctx = vidconsole_ctx(dev); - - if (xpl_phase() <= PHASE_SPL) - return -ENOSYS; - - memcpy(ctx, abuf_data(buf), sizeof(*ctx)); - - return 0; -} - static int truetype_get_cursor_info(struct udevice *dev, void *vctx) { struct console_tt_ctx *ctx = vctx; @@ -1196,9 +1168,7 @@ static int truetype_get_cursor_info(struct udevice *dev, void *vctx) return -ENOSYS; /* - * figure out where to place the cursor. This driver ignores the - * passed-in values, since an entry_restore() must have been done before - * calling this function. + * Figure out where to place the cursor. * * A current quirk is that the cursor is always at xcur_frac, since we * output characters directly to the console as they are typed by the @@ -1315,8 +1285,6 @@ struct vidconsole_ops console_truetype_ops = { .measure = truetype_measure, .nominal = truetype_nominal, .ctx_new = truetype_ctx_new, - .entry_save = truetype_entry_save, - .entry_restore = truetype_entry_restore, .get_cursor_info = truetype_get_cursor_info, .mark_start = truetype_mark_start, }; diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 513c8f3bacb..0f9e9e35a98 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -801,37 +801,6 @@ int vidconsole_ctx_dispose(struct udevice *dev, void *vctx) return 0; } -int vidconsole_entry_save(struct udevice *dev, struct abuf *buf) -{ - struct vidconsole_ops *ops = vidconsole_get_ops(dev); - int ret; - - if (ops->entry_save) { - ret = ops->entry_save(dev, buf); - if (ret != -ENOSYS) - return ret; - } - - /* no data so make sure the buffer is empty */ - abuf_realloc(buf, 0); - - return 0; -} - -int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf) -{ - struct vidconsole_ops *ops = vidconsole_get_ops(dev); - int ret; - - if (ops->entry_restore) { - ret = ops->entry_restore(dev, buf); - if (ret != -ENOSYS) - return ret; - } - - return 0; -} - #ifdef CONFIG_CURSOR int vidconsole_show_cursor(struct udevice *dev, void *vctx) { diff --git a/include/expo.h b/include/expo.h index adbe02922ab..d63fbd0c8ad 100644 --- a/include/expo.h +++ b/include/expo.h @@ -208,7 +208,6 @@ struct expo_string { * @highlight_id: ID of highlighted object, if any * @cls: cread state to use for input * @buf: Buffer for input - * @entry_save: Buffer to hold vidconsole text-entry information * @sibling: Node to link this scene to its siblings * @obj_head: List of objects in the scene */ @@ -221,7 +220,6 @@ struct scene { uint highlight_id; struct cli_line_state cls; struct abuf buf; - struct abuf entry_save; struct list_head sibling; struct list_head obj_head; }; diff --git a/include/video_console.h b/include/video_console.h index c047d45cf53..13d32dea2a9 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -405,30 +405,6 @@ struct vidconsole_ops { */ int (*ctx_dispose)(struct udevice *dev, void *ctx); - /** - * entry_save() - Save any text-entry information for later use - * - * Saves text-entry context such as a list of positions for each - * character in the string. - * - * @dev: Console device to use - * @buf: Buffer to hold saved data - * Return: 0 if OK, -ENOMEM if out of memory - */ - int (*entry_save)(struct udevice *dev, struct abuf *buf); - - /** - * entry_restore() - Restore text-entry information for current use - * - * Restores text-entry context such as a list of positions for each - * character in the string. - * - * @dev: Console device to use - * @buf: Buffer containing data to restore - * Return: 0 if OK, -ve on error - */ - int (*entry_restore)(struct udevice *dev, struct abuf *buf); - /** * get_cursor_info() - Get cursor position info * @@ -558,30 +534,6 @@ int vidconsole_ctx_new(struct udevice *dev, void **ctxp); */ int vidconsole_ctx_dispose(struct udevice *dev, void *ctx); -/** - * vidconsole_entry_save() - Save any text-entry information for later use - * - * Saves text-entry context such as a list of positions for each - * character in the string. - * - * @dev: Console device to use - * @buf: Buffer to hold saved data - * Return: 0 if OK, -ENOMEM if out of memory - */ -int vidconsole_entry_save(struct udevice *dev, struct abuf *buf); - -/** - * entry_restore() - Restore text-entry information for current use - * - * Restores text-entry context such as a list of positions for each - * character in the string. - * - * @dev: Console device to use - * @buf: Buffer containing data to restore - * Return: 0 if OK, -ve on error - */ -int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf); - #ifdef CONFIG_CURSOR /** * vidconsole_show_cursor() - Show the cursor diff --git a/test/dm/video.c b/test/dm/video.c index b4a1200e481..fe6407dad35 100644 --- a/test/dm/video.c +++ b/test/dm/video.c @@ -1516,70 +1516,3 @@ static int dm_test_video_context_alloc(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_video_context_alloc, UTF_SCAN_PDATA | UTF_SCAN_FDT); - -/* Test vidconsole entry save/restore */ -static int check_entry_save(struct unit_test_state *uts, struct udevice *con) -{ - struct vidconsole_priv *priv; - struct vidconsole_ctx *ctx; - int xcur_frac, ycur; - struct abuf buf; - - priv = dev_get_uclass_priv(con); - ctx = priv->ctx; - - /* Move cursor to a known position */ - vidconsole_position_cursor(con, 5, 3); - xcur_frac = ctx->xcur_frac; - ycur = ctx->ycur; - - /* Save the state */ - abuf_init(&buf); - ut_assertok(vidconsole_entry_save(con, &buf)); - - /* Move cursor to a different position */ - vidconsole_position_cursor(con, 10, 7); - ut_assert(ctx->xcur_frac != xcur_frac || ctx->ycur != ycur); - - /* Restore the state */ - ut_assertok(vidconsole_entry_restore(con, &buf)); - - /* Verify cursor is back at saved position */ - ut_asserteq(xcur_frac, ctx->xcur_frac); - ut_asserteq(ycur, ctx->ycur); - - abuf_uninit(&buf); - - return 0; -} - -/* Test entry save/restore with bitmap font */ -static int dm_test_video_entry_save(struct unit_test_state *uts) -{ - struct udevice *dev, *con; - - 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, NULL, "8x16", 0)); - - ut_assertok(check_entry_save(uts, con)); - - return 0; -} -DM_TEST(dm_test_video_entry_save, UTF_SCAN_PDATA | UTF_SCAN_FDT); - -/* Test entry save/restore with truetype font */ -static int dm_test_video_entry_save_tt(struct unit_test_state *uts) -{ - struct udevice *dev, *con; - - ut_assertok(video_get_nologo(uts, &dev)); - ut_assertok(uclass_get_device(UCLASS_VIDEO_CONSOLE, 0, &con)); - ut_assertok(vidconsole_select_font(con, NULL, NULL, 30)); - - ut_assertok(check_entry_save(uts, con)); - - return 0; -} -DM_TEST(dm_test_video_entry_save_tt, UTF_SCAN_PDATA | UTF_SCAN_FDT);