initial import
[patches.git] / sdl-fbcon-page-header.patch
CommitLineData
5e993f12 1Index: src/video/fbcon/SDL_fbvideo.c
2===================================================================
3--- src/video/fbcon/SDL_fbvideo.c (revision 2990)
4+++ src/video/fbcon/SDL_fbvideo.c (working copy)
5@@ -29,7 +29,9 @@
6 #include <unistd.h>
7 #include <sys/ioctl.h>
8 #include <sys/mman.h>
9+#ifndef HAVE_GETPAGESIZE
10 #include <asm/page.h> /* For definition of PAGE_SIZE */
11+#endif
12 #include <linux/vt.h>
13
14 #include "SDL_video.h"
15@@ -425,7 +427,7 @@ FB_CheckMode(_THIS, struct fb_var_screen
16
17 static int
18 FB_AddMode(_THIS, int index, unsigned int w, unsigned int h,
19- int check_timings)
20+ int check_timings, int reversed)
21 {
22 SDL_Rect *mode;
23 int i;
24@@ -448,10 +450,12 @@ FB_AddMode(_THIS, int index, unsigned in
25 if (check_timings) {
26 int found_timing = 0;
27 for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) {
28- if ((w == vesa_timings[i].xres) &&
29- (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) {
30- found_timing = 1;
31- break;
32+ if (vesa_timings[i].pixclock) {
33+ if (!reversed && w == vesa_timings[i].xres && h == vesa_timings[i].yres ||
34+ reversed && h == vesa_timings[i].xres && w == vesa_timings[i].yres) {
35+ found_timing = 1;
36+ break;
37+ }
38 }
39 }
40 if (!found_timing) {
41@@ -667,24 +671,33 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
42 SDL_modelist[i] = NULL;
43 }
44 if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) {
45- FB_AddMode(this, current_index, current_w, current_h, 0);
46+ FB_AddMode(this, current_index, current_w, current_h, 0, 0);
47 } else if (modesdb) {
48 while (read_fbmodes_mode(modesdb, &vinfo)) {
49 for (i = 0; i < NUM_MODELISTS; ++i) {
50 unsigned int w, h;
51+ int reversed = 0;
52
53 /* See if we are querying for the current mode */
54 w = vinfo.xres;
55 h = vinfo.yres;
56+try_reversed_dynamic:
57 if (i == current_index) {
58 if ((current_w > w) || (current_h > h)) {
59 /* Only check once */
60- FB_AddMode(this, i, current_w, current_h, 0);
61+ FB_AddMode(this, i, current_w, current_h, 0, reversed);
62 current_index = -1;
63 }
64 }
65 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
66- FB_AddMode(this, i, w, h, 0);
67+ FB_AddMode(this, i, w, h, 0, reversed);
68+ }
69+
70+ /* See if a reversed X/Y matches */
71+ if (!reversed) {
72+ unsigned tmp = w; w = h; h = tmp;
73+ reversed = 1;
74+ goto try_reversed_dynamic;
75 }
76 }
77 }
78@@ -694,19 +707,28 @@ FB_VideoInit(_THIS, SDL_PixelFormat * vf
79 for (i = 0; i < NUM_MODELISTS; ++i) {
80 for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) {
81 unsigned int w, h;
82+ int reversed = 0;
83
84 /* See if we are querying for the current mode */
85 w = checkres[j].w;
86 h = checkres[j].h;
87+try_reversed_static:
88 if (i == current_index) {
89 if ((current_w > w) || (current_h > h)) {
90 /* Only check once */
91- FB_AddMode(this, i, current_w, current_h, 0);
92+ FB_AddMode(this, i, current_w, current_h, 0, reversed);
93 current_index = -1;
94 }
95 }
96 if (FB_CheckMode(this, &vinfo, i, &w, &h)) {
97- FB_AddMode(this, i, w, h, 1);
98+ FB_AddMode(this, i, w, h, 1, reversed);
99+ }
100+
101+ /* See if a reversed X/Y matches */
102+ if (!reversed) {
103+ unsigned tmp = w; w = h; h = tmp;
104+ reversed = 1;
105+ goto try_reversed_static;
106 }
107 }
108 }