Blame SOURCES/0197-EFI-console-Do-not-set-cursor-until-the-first-text-o.patch

fd0330
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
fd0330
From: Hans de Goede <hdegoede@redhat.com>
fd0330
Date: Fri, 28 Jan 2022 12:43:49 +0100
fd0330
Subject: [PATCH] EFI: console: Do not set cursor until the first text output
fd0330
fd0330
To allow flickerfree boot the EFI console code does not call
fd0330
grub_efi_set_text_mode (1) until some text is actually output.
fd0330
fd0330
Depending on if the output text is because of an error loading
fd0330
e.g. the .cfg file; or because of showing the menu the cursor needs
fd0330
to be on or off when the first text is shown.
fd0330
fd0330
So far the cursor was hardcoded to being on, but this is causing
fd0330
drawing artifacts + slow drawing of the menu as reported here:
fd0330
https://bugzilla.redhat.com/show_bug.cgi?id=1946969
fd0330
fd0330
Handle the cursorstate in the same way as the colorstate to fix this,
fd0330
when no text has been output yet, just cache the cursorstate and
fd0330
then use the last set value when the first text is output.
fd0330
fd0330
Fixes: 2d7c3abd871f ("efi/console: Do not set text-mode until we actually need it")
fd0330
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
fd0330
---
fd0330
 grub-core/term/efi/console.c | 19 ++++++++++++++++---
fd0330
 1 file changed, 16 insertions(+), 3 deletions(-)
fd0330
fd0330
diff --git a/grub-core/term/efi/console.c b/grub-core/term/efi/console.c
fd0330
index c44b2ac318..a3622e4fe5 100644
fd0330
--- a/grub-core/term/efi/console.c
fd0330
+++ b/grub-core/term/efi/console.c
fd0330
@@ -31,7 +31,15 @@ typedef enum {
fd0330
 }
fd0330
 grub_text_mode;
fd0330
 
fd0330
+typedef enum {
fd0330
+    GRUB_CURSOR_MODE_UNDEFINED = -1,
fd0330
+    GRUB_CURSOR_MODE_OFF = 0,
fd0330
+    GRUB_CURSUR_MODE_ON
fd0330
+}
fd0330
+grub_cursor_mode;
fd0330
+
fd0330
 static grub_text_mode text_mode = GRUB_TEXT_MODE_UNDEFINED;
fd0330
+static grub_cursor_mode cursor_mode = GRUB_CURSOR_MODE_UNDEFINED;
fd0330
 static grub_term_color_state text_colorstate = GRUB_TERM_COLOR_UNDEFINED;
fd0330
 
fd0330
 static grub_uint32_t
fd0330
@@ -119,8 +127,12 @@ grub_console_setcursor (struct grub_term_output *term __attribute__ ((unused)),
fd0330
 {
fd0330
   grub_efi_simple_text_output_interface_t *o;
fd0330
 
fd0330
-  if (grub_efi_is_finished)
fd0330
-    return;
fd0330
+  if (grub_efi_is_finished || text_mode != GRUB_TEXT_MODE_AVAILABLE)
fd0330
+    {
fd0330
+      /* Cache cursor changes before the first text-output */
fd0330
+      cursor_mode = on;
fd0330
+      return;
fd0330
+    }
fd0330
 
fd0330
   o = grub_efi_system_table->con_out;
fd0330
   efi_call_2 (o->enable_cursor, o, on);
fd0330
@@ -143,7 +155,8 @@ grub_prepare_for_text_output (struct grub_term_output *term)
fd0330
       return GRUB_ERR_BAD_DEVICE;
fd0330
     }
fd0330
 
fd0330
-  grub_console_setcursor (term, 1);
fd0330
+  if (cursor_mode != GRUB_CURSOR_MODE_UNDEFINED)
fd0330
+    grub_console_setcursor (term, cursor_mode);
fd0330
   if (text_colorstate != GRUB_TERM_COLOR_UNDEFINED)
fd0330
     grub_console_setcolorstate (term, text_colorstate);
fd0330
   text_mode = GRUB_TEXT_MODE_AVAILABLE;