[2590] 2009-09-12 Robert Millan <[email protected]>

Robert Millan <[email protected]> Sat, 12 Sep 2009 13:07:27 +0000
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2590
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2590
Author:   robertmh
Date:     2009-09-12 13:07:27 +0000 (Sat, 12 Sep 2009)
Log Message:
-----------
2009-09-12  Robert Millan  <[email protected]>

        * video/i386/pc/vbe.c (grub_vbe_get_video_mode_info): Move packed
        mode special handling (grub_vbe_bios_set_dac_palette_width() call)
        from here ...
        * loader/i386/linux.c [GRUB_MACHINE_PCBIOS]
        (grub_linux_setup_video): ... to here (with some adjustments).

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/loader/i386/linux.c
    trunk/grub2/video/i386/pc/vbe.c

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-09-12 13:05:25 UTC (rev 2589)
+++ trunk/grub2/ChangeLog	2009-09-12 13:07:27 UTC (rev 2590)
@@ -1,5 +1,13 @@
 2009-09-12  Robert Millan  <[email protected]>
 
+	* video/i386/pc/vbe.c (grub_vbe_get_video_mode_info): Move packed
+	mode special handling (grub_vbe_bios_set_dac_palette_width() call)
+	from here ...
+	* loader/i386/linux.c [GRUB_MACHINE_PCBIOS]
+	(grub_linux_setup_video): ... to here (with some adjustments).
+
+2009-09-12  Robert Millan  <[email protected]>
+
 	Fix memory corruption issue (spotted by Colin Watson).
 
 	* kern/i386/pc/startup.S (grub_vbe_bios_getset_dac_palette): Fix bug

Modified: trunk/grub2/loader/i386/linux.c
===================================================================
--- trunk/grub2/loader/i386/linux.c	2009-09-12 13:05:25 UTC (rev 2589)
+++ trunk/grub2/loader/i386/linux.c	2009-09-12 13:07:27 UTC (rev 2590)
@@ -33,6 +33,7 @@
 #include <grub/video.h>
 #include <grub/video_fb.h>
 #include <grub/command.h>
+#include <grub/i386/pc/vbe.h>
 
 #define GRUB_LINUX_CL_OFFSET		0x1000
 #define GRUB_LINUX_CL_END_OFFSET	0x2000
@@ -416,6 +417,33 @@
   params->reserved_mask_size = mode_info.reserved_mask_size;
   params->reserved_field_pos = mode_info.reserved_field_pos;
 
+
+#ifdef GRUB_MACHINE_PCBIOS
+  /* VESA packed modes may come with zeroed mask sizes, which need
+     to be set here according to DAC Palette width.  If we don't,
+     this results in Linux displaying a black screen.  */
+  if (mode_info.bpp <= 8)
+    {
+      struct grub_vbe_info_block controller_info;
+      int status;
+      int width = 8;
+
+      status = grub_vbe_bios_get_controller_info (&controller_info);
+
+      if (status == GRUB_VBE_STATUS_OK &&
+	  (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH))
+	status = grub_vbe_bios_set_dac_palette_width (&width);
+
+      if (status != GRUB_VBE_STATUS_OK)
+	/* 6 is default after mode reset.  */
+	width = 6;
+
+      params->red_mask_size = params->green_mask_size
+	= params->blue_mask_size = width;
+      params->reserved_mask_size = 0;
+    }
+#endif
+
   return 0;
 }
 

Modified: trunk/grub2/video/i386/pc/vbe.c
===================================================================
--- trunk/grub2/video/i386/pc/vbe.c	2009-09-12 13:05:25 UTC (rev 2589)
+++ trunk/grub2/video/i386/pc/vbe.c	2009-09-12 13:07:27 UTC (rev 2590)
@@ -286,24 +286,6 @@
 
       /* Make copy of mode info block.  */
       grub_memcpy (mode_info, mi_tmp, sizeof (*mode_info));
-
-      /* Packed mode.  Query DAC Palette width for color sizes.  */
-      if (mode_info->bits_per_pixel <= 8)
-	{
-	  int width = 8;
-	  status = 0;
-
-	  if (controller_info.capabilities & GRUB_VBE_CAPABILITY_DACWIDTH)
-	    status = grub_vbe_bios_set_dac_palette_width (& width);
-
-	  if (status != GRUB_VBE_STATUS_OK)
-	    /* 6 is default after mode reset.  */
-	    width = 6;
-
-	  mode_info->red_mask_size = mode_info->green_mask_size
-	    = mode_info->blue_mask_size = width;
-	  mode_info->rsvd_mask_size = 0;
-	}
     }
   else
     /* Just clear mode info block if it isn't a VESA mode.  */