[patch] add support for rotated linux framebuffers

View: New views
1 Messages — Rating Filter:   Alert me  

[patch] add support for rotated linux framebuffers

by Mike Frysinger :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i brought this up some time ago but hadnt gotten a real chance until now to
put together a patch ... to refresh people's minds, the issue at hand is that
some framebuffer devices are rotated so you'll have resolutions like 240x320
rather than 320x240.  while we could duplicate all the scannable resolutions
and their vsync values, that's no fun

so in the attached patch, i have the framebuffer code swap the X and Y values
and do a second pass for each vesa entry

this is a copy & paste patch from 1.2.9 to latest svn, i'm just unable to
compile latest svn at the moment it would seem (the DirectFB and FBCON video
drivers fail)
-mike


Index: src/video/fbcon/SDL_fbvideo.c
===================================================================
--- src/video/fbcon/SDL_fbvideo.c (revision 2761)
+++ src/video/fbcon/SDL_fbvideo.c (working copy)
@@ -412,7 +412,7 @@ FB_CheckMode(_THIS, struct fb_var_screen
 
 static int
 FB_AddMode(_THIS, int index, unsigned int w, unsigned int h,
-           int check_timings)
+           int check_timings, int reversed)
 {
     SDL_Rect *mode;
     int i;
@@ -435,10 +435,12 @@ FB_AddMode(_THIS, int index, unsigned in
     if (check_timings) {
         int found_timing = 0;
         for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
-            if ((w == vesa_timings[i].xres) &&
-                (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) {
-                found_timing = 1;
-                break;
+            if (vesa_timings[i].pixclock) {
+                if (!reversed && w == vesa_timings[i].xres && h == vesa_timings[i].yres ||
+                     reversed && h == vesa_timings[i].xres && w == vesa_timings[i].yres) {
+                    found_timing = 1;
+                    break;
+                }
             }
         }
         if (!found_timing) {
@@ -653,24 +655,33 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
         SDL_modelist[i] = NULL;
     }
     if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) {
-        FB_AddMode(this, current_index, current_w, current_h, 0);
+        FB_AddMode(this, current_index, current_w, current_h, 0, 0);
     } else if (modesdb) {
         while (read_fbmodes_mode(modesdb, &vinfo)) {
             for (i = 0; i < NUM_MODELISTS; ++i) {
                 unsigned int w, h;
+                int reversed = 0;
 
                 /* See if we are querying for the current mode */
                 w = vinfo.xres;
                 h = vinfo.yres;
+try_reversed_dynamic:
                 if (i == current_index) {
                     if ((current_w > w) || (current_h > h)) {
                         /* Only check once */
-                        FB_AddMode(this, i, current_w, current_h, 0);
+                        FB_AddMode(this, i, current_w, current_h, 0, reversed);
                         current_index = -1;
                     }
                 }
                 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
-                    FB_AddMode(this, i, w, h, 0);
+                    FB_AddMode(this, i, w, h, 0, reversed);
+                }
+
+                /* See if a reversed X/Y matches */
+                if (!reversed) {
+                    unsigned tmp = w; w = h; h = tmp;
+                    reversed = 1;
+                    goto try_reversed_dynamic;
                 }
             }
         }
@@ -680,19 +691,28 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
         for (i = 0; i < NUM_MODELISTS; ++i) {
             for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) {
                 unsigned int w, h;
+                int reversed = 0;
 
                 /* See if we are querying for the current mode */
                 w = checkres[j].w;
                 h = checkres[j].h;
+try_reversed_static:
                 if (i == current_index) {
                     if ((current_w > w) || (current_h > h)) {
                         /* Only check once */
-                        FB_AddMode(this, i, current_w, current_h, 0);
+                        FB_AddMode(this, i, current_w, current_h, 0, reversed);
                         current_index = -1;
                     }
                 }
                 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
-                    FB_AddMode(this, i, w, h, 1);
+                    FB_AddMode(this, i, w, h, 1, reversed);
+                }
+
+                /* See if a reversed X/Y matches */
+                if (!reversed) {
+                    unsigned tmp = w; w = h; h = tmp;
+                    reversed = 1;
+                    goto try_reversed_static;
                 }
             }
         }

_______________________________________________
SDL mailing list
SDL@...
http://www.libsdl.org/mailman/listinfo/sdl

attachment0 (844 bytes) Download Attachment