Subject: bug#39607: GRUB module all_video required to get video on 4K monitor

From: Maxim Cournoyer <[email-masked]>
Date: Wed, 19 Feb 2020 21:55:54 -0500

Hello,

Maxim Cournoyer <[email-masked]> writes:

> Hello,
>
> I installed Guix System on a new machine, which displays on a 4K (3840 x
> 2160 pixels) monitor.
>
> Unless I go to the GRUB command prompt with 'c' at boot and type 'insmod
> all_video', the video cuts early after booting a GRUB entry with 'No
> suitable video mode found', or similar.
>
> I think we should include this GRUB module in our default GRUB
> package/configuration.
>
> Maxim

I think the attached patches fixes this issue, and makes the
GRUB configuration a bit simpler too!

>From 115cc43361c72b3bae0d89e03f328e4383d9e9be Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Wed, 19 Feb 2020 15:35:46 -0500
Subject: [PATCH 1/2] bootloader: grub: Use the all_video module in graphic
 mode.

Fixes <https://bugs.gnu.org/39467>.

* gnu/bootloader/grub.scm (eye-candy): Load the module 'all_video'
which automatically loads all the available and relevant video
modules.
---
 gnu/bootloader/grub.scm | 15 +--------------
 1 file changed, 1 insertion(+), 14 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index 3ec960abd8..c1cee78a16 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -163,21 +163,8 @@ system string---e.g., \"x86_64-linux\"."
                (string-append "set gfxmode=" (string-join gfxmode ";"))
                "# Leave 'gfxmode' to 'auto'."))
          "
-  insmod video_bochs
-  insmod video_cirrus
+  insmod all_video
   insmod gfxterm
-
-  if [ \"${grub_platform}\" == efi ]; then
-    # This is for (U)EFI systems (these modules are unavailable in the
-    # non-EFI GRUB.)  If we don't load them, GRUB boots in \"blind mode\",
-    # which isn't convenient.
-    insmod efi_gop
-    insmod efi_uga
-  else
-    # These are specific to non-EFI Intel machines.
-    insmod vbe
-    insmod vga
-  fi
 ")
         ""))
 
-- 
2.25.0

>From 5892917e2e56535deba9579a3013b54177fadc57 Mon Sep 17 00:00:00 2001
From: Maxim Cournoyer <[email-masked]>
Date: Wed, 19 Feb 2020 15:59:06 -0500
Subject: [PATCH 2/2] bootloader: grub: Refactor eye-candy a bit.

* gnu/bootloader/grub.scm (eye-candy)[setup-gfxterm-body]: Define the GFXMODE
binding using AND-LET* instead of chained AND=>.  Add a comment about
supporting graphical mode on other systems than x86. Generate configuration
string using FORMAT rather than STRING-APPEND.
---
 gnu/bootloader/grub.scm | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/gnu/bootloader/grub.scm b/gnu/bootloader/grub.scm
index c1cee78a16..d81e990cea 100644
--- a/gnu/bootloader/grub.scm
+++ b/gnu/bootloader/grub.scm
@@ -36,6 +36,7 @@
   #:use-module (ice-9 match)
   #:use-module (ice-9 regex)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-2)
   #:export (grub-image
             grub-image?
             grub-image-aspect-ratio
@@ -149,24 +150,26 @@ STORE-MOUNT-POINT is its mount point; these are used to determine where the
 background image and fonts must be searched for.  SYSTEM must be the target
 system string---e.g., \"x86_64-linux\"."
   (define setup-gfxterm-body
-    ;; Intel and EFI systems need to be switched into graphics mode, whereas
-    ;; most other modern architectures have no other mode and therefore don't
-    ;; need to be switched.
-    (if (string-match "^(x86_64|i[3-6]86)-" system)
-        (string-append
-         "
-"
-         (let ((gfxmode (and=>
-                         (and=> config bootloader-configuration-theme)
-                         grub-gfxmode)))
-           (if gfxmode
-               (string-append "set gfxmode=" (string-join gfxmode ";"))
-               "# Leave 'gfxmode' to 'auto'."))
-         "
+    (let ((gfxmode
+           (or (and-let* ((theme (bootloader-configuration-theme config))
+                          (gfxmode (grub-gfxmode theme)))
+                 (string-join gfxmode ";"))
+               "auto")))
+
+      ;; Intel and EFI systems need to be switched into graphics mode, whereas
+      ;; most other modern architectures have no other mode and therefore
+      ;; don't need to be switched.
+
+      ;; XXX: Do we really need to restrict to x86 systems?  We could imitate
+      ;; what the GRUB default configuration does and decide based on whether
+      ;; a user provided 'gfxterm' in the terminal-outputs field of their
+      ;; bootloader-configuration record.
+      (if (string-match "^(x86_64|i[3-6]86)-" system)
+          (format #f "
+  set gfxmode=~a
   insmod all_video
-  insmod gfxterm
-")
-        ""))
+  insmod gfxterm~%" gfxmode)
+          "")))
 
   (define (setup-gfxterm config font-file)
     (if (memq 'gfxterm (bootloader-configuration-terminal-outputs config))
-- 
2.25.0