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