[Concept,23/36] video: Pass context to console_alloc_cursor()

Message ID 20260120231814.2033069-24-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>

Update console_alloc_cursor() to take a context parameter so it can
allocate cursor memory for a specific context rather than always using
the default.

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_truetype.c    | 2 +-
 drivers/video/vidconsole_internal.h | 3 ++-
 3 files changed, 5 insertions(+), 7 deletions(-)
  

Patch

diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index 5cb1b3fb2b7..dba47af4eb5 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -278,9 +278,8 @@  int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv,
 	return 0;
 }
 
-int console_alloc_cursor(struct udevice *dev)
+int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx)
 {
-	struct vidconsole_ctx *ctx;
 	struct vidconsole_cursor *curs;
 	struct video_priv *vid_priv;
 	struct udevice *vid;
@@ -288,8 +287,6 @@  int console_alloc_cursor(struct udevice *dev)
 
 	if (!CONFIG_IS_ENABLED(CURSOR) || xpl_phase() < PHASE_BOARD_R)
 		return 0;
-
-	ctx = vidconsole_ctx(dev);
 	vid = dev_get_parent(dev);
 	vid_priv = dev_get_uclass_priv(vid);
 	curs = &ctx->curs;
@@ -312,7 +309,7 @@  int console_probe(struct udevice *dev)
 		return ret;
 
 	if (CONFIG_IS_ENABLED(CURSOR) && xpl_phase() == PHASE_BOARD_R) {
-		ret = console_alloc_cursor(dev);
+		ret = console_alloc_cursor(dev, vidconsole_ctx(dev));
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index 4dd382055b2..9b835437031 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1301,7 +1301,7 @@  static int console_truetype_probe(struct udevice *dev)
 
 	debug("%s: ready\n", __func__);
 
-	ret = console_alloc_cursor(dev);
+	ret = console_alloc_cursor(dev, &ctx->com);
 	if (ret)
 		return ret;
 
diff --git a/drivers/video/vidconsole_internal.h b/drivers/video/vidconsole_internal.h
index e1e89f6524a..60ff7bed758 100644
--- a/drivers/video/vidconsole_internal.h
+++ b/drivers/video/vidconsole_internal.h
@@ -152,9 +152,10 @@  int cursor_hide(struct vidconsole_cursor *curs, struct video_priv *vid_priv,
  * Allocates memory for saving pixels under the cursor
  *
  * @dev: vidconsole device
+ * @ctx: vidconsole context
  * Return: 0 if success, -ENOMEM if allocation fails
  */
-int console_alloc_cursor(struct udevice *dev);
+int console_alloc_cursor(struct udevice *dev, struct vidconsole_ctx *ctx);
 
 /**
  * console probe function.