Skip to contentSkip to conversation

Fix SDL problems with BGR displays

PATCH In review Anthony Liguori 4 participants 9 messages Jul 22, 2008 – Jul 23, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Fix SDL problems with BGR displays

From: Avi Kivity <[email protected]>

kvm: qemu: revert qemu's sdl.c rev 1.40

this fixes problems with bgr displays.

sdl.c +1 -1
index bac60ea..719e2bd 100644
@@ -89,7 +89,7 @@ static void sdl_resize(DisplayState *ds, int w, int h)
     ds->data = screen->pixels;
     ds->linesize = screen->pitch;
     ds->depth = screen->format->BitsPerPixel;
-    if (screen->format->Bshift > screen->format->Rshift) {
+    if (ds->depth == 32 && screen->format->Rshift == 0) {
         ds->bgr = 1;
     } else {
         ds->bgr = 0;
#1 lore raw

PATCH 2/3 Fix task register type after reset

From: Avi Kivity <[email protected]>

kvm: qemu: fix task register type after reset

Breaks reboots.

target-i386/helper.c +1 -1
index 852f093..7962d6b 100644
@@ -403,7 +403,7 @@ void cpu_reset(CPUX86State *env)
     env->ldt.limit = 0xffff;
     env->ldt.flags = DESC_P_MASK | (2 << DESC_TYPE_SHIFT);
     env->tr.limit = 0xffff;
-    env->tr.flags = DESC_P_MASK | (11 < DESC_TYPE_SHIFT);
+    env->tr.flags = DESC_P_MASK | (11 << DESC_TYPE_SHIFT);
 
     cpu_x86_load_seg_cache(env, R_CS, 0xf000, 0xffff0000, 0xffff,
                            DESC_P_MASK | DESC_S_MASK | DESC_CS_MASK | DESC_R_MASK);
#2 lore raw

PATCH 3/3 Fix -daemonize option

In reply to Anthony Liguori

When using -daemonize, we want to avoid chdir() until after we've opened the block devices. It's also perfectly fine to use -dameonize along with SDL.

vl.c +1 -6
index f057a5e..d94ebb1 100644
@@ -8626,11 +8626,6 @@ int main(int argc, char **argv)
     }
 
 #ifndef _WIN32
-    if (daemonize && !nographic && vnc_display == NULL) {
-	fprintf(stderr, "Can only daemonize if using -nographic or -vnc\n");
-	daemonize = 0;
-    }
-
     if (daemonize) {
 	pid_t pid;
 
@@ -8668,7 +8663,6 @@ int main(int argc, char **argv)
 	    exit(1);
 
 	umask(027);
-	chdir("/");
 
         signal(SIGTSTP, SIG_IGN);
         signal(SIGTTOU, SIG_IGN);
@@ -8974,6 +8968,7 @@ int main(int argc, char **argv)
 	if (len != 1)
 	    exit(1);
 
+	chdir("/");
 	TFR(fd = open("/dev/null", O_RDWR));
 	if (fd == -1)
 	    exit(1);
#3 lore raw
In reply to Anthony Liguori

Hi,

Am 22.07.2008 um 22:51 schrieb Anthony Liguori:

Quoted 5 lines

From: Avi Kivity <[email protected]>

kvm: qemu: revert qemu's sdl.c rev 1.40

this fixes problems with bgr displays.

What problems exactly are you fixing? Could other backends such as Cocoa be affected, too?

Quoted 16 lines
sdl.c +1 -1
index bac60ea..719e2bd 100644
@@ -89,7 +89,7 @@ static void sdl_resize(DisplayState *ds, int w,  
 int h)
    ds->data = screen->pixels;
    ds->linesize = screen->pitch;
    ds->depth = screen->format->BitsPerPixel;
-    if (screen->format->Bshift > screen->format->Rshift) {
+    if (ds->depth == 32 && screen->format->Rshift == 0) {
        ds->bgr = 1;
    } else {
Quoted 2 lines
        ds->bgr = 0;

Why does BGR depend on a depth of 32?

Andreas

#4 lore raw
Quoted 11 lines · Andreas Färber

Hi,

Am 22.07.2008 um 22:51 schrieb Anthony Liguori:

Quoted 5 lines

From: Avi Kivity <[email protected]>

kvm: qemu: revert qemu's sdl.c rev 1.40

this fixes problems with bgr displays.

What problems exactly are you fixing? Could other backends such as Cocoa be affected, too?

The original commit in question is 2974. I don't have the ability to test Cocoa but we received a bug report about a BGR display regression shortly after this commit. Reverting this particular part of the commit made the problem go away. See http://thread.gmane.org/gmane.comp.emulators.kvm.devel/7773

Perhaps Blue Swirl can comment if reverting this part of the patch regresses some of the test cases he was working with when he committed the original patch?

Regards,

Anthony Liguori

#5 lore raw
Quoted 24 lines · Anthony Liguori
Quoted 5 lines · Andreas Färber

Hi,

Am 22.07.2008 um 22:51 schrieb Anthony Liguori:

Quoted 8 lines
Quoted 6 lines

From: Avi Kivity <[email protected]>

kvm: qemu: revert qemu's sdl.c rev 1.40

this fixes problems with bgr displays.

What problems exactly are you fixing? Could other backends such as Cocoa

be affected, too?

Quoted 1 line

The original commit in question is 2974. I don't have the ability to test
Cocoa but we received a bug report about a BGR display regression shortly after this commit. Reverting this particular part of the commit made the problem go away. See
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/7773

Quoted 3 lines

Perhaps Blue Swirl can comment if reverting this part of the patch
regresses some of the test cases he was working with when he committed the original patch?

I can't reproduce the problem anymore, even reverting the patch changes nothing at depth 16. There seems to be other bugs involved, for example at depth 15 everything looks cosmic. Maybe VGA memory accesses assume some host endianness which are wrong on big endian host.

#6 lore raw
Quoted 8 lines · Blue Swirl

On 7/23/08, Anthony Liguori <[email protected]> wrote:

I can't reproduce the problem anymore, even reverting the patch changes nothing at depth 16. There seems to be other bugs involved, for example at depth 15 everything looks cosmic. Maybe VGA memory accesses assume some host endianness which are wrong on big endian host.

Okay, I'll commit the partial revert since it does at least fix some displays.

Regards,

Anthony Liguori

#7 lore raw
In reply to Blue Swirl
Quoted 30 lines · Blue Swirl
Quoted 24 lines · Anthony Liguori
Quoted 5 lines · Andreas Färber

Hi,

Am 22.07.2008 um 22:51 schrieb Anthony Liguori:

Quoted 8 lines
Quoted 6 lines

From: Avi Kivity <[email protected]>

kvm: qemu: revert qemu's sdl.c rev 1.40

this fixes problems with bgr displays.

What problems exactly are you fixing? Could other backends such as Cocoa

be affected, too?

Quoted 1 line

The original commit in question is 2974. I don't have the ability to test
Cocoa but we received a bug report about a BGR display regression shortly after this commit. Reverting this particular part of the commit made the problem go away. See
http://thread.gmane.org/gmane.comp.emulators.kvm.devel/7773

Quoted 3 lines

Perhaps Blue Swirl can comment if reverting this part of the patch
regresses some of the test cases he was working with when he committed the original patch?

Quoted 6 lines

I can't reproduce the problem anymore, even reverting the patch
changes nothing at depth 16. There seems to be other bugs involved, for example at depth 15 everything looks cosmic. Maybe VGA memory accesses assume some host endianness which are wrong on big endian host.

This patch gets 15 bit display working for me. SDL BitsPerPixel never indicates any values other than multiples of 8, so we need to check for strange depths. Any comments?

sdl.c +9 -0
Index: qemu/sdl.c
===================================================================
@@ -89,6 +89,15 @@
     ds->data = screen->pixels;
     ds->linesize = screen->pitch;
     ds->depth = screen->format->BitsPerPixel;
+    if (ds->depth == 16) {
+        uint32_t mask;
+
+        mask = screen->format->Rmask;
+        mask |= screen->format->Gmask;
+        mask |= screen->format->Bmask;
+        if ((mask & 0x8000) == 0)
+            ds->depth = 15;
+    }
     if (ds->depth == 32 && screen->format->Rshift == 0) {
         ds->bgr = 1;
     } else {
#8 lore raw
Quoted 4 lines · Blue Swirl

This patch gets 15 bit display working for me. SDL BitsPerPixel never indicates any values other than multiples of 8, so we need to check for strange depths. Any comments?

It looks sane to me.

Regards,

Anthony Liguori