qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* RE: [Qemu-devel] [PATCH]Fix for minor video corruption under Windows
@ 2006-05-09 23:12 Dugger, Donald D
  2006-05-10 14:27 ` WaxDragon
  2006-05-11 22:47 ` Fabrice Bellard
  0 siblings, 2 replies; 7+ messages in thread
From: Dugger, Donald D @ 2006-05-09 23:12 UTC (permalink / raw)
  To: qemu-devel

Leo-

Yeah, I started there but it turns out there are multiple reasons why
that is the wrong place to fix things:

1)  `hw/vga.c' only knows about resolution changes, the bug also appears
if you change the pixel size, e.g. 24 bpp to 16 bpp.

2)  Technically, because of the lazy screen update, your change would be
too late.  To improve performance the vga code is only called
periodically, not after every VRAM change.  It is theoretically possible
for the target to change video mode, assume VRAM got reset, do a bitblt
from non-visible VRAM to visible VRAM and then have the `hw/vga.c' code
get called, overwriting the changes done to visible VRAM.

--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Donald.D.Dugger@intel.com
Ph: (303)440-1368 

>-----Original Message-----
>From: qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org 
>[mailto:qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org
>] On Behalf Of Leonardo E. Reiter
>Sent: Tuesday, May 09, 2006 2:29 PM
>To: qemu-devel@nongnu.org
>Subject: Re: [Qemu-devel] [PATCH]Fix for minor video 
>corruption under Windows
>
>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
>
>Donald D. Dugger wrote:
>> 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: Donald.D.Dugger@intel.com
>> 
>
>-- 
>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
>

^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: [Qemu-devel] [PATCH]Fix for minor video corruption under Windows
@ 2006-05-12  0:15 Dugger, Donald D
  0 siblings, 0 replies; 7+ messages in thread
From: Dugger, Donald D @ 2006-05-12  0:15 UTC (permalink / raw)
  To: qemu-devel

Fabrice-

Well, I've been assuming that the Windows driver doesn't call the BIOS
to do a video mode switch (that seems like a silly thing to do and
without sources I hate having to guess at things) but this is Windows so
I guess it's possible.  If you've got a BIOS patch I'd love to try it
out when you're ready.

--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Donald.D.Dugger@intel.com
Ph: (303)440-1368 

>-----Original Message-----
>From: qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org 
>[mailto:qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org
>] On Behalf Of Fabrice Bellard
>Sent: Thursday, May 11, 2006 4:48 PM
>To: qemu-devel@nongnu.org
>Subject: Re: [Qemu-devel] [PATCH]Fix for minor video 
>corruption under Windows
>
>Hi,
>
>I think the proper fix must be done in the BIOS (set VRAM to 0xFF at 
>cirrus mode init). I made a patch for that but I must test it 
>a little more.
>
>Fabrice.
>
>Dugger, Donald D wrote:
>> Leo-
>> 
>> Yeah, I started there but it turns out there are multiple reasons why
>> that is the wrong place to fix things:
>> 
>> 1)  `hw/vga.c' only knows about resolution changes, the bug 
>also appears
>> if you change the pixel size, e.g. 24 bpp to 16 bpp.
>> 
>> 2)  Technically, because of the lazy screen update, your 
>change would be
>> too late.  To improve performance the vga code is only called
>> periodically, not after every VRAM change.  It is 
>theoretically possible
>> for the target to change video mode, assume VRAM got reset, 
>do a bitblt
>> from non-visible VRAM to visible VRAM and then have the 
>`hw/vga.c' code
>> get called, overwriting the changes done to visible VRAM.
>> 
>> --
>> Don Dugger
>> "Censeo Toto nos in Kansa esse decisse." - D. Gale
>> Donald.D.Dugger@intel.com
>> Ph: (303)440-1368 
>> 
>> 
>>>-----Original Message-----
>>>From: qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org 
>>>[mailto:qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org
>>>] On Behalf Of Leonardo E. Reiter
>>>Sent: Tuesday, May 09, 2006 2:29 PM
>>>To: qemu-devel@nongnu.org
>>>Subject: Re: [Qemu-devel] [PATCH]Fix for minor video 
>>>corruption under Windows
>>>
>>>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
>>>
>>>Donald D. Dugger wrote:
>>>
>>>>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: Donald.D.Dugger@intel.com
>>>>
>>>
>>>-- 
>>>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
>>>
>> 
>> 
>> 
>> _______________________________________________
>> Qemu-devel mailing list
>> Qemu-devel@nongnu.org
>> http://lists.nongnu.org/mailman/listinfo/qemu-devel
>> 
>> 
>
>
>
>_______________________________________________
>Qemu-devel mailing list
>Qemu-devel@nongnu.org
>http://lists.nongnu.org/mailman/listinfo/qemu-devel
>

