Skip to contentSkip to conversation

loader/i386/linux: Transfer EDID information to kernel

PATCH Superseded Thomas Zimmermann 4 participants 5 messages Sep 16, 2025 – Oct 2, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 loader/i386/linux: Transfer EDID information to kernel

The Linux kernel's struct bootparams provides a field at offset 0x140 for storing an EDID header. Copy the video adapter's data to the field.

The edid_info field was added in 2003 (see "[FBDEV] EDID support from OpenFirmware on PPC platoforms and from the BIOS on intel platforms."), but only got useable in 2004 (see "[PATCH] Fix EDID_INFO in zero-page"). The boot protocol was at version 2.03 at that time.

The field was never used much, but with the recent addition of the efidrm and vesadrm drivers to the kernel, it becomes much more useful. As with the initial screen setup, these drivers can make use of the provided EDID information for basic display output.

---
 grub-core/loader/i386/linux.c | 16 ++++++++++++++++
 grub-core/video/video.c       | 21 +++++++++++++++++++++
 include/grub/video.h          |  2 ++
 3 files changed, 39 insertions(+)
grub-core/loader/i386/linux.c +16 -0
index 12731feb2..afc8699bf 100644
@@ -234,6 +234,7 @@ grub_e820_add_region (struct grub_boot_e820_entry *e820_entry, int *e820_num,
 static grub_err_t
 grub_linux_setup_video (struct linux_kernel_params *params)
 {
+  struct grub_video_edid_info edid_info;
   struct grub_video_mode_info mode_info;
   void *framebuffer;
   grub_err_t err;
@@ -245,6 +246,19 @@ grub_linux_setup_video (struct linux_kernel_params *params)
   if (driver_id == GRUB_VIDEO_DRIVER_NONE)
     return 1;
 
+  err = grub_video_get_edid (&edid_info);
+  if (err)
+    grub_memset (&edid_info, 0, sizeof (edid_info));
+
+  /*
+   * We cannot transfer any extensions. Therefore clear
+   * the extension flag from the checksum and set the
+   * field to zero. Adding the extension flag to the
+   * checksum does the trick.
+   */
+  edid_info.checksum += edid_info.extension_flag;
+  edid_info.extension_flag = 0;
+
   err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
 
   if (err)
@@ -338,6 +352,8 @@ grub_linux_setup_video (struct linux_kernel_params *params)
     }
 #endif
 
+  grub_memcpy (params->edid_info, &edid_info, sizeof (params->edid_info));
+
   return GRUB_ERR_NONE;
 }
 
grub-core/video/video.c +21 -0
index 8937da745..b92b7036d 100644
@@ -89,6 +89,27 @@ grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
   return GRUB_ERR_NONE;
 }
 
+/* Get information about connected display.  */
+grub_err_t
+grub_video_get_edid (struct grub_video_edid_info *edid_info)
+{
+  grub_err_t err;
+
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+  if (grub_video_adapter_active->get_edid)
+    {
+      err = grub_video_adapter_active->get_edid (edid_info);
+      if (err)
+	return err;
+    }
+  else
+    grub_memset (edid_info, 0, sizeof (*edid_info));
+
+  return GRUB_ERR_NONE;
+}
+
 /* Determine optimized blitting formation for specified video mode info.  */
 enum grub_video_blit_format
 grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
include/grub/video.h +2 -0
index 9dac0f379..761ee994a 100644
@@ -445,6 +445,8 @@ grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_
 grub_err_t EXPORT_FUNC (grub_video_get_info_and_fini) (struct grub_video_mode_info *mode_info,
 					 void **framebuffer);
 
+grub_err_t EXPORT_FUNC (grub_video_get_edid) (struct grub_video_edid_info *edid_info);
+
 enum grub_video_blit_format EXPORT_FUNC(grub_video_get_blit_format) (struct grub_video_mode_info *mode_info);
 
 grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
Signature · 7 lines
2.51.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
#1 lore raw

FYI, we've been shipping a variant of this patch in openSUSE Tumbleweed for a few months already. See [1].

[1] https://build.opensuse.org/projects/Base:System/packages/grub2/files/grub2-provide-edid.patch?expand=1

Am 16.09.25 um 13:48 schrieb Thomas Zimmermann:

Quoted 106 lines

The Linux kernel's struct bootparams provides a field at offset 0x140 for storing an EDID header. Copy the video adapter's data to the field.

