1706f2543Smrg/**************************************************************************
2706f2543Smrg
3706f2543SmrgCopyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
4706f2543SmrgAll Rights Reserved.
5706f2543Smrg
6706f2543SmrgPermission is hereby granted, free of charge, to any person obtaining a
7706f2543Smrgcopy of this software and associated documentation files (the
8706f2543Smrg"Software"), to deal in the Software without restriction, including
9706f2543Smrgwithout limitation the rights to use, copy, modify, merge, publish,
10706f2543Smrgdistribute, sub license, and/or sell copies of the Software, and to
11706f2543Smrgpermit persons to whom the Software is furnished to do so, subject to
12706f2543Smrgthe following conditions:
13706f2543Smrg
14706f2543SmrgThe above copyright notice and this permission notice (including the
15706f2543Smrgnext paragraph) shall be included in all copies or substantial portions
16706f2543Smrgof the Software.
17706f2543Smrg
18706f2543SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19706f2543SmrgOR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20706f2543SmrgMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21706f2543SmrgIN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
22706f2543SmrgANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23706f2543SmrgTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24706f2543SmrgSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25706f2543Smrg
26706f2543Smrg**************************************************************************/
27706f2543Smrg
28706f2543Smrg/*
29706f2543Smrg * Authors:
30706f2543Smrg *   Kevin E. Martin <kevin@precisioninsight.com>
31706f2543Smrg *
32706f2543Smrg */
33706f2543Smrg
34706f2543Smrg#ifdef HAVE_XORG_CONFIG_H
35706f2543Smrg#include <xorg-config.h>
36706f2543Smrg#endif
37706f2543Smrg
38706f2543Smrg#include "xf86Module.h"
39706f2543Smrg#include "xf86Priv.h"
40706f2543Smrg#include "xf86.h"
41706f2543Smrg#include "colormap.h"
42706f2543Smrg#include "micmap.h"
43706f2543Smrg#include "globals.h"
44706f2543Smrg#include "glxserver.h"
45706f2543Smrg
46706f2543Smrgstatic MODULESETUPPROTO(glxSetup);
47706f2543Smrg
48706f2543Smrgstatic const char *initdeps[] = { "DOUBLE-BUFFER", "COMPOSITE", NULL };
49706f2543Smrg
50706f2543Smrgstatic ExtensionModule GLXExt =
51706f2543Smrg{
52706f2543Smrg    GlxExtensionInit,
53706f2543Smrg    "GLX",
54706f2543Smrg    &noGlxExtension,
55706f2543Smrg    NULL,
56706f2543Smrg    initdeps
57706f2543Smrg};
58706f2543Smrg
59706f2543Smrgstatic XF86ModuleVersionInfo VersRec =
60706f2543Smrg{
61706f2543Smrg        "glx",
62706f2543Smrg        MODULEVENDORSTRING,
63706f2543Smrg        MODINFOSTRING1,
64706f2543Smrg        MODINFOSTRING2,
65706f2543Smrg        XORG_VERSION_CURRENT,
66706f2543Smrg        1, 0, 0,
67706f2543Smrg        ABI_CLASS_EXTENSION,
68706f2543Smrg        ABI_EXTENSION_VERSION,
69706f2543Smrg        MOD_CLASS_NONE,
70706f2543Smrg        {0,0,0,0}
71706f2543Smrg};
72706f2543Smrg
73706f2543Smrg_X_EXPORT XF86ModuleData glxModuleData = { &VersRec, glxSetup, NULL };
74706f2543Smrg
75706f2543Smrgstatic pointer
76706f2543SmrgglxSetup(pointer module, pointer opts, int *errmaj, int *errmin)
77706f2543Smrg{
78706f2543Smrg    static Bool setupDone = FALSE;
79706f2543Smrg    __GLXprovider *provider;
80706f2543Smrg
81706f2543Smrg    if (setupDone) {
82706f2543Smrg	if (errmaj) *errmaj = LDR_ONCEONLY;
83706f2543Smrg	return NULL;
84706f2543Smrg    }
85706f2543Smrg
86706f2543Smrg    setupDone = TRUE;
87706f2543Smrg
88706f2543Smrg    provider = LoaderSymbol("__glXDRISWRastProvider");
89706f2543Smrg    if (provider == NULL)
90706f2543Smrg	return NULL;
91706f2543Smrg    GlxPushProvider(provider);
92706f2543Smrg
93706f2543Smrg    xf86Msg(xf86Info.aiglxFrom, "AIGLX %s\n",
94706f2543Smrg	    xf86Info.aiglx ? "enabled" : "disabled");
95706f2543Smrg    if (xf86Info.aiglx) {
96706f2543Smrg      provider = LoaderSymbol("__glXDRIProvider");
97706f2543Smrg      if (provider)
98706f2543Smrg	GlxPushProvider(provider);
99706f2543Smrg      provider = LoaderSymbol("__glXDRI2Provider");
100706f2543Smrg      if (provider)
101706f2543Smrg	GlxPushProvider(provider);
102706f2543Smrg    }
103706f2543Smrg
104706f2543Smrg    LoadExtension(&GLXExt, FALSE);
105706f2543Smrg
106706f2543Smrg    return module;
107706f2543Smrg}
108