1 /* $Id: genkgi_visual.c,v 1.6 2000/01/07 08:34:44 jtaylor Exp $
2 ******************************************************************************
4 genkgi_visual.c: visual handling for the generic KGI helper
6 Copyright (C) 1999 Jon Taylor [taylorj@ggi-project.org]
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:
15 The above copyright notice and this permission notice shall be included in
16 all copies or substantial portions of the Software.
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.
25 ******************************************************************************
28 #include <ggi/internal/ggi-dl.h>
29 #include <ggi/mesa/ggimesa_int.h>
30 #include <ggi/mesa/display_fbdev.h>
31 #include <ggi/mesa/debug.h>
48 #ifdef HAVE_LINUX_KDEV_T_H
49 #include <linux/kdev_t.h>
51 #include <linux/tty.h>
53 #define DEFAULT_FBNUM 0
55 static char accel_prefix
[] = "tgt-fbdev-kgicon-";
56 #define PREFIX_LEN (sizeof(accel_prefix))
63 static accel_info accel_strings
[] =
65 { 0, "d3dim" }, /* Direct3D Immediate Mode */
68 #define NUM_ACCELS (sizeof(accel_strings)/sizeof(accel_info))
70 /* FIXME: These should be defined in the makefile system */
71 #define CONF_FILE "/usr/local/etc/ggi/mesa/targets/genkgi.conf"
73 char confstub
[512] = CONF_FILE
;
74 char *conffile
= confstub
;
76 static int changed(ggi_visual_t vis
, int whatchanged
)
78 GGIMESADPRINT_CORE("Entered ggimesa_genkgi_changed\n");
90 for (i
= 0; ggiGetAPI(vis
, i
, api
, args
) == 0; i
++)
93 GGIMESADPRINT_CORE("ggimesa_genkgi_changed: api=%s, i=%d\n", api
, i
);
94 fname
= ggMatchConfig(_configHandle
, api
, NULL
);
97 /* No special implementation for this sublib */
101 lib
= ggiExtensionLoadDL(vis
, fname
, args
, NULL
);
109 int GGIdlinit(ggi_visual
*vis
, const char *args
, void *argptr
)
111 struct genkgi_priv_mesa
*priv
;
112 char libname
[256], libargs
[256];
115 ggifunc_getapi
*oldgetapi
;
117 GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit start\n");
119 GENKGI_PRIV_MESA(vis
) = priv
= malloc(sizeof(struct genkgi_priv_mesa
));
122 fprintf(stderr
, "Failed to allocate genkgi private data\n");
126 priv
->oldpriv
= GENKGI_PRIV(vis
);
128 err
= ggLoadConfig(conffile
, &_configHandle
);
131 gl_ggiPrint("display-fbdev-kgicon-mesa: Couldn't open %s\n", conffile
);
135 /* Hack city here. We need to probe the KGI driver properly for
136 * suggest-strings to discover the acceleration type(s).
138 priv
->have_accel
= 0;
140 if (stat("/proc/gfx0", &junk
) == 0)
142 sprintf(priv
->accel
, "%s%s", accel_prefix
, "d3dim");
143 priv
->have_accel
= 1;
144 GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: Using accel: \"%s\"\n", priv
->accel
);
147 /* Mode management */
148 vis
->opdisplay
->getapi
= GGIMesa_genkgi_getapi
;
149 ggiIndicateChange(vis
, GGI_CHG_APILIST
);
151 /* Give the accel sublibs a chance to set up a driver */
152 if (priv
->have_accel
== 1)
154 oldgetapi
= vis
->opdisplay
->getapi
;
155 vis
->opdisplay
->getapi
= GGIMesa_genkgi_getapi
;
156 changed(vis
, GGI_CHG_APILIST
);
157 /* If the accel sublibs didn't produce, back up
158 * and keep looking */
159 if ((LIBGGI_MESAEXT(vis
)->update_state
== NULL
) ||
160 (LIBGGI_MESAEXT(vis
)->setup_driver
== NULL
))
161 vis
->opdisplay
->getapi
= oldgetapi
;
164 LIBGGI_MESAEXT(vis
)->update_state
= genkgi_update_state
;
165 LIBGGI_MESAEXT(vis
)->setup_driver
= genkgi_setup_driver
;
167 GGIMESADPRINT_CORE("display-fbdev-kgicon-mesa: GGIdlinit finished\n");
172 int GGIdlcleanup(ggi_visual
*vis
)
177 #include <ggi/internal/ggidlinit.h>