The edid_info field was added in 2003 (see "[FBDEV] EDID support from OpenFirmware on PPC platoforms and from the BIOS on intel platforms."), but only got useable in 2004 (see "[PATCH] Fix EDID_INFO in zero-page"). The boot protocol was at version 2.03 at that time.

The field was never used much, but with the recent addition of the efidrm and vesadrm drivers to the kernel, it becomes much more useful. As with the initial screen setup, these drivers can make use of the provided EDID information for basic display output.

---
  grub-core/loader/i386/linux.c | 16 ++++++++++++++++
  grub-core/video/video.c       | 21 +++++++++++++++++++++
  include/grub/video.h          |  2 ++
  3 files changed, 39 insertions(+)
grub-core/loader/i386/linux.c +16 -0
index 12731feb2..afc8699bf 100644
@@ -234,6 +234,7 @@ grub_e820_add_region (struct grub_boot_e820_entry *e820_entry, int *e820_num,
  static grub_err_t
  grub_linux_setup_video (struct linux_kernel_params *params)
  {
+  struct grub_video_edid_info edid_info;
    struct grub_video_mode_info mode_info;
    void *framebuffer;
    grub_err_t err;
@@ -245,6 +246,19 @@ grub_linux_setup_video (struct linux_kernel_params *params)
    if (driver_id == GRUB_VIDEO_DRIVER_NONE)
      return 1;
 
+  err = grub_video_get_edid (&edid_info);
+  if (err)
+    grub_memset (&edid_info, 0, sizeof (edid_info));
+
+  /*
+   * We cannot transfer any extensions. Therefore clear
+   * the extension flag from the checksum and set the
+   * field to zero. Adding the extension flag to the
+   * checksum does the trick.
+   */
+  edid_info.checksum += edid_info.extension_flag;
+  edid_info.extension_flag = 0;
+
    err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
 
    if (err)
@@ -338,6 +352,8 @@ grub_linux_setup_video (struct linux_kernel_params *params)
      }
  #endif
 
+  grub_memcpy (params->edid_info, &edid_info, sizeof (params->edid_info));
+
    return GRUB_ERR_NONE;
  }
 
grub-core/video/video.c +21 -0
index 8937da745..b92b7036d 100644
@@ -89,6 +89,27 @@ grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
    return GRUB_ERR_NONE;
  }
 
+/* Get information about connected display.  */
+grub_err_t
+grub_video_get_edid (struct grub_video_edid_info *edid_info)
+{
+  grub_err_t err;
+
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+  if (grub_video_adapter_active->get_edid)
+    {
+      err = grub_video_adapter_active->get_edid (edid_info);
+      if (err)
+	return err;
+    }
+  else
+    grub_memset (edid_info, 0, sizeof (*edid_info));
+
+  return GRUB_ERR_NONE;
+}
+
  /* Determine optimized blitting formation for specified video mode info.  */
  enum grub_video_blit_format
  grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
include/grub/video.h +2 -0
index 9dac0f379..761ee994a 100644
@@ -445,6 +445,8 @@ grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_
  grub_err_t EXPORT_FUNC (grub_video_get_info_and_fini) (struct grub_video_mode_info *mode_info,
  					 void **framebuffer);
 
+grub_err_t EXPORT_FUNC (grub_video_get_edid) (struct grub_video_edid_info *edid_info);
+
  enum grub_video_blit_format EXPORT_FUNC(grub_video_get_blit_format) (struct grub_video_mode_info *mode_info);
 
  grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
Signature · 14 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)



_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by on v1 1/1
#2 lore raw
In reply to Thomas Zimmermann
Quoted 14 lines · Thomas Zimmermann

The Linux kernel's struct bootparams provides a field at offset 0x140 for storing an EDID header. Copy the video adapter's data to the field.

The edid_info field was added in 2003 (see "[FBDEV] EDID support from OpenFirmware on PPC platoforms and from the BIOS on intel platforms."), but only got useable in 2004 (see "[PATCH] Fix EDID_INFO in zero-page"). The boot protocol was at version 2.03 at that time.

The field was never used much, but with the recent addition of the efidrm and vesadrm drivers to the kernel, it becomes much more useful. As with the initial screen setup, these drivers can make use of the provided EDID information for basic display output.

Quoted 7 lines
---
 grub-core/loader/i386/linux.c | 16 ++++++++++++++++
 grub-core/video/video.c       | 21 +++++++++++++++++++++
 include/grub/video.h          |  2 ++
 3 files changed, 39 insertions(+)

