[Concept,32/42] video: Drop extra parameters from get_cursor_info()

Message ID 20250919201507.4024144-33-sjg@u-boot.org
State New
Headers
Series video: Support a cursor more generally |

Commit Message

Simon Glass Sept. 19, 2025, 8:14 p.m. UTC
  From: Simon Glass <sjg@chromium.org>

Now that the console tracks the CLI index, remove the unnecessary
parameters. Both the normal and truetype consoles use the information
provided by the console.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

 drivers/video/console_normal.c    |  5 ++---
 drivers/video/console_truetype.c  | 20 +++++++++-----------
 drivers/video/vidconsole-uclass.c | 11 ++++++-----
 include/video_console.h           | 11 ++++-------
 4 files changed, 21 insertions(+), 26 deletions(-)
  

Patch

diff --git a/drivers/video/console_normal.c b/drivers/video/console_normal.c
index ac7053d60a8..5ef1cb1c68f 100644
--- a/drivers/video/console_normal.c
+++ b/drivers/video/console_normal.c
@@ -82,14 +82,13 @@  int console_normal_putc_xy(struct udevice *dev, uint x_frac, uint y, int cp)
 	return console_fixed_putc_xy(dev, x_frac, y, cp, priv->fontdata);
 }
 
-static __maybe_unused int console_get_cursor_info(struct udevice *dev,
-						  bool visible, uint x, uint y,
-						  uint index)
+static __maybe_unused int console_get_cursor_info(struct udevice *dev)
 {
 	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
 	struct console_simple_priv *priv = dev_get_priv(dev);
 	struct video_fontdata *fontdata = priv->fontdata;
 	struct vidconsole_cursor *curs = &vc_priv->curs;
+	int x, y, index;
 
 	/* for now, this is not used outside expo */
 	if (!IS_ENABLED(CONFIG_EXPO))
diff --git a/drivers/video/console_truetype.c b/drivers/video/console_truetype.c
index aabacd10afe..e215a3e0e54 100644
--- a/drivers/video/console_truetype.c
+++ b/drivers/video/console_truetype.c
@@ -1018,12 +1018,12 @@  static int truetype_entry_restore(struct udevice *dev, struct abuf *buf)
 	return 0;
 }
 
-static int truetype_get_cursor_info(struct udevice *dev, bool visible,
-				    uint x, uint y, uint index)
+static int truetype_get_cursor_info(struct udevice *dev)
 {
 	struct vidconsole_priv *vc_priv = dev_get_uclass_priv(dev);
 	struct console_tt_priv *priv = dev_get_priv(dev);
 	struct vidconsole_cursor *curs = &vc_priv->curs;
+	int x, y, index;
 	uint height;
 
 	if (xpl_phase() <= PHASE_SPL)
@@ -1034,14 +1034,12 @@  static int truetype_get_cursor_info(struct udevice *dev, bool visible,
 	 * passed-in values, since an entry_restore() must have been done before
 	 * calling this function.
 	 */
-	if (visible) {
-		index = priv->pos_ptr;
-		if (index < priv->pos_ptr)
-			x = VID_TO_PIXEL(priv->pos[index].xpos_frac);
-		else
-			x = VID_TO_PIXEL(vc_priv->xcur_frac);
-		y = vc_priv->ycur;
-	}
+	index = priv->pos_ptr;
+	if (index < priv->pos_ptr)
+		x = VID_TO_PIXEL(priv->pos[index].xpos_frac);
+	else
+		x = VID_TO_PIXEL(vc_priv->xcur_frac);
+	y = vc_priv->ycur;
 
 	/* Get font height from current font type */
 	if (priv->cur_fontdata)
@@ -1052,8 +1050,8 @@  static int truetype_get_cursor_info(struct udevice *dev, bool visible,
 	/* Store line pointer and height in cursor struct */
 	curs->x = x;
 	curs->y = y;
-	curs->index = index;
 	curs->height = height;
+	curs->index = index;
 
 	return 0;
 }
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index 65c912a4f6f..f62e34673db 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -720,11 +720,12 @@  int vidconsole_show_cursor(struct udevice *dev, uint x, uint y, uint index)
 	int ret;
 
 	/* find out where the cursor should be drawn */
-	if (ops->get_cursor_info) {
-		ret = ops->get_cursor_info(dev, true, x, y, index);
-		if (ret && ret != -ENOSYS)
-			return ret;
-	}
+	if (!ops->get_cursor_info)
+		return -ENOSYS;
+
+	ret = ops->get_cursor_info(dev);
+	if (ret)
+		return ret;
 
 	/* If the driver stored cursor line and height, use them for drawing */
 	if (curs->height) {
diff --git a/include/video_console.h b/include/video_console.h
index 0b8742c5ee9..669292c97d7 100644
--- a/include/video_console.h
+++ b/include/video_console.h
@@ -342,17 +342,14 @@  struct vidconsole_ops {
 	/**
 	 * get_cursor_info() - Get cursor position info
 	 *
-	 * Calculates and stores cursor position information
+	 * Calculates and stores cursor position information. This must fill in
+	 * @x, @y, @height and @index using struct vidconsole_priv fields
+	 * @xmark_frac, @ymark and @index
 	 *
 	 * @dev: Console device to use
-	 * @visible: true to show the cursor, false to hide it
-	 * @x: X position in pixels
-	 * @y: Y position in pixels
-	 * @index: Character position (0 = at start)
 	 * Return: 0 if OK, -ve on error
 	 */
-	int (*get_cursor_info)(struct udevice *dev, bool visible,
-			       uint x, uint y, uint index);
+	int (*get_cursor_info)(struct udevice *dev);
 
 	/**
 	 * mark_start() - Mark the current position as the state of CLI entry