Root/liballegro/patches/020-fix-fbcon-init.patch

1Index: allegro-4.4.2/src/linux/fbcon.c
2===================================================================
3--- allegro-4.4.2.orig/src/linux/fbcon.c 2011-06-02 11:18:50.000000000 +0200
4+++ allegro-4.4.2/src/linux/fbcon.c 2011-06-16 22:13:10.000000000 +0200
5@@ -19,6 +19,10 @@
6  * See readme.txt for copyright information.
7  */
8 
9+/* #define DEBUGMODE */
10+
11+#include <errno.h>
12+#include <string.h>
13 
14 #include "allegro.h"
15 #include "allegro/internal/aintern.h"
16@@ -251,6 +255,7 @@
17    if (__al_linux_console_graphics() != 0) {
18       ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_mode);
19       close(fbfd);
20+ fb_mode_read = FALSE;
21       return NULL;
22    }
23 
24@@ -263,6 +268,7 @@
25      case -1:
26         /* let's see if we can get the actual screen mode */
27         /* shouldn't we be keeping the previous color depth setting? */
28+ TRACE(PREFIX_I "...orig bpp %i...\n", (int)orig_mode.bits_per_pixel);
29         switch (orig_mode.bits_per_pixel) {
30            case 8:
31            case 16:
32@@ -360,9 +366,21 @@
33      continue;
34 
35       /* try to set the mode */
36+ TRACE(PREFIX_I "...trying w %i h %i vw %i vh %i bpp %i...\n",
37+ (int)my_mode.xres, (int)my_mode.yres,
38+ (int)my_mode.xres_virtual, (int)my_mode.yres_virtual,
39+ my_mode.bits_per_pixel);
40       if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0) {
41+ TRACE(PREFIX_I "...ioctl ok w %i h %i vw %i vh %i bpp %i...\n",
42+ (int)my_mode.xres, (int)my_mode.yres,
43+ (int)my_mode.xres_virtual, (int)my_mode.yres_virtual,
44+ my_mode.bits_per_pixel);
45      if (my_mode.bits_per_pixel == (unsigned)color_depth)
46         goto got_a_nice_mode;
47+ }
48+ else
49+ {
50+ TRACE(PREFIX_I "...ioctl said %i %s\n", errno, strerror(errno));
51       }
52    }
53 
54@@ -377,6 +395,9 @@
55    close(fbfd);
56    ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Framebuffer resolution not available"));
57    TRACE(PREFIX_E "Resolution %dx%d not available...\n", w, h);
58+ /* bugfix: if we don't reset fb_mode_read than the next call to
59+ set_gfx_mode() is going to fail with "bad file descriptor" */
60+ fb_mode_read = FALSE;
61    return NULL;
62 
63    got_a_nice_mode:
64@@ -387,6 +408,7 @@
65       __al_linux_console_text();
66       close(fbfd);
67       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Framebuffer ioctl() failed"));
68+ fb_mode_read = FALSE;
69       return NULL;
70    }
71 
72@@ -399,6 +421,7 @@
73       ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE, get_config_text("Can't map framebuffer"));
74       TRACE(PREFIX_E "Couldn't map framebuffer for %dx%d. Restored old "
75         "resolution.\n", w, h);
76+ fb_mode_read = FALSE;
77       return NULL;
78    }
79 
80@@ -428,6 +451,7 @@
81       __al_linux_console_text();
82       close(fbfd);
83       TRACE(PREFIX_E "Couldn't make bitmap `b', sorry.\n");
84+ fb_mode_read = FALSE;
85       return NULL;
86    }
87 
88

Archive Download this file



interactive