2 * Loosely based on code bearing the following copyright:
4 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
8 * Copyright 1992-2003 by The XFree86 Project, Inc.
9 * Copyright 1997 by Metro Link, Inc.
11 * Permission is hereby granted, free of charge, to any person obtaining a
12 * copy of this software and associated documentation files (the "Software"),
13 * to deal in the Software without restriction, including without limitation
14 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15 * and/or sell copies of the Software, and to permit persons to whom the
16 * Software is furnished to do so, subject to the following conditions:
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
29 * Except as contained in this notice, the name of the copyright holder(s)
30 * and author(s) shall not be used in advertising or otherwise to promote
31 * the sale, use or other dealings in this Software without prior written
32 * authorization from the copyright holder(s) and author(s).
38 * Dirk Hohndel <hohndel@XFree86.Org>
39 * David Dawes <dawes@XFree86.Org>
40 * Marc La France <tsi@XFree86.Org>
41 * Egbert Eich <eich@XFree86.Org>
45 #ifdef HAVE_XORG_CONFIG_H
46 #include <xorg-config.h>
50 #include <sys/types.h>
55 #include "xf86Modes.h"
56 #include "xf86Parser.h"
57 #include "xf86tokens.h"
58 #include "xf86Config.h"
60 #include "xf86_OSlib.h"
61 #include "configProcs.h"
63 #include "extension.h"
64 #include "xf86pciBus.h"
66 #include "xf86Xinput.h"
73 * These paths define the way the config file search is done. The escape
74 * sequences are documented in parser/scan.c.
76 #ifndef ALL_CONFIGPATH
77 #define ALL_CONFIGPATH "%A," "%R," \
78 "/etc/X11/%R," "%P/etc/X11/%R," \
80 "/etc/X11/%F," "%P/etc/X11/%F," \
81 "/etc/X11/%X," "/etc/%X," \
87 #ifndef RESTRICTED_CONFIGPATH
88 #define RESTRICTED_CONFIGPATH "/etc/X11/%S," "%P/etc/X11/%S," \
89 "/etc/X11/%G," "%P/etc/X11/%G," \
90 "/etc/X11/%X," "/etc/%X," \
96 #ifndef ALL_CONFIGDIRPATH
97 #define ALL_CONFIGDIRPATH "%A," "%R," \
98 "/etc/X11/%R," "%C/X11/%R," \
99 "/etc/X11/%X," "%C/X11/%X"
101 #ifndef RESTRICTED_CONFIGDIRPATH
102 #define RESTRICTED_CONFIGDIRPATH "/etc/X11/%R," "%C/X11/%R," \
103 "/etc/X11/%X," "%C/X11/%X"
105 #ifndef SYS_CONFIGDIRPATH
106 #define SYS_CONFIGDIRPATH "%D/X11/%X"
109 #define PROJECTROOT "/usr/X11R6"
112 static ModuleDefault ModuleDefaults[] = {
114 {.name = "glx",.toLoad = TRUE,.load_opt = NULL},
117 /* load DIX modules used by drivers first */
118 {.name = "fb",.toLoad = TRUE,.load_opt = NULL},
119 {.name = "shadow",.toLoad = TRUE,.load_opt = NULL},
121 {.name = NULL,.toLoad = FALSE,.load_opt = NULL}
124 /* Forward declarations */
125 static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
126 int scrnum, MessageType from);
127 static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
128 static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
130 static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
132 static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
133 static Bool addDefaultModes(MonPtr monitorp);
136 static void configDRI(XF86ConfDRIPtr drip);
138 static void configExtensions(XF86ConfExtensionsPtr conf_ext);
142 * Extract a single element from the font path string starting at
143 * pnt. The font path element will be returned, and pnt will be
144 * updated to point to the start of the next element, or set to
145 * NULL if there are no more.
148 xf86GetPathElem(char **pnt)
153 *pnt = index(*pnt, ',');
162 * xf86ValidateFontPath --
163 * Validates the user-specified font path. Each element that
164 * begins with a '/' is checked to make sure the directory exists.
165 * If the directory exists, the existence of a file named 'fonts.dir'
166 * is checked. If either check fails, an error is printed and the
167 * element is removed from the font path.
170 #define DIR_FILE "/fonts.dir"
172 xf86ValidateFontPath(char *path)
174 char *next, *tmp_path, *out_pnt, *path_elem, *p1, *dir_elem;
175 struct stat stat_buf;
179 tmp_path = calloc(1, strlen(path) + 1);
183 while (next != NULL) {
184 path_elem = xf86GetPathElem(&next);
185 if (*path_elem == '/') {
186 dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
187 if ((p1 = strchr(path_elem, ':')) != 0)
188 dirlen = p1 - path_elem;
190 dirlen = strlen(path_elem);
191 strlcpy(dir_elem, path_elem, dirlen + 1);
192 flag = stat(dir_elem, &stat_buf);
194 if (!S_ISDIR(stat_buf.st_mode))
197 xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n",
199 xf86ErrorF("\tEntry deleted from font path.\n");
204 XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE);
205 flag = stat(p1, &stat_buf);
207 if (!S_ISREG(stat_buf.st_mode))
212 "`fonts.dir' not found (or not valid) in \"%s\".\n",
214 xf86ErrorF("\tEntry deleted from font path.\n");
215 xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
224 * Either an OK directory, or a font server name. So add it to
227 if (out_pnt != tmp_path)
229 strcat(out_pnt, path_elem);
230 out_pnt += strlen(path_elem);
235 #define FIND_SUITABLE(pointertype, listhead, ptr) \
237 pointertype _l, _p; \
239 for (_l = (listhead), _p = NULL; !_p && _l; _l = (pointertype)_l->list.next) { \
240 if (!_l->match_seat || (SeatId && xf86nameCompare(_l->match_seat, SeatId) == 0)) \
248 * use the datastructure that the parser provides and pick out the parts
249 * that we need at this point
252 xf86ModulelistFromConfig(void ***optlist)
254 int count = 0, i = 0;
255 const char **modulearray;
257 const char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
266 * make sure the config file has been parsed and that we have a
267 * ModulePath set; if no ModulePath was given, use the default
270 if (xf86configptr == NULL) {
271 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
275 if (xf86configptr->conf_modules) {
276 /* Walk the disable list and let people know what we've parsed to
279 modp = xf86configptr->conf_modules->mod_disable_lst;
282 "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n",
284 modp = (XF86LoadPtr) modp->list.next;
287 * Walk the default settings table. For each module listed to be
288 * loaded, make sure it's in the mod_load_lst. If it's not, make
289 * sure it's not in the mod_no_load_lst. If it's not disabled,
290 * append it to mod_load_lst
292 for (i = 0; ModuleDefaults[i].name != NULL; i++) {
293 if (ModuleDefaults[i].toLoad == FALSE) {
295 "\"%s\" is not to be loaded by default. Skipping.\n",
296 ModuleDefaults[i].name);
300 modp = xf86configptr->conf_modules->mod_load_lst;
302 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
304 "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n",
305 ModuleDefaults[i].name);
309 modp = (XF86LoadPtr) modp->list.next;
311 if (found == FALSE) {
312 modp = xf86configptr->conf_modules->mod_disable_lst;
314 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
316 "\"%s\" will be loaded even though the default is to disable it.\n",
317 ModuleDefaults[i].name);
321 modp = (XF86LoadPtr) modp->list.next;
324 if (found == FALSE) {
325 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
327 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
329 ModuleDefaults[i].load_opt);
330 xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n",
331 ModuleDefaults[i].name);
336 xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
337 for (i = 0; ModuleDefaults[i].name != NULL; i++) {
338 if (ModuleDefaults[i].toLoad == TRUE) {
339 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
341 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
343 ModuleDefaults[i].load_opt);
349 * Walk the list of modules in the "Module" section to determine how
352 modp = xf86configptr->conf_modules->mod_load_lst;
354 for (i = 0; ignore[i]; i++) {
355 if (strcmp(modp->load_name, ignore[i]) == 0)
360 modp = (XF86LoadPtr) modp->list.next;
364 * allocate the memory and walk the list again to fill in the pointers
366 modulearray = xnfalloc((count + 1) * sizeof(char *));
367 optarray = xnfalloc((count + 1) * sizeof(void *));
369 if (xf86configptr->conf_modules) {
370 modp = xf86configptr->conf_modules->mod_load_lst;
373 modulearray[count] = modp->load_name;
374 optarray[count] = modp->load_opt;
377 modp = (XF86LoadPtr) modp->list.next;
380 modulearray[count] = NULL;
381 optarray[count] = NULL;
390 xf86DriverlistFromConfig(void)
394 const char **modulearray;
398 * make sure the config file has been parsed and that we have a
399 * ModulePath set; if no ModulePath was given, use the default
402 if (xf86configptr == NULL) {
403 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
408 * Walk the list of driver lines in active "Device" sections to
409 * determine now many implicitly loaded modules there are.
412 if (xf86ConfigLayout.screens) {
413 slp = xf86ConfigLayout.screens;
414 while ((slp++)->screen) {
420 * Handle the set of inactive "Device" sections.
423 while (xf86ConfigLayout.inactives[j++].identifier)
430 * allocate the memory and walk the list again to fill in the pointers
432 modulearray = xnfalloc((count + 1) * sizeof(char *));
434 slp = xf86ConfigLayout.screens;
435 while (slp->screen) {
436 modulearray[count] = slp->screen->device->driver;
443 while (xf86ConfigLayout.inactives[j].identifier)
444 modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
446 modulearray[count] = NULL;
448 /* Remove duplicates */
449 for (count = 0; modulearray[count] != NULL; count++) {
452 for (i = 0; i < count; i++)
453 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
454 modulearray[count] = "";
462 xf86InputDriverlistFromConfig(void)
465 const char **modulearray;
469 * make sure the config file has been parsed and that we have a
470 * ModulePath set; if no ModulePath was given, use the default
473 if (xf86configptr == NULL) {
474 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
479 * Walk the list of driver lines in active "InputDevice" sections to
480 * determine now many implicitly loaded modules there are.
482 if (xf86ConfigLayout.inputs) {
483 idp = xf86ConfigLayout.inputs;
494 * allocate the memory and walk the list again to fill in the pointers
496 modulearray = xnfalloc((count + 1) * sizeof(char *));
498 idp = xf86ConfigLayout.inputs;
499 while (idp && *idp) {
500 modulearray[count] = (*idp)->driver;
504 modulearray[count] = NULL;
506 /* Remove duplicates */
507 for (count = 0; modulearray[count] != NULL; count++) {
510 for (i = 0; i < count; i++)
511 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
512 modulearray[count] = "";
520 fixup_video_driver_list(const char **drivers)
522 static const char *fallback[5] = { "modesetting", "fbdev", "vesa", "wsfb", NULL };
523 const char **end, **drv;
527 /* walk to the end of the list */
528 for (end = drivers; *end && **end; end++);
532 * for each of the fallback drivers, if we find it in the list,
533 * swap it with the last available non-fallback driver.
535 for (i = 0; fallback[i]; i++) {
536 for (drv = drivers; drv != end; drv++) {
537 if (strstr(*drv, fallback[i])) {
549 GenerateDriverlist(const char *dirname)
552 const char *subdirs[] = { dirname, NULL };
553 static const char *patlist[] = { "(.*)_drv\\.so", NULL };
554 ret = LoaderListDirs(subdirs, patlist);
556 /* fix up the probe order for video drivers */
557 if (strstr(dirname, "drivers") && ret != NULL)
558 fixup_video_driver_list(ret);
564 xf86DriverlistFromCompile(void)
566 static const char **driverlist = NULL;
569 driverlist = GenerateDriverlist("drivers");
576 * Print a READABLE ErrorMessage!!! All information that is
577 * available is printed.
580 _X_ATTRIBUTE_PRINTF(1, 2)
581 xf86ConfigError(const char *msg, ...)
585 ErrorF("\nConfig Error:\n");
594 configFiles(XF86ConfFilesPtr fileconf)
596 MessageType pathFrom;
599 char *temp_path, *log_buf, *start, *end;
604 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
606 pathFrom = X_CMDLINE;
607 else if (fileconf && fileconf->file_fontpath) {
609 if (xf86Info.useDefaultFontPath) {
611 if (asprintf(&new_font_path, "%s%s%s", fileconf->file_fontpath,
612 *temp_path ? "," : "", temp_path) == -1)
613 new_font_path = NULL;
616 defaultFontPath = new_font_path;
619 defaultFontPath = fileconf->file_fontpath;
622 pathFrom = X_DEFAULT;
623 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
625 /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
626 temp_path = must_copy ? xnfstrdup(defaultFontPath) : (char *) defaultFontPath;
627 defaultFontPath = xf86ValidateFontPath(temp_path);
630 /* make fontpath more readable in the logfiles */
632 temp_path = (char *) defaultFontPath;
633 while ((temp_path = index(temp_path, ',')) != NULL) {
638 log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1);
640 start = (char *) defaultFontPath;
641 while ((end = index(start, ',')) != NULL) {
642 size = (end - start) + 1;
643 *(temp_path++) = '\t';
644 strncpy(temp_path, start, size);
646 *(temp_path++) = '\n';
649 /* copy last entry */
650 *(temp_path++) = '\t';
651 strcpy(temp_path, start);
652 xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
658 if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
659 xf86ModulePath = fileconf->file_modulepath;
660 xf86ModPathFrom = X_CONFIG;
664 xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
666 if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
667 XkbBaseDirectory = fileconf->file_xkbdir;
668 xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
674 * XXX The problem with this is that the log file is already open.
675 * One option might be to copy the exiting contents to the new location.
676 * and re-open it. The down side is that the default location would
677 * already have been overwritten. Another option would be to start with
678 * unique temporary location, then copy it once the correct name is known.
679 * A problem with this is what happens if the server exits before that
682 if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
683 xf86LogFile = fileconf->file_logfile;
684 xf86LogFileFrom = X_CONFIG;
698 FLAG_ALLOWMOUSEOPENFAIL,
699 FLAG_SAVER_BLANKTIME,
700 FLAG_DPMS_STANDBYTIME,
701 FLAG_DPMS_SUSPENDTIME,
707 FLAG_RENDER_COLORMAP_MODE,
711 FLAG_ALLOW_EMPTY_INPUT,
712 FLAG_USE_DEFAULT_FONT_PATH,
713 FLAG_AUTO_ADD_DEVICES,
714 FLAG_AUTO_ENABLE_DEVICES,
722 * NOTE: the last value for each entry is NOT the default. It is set to TRUE
723 * if the parser found the option in the config file.
725 static OptionInfoRec FlagOptions[] = {
726 {FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
728 {FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
730 {FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
732 {FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
734 {FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
736 {FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
738 {FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
740 {FLAG_SAVER_BLANKTIME, "BlankTime", OPTV_INTEGER,
742 {FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
744 {FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
746 {FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
748 {FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
750 {FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
752 {FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
754 {FLAG_LOG, "Log", OPTV_STRING,
756 {FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
758 {FLAG_RANDR, "RandR", OPTV_BOOLEAN,
760 {FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
762 {FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
764 {FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
766 {FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
768 {FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
770 {FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
772 {FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
774 {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
776 {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
778 {-1, NULL, OPTV_NONE,
783 configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
785 XF86OptionPtr optp, tmp;
787 Pix24Flags pix24 = Pix24DontCare;
794 /* Default options. */
795 #ifndef _F_SET_XKB_DEFAULT_OPTIONS_FROM_CONFIGURE_
801 #else//_F_SET_XKB_DEFAULT_OPTIONS_FROM_CONFIGURE_
802 set.rules = XKB_DFLT_RULES?XKB_DFLT_RULES:"base";
803 set.model = XKB_DFLT_MODEL?XKB_DFLT_MODEL:"pc105";
804 set.layout = XKB_DFLT_LAYOUT?XKB_DFLT_LAYOUT:"us";
805 set.variant = XKB_DFLT_VARIANT?XKB_DFLT_VARIANT:NULL;
806 set.options = XKB_DFLT_OPTIONS?XKB_DFLT_OPTIONS:NULL;
807 #endif//_F_SET_XKB_DEFAULT_OPTIONS_FROM_CONFIGURE_
810 * Merge the ServerLayout and ServerFlags options. The former have
811 * precedence over the latter.
814 if (flagsconf && flagsconf->flg_option_lst)
815 optp = xf86optionListDup(flagsconf->flg_option_lst);
817 tmp = xf86optionListDup(layoutopts);
819 optp = xf86optionListMerge(optp, tmp);
824 xf86ProcessOptions(-1, optp, FlagOptions);
826 xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
827 xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
828 xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
829 xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
831 xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
832 if (xf86Info.ignoreABI) {
833 xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
836 if (xf86SIGIOSupported()) {
838 xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO,
839 USE_SIGIO_BY_DEFAULT);
840 if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
846 if (!xf86Info.useSIGIO) {
847 xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
849 else if (from == X_CONFIG) {
850 xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
854 xf86Info.useSIGIO = FALSE;
857 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
858 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
859 &xf86Info.autoAddDevices);
865 xf86Msg(from, "%sutomatically adding devices\n",
866 xf86Info.autoAddDevices ? "A" : "Not a");
868 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
869 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
870 &xf86Info.autoEnableDevices);
876 xf86Msg(from, "%sutomatically enabling devices\n",
877 xf86Info.autoEnableDevices ? "A" : "Not a");
879 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_GPU)) {
880 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_GPU,
881 &xf86Info.autoAddGPU);
887 xf86Msg(from, "%sutomatically adding GPU devices\n",
888 xf86Info.autoAddGPU ? "A" : "Not a");
890 * Set things up based on the config file information. Some of these
891 * settings may be overridden later when the command line options are
895 if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
896 xf86Info.vidModeEnabled = !value;
897 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
898 xf86Info.vidModeAllowNonLocal = value;
901 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
902 xf86Info.allowMouseOpenFail = value;
904 xf86Info.pmFlag = TRUE;
905 if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
906 xf86Info.pmFlag = !value;
908 if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
909 if (!xf86NameCmp(s, "flush")) {
910 xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
911 xf86Info.log = LogFlush;
912 LogSetParameter(XLOG_FLUSH, TRUE);
914 else if (!xf86NameCmp(s, "sync")) {
915 xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
916 xf86Info.log = LogSync;
917 LogSetParameter(XLOG_FLUSH, TRUE);
918 LogSetParameter(XLOG_SYNC, TRUE);
921 xf86Msg(X_WARNING, "Unknown Log option\n");
927 if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))) {
928 int policy = PictureParseCmapPolicy(s);
930 if (policy == PictureCmapPolicyInvalid)
931 xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
933 xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
934 PictureCmapPolicy = policy;
940 xf86Info.disableRandR = FALSE;
941 xf86Info.randRFrom = X_DEFAULT;
942 if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
943 xf86Info.disableRandR = !value;
944 xf86Info.randRFrom = X_CONFIG;
948 xf86Info.aiglx = TRUE;
949 xf86Info.aiglxFrom = X_DEFAULT;
950 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
951 xf86Info.aiglx = value;
952 xf86Info.aiglxFrom = X_CONFIG;
956 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
957 xf86Info.glxVisualsFrom = X_DEFAULT;
958 if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
959 if (!xf86NameCmp(s, "minimal")) {
960 xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
962 else if (!xf86NameCmp(s, "typical")) {
963 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
965 else if (!xf86NameCmp(s, "all")) {
966 xf86Info.glxVisuals = XF86_GlxVisualsAll;
969 xf86Msg(X_WARNING, "Unknown GlxVisuals option\n");
973 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
974 xf86Info.aiglx = value;
975 xf86Info.aiglxFrom = X_CONFIG;
979 /* if we're not hotplugging, force some input devices to exist */
980 xf86Info.forceInputDevices = !(xf86Info.autoAddDevices &&
981 xf86Info.autoEnableDevices);
983 /* when forcing input devices, we use kbd. otherwise evdev, so use the
984 * evdev rules set. */
986 if (!xf86Info.forceInputDevices)
992 /* Xkb default options. */
993 XkbInitRules(&set, rules, "pc105", "us", NULL, NULL);
994 XkbSetRulesDflts(&set);
995 XkbFreeRMLVOSet(&set, FALSE);
997 xf86Info.useDefaultFontPath = TRUE;
998 xf86Info.useDefaultFontPathFrom = X_DEFAULT;
999 if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
1000 xf86Info.useDefaultFontPath = value;
1001 xf86Info.useDefaultFontPathFrom = X_CONFIG;
1004 /* Make sure that timers don't overflow CARD32's after multiplying */
1005 #define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
1008 xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
1009 if ((i >= 0) && (i < MAX_TIME_IN_MIN))
1010 ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
1013 ("BlankTime value %d outside legal range of 0 - %d minutes", i,
1016 #ifdef DPMSExtension
1018 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
1019 if ((i >= 0) && (i < MAX_TIME_IN_MIN))
1020 DPMSStandbyTime = i * MILLI_PER_MIN;
1023 ("StandbyTime value %d outside legal range of 0 - %d minutes", i,
1026 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
1027 if ((i >= 0) && (i < MAX_TIME_IN_MIN))
1028 DPMSSuspendTime = i * MILLI_PER_MIN;
1031 ("SuspendTime value %d outside legal range of 0 - %d minutes", i,
1034 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
1035 if ((i >= 0) && (i < MAX_TIME_IN_MIN))
1036 DPMSOffTime = i * MILLI_PER_MIN;
1039 ("OffTime value %d outside legal range of 0 - %d minutes", i,
1044 xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
1055 xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
1058 if (xf86Pix24 != Pix24DontCare) {
1059 xf86Info.pixmap24 = xf86Pix24;
1060 xf86Info.pix24From = X_CMDLINE;
1062 else if (pix24 != Pix24DontCare) {
1063 xf86Info.pixmap24 = pix24;
1064 xf86Info.pix24From = X_CONFIG;
1067 xf86Info.pixmap24 = Pix24DontCare;
1068 xf86Info.pix24From = X_DEFAULT;
1073 if (!noPanoramiXExtension)
1075 else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
1076 noPanoramiXExtension = !value;
1079 if (!noPanoramiXExtension)
1080 xf86Msg(from, "Xinerama: enabled\n");
1084 xf86Info.dri2 = FALSE;
1085 xf86Info.dri2From = X_DEFAULT;
1086 if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
1087 xf86Info.dri2 = value;
1088 xf86Info.dri2From = X_CONFIG;
1096 xf86DRI2Enabled(void)
1098 return xf86Info.dri2;
1102 * Search for the pInfo in the null-terminated list given and remove (and
1103 * free) it if present. All other devices are moved forward.
1106 freeDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1110 for (devs = list; devs && *devs; devs++) {
1111 if (*devs == pInfo) {
1113 for (; devs && *devs; devs++)
1121 * Append pInfo to the null-terminated list, allocating space as necessary.
1122 * pInfo is used as the last element.
1124 static InputInfoPtr *
1125 addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1130 for (devs = list; devs && *devs; devs++)
1133 list = xnfrealloc(list, (count + 1) * sizeof(InputInfoPtr));
1136 list[count - 1] = pInfo;
1141 * Locate the core input devices. These can be specified/located in
1142 * the following ways, in order of priority:
1144 * 1. The InputDevices named by the -pointer and -keyboard command line
1146 * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
1147 * the active ServerLayout.
1148 * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
1149 * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
1150 * driver (mouse, synaptics, evdev, vmmouse, void)
1151 * 5. Default devices with an empty (default) configuration. These defaults
1152 * will reference the 'mouse' and 'keyboard' drivers.
1156 checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
1158 InputInfoPtr corePointer = NULL, coreKeyboard = NULL;
1159 Bool foundPointer = FALSE, foundKeyboard = FALSE;
1160 const char *pointerMsg = NULL, *keyboardMsg = NULL;
1161 InputInfoPtr *devs, /* iterator */
1163 InputInfoPtr Pointer, Keyboard;
1164 XF86ConfInputPtr confInput;
1165 XF86ConfInputRec defPtr, defKbd;
1166 MessageType from = X_DEFAULT;
1168 const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
1173 * First check if a core pointer or core keyboard have been specified
1174 * in the active ServerLayout. If more than one is specified for either,
1175 * remove the core attribute from the later ones.
1177 for (devs = servlayoutp->inputs; devs && *devs; devs++) {
1179 if (indp->options &&
1180 xf86CheckBoolOption(indp->options, "CorePointer", FALSE)) {
1185 if (indp->options &&
1186 xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE)) {
1187 if (!coreKeyboard) {
1188 coreKeyboard = indp;
1195 /* 1. Check for the -pointer command line option. */
1196 if (xf86PointerName) {
1197 confInput = xf86findInput(xf86PointerName,
1198 xf86configptr->conf_input_lst);
1200 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1206 * If one was already specified in the ServerLayout, it needs to be
1210 freeDevice(servlayoutp->inputs, corePointer);
1213 foundPointer = TRUE;
1216 /* 2. ServerLayout-specified core pointer. */
1218 foundPointer = TRUE;
1222 /* 3. First core pointer device. */
1223 if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
1226 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1227 if (p->inp_option_lst &&
1228 xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE)) {
1230 foundPointer = TRUE;
1232 pointerMsg = "first core pointer device";
1238 /* 4. First pointer with an allowed mouse driver. */
1239 if (!foundPointer && xf86Info.forceInputDevices) {
1240 const char **driver = mousedrivers;
1242 confInput = xf86findInput(CONF_IMPLICIT_POINTER,
1243 xf86configptr->conf_input_lst);
1244 while (*driver && !confInput) {
1245 confInput = xf86findInputByDriver(*driver,
1246 xf86configptr->conf_input_lst);
1250 foundPointer = TRUE;
1252 pointerMsg = "first mouse device";
1256 /* 5. Built-in default. */
1257 if (!foundPointer && xf86Info.forceInputDevices) {
1258 memset(&defPtr, 0, sizeof(defPtr));
1259 defPtr.inp_identifier = strdup("<default pointer>");
1260 defPtr.inp_driver = strdup("mouse");
1261 confInput = &defPtr;
1262 foundPointer = TRUE;
1264 pointerMsg = "default mouse configuration";
1267 /* Add the core pointer device to the layout, and set it to Core. */
1268 if (foundPointer && confInput) {
1269 Pointer = xf86AllocateInput();
1271 foundPointer = configInput(Pointer, confInput, from);
1273 Pointer->options = xf86AddNewOption(Pointer->options,
1274 "CorePointer", "on");
1275 Pointer->options = xf86AddNewOption(Pointer->options,
1277 confInput->inp_driver);
1279 xf86AddNewOption(Pointer->options, "identifier",
1280 confInput->inp_identifier);
1281 servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
1285 if (!foundPointer && xf86Info.forceInputDevices) {
1286 /* This shouldn't happen. */
1287 xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
1288 xf86DeleteInput(Pointer, 0);
1294 /* 1. Check for the -keyboard command line option. */
1295 if (xf86KeyboardName) {
1296 confInput = xf86findInput(xf86KeyboardName,
1297 xf86configptr->conf_input_lst);
1299 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1305 * If one was already specified in the ServerLayout, it needs to be
1309 freeDevice(servlayoutp->inputs, coreKeyboard);
1310 coreKeyboard = NULL;
1312 foundKeyboard = TRUE;
1315 /* 2. ServerLayout-specified core keyboard. */
1317 foundKeyboard = TRUE;
1321 /* 3. First core keyboard device. */
1322 if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
1325 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1326 if (p->inp_option_lst &&
1327 xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE)) {
1329 foundKeyboard = TRUE;
1331 keyboardMsg = "first core keyboard device";
1337 /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
1338 if (!foundKeyboard && xf86Info.forceInputDevices) {
1339 confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD,
1340 xf86configptr->conf_input_lst);
1342 confInput = xf86findInputByDriver("kbd",
1343 xf86configptr->conf_input_lst);
1346 foundKeyboard = TRUE;
1348 keyboardMsg = "first keyboard device";
1352 /* 5. Built-in default. */
1353 if (!foundKeyboard && xf86Info.forceInputDevices) {
1354 memset(&defKbd, 0, sizeof(defKbd));
1355 defKbd.inp_identifier = strdup("<default keyboard>");
1356 defKbd.inp_driver = strdup("kbd");
1357 confInput = &defKbd;
1358 foundKeyboard = TRUE;
1359 keyboardMsg = "default keyboard configuration";
1363 /* Add the core keyboard device to the layout, and set it to Core. */
1364 if (foundKeyboard && confInput) {
1365 Keyboard = xf86AllocateInput();
1367 foundKeyboard = configInput(Keyboard, confInput, from);
1368 if (foundKeyboard) {
1369 Keyboard->options = xf86AddNewOption(Keyboard->options,
1370 "CoreKeyboard", "on");
1371 Keyboard->options = xf86AddNewOption(Keyboard->options,
1373 confInput->inp_driver);
1375 xf86AddNewOption(Keyboard->options, "identifier",
1376 confInput->inp_identifier);
1377 servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
1381 if (!foundKeyboard && xf86Info.forceInputDevices) {
1382 /* This shouldn't happen. */
1383 xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
1384 xf86DeleteInput(Keyboard, 0);
1390 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1393 xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
1394 "explicitly in the layout.\n"
1395 "\tUsing the %s.\n", pointerMsg);
1400 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1403 xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
1404 "explicitly in the layout.\n"
1405 "\tUsing the %s.\n", keyboardMsg);
1408 if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
1409 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1410 const char *config_backend;
1412 #if defined(CONFIG_HAL)
1413 config_backend = "HAL";
1414 #elif defined(CONFIG_UDEV)
1415 config_backend = "udev";
1417 config_backend = "wscons";
1419 xf86Msg(X_INFO, "The server relies on %s to provide the list of "
1420 "input devices.\n\tIf no devices become available, "
1421 "reconfigure %s or disable AutoAddDevices.\n",
1422 config_backend, config_backend);
1424 xf86Msg(X_WARNING, "Hotplugging requested but the server was "
1425 "compiled without a config backend. "
1426 "No input devices were configured, the server "
1427 "will start without any input devices.\n");
1435 LAYOUT_ISOLATEDEVICE,
1439 static OptionInfoRec LayoutOptions[] = {
1440 {LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
1442 {LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
1444 {-1, NULL, OPTV_NONE,
1449 configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
1451 XF86ConfInputrefPtr irp;
1456 * Count the number of input devices.
1458 irp = layout->lay_input_lst;
1461 irp = (XF86ConfInputrefPtr) irp->list.next;
1463 DebugF("Found %d input devices in the layout section %s\n",
1464 count, layout->lay_identifier);
1465 indp = xnfcalloc((count + 1), sizeof(InputInfoPtr));
1467 irp = layout->lay_input_lst;
1470 indp[count] = xf86AllocateInput();
1471 if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
1478 indp[count]->options = xf86OptionListMerge(indp[count]->options,
1479 irp->iref_option_lst);
1481 irp = (XF86ConfInputrefPtr) irp->list.next;
1483 servlayoutp->inputs = indp;
1489 * figure out which layout is active, which screens are used in that layout,
1490 * which drivers and monitors are used in these screens
1493 configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
1494 char *default_layout)
1496 XF86ConfAdjacencyPtr adjp;
1497 XF86ConfInactivePtr idp;
1498 int saved_count, count = 0;
1500 XF86ConfLayoutPtr l;
1502 screenLayoutPtr slp;
1510 * which layout section is the active one?
1512 * If there is a -layout command line option, use that one, otherwise
1513 * pick the first one.
1516 if (xf86LayoutName != NULL)
1518 else if (default_layout) {
1519 xf86LayoutName = default_layout;
1522 if (xf86LayoutName != NULL) {
1523 if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL) {
1524 xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
1530 xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
1531 adjp = conf_layout->lay_adjacency_lst;
1534 * we know that each screen is referenced exactly once on the left side
1535 * of a layout statement in the Layout section. So to allocate the right
1536 * size for the array we do a quick walk of the list to figure out how
1537 * many sections we have
1541 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1544 DebugF("Found %d screens in the layout section %s",
1545 count, conf_layout->lay_identifier);
1546 if (!count) /* alloc enough storage even if no screen is specified */
1549 slp = xnfcalloc(1, (count + 1) * sizeof(screenLayoutRec));
1550 slp[count].screen = NULL;
1552 * now that we have storage, loop over the list again and fill in our
1553 * data structure; at this point we do not fill in the adjacency
1554 * information as it is not clear if we need it at all
1556 adjp = conf_layout->lay_adjacency_lst;
1559 slp[count].screen = xnfcalloc(1, sizeof(confScreenRec));
1560 if (adjp->adj_scrnum < 0)
1563 scrnum = adjp->adj_scrnum;
1564 if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
1567 free(slp[count].screen);
1572 slp[count].x = adjp->adj_x;
1573 slp[count].y = adjp->adj_y;
1574 slp[count].refname = adjp->adj_refscreen;
1575 switch (adjp->adj_where) {
1576 case CONF_ADJ_OBSOLETE:
1577 slp[count].where = PosObsolete;
1578 slp[count].topname = adjp->adj_top_str;
1579 slp[count].bottomname = adjp->adj_bottom_str;
1580 slp[count].leftname = adjp->adj_left_str;
1581 slp[count].rightname = adjp->adj_right_str;
1583 case CONF_ADJ_ABSOLUTE:
1584 slp[count].where = PosAbsolute;
1586 case CONF_ADJ_RIGHTOF:
1587 slp[count].where = PosRightOf;
1589 case CONF_ADJ_LEFTOF:
1590 slp[count].where = PosLeftOf;
1592 case CONF_ADJ_ABOVE:
1593 slp[count].where = PosAbove;
1595 case CONF_ADJ_BELOW:
1596 slp[count].where = PosBelow;
1598 case CONF_ADJ_RELATIVE:
1599 slp[count].where = PosRelative;
1603 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1606 /* No screen was specified in the layout. take the first one from the
1607 * config file, or - if it is NULL - configScreen autogenerates one for
1610 XF86ConfScreenPtr screen;
1612 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
1613 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
1614 if (!configScreen(slp[0].screen, screen,
1616 free(slp[0].screen);
1622 /* XXX Need to tie down the upper left screen. */
1624 /* Fill in the refscreen and top/bottom/left/right values */
1625 for (i = 0; i < count; i++) {
1626 for (j = 0; j < count; j++) {
1627 if (slp[i].refname &&
1628 strcmp(slp[i].refname, slp[j].screen->id) == 0) {
1629 slp[i].refscreen = slp[j].screen;
1631 if (slp[i].topname &&
1632 strcmp(slp[i].topname, slp[j].screen->id) == 0) {
1633 slp[i].top = slp[j].screen;
1635 if (slp[i].bottomname &&
1636 strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
1637 slp[i].bottom = slp[j].screen;
1639 if (slp[i].leftname &&
1640 strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
1641 slp[i].left = slp[j].screen;
1643 if (slp[i].rightname &&
1644 strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
1645 slp[i].right = slp[j].screen;
1648 if (slp[i].where != PosObsolete
1649 && slp[i].where != PosAbsolute && !slp[i].refscreen) {
1650 xf86Msg(X_ERROR, "Screen %s doesn't exist: deleting placement\n",
1652 slp[i].where = PosAbsolute;
1661 saved_count = count;
1663 * Count the number of inactive devices.
1666 idp = conf_layout->lay_inactive_lst;
1669 idp = (XF86ConfInactivePtr) idp->list.next;
1671 DebugF("Found %d inactive devices in the layout section %s\n",
1672 count, conf_layout->lay_identifier);
1673 gdp = xnfalloc((count + 1) * sizeof(GDevRec));
1674 gdp[count].identifier = NULL;
1675 idp = conf_layout->lay_inactive_lst;
1678 if (!configDevice(&gdp[count], idp->inactive_device, FALSE))
1681 idp = (XF86ConfInactivePtr) idp->list.next;
1684 if (!configInputDevices(conf_layout, servlayoutp))
1687 servlayoutp->id = conf_layout->lay_identifier;
1688 servlayoutp->screens = slp;
1689 servlayoutp->inactives = gdp;
1690 servlayoutp->options = conf_layout->lay_option_lst;
1697 free(slp[saved_count].screen);
1698 } while (saved_count--);
1705 * No layout section, so find the first Screen section and set that up as
1706 * the only active screen.
1709 configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
1710 XF86ConfigPtr conf_ptr)
1713 XF86ConfScreenPtr s;
1714 screenLayoutPtr slp;
1716 XF86ConfLayoutRec layout;
1722 * which screen section is the active one?
1724 * If there is a -screen option, use that one, otherwise use the first
1729 if (xf86ScreenName != NULL) {
1730 if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL) {
1731 xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
1739 /* We have exactly one screen */
1741 slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec));
1742 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec));
1743 slp[1].screen = NULL;
1744 if (!configScreen(slp[0].screen, conf_screen, 0, from)) {
1748 servlayoutp->id = "(implicit)";
1749 servlayoutp->screens = slp;
1750 servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec));
1751 servlayoutp->options = NULL;
1753 memset(&layout, 0, sizeof(layout));
1754 layout.lay_identifier = servlayoutp->id;
1755 if (xf86layoutAddInputDevices(conf_ptr, &layout) > 0) {
1756 if (!configInputDevices(&layout, servlayoutp))
1761 /* Set up an empty input device list, then look for some core devices. */
1762 indp = xnfalloc(sizeof(InputInfoPtr));
1764 servlayoutp->inputs = indp;
1771 configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
1774 XF86ConfVideoPortPtr conf_port;
1776 xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
1777 conf_adaptor->va_identifier);
1778 adaptor->identifier = conf_adaptor->va_identifier;
1779 adaptor->options = conf_adaptor->va_option_lst;
1780 if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
1781 xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
1786 * figure out how many videoport subsections there are and fill them in
1788 conf_port = conf_adaptor->va_port_lst;
1791 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1793 adaptor->ports = xnfalloc((count) * sizeof(confXvPortRec));
1794 adaptor->numports = count;
1796 conf_port = conf_adaptor->va_port_lst;
1798 adaptor->ports[count].identifier = conf_port->vp_identifier;
1799 adaptor->ports[count].options = conf_port->vp_option_lst;
1801 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1808 configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
1812 XF86ConfDisplayPtr dispptr;
1813 XF86ConfAdaptorLinkPtr conf_adaptor;
1814 Bool defaultMonitor = FALSE;
1815 XF86ConfScreenRec local_conf_screen;
1818 memset(&local_conf_screen, 0, sizeof(local_conf_screen));
1819 conf_screen = &local_conf_screen;
1820 conf_screen->scrn_identifier = "Default Screen Section";
1821 xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
1824 xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
1827 * now we fill in the elements of the screen
1829 screenp->id = conf_screen->scrn_identifier;
1830 screenp->screennum = scrnum;
1831 screenp->defaultdepth = conf_screen->scrn_defaultdepth;
1832 screenp->defaultbpp = conf_screen->scrn_defaultbpp;
1833 screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
1834 screenp->monitor = xnfcalloc(1, sizeof(MonRec));
1835 /* If no monitor is specified, create a default one. */
1836 if (!conf_screen->scrn_monitor) {
1837 XF86ConfMonitorRec defMon;
1839 memset(&defMon, 0, sizeof(defMon));
1840 defMon.mon_identifier = "<default monitor>";
1841 if (!configMonitor(screenp->monitor, &defMon))
1843 defaultMonitor = TRUE;
1846 if (!configMonitor(screenp->monitor, conf_screen->scrn_monitor))
1849 /* Configure the device. If there isn't one configured, attach to the
1850 * first inactive one that we can configure. If there's none that work,
1851 * set it to NULL so that the section can be autoconfigured later */
1852 screenp->device = xnfcalloc(1, sizeof(GDevRec));
1853 if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
1854 FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device);
1855 xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
1856 "\tUsing the first device section listed.\n", screenp->id);
1858 if (configDevice(screenp->device, conf_screen->scrn_device, TRUE)) {
1859 screenp->device->myScreenSection = screenp;
1862 screenp->device = NULL;
1864 screenp->options = conf_screen->scrn_option_lst;
1867 * figure out how many display subsections there are and fill them in
1869 dispptr = conf_screen->scrn_display_lst;
1872 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1874 screenp->displays = xnfalloc((count) * sizeof(DispRec));
1875 screenp->numdisplays = count;
1877 /* Fill in the default Virtual size, if any */
1878 if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
1879 for (count = 0, dispptr = conf_screen->scrn_display_lst;
1881 dispptr = (XF86ConfDisplayPtr) dispptr->list.next, count++) {
1882 screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
1883 screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
1887 /* Now do the per-Display Virtual sizes */
1889 dispptr = conf_screen->scrn_display_lst;
1891 configDisplay(&(screenp->displays[count]), dispptr);
1893 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1897 * figure out how many videoadaptor references there are and fill them in
1899 conf_adaptor = conf_screen->scrn_adaptor_lst;
1900 while (conf_adaptor) {
1902 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1904 screenp->xvadaptors = xnfalloc((count) * sizeof(confXvAdaptorRec));
1905 screenp->numxvadaptors = 0;
1906 conf_adaptor = conf_screen->scrn_adaptor_lst;
1907 while (conf_adaptor) {
1908 if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
1909 conf_adaptor->al_adaptor))
1910 screenp->numxvadaptors++;
1911 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1914 if (defaultMonitor) {
1915 xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
1916 "\tUsing a default monitor configuration.\n", screenp->id);
1922 MON_REDUCEDBLANKING,
1926 static OptionInfoRec MonitorOptions[] = {
1927 {MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
1929 {MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
1931 {-1, NULL, OPTV_NONE,
1936 configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
1939 DisplayModePtr mode, last = NULL;
1940 XF86ConfModeLinePtr cmodep;
1941 XF86ConfModesPtr modes;
1942 XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
1943 Gamma zeros = { 0.0, 0.0, 0.0 };
1944 float badgamma = 0.0;
1947 xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n", conf_monitor->mon_identifier);
1948 monitorp->id = conf_monitor->mon_identifier;
1949 monitorp->vendor = conf_monitor->mon_vendor;
1950 monitorp->model = conf_monitor->mon_modelname;
1951 monitorp->Modes = NULL;
1952 monitorp->Last = NULL;
1953 monitorp->gamma = zeros;
1954 monitorp->widthmm = conf_monitor->mon_width;
1955 monitorp->heightmm = conf_monitor->mon_height;
1956 monitorp->reducedblanking = FALSE;
1957 monitorp->maxPixClock = 0;
1958 monitorp->options = conf_monitor->mon_option_lst;
1961 * fill in the monitor structure
1964 count < conf_monitor->mon_n_hsync && count < MAX_HSYNC; count++) {
1965 monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
1966 monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
1968 monitorp->nHsync = count;
1970 count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH;
1972 monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
1973 monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
1975 monitorp->nVrefresh = count;
1978 * first we collect the mode lines from the UseModes directive
1981 modes = xf86findModes(modeslnk->ml_modes_str,
1982 xf86configptr->conf_modes_lst);
1983 modeslnk->ml_modes = modes;
1985 /* now add the modes found in the modes
1986 section to the list of modes for this
1987 monitor unless it has been added before
1988 because we are reusing the same section
1989 for another screen */
1990 if (xf86itemNotSublist((GenericListPtr) conf_monitor->mon_modeline_lst,
1991 (GenericListPtr) modes->mon_modeline_lst)) {
1992 conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
1993 xf86addListItem((GenericListPtr) conf_monitor->mon_modeline_lst,
1994 (GenericListPtr) modes->mon_modeline_lst);
1996 modeslnk = modeslnk->list.next;
2000 * we need to hook in the mode lines now
2001 * here both data structures use lists, only our internal one
2004 cmodep = conf_monitor->mon_modeline_lst;
2006 mode = xnfcalloc(1, sizeof(DisplayModeRec));
2008 mode->Clock = cmodep->ml_clock;
2009 mode->HDisplay = cmodep->ml_hdisplay;
2010 mode->HSyncStart = cmodep->ml_hsyncstart;
2011 mode->HSyncEnd = cmodep->ml_hsyncend;
2012 mode->HTotal = cmodep->ml_htotal;
2013 mode->VDisplay = cmodep->ml_vdisplay;
2014 mode->VSyncStart = cmodep->ml_vsyncstart;
2015 mode->VSyncEnd = cmodep->ml_vsyncend;
2016 mode->VTotal = cmodep->ml_vtotal;
2017 mode->Flags = cmodep->ml_flags;
2018 mode->HSkew = cmodep->ml_hskew;
2019 mode->VScan = cmodep->ml_vscan;
2020 mode->name = xnfstrdup(cmodep->ml_identifier);
2027 * this is the first mode
2029 monitorp->Modes = mode;
2033 cmodep = (XF86ConfModeLinePtr) cmodep->list.next;
2038 monitorp->Last = last;
2040 /* add the (VESA) default modes */
2041 if (!addDefaultModes(monitorp))
2044 if (conf_monitor->mon_gamma_red > GAMMA_ZERO)
2045 monitorp->gamma.red = conf_monitor->mon_gamma_red;
2046 if (conf_monitor->mon_gamma_green > GAMMA_ZERO)
2047 monitorp->gamma.green = conf_monitor->mon_gamma_green;
2048 if (conf_monitor->mon_gamma_blue > GAMMA_ZERO)
2049 monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
2051 /* Check that the gamma values are within range */
2052 if (monitorp->gamma.red > GAMMA_ZERO &&
2053 (monitorp->gamma.red < GAMMA_MIN || monitorp->gamma.red > GAMMA_MAX)) {
2054 badgamma = monitorp->gamma.red;
2056 else if (monitorp->gamma.green > GAMMA_ZERO &&
2057 (monitorp->gamma.green < GAMMA_MIN ||
2058 monitorp->gamma.green > GAMMA_MAX)) {
2059 badgamma = monitorp->gamma.green;
2061 else if (monitorp->gamma.blue > GAMMA_ZERO &&
2062 (monitorp->gamma.blue < GAMMA_MIN ||
2063 monitorp->gamma.blue > GAMMA_MAX)) {
2064 badgamma = monitorp->gamma.blue;
2066 if (badgamma > GAMMA_ZERO) {
2067 xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
2068 badgamma, GAMMA_MIN, GAMMA_MAX);
2072 xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
2073 xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
2074 &monitorp->reducedblanking);
2075 if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
2076 &maxPixClock) == TRUE) {
2077 monitorp->maxPixClock = (int) maxPixClock;
2084 lookupVisual(const char *visname)
2088 if (!visname || !*visname)
2091 for (i = 0; i <= DirectColor; i++) {
2092 if (!xf86nameCompare(visname, xf86VisualNames[i]))
2096 if (i <= DirectColor)
2103 configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
2108 displayp->frameX0 = conf_display->disp_frameX0;
2109 displayp->frameY0 = conf_display->disp_frameY0;
2110 displayp->virtualX = conf_display->disp_virtualX;
2111 displayp->virtualY = conf_display->disp_virtualY;
2112 displayp->depth = conf_display->disp_depth;
2113 displayp->fbbpp = conf_display->disp_bpp;
2114 displayp->weight.red = conf_display->disp_weight.red;
2115 displayp->weight.green = conf_display->disp_weight.green;
2116 displayp->weight.blue = conf_display->disp_weight.blue;
2117 displayp->blackColour.red = conf_display->disp_black.red;
2118 displayp->blackColour.green = conf_display->disp_black.green;
2119 displayp->blackColour.blue = conf_display->disp_black.blue;
2120 displayp->whiteColour.red = conf_display->disp_white.red;
2121 displayp->whiteColour.green = conf_display->disp_white.green;
2122 displayp->whiteColour.blue = conf_display->disp_white.blue;
2123 displayp->options = conf_display->disp_option_lst;
2124 if (conf_display->disp_visual) {
2125 displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
2126 if (displayp->defaultVisual == -1) {
2127 xf86ConfigError("Invalid visual name: \"%s\"",
2128 conf_display->disp_visual);
2133 displayp->defaultVisual = -1;
2137 * now hook in the modes
2139 modep = conf_display->disp_mode_lst;
2142 modep = (XF86ModePtr) modep->list.next;
2144 displayp->modes = xnfalloc((count + 1) * sizeof(char *));
2145 modep = conf_display->disp_mode_lst;
2148 displayp->modes[count] = modep->mode_name;
2150 modep = (XF86ModePtr) modep->list.next;
2152 displayp->modes[count] = NULL;
2158 configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active)
2167 xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
2168 conf_device->dev_identifier);
2170 xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
2171 conf_device->dev_identifier);
2173 devicep->identifier = conf_device->dev_identifier;
2174 devicep->vendor = conf_device->dev_vendor;
2175 devicep->board = conf_device->dev_board;
2176 devicep->chipset = conf_device->dev_chipset;
2177 devicep->ramdac = conf_device->dev_ramdac;
2178 devicep->driver = conf_device->dev_driver;
2179 devicep->active = active;
2180 devicep->videoRam = conf_device->dev_videoram;
2181 devicep->BiosBase = conf_device->dev_bios_base;
2182 devicep->MemBase = conf_device->dev_mem_base;
2183 devicep->IOBase = conf_device->dev_io_base;
2184 devicep->clockchip = conf_device->dev_clockchip;
2185 devicep->busID = conf_device->dev_busid;
2186 devicep->textClockFreq = conf_device->dev_textclockfreq;
2187 devicep->chipID = conf_device->dev_chipid;
2188 devicep->chipRev = conf_device->dev_chiprev;
2189 devicep->options = conf_device->dev_option_lst;
2190 devicep->irq = conf_device->dev_irq;
2191 devicep->screen = conf_device->dev_screen;
2193 for (i = 0; i < MAXDACSPEEDS; i++) {
2194 if (i < CONF_MAXDACSPEEDS)
2195 devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
2197 devicep->dacSpeeds[i] = 0;
2199 devicep->numclocks = conf_device->dev_clocks;
2200 if (devicep->numclocks > MAXCLOCKS)
2201 devicep->numclocks = MAXCLOCKS;
2202 for (i = 0; i < devicep->numclocks; i++) {
2203 devicep->clock[i] = conf_device->dev_clock[i];
2205 devicep->claimed = FALSE;
2212 configDRI(XF86ConfDRIPtr drip)
2216 xf86ConfigDRI.group = -1;
2217 xf86ConfigDRI.mode = 0;
2220 if (drip->dri_group_name) {
2221 if ((grp = getgrnam(drip->dri_group_name)))
2222 xf86ConfigDRI.group = grp->gr_gid;
2225 if (drip->dri_group >= 0)
2226 xf86ConfigDRI.group = drip->dri_group;
2228 xf86ConfigDRI.mode = drip->dri_mode;
2234 configExtensions(XF86ConfExtensionsPtr conf_ext)
2238 if (conf_ext && conf_ext->ext_option_lst) {
2239 for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
2240 char *name = xf86OptionName(o);
2241 char *val = xf86OptionValue(o);
2245 /* Handle "No<ExtensionName>" */
2246 n = xf86NormalizeName(name);
2247 if (strncmp(n, "no", 2) == 0) {
2253 xf86NameCmp(val, "enable") == 0 ||
2254 xf86NameCmp(val, "enabled") == 0 ||
2255 xf86NameCmp(val, "on") == 0 ||
2256 xf86NameCmp(val, "1") == 0 ||
2257 xf86NameCmp(val, "yes") == 0 || xf86NameCmp(val, "true") == 0) {
2258 /* NOTHING NEEDED -- enabling is handled below */
2260 else if (xf86NameCmp(val, "disable") == 0 ||
2261 xf86NameCmp(val, "disabled") == 0 ||
2262 xf86NameCmp(val, "off") == 0 ||
2263 xf86NameCmp(val, "0") == 0 ||
2264 xf86NameCmp(val, "no") == 0 ||
2265 xf86NameCmp(val, "false") == 0) {
2269 xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
2274 if (EnableDisableExtension(name, enable)) {
2275 xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
2276 name, enable ? "enabled" : "disabled");
2279 xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
2288 configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
2290 xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
2291 inputp->name = conf_input->inp_identifier;
2292 inputp->driver = conf_input->inp_driver;
2293 inputp->options = conf_input->inp_option_lst;
2294 inputp->attrs = NULL;
2300 modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
2302 DisplayModePtr knownmodes = monitorp->Modes;
2304 /* all I can think of is a linear search... */
2305 while (knownmodes != NULL) {
2306 if (!strcmp(mode->name, knownmodes->name) &&
2307 !(knownmodes->type & M_T_DEFAULT))
2309 knownmodes = knownmodes->next;
2315 addDefaultModes(MonPtr monitorp)
2317 DisplayModePtr mode;
2318 DisplayModePtr last = monitorp->Last;
2321 for (i = 0; i < xf86NumDefaultModes; i++) {
2322 mode = xf86DuplicateMode(&xf86DefaultModes[i]);
2323 if (!modeIsPresent(mode, monitorp)) {
2324 monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
2331 monitorp->Last = last;
2337 checkInput(serverLayoutPtr layout, Bool implicit_layout)
2339 checkCoreInputDevices(layout, implicit_layout);
2341 /* Unless we're forcing input devices, disable mouse/kbd devices in the
2342 * config. Otherwise the same physical device is added multiple times,
2343 * leading to duplicate events.
2345 if (!xf86Info.forceInputDevices && layout->inputs) {
2346 InputInfoPtr *dev = layout->inputs;
2347 BOOL warned = FALSE;
2350 if (strcmp((*dev)->driver, "kbd") == 0 ||
2351 strcmp((*dev)->driver, "mouse") == 0 ||
2352 strcmp((*dev)->driver, "vmmouse") == 0) {
2353 InputInfoPtr *current;
2356 xf86Msg(X_WARNING, "Hotplugging is on, devices using "
2357 "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
2361 xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
2368 *current = *(current + 1);
2379 * load the config file and fill the global data structure
2382 xf86HandleConfigFile(Bool autoconfig)
2384 const char *scanptr;
2385 Bool singlecard = 0;
2386 Bool implicit_layout = FALSE;
2387 XF86ConfLayoutPtr layout;
2390 char *filename, *dirname, *sysdirname;
2391 const char *filesearch, *dirsearch;
2392 MessageType filefrom = X_DEFAULT;
2393 MessageType dirfrom = X_DEFAULT;
2395 if (!xf86PrivsElevated()) {
2396 filesearch = ALL_CONFIGPATH;
2397 dirsearch = ALL_CONFIGDIRPATH;
2400 filesearch = RESTRICTED_CONFIGPATH;
2401 dirsearch = RESTRICTED_CONFIGDIRPATH;
2405 filefrom = X_CMDLINE;
2407 dirfrom = X_CMDLINE;
2409 xf86initConfigFiles();
2410 sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH, NULL,
2412 dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT);
2413 filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT);
2415 xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
2416 xf86ConfigFile = xnfstrdup(filename);
2420 xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
2424 xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
2426 xf86ConfigDir = xnfstrdup(dirname);
2431 "Unable to locate/open config directory: \"%s\"\n",
2435 xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
2437 if (!filename && !dirname && !sysdirname)
2438 return CONFIG_NOFILE;
2445 if ((xf86configptr = xf86readConfigFile()) == NULL) {
2446 xf86Msg(X_ERROR, "Problem parsing the config file\n");
2447 return CONFIG_PARSE_ERROR;
2449 xf86closeConfigFile();
2451 /* Initialise a few things. */
2454 * now we convert part of the information contained in the parser
2455 * structures into our own structures.
2456 * The important part here is to figure out which Screen Sections
2457 * in the XF86Config file are active so that we can piece together
2458 * the modes that we need later down the road.
2459 * And while we are at it, we'll decode the rest of the stuff as well
2462 /* First check if a layout section is present, and if it is valid. */
2463 FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout);
2464 if (layout == NULL || xf86ScreenName != NULL) {
2465 XF86ConfScreenPtr screen;
2467 if (xf86ScreenName == NULL) {
2469 "No Layout section. Using the first Screen section.\n");
2471 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen);
2472 if (!configImpliedLayout(&xf86ConfigLayout,
2475 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2476 return CONFIG_PARSE_ERROR;
2478 implicit_layout = TRUE;
2481 if (xf86configptr->conf_flags != NULL) {
2482 char *dfltlayout = NULL;
2483 void *optlist = xf86configptr->conf_flags->flg_option_lst;
2485 if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
2487 xf86SetStrOption(optlist, "defaultserverlayout", NULL);
2488 if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
2489 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2490 return CONFIG_PARSE_ERROR;
2494 if (!configLayout(&xf86ConfigLayout, layout, NULL)) {
2495 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2496 return CONFIG_PARSE_ERROR;
2501 xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
2502 #ifdef XSERVER_LIBPCIACCESS
2503 if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
2504 ; /* IsolateDevice specified; overrides SingleCard */
2507 xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
2509 scanptr = xf86ConfigLayout.screens->screen->device->busID;
2512 if (strncmp(scanptr, "PCI:", 4) != 0) {
2513 xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
2514 "\tIgnoring IsolateDevice option.\n");
2517 xf86PciIsolateDevice(scanptr);
2520 /* Now process everything else */
2521 if (!configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options)) {
2522 ErrorF("Problem when converting the config data structures\n");
2523 return CONFIG_PARSE_ERROR;
2526 configFiles(xf86configptr->conf_files);
2527 configExtensions(xf86configptr->conf_extensions);
2529 configDRI(xf86configptr->conf_dri);
2532 checkInput(&xf86ConfigLayout, implicit_layout);
2535 * Handle some command line options that can override some of the
2536 * ServerFlags settings.
2539 if (xf86VidModeDisabled)
2540 xf86Info.vidModeEnabled = FALSE;
2541 if (xf86VidModeAllowNonLocal)
2542 xf86Info.vidModeAllowNonLocal = TRUE;
2545 if (xf86AllowMouseOpenFail)
2546 xf86Info.allowMouseOpenFail = TRUE;
2552 xf86PathIsSafe(const char *path)
2554 return (xf86pathIsSafe(path) != 0);