summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Taylor <[email protected]>1999-08-22 08:56:50 +0000
committerJon Taylor <[email protected]>1999-08-22 08:56:50 +0000
commit72fc9a527d29b731969bc5c94c51467f32f5a2e9 (patch)
treed8d36ac41de8f046ff9c2c007bb110140b402f5e
parent14c53fe1d5490b94138ca570890f734641e99dac (diff)
*** empty log message ***
-rw-r--r--progs/ggi/gears.c37
-rw-r--r--src/glut/ggi/ggiglut.c39
-rw-r--r--src/mesa/drivers/ggi/default/genkgi.conf.in4
-rw-r--r--src/mesa/drivers/ggi/default/genkgi.h47
-rw-r--r--src/mesa/drivers/ggi/default/genkgi_mode.c45
-rw-r--r--src/mesa/drivers/ggi/default/genkgi_visual.c34
-rw-r--r--src/mesa/drivers/ggi/display/fbdev_mode.c6
-rw-r--r--src/mesa/drivers/ggi/display/fbdev_visual.c8
-rw-r--r--src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h6
9 files changed, 156 insertions, 70 deletions
diff --git a/progs/ggi/gears.c b/progs/ggi/gears.c
index 61a8b9f3311..ac2e9f2a6ea 100644
--- a/progs/ggi/gears.c
+++ b/progs/ggi/gears.c
@@ -1,4 +1,4 @@
-/* $Id: gears.c,v 1.2 1999/08/21 08:53:27 jtaylor Exp $ */
+/* $Id: gears.c,v 1.3 1999/08/22 08:56:50 jtaylor Exp $ */
/*
* 3-D gear wheels. This program is in the public domain.
@@ -222,7 +222,7 @@ key(unsigned char k, int x, int y)
view_rotz -= 5.0;
break;
case 27: /* Escape */
- exit(0);
+ exit(0); /* FIXME: Shutdown and free resources cleanly in ggiglut */
break;
default:
return;
@@ -320,20 +320,21 @@ visible(int vis)
int main(int argc, char *argv[])
{
- glutInit(&argc, argv);
- glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
-
- glutInitWindowPosition(0, 0);
- glutInitWindowSize(300, 300);
- glutCreateWindow("Gears");
- init();
-
- glutDisplayFunc(draw);
- glutReshapeFunc(reshape);
- glutKeyboardFunc(key);
- glutSpecialFunc(special);
- glutVisibilityFunc(visible);
-
- glutMainLoop();
- return 0; /* ANSI C requires main to return int. */
+ glutInit(&argc, argv);
+ glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
+
+// glutInitWindowPosition(0, 0);
+// glutInitWindowSize(300, 300);
+ glutCreateWindow("Gears");
+ init();
+
+ glutDisplayFunc(draw);
+ glutReshapeFunc(reshape);
+ glutKeyboardFunc(key);
+ glutSpecialFunc(special);
+ glutVisibilityFunc(visible);
+
+ glutMainLoop();
+
+ return 0;
}
diff --git a/src/glut/ggi/ggiglut.c b/src/glut/ggi/ggiglut.c
index f9ca0a71fda..31658c79ff3 100644
--- a/src/glut/ggi/ggiglut.c
+++ b/src/glut/ggi/ggiglut.c
@@ -51,10 +51,14 @@ static ggi_visual_t __glut_vis;
static GGIMesaContext __glut_ctx;
-static int __glut_width = WIDTH;
-static int __glut_height = HEIGHT;
-static ggi_graphtype __glut_gt_rgb = GRAPHTYPE_RGB;
-static ggi_graphtype __glut_gt_index = GRAPHTYPE_INDEX;
+//static int __glut_width = WIDTH;
+//static int __glut_height = HEIGHT;
+//static ggi_graphtype __glut_gt_rgb = GRAPHTYPE_RGB;
+//static ggi_graphtype __glut_gt_index = GRAPHTYPE_INDEX;
+static int __glut_width = GGI_AUTO;
+static int __glut_height = GGI_AUTO;
+static ggi_graphtype __glut_gt_rgb = GT_AUTO;
+static ggi_graphtype __glut_gt_index = GT_8BIT;
static int __glut_init = GL_FALSE;
static int mousex = WIDTH / 2;
@@ -120,7 +124,6 @@ void glut_ggiDEBUG(char *format, ...)
vfprintf(stderr, format, args);
va_end(args);
}
-
}
void glutInit(int *argc, char **argv)
@@ -159,10 +162,7 @@ void glutInit(int *argc, char **argv)
case 24: gt = GT_24BIT; break;
case 32: gt = GT_32BIT; break;
default:
- glut_ggiDEBUG("\"%s\" bits per pixel?\n",
- argv[i+1]);
-
- exit(1);
+ ggiPanic("\"%s\" bits per pixel?\n", argv[i+1]);
}
__glut_gt_rgb = __glut_gt_index = gt;
REMOVE;
@@ -171,8 +171,8 @@ void glutInit(int *argc, char **argv)
else
if (strcmp(argv[i], "-size") == 0 && (i + 2) < (*argc))
{
- __glut_width=atoi(argv[i+1]);
- __glut_height=atoi(argv[i+2]);
+ __glut_width = atoi(argv[i + 1]);
+ __glut_height = atoi(argv[i + 2]);
REMOVE;
REMOVE;
REMOVE;
@@ -180,13 +180,13 @@ void glutInit(int *argc, char **argv)
}
}
- if (ggiInit()<0)
+ if (ggiInit() < 0)
{
ggiPanic("ggiInit() failed!\n");
}
- __glut_init=GL_TRUE;
+ __glut_init = GL_TRUE;
- #undef REMOVE
+#undef REMOVE
}
void glutInitWindowPosition(int x, int y)
@@ -266,11 +266,17 @@ int glutCreateWindow(const char *title)
ggiPanic("GGIMesaSetVisual failed!\n");
}
+ __glut_width = mode.visible.x;
+ __glut_height = mode.visible.y;
+
+ mousex = mode.visible.x / 2;
+ mousey = mode.visible.y / 2;
+
GGIMesaMakeCurrent(__glut_ctx);
if (__glut_reshape)
__glut_reshape(__glut_width, __glut_height);
-
+
return GL_TRUE;
}
@@ -491,8 +497,9 @@ void glutMainLoop(void)
ggi_event ev;
ggi_event_mask evmask = (emKeyPress | emKeyRepeat | emPtrMove | emPtrButton);
+
ggiSetEventMask(__glut_vis, evmask);
-
+
glutPostRedisplay();
if (__glut_visibility)
diff --git a/src/mesa/drivers/ggi/default/genkgi.conf.in b/src/mesa/drivers/ggi/default/genkgi.conf.in
index 8b3a25431b6..02acad2a191 100644
--- a/src/mesa/drivers/ggi/default/genkgi.conf.in
+++ b/src/mesa/drivers/ggi/default/genkgi.conf.in
@@ -1,4 +1,4 @@
# GGIMesa genkgi helper configuration
-.root: @ggi_libdir@/ggi/mesa/default/
+.root: @ggi_libdir@/ggi/mesa/default
-tgt-fbdev-kgicon-savage4-mesa kgi/savage4.so
+tgt-fbdev-kgicon-d3dim-mesa d3dim.so
diff --git a/src/mesa/drivers/ggi/default/genkgi.h b/src/mesa/drivers/ggi/default/genkgi.h
index c5a725cad82..022189138f1 100644
--- a/src/mesa/drivers/ggi/default/genkgi.h
+++ b/src/mesa/drivers/ggi/default/genkgi.h
@@ -1,4 +1,4 @@
-/* $Id: genkgi.h,v 1.2 1999/08/21 22:36:52 jtaylor Exp $
+/* $Id: genkgi.h,v 1.3 1999/08/22 08:56:50 jtaylor Exp $
******************************************************************************
GGIMesa - KGIcon specific overrides for fbcon-mesa
@@ -26,18 +26,51 @@
******************************************************************************
*/
+#ifndef _GENKGI_MESA_H
+#define _GENKGI_MESA_H
+
+#undef KGI_USE_PPBUFS
+
+#include <unistd.h>
+#include <sys/mman.h>
#include <ggi/internal/ggi-dl.h>
#include <ggi/mesa/display_fbdev.h>
+#include <kgi/kgi.h>
-//ggifunc_setmode GGIMesa_genkgi_setmode;
-ggifunc_getapi GGIMesa_genkgi_getapi;
+#ifndef MAP_FAILED
+#define MAP_FAILED ((void *)-1)
+#endif
-typedef struct genkgi_hook_mesa
+/* FIXME: LibGGI needs to export its genkgi.h */
+struct genkgi_priv
+{
+ ggi_gc *mapped_gc;
+ unsigned int gc_size;
+ ggifunc_drawline *drawline;
+ ggifunc_drawbox *drawbox;
+ ggifunc_fillscreen *fillscreen;
+ int fd_gc;
+ int close_gc;
+ int fd_kgicommand;
+ uint8 *mapped_kgicommand;
+ uint8 *kgicommand_ptr;
+ unsigned int kgicommand_buffersize;
+};
+
+#define GENKGI_PRIV(vis) ((struct genkgi_priv *)FBDEV_PRIV(vis)->accelpriv)
+
+extern ggifunc_getapi GGIMesa_genkgi_getapi;
+extern ggifunc_flush GGIMesa_genkgi_flush;
+
+struct genkgi_priv_mesa
{
char accel[100];
int have_accel;
- void *accelpriv;
-} genkgi_hook_mesa;
+ void *accelpriv; /* Private data of subdrivers */
+ struct genkgi_priv *oldpriv; /* LibGGI's private data */
+};
+
+#define GENKGI_PRIV_MESA(vis) ((struct genkgi_priv_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv)
-#define GENKGI_PRIVATE(vis) ((genkgi_hook_mesa *)FBDEV_PRIV_MESA(vis)->accelpriv)
+#endif /* _GENKHI_MESA_H */
diff --git a/src/mesa/drivers/ggi/default/genkgi_mode.c b/src/mesa/drivers/ggi/default/genkgi_mode.c
index 67e0145f705..b11b6414996 100644
--- a/src/mesa/drivers/ggi/default/genkgi_mode.c
+++ b/src/mesa/drivers/ggi/default/genkgi_mode.c
@@ -1,4 +1,4 @@
-/* $Id: genkgi_mode.c,v 1.2 1999/08/21 22:36:52 jtaylor Exp $
+/* $Id: genkgi_mode.c,v 1.3 1999/08/22 08:56:50 jtaylor Exp $
******************************************************************************
display-fbdev-kgicon-generic-mesa
@@ -41,7 +41,7 @@
int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
{
- genkgi_hook_mesa *priv = GENKGI_PRIVATE(vis);
+ struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
gl_ggiDEBUG("Entered mesa_genkgi_getapi, num=%d\n", num);
@@ -59,3 +59,44 @@ int GGIMesa_genkgi_getapi(ggi_visual *vis, int num, char *apiname, char *argumen
}
return -1;
}
+
+int GGIMesa_genkgi_flush(ggi_visual *vis, int x, int y, int w, int h, int tryflag)
+{
+ struct genkgi_priv_mesa *priv = GENKGI_PRIV_MESA(vis);
+ int junkval; // There must be a better way to do this
+
+ priv->oldpriv->kgicommand_ptr += getpagesize();
+ (kgiu32)(priv->oldpriv->kgicommand_ptr) &= 0xfffff000;
+ junkval = *((int *)(priv->oldpriv->kgicommand_ptr));
+
+ /* Check if we are now in the last page, and reset the
+ * FIFO if so. We can't use the last page to send
+ * more commands, since there's no page after it that
+ * we can touch to fault in the last page's commands.
+ *
+ * FIXME: This will be replaced with a flush-and-reset handler
+ * on the end-of-buffer pagefault at some point....
+ *
+ */
+ if ((priv->oldpriv->kgicommand_ptr - priv->oldpriv->mapped_kgicommand)
+ >= (priv->oldpriv->kgicommand_buffersize - getpagesize()))
+ {
+ gl_ggiDEBUG("Hit end of FIFO, attempting remap");
+ munmap(priv->oldpriv->mapped_kgicommand, priv->oldpriv->kgicommand_buffersize);
+ gl_ggiDEBUG("Passed munmap");
+ if ((priv->oldpriv->mapped_kgicommand =
+ mmap(NULL,
+ priv->oldpriv->kgicommand_buffersize,
+ PROT_READ | PROT_WRITE,
+ MAP_SHARED,
+ priv->oldpriv->fd_kgicommand,
+ 0)) == MAP_FAILED)
+ {
+ ggiPanic("Failed to remap kgicommand!");
+ }
+ gl_ggiDEBUG("Passed mmap");
+ priv->oldpriv->kgicommand_ptr = priv->oldpriv->mapped_kgicommand;
+ gl_ggiDEBUG("Passed kgicommand_ptr reset");
+ }
+ return 0;
+}
diff --git a/src/mesa/drivers/ggi/default/genkgi_visual.c b/src/mesa/drivers/ggi/default/genkgi_visual.c
index a1de5ff7c38..1ed038a0c78 100644
--- a/src/mesa/drivers/ggi/default/genkgi_visual.c
+++ b/src/mesa/drivers/ggi/default/genkgi_visual.c
@@ -1,4 +1,4 @@
-/* $Id: genkgi_visual.c,v 1.3 1999/08/21 22:46:13 jtaylor Exp $
+/* $Id: genkgi_visual.c,v 1.4 1999/08/22 08:56:50 jtaylor Exp $
******************************************************************************
genkgi_visual.c: visual handling for the generic KGI helper
@@ -70,7 +70,7 @@ typedef struct {
static accel_info accel_strings[] =
{
- { 0, "savage4" }, /* S3 Savage4 */
+ { 0, "d3dim" }, /* Direct3D Immedaite Mode */
};
#define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info))
@@ -115,7 +115,7 @@ static int changed(ggi_visual_t vis, int whatchanged)
int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
{
- genkgi_hook_mesa *priv;
+ struct genkgi_priv_mesa *priv;
char libname[256], libargs[256];
int id, err;
struct stat junk;
@@ -123,13 +123,15 @@ int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit start\n");
- GENKGI_PRIVATE(vis) = priv = malloc(sizeof(genkgi_hook_mesa));
+ GENKGI_PRIV_MESA(vis) = priv = malloc(sizeof(struct genkgi_priv_mesa));
if (priv == NULL)
{
- fprintf(stderr, "Failed to allocate genkgi_hook!\n");
+ fprintf(stderr, "Failed to allocate genkgi private data\n");
return GGI_DL_ERROR;
}
+ priv->oldpriv = GENKGI_PRIV(vis);
+#if 0
err = ggLoadConfig(conffile, &_configHandle);
if (err != GGI_OK)
{
@@ -137,24 +139,22 @@ int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
return err;
}
- /* Hack city here. We need to probe the KGI driver properly to discover
- * the acceleration type.
+ /* Hack city here. We need to probe the KGI driver properly for
+ * suggest-strings to discover the acceleration type(s).
*/
priv->have_accel = 0;
-#if 0
- if (stat("/proc/savage4", &junk) == 0)
+#if 1
+ if (stat("/proc/gfx0", &junk) == 0)
{
- sprintf(priv->accel, "%s%s", accel_prefix, "savage4");
+ sprintf(priv->accel, "%s%s", accel_prefix, "d3dim");
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;
-
+ vis->opdisplay->getapi = GGIMesa_genkgi_getapi;
ggiIndicateChange(vis, GGI_CHG_APILIST);
-
+#endif
/* Give the accel sublibs a chance to set up a driver */
if (priv->have_accel == 1)
@@ -168,7 +168,11 @@ int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
(LIBGGI_MESAEXT(vis)->setup_driver == NULL))
vis->opdisplay->getapi = oldgetapi;
}
-
+#endif
+
+ LIBGGI_MESAEXT(vis)->update_state = genkgi_update_state;
+ LIBGGI_MESAEXT(vis)->setup_driver = genkgi_setup_driver;
+
gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit finished\n");
return 0;
diff --git a/src/mesa/drivers/ggi/display/fbdev_mode.c b/src/mesa/drivers/ggi/display/fbdev_mode.c
index 478ad83801c..6815e5f198e 100644
--- a/src/mesa/drivers/ggi/display/fbdev_mode.c
+++ b/src/mesa/drivers/ggi/display/fbdev_mode.c
@@ -1,4 +1,4 @@
-/* $Id: fbdev_mode.c,v 1.2 1999/08/21 22:46:13 jtaylor Exp $
+/* $Id: fbdev_mode.c,v 1.3 1999/08/22 08:56:50 jtaylor Exp $
******************************************************************************
display-fbdev-mesa
@@ -50,7 +50,7 @@
int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *arguments)
{
- fbdev_hook_mesa *priv = GGIMESA_PRIVATE(vis);
+ struct fbdev_priv_mesa *priv = GGIMESA_PRIVATE(vis);
strcpy(arguments, "");
@@ -70,7 +70,7 @@ int GGIMesa_fbdev_getapi(ggi_visual *vis, int num, char *apiname, char *argument
static int do_setmode(ggi_visual *vis)
{
- fbdev_hook_mesa *priv = GGIMESA_PRIVATE(vis);
+ struct fbdev_priv_mesa *priv = GGIMESA_PRIVATE(vis);
int err, id;
char libname[256], libargs[256];
ggi_graphtype gt;
diff --git a/src/mesa/drivers/ggi/display/fbdev_visual.c b/src/mesa/drivers/ggi/display/fbdev_visual.c
index 60af90412af..13ac848e7cc 100644
--- a/src/mesa/drivers/ggi/display/fbdev_visual.c
+++ b/src/mesa/drivers/ggi/display/fbdev_visual.c
@@ -1,4 +1,4 @@
-/* $Id: fbdev_visual.c,v 1.2 1999/08/21 22:46:13 jtaylor Exp $
+/* $Id: fbdev_visual.c,v 1.3 1999/08/22 08:56:50 jtaylor Exp $
******************************************************************************
display-fbdev-mesa: visual handling
@@ -107,16 +107,16 @@ static int changed(ggi_visual_t vis, int whatchanged)
int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
{
- fbdev_hook_mesa *priv;
+ struct fbdev_priv_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));
+ GGIMESA_PRIVATE(vis) = priv = malloc(sizeof(struct fbdev_priv_mesa));
if (priv == NULL) {
- fprintf(stderr, "Failed to allocate fbdev_hook!\n");
+ fprintf(stderr, "Failed to allocate fbdev private data\n");
return GGI_DL_ERROR;
}
diff --git a/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h b/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h
index eee65339782..72d294bb6fc 100644
--- a/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h
+++ b/src/mesa/drivers/ggi/include/ggi/mesa/display_fbdev.h
@@ -7,14 +7,14 @@
ggifunc_setmode GGIMesa_fbdev_setmode;
ggifunc_getapi GGIMesa_fbdev_getapi;
-#define FBDEV_PRIV_MESA(vis) ((fbdev_hook_mesa *)(FBDEV_PRIV(vis)->accelpriv))
+#define FBDEV_PRIV_MESA(vis) ((struct fbdev_priv_mesa *)(FBDEV_PRIV(vis)->accelpriv))
-typedef struct fbdev_hook_mesa
+struct fbdev_priv_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 */