~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to hw/xgl/xglinit.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2005 Novell, Inc.
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software
 
5
 * and its documentation for any purpose is hereby granted without
 
6
 * fee, provided that the above copyright notice appear in all copies
 
7
 * and that both that copyright notice and this permission notice
 
8
 * appear in supporting documentation, and that the name of
 
9
 * Novell, Inc. not be used in advertising or publicity pertaining to
 
10
 * distribution of the software without specific, written prior permission.
 
11
 * Novell, Inc. makes no representations about the suitability of this
 
12
 * software for any purpose. It is provided "as is" without express or
 
13
 * implied warranty.
 
14
 *
 
15
 * NOVELL, INC. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
17
 * NO EVENT SHALL NOVELL, INC. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
19
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
20
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 
21
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
22
 *
 
23
 * Author: David Reveman <davidr@novell.com>
 
24
 */
 
25
 
 
26
#include "xgl.h"
 
27
#include "xglglx.h"
 
28
#include "micmap.h"
 
29
#include "mipointer.h"
 
30
#include "fb.h"
 
31
 
 
32
#ifdef XGL_MODULAR
 
33
#include <dlfcn.h>
 
34
#endif
 
35
 
 
36
#define DEFAULT_DDX_MODULE_NAME "xglx"
 
37
 
 
38
static char *ddxModuleName = DEFAULT_DDX_MODULE_NAME;
 
39
 
 
40
xglScreenInfoRec xglScreenInfo = {
 
41
    NULL, 0, 0, 0, 0, 0,
 
42
    DEFAULT_GEOMETRY_DATA_TYPE,
 
43
    DEFAULT_GEOMETRY_USAGE,
 
44
    FALSE,
 
45
    XGL_DEFAULT_PBO_MASK,
 
46
    FALSE,
 
47
    {
 
48
        { FALSE, FALSE, { 0, 0, 0, 0 } },
 
49
        { FALSE, FALSE, { 0, 0, 0, 0 } },
 
50
        { FALSE, FALSE, { 0, 0, 0, 0 } },
 
51
        { FALSE, FALSE, { 0, 0, 0, 0 } }
 
52
    }
 
53
};
 
54
 
 
55
#ifdef GLXEXT
 
56
static Bool loadGlx = TRUE;
 
57
 
 
58
#ifndef NGLXEXTLOG
 
59
static char *glxExtLogFile = 0;
 
60
#endif
 
61
 
 
62
#endif
 
63
 
 
64
typedef struct _xglDDXFunc {
 
65
    void (*initOutput)         (ScreenInfo   *pScreenInfo,
 
66
                                int          argc,
 
67
                                char         **argv);
 
68
    void (*initInput)          (int          argc,
 
69
                                char         **argv);
 
70
    Bool (*legalModifier)      (unsigned int key,
 
71
                                DevicePtr    pDev);
 
72
    void (*processInputEvents) (void);
 
73
    void (*useMsg)             (void);
 
74
    int  (*processArgument)    (int          argc,
 
75
                                char         **argv,
 
76
                                int          i);
 
77
    void (*abort)              (void);
 
78
    void (*giveUp)             (void);
 
79
    void (*osVendorInit)       (void);
 
80
} xglDDXFuncRec;
 
81
 
 
82
static xglDDXFuncRec __ddxFunc;
 
83
 
 
84
#define SYMFUNC(name) ((void *) (name))
 
85
#define SYMVAR(name)  ((void *) &(name))
 
86
 
 
87
/*
 
88
 * The following table is used to make sure that all symbols required by
 
89
 * dynamically loaded modules are present in the main program. Add more symbols
 
90
 * as needed.
 
91
 */
 
92
 
 
93
void *symTab[] = {
 
94
    SYMFUNC (xglKbdCtrl),
 
95
    SYMFUNC (xglSetPixmapFormats),
 
96
    SYMVAR  (xglVisuals),
 
97
 
 
98
    SYMFUNC (mieqEnqueue),
 
99
    SYMFUNC (mieqInit),
 
100
    SYMFUNC (mieqProcessInputEvents),
 
101
    SYMFUNC (miPointerAbsoluteCursor),
 
102
    SYMFUNC (miRegisterPointerDevice),
 
103
    SYMFUNC (miPointerWarpCursor),
 
104
    SYMFUNC (miDCInitialize),
 
105
    SYMFUNC (miPointerAbsoluteCursor),
 
106
    SYMFUNC (miPointerUpdate),
 
107
    SYMFUNC (miRegisterRedirectBorderClipProc)
 
108
};
 