This patch seems reasonable to me.

Signature · 6 lines
真実はいつも一つ!/ Always, there's only one truth!

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel
Reviewed-by Michael Chang on v1 1/1
#3 lore raw
In reply to Thomas Zimmermann
Quoted 8 lines · Thomas Zimmermann

The Linux kernel's struct bootparams provides a field at offset 0x140 for storing an EDID header. Copy the video adapter's data to the field.

The edid_info field was added in 2003 (see "[FBDEV] EDID support from OpenFirmware on PPC platoforms and from the BIOS on intel platforms."), but only got useable in 2004 (see "[PATCH] Fix EDID_INFO in zero-page"). The boot protocol was at version 2.03 at that time.

Quoted 6 lines

The field was never used much, but with the recent addition of the efidrm and vesadrm drivers to the kernel, it becomes much more useful. As with the initial screen setup, these drivers can make use of the provided EDID information for basic display output.

Thanks,
Michael

Quoted 100 lines
---
 grub-core/loader/i386/linux.c | 16 ++++++++++++++++
 grub-core/video/video.c       | 21 +++++++++++++++++++++
 include/grub/video.h          |  2 ++
 3 files changed, 39 insertions(+)
grub-core/loader/i386/linux.c +16 -0
index 12731feb2..afc8699bf 100644
@@ -234,6 +234,7 @@ grub_e820_add_region (struct grub_boot_e820_entry *e820_entry, int *e820_num,
 static grub_err_t
 grub_linux_setup_video (struct linux_kernel_params *params)
 {
+  struct grub_video_edid_info edid_info;
   struct grub_video_mode_info mode_info;
   void *framebuffer;
   grub_err_t err;
@@ -245,6 +246,19 @@ grub_linux_setup_video (struct linux_kernel_params *params)
   if (driver_id == GRUB_VIDEO_DRIVER_NONE)
     return 1;
 
+  err = grub_video_get_edid (&edid_info);
+  if (err)
+    grub_memset (&edid_info, 0, sizeof (edid_info));
+
+  /*
+   * We cannot transfer any extensions. Therefore clear
+   * the extension flag from the checksum and set the
+   * field to zero. Adding the extension flag to the
+   * checksum does the trick.
+   */
+  edid_info.checksum += edid_info.extension_flag;
+  edid_info.extension_flag = 0;
+
   err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
 
   if (err)
@@ -338,6 +352,8 @@ grub_linux_setup_video (struct linux_kernel_params *params)
     }
 #endif
 
+  grub_memcpy (params->edid_info, &edid_info, sizeof (params->edid_info));
+
   return GRUB_ERR_NONE;
 }
 
grub-core/video/video.c +21 -0
index 8937da745..b92b7036d 100644
@@ -89,6 +89,27 @@ grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
   return GRUB_ERR_NONE;
 }
 
+/* Get information about connected display.  */
+grub_err_t
+grub_video_get_edid (struct grub_video_edid_info *edid_info)
+{
+  grub_err_t err;
+
+  if (! grub_video_adapter_active)
+    return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+  if (grub_video_adapter_active->get_edid)
+    {
+      err = grub_video_adapter_active->get_edid (edid_info);
+      if (err)
+	return err;
+    }
+  else
+    grub_memset (edid_info, 0, sizeof (*edid_info));
+
+  return GRUB_ERR_NONE;
+}
+
 /* Determine optimized blitting formation for specified video mode info.  */
 enum grub_video_blit_format
 grub_video_get_blit_format (struct grub_video_mode_info *mode_info)
