Re: [AD] fbcon driver color depth |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
- To: Coordination of admins/developers of the game programming library Allegro <alleg-developers@xxxxxxxxxx>
- Subject: Re: [AD] fbcon driver color depth
- From: Evert Glebbeek <eglebbk@xxxxxxxxxx>
- Date: Sun, 7 Jan 2007 11:47:27 +0100
On Sunday 07 January 2007 04:03, Milan Mimica wrote:
> It works. Using vesafb driver in 800x600x16 mode, with fbcon as a module.
Good.
Could you also test with modules disabled?
> Just that there should be a "fb_mode_read = FALSE;" in fbexit() because
> some drivers are able to change resolution and color depth I think.
Ok, revised patch attached.
Evert
Index: src/linux/lsystem.c
===================================================================
--- src/linux/lsystem.c (revision 7693)
+++ src/linux/lsystem.c (working copy)
@@ -42,6 +42,13 @@
#endif
+#if (defined ALLEGRO_LINUX_FBCON) && (!defined ALLEGRO_WITH_MODULES)
+/* Functions for querying the framebuffer, for the fbcon driver */
+extern int __al_linux_get_fb_color_depth(void);
+extern int __al_linux_get_fb_resolution(int *width, int *height);
+#endif
+
+
static int sys_linux_init(void);
static void sys_linux_exit(void);
static void sys_linux_message (AL_CONST char *msg);
@@ -86,8 +93,13 @@
NULL, /* get_vtable */
__al_linux_set_display_switch_mode,
__al_linux_display_switch_lock,
+#if (defined ALLEGRO_LINUX_FBCON) && (!defined ALLEGRO_WITH_MODULES)
+ __al_linux_get_fb_color_depth,
+ __al_linux_get_fb_resolution,
+#else
NULL, /* desktop_color_depth */
NULL, /* get_desktop_resolution */
+#endif
NULL, /* get_gfx_safe_mode */
_unix_yield_timeslice,
#ifdef HAVE_LIBPTHREAD
Index: src/linux/fbcon.c
===================================================================
--- src/linux/fbcon.c (revision 7693)
+++ src/linux/fbcon.c (working copy)
@@ -97,6 +97,8 @@
static char fb_desc[256] = EMPTY_STRING; /* description string */
+static int fb_mode_read = FALSE; /* has orig_mode been read? */
+
static struct fb_fix_screeninfo fix_info; /* read-only video mode info */
static struct fb_var_screeninfo orig_mode; /* original video mode info */
static struct fb_var_screeninfo my_mode; /* my video mode info */
@@ -188,6 +190,33 @@
+/* __al_linux_get_fb_color_depth:
+ * Get the colour depth of the framebuffer
+ */
+int __al_linux_get_fb_color_depth(void)
+{
+ if ( (!fb_mode_read) && (fb_open_device() != 0) )
+ return 0;
+ return orig_mode.bits_per_pixel;
+}
+
+
+
+/* __al_linux_get_fb_resolution:
+ * Get the resolution of the framebuffer
+ */
+int __al_linux_get_fb_resolution(int *width, int *height)
+{
+ if ( (!fb_mode_read) && (fb_open_device() != 0) )
+ return -1;
+
+ *width = orig_mode.xres;
+ *height = orig_mode.yres;
+ return 0;
+}
+
+
+
/* fb_init:
* Sets a graphics mode.
*/
@@ -199,7 +228,7 @@
char tmp[16];
/* open framebuffer and store info in global variables */
- if (fb_open_device() != 0)
+ if ( (!fb_mode_read) && (fb_open_device() != 0) )
return NULL;
/* look for a nice graphics mode in several passes */
@@ -548,6 +577,7 @@
}
TRACE(PREFIX_I "fb device %s opened successfully.\n", fname);
+ fb_mode_read = TRUE;
return 0;
}
@@ -566,6 +596,7 @@
close(fbfd);
__al_linux_console_text();
+ fb_mode_read = FALSE;
}
@@ -1105,8 +1136,15 @@
*/
void _module_init(int system_driver)
{
- if (system_driver == SYSTEM_LINUX)
+ if (system_driver == SYSTEM_LINUX) {
_unix_register_gfx_driver(GFX_FBCON, &gfx_fbcon, TRUE, TRUE);
+ /* Register resolution and colour depth getters.
+ * This is a bit ugly because these are actually part of the
+ * system driver rather than the graphics driver...
+ */
+ system_linux.desktop_color_depth = __al_linux_get_fb_color_depth;
+ system_linux.get_desktop_resolution = __al_linux_get_fb_resolution;
+ }
}
#endif /* ifdef ALLEGRO_MODULE */