From: Simon Glass <simon.glass@canonical.com>
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 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
drivers/video/console_truetype.c | 4 ++--
drivers/video/vidconsole-uclass.c | 8 ++++----
include/video_console.h | 3 ++-
3 files changed, 8 insertions(+), 7 deletions(-)
@@ -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;
@@ -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)
@@ -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 */