Disable genkgi sublib handling until we have some sublibs to handle
[mesa.git] / src / mesa / drivers / ggi / default / genkgi_visual.c
1 /* $Id: genkgi_visual.c,v 1.5 1999/09/21 00:46:26 jtaylor Exp $
2 ******************************************************************************
3
4 genkgi_visual.c: visual handling for the generic KGI helper
5
6 Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org]
7
8 Permission is hereby granted, free of charge, to any person obtaining a
9 copy of this software and associated documentation files (the "Software"),
10 to deal in the Software without restriction, including without limitation
11 the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 and/or sell copies of the Software, and to permit persons to whom the
13 Software is furnished to do so, subject to the following conditions:
14
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 THE AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
22 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24
25 ******************************************************************************
26 */
27
28 #include <ggi/internal/ggi-dl.h>
29 #include <ggi/mesa/ggimesa_int.h>
30 #include <ggi/mesa/display_fbdev.h>
31 #include "genkgi.h"
32
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <ctype.h>
37 #include <errno.h>
38 #include <unistd.h>
39 #include <fcntl.h>
40 #include <sys/stat.h>
41
42 #ifdef HAVE_SYS_VT_H
43 #include <sys/vt.h>
44 #else
45 #include <linux/vt.h>
46 #endif
47 #ifdef HAVE_LINUX_KDEV_T_H
48 #include <linux/kdev_t.h>
49 #endif
50 #include <linux/tty.h>
51
52 #define DEFAULT_FBNUM 0
53
54 static char accel_prefix[] = "tgt-fbdev-kgicon-";
55 #define PREFIX_LEN (sizeof(accel_prefix))
56
57 typedef struct {
58 int async;
59 char *str;
60 } accel_info;
61
62 static accel_info accel_strings[] =
63 {
64 { 0, "d3dim" }, /* Direct3D Immediate Mode */
65 };
66
67 #define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info))
68
69 /* FIXME: These should be defined in the makefile system */
70 #define CONF_FILE "/usr/local/etc/ggi/mesa/targets/genkgi.conf"
71 void *_configHandle;
72 char confstub[512] = CONF_FILE;
73 char *conffile = confstub;
74
75 static int changed(ggi_visual_t vis, int whatchanged)
76 {
77 gl_ggiDEBUG("Entered ggimesa_genkgi_changed\n");
78 switch (whatchanged)
79 {
80 case GGI_CHG_APILIST:
81 {
82 char api[256];
83 char args[256];
84 int i;
85 const char *fname;
86 ggi_dlhandle *lib;
87
88 for (i = 0; ggiGetAPI(vis, i, api, args) == 0; i++)
89 {
90 strcat(api, "-mesa");
91 gl_ggiDEBUG("ggimesa_genkgi_changed: api=%s, i=%d\n", api, i);
92 fname = ggMatchConfig(_configHandle, api, NULL);
93 if (fname == NULL)
94 {
95 /* No special implementation for this sublib */
96 continue;
97 }
98
99 lib = ggiExtensionLoadDL(vis, fname, args, NULL);
100 }
101 }
102 break;
103 }
104 return 0;
105 }
106
107 int GGIdlinit(ggi_visual *vis, const char *args, void *argptr)
108 {
109 struct genkgi_priv_mesa *priv;
110 char libname[256], libargs[256];
111 int id, err;
112 struct stat junk;
113 ggifunc_getapi *oldgetapi;
114
115 gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit start\n");
116
117 GENKGI_PRIV_MESA(vis) = priv = malloc(sizeof(struct genkgi_priv_mesa));
118 if (priv == NULL)
119 {
120 fprintf(stderr, "Failed to allocate genkgi private data\n");
121 return GGI_DL_ERROR;
122 }
123
124 priv->oldpriv = GENKGI_PRIV(vis);
125 #if 0
126 err = ggLoadConfig(conffile, &_configHandle);
127 if (err != GGI_OK)
128 {
129 gl_ggiPrint("display-fbdev-kgicon-mesa: Couldn't open %s\n", conffile);
130 return err;
131 }
132
133 /* Hack city here. We need to probe the KGI driver properly for
134 * suggest-strings to discover the acceleration type(s).
135 */
136 priv->have_accel = 0;
137
138 if (stat("/proc/gfx0", &junk) == 0)
139 {
140 sprintf(priv->accel, "%s%s", accel_prefix, "d3dim");
141 priv->have_accel = 1;
142 gl_ggiDEBUG("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv->accel);
143 }
144
145 /* Mode management */
146 vis->opdisplay->getapi = GGIMesa_genkgi_getapi;
147 ggiIndicateChange(vis, GGI_CHG_APILIST);
148
149 /* Give the accel sublibs a chance to set up a driver */
150 if (priv->have_accel == 1)
151 {
152 oldgetapi = vis->opdisplay->getapi;
153 vis->opdisplay->getapi = GGIMesa_genkgi_getapi;
154 changed(vis, GGI_CHG_APILIST);
155 /* If the accel sublibs didn't produce, back up
156 * and keep looking */
157 if ((LIBGGI_MESAEXT(vis)->update_state == NULL) ||
158 (LIBGGI_MESAEXT(vis)->setup_driver == NULL))
159 vis->opdisplay->getapi = oldgetapi;
160 }
161
162 LIBGGI_MESAEXT(vis)->update_state = genkgi_update_state;
163 LIBGGI_MESAEXT(vis)->setup_driver = genkgi_setup_driver;
164 #endif
165 gl_ggiDEBUG("display-fbdev-kgicon-mesa: GGIdlinit finished\n");
166
167 return 0;
168 }
169
170 int GGIdlcleanup(ggi_visual *vis)
171 {
172 return 0;
173 }
174
175 #include <ggi/internal/ggidlinit.h>