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: Sat, 6 Jan 2007 22:39:47 +0100
On Saturday 06 January 2007 21:44, Evert Glebbeek wrote:
> I'll see if I can hack something together then... been a while, so I may
be
> a bit rusty. I also won't be able to test it, but I'm sure someone else
> can do that for me.
Patch attached. I actually also added a resolution getter while I was at
it.
Tested in so far as I can say that it compiles on my system (so not
actually tested at all). I'm not sure it does the right thing when it
comes to loading the driver as a module.
I find the code a bit hackish, in particular because the fbdev graphics
driver now inserts part of itself into the system driver. Ugly, but cannot
be helped that I can see.
Tests and comments welcome!
Evert
Index: src/linux/fbcon.c
===================================================================
--- src/linux/fbcon.c (revision 7690)
+++ 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;
}
@@ -1105,8 +1135,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 */
Index: src/linux/lsystem.c
===================================================================
--- src/linux/lsystem.c (revision 7690)
+++ 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