diff options
Diffstat (limited to 'hw/xfree86/common/xf86Config.c')
-rw-r--r-- | hw/xfree86/common/xf86Config.c | 477 |
1 files changed, 370 insertions, 107 deletions
diff --git a/hw/xfree86/common/xf86Config.c b/hw/xfree86/common/xf86Config.c index 1738222f5..8f6dd2803 100644 --- a/hw/xfree86/common/xf86Config.c +++ b/hw/xfree86/common/xf86Config.c @@ -1,17 +1,48 @@ -/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.269 2003/02/20 04:36:07 dawes Exp $ */ +/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.277 2003/10/15 22:51:48 dawes Exp $ */ /* - * Copyright 1991-2002 by The XFree86 Project, Inc. - * Copyright 1997 by Metro Link, Inc. - * * Loosely based on code bearing the following copyright: * * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. + */ + +/* + * Copyright 1992-2003 by The XFree86 Project, Inc. + * Copyright 1997 by Metro Link, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: * - * <Put copyright message here> + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. * - * Author: Dirk Hohndel <hohndel@XFree86.Org> and others. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * Except as contained in this notice, the name of the copyright holder(s) + * and author(s) shall not be used in advertising or otherwise to promote + * the sale, use or other dealings in this Software without prior written + * authorization from the copyright holder(s) and author(s). + */ + +/* + * + * Authors: + * Dirk Hohndel <hohndel@XFree86.Org> + * David Dawes <dawes@XFree86.Org> + * Marc La France <tsi@XFree86.Org> + * Egbert Eich <eich@XFree86.Org> + * ... and others */ #ifdef XF86DRI @@ -19,6 +50,10 @@ #include <grp.h> #endif +#ifdef __UNIXOS2__ +#define I_NEED_OS2_H +#endif + #include "xf86.h" #include "xf86Parser.h" #include "xf86tokens.h" @@ -905,9 +940,11 @@ configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts) if (!xf86NameCmp(s,"flush")) { xf86Msg(X_CONFIG, "Flushing logfile enabled\n"); xf86Info.log = LogFlush; + LogSetParameter(XLOG_FLUSH, TRUE); } else if (!xf86NameCmp(s,"sync")) { xf86Msg(X_CONFIG, "Syncing logfile enabled\n"); xf86Info.log = LogSync; + LogSetParameter(XLOG_SYNC, TRUE); } else { xf86Msg(X_WARNING,"Unknown Log option\n"); } @@ -1143,6 +1180,11 @@ configInputKbd(IDevPtr inputp) xf86Msg(X_PROBED, "Keyboard type: Sun\n"); break; #endif +#ifdef WSKBD_TYPE_SUN5 + case WSKBD_TYPE_SUN5: + xf86Msg(X_PROBED, "Keyboard type: Sun5\n"); + break; +#endif default: xf86ConfigError("Unsupported wskbd type \"%d\"", xf86Info.wsKbdType); @@ -1314,105 +1356,297 @@ configInputKbd(IDevPtr inputp) return TRUE; } +/* + * Locate the core input devices. These can be specified/located in + * the following ways, in order of priority: + * + * 1. The InputDevices named by the -pointer and -keyboard command line + * options. + * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by + * the active ServerLayout. + * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard". + * 4. The first InputDevices that use the 'mouse' and 'keyboard' or 'kbd' + * drivers. + * 5. Default devices with an empty (default) configuration. These defaults + * will reference the 'mouse' and 'keyboard' drivers. + */ + static Bool checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout) { - Bool havePointer = FALSE, haveKeyboard = FALSE; + IDevPtr corePointer = NULL, coreKeyboard = NULL; Bool foundPointer = FALSE, foundKeyboard = FALSE; + const char *pointerMsg = NULL, *keyboardMsg = NULL; IDevPtr indp; IDevRec Pointer, Keyboard; XF86ConfInputPtr confInput; + XF86ConfInputRec defPtr, defKbd; int count = 0; MessageType from = X_DEFAULT; - /* Check if a core pointer or core keyboard is needed. */ + /* + * First check if a core pointer or core keyboard have been specified + * in the active ServerLayout. If more than one is specified for either, + * remove the core attribute from the later ones. + */ for (indp = servlayoutp->inputs; indp->identifier; indp++) { - if ((indp->commonOptions && - xf86FindOption(indp->commonOptions, "CorePointer")) || - (indp->extraOptions && - xf86FindOption(indp->extraOptions, "CorePointer"))) { - havePointer = TRUE; + pointer opt1 = NULL, opt2 = NULL; + if (indp->commonOptions && + xf86CheckBoolOption(indp->commonOptions, "CorePointer", FALSE)) { + opt1 = indp->commonOptions; + } + if (indp->extraOptions && + xf86CheckBoolOption(indp->extraOptions, "CorePointer", FALSE)) { + opt2 = indp->extraOptions; + } + if (opt1 || opt2) { + if (!corePointer) { + corePointer = indp; + } else { + if (opt1) + xf86ReplaceBoolOption(opt1, "CorePointer", FALSE); + if (opt2) + xf86ReplaceBoolOption(opt2, "CorePointer", FALSE); + xf86Msg(X_WARNING, "Duplicate core pointer devices. " + "Removing core pointer attribute from \"%s\"\n", + indp->identifier); + } + } + opt1 = opt2 = NULL; + if (indp->commonOptions && + xf86CheckBoolOption(indp->commonOptions, "CoreKeyboard", FALSE)) { + opt1 = indp->commonOptions; } - if ((indp->commonOptions && - xf86FindOption(indp->commonOptions, "CoreKeyboard")) || - (indp->extraOptions && - xf86FindOption(indp->extraOptions, "CoreKeyboard"))) { - haveKeyboard = TRUE; + if (indp->extraOptions && + xf86CheckBoolOption(indp->extraOptions, "CoreKeyboard", FALSE)) { + opt2 = indp->extraOptions; + } + if (opt1 || opt2) { + if (!coreKeyboard) { + coreKeyboard = indp; + } else { + if (opt1) + xf86ReplaceBoolOption(opt1, "CoreKeyboard", FALSE); + if (opt2) + xf86ReplaceBoolOption(opt2, "CoreKeyboard", FALSE); + xf86Msg(X_WARNING, "Duplicate core keyboard devices. " + "Removing core keyboard attribute from \"%s\"\n", + indp->identifier); + } } count++; } - if (!havePointer) { - if (xf86PointerName) { - confInput = xf86findInput(xf86PointerName, - xf86configptr->conf_input_lst); - if (!confInput) { - xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", - xf86PointerName); - return FALSE; + + confInput = NULL; + + /* 1. Check for the -pointer command line option. */ + if (xf86PointerName) { + confInput = xf86findInput(xf86PointerName, + xf86configptr->conf_input_lst); + if (!confInput) { + xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", + xf86PointerName); + return FALSE; + } + from = X_CMDLINE; + /* + * If one was already specified in the ServerLayout, it needs to be + * removed. + */ + if (corePointer) { + for (indp = servlayoutp->inputs; indp->identifier; indp++) + if (indp == corePointer) + break; + for (; indp->identifier; indp++) + indp[0] = indp[1]; + count--; + } + corePointer = NULL; + foundPointer = TRUE; + } + + /* 2. ServerLayout-specified core pointer. */ + if (corePointer) { + foundPointer = TRUE; + from = X_CONFIG; + } + + /* 3. First core pointer device. */ + if (!foundPointer) { + XF86ConfInputPtr p; + + for (p = xf86configptr->conf_input_lst; p; p = p->list.next) { + if (p->inp_option_lst && + xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) { + confInput = p; + foundPointer = TRUE; + from = X_DEFAULT; + pointerMsg = "first core pointer device"; + break; } - from = X_CMDLINE; - } else { + } + } + + /* 4. First pointer with 'mouse' as the driver. */ + if (!foundPointer) { + confInput = xf86findInput(CONF_IMPLICIT_POINTER, + xf86configptr->conf_input_lst); + if (!confInput) { + confInput = xf86findInputByDriver("mouse", + xf86configptr->conf_input_lst); + } + if (confInput) { + foundPointer = TRUE; from = X_DEFAULT; - confInput = xf86findInput(CONF_IMPLICIT_POINTER, - xf86configptr->conf_input_lst); - if (!confInput && implicitLayout) { - confInput = xf86findInputByDriver("mouse", - xf86configptr->conf_input_lst); - } + pointerMsg = "first mouse device"; + } + } + + /* 5. Built-in default. */ + if (!foundPointer) { + bzero(&defPtr, sizeof(defPtr)); + defPtr.inp_identifier = "<default pointer>"; + defPtr.inp_driver = "mouse"; + confInput = &defPtr; + foundPointer = TRUE; + from = X_DEFAULT; + pointerMsg = "default mouse configuration"; + } + + /* Add the core pointer device to the layout, and set it to Core. */ + if (foundPointer && confInput) { + foundPointer = configInput(&Pointer, confInput, from); + if (foundPointer) { + count++; + indp = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevRec)); + indp[count - 1] = Pointer; + indp[count - 1].extraOptions = + xf86addNewOption(NULL, "CorePointer", NULL); + indp[count].identifier = NULL; + servlayoutp->inputs = indp; } - if (confInput) - foundPointer = configInput(&Pointer, confInput, from); - } - if (!haveKeyboard) { - if (xf86KeyboardName) { - confInput = xf86findInput(xf86KeyboardName, - xf86configptr->conf_input_lst); - if (!confInput) { - xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", - xf86KeyboardName); - return FALSE; + } + + if (!foundPointer) { + /* This shouldn't happen. */ + xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n"); + return FALSE; + } + + confInput = NULL; + + /* 1. Check for the -keyboard command line option. */ + if (xf86KeyboardName) { + confInput = xf86findInput(xf86KeyboardName, + xf86configptr->conf_input_lst); + if (!confInput) { + xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n", + xf86KeyboardName); + return FALSE; + } + from = X_CMDLINE; + /* + * If one was already specified in the ServerLayout, it needs to be + * removed. + */ + if (coreKeyboard) { + for (indp = servlayoutp->inputs; indp->identifier; indp++) + if (indp == coreKeyboard) + break; + for (; indp->identifier; indp++) + indp[0] = indp[1]; + count--; + } + coreKeyboard = NULL; + foundKeyboard = TRUE; + } + + /* 2. ServerLayout-specified core keyboard. */ + if (coreKeyboard) { + foundKeyboard = TRUE; + from = X_CONFIG; + } + + /* 3. First core keyboard device. */ + if (!foundKeyboard) { + XF86ConfInputPtr p; + + for (p = xf86configptr->conf_input_lst; p; p = p->list.next) { + if (p->inp_option_lst && + xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) { + confInput = p; + foundKeyboard = TRUE; + from = X_DEFAULT; + keyboardMsg = "first core keyboard device"; + break; } - from = X_CMDLINE; - } else { + } + } + + /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */ + if (!foundKeyboard) { + confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD, + xf86configptr->conf_input_lst); + if (!confInput) { + confInput = xf86findInputByDriver("keyboard", + xf86configptr->conf_input_lst); + } + if (!confInput) { + confInput = xf86findInputByDriver("kbd", + xf86configptr->conf_input_lst); + } + if (confInput) { + foundKeyboard = TRUE; from = X_DEFAULT; - confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD, - xf86configptr->conf_input_lst); - if (!confInput && implicitLayout) { - confInput = xf86findInputByDriver("keyboard", - xf86configptr->conf_input_lst); - } + pointerMsg = "first keyboard device"; } - if (confInput) - foundKeyboard = configInput(&Keyboard, confInput, from); } - if (foundPointer) { - count++; - indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec)); - indp[count - 1] = Pointer; - indp[count - 1].extraOptions = xf86addNewOption(NULL, "CorePointer", NULL); - indp[count].identifier = NULL; - servlayoutp->inputs = indp; - } else if (!havePointer) { - if (implicitLayout) - xf86Msg(X_ERROR, "Unable to find a core pointer device\n"); - else - xf86Msg(X_ERROR, "No core pointer device specified\n"); - return FALSE; + + /* 5. Built-in default. */ + if (!foundKeyboard) { + bzero(&defKbd, sizeof(defKbd)); + defKbd.inp_identifier = "<default keyboard>"; + defKbd.inp_driver = "keyboard"; + confInput = &defKbd; + foundKeyboard = TRUE; + keyboardMsg = "default keyboard configuration"; + from = X_DEFAULT; } - if (foundKeyboard) { - count++; - indp = xnfrealloc(servlayoutp->inputs, (count + 1) * sizeof(IDevRec)); - indp[count - 1] = Keyboard; - indp[count - 1].extraOptions = xf86addNewOption(NULL, "CoreKeyboard", NULL); - indp[count].identifier = NULL; - servlayoutp->inputs = indp; - } else if (!haveKeyboard) { - if (implicitLayout) - xf86Msg(X_ERROR, "Unable to find a core keyboard device\n"); - else - xf86Msg(X_ERROR, "No core keyboard device specified\n"); + + /* Add the core keyboard device to the layout, and set it to Core. */ + if (foundKeyboard && confInput) { + foundKeyboard = configInput(&Keyboard, confInput, from); + if (foundKeyboard) { + count++; + indp = xnfrealloc(servlayoutp->inputs, + (count + 1) * sizeof(IDevRec)); + indp[count - 1] = Keyboard; + indp[count - 1].extraOptions = + xf86addNewOption(NULL, "CoreKeyboard", NULL); + indp[count].identifier = NULL; + servlayoutp->inputs = indp; + } + } + + if (!foundKeyboard) { + /* This shouldn't happen. */ + xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n"); return FALSE; } + + if (pointerMsg) { + xf86Msg(X_WARNING, "The core pointer device wasn't specified " + "explicitly in the layout.\n" + "\tUsing the %s.\n", pointerMsg); + } + + if (keyboardMsg) { + xf86Msg(X_WARNING, "The core keyboard device wasn't specified " + "explicitly in the layout.\n" + "\tUsing the %s.\n", keyboardMsg); + } + return TRUE; } @@ -1767,6 +2001,7 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, int count = 0; XF86ConfDisplayPtr dispptr; XF86ConfAdaptorLinkPtr conf_adaptor; + Bool defaultMonitor = FALSE; xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier, scrnum); @@ -1779,8 +2014,29 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, screenp->defaultbpp = conf_screen->scrn_defaultbpp; screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp; screenp->monitor = xnfcalloc(1, sizeof(MonRec)); - if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor)) - return FALSE; + /* If no monitor is specified, create a default one. */ + if (!conf_screen->scrn_monitor) { + XF86ConfMonitorRec defMon; + + bzero(&defMon, sizeof(defMon)); + defMon.mon_identifier = "<default monitor>"; + /* + * TARGET_REFRESH_RATE may be defined to effectively limit the + * default resolution to the largest that has a "good" refresh + * rate. + */ +#ifdef TARGET_REFRESH_RATE + defMon.mon_option_lst = xf86ReplaceRealOption(defMon.mon_option_lst, + "TargetRefresh", + TARGET_REFRESH_RATE); +#endif + if (!configMonitor(screenp->monitor, &defMon)) + return FALSE; + defaultMonitor = TRUE; + } else { + if (!configMonitor(screenp->monitor,conf_screen->scrn_monitor)) + return FALSE; + } screenp->device = xnfcalloc(1, sizeof(GDevRec)); configDevice(screenp->device,conf_screen->scrn_device, TRUE); screenp->device->myScreenSection = screenp; @@ -1822,6 +2078,10 @@ configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum, conf_adaptor = (XF86ConfAdaptorLinkPtr)conf_adaptor->list.next; } + if (defaultMonitor) { + xf86Msg(X_WARNING, "No monitor specified for screen \"%s\".\n" + "\tUsing a default monitor configuration.\n", screenp->id); + } return TRUE; } @@ -2149,7 +2409,7 @@ configInput(IDevPtr inputp, XF86ConfInputPtr conf_input, MessageType from) return TRUE; } - + static Bool modeIsPresent(char * modename,MonPtr monitorp) { @@ -2207,35 +2467,38 @@ addDefaultModes(MonPtr monitorp) /* * load the config file and fill the global data structure */ -Bool -xf86HandleConfigFile(void) +ConfigStatus +xf86HandleConfigFile(Bool autoconfig) { const char *filename; char *searchpath; MessageType from = X_DEFAULT; - if (getuid() == 0) - searchpath = ROOT_CONFIGPATH; - else - searchpath = USER_CONFIGPATH; - - if (xf86ConfigFile) - from = X_CMDLINE; + if (!autoconfig) { + if (getuid() == 0) + searchpath = ROOT_CONFIGPATH; + else + searchpath = USER_CONFIGPATH; - filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); - if (filename) { - xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); - xf86ConfigFile = xnfstrdup(filename); - } else { - xf86Msg(X_ERROR, "Unable to locate/open config file"); if (xf86ConfigFile) - xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile); - xf86ErrorFVerb(0, "\n"); - return FALSE; + from = X_CMDLINE; + + filename = xf86openConfigFile(searchpath, xf86ConfigFile, PROJECTROOT); + if (filename) { + xf86MsgVerb(from, 0, "Using config file: \"%s\"\n", filename); + xf86ConfigFile = xnfstrdup(filename); + } else { + xf86Msg(X_ERROR, "Unable to locate/open config file"); + if (xf86ConfigFile) + xf86ErrorFVerb(0, ": \"%s\"", xf86ConfigFile); + xf86ErrorFVerb(0, "\n"); + return CONFIG_NOFILE; + } } + if ((xf86configptr = xf86readConfigFile ()) == NULL) { xf86Msg(X_ERROR, "Problem parsing the config file\n"); - return FALSE; + return CONFIG_PARSE_ERROR; } xf86closeConfigFile (); @@ -2260,7 +2523,7 @@ xf86HandleConfigFile(void) if (!configImpliedLayout(&xf86ConfigLayout, xf86configptr->conf_screen_lst)) { xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); - return FALSE; + return CONFIG_PARSE_ERROR; } } else { if (xf86configptr->conf_flags != NULL) { @@ -2272,13 +2535,13 @@ xf86HandleConfigFile(void) if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst, dfltlayout)) { xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); - return FALSE; + return CONFIG_PARSE_ERROR; } } else { if (!configLayout(&xf86ConfigLayout, xf86configptr->conf_layout_lst, NULL)) { xf86Msg(X_ERROR, "Unable to determine the screen layout\n"); - return FALSE; + return CONFIG_PARSE_ERROR; } } } @@ -2293,7 +2556,7 @@ xf86HandleConfigFile(void) #endif ) { ErrorF ("Problem when converting the config data structures\n"); - return FALSE; + return CONFIG_PARSE_ERROR; } /* @@ -2317,7 +2580,7 @@ xf86HandleConfigFile(void) if (xf86AllowMouseOpenFail) xf86Info.allowMouseOpenFail = TRUE; - return TRUE; + return CONFIG_OK; } |