From: Simon Glass <simon.glass@canonical.com> Move the last_ch field from vidconsole_priv into vidconsole_ctx as part of the per-client context refactoring. This field tracks the last character written, used for kerning in truetype fonts. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- drivers/video/console_truetype.c | 7 ++++--- drivers/video/vidconsole-uclass.c | 10 +++++----- include/video_console.h | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c index 233154cfeea..e607dff0aea 100644 --- a/drivers/video/console_truetype.c +++ b/drivers/video/console_truetype.c @@ -452,8 +452,8 @@ static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y, pos = ctx->pos_ptr < ctx->pos_count ? &ctx->pos[ctx->pos_ptr] : NULL; xpos = frac(VID_TO_PIXEL((double)x)); kern = 0; - if (vc_priv->last_ch) { - int last_cp = vc_priv->last_ch; + if (vc_ctx->last_ch) { + int last_cp = vc_ctx->last_ch; if (pos) last_cp = pos->cp; @@ -722,13 +722,14 @@ static int console_truetype_backspace(struct udevice *dev) static int console_truetype_entry_start(struct udevice *dev) { struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev); + struct vidconsole_ctx *vc_ctx = vidconsole_ctx_from_priv(vc_priv); struct console_tt_priv *priv = dev_get_priv(dev); struct console_tt_ctx *ctx = &priv->ctx; /* A new input line has start, so clear our history */ ctx->pos_ptr = 0; ctx->pos_count = 0; - vc_priv->last_ch = 0; + vc_ctx->last_ch = 0; return 0; } diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c index 29caaf34fc0..1e9c0b4b730 100644 --- a/drivers/video/vidconsole-uclass.c +++ b/drivers/video/vidconsole-uclass.c @@ -113,7 +113,7 @@ static void vidconsole_newline(struct udevice *dev) vid_priv->colour_bg); ctx->ycur -= rows * ctx->y_charsize; } - priv->last_ch = 0; + ctx->last_ch = 0; ret = video_sync(dev->parent, false); if (ret) { @@ -143,7 +143,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y) ctx->ycur = y; /* make sure not to kern against the previous character */ - priv->last_ch = 0; + ctx->last_ch = 0; vidconsole_entry_start(dev); } @@ -460,7 +460,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) if (_DEBUG) { console_printf_select_stderr(true, "glyph last_ch '%c': ch '%c' (%02x): ", - priv->last_ch, ch >= ' ' ? ch : ' ', ch); + ctx->last_ch, ch >= ' ' ? ch : ' ', ch); } /* * Failure of this function normally indicates an unsupported @@ -475,7 +475,7 @@ static int vidconsole_output_glyph(struct udevice *dev, int ch) if (ret < 0) return ret; ctx->xcur_frac += ret; - priv->last_ch = ch; + ctx->last_ch = ch; if (ctx->xcur_frac >= priv->xsize_frac) vidconsole_newline(dev); cli_index_adjust(priv, 1); @@ -522,7 +522,7 @@ int vidconsole_put_char(struct udevice *dev, char ch) break; case '\b': vidconsole_back(dev); - priv->last_ch = 0; + ctx->last_ch = 0; break; default: if (CONFIG_IS_ENABLED(CHARSET)) { diff --git a/include/video_console.h b/include/video_console.h index c2656ec452d..6dfa2214448 100644 --- a/include/video_console.h +++ b/include/video_console.h @@ -85,6 +85,7 @@ struct vidconsole_cursor { * @y_charsize: Character height in pixels * @xcur_frac: Current X position, in fractional units (VID_TO_POS(x)) * @ycur: Current Y position in pixels (0=top) + * @last_ch: Last character written to the text console on this line */ struct vidconsole_ctx { int rows; @@ -93,6 +94,7 @@ struct vidconsole_ctx { int y_charsize; int xcur_frac; int ycur; + int last_ch; }; /** @@ -135,7 +137,6 @@ struct vidconsole_ansi { * @tab_width_frac: Tab width in fractional units * @xsize_frac: Width of the display in fractional units * @xstart_frac: Left margin for the text console in fractional units - * @last_ch: Last character written to the text console on this line * @xmark_frac: X position of start of CLI text entry, in fractional units * @ymark: Y position of start of CLI text * @cli_index: Character index into the CLI text (0=start) @@ -150,7 +151,6 @@ struct vidconsole_priv { int tab_width_frac; int xsize_frac; int xstart_frac; - int last_ch; int xmark_frac; int ymark; int cli_index; -- 2.43.0