diff options
Diffstat (limited to 'src/mesa/drivers/ggi/display')
-rw-r--r-- | src/mesa/drivers/ggi/display/.gitignore | 1 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev.conf.in | 4 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev_mode.c | 130 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev_visual.c | 138 |
4 files changed, 273 insertions, 0 deletions
diff --git a/src/mesa/drivers/ggi/display/.gitignore b/src/mesa/drivers/ggi/display/.gitignore new file mode 100644 index 0000000000..98858db2c0 --- /dev/null +++ b/src/mesa/drivers/ggi/display/.gitignore @@ -0,0 +1 @@ +fbdev.conf diff --git a/src/mesa/drivers/ggi/display/fbdev.conf.in b/src/mesa/drivers/ggi/display/fbdev.conf.in new file mode 100644 index 0000000000..2acb89426f --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev.conf.in @@ -0,0 +1,4 @@ +# GGIMesa fbdev target configuration +.root: @ggi_libdir@/ggi/mesa/default + +tgt-fbdev-kgicon-generic-mesa genkgi.so diff --git a/src/mesa/drivers/ggi/display/fbdev_mode.c b/src/mesa/drivers/ggi/display/fbdev_mode.c new file mode 100644 index 0000000000..85c35ffe0e --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev_mode.c @@ -0,0 +1,130 @@ +/****************************************************************************** + + display-fbdev-mesa + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/ioctl.h> +#include <sys/mman.h> + +#include <linux/fb.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/display_fbdev.h> +#include <ggi/mesa/debug.h> + +#ifndef MAP_FAILED +#define MAP_FAILED ((void*)-1) +#endif + +#define FB_KLUDGE_FONTX 8 +#define FB_KLUDGE_FONTY 16 +#define FB_KLUDGE_TEXTMODE 13 +#define TIMINGFILE "/etc/fb.modes" + +int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + + arguments = '\0'; + + switch(num) { + case 0: + if (priv->oldpriv->have_accel) { + strcpy(apiname, priv->oldpriv->accel); + return 0; + } + break; + } + + return -1; +} + +static int do_setmode(ggi_visual *vis) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + int err, id; + char libname[GGI_API_MAXLEN], libargs[GGI_API_MAXLEN]; + ggi_graphtype gt; + + _ggiZapMode(vis, ~GGI_DL_OPDISPLAY); + priv->have_accel = 0; + + for (id = 1; GGIMesa_fbdev_getapi(vis, id, libname, libargs) == 0; id++) { + if (_ggiOpenDL(vis, libname, libargs, NULL) == 0) { + GGIMESADPRINT_LIBS(stderr, "display-fbdev-mesa: Error opening the " + "%s (%s) library.\n", libname, libargs); + return GGI_EFATAL; + } + + GGIMESADPRINT_CORE("Success in loading %s (%s)\n", + libname, libargs); + } + + if (priv->oldpriv->accel && + _ggiOpenDL(vis, priv->accel, NULL, NULL) != 0) { + priv->have_accel = 1; + } else { + priv->have_accel = 0; + } + vis->accelactive = 0; + + ggiIndicateChange(vis, GGI_CHG_APILIST); + + GGIMESADPRINT_CORE("display-fbdev-mesa: do_setmode SUCCESS\n"); + + return 0; +} + + +int GGIMesa_fbdev_setmode(ggi_visual *vis, ggi_mode *mode) +{ + int err; + + if ((err = ggiCheckMode(vis, mode)) != 0) { + return err; + } + + GGIMESADPRINT_CORE("display-fbdev-mesa: setmode %dx%d#%dx%dF%d[0x%02x]\n", + mode->visible.x, mode->visible.y, + mode->virt.x, mode->virt.y, + mode->frames, mode->graphtype); + + memcpy(LIBGGI_MODE(vis), mode, sizeof(ggi_mode)); + + /* Now actually set the mode */ + err = do_setmode(vis); + if (err != 0) { + return err; + } + + GGIMESADPRINT_CORE("display-fbdev-mesa: setmode success.\n"); + + return 0; +} diff --git a/src/mesa/drivers/ggi/display/fbdev_visual.c b/src/mesa/drivers/ggi/display/fbdev_visual.c new file mode 100644 index 0000000000..f0c1771c77 --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev_visual.c @@ -0,0 +1,138 @@ +/****************************************************************************** + + display-fbdev-mesa: visual handling + + Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org] + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +****************************************************************************** +*/ + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> +#include <ggi/mesa/display_fbdev.h> +#include <ggi/mesa/debug.h> + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <ctype.h> +#include <errno.h> +#include <unistd.h> +#include <fcntl.h> +#include <sys/stat.h> + + +#ifdef HAVE_SYS_VT_H +#include <sys/vt.h> +#else +#include <linux/vt.h> +#endif +#ifdef HAVE_LINUX_KDEV_T_H +#include <linux/kdev_t.h> +#endif +#include <linux/tty.h> + +#define MAX_DEV_LEN 63 +#define DEFAULT_FBNUM 0 + +static char accel_prefix[] = "tgt-fbdev-"; +#define PREFIX_LEN (sizeof(accel_prefix)) + +typedef struct { + int async; + char *str; +} accel_info; + +static accel_info accel_strings[] = { + { 0, "kgicon-generic",}, /* no accel - check for KGIcon */ + { 0, NULL }, /* Atari Blitter */ +}; + +#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) + + + +static int GGIopen(ggi_visual *vis, struct ggi_dlhandle *dlh, + const char *args, void *argptr, uint32 *dlret) +{ + int err; + struct fbdev_priv_mesa *priv; + ggifunc_getapi *oldgetapi; + + + priv->oldpriv = LIBGGI_PRIVATE(vis); /* Hook back */ + + GGIMESA_PRIV(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa)); + if (priv == NULL) { + fprintf(stderr, "GGIMesa: Failed to allocate fbdev private data\n"); + return GGI_ENOMEM; + } + + oldgetapi = vis->opdisplay->getapi; + vis->opdisplay->getapi = GGIMesa_fbdev_getapi; + changed(vis, GGI_CHG_APILIST); + + /* If the accel sublibs didn't sucessfuly hook a driver, + * back up and keep looking */ + if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || + (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) + { + vis->opdisplay->getapi = oldgetapi; + } + + *dlret = GGI_DL_EXTENSION; + return 0; +} + + +static int GGIclose(ggi_visual *vis, struct ggi_dlhandle *dlh) +{ + struct fbdev_priv_mesa *priv = GGIMESA_PRIV(vis); + + if (priv) { + LIBGGI_PRIVATE(vis) = priv->oldpriv; + free(priv); + } + + return 0; +} + + +int MesaGGIdl_fbdev_mesa(int func, void **funcptr) +{ + switch (func) { + case GGIFUNC_open: + *funcptr = GGIopen; + return 0; + case GGIFUNC_exit: + *funcptr = NULL; + return 0; + case GGIFUNC_close: + *funcptr = GGIclose; + return 0; + default: + *funcptr = NULL; + } + + return GGI_ENOTFOUND; +} + + +#include <ggi/internal/ggidlinit.h> |