summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2022-10-06 08:36:04 -0600
committerAnatolij Gustschin <agust@denx.de>2022-10-30 09:53:47 +0100
commit6b6dc0d2fbf8b036d7ee278071036c7479074b32 (patch)
treeb333e6f2bb40d90f2ba48686c1b7531e20858398 /drivers
parenta032e4b55ea717fb931dd0d4754cf72b9bafe2f4 (diff)
downloadu-boot-6b6dc0d2fbf8b036d7ee278071036c7479074b32.tar.gz
u-boot-6b6dc0d2fbf8b036d7ee278071036c7479074b32.tar.bz2
u-boot-6b6dc0d2fbf8b036d7ee278071036c7479074b32.zip
video: Provide a function to set the cursor position
Add an exported function which allows the cursor position to be set to pixel granularity. Make use of this in the existing code. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/video/vidconsole-uclass.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/video/vidconsole-uclass.c b/drivers/video/vidconsole-uclass.c
index f67027c67b..53263580e3 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -122,6 +122,15 @@ static char *parsenum(char *s, int *num)
return end;
}
+void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
+{
+ struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
+ priv->xcur_frac = VID_TO_POS(x);
+ priv->xstart_frac = priv->xcur_frac;
+ priv->ycur = y;
+}
+
/**
* set_cursor_position() - set cursor position
*
@@ -614,12 +623,11 @@ void vidconsole_position_cursor(struct udevice *dev, unsigned col, unsigned row)
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
struct udevice *vid_dev = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
+ short x, y;
- col *= priv->x_charsize;
- row *= priv->y_charsize;
- priv->xcur_frac = VID_TO_POS(min_t(short, col, vid_priv->xsize - 1));
- priv->xstart_frac = priv->xcur_frac;
- priv->ycur = min_t(short, row, vid_priv->ysize - 1);
+ x = min_t(short, col * priv->x_charsize, vid_priv->xsize - 1);
+ y = min_t(short, row * priv->y_charsize, vid_priv->ysize - 1);
+ vidconsole_set_cursor_pos(dev, x, y);
}
static int do_video_setcursor(struct cmd_tbl *cmdtp, int flag, int argc,