]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: Correct setting of cursor position
authorSimon Glass <sjg@chromium.org>
Thu, 4 Jan 2024 15:10:37 +0000 (08:10 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 11 Apr 2024 02:01:33 +0000 (20:01 -0600)
The ANSI codes are not correctly handled at present, in that the
requested X position is added to the current one.

Correct this and also call vidconsole_entry_start() to start a new text
line.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Anatolij Gustschin <agust@denx.de>
drivers/video/vidconsole-uclass.c

index 22d55df71f63de1e90e657df51d205370ad71d8f..a312a1985242c2a5374f5b391630d5940e7c56a1 100644 (file)
@@ -125,6 +125,7 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
        priv->xcur_frac = VID_TO_POS(x);
        priv->xstart_frac = priv->xcur_frac;
        priv->ycur = y;
+       vidconsole_entry_start(dev);
 }
 
 /**
@@ -134,8 +135,10 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
  * @row:       new row
  * @col:       new column
  */
-static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
+static void set_cursor_position(struct udevice *dev, int row, int col)
 {
+       struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
+
        /*
         * Ensure we stay in the bounds of the screen.
         */
@@ -144,9 +147,7 @@ static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
        if (col >= priv->cols)
                col = priv->cols - 1;
 
-       priv->ycur = row * priv->y_charsize;
-       priv->xcur_frac = priv->xstart_frac +
-                         VID_TO_POS(col * priv->x_charsize);
+       vidconsole_position_cursor(dev, col, row);
 }
 
 /**
@@ -193,7 +194,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                        int row = priv->row_saved;
                        int col = priv->col_saved;
 
-                       set_cursor_position(priv, row, col);
+                       set_cursor_position(dev, row, col);
                        priv->escape = 0;
                        return;
                }
@@ -255,7 +256,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                if (row < 0)
                        row = 0;
                /* Right and bottom overflows are handled in the callee. */
-               set_cursor_position(priv, row, col);
+               set_cursor_position(dev, row, col);
                break;
        }
        case 'H':
@@ -279,7 +280,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                if (col)
                        --col;
 
-               set_cursor_position(priv, row, col);
+               set_cursor_position(dev, row, col);
 
                break;
        }