Skip to contentSkip to conversation

Fix hardware accelerated video to video copy on Cirrus VGA

PATCH Applied Brian Kress 3 participants 3 messages Feb 15, 2009 – Feb 16, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix hardware accelerated video to video copy on Cirrus VGA

cirrus_do_copy() in hw/cirrus_vga.c seems to make some incorrect
assumptions about video
memory layout. It tries to convert addresses to coordinates assuming that one row of data is (width * depth) bytes long. The correct way seems to be to use the pitch fields in the CirrusVGAState structure instead.
Without this patch, I get lots of screen corruption when I try to
drag a window under X as it's
passing the wrong coordinates to the display surface for the copy. With this patch I can drag a window with no screen corruption.

cirrus_vga.c +4 -4
Index: hw/cirrus_vga.c
===================================================================
@@ -730,10 +730,10 @@
     s->get_resolution((VGAState *)s, &width, &height);
 
     /* extra x, y */
-    sx = (src % (width * depth)) / depth;
-    sy = (src / (width * depth));
-    dx = (dst % (width *depth)) / depth;
-    dy = (dst / (width * depth));
+    sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth;
+    sy = (src / ABS(s->cirrus_blt_srcpitch));
+    dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth;
+    dy = (dst / ABS(s->cirrus_blt_dstpitch));
 
     /* normalize width */
     w /= depth;
#1 lore raw

I have also noticed that, when emulating Rhapsody, if I have the color set to millions (32 bit) then it has issues redrawing lines. I do not know if this patch will fix it, but I'll look into it.

Quoted 32 lines · Brian Kress

cirrus_do_copy() in hw/cirrus_vga.c seems to make some incorrect
assumptions about video
memory layout. It tries to convert addresses to coordinates assuming that one row of data is (width * depth) bytes long. The correct way seems to be to use the pitch fields in the CirrusVGAState structure instead.
Without this patch, I get lots of screen corruption when I try to
drag a window under X as it's
passing the wrong coordinates to the display surface for the copy. With this patch I can drag a window with no screen corruption.

Index: hw/cirrus_vga.c
===================================================================

cirrus_vga.c +4 -4
@@ -730,10 +730,10 @@
    s->get_resolution((VGAState *)s, &width, &height);
 
    /* extra x, y */
-    sx = (src % (width * depth)) / depth;
-    sy = (src / (width * depth));
-    dx = (dst % (width *depth)) / depth;
-    dy = (dst / (width * depth));
+    sx = (src % ABS(s->cirrus_blt_srcpitch)) / depth;
+    sy = (src / ABS(s->cirrus_blt_srcpitch));
+    dx = (dst % ABS(s->cirrus_blt_dstpitch)) / depth;
+    dy = (dst / ABS(s->cirrus_blt_dstpitch));
 
    /* normalize width */
    w /= depth;
#2 lore raw
In reply to Brian Kress
Quoted 9 lines · Brian Kress

cirrus_do_copy() in hw/cirrus_vga.c seems to make some incorrect
assumptions about video
memory layout. It tries to convert addresses to coordinates assuming that one row of data is (width * depth) bytes long. The correct way seems to be to use the pitch fields in the CirrusVGAState structure instead.
Without this patch, I get lots of screen corruption when I try to
drag a window under X as it's
passing the wrong coordinates to the display surface for the copy. With this patch I can drag a window with no screen corruption.

Applied. Thanks.

Regards,

Anthony Liguori