]> git.baikalelectronics.ru Git - uboot.git/commitdiff
Revert 78baeeaee165 ("video: Remove duplicate cursor-positioning function")
authorTom Rini <trini@konsulko.com>
Wed, 15 Mar 2023 15:58:58 +0000 (11:58 -0400)
committerTom Rini <trini@konsulko.com>
Thu, 16 Mar 2023 16:17:02 +0000 (12:17 -0400)
This reverts commit 78baeeaee165bcf26965bda8e0ee1ccdef143404.

The changes here aren't quite right, and on platforms such as Raspberry
Pi where we can have both serial and video output, the change above
causes output to change. This can be seen as the hush tests we have now
fail.

Signed-off-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
drivers/video/vidconsole-uclass.c

index 61f4216750f2ea8dbfe5f67438f4d9675733ff38..1225de2333255ceb66a89a22e71722ba4bacac69 100644 (file)
@@ -126,14 +126,26 @@ void vidconsole_set_cursor_pos(struct udevice *dev, int x, int y)
        priv->ycur = y;
 }
 
-void vidconsole_position_cursor(struct udevice *dev, uint col, uint row)
+/**
+ * set_cursor_position() - set cursor position
+ *
+ * @priv:      private data of the video console
+ * @row:       new row
+ * @col:       new column
+ */
+static void set_cursor_position(struct vidconsole_priv *priv, int row, int col)
 {
-       struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
-       short x, y;
-
-       x = min_t(short, col, priv->cols - 1) * priv->x_charsize;
-       y = min_t(short, row, priv->rows - 1) * priv->y_charsize;
-       vidconsole_set_cursor_pos(dev, x, y);
+       /*
+        * Ensure we stay in the bounds of the screen.
+        */
+       if (row >= priv->rows)
+               row = priv->rows - 1;
+       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);
 }
 
 /**
@@ -180,7 +192,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                        int row = priv->row_saved;
                        int col = priv->col_saved;
 
-                       vidconsole_position_cursor(dev, col, row);
+                       set_cursor_position(priv, row, col);
                        priv->escape = 0;
                        return;
                }
@@ -242,7 +254,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. */
-               vidconsole_position_cursor(dev, col, row);
+               set_cursor_position(priv, row, col);
                break;
        }
        case 'H':
@@ -266,7 +278,7 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
                if (col)
                        --col;
 
-               vidconsole_position_cursor(dev, col, row);
+               set_cursor_position(priv, row, col);
 
                break;
        }
@@ -655,3 +667,15 @@ int vidconsole_clear_and_reset(struct udevice *dev)
 
        return 0;
 }
+
+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;
+
+       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);
+}