@@ -280,7 +280,7 @@ int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv,
int console_alloc_cursor(struct udevice *dev)
{
- struct vidconsole_priv *vc_priv;
+ struct vidconsole_ctx *ctx;
struct vidconsole_cursor *curs;
struct video_priv *vid_priv;
struct udevice *vid;
@@ -289,10 +289,10 @@ int console_alloc_cursor(struct udevice *dev)
if (!CONFIG_IS_ENABLED(CURSOR) || xpl_phase() < PHASE_BOARD_R)
return 0;
- vc_priv = dev_get_uclass_priv(dev);
+ ctx = vidconsole_ctx(dev);
vid = dev_get_parent(dev);
vid_priv = dev_get_uclass_priv(vid);
- curs = &vc_priv->curs;
+ curs = &ctx->curs;
/* Allocate cursor save buffer for maximum possible cursor height */
save_count = vid_priv->ysize * VIDCONSOLE_CURSOR_WIDTH;
@@ -98,7 +98,7 @@ static __maybe_unused int console_get_cursor_info(struct udevice *dev)
struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv);
struct console_simple_priv *priv = dev_get_priv(dev);
struct video_fontdata *fontdata = priv->fontdata;
- struct vidconsole_cursor *curs = &vc_priv->curs;
+ struct vidconsole_cursor *curs = &ctx->curs;
int x, y, index, xspace, xpos;
/* for now, this is not used outside expo */
@@ -1233,7 +1233,7 @@ static int truetype_get_cursor_info(struct udevice *dev)
struct vidconsole_ctx *com = vidconsole_ctx_from_priv(vc_priv);
struct console_tt_priv *priv = dev_get_priv(dev);
struct console_tt_ctx *ctx = &priv->ctx;
- struct vidconsole_cursor *curs = &vc_priv->curs;
+ struct vidconsole_cursor *curs = &com->curs;
int x, y, index;
uint height;
@@ -767,8 +767,9 @@ int vidconsole_entry_restore(struct udevice *dev, struct abuf *buf)
int vidconsole_show_cursor(struct udevice *dev)
{
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+ struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv);
struct vidconsole_ops *ops = vidconsole_get_ops(dev);
- struct vidconsole_cursor *curs = &priv->curs;
+ struct vidconsole_cursor *curs = &ctx->curs;
int ret;
/* find out where the cursor should be drawn */
@@ -807,7 +808,8 @@ int vidconsole_show_cursor(struct udevice *dev)
int vidconsole_hide_cursor(struct udevice *dev)
{
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
- struct vidconsole_cursor *curs = &priv->curs;
+ struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(priv);
+ struct vidconsole_cursor *curs = &ctx->curs;
int ret;
if (!curs->visible)
@@ -912,9 +914,9 @@ static int vidconsole_post_probe(struct udevice *dev)
static int vidconsole_pre_remove(struct udevice *dev)
{
- struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
+ struct vidconsole_ctx *ctx = vidconsole_ctx(dev);
- free(vc_priv->curs.save_data);
+ free(ctx->curs.save_data);
return 0;
}
@@ -987,8 +989,8 @@ void vidconsole_set_bitmap_font(struct udevice *dev,
void vidconsole_idle(struct udevice *dev)
{
- struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
- struct vidconsole_cursor *curs = &priv->curs;
+ struct vidconsole_ctx *ctx = vidconsole_ctx(dev);
+ struct vidconsole_cursor *curs = &ctx->curs;
/* Only handle cursor if it's enabled */
if (curs->enabled && !curs->visible) {
@@ -1008,10 +1010,10 @@ void vidconsole_readline_start(bool indent)
struct udevice *dev;
uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) {
- struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+ struct vidconsole_ctx *ctx = vidconsole_ctx(dev);
- priv->curs.indent = indent;
- priv->curs.enabled = true;
+ ctx->curs.indent = indent;
+ ctx->curs.enabled = true;
vidconsole_mark_start(dev);
}
}
@@ -1022,9 +1024,9 @@ void vidconsole_readline_end(void)
struct udevice *dev;
uclass_id_foreach_dev(UCLASS_VIDEO_CONSOLE, dev, uc) {
- struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+ struct vidconsole_ctx *ctx = vidconsole_ctx(dev);
- priv->curs.enabled = false;
+ ctx->curs.enabled = false;
}
}
#endif /* CURSOR */
@@ -112,6 +112,7 @@ struct vidconsole_ansi {
* @ymark: Y position of start of CLI text
* @ansi: ANSI escape-sequence state
* @utf8_buf: Buffer to accumulate UTF-8 byte sequence
+ * @curs: Cursor state and management
*/
struct vidconsole_ctx {
int rows;
@@ -126,6 +127,7 @@ struct vidconsole_ctx {
int ymark;
struct vidconsole_ansi ansi;
char utf8_buf[5];
+ struct vidconsole_cursor curs;
};
/**
@@ -148,7 +150,6 @@ struct vidconsole_ctx {
* @xsize_frac: Width of the display in fractional units
* @xstart_frac: Left margin for the text console in fractional units
* @quiet: Suppress all output from stdio
- * @curs: Cursor state and management
*/
struct vidconsole_priv {
struct stdio_dev sdev;
@@ -157,7 +158,6 @@ struct vidconsole_priv {
int xsize_frac;
int xstart_frac;
bool quiet;
- struct vidconsole_cursor curs;
};
/**
@@ -1185,7 +1185,8 @@ static int check_cursor_backspace(struct unit_test_state *uts,
{
int with_a, with_cursor, after_backspace, after_idle, after_hide;
struct vidconsole_priv *vc_priv = dev_get_uclass_priv(con);
- struct vidconsole_cursor *curs = &vc_priv->curs;
+ struct vidconsole_ctx *ctx = vidconsole_ctx_from_priv(vc_priv);
+ struct vidconsole_cursor *curs = &ctx->curs;
/* Output chars without cursor */
ut_assert(!curs->visible);