[AD] fbcon driver color depth |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
A call to set_gfx_mode(GFX_FBCON, ...) will crash if color depth
unsupported by the framebuffer was selected. I'm using vesafb that can't
change color depth selected at boot time.
Graphic mode is set in src/linux/fbcon.c, line 334:
/* try to set the mode */
if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0)
goto got_a_nice_mode;
Apparently, setting a mode with unsupported color depth will not fail.
It will just modify 'my_mode' to the mode that was actually set. I
assume that other fields in 'my_mode' are also corrected. I couldn't
find any documentation that would confirm that. I couldn't find any
documentation at all for that matter.
Attached is a fix that is rather simple: update allegro to the actual
color depth and continue, using 'my_mode.bits_per_pixel' instead of
requested 'color_depth'.
Any opinions?
--
Milan Mimica
http://sparklet.sf.net
Index: src/linux/fbcon.c
===================================================================
--- src/linux/fbcon.c (revision 7682)
+++ src/linux/fbcon.c (working copy)
@@ -331,8 +331,10 @@
continue;
/* try to set the mode */
- if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0)
+ if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &my_mode) == 0) {
+ set_color_depth(my_mode.bits_per_pixel);
goto got_a_nice_mode;
+ }
}
/* oops! */
@@ -386,11 +388,12 @@
v_w = w;
v_h = h;
- p += (my_mode.xres-w)/2 * BYTES_PER_PIXEL(color_depth) +
+ p += (my_mode.xres-w)/2 * BYTES_PER_PIXEL(my_mode.bits_per_pixel) +
(my_mode.yres-h)/2 * stride;
}
- b = _make_bitmap(v_w, v_h, (unsigned long)p, &gfx_fbcon, color_depth, stride);
+ b = _make_bitmap(v_w, v_h, (unsigned long)p, &gfx_fbcon,
+ my_mode.bits_per_pixel, stride);
if (!b) {
ioctl(fbfd, FBIOPUT_VSCREENINFO, &orig_mode);
munmap(fbaddr, fix_info.smem_len);
@@ -413,7 +416,7 @@
gfx_fbcon.desc = fb_desc;
/* set up the truecolor pixel format */
- switch (color_depth) {
+ switch (my_mode.bits_per_pixel) {
#ifdef ALLEGRO_COLOR16