135c4bbdfSmrg/* 235c4bbdfSmrg * Copyright © 2011 Daniel Stone 335c4bbdfSmrg * 435c4bbdfSmrg * Permission is hereby granted, free of charge, to any person obtaining a 535c4bbdfSmrg * copy of this software and associated documentation files (the "Software"), 635c4bbdfSmrg * to deal in the Software without restriction, including without limitation 735c4bbdfSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 835c4bbdfSmrg * and/or sell copies of the Software, and to permit persons to whom the 935c4bbdfSmrg * Software is furnished to do so, subject to the following conditions: 1035c4bbdfSmrg * 1135c4bbdfSmrg * The above copyright notice and this permission notice (including the next 1235c4bbdfSmrg * paragraph) shall be included in all copies or substantial portions of the 1335c4bbdfSmrg * Software. 1435c4bbdfSmrg * 1535c4bbdfSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1635c4bbdfSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1735c4bbdfSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 1835c4bbdfSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 1935c4bbdfSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 2035c4bbdfSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 2135c4bbdfSmrg * DEALINGS IN THE SOFTWARE. 2235c4bbdfSmrg * 2335c4bbdfSmrg * Author: Daniel Stone <daniel@fooishbar.org> 2435c4bbdfSmrg */ 2535c4bbdfSmrg 2635c4bbdfSmrg#ifdef HAVE_XORG_CONFIG_H 2735c4bbdfSmrg#include <xorg-config.h> 2835c4bbdfSmrg#endif 2935c4bbdfSmrg 3035c4bbdfSmrg#include "extension.h" 3135c4bbdfSmrg#include "extinit.h" 3235c4bbdfSmrg#include "globals.h" 3335c4bbdfSmrg 3435c4bbdfSmrg#include "xf86.h" 3535c4bbdfSmrg#include "xf86Config.h" 3635c4bbdfSmrg#include "xf86Module.h" 3735c4bbdfSmrg#include "xf86Extensions.h" 3835c4bbdfSmrg#include "xf86Opt.h" 3935c4bbdfSmrg#include "optionstr.h" 4035c4bbdfSmrg 4135c4bbdfSmrg#ifdef XSELINUX 4235c4bbdfSmrg#include "xselinux.h" 4335c4bbdfSmrg#endif 4435c4bbdfSmrg 4535c4bbdfSmrg#ifdef XFreeXDGA 4635c4bbdfSmrg#include <X11/extensions/xf86dgaproto.h> 4735c4bbdfSmrg#endif 4835c4bbdfSmrg 4935c4bbdfSmrg#ifdef XF86VIDMODE 5035c4bbdfSmrg#include <X11/extensions/xf86vmproto.h> 5135c4bbdfSmrg#include "vidmodestr.h" 5235c4bbdfSmrg#endif 5335c4bbdfSmrg 5435c4bbdfSmrg/* 5535c4bbdfSmrg * DDX-specific extensions. 5635c4bbdfSmrg */ 5735c4bbdfSmrgstatic const ExtensionModule extensionModules[] = { 5835c4bbdfSmrg#ifdef XF86VIDMODE 5935c4bbdfSmrg { 6035c4bbdfSmrg XFree86VidModeExtensionInit, 6135c4bbdfSmrg XF86VIDMODENAME, 6235c4bbdfSmrg &noXFree86VidModeExtension 6335c4bbdfSmrg }, 6435c4bbdfSmrg#endif 6535c4bbdfSmrg#ifdef XFreeXDGA 6635c4bbdfSmrg { 6735c4bbdfSmrg XFree86DGAExtensionInit, 6835c4bbdfSmrg XF86DGANAME, 6935c4bbdfSmrg &noXFree86DGAExtension 7035c4bbdfSmrg }, 7135c4bbdfSmrg#endif 7235c4bbdfSmrg#ifdef XF86DRI 7335c4bbdfSmrg { 7435c4bbdfSmrg XFree86DRIExtensionInit, 7535c4bbdfSmrg "XFree86-DRI", 7635c4bbdfSmrg &noXFree86DRIExtension 7735c4bbdfSmrg }, 7835c4bbdfSmrg#endif 7935c4bbdfSmrg#ifdef DRI2 8035c4bbdfSmrg { 8135c4bbdfSmrg DRI2ExtensionInit, 8235c4bbdfSmrg DRI2_NAME, 8335c4bbdfSmrg &noDRI2Extension 8435c4bbdfSmrg } 8535c4bbdfSmrg#endif 8635c4bbdfSmrg}; 8735c4bbdfSmrg 8835c4bbdfSmrgstatic void 8935c4bbdfSmrgload_extension_config(void) 9035c4bbdfSmrg{ 9135c4bbdfSmrg XF86ConfModulePtr mod_con = xf86configptr->conf_modules; 9235c4bbdfSmrg XF86LoadPtr modp; 9335c4bbdfSmrg 9435c4bbdfSmrg /* Only the best. */ 9535c4bbdfSmrg if (!mod_con) 9635c4bbdfSmrg return; 9735c4bbdfSmrg 9835c4bbdfSmrg nt_list_for_each_entry(modp, mod_con->mod_load_lst, list.next) { 9935c4bbdfSmrg InputOption *opt; 10035c4bbdfSmrg 10135c4bbdfSmrg if (strcasecmp(modp->load_name, "extmod") != 0) 10235c4bbdfSmrg continue; 10335c4bbdfSmrg 10435c4bbdfSmrg /* extmod options are of the form "omit <extension-name>" */ 10535c4bbdfSmrg nt_list_for_each_entry(opt, modp->load_opt, list.next) { 10635c4bbdfSmrg const char *key = input_option_get_key(opt); 10735c4bbdfSmrg if (strncasecmp(key, "omit", 4) != 0 || strlen(key) < 5) 10835c4bbdfSmrg continue; 10935c4bbdfSmrg if (EnableDisableExtension(key + 4, FALSE)) 11035c4bbdfSmrg xf86MarkOptionUsed(opt); 11135c4bbdfSmrg } 11235c4bbdfSmrg 11335c4bbdfSmrg#ifdef XSELINUX 11435c4bbdfSmrg if ((opt = xf86FindOption(modp->load_opt, 11535c4bbdfSmrg "SELinux mode disabled"))) { 11635c4bbdfSmrg xf86MarkOptionUsed(opt); 11735c4bbdfSmrg selinuxEnforcingState = SELINUX_MODE_DISABLED; 11835c4bbdfSmrg } 11935c4bbdfSmrg if ((opt = xf86FindOption(modp->load_opt, 12035c4bbdfSmrg "SELinux mode permissive"))) { 12135c4bbdfSmrg xf86MarkOptionUsed(opt); 12235c4bbdfSmrg selinuxEnforcingState = SELINUX_MODE_PERMISSIVE; 12335c4bbdfSmrg } 12435c4bbdfSmrg if ((opt = xf86FindOption(modp->load_opt, 12535c4bbdfSmrg "SELinux mode enforcing"))) { 12635c4bbdfSmrg xf86MarkOptionUsed(opt); 12735c4bbdfSmrg selinuxEnforcingState = SELINUX_MODE_ENFORCING; 12835c4bbdfSmrg } 12935c4bbdfSmrg#endif 13035c4bbdfSmrg } 13135c4bbdfSmrg} 13235c4bbdfSmrg 13335c4bbdfSmrgvoid 13435c4bbdfSmrgxf86ExtensionInit(void) 13535c4bbdfSmrg{ 13635c4bbdfSmrg load_extension_config(); 13735c4bbdfSmrg 13835c4bbdfSmrg LoadExtensionList(extensionModules, ARRAY_SIZE(extensionModules), TRUE); 13935c4bbdfSmrg} 140