109
 
 
110
#define SYM(ptr, name) { (void **) &(ptr), (name) }
 
111
 
 
112
static Bool
 
113
xglEnsureDDXModule (void)
 
114
{
 
115
 
 
116
#ifdef XGL_MODULAR
 
117
    static void *ddxHandle = 0;
 
118
    static Bool status = TRUE;
 
119
 
 
120
    if (!status)
 
121
        return FALSE;
 
122
 
 
123
#ifdef GLXEXT
 
124
    /* GLX and GLcore modules must be loaded with RTLD_NOW and RTLD_LOCAL
 
125
       flags before DDX module which is linked to libGL and should be
 
126
       loaded with RTLD_GLOBAL. */
 
127
    if (loadGlx)
 
128
    {
 
129
        if (!xglLoadGLXModules ())
 
130
            FatalError ("No GLX modules loaded");
 
131
 
 
132
#ifndef NGLXEXTLOG
 
133
        if (glxExtLogFile)
 
134
        {
 
135
            __xglGLXLogFp = fopen (glxExtLogFile, "w");
 
136
            if (!__xglGLXLogFp)
 
137
                perror ("InitOutput");
 
138
        }
 
139
        else
 
140
            __xglGLXLogFp = 0;
 
141
#endif
 
142
 
 
143
    }
 
144
#endif
 
145
 
 
146
    if (!ddxHandle)
 
147
    {
 
148
        xglSymbolRec sym[] = {
 
149
            SYM (__ddxFunc.initOutput,         "InitOutput"),
 
150
            SYM (__ddxFunc.initInput,          "InitInput"),
 
151
            SYM (__ddxFunc.legalModifier,      "LegalModifier"),
 
152
            SYM (__ddxFunc.processInputEvents, "ProcessInputEvents"),
 
153
            SYM (__ddxFunc.useMsg,             "ddxUseMsg"),
 
154
            SYM (__ddxFunc.processArgument,    "ddxProcessArgument"),
 
155
            SYM (__ddxFunc.abort,              "AbortDDX"),
 
156
            SYM (__ddxFunc.giveUp,             "ddxGiveUp"),
 
157
            SYM (__ddxFunc.osVendorInit,       "OsVendorInit")
 
158
        };
 
159
 
 
160
        ddxHandle = xglLoadModule (ddxModuleName, RTLD_NOW | RTLD_GLOBAL);
 
161
        if (!ddxHandle)
 
162
            return (status = FALSE);
 
163
 
 
164
        if (!xglLookupSymbols (ddxHandle, sym, sizeof (sym) / sizeof (sym[0])))
 
165
        {
 
166
            xglUnloadModule (ddxHandle);
 
167
            ddxHandle = 0;
 
168
 
 
169
            return (status = FALSE);
 
170
        }
 
171
    }
 
172
 
 
173
    return TRUE;
 
174
#else
 
175
    return FALSE;
 
176
#endif
 
177
 
 
178
}
 
179
 
 
180
void
 
181
InitOutput (ScreenInfo *pScreenInfo,
 
182
            int        argc,
 
183
            char       **argv)
 
184
{
 
185
    (void) symTab;
 
186
 
 
187
    if (!xglEnsureDDXModule ())
 
188
        FatalError ("No DDX module loaded");
 
189
 
 
190
    (*__ddxFunc.initOutput) (pScreenInfo, argc, argv);
 
191
}
 
192
 
 
193
Bool
 
194
LegalModifier (unsigned int key,
 
195
               DevicePtr    pDev)
 
196
{
 
197
    return (*__ddxFunc.legalModifier) (key, pDev);
 
198
}
 
199
 
 
200
void
 
201
ProcessInputEvents (void)
 
