The vidconsole ANSI 'K' (Erase in Line) handler only implemented the
[2K variant (clear entire line). A bare ESC[K, i.e. mode 0, means
"clear from the cursor to the end of the line" and was silently
ignored.

Code that relies on it therefore left stale characters on screen. For
example the autoboot countdown redraws its line with a carriage return
and trailing ESC[K:

  printf("\rHit any key to stop autoboot: %1d\033[K", bootdelay);

This redraw form was introduced by commit 5f70be08b015 ("Fix autoboot
countdown printing wrong"), which replaced the older
"printf(\"\b\b\b%2d \", bootdelay)" backspace scheme (that broke for a
bootdelay > 99) with a robust "\r" + full reprint + ESC[K approach. The
ESC[K is what erases any trailing characters left over from the
previous, possibly longer, count.

On a serial terminal ESC[K is honoured, so the countdown looks correct.
On vidconsole it was a no-op, so leftovers stayed behind: because the
initial prompt is still printed with "%2d " while the updates use "%1d"
(an inconsistency left behind by that same commit, which only updated
the in-loop print), the digit shifts one column and the old trailing
digit is never erased. The countdown then showed up as
"45 35 25 15 05" on the display.

Implement mode 0 by clearing from the current cursor position to the end
of the line with video_fill_part(), mirroring the span the truetype
console already erases on backspace.

Signed-off-by: Michal Simek <[email protected]>
---

Tested on vek385 revB with DP over mmi
---
 drivers/video/vidconsole-uclass.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index f1b2d61bd8ff..02c234b463dc 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -327,7 +327,7 @@ static void vidconsole_escape_char(struct udevice *dev, 
char ch)
 
                /*
                 * Clear (parts of) current line
-                *   [0K       - clear line to end
+                *   [0K / [K  - clear from cursor to end of line
                 *   [2K       - clear entire line
                 */
                parsenum(priv->escape_buf + 1, &mode);
@@ -337,6 +337,19 @@ static void vidconsole_escape_char(struct udevice *dev, 
char ch)
 
                        get_cursor_position(priv, &row, &col);
                        vidconsole_set_row(dev, row, vid_priv->colour_bg);
+               } else if (mode == 0) {
+                       /*
+                        * Clear from the cursor to the end of the line,
+                        * leaving the cursor where it is. Same span the
+                        * truetype console erases on backspace.
+                        */
+                       video_fill_part(dev->parent,
+                                       VID_TO_PIXEL(priv->xcur_frac),
+                                       priv->ycur, vid_priv->xsize,
+                                       priv->ycur + priv->y_charsize,
+                                       vid_priv->colour_bg);
+               } else {
+                       debug("unsupported clear mode: %d\n", mode);
                }
                break;
        }
---

-- 
2.43.0

Reply via email to