Skip to contentSkip to conversation

Fix for minor video corruption under Windows

PATCH In review Donald D. Dugger 2 participants 2 messages May 9, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix for minor video corruption under Windows

If you change the video resolution while running a Windows XP image such that it uses fewer bytes of VRAM (either by using fewer bytes per pixel or by lowering the resolution) then some window backgrounds will become corrupted. This happens because the Windows XP Cirrus Logic driver assumes that VRAM is initialized to 0xff whenever the video mode switches between VGA and SVGA.

This patch fixes this problem by resetting VRAM whenever a VGA/SVGA mode switch occurs.

Signed-off-by [email protected]
Signature · 36 lines
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
[email protected]
Ph: (303)440-1368


--- qemu-0.8.0-/hw/cirrus_vga.c	2005-12-19 15:51:53.000000000 -0700
+++ qemu-0.8.0/hw/cirrus_vga.c	2006-05-04 10:14:28.000000000 -0600
@@ -1185,6 +1185,17 @@
 	s->hw_cursor_y = (reg_value << 3) | (reg_index >> 5);
 	break;
     case 0x07:			// Extended Sequencer Mode
+	/* Win2K seems to assume that the VRAM is set to 0xff
+	 *   whenever VGA/SVGA mode changes
+	 */
+	if ((s->sr[0x07] ^ reg_value) & CIRRUS_SR7_BPP_SVGA)
+	    memset(s->vram_ptr, 0xff, s->real_vram_size);
+	s->sr[0x07] = reg_value;
+#ifdef DEBUG_CIRRUS
+	printf("cirrus: handled outport sr_index %02x, sr_value %02x\n",
+	       reg_index, reg_value);
+#endif
+	break;
     case 0x08:			// EEPROM Control
     case 0x09:			// Scratch Register 0
     case 0x0a:			// Scratch Register 1
@@ -2993,10 +3004,6 @@
     }
     s->cr[0x27] = device_id;
 
-    /* Win2K seems to assume that the pattern buffer is at 0xff
-       initially ! */
-    memset(s->vram_ptr, 0xff, s->real_vram_size);
-
     s->cirrus_hidden_dac_lockindex = 5;
     s->cirrus_hidden_dac_data = 0;
#1 lore raw

Donald...

thanks... I actually posted a patch to fix this sometime ago, but your patch seems more thorough and probably more correct. Just FYI, I attached my patch again. I will test your patch as well.

Thanks again,

Leo Reiter

Quoted 11 lines · Donald D. Dugger

If you change the video resolution while running a Windows XP image such that it uses fewer bytes of VRAM (either by using fewer bytes per pixel or by lowering the resolution) then some window backgrounds will become corrupted. This happens because the Windows XP Cirrus Logic driver assumes that VRAM is initialized to 0xff whenever the video mode switches between VGA and SVGA.

This patch fixes this problem by resetting VRAM whenever a VGA/SVGA mode switch occurs.

Signed-off-by [email protected]
Signature · 8 lines
Leonardo E. Reiter
Vice President of Product Development, CTO

Win4Lin, Inc.
Virtual Computing that means Business
Main: +1 512 339 7979
Fax: +1 512 532 6501
http://www.win4lin.com

Index: hw/vga.c
===================================================================
RCS file: /cvsroot/qemu/qemu/hw/vga.c,v
retrieving revision 1.42

vga.c +2 -0
diff -a -u -r1.42 vga.c
@@ -1366,6 +1366,8 @@
 
     if (disp_width != s->last_width ||
         height != s->last_height) {
+        if (cirrus_vga_enabled && s->get_bpp(s) >= 8)
+            memset(s->vram_ptr, 0xff, s->vram_size);
         dpy_resize(s->ds, disp_width, height);
         s->last_scr_width = disp_width;
         s->last_scr_height = height;