Imported Upstream version 1.15.1
[deb_xorg-server.git] / hw / xfree86 / common / xf86Extensions.c
1 /*
2 * Copyright © 2011 Daniel Stone
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
22 *
23 * Author: Daniel Stone <daniel@fooishbar.org>
24 */
25
26 #ifdef HAVE_XORG_CONFIG_H
27 #include <xorg-config.h>
28 #endif
29
30 #include "extension.h"
31 #include "globals.h"
32
33 #include "xf86.h"
34 #include "xf86Config.h"
35 #include "xf86Module.h"
36 #include "xf86Extensions.h"
37 #include "xf86Opt.h"
38 #include "optionstr.h"
39
40 #ifdef XSELINUX
41 #include "xselinux.h"
42 #endif
43
44 #ifdef XFreeXDGA
45 #include <X11/extensions/xf86dgaproto.h>
46 #endif
47
48 #ifdef XF86VIDMODE
49 #include <X11/extensions/xf86vmproto.h>
50 #include "vidmodeproc.h"
51 #endif
52
53 /*
54 * DDX-specific extensions.
55 */
56 static const ExtensionModule extensionModules[] = {
57 #ifdef XF86VIDMODE
58 {
59 XFree86VidModeExtensionInit,
60 XF86VIDMODENAME,
61 &noXFree86VidModeExtension
62 },
63 #endif
64 #ifdef XFreeXDGA
65 {
66 XFree86DGAExtensionInit,
67 XF86DGANAME,
68 &noXFree86DGAExtension
69 },
70 #endif
71 #ifdef XF86DRI
72 {
73 XFree86DRIExtensionInit,
74 "XFree86-DRI",
75 &noXFree86DRIExtension
76 },
77 #endif
78 #ifdef DRI2
79 {
80 DRI2ExtensionInit,
81 DRI2_NAME,
82 &noDRI2Extension
83 }
84 #endif
85 };
86
87 static void
88 load_extension_config(void)
89 {
90 XF86ConfModulePtr mod_con = xf86configptr->conf_modules;
91 XF86LoadPtr modp;
92 int i;
93
94 /* Only the best. */
95 if (!mod_con)
96 return;
97
98 nt_list_for_each_entry(modp, mod_con->mod_load_lst, list.next) {
99 InputOption *opt;
100
101 if (strcasecmp(modp->load_name, "extmod") != 0)
102 continue;
103
104 /* extmod options are of the form "omit <extension-name>" */
105 nt_list_for_each_entry(opt, modp->load_opt, list.next) {
106 const char *key = input_option_get_key(opt);
107 if (strncasecmp(key, "omit", 4) != 0 || strlen(key) < 5)
108 continue;
109 if (EnableDisableExtension(key + 4, FALSE))
110 xf86MarkOptionUsed(opt);
111 }
112
113 #ifdef XSELINUX
114 if ((opt = xf86FindOption(modp->load_opt,
115 "SELinux mode disabled"))) {
116 xf86MarkOptionUsed(opt);
117 selinuxEnforcingState = SELINUX_MODE_DISABLED;
118 }
119 if ((opt = xf86FindOption(modp->load_opt,
120 "SELinux mode permissive"))) {
121 xf86MarkOptionUsed(opt);
122 selinuxEnforcingState = SELINUX_MODE_PERMISSIVE;
123 }
124 if ((opt = xf86FindOption(modp->load_opt,
125 "SELinux mode enforcing"))) {
126 xf86MarkOptionUsed(opt);
127 selinuxEnforcingState = SELINUX_MODE_ENFORCING;
128 }
129 #endif
130 }
131 }
132
133 void
134 xf86ExtensionInit(void)
135 {
136 int i;
137
138 load_extension_config();
139
140 for (i = 0; i < ARRAY_SIZE(extensionModules); i++)
141 LoadExtension(&extensionModules[i], TRUE);
142 }