1
0
mirror of git://projects.qi-hardware.com/openwrt-packages.git synced 2024-07-03 09:22:01 +03:00
openwrt-packages/liballegro/patches/020-fix-fbcon-init.patch

88 lines
2.8 KiB
Diff

Index: allegro-4.4.2/src/linux/fbcon.c
===================================================================
--- allegro-4.4.2.orig/src/linux/fbcon.c 2011-06-02 11:18:50.000000000 +0200
+++ allegro-4.4.2/src/linux/fbcon.c 2011-06-16 22:13:10.000000000 +0200
@@ -19,6 +19,10 @@
* See readme.txt for copyright information.
*/
+/* #define DEBUGMODE */
+
+#include <errno.h>
+#include <string.h>
#include "allegro.h"
#include "allegro/internal/aintern.h"
@@ -251,6 +255,7 @@
if (__al_linux_console_graphics() != 0) {
ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_mode);
close(fbfd);
+ fb_mode_read = FALSE;
return NULL;
}
@@ -263,6 +268,7 @@
case -1:
/* let's see if we can get the actual screen mode */
/* shouldn't we be keeping the previous color depth setting? */
+ TRACE(PREFIX_I "...orig bpp %i...\n", (int)orig_mode.bits_per_pixel);
switch (orig_mode.bits_per_pixel) {
case 8:
case 16:
@@ -360,9 +366,21 @@
continue;
/* try to set the mode */
+ TRACE(PREFIX_I "...trying w %i h %i vw %i vh %i bpp %i...\n",
+ (int)my_mode.xres, (int)my_mode.yres,
+ (int)my_mode.xres_virtual, (int)my_mode.yres_virtual,
+ my_mode.bits_per_pixel);
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0) {
+ TRACE(PREFIX_I "...ioctl ok w %i h %i vw %i vh %i bpp %i...\n",
+ (int)my_mode.xres, (int)my_mode.yres,
+ (int)my_mode.xres_virtual, (int)my_mode.yres_virtual,
+ my_mode.bits_per_pixel);
if (my_mode.bits_per_pixel == (unsigned)color_depth)
goto got_a_nice_mode;
+ }
+ else
+ {
+ TRACE(PREFIX_I "...ioctl said %i %s\n", errno, strerror(errno));
}
}
@@ -377,6 +395,9 @@
close(fbfd);
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Framebuffer resolution not available"));
TRACE(PREFIX_E "Resolution %dx%d not available...\n", w, h);
+ /* bugfix: if we don't reset fb_mode_read than the next call to
+ set_gfx_mode() is going to fail with "bad file descriptor" */
+ fb_mode_read = FALSE;
return NULL;
got_a_nice_mode:
@@ -387,6 +408,7 @@
__al_linux_console_text();
close(fbfd);
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Framebuffer ioctl() failed"));
+ fb_mode_read = FALSE;
return NULL;
}
@@ -399,6 +421,7 @@
ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can't map framebuffer"));
TRACE(PREFIX_E "Couldn't map framebuffer for %dx%d. Restored old "
"resolution.\n", w, h);
+ fb_mode_read = FALSE;
return NULL;
}
@@ -428,6 +451,7 @@
__al_linux_console_text();
close(fbfd);
TRACE(PREFIX_E "Couldn't make bitmap `b', sorry.\n");
+ fb_mode_read = FALSE;
return NULL;
}