include/grub/video.h +2 -0
index 9dac0f379..761ee994a 100644
@@ -445,6 +445,8 @@ grub_err_t EXPORT_FUNC (grub_video_get_info) (struct grub_video_mode_info *mode_
 grub_err_t EXPORT_FUNC (grub_video_get_info_and_fini) (struct grub_video_mode_info *mode_info,
 					 void **framebuffer);
 
+grub_err_t EXPORT_FUNC (grub_video_get_edid) (struct grub_video_edid_info *edid_info);
+
 enum grub_video_blit_format EXPORT_FUNC(grub_video_get_blit_format) (struct grub_video_mode_info *mode_info);
 
 grub_err_t grub_video_set_palette (unsigned int start, unsigned int count,
Signature · 7 lines
2.51.0


_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel

Reviewed-by on v1 1/1
#4 lore raw
In reply to Thomas Zimmermann
Quoted 8 lines · Thomas Zimmermann

The Linux kernel's struct bootparams provides a field at offset 0x140 for storing an EDID header. Copy the video adapter's data to the field.

The edid_info field was added in 2003 (see "[FBDEV] EDID support from OpenFirmware on PPC platoforms and from the BIOS on intel platforms."), but only got useable in 2004 (see "[PATCH] Fix EDID_INFO in zero-page"). The boot protocol was at version 2.03 at that time.

Quoted 6 lines

The field was never used much, but with the recent addition of the efidrm and vesadrm drivers to the kernel, it becomes much more useful. As with the initial screen setup, these drivers can make use of the provided EDID information for basic display output.

But a few nits below...

Quoted 19 lines
---
 grub-core/loader/i386/linux.c | 16 ++++++++++++++++
 grub-core/video/video.c       | 21 +++++++++++++++++++++
 include/grub/video.h          |  2 ++
 3 files changed, 39 insertions(+)
grub-core/loader/i386/linux.c +1 -0
index 12731feb2..afc8699bf 100644
@@ -234,6 +234,7 @@ grub_e820_add_region (struct grub_boot_e820_entry *e820_entry, int *e820_num,
 static grub_err_t
 grub_linux_setup_video (struct linux_kernel_params *params)
 {
+  struct grub_video_edid_info edid_info;
   struct grub_video_mode_info mode_info;
   void *framebuffer;
   grub_err_t err;

grub-core/loader/i386/linux.c grub_linux_setup_video (struct linux_kernel_params *params) · line 250

Quoted 5 lines
grub-core/loader/i386/linux.c +2 -0
@@ -245,6 +246,19 @@ grub_linux_setup_video (struct linux_kernel_params *params)
   if (driver_id == GRUB_VIDEO_DRIVER_NONE)
     return 1;
 
+  err = grub_video_get_edid (&edid_info);
+  if (err)

if (err != GRUB_ERR_NONE)

Quoted 28 lines
grub-core/loader/i386/linux.c +13 -0
+    grub_memset (&edid_info, 0, sizeof (edid_info));
+
+  /*
+   * We cannot transfer any extensions. Therefore clear
+   * the extension flag from the checksum and set the
+   * field to zero. Adding the extension flag to the
+   * checksum does the trick.
+   */
+  edid_info.checksum += edid_info.extension_flag;
+  edid_info.extension_flag = 0;
+
   err = grub_video_get_info_and_fini (&mode_info, &framebuffer);
 
   if (err)
@@ -338,6 +352,8 @@ grub_linux_setup_video (struct linux_kernel_params *params)
     }
 #endif
 
+  grub_memcpy (params->edid_info, &edid_info, sizeof (params->edid_info));
+
   return GRUB_ERR_NONE;
 }
 
grub-core/video/video.c +0 -0
index 8937da745..b92b7036d 100644

grub-core/video/video.c grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, · line 98

Quoted 10 lines
grub-core/video/video.c +7 -0
@@ -89,6 +89,27 @@ grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info,
   return GRUB_ERR_NONE;
 }
 
+/* Get information about connected display.  */
+grub_err_t
+grub_video_get_edid (struct grub_video_edid_info *edid_info)
+{
+  grub_err_t err;
+
+  if (! grub_video_adapter_active)

if (grub_video_adapter_active == NULL)

grub-core/video/video.c grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, · line 101

Quoted 3 lines
grub-core/video/video.c +3 -0
+    return grub_error (GRUB_ERR_BAD_DEVICE, "no video mode activated");
+
+  if (grub_video_adapter_active->get_edid)

if (grub_video_adapter_active->get_edid != NULL)

grub-core/video/video.c grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, · line 104

Quoted 3 lines
grub-core/video/video.c +3 -0
+    {
+      err = grub_video_adapter_active->get_edid (edid_info);
+      if (err)

if (err != GRUB_ERR_NONE)

grub-core/video/video.c grub_video_get_info_and_fini (struct grub_video_mode_info *mode_info, · line 111

Quoted 7 lines
grub-core/video/video.c +7 -0
+	return err;
+    }
+  else
+    grub_memset (edid_info, 0, sizeof (*edid_info));
+
+  return GRUB_ERR_NONE;
+}

Please fix the issues, add all RBs which you got and repost the patch...

Daniel

_______________________________________________
Grub-devel mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/grub-devel