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(-)
@@ -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;
@@ -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;
@@ -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;
@@ -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