^ permalink raw reply	[flat|nested] 7+ messages in thread
* RE: [Qemu-devel] [PATCH]Fix for minor video corruption under Windows
@ 2006-05-10 16:17 Dugger, Donald D
  0 siblings, 0 replies; 7+ messages in thread
From: Dugger, Donald D @ 2006-05-10 16:17 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2871 bytes --]

WD-

I see the problem here, `patch' got confused because my patch was
against a 0.8.0 tree and you applied it to a 0.8.1 tree.  You wound up
making the change to `cirrus_hook_read_sr', where the Windows driver
attempts to read the mode register.  The patch is supposed to apply to
the routine `cirrus_hook_write_sr', where the video mode is set.

I've attached a version of the patch that should apply cleanly against
the 0.8.1 tree.  (Sorry about the attachment, IT policies force me to
use a broken mailer and I can only reply to you with an attachment.)

--
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Donald.D.Dugger@intel.com
Ph: (303)440-1368 

>-----Original Message-----
>From: qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org 
>[mailto:qemu-devel-bounces+donald.d.dugger=intel.com@nongnu.org
>] On Behalf Of WaxDragon
>Sent: Wednesday, May 10, 2006 8:27 AM
>To: qemu-devel@nongnu.org
>Subject: Re: [Qemu-devel] [PATCH]Fix for minor video 
>corruption under Windows
>
>I tried out this patch (with CVS, after fixing it) with XP SP2 and 2k3
>SP1.  It did address the corruption when changing bpp or resolution,
>but paints the screen white while the UI elements repaint themselves. 
>Just a little disturbing, but I'll get used to it.  Also, I had the
>leave the second chunk in, otherwise XP failed to paint much of the
>screen upon bootup.
>
>Index: hw/cirrus_vga.c
>===================================================================
>RCS file: /sources/qemu/qemu/hw/cirrus_vga.c,v
>retrieving revision 1.21
>diff -u -r1.21 cirrus_vga.c
>--- hw/cirrus_vga.c     30 Apr 2006 21:28:36 -0000      1.21
>+++ hw/cirrus_vga.c     10 May 2006 14:08:25 -0000
>@@ -1181,6 +1181,17 @@
>        break;
>     case 0x05:                 // ???
>     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);
>+    *reg_value = s->sr[0x07];
>+#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
>
>
>WD
>--
>ReactOS is a hub, follow the spokes and you'll
>immediately find absolutely everything you need
>to know about Windows.  ReactOS is not just
>software, it's people.
>                                        kjk_hyperion
>
>
>_______________________________________________
>Qemu-devel mailing list
>Qemu-devel@nongnu.org
>http://lists.nongnu.org/mailman/listinfo/qemu-devel
>

[-- Attachment #2: patch-cirrus-0510.l --]
[-- Type: application/octet-stream, Size: 1103 bytes --]

diff -Naur qemu-0.8.1-/hw/cirrus_vga.c qemu-0.8.1/hw/cirrus_vga.c
--- qemu-0.8.1-/hw/cirrus_vga.c	2006-05-03 14:32:58.000000000 -0600
+++ qemu-0.8.1/hw/cirrus_vga.c	2006-05-10 10:09:55.000000000 -0600
@@ -1260,6 +1260,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
@@ -3068,10 +3079,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;
 

^ permalink raw reply	[flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH]Fix for minor video corruption under Windows
@ 2006-05-09 19:56 Donald D. Dugger
  2006-05-09 20:29 ` Leonardo E. Reiter
  0 siblings, 1 reply; 7+ messages in thread
From: Donald D. Dugger @ 2006-05-09 19:56 UTC (permalink / raw)
  To: qemu-devel

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: Donald.D.Dugger@intel.com

-- 
Don Dugger
"Censeo Toto nos in Kansa esse decisse." - D. Gale
Donald.D.Dugger@intel.com
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;
 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-05-12  0:15 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-09 23:12 [Qemu-devel] [PATCH]Fix for minor video corruption under Windows Dugger, Donald D
2006-05-10 14:27 ` WaxDragon
2006-05-11 22:47 ` Fabrice Bellard
  -- strict thread matches above, loose matches on Subject: below --
2006-05-12  0:15 Dugger, Donald D
2006-05-10 16:17 Dugger, Donald D
2006-05-09 19:56 Donald D. Dugger
2006-05-09 20:29 ` Leonardo E. Reiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).