diff options
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r-- | src/mesa/drivers/ggi/default/genkgi.conf.in | 4 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/genkgi.h | 43 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/genkgi_mode.c | 61 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/genkgi_visual.c | 184 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear.c | 333 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear_15.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear_16.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear_24.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear_32.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/linear_8.c | 35 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/default/stubs.c | 409 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev.conf.in | 6 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev_mode.c | 134 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/display/fbdev_visual.c | 157 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/include/ggi/mesa/debug.h | 1 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h | 20 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h | 90 | ||||
-rw-r--r-- | src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h | 22 |
18 files changed, 1639 insertions, 0 deletions
diff --git a/src/mesa/drivers/ggi/default/genkgi.conf.in b/src/mesa/drivers/ggi/default/genkgi.conf.in new file mode 100644 index 00000000000..8b3a25431b6 --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi.conf.in @@ -0,0 +1,4 @@ +# GGIMesa genkgi helper configuration +.root: @ggi_libdir@/ggi/mesa/default/ + +tgt-fbdev-kgicon-savage4-mesa kgi/savage4.so diff --git a/src/mesa/drivers/ggi/default/genkgi.h b/src/mesa/drivers/ggi/default/genkgi.h new file mode 100644 index 00000000000..135c9aeec3d --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi.h @@ -0,0 +1,43 @@ +/* $Id: genkgi.h,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + GGIMesa - KGIcon specific overrides for fbcon-mesa + API header + + Copyright (C) 1999 Creative Labs + + 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/display/fbdev.h> + +//ggifunc_setmode GGIMesa_genkgi_setmode; +ggifunc_getapi GGIMesa_genkgi_getapi; + +typedef struct genkgi_hook_mesa +{ + char accel[100]; + int have_accel; + void *accelpriv; +} genkgi_hook_mesa; + +#define GENKGI_PRIVATE(vis) ((genkgi_hook_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv) diff --git a/src/mesa/drivers/ggi/default/genkgi_mode.c b/src/mesa/drivers/ggi/default/genkgi_mode.c new file mode 100644 index 00000000000..81cf6c84071 --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi_mode.c @@ -0,0 +1,61 @@ +/* $Id: genkgi_mode.c,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + display-fbdev-kgicon-generic-mesa + + Copyright (C) 1999 Creative Labs + + 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 "genkgi.h" + +int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments) +{ + genkgi_hook_mesa *priv = GENKGI_PRIVATE(vis); + + gl_ggiDEBUG("Entered mesa_genkgi_getapi, num=%d\n", num); + + strcpy(arguments, ""); + + switch(num) + { + case 0: + if (priv->have_accel) + { + strcpy(apiname, priv->accel); + return 0; + } + break; + } + return -1; +} diff --git a/src/mesa/drivers/ggi/default/genkgi_visual.c b/src/mesa/drivers/ggi/default/genkgi_visual.c new file mode 100644 index 00000000000..1c90120b3e6 --- /dev/null +++ b/src/mesa/drivers/ggi/default/genkgi_visual.c @@ -0,0 +1,184 @@ +/* $Id: genkgi_visual.c,v 1.1 1999/08/21 05:59:29 jtaylor Exp $ +****************************************************************************** + + display-fbdev-mesa-generic-kgi: visual handling + + Copyright (C) 1998 Andrew Apted [[email protected]] + Copyright (C) 1999 Marcus Sundberg [[email protected]] + Copyright (C) 1999 Creative Labs + + 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 "genkgi.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> + + +static int refcount = 0; +static int vtnum; +static void *_ggi_fbdev_lock = NULL; +#ifdef FBIOGET_CON2FBMAP +static struct fb_con2fbmap origconmap; +#endif + +#define MAX_DEV_LEN 63 +#define DEFAULT_FBNUM 0 + +static char accel_prefix[] = "tgt-fbdev-kgicon-"; +#define PREFIX_LEN (sizeof(accel_prefix)) + +typedef struct { + int async; + char *str; +} accel_info; + +static accel_info accel_strings[] = +{ + { 0, "savage4" }, /* S3 Savage4 */ +}; + +#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info)) + +/* FIXME: These should be defined in the makefile system */ +#define CONF_FILE "/usr/local/etc/ggi/mesa/targets/genkgi.conf" +void *_configHandle; +char confstub[512] = CONF_FILE; +char *conffile = confstub; + +static int changed(ggi_visual_t vis, int whatchanged) +{ + gl_ggiDEBUG("Entered ggimesa_genkgi_changed\n"); + switch (whatchanged) + { + case GGI_CHG_APILIST: + { + char api[256]; + char args[256]; + int i; + const char *fname; + ggi_dlhandle *lib; + + for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) + { + strcat(api, "-mesa"); + gl_ggiDEBUG("ggimesa_genkgi_changed: api=%s, i=%d\n", api, i); + fname = ggMatchConfig(_configHandle, api, NULL); + if (fname == NULL) + { + /* No special implementation for this sublib */ + continue; + } + + lib = ggiExtensionLoadDL(vis, fname, args, NULL); + } + } + break; + } + return 0; +} + +int GGIdlinit(ggi_visual *vis, const char *args, void *argptr) +{ + genkgi_hook_mesa *priv; + char libname[256], libargs[256]; + int id, err; + struct stat junk; + ggifunc_getapi *oldgetapi; + + gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit start\n"); + + GENKGI_PRIVATE(vis) = priv = malloc(sizeof(genkgi_hook_mesa)); + if (priv == NULL) + { + fprintf(stderr, "Failed to allocate genkgi_hook!\n"); + return GGI_DL_ERROR; + } + + err = ggLoadConfig(conffile, &_configHandle); + if (err != GGI_OK) + { + gl_ggiPrint("display-fbdev: Couldn't open %s\n", conffile); + return err; + } + + /* Hack city here. We need to probe the KGI driver properly to discover + * the acceleration type. + */ + priv->have_accel = 0; +#if 1 + if (stat("/proc/savage4", &junk) == 0) + { + sprintf(priv->accel, "%s%s", accel_prefix, "savage4"); + priv->have_accel = 1; + gl_ggiDEBUG("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel); + } + +#endif + /* Mode management */ + vis->opdisplay->getapi = GGIMesa_genkgi_getapi; + + ggiIndicateChange(vis, GGI_CHG_APILIST); + + + /* Give the accel sublibs a chance to set up a driver */ + if (priv->have_accel == 1) + { + oldgetapi = vis->opdisplay->getapi; + vis->opdisplay->getapi = GGIMesa_genkgi_getapi; + changed(vis, GGI_CHG_APILIST); + /* If the accel sublibs didn't produce, back up + * and keep looking */ + if ((LIBGGI_MESAEXT(vis)->update_state == NULL) || + (LIBGGI_MESAEXT(vis)->setup_driver == NULL)) + vis->opdisplay->getapi = oldgetapi; + } + + gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit finished\n"); + + return 0; +} + +int GGIdlcleanup(ggi_visual *vis) +{ + return 0; +} + +#include <ggi/internal/ggidlinit.h> diff --git a/src/mesa/drivers/ggi/default/linear.c b/src/mesa/drivers/ggi/default/linear.c new file mode 100644 index 00000000000..6acdf4d8012 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear.c @@ -0,0 +1,333 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> +#include <ggi/mesa/ggimesa_int.h> + +#define RMASK ((1<<R)-1) +#define GMASK ((1<<G)-1) +#define BMASK ((1<<B)-1) + +#define RS (8-R) +#define GS (8-G) +#define BS (8-B) + + +/**********************************************************************/ +/***** Write spans of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLuint ci[], + const GLubyte mask[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + if (mask) + { + while (n--) { + if (*mask++) *fb=*ci; + fb++; + ci++; + } + } + else + { + while (n--) *fb++ = *ci++; + } +} + +void GGIwrite_ci8_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte ci[], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + + if (mask) + { + while (n--) { + if (*mask++) *fb=*ci; + fb++; + ci++; + } + } + else + { + while (n--) *fb++ = *ci++; + } +} + + +void GGIwrite_rgba_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], + const GLubyte mask[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + + if (mask) + { + while (n--) { + if (*mask++) { + *fb= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + } + fb++; + rgba++; + } + } + else + { + while (n--) { + *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B)| + ((rgba[0][BCOMP]>>BS)); + rgba++; + } + } +} + +void GGIwrite_rgb_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][3], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + if (mask) + { + while (n--) { + if (*mask++) { + *fb= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + } + fb++; + rgba++; + } + } + else + { + while (n--) { + *fb++= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + rgba++; + } + } +} + + +void GGIwrite_mono_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[]) +{ + FB_TYPE *fb; + FB_TYPE color; + + if (mask) + { + fb=LFB(FB_TYPE,x,FLIP(y)); + color=(FB_TYPE) GGICTX->color; + + while (n--) + { + if (*mask++) *fb=color; + fb++; + } + } + else + { + ggiDrawHLine(VIS,x,FLIP(y),n); + } +} + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + while (n--) + *ci++=(GLuint)*fb++; +} + +void GGIread_rgba_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + FB_TYPE *fb=LFB(FB_TYPE,x,FLIP(y)); + FB_TYPE color; + + while (n--) + { + color=*fb++; + rgba[0][RCOMP] = (GLubyte) (color>>(G+B))<<RS; + rgba[0][GCOMP] = (GLubyte) ((color>>B)& ((1<<G)-1))<<GS; + rgba[0][BCOMP] = (GLubyte) (color & ((1<<B)-1))<<BS; + rgba[0][ACOMP] =0; + rgba++; + } +} + +/**********************************************************************/ +/***** Write arrays of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint ci[], const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + + while (n--) { + if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=*ci; + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_pixels(const GLcontext *ctx, + GLuint n, + const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color=(FB_TYPE) GGICTX->color; + + while (n--) { + if (*mask++) *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + x++; + y++; + } +} + +void GGIwrite_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte rgba[][4], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color; + + while (n--) { + if (*mask++) { + color= ((rgba[0][RCOMP]>>RS) << (G+B)) | + ((rgba[0][GCOMP]>>GS) << B) | + ((rgba[0][BCOMP]>>BS)); + *(fb+ *x + FLIP(*y)*GGICTX->width)=color; + } + x++;y++; + rgba++; + } +} + + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + + while (n--) { + if (*mask++) + *ci=*(fb+ *x + FLIP(*y)*GGICTX->width); + ci++; + x++; + y++; + } +} + +void GGIread_rgba_pixels(const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], + const GLubyte mask[] ) +{ + FB_TYPE *fb=LFB(FB_TYPE,0,0); + FB_TYPE color; + + while (n--) + { + if (*mask++) + { + color=*(fb+ *x + FLIP(*y)*GGICTX->width); + rgba[0][RCOMP] =(GLubyte)(color>>(G+B))<<RS; + rgba[0][GCOMP] =(GLubyte)((color>>B)& ((1<<G)-1))<<GS; + rgba[0][BCOMP] =(GLubyte) (color & ((1<<B)-1))<<BS; + rgba[0][ACOMP] =0; + } + x++; y++; + rgba++; + } +} + +int GGIsetup_driver(GGIMesaContext ggictx,struct ggi_mesa_info *info) +{ + GLcontext *ctx=ggictx->gl_ctx; + + ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span; + ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span; + ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span; + ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels; + ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels; + + ctx->Driver.WriteCI32Span = GGIwrite_ci32_span; + ctx->Driver.WriteCI8Span = GGIwrite_ci8_span; + ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span; + ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels; + ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels; + + ctx->Driver.ReadCI32Span = GGIread_ci32_span; + ctx->Driver.ReadRGBASpan = GGIread_rgba_span; + ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels; + ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels; + + info->red_bits=R; + info->green_bits=G; + info->blue_bits=B; + + return 0; +} + +int GGIdlinit(ggi_visual_t vis,const char *version,void *argptr) +{ + LIBGGI_MESAEXT(vis)->setup_driver=GGIsetup_driver; + + return 0; +} + +int GGIdlcleanup(ggi_visual_t vis) +{ + return 0; +} diff --git a/src/mesa/drivers/ggi/default/linear_15.c b/src/mesa/drivers/ggi/default/linear_15.c new file mode 100644 index 00000000000..8eb89f97954 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_15.c @@ -0,0 +1,35 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 5 +#define G 5 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 15 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_16.c b/src/mesa/drivers/ggi/default/linear_16.c new file mode 100644 index 00000000000..d7eeef1123a --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_16.c @@ -0,0 +1,35 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 5 +#define G 6 +#define B 5 + +#define FB_TYPE uint16 +#define FB_BITS 16 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_24.c b/src/mesa/drivers/ggi/default/linear_24.c new file mode 100644 index 00000000000..6058a2a168a --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_24.c @@ -0,0 +1,35 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 24 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_32.c b/src/mesa/drivers/ggi/default/linear_32.c new file mode 100644 index 00000000000..13631b4747c --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_32.c @@ -0,0 +1,35 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 8 +#define G 8 +#define B 8 + +#define FB_TYPE uint32 +#define FB_BITS 32 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/linear_8.c b/src/mesa/drivers/ggi/default/linear_8.c new file mode 100644 index 00000000000..027f21f80d9 --- /dev/null +++ b/src/mesa/drivers/ggi/default/linear_8.c @@ -0,0 +1,35 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <ggi/mesa/ggimesa.h> + +#define R 3 +#define G 3 +#define B 2 + +#define FB_TYPE uint8 +#define FB_BITS 8 + +#include "../common/linear.c" + diff --git a/src/mesa/drivers/ggi/default/stubs.c b/src/mesa/drivers/ggi/default/stubs.c new file mode 100644 index 00000000000..52f55d409d3 --- /dev/null +++ b/src/mesa/drivers/ggi/default/stubs.c @@ -0,0 +1,409 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#include <stdio.h> + +#include <ggi/internal/ggi-dl.h> +#include <ggi/mesa/ggimesa_int.h> + +/**********************************************************************/ +/***** Write spans of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLuint ci[], + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiPutPixel(VIS,x,y,*ci); + x++; + ci++; + } + } + else + { + while (n--) ggiPutPixel(VIS,x++,y,*ci++); + } +} + +void GGIwrite_ci8_span(const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte ci[], + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiPutPixel(VIS,x,y,*ci); + x++; + ci++; + } + } + else + { + while (n--) ggiPutPixel(VIS,x++,y,*ci++); + } +} + +void GGIwrite_mono_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte mask[] ) +{ + y=FLIP(y); + if (mask) + { + while (n--) { + if (*mask++) ggiDrawPixel(VIS,x,y); + x++; + } + } + else + { + ggiDrawHLine(VIS,x,y,n); + } +} + +void GGIwrite_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][4], + const GLubyte mask[]) +{ + ggi_color rgb; + ggi_pixel col; + y=FLIP(y); + + if (mask) + { + while (n--) { + if (*mask++) + { + rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT; + col=ggiMapColor(VIS,&rgb); + ggiPutPixel(VIS,x,y,col); + } + x++; + rgba++; + } + } + else + { + while (n--) + { + rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT; + col=ggiMapColor(VIS,&rgb); + ggiPutPixel(VIS,x++,y,col); + rgba++; + } + } +} +void GGIwrite_rgb_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + const GLubyte rgba[][3], + const GLubyte mask[] ) +{ + ggi_color rgb; + ggi_pixel col; + y=FLIP(y); + + if (mask) + { + while (n--) { + if (*mask++) + { + rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT; + col=ggiMapColor(VIS,&rgb); + ggiPutPixel(VIS,x,y,col); + } + x++; + rgba++; + } + } + else + { + while (n--) + { + rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT; + col=ggiMapColor(VIS,&rgb); + ggiPutPixel(VIS,x++,y,col); + rgba++; + } + } +} + + + +/**********************************************************************/ +/***** Read spans of pixels *****/ +/**********************************************************************/ + + +void GGIread_ci32_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, GLuint ci[]) +{ + y = FLIP(y); + while (n--) + ggiGetPixel(VIS, x++, y,ci++); +} + +void GGIread_rgba_span( const GLcontext *ctx, + GLuint n, GLint x, GLint y, + GLubyte rgba[][4]) +{ + ggi_color rgb; + ggi_pixel col; + + y=FLIP(y); + + while (n--) + { + ggiGetPixel(VIS,x++,y,&col); + ggiUnmapPixel(VIS,col,&rgb); + rgba[0][RCOMP] = (GLubyte) (rgb.r >> SHIFT); + rgba[0][GCOMP] = (GLubyte) (rgb.g >> SHIFT); + rgba[0][BCOMP] = (GLubyte) (rgb.b >> SHIFT); + rgba[0][ACOMP] = 0; + rgba++; + } +} + +/**********************************************************************/ +/***** Write arrays of pixels *****/ +/**********************************************************************/ + +void GGIwrite_ci32_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLuint ci[], const GLubyte mask[] ) +{ + while (n--) { + if (*mask++) ggiPutPixel(VIS,*x, FLIP(*y),*ci); + ci++; + x++; + y++; + } +} + +void GGIwrite_mono_pixels( const GLcontext *ctx, + GLuint n, + const GLint x[], const GLint y[], + const GLubyte mask[] ) +{ + while (n--) { + if (*mask++) ggiDrawPixel(VIS,*x,FLIP(*y)); + x++; + y++; + } +} + +void GGIwrite_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + const GLubyte rgba[][4], + const GLubyte mask[] ) +{ + ggi_pixel col; + ggi_color rgb; + while (n--) { + if (*mask++) { + rgb.r=(uint16)(rgba[0][RCOMP]) << SHIFT; + rgb.g=(uint16)(rgba[0][GCOMP]) << SHIFT; + rgb.b=(uint16)(rgba[0][BCOMP]) << SHIFT; + col=ggiMapColor(VIS,&rgb); + ggiPutPixel(VIS,*x,FLIP(*y),col); + } + x++;y++; + rgba++; + } +} + + +/**********************************************************************/ +/***** Read arrays of pixels *****/ +/**********************************************************************/ + +void GGIread_ci32_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLuint ci[], const GLubyte mask[]) +{ + while (n--) { + if (*mask++) + ggiGetPixel(VIS, *x, FLIP(*y) ,ci); + ci++; + x++; + y++; + } +} + +void GGIread_rgba_pixels( const GLcontext *ctx, + GLuint n, const GLint x[], const GLint y[], + GLubyte rgba[][4], + const GLubyte mask[] ) +{ + ggi_color rgb; + ggi_pixel col; + + while (n--) + { + if (*mask++) + { + ggiGetPixel(VIS,*x,FLIP(*y),&col); + ggiUnmapPixel(VIS,col,&rgb); + rgba[0][RCOMP]= rgb.r >> SHIFT; + rgba[0][GCOMP]= rgb.g >> SHIFT; + rgba[0][BCOMP]= rgb.b >> SHIFT; + rgba[0][ACOMP]=0; + } + x++; y++; + rgba++; + } +} + + +triangle_func ggiGetTriangleFunc(GLcontext *ctx); + +int GGIsetup_driver(GGIMesaContext ggictx,struct ggi_mesa_info *info) +{ + GLcontext *ctx=ggictx->gl_ctx; + + ctx->Driver.WriteRGBASpan = GGIwrite_rgba_span; + ctx->Driver.WriteRGBSpan = GGIwrite_rgb_span; + ctx->Driver.WriteMonoRGBASpan = GGIwrite_mono_span; + ctx->Driver.WriteRGBAPixels = GGIwrite_rgba_pixels; + ctx->Driver.WriteMonoRGBAPixels = GGIwrite_mono_pixels; + + ctx->Driver.WriteCI32Span = GGIwrite_ci32_span; + ctx->Driver.WriteCI8Span = GGIwrite_ci8_span; + ctx->Driver.WriteMonoCISpan = GGIwrite_mono_span; + ctx->Driver.WriteCI32Pixels = GGIwrite_ci32_pixels; + ctx->Driver.WriteMonoCIPixels = GGIwrite_mono_pixels; + + ctx->Driver.ReadCI32Span = GGIread_ci32_span; + ctx->Driver.ReadRGBASpan = GGIread_rgba_span; + ctx->Driver.ReadCI32Pixels = GGIread_ci32_pixels; + ctx->Driver.ReadRGBAPixels = GGIread_rgba_pixels; + + return 0; +} + +void GGIupdate_state(GLcontext *ctx) +{ + ctx->Driver.TriangleFunc = ggiGetTriangleFunc(ctx); +} + + +void GGItriangle_flat(GLcontext *ctx,GLuint v0,GLuint v1,GLuint v2,GLuint pv) +{ +#define SETUP_CODE \ + GLubyte r = VB->ColorPtr->data[pv][0]; \ + GLubyte g = VB->ColorPtr->data[pv][1]; \ + GLubyte b = VB->ColorPtr->data[pv][2]; \ + GLubyte a = VB->ColorPtr->data[pv][3]; \ + (*ctx->Driver.Color)(ctx,r,g,b,a); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + ggiDrawHLine(VIS,LEFT,FLIP(Y),RIGHT-LEFT); + +#include "tritemp.h" +} + + +void GGItriangle_flat_depth(GLcontext *ctx,GLuint v0,GLuint v1, + GLuint v2,GLuint pv) +{ +#define INTERP_Z 1 + +#define SETUP_CODE \ + GLubyte r = VB->ColorPtr->data[pv][0]; \ + GLubyte g = VB->ColorPtr->data[pv][1]; \ + GLubyte b = VB->ColorPtr->data[pv][2]; \ + GLubyte a = VB->ColorPtr->data[pv][3]; \ + (*ctx->Driver.Color)(ctx,r,g,b,a); + +#define INNER_LOOP(LEFT,RIGHT,Y) \ + { \ + GLint i,xx=LEFT,yy=FLIP(Y),n=RIGHT-LEFT,length=0; \ + GLint startx=xx; \ + for (i=0;i<n;i++){ \ + GLdepth z=FixedToDepth(ffz); \ + if (z<zRow[i]) \ + { \ + zRow[i]=z; \ + length++; \ + } \ + else \ + { \ + if (length) \ + { \ + ggiDrawHLine(VIS,startx,yy,length); \ + length=0; \ + } \ + startx=xx+i+1; \ + } \ + ffz+=fdzdx; \ + } \ + if (length) ggiDrawHLine(VIS,startx,yy,length); \ + } + +#include "tritemp.h" +} + + +triangle_func ggiGetTriangleFunc(GLcontext *ctx) +{ + if (ctx->Stencil.Enabled) return NULL; + if (ctx->Polygon.SmoothFlag) return NULL; + if (ctx->Polygon.StippleFlag) return NULL; + if (ctx->Texture.Enabled) return NULL; + if (ctx->Light.ShadeModel==GL_SMOOTH) return NULL; + if (ctx->Depth.Test && ctx->Depth.Func != GL_LESS) return NULL; + + if (ctx->Depth.Test) + return GGItriangle_flat_depth; + + return GGItriangle_flat; +} + +int GGIdlinit(ggi_visual_t vis, const char *version, void *argptr) +{ + LIBGGI_MESAEXT(vis)->update_state = GGIupdate_state; + LIBGGI_MESAEXT(vis)->setup_driver = GGIsetup_driver; + + return 0; +} + +int GGIdlcleanup(ggi_visual_t vis) +{ + return 0; +} 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 00000000000..902a8be2ea0 --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev.conf.in @@ -0,0 +1,6 @@ +# GGIMesa fbdev target configuration +.root: @ggi_libdir@/ggi/mesa/default + +tgt-fbdev-kgicon-generic-mesa kgi/genkgi.so + +# .include /usr/local/etc/ggi/mesa/genkgi.conf 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 00000000000..1c882f7f84c --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev_mode.c @@ -0,0 +1,134 @@ +/* $Id: fbdev_mode.c,v 1.1 1999/08/21 05:57:59 jtaylor Exp $ +****************************************************************************** + + display-fbdev-mesa + + Copyright (C) 1999 Creative Labs + + 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> + +#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) +{ + fbdev_hook_mesa *priv = GGIMESA_PRIVATE(vis); + + strcpy(arguments, ""); + + 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) +{ + fbdev_hook_mesa *priv = GGIMESA_PRIVATE(vis); + int err, id; + char libname[256], libargs[256]; + 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) == NULL) + { + fprintf(stderr, "display-fbdev-mesa: Error opening the " + "%s (%s) library.\n", libname, libargs); + return GGI_EFATAL; + } + + gl_ggiDEBUG("Success in loading %s (%s)\n", libname, libargs); + } + + if (priv->oldpriv->accel && + _ggiOpenDL(vis, priv->accel, NULL, NULL) != NULL) { + priv->have_accel = 1; + } + else + { + priv->have_accel = 0; + } + vis->accelactive = 0; + + ggiIndicateChange(vis, GGI_CHG_APILIST); + + gl_ggiDEBUG("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; + } + + gl_ggiDEBUG("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; + } + + gl_ggiDEBUG("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 00000000000..30ad3402260 --- /dev/null +++ b/src/mesa/drivers/ggi/display/fbdev_visual.c @@ -0,0 +1,157 @@ +/* $Id: fbdev_visual.c,v 1.1 1999/08/21 05:57:59 jtaylor Exp $ +****************************************************************************** + + display-fbdev-mesa: visual handling + + Copyright (C) 1998 Andrew Apted [[email protected]] + Copyright (C) 1999 Marcus Sundberg [[email protected]] + Copyright (C) 1999 Creative Labs + + 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 <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)) + +/* FIXME: These should really be defined in the make system */ +#define CONF_FILE "/usr/local/etc/ggi/mesa/targets/fbdev.conf" +void *_configHandle; +char confstub[512] = CONF_FILE; +char *conffile = confstub; + +static int changed(ggi_visual_t vis, int whatchanged) +{ + gl_ggiDEBUG("Entered ggimesa_fbdev_changed\n"); + switch (whatchanged) + { + case GGI_CHG_APILIST: + { + char api[256]; + char args[256]; + int i; + const char *fname; + ggi_dlhandle *lib; + + for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++) + { + strcat(api, "-mesa"); + gl_ggiDEBUG("ggimesa_fbdev_changed: api=%s, i=%d\n", api, i); + fname = ggMatchConfig(_configHandle, api, NULL); + if (fname == NULL) + { + /* No special implementation for this sublib */ + continue; + } + + lib = ggiExtensionLoadDL(vis, fname, args, NULL); + } + } + break; + } + gl_ggiDEBUG("Leaving ggimesa_fbdev_changed\n"); + return 0; +} + +int GGIdlinit(ggi_visual *vis, const char *args, void *argptr) +{ + fbdev_hook_mesa *priv; + char libname[256], libargs[256]; + int id, err; + ggifunc_getapi *oldgetapi; + + gl_ggiDEBUG("display-fbdev-mesa: GGIdlinit start\n"); + + GGIMESA_PRIVATE(vis) = priv = malloc(sizeof(fbdev_hook_mesa)); + if (priv == NULL) { + fprintf(stderr, "Failed to allocate fbdev_hook!\n"); + return GGI_DL_ERROR; + } + + priv->oldpriv = LIBGGI_PRIVATE(vis); // Hook back + + err = ggLoadConfig(conffile, &_configHandle); + if (err != GGI_OK) + { + gl_ggiPrint("display-fbdev: Couldn't open %s\n", conffile); + return err; + } + + LIBGGI_MESAEXT(vis)->update_state = NULL; + LIBGGI_MESAEXT(vis)->setup_driver = NULL; + + 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; + } + + gl_ggiDEBUG("display-fbdev-mesa: GGIdlinit done\n"); + return 0; +} + +int GGIdlcleanup(ggi_visual *vis) +{ + return 0; +} + +#include <ggi/internal/ggidlinit.h> diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/debug.h b/src/mesa/drivers/ggi/include/ggi/mesa/debug.h new file mode 100644 index 00000000000..d14c6e4a1d1 --- /dev/null +++ b/src/mesa/drivers/ggi/include/ggi/mesa/debug.h @@ -0,0 +1 @@ +/* Nothing here yet */ diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h b/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h new file mode 100644 index 00000000000..eee65339782 --- /dev/null +++ b/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h @@ -0,0 +1,20 @@ +#ifndef _GGIMESA_DISPLAY_FBDEV_H +#define _GGIMESA_DISPLAY_FBDEV_H + +#include <ggi/internal/ggi-dl.h> +#include <ggi/display/fbdev.h> + +ggifunc_setmode GGIMesa_fbdev_setmode; +ggifunc_getapi GGIMesa_fbdev_getapi; + +#define FBDEV_PRIV_MESA(vis) ((fbdev_hook_mesa *)(FBDEV_PRIV(vis)->accelpriv)) + +typedef struct fbdev_hook_mesa +{ + char *accel; + int have_accel; + void *accelpriv; + fbdev_hook *oldpriv; // Hooks back to the LibGGI fbdev target's private data +} fbdev_hook_mesa; + +#endif /* _GGIMESA_DISPLAY_FBDEV_H */ diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h new file mode 100644 index 00000000000..c4611fa01b5 --- /dev/null +++ b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa.h @@ -0,0 +1,90 @@ +/* GGI-Driver for MESA + * + * Copyright (C) 1997 Uwe Maurer + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * --------------------------------------------------------------------- + * This code was derived from the following source of information: + * + * svgamesa.c and ddsample.c by Brian Paul + * + */ + +#ifndef _GGIMESA_H +#define _GGIMESA_H + +#include <stdio.h> +#include <stdlib.h> +#include <stdarg.h> +#include "config.h" +#include "context.h" +#include "matrix.h" +#include "types.h" +#include "vb.h" +#include "macros.h" +#include "depth.h" + +#undef ASSERT /* ASSERT is redefined */ + +#include <ggi/internal/internal.h> +#include <ggi/ggi_ext.h> +#include <ggi/ggi.h> +#include "GL/ggimesa.h" + +struct ggi_mesa_info; + +struct ggi_mesa_context +{ + GLcontext *gl_ctx; + GLvisual *gl_vis; + GLframebuffer *gl_buffer; + + ggi_visual_t ggi_vis; + ggi_coord origin; + int flip_y; + int width, height, stride; /* Stride is in pixels */ + ggi_pixel color; /* Current color or index*/ + ggi_pixel clearcolor; + void *lfb; /* Linear frame buffer*/ + int viewport_init; +}; + +struct ggi_mesa_info +{ + GLboolean rgb_flag; + GLboolean db_flag; + GLboolean alpha_flag; + GLint index_bits; + GLint red_bits, green_bits, blue_bits, alpha_bits; + GLint depth_bits, stencil_bits, accum_bits; +}; + +extern GGIMesaContext GGIMesa; /* The current context */ + +#define SHIFT (GGI_COLOR_PRECISION - 8) + +#define GGICTX ((GGIMesaContext)ctx->DriverCtx) +#define VIS (GGICTX->ggi_vis) +#define FLIP(y) (GGICTX->flip_y-(y)) + +#define LFB(type,x,y) ((type *)GGICTX->lfb + (x) + (y) * GGICTX->stride) + +#define CTX_OPMESA(ctx) \ +((struct mesa_ext *)LIBGGI_EXT(((GGIMesaContext)ctx->DriverCtx)->ggi_vis, \ + ggiMesaID)) + + +#endif + diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h new file mode 100644 index 00000000000..0589991ce9d --- /dev/null +++ b/src/mesa/drivers/ggi/include/ggi/mesa/ggimesa_int.h @@ -0,0 +1,22 @@ +#ifndef _GGI_MESA_INT_H +#define _GGI_MESA_INT_H + +#include <ggi/internal/internal.h> +#include "ggimesa.h" + +extern ggi_extid ggiMesaID; + +ggifunc_setmode GGIMesa_setmode; +ggifunc_getapi GGIMesa_getapi; + +typedef struct mesa_ext +{ + void (*update_state)(GLcontext *ctx); + int (*setup_driver)(GGIMesaContext ctx, struct ggi_mesa_info *info); + void *private; +} mesaext; + +#define LIBGGI_MESAEXT(vis) ((mesaext *)LIBGGI_EXT(vis,ggiMesaID)) +#define GGIMESA_PRIVATE(vis) ((LIBGGI_MESAEXT(vis)->private)) + +#endif /* _GGI_MISC_INT_H */ |