From: Simon Glass <simon.glass@canonical.com> 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 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- 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 -- 2.43.0