[Concept,12/36] video: Pass context to console_fixed_putc_xy()

Message ID 20260120231814.2033069-13-sjg@u-boot.org
State New
Headers
Series video: Add multiple-context support to vidconsole (part F) |

Commit Message

Simon Glass Jan. 20, 2026, 11:17 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Add a vctx parameter to console_fixed_putc_xy() to allow passing in a
specific vidconsole context. If NULL, the default context from priv is
used.

Update all callers accordingly.

Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 drivers/video/console_core.c        | 7 +++----
 drivers/video/console_normal.c      | 4 +++-
 drivers/video/console_truetype.c    | 3 ++-
 drivers/video/vidconsole_internal.h | 5 +++--
 4 files changed, 11 insertions(+), 8 deletions(-)
  

Patch

diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index 18edc14bcd7..ecb0b9dab89 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -336,11 +336,10 @@  int console_simple_get_font(struct udevice *dev, int seq, struct vidfont_info *i
 	return info->name ? 0 : -ENOENT;
 }
 
-int console_fixed_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp,
-			   struct video_fontdata *fontdata)
+int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y,
+			  int cp, struct video_fontdata *fontdata)
 {
-	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 udevice *vid = dev->parent;
 	struct video_priv *vid_priv = dev_get_uclass_priv(vid);
 	int pbytes = VNBYTES(vid_priv->bpix);
diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index fa9d496ef86..5b6f0f0ce86 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -81,9 +81,11 @@  static int console_move_rows(struct udevice *dev, uint rowdst,
 
 int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
 {
+	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 
-	return console_fixed_putc_xy(dev, x_frac, y, cp, priv->fontdata);
+	return console_fixed_putc_xy(dev, vidconsole_ctx_from_priv(vc_priv),
+				     x_frac, y, cp, priv->fontdata);
 }
 
 static __maybe_unused int console_get_cursor_info(struct udevice *dev)
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 519b8f88843..b4b491039ae 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -417,7 +417,8 @@  static int console_truetype_putc_xy(struct udevice *dev, uint x, uint y,
 
 	/* Use fixed font if selected */
 	if (ctx->cur_fontdata)
-		return console_fixed_putc_xy(dev, x, y, cp, ctx->cur_fontdata);
+		return console_fixed_putc_xy(dev, &ctx->com, x, y, cp,
+					     ctx->cur_fontdata);
 
 	/* Reset scratch buffer for this character */
 	stbtt_scratch_reset(&priv->scratch);
diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h
index 241be149ac9..ef864a7c858 100644
--- a/drivers/video/vidconsole_internal.h
+++ b/drivers/video/vidconsole_internal.h
@@ -198,14 +198,15 @@  int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp);
  * Fixed font putc_xy function that can be called with explicit font data
  *
  * @param dev		console device
+ * @param vctx		vidconsole context to use (cannot be NULL)
  * @param x_frac	fractional X position
  * @param y		Y position in pixels
  * @param cp		Unicode code point
  * @param fontdata	font data to use for rendering
  * @returns width in fractional pixels, or -ve on error
  */
-int console_fixed_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp,
-			  struct video_fontdata *fontdata);
+int console_fixed_putc_xy(struct udevice *dev, void *vctx, uint x_frac, uint y,
+			  int cp, struct video_fontdata *fontdata);
 
 /**
  * Internal function to convert Unicode code points to code page 437.