202
{
 
203
    (*__ddxFunc.processInputEvents) ();
 
204
}
 
205
 
 
206
void
 
207
InitInput (int  argc,
 
208
           char **argv)
 
209
{
 
210
    if (!xglEnsureDDXModule ())
 
211
        FatalError ("No DDX module loaded");
 
212
 
 
213
    (*__ddxFunc.initInput) (argc, argv);
 
214
}
 
215
 
 
216
void
 
217
ddxUseMsg (void)
 
218
{
 
219
    ErrorF ("\nXgl usage:\n");
 
220
    ErrorF ("-ddx module            specify ddx module\n");
 
221
 
 
222
#ifdef GLXEXT
 
223
    ErrorF ("-noglx                 don't load glx extension\n");
 
224
 
 
225
#ifndef NGLXEXTLOG
 
226
    ErrorF ("-glxlog file           glx extension log file\n");
 
227
#endif
 
228
 
 
229
#endif
 
230
 
 
231
    xglUseMsg ();
 
232
 
 
233
    if (xglEnsureDDXModule ())
 
234
        (*__ddxFunc.useMsg) ();
 
235
}
 
236
 
 
237
int
 
238
ddxProcessArgument (int  argc,
 
239
                    char **argv,
 
240
                    int  i)
 
241
{
 
242
    static Bool checkDDX = FALSE;
 
243
    int         skip;
 
244
 
 
245
    if (!checkDDX)
 
246
    {
 
247
        int j;
 
248
 
 
249
        for (j = i; j < argc; j++)
 
250
        {
 
251
            if (!strcmp (argv[j], "-ddx"))
 
252
            {
 
253
                if (++j < argc)
 
254
                    ddxModuleName = argv[j];
 
255
            }
 
256
 
 
257
#ifdef GLXEXT
 
258
            else if (!strcmp (argv[j], "-noglx"))
 
259
            {
 
260
                loadGlx = FALSE;
 
261
            }
 
262
 
 
263
#ifndef NGLXEXTLOG
 
264
            else if (!strcmp (argv[j], "-glxlog"))
 
265
            {
 
266
                if (++j < argc)
 
267
                    glxExtLogFile = argv[j];
 
268
            }
 
269
#endif
 
270
 
 
271
#endif
 
272
 
 
273
        }
 
274
        checkDDX = TRUE;
 
275
    }
 
276
 
 
277
    if (!strcmp (argv[i], "-ddx"))
 
278
    {
 
279
        if ((i + 1) < argc)
 
280
            return 2;
 
281
 
 
282
        return 1;
 
283
    }
 
284
 
 
285
#ifdef GLXEXT
 
286
    else if (!strcmp (argv[i], "-noglx"))
 
287
    {
 
288
        return 1;
 
289
    }
 
290
 
 
291
#ifndef NGLXEXTLOG
 
292
    else if (!strcmp (argv[i], "-glxlog"))
 
293
    {
 
294
        if ((i + 1) < argc)
 
295
            return 2;
 
296
 
 
297
        return 1;
 
298
    }
 
299
#endif
 
300
 
 
301
#endif
 
302
 
 
303
    skip = xglProcessArgument (argc, argv, i);
 
304
    if (skip)
 
305
        return skip;
 
306
 
 
307
    if (xglEnsureDDXModule ())
 
308
        return (*__ddxFunc.processArgument) (argc, argv, i);
 
309
 
 
310
    return 0;
 
311
}
 
312
 
 
313
void
 
314
AbortDDX (void)
 
315
{
 
316
    if (xglEnsureDDXModule ())
 
317
        (*__ddxFunc.abort) ();
 
318
}
 
319
 
 
320
void
 
321
ddxGiveUp (void)
 
322
{
 
323
    if (xglEnsureDDXModule ())
 
324
        (*__ddxFunc.giveUp) ();
 
325
}
 
326
 
 
327
void
 
328
OsVendorInit (void)
 
329
{
 
330
    if (xglEnsureDDXModule ())
 
331
        (*__ddxFunc.osVendorInit) ();
 
332
}
 
333
 
 
334
void ddxInitGlobals()
 
335
{
 
336
}