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 "/usr/share/X11/%X," "%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 *tmp_path
, *out_pnt
, *path_elem
, *next
, *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
);
236 * use the datastructure that the parser provides and pick out the parts
237 * that we need at this point
240 xf86ModulelistFromConfig(pointer
**optlist
)
242 int count
= 0, i
= 0;
245 const char *ignore
[] = { "GLcore", "speedo", "bitmap", "drm",
254 * make sure the config file has been parsed and that we have a
255 * ModulePath set; if no ModulePath was given, use the default
258 if (xf86configptr
== NULL
) {
259 xf86Msg(X_ERROR
, "Cannot access global config data structure\n");
263 if (xf86configptr
->conf_modules
) {
264 /* Walk the disable list and let people know what we've parsed to
267 modp
= xf86configptr
->conf_modules
->mod_disable_lst
;
270 "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n",
272 modp
= (XF86LoadPtr
) modp
->list
.next
;
275 * Walk the default settings table. For each module listed to be
276 * loaded, make sure it's in the mod_load_lst. If it's not, make
277 * sure it's not in the mod_no_load_lst. If it's not disabled,
278 * append it to mod_load_lst
280 for (i
= 0; ModuleDefaults
[i
].name
!= NULL
; i
++) {
281 if (ModuleDefaults
[i
].toLoad
== FALSE
) {
283 "\"%s\" is not to be loaded by default. Skipping.\n",
284 ModuleDefaults
[i
].name
);
288 modp
= xf86configptr
->conf_modules
->mod_load_lst
;
290 if (strcmp(modp
->load_name
, ModuleDefaults
[i
].name
) == 0) {
292 "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n",
293 ModuleDefaults
[i
].name
);
297 modp
= (XF86LoadPtr
) modp
->list
.next
;
299 if (found
== FALSE
) {
300 modp
= xf86configptr
->conf_modules
->mod_disable_lst
;
302 if (strcmp(modp
->load_name
, ModuleDefaults
[i
].name
) == 0) {
304 "\"%s\" will be loaded even though the default is to disable it.\n",
305 ModuleDefaults
[i
].name
);
309 modp
= (XF86LoadPtr
) modp
->list
.next
;
312 if (found
== FALSE
) {
313 XF86LoadPtr ptr
= (XF86LoadPtr
) xf86configptr
->conf_modules
;
315 xf86addNewLoadDirective(ptr
, ModuleDefaults
[i
].name
,
317 ModuleDefaults
[i
].load_opt
);
318 xf86Msg(X_INFO
, "\"%s\" will be loaded by default.\n",
319 ModuleDefaults
[i
].name
);
324 xf86configptr
->conf_modules
= xnfcalloc(1, sizeof(XF86ConfModuleRec
));
325 for (i
= 0; ModuleDefaults
[i
].name
!= NULL
; i
++) {
326 if (ModuleDefaults
[i
].toLoad
== TRUE
) {
327 XF86LoadPtr ptr
= (XF86LoadPtr
) xf86configptr
->conf_modules
;
329 xf86addNewLoadDirective(ptr
, ModuleDefaults
[i
].name
,
331 ModuleDefaults
[i
].load_opt
);
337 * Walk the list of modules in the "Module" section to determine how
340 modp
= xf86configptr
->conf_modules
->mod_load_lst
;
342 for (i
= 0; ignore
[i
]; i
++) {
343 if (strcmp(modp
->load_name
, ignore
[i
]) == 0)
348 modp
= (XF86LoadPtr
) modp
->list
.next
;
352 * allocate the memory and walk the list again to fill in the pointers
354 modulearray
= xnfalloc((count
+ 1) * sizeof(char *));
355 optarray
= xnfalloc((count
+ 1) * sizeof(pointer
));
357 if (xf86configptr
->conf_modules
) {
358 modp
= xf86configptr
->conf_modules
->mod_load_lst
;
361 modulearray
[count
] = modp
->load_name
;
362 optarray
[count
] = modp
->load_opt
;
365 modp
= (XF86LoadPtr
) modp
->list
.next
;
368 modulearray
[count
] = NULL
;
369 optarray
[count
] = NULL
;
378 xf86DriverlistFromConfig(void)
386 * make sure the config file has been parsed and that we have a
387 * ModulePath set; if no ModulePath was given, use the default
390 if (xf86configptr
== NULL
) {
391 xf86Msg(X_ERROR
, "Cannot access global config data structure\n");
396 * Walk the list of driver lines in active "Device" sections to
397 * determine now many implicitly loaded modules there are.
400 if (xf86ConfigLayout
.screens
) {
401 slp
= xf86ConfigLayout
.screens
;
402 while ((slp
++)->screen
) {
408 * Handle the set of inactive "Device" sections.
411 while (xf86ConfigLayout
.inactives
[j
++].identifier
)
418 * allocate the memory and walk the list again to fill in the pointers
420 modulearray
= xnfalloc((count
+ 1) * sizeof(char *));
422 slp
= xf86ConfigLayout
.screens
;
423 while (slp
->screen
) {
424 modulearray
[count
] = slp
->screen
->device
->driver
;
431 while (xf86ConfigLayout
.inactives
[j
].identifier
)
432 modulearray
[count
++] = xf86ConfigLayout
.inactives
[j
++].driver
;
434 modulearray
[count
] = NULL
;
436 /* Remove duplicates */
437 for (count
= 0; modulearray
[count
] != NULL
; count
++) {
440 for (i
= 0; i
< count
; i
++)
441 if (xf86NameCmp(modulearray
[i
], modulearray
[count
]) == 0) {
442 modulearray
[count
] = "";
450 xf86InputDriverlistFromConfig(void)
457 * make sure the config file has been parsed and that we have a
458 * ModulePath set; if no ModulePath was given, use the default
461 if (xf86configptr
== NULL
) {
462 xf86Msg(X_ERROR
, "Cannot access global config data structure\n");
467 * Walk the list of driver lines in active "InputDevice" sections to
468 * determine now many implicitly loaded modules there are.
470 if (xf86ConfigLayout
.inputs
) {
471 idp
= xf86ConfigLayout
.inputs
;
482 * allocate the memory and walk the list again to fill in the pointers
484 modulearray
= xnfalloc((count
+ 1) * sizeof(char *));
486 idp
= xf86ConfigLayout
.inputs
;
487 while (idp
&& *idp
) {
488 modulearray
[count
] = (*idp
)->driver
;
492 modulearray
[count
] = NULL
;
494 /* Remove duplicates */
495 for (count
= 0; modulearray
[count
] != NULL
; count
++) {
498 for (i
= 0; i
< count
; i
++)
499 if (xf86NameCmp(modulearray
[i
], modulearray
[count
]) == 0) {
500 modulearray
[count
] = "";
508 fixup_video_driver_list(char **drivers
)
510 static const char *fallback
[4] = { "fbdev", "vesa", "wsfb", NULL
};
515 /* walk to the end of the list */
516 for (end
= drivers
; *end
&& **end
; end
++);
520 * for each of the fallback drivers, if we find it in the list,
521 * swap it with the last available non-fallback driver.
523 for (i
= 0; fallback
[i
]; i
++) {
524 for (drv
= drivers
; drv
!= end
; drv
++) {
525 if (strstr(*drv
, fallback
[i
])) {
537 GenerateDriverlist(const char *dirname
)
540 const char *subdirs
[] = { dirname
, NULL
};
541 static const char *patlist
[] = { "(.*)_drv\\.so", NULL
};
542 ret
= LoaderListDirs(subdirs
, patlist
);
544 /* fix up the probe order for video drivers */
545 if (strstr(dirname
, "drivers") && ret
!= NULL
)
546 fixup_video_driver_list(ret
);
552 xf86DriverlistFromCompile(void)
554 static char **driverlist
= NULL
;
557 driverlist
= GenerateDriverlist("drivers");
564 * Print a READABLE ErrorMessage!!! All information that is
565 * available is printed.
568 _X_ATTRIBUTE_PRINTF(1, 2)
569 xf86ConfigError(const char *msg
, ...)
573 ErrorF("\nConfig Error:\n");
582 configFiles(XF86ConfFilesPtr fileconf
)
584 MessageType pathFrom
;
587 char *temp_path
, *log_buf
, *start
, *end
;
592 temp_path
= defaultFontPath
? defaultFontPath
: "";
594 pathFrom
= X_CMDLINE
;
595 else if (fileconf
&& fileconf
->file_fontpath
) {
597 if (xf86Info
.useDefaultFontPath
) {
598 if (asprintf(&defaultFontPath
, "%s%s%s", fileconf
->file_fontpath
,
599 *temp_path
? "," : "", temp_path
) == -1)
600 defaultFontPath
= NULL
;
605 defaultFontPath
= fileconf
->file_fontpath
;
608 pathFrom
= X_DEFAULT
;
609 temp_path
= defaultFontPath
? defaultFontPath
: "";
611 /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
612 temp_path
= must_copy
? xnfstrdup(defaultFontPath
) : defaultFontPath
;
613 defaultFontPath
= xf86ValidateFontPath(temp_path
);
616 /* make fontpath more readable in the logfiles */
618 temp_path
= defaultFontPath
;
619 while ((temp_path
= index(temp_path
, ',')) != NULL
) {
624 log_buf
= xnfalloc(strlen(defaultFontPath
) + (2 * countDirs
) + 1);
626 start
= defaultFontPath
;
627 while ((end
= index(start
, ',')) != NULL
) {
628 size
= (end
- start
) + 1;
629 *(temp_path
++) = '\t';
630 strncpy(temp_path
, start
, size
);
632 *(temp_path
++) = '\n';
635 /* copy last entry */
636 *(temp_path
++) = '\t';
637 strcpy(temp_path
, start
);
638 xf86Msg(pathFrom
, "FontPath set to:\n%s\n", log_buf
);
644 if (xf86ModPathFrom
!= X_CMDLINE
&& fileconf
->file_modulepath
) {
645 xf86ModulePath
= fileconf
->file_modulepath
;
646 xf86ModPathFrom
= X_CONFIG
;
650 xf86Msg(xf86ModPathFrom
, "ModulePath set to \"%s\"\n", xf86ModulePath
);
652 if (!xf86xkbdirFlag
&& fileconf
&& fileconf
->file_xkbdir
) {
653 XkbBaseDirectory
= fileconf
->file_xkbdir
;
654 xf86Msg(X_CONFIG
, "XKB base directory set to \"%s\"\n",
660 * XXX The problem with this is that the log file is already open.
661 * One option might be to copy the exiting contents to the new location.
662 * and re-open it. The down side is that the default location would
663 * already have been overwritten. Another option would be to start with
664 * unique temporary location, then copy it once the correct name is known.
665 * A problem with this is what happens if the server exits before that
668 if (xf86LogFileFrom
== X_DEFAULT
&& fileconf
->file_logfile
) {
669 xf86LogFile
= fileconf
->file_logfile
;
670 xf86LogFileFrom
= X_CONFIG
;
684 FLAG_ALLOWMOUSEOPENFAIL
,
685 FLAG_SAVER_BLANKTIME
,
686 FLAG_DPMS_STANDBYTIME
,
687 FLAG_DPMS_SUSPENDTIME
,
693 FLAG_RENDER_COLORMAP_MODE
,
697 FLAG_ALLOW_EMPTY_INPUT
,
698 FLAG_USE_DEFAULT_FONT_PATH
,
699 FLAG_AUTO_ADD_DEVICES
,
700 FLAG_AUTO_ENABLE_DEVICES
,
708 * NOTE: the last value for each entry is NOT the default. It is set to TRUE
709 * if the parser found the option in the config file.
711 static OptionInfoRec FlagOptions
[] = {
712 {FLAG_NOTRAPSIGNALS
, "NoTrapSignals", OPTV_BOOLEAN
,
714 {FLAG_DONTVTSWITCH
, "DontVTSwitch", OPTV_BOOLEAN
,
716 {FLAG_DONTZAP
, "DontZap", OPTV_BOOLEAN
,
718 {FLAG_DONTZOOM
, "DontZoom", OPTV_BOOLEAN
,
720 {FLAG_DISABLEVIDMODE
, "DisableVidModeExtension", OPTV_BOOLEAN
,
722 {FLAG_ALLOWNONLOCAL
, "AllowNonLocalXvidtune", OPTV_BOOLEAN
,
724 {FLAG_ALLOWMOUSEOPENFAIL
, "AllowMouseOpenFail", OPTV_BOOLEAN
,
726 {FLAG_SAVER_BLANKTIME
, "BlankTime", OPTV_INTEGER
,
728 {FLAG_DPMS_STANDBYTIME
, "StandbyTime", OPTV_INTEGER
,
730 {FLAG_DPMS_SUSPENDTIME
, "SuspendTime", OPTV_INTEGER
,
732 {FLAG_DPMS_OFFTIME
, "OffTime", OPTV_INTEGER
,
734 {FLAG_PIXMAP
, "Pixmap", OPTV_INTEGER
,
736 {FLAG_NOPM
, "NoPM", OPTV_BOOLEAN
,
738 {FLAG_XINERAMA
, "Xinerama", OPTV_BOOLEAN
,
740 {FLAG_LOG
, "Log", OPTV_STRING
,
742 {FLAG_RENDER_COLORMAP_MODE
, "RenderColormapMode", OPTV_STRING
,
744 {FLAG_RANDR
, "RandR", OPTV_BOOLEAN
,
746 {FLAG_AIGLX
, "AIGLX", OPTV_BOOLEAN
,
748 {FLAG_IGNORE_ABI
, "IgnoreABI", OPTV_BOOLEAN
,
750 {FLAG_USE_DEFAULT_FONT_PATH
, "UseDefaultFontPath", OPTV_BOOLEAN
,
752 {FLAG_AUTO_ADD_DEVICES
, "AutoAddDevices", OPTV_BOOLEAN
,
754 {FLAG_AUTO_ENABLE_DEVICES
, "AutoEnableDevices", OPTV_BOOLEAN
,
756 {FLAG_GLX_VISUALS
, "GlxVisuals", OPTV_STRING
,
758 {FLAG_DRI2
, "DRI2", OPTV_BOOLEAN
,
760 {FLAG_USE_SIGIO
, "UseSIGIO", OPTV_BOOLEAN
,
762 {FLAG_AUTO_ADD_GPU
, "AutoAddGPU", OPTV_BOOLEAN
,
764 {-1, NULL
, OPTV_NONE
,
769 configServerFlags(XF86ConfFlagsPtr flagsconf
, XF86OptionPtr layoutopts
)
771 XF86OptionPtr optp
, tmp
;
773 Pix24Flags pix24
= Pix24DontCare
;
779 /* Default options. */
787 * Merge the ServerLayout and ServerFlags options. The former have
788 * precedence over the latter.
791 if (flagsconf
&& flagsconf
->flg_option_lst
)
792 optp
= xf86optionListDup(flagsconf
->flg_option_lst
);
794 tmp
= xf86optionListDup(layoutopts
);
796 optp
= xf86optionListMerge(optp
, tmp
);
801 xf86ProcessOptions(-1, optp
, FlagOptions
);
803 xf86GetOptValBool(FlagOptions
, FLAG_NOTRAPSIGNALS
, &xf86Info
.notrapSignals
);
804 xf86GetOptValBool(FlagOptions
, FLAG_DONTVTSWITCH
, &xf86Info
.dontVTSwitch
);
805 xf86GetOptValBool(FlagOptions
, FLAG_DONTZAP
, &xf86Info
.dontZap
);
806 xf86GetOptValBool(FlagOptions
, FLAG_DONTZOOM
, &xf86Info
.dontZoom
);
808 xf86GetOptValBool(FlagOptions
, FLAG_IGNORE_ABI
, &xf86Info
.ignoreABI
);
809 if (xf86Info
.ignoreABI
) {
810 xf86Msg(X_CONFIG
, "Ignoring ABI Version\n");
813 if (xf86SIGIOSupported()) {
815 xf86ReturnOptValBool(FlagOptions
, FLAG_USE_SIGIO
,
816 USE_SIGIO_BY_DEFAULT
);
817 if (xf86IsOptionSet(FlagOptions
, FLAG_USE_SIGIO
)) {
823 if (!xf86Info
.useSIGIO
) {
824 xf86Msg(from
, "Disabling SIGIO handlers for input devices\n");
826 else if (from
== X_CONFIG
) {
827 xf86Msg(from
, "Enabling SIGIO handlers for input devices\n");
831 xf86Info
.useSIGIO
= FALSE
;
834 if (xf86IsOptionSet(FlagOptions
, FLAG_AUTO_ADD_DEVICES
)) {
835 xf86GetOptValBool(FlagOptions
, FLAG_AUTO_ADD_DEVICES
,
836 &xf86Info
.autoAddDevices
);
842 xf86Msg(from
, "%sutomatically adding devices\n",
843 xf86Info
.autoAddDevices
? "A" : "Not a");
845 if (xf86IsOptionSet(FlagOptions
, FLAG_AUTO_ENABLE_DEVICES
)) {
846 xf86GetOptValBool(FlagOptions
, FLAG_AUTO_ENABLE_DEVICES
,
847 &xf86Info
.autoEnableDevices
);
853 xf86Msg(from
, "%sutomatically enabling devices\n",
854 xf86Info
.autoEnableDevices
? "A" : "Not a");
856 if (xf86IsOptionSet(FlagOptions
, FLAG_AUTO_ADD_GPU
)) {
857 xf86GetOptValBool(FlagOptions
, FLAG_AUTO_ADD_GPU
,
858 &xf86Info
.autoAddGPU
);
864 xf86Msg(from
, "%sutomatically adding GPU devices\n",
865 xf86Info
.autoAddGPU
? "A" : "Not a");
867 * Set things up based on the config file information. Some of these
868 * settings may be overridden later when the command line options are
872 if (xf86GetOptValBool(FlagOptions
, FLAG_DISABLEVIDMODE
, &value
))
873 xf86Info
.vidModeEnabled
= !value
;
874 if (xf86GetOptValBool(FlagOptions
, FLAG_ALLOWNONLOCAL
, &value
))
875 xf86Info
.vidModeAllowNonLocal
= value
;
878 if (xf86GetOptValBool(FlagOptions
, FLAG_ALLOWMOUSEOPENFAIL
, &value
))
879 xf86Info
.allowMouseOpenFail
= value
;
881 xf86Info
.pmFlag
= TRUE
;
882 if (xf86GetOptValBool(FlagOptions
, FLAG_NOPM
, &value
))
883 xf86Info
.pmFlag
= !value
;
885 if ((s
= xf86GetOptValString(FlagOptions
, FLAG_LOG
))) {
886 if (!xf86NameCmp(s
, "flush")) {
887 xf86Msg(X_CONFIG
, "Flushing logfile enabled\n");
888 xf86Info
.log
= LogFlush
;
889 LogSetParameter(XLOG_FLUSH
, TRUE
);
891 else if (!xf86NameCmp(s
, "sync")) {
892 xf86Msg(X_CONFIG
, "Syncing logfile enabled\n");
893 xf86Info
.log
= LogSync
;
894 LogSetParameter(XLOG_FLUSH
, TRUE
);
895 LogSetParameter(XLOG_SYNC
, TRUE
);
898 xf86Msg(X_WARNING
, "Unknown Log option\n");
904 if ((s
= xf86GetOptValString(FlagOptions
, FLAG_RENDER_COLORMAP_MODE
))) {
905 int policy
= PictureParseCmapPolicy(s
);
907 if (policy
== PictureCmapPolicyInvalid
)
908 xf86Msg(X_WARNING
, "Unknown colormap policy \"%s\"\n", s
);
910 xf86Msg(X_CONFIG
, "Render colormap policy set to %s\n", s
);
911 PictureCmapPolicy
= policy
;
917 xf86Info
.disableRandR
= FALSE
;
918 xf86Info
.randRFrom
= X_DEFAULT
;
919 if (xf86GetOptValBool(FlagOptions
, FLAG_RANDR
, &value
)) {
920 xf86Info
.disableRandR
= !value
;
921 xf86Info
.randRFrom
= X_CONFIG
;
925 xf86Info
.aiglx
= TRUE
;
926 xf86Info
.aiglxFrom
= X_DEFAULT
;
927 if (xf86GetOptValBool(FlagOptions
, FLAG_AIGLX
, &value
)) {
928 xf86Info
.aiglx
= value
;
929 xf86Info
.aiglxFrom
= X_CONFIG
;
933 xf86Info
.glxVisuals
= XF86_GlxVisualsTypical
;
934 xf86Info
.glxVisualsFrom
= X_DEFAULT
;
935 if ((s
= xf86GetOptValString(FlagOptions
, FLAG_GLX_VISUALS
))) {
936 if (!xf86NameCmp(s
, "minimal")) {
937 xf86Info
.glxVisuals
= XF86_GlxVisualsMinimal
;
939 else if (!xf86NameCmp(s
, "typical")) {
940 xf86Info
.glxVisuals
= XF86_GlxVisualsTypical
;
942 else if (!xf86NameCmp(s
, "all")) {
943 xf86Info
.glxVisuals
= XF86_GlxVisualsAll
;
946 xf86Msg(X_WARNING
, "Unknown GlxVisuals option\n");
950 if (xf86GetOptValBool(FlagOptions
, FLAG_AIGLX
, &value
)) {
951 xf86Info
.aiglx
= value
;
952 xf86Info
.aiglxFrom
= X_CONFIG
;
956 /* if we're not hotplugging, force some input devices to exist */
957 xf86Info
.forceInputDevices
= !(xf86Info
.autoAddDevices
&&
958 xf86Info
.autoEnableDevices
);
960 /* when forcing input devices, we use kbd. otherwise evdev, so use the
961 * evdev rules set. */
963 if (!xf86Info
.forceInputDevices
)
966 XkbSetRulesDflts(&set
);
968 xf86Info
.useDefaultFontPath
= TRUE
;
969 xf86Info
.useDefaultFontPathFrom
= X_DEFAULT
;
970 if (xf86GetOptValBool(FlagOptions
, FLAG_USE_DEFAULT_FONT_PATH
, &value
)) {
971 xf86Info
.useDefaultFontPath
= value
;
972 xf86Info
.useDefaultFontPathFrom
= X_CONFIG
;
975 /* Make sure that timers don't overflow CARD32's after multiplying */
976 #define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)
979 xf86GetOptValInteger(FlagOptions
, FLAG_SAVER_BLANKTIME
, &i
);
980 if ((i
>= 0) && (i
< MAX_TIME_IN_MIN
))
981 ScreenSaverTime
= defaultScreenSaverTime
= i
* MILLI_PER_MIN
;
984 ("BlankTime value %d outside legal range of 0 - %d minutes", i
,
989 xf86GetOptValInteger(FlagOptions
, FLAG_DPMS_STANDBYTIME
, &i
);
990 if ((i
>= 0) && (i
< MAX_TIME_IN_MIN
))
991 DPMSStandbyTime
= i
* MILLI_PER_MIN
;
994 ("StandbyTime value %d outside legal range of 0 - %d minutes", i
,
997 xf86GetOptValInteger(FlagOptions
, FLAG_DPMS_SUSPENDTIME
, &i
);
998 if ((i
>= 0) && (i
< MAX_TIME_IN_MIN
))
999 DPMSSuspendTime
= i
* MILLI_PER_MIN
;
1002 ("SuspendTime value %d outside legal range of 0 - %d minutes", i
,
1005 xf86GetOptValInteger(FlagOptions
, FLAG_DPMS_OFFTIME
, &i
);
1006 if ((i
>= 0) && (i
< MAX_TIME_IN_MIN
))
1007 DPMSOffTime
= i
* MILLI_PER_MIN
;
1010 ("OffTime value %d outside legal range of 0 - %d minutes", i
,
1015 xf86GetOptValInteger(FlagOptions
, FLAG_PIXMAP
, &i
);
1026 xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i
);
1029 if (xf86Pix24
!= Pix24DontCare
) {
1030 xf86Info
.pixmap24
= xf86Pix24
;
1031 xf86Info
.pix24From
= X_CMDLINE
;
1033 else if (pix24
!= Pix24DontCare
) {
1034 xf86Info
.pixmap24
= pix24
;
1035 xf86Info
.pix24From
= X_CONFIG
;
1038 xf86Info
.pixmap24
= Pix24DontCare
;
1039 xf86Info
.pix24From
= X_DEFAULT
;
1044 if (!noPanoramiXExtension
)
1046 else if (xf86GetOptValBool(FlagOptions
, FLAG_XINERAMA
, &value
)) {
1047 noPanoramiXExtension
= !value
;
1050 if (!noPanoramiXExtension
)
1051 xf86Msg(from
, "Xinerama: enabled\n");
1055 xf86Info
.dri2
= FALSE
;
1056 xf86Info
.dri2From
= X_DEFAULT
;
1057 if (xf86GetOptValBool(FlagOptions
, FLAG_DRI2
, &value
)) {
1058 xf86Info
.dri2
= value
;
1059 xf86Info
.dri2From
= X_CONFIG
;
1067 xf86DRI2Enabled(void)
1069 return xf86Info
.dri2
;
1073 * Search for the pInfo in the null-terminated list given and remove (and
1074 * free) it if present. All other devices are moved forward.
1077 freeDevice(InputInfoPtr
* list
, InputInfoPtr pInfo
)
1081 for (devs
= list
; devs
&& *devs
; devs
++) {
1082 if (*devs
== pInfo
) {
1084 for (; devs
&& *devs
; devs
++)
1092 * Append pInfo to the null-terminated list, allocating space as necessary.
1093 * pInfo is used as the last element.
1095 static InputInfoPtr
*
1096 addDevice(InputInfoPtr
* list
, InputInfoPtr pInfo
)
1101 for (devs
= list
; devs
&& *devs
; devs
++)
1104 list
= xnfrealloc(list
, (count
+ 1) * sizeof(InputInfoPtr
));
1107 list
[count
- 1] = pInfo
;
1112 * Locate the core input devices. These can be specified/located in
1113 * the following ways, in order of priority:
1115 * 1. The InputDevices named by the -pointer and -keyboard command line
1117 * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
1118 * the active ServerLayout.
1119 * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
1120 * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
1121 * driver (mouse, synaptics, evdev, vmmouse, void)
1122 * 5. Default devices with an empty (default) configuration. These defaults
1123 * will reference the 'mouse' and 'keyboard' drivers.
1127 checkCoreInputDevices(serverLayoutPtr servlayoutp
, Bool implicitLayout
)
1129 InputInfoPtr corePointer
= NULL
, coreKeyboard
= NULL
;
1130 Bool foundPointer
= FALSE
, foundKeyboard
= FALSE
;
1131 const char *pointerMsg
= NULL
, *keyboardMsg
= NULL
;
1132 InputInfoPtr
*devs
, /* iterator */
1134 InputInfoPtr Pointer
, Keyboard
;
1135 XF86ConfInputPtr confInput
;
1136 XF86ConfInputRec defPtr
, defKbd
;
1137 MessageType from
= X_DEFAULT
;
1139 const char *mousedrivers
[] = { "mouse", "synaptics", "evdev", "vmmouse",
1144 * First check if a core pointer or core keyboard have been specified
1145 * in the active ServerLayout. If more than one is specified for either,
1146 * remove the core attribute from the later ones.
1148 for (devs
= servlayoutp
->inputs
; devs
&& *devs
; devs
++) {
1150 if (indp
->options
&&
1151 xf86CheckBoolOption(indp
->options
, "CorePointer", FALSE
)) {
1156 if (indp
->options
&&
1157 xf86CheckBoolOption(indp
->options
, "CoreKeyboard", FALSE
)) {
1158 if (!coreKeyboard
) {
1159 coreKeyboard
= indp
;
1166 /* 1. Check for the -pointer command line option. */
1167 if (xf86PointerName
) {
1168 confInput
= xf86findInput(xf86PointerName
,
1169 xf86configptr
->conf_input_lst
);
1171 xf86Msg(X_ERROR
, "No InputDevice section called \"%s\"\n",
1177 * If one was already specified in the ServerLayout, it needs to be
1181 freeDevice(servlayoutp
->inputs
, corePointer
);
1184 foundPointer
= TRUE
;
1187 /* 2. ServerLayout-specified core pointer. */
1189 foundPointer
= TRUE
;
1193 /* 3. First core pointer device. */
1194 if (!foundPointer
&& (xf86Info
.forceInputDevices
|| implicitLayout
)) {
1197 for (p
= xf86configptr
->conf_input_lst
; p
; p
= p
->list
.next
) {
1198 if (p
->inp_option_lst
&&
1199 xf86CheckBoolOption(p
->inp_option_lst
, "CorePointer", FALSE
)) {
1201 foundPointer
= TRUE
;
1203 pointerMsg
= "first core pointer device";
1209 /* 4. First pointer with an allowed mouse driver. */
1210 if (!foundPointer
&& xf86Info
.forceInputDevices
) {
1211 const char **driver
= mousedrivers
;
1213 confInput
= xf86findInput(CONF_IMPLICIT_POINTER
,
1214 xf86configptr
->conf_input_lst
);
1215 while (*driver
&& !confInput
) {
1216 confInput
= xf86findInputByDriver(*driver
,
1217 xf86configptr
->conf_input_lst
);
1221 foundPointer
= TRUE
;
1223 pointerMsg
= "first mouse device";
1227 /* 5. Built-in default. */
1228 if (!foundPointer
&& xf86Info
.forceInputDevices
) {
1229 memset(&defPtr
, 0, sizeof(defPtr
));
1230 defPtr
.inp_identifier
= strdup("<default pointer>");
1231 defPtr
.inp_driver
= strdup("mouse");
1232 confInput
= &defPtr
;
1233 foundPointer
= TRUE
;
1235 pointerMsg
= "default mouse configuration";
1238 /* Add the core pointer device to the layout, and set it to Core. */
1239 if (foundPointer
&& confInput
) {
1240 Pointer
= xf86AllocateInput();
1242 foundPointer
= configInput(Pointer
, confInput
, from
);
1244 Pointer
->options
= xf86AddNewOption(Pointer
->options
,
1245 "CorePointer", "on");
1246 Pointer
->options
= xf86AddNewOption(Pointer
->options
,
1248 confInput
->inp_driver
);
1250 xf86AddNewOption(Pointer
->options
, "identifier",
1251 confInput
->inp_identifier
);
1252 servlayoutp
->inputs
= addDevice(servlayoutp
->inputs
, Pointer
);
1256 if (!foundPointer
&& xf86Info
.forceInputDevices
) {
1257 /* This shouldn't happen. */
1258 xf86Msg(X_ERROR
, "Cannot locate a core pointer device.\n");
1259 xf86DeleteInput(Pointer
, 0);
1265 /* 1. Check for the -keyboard command line option. */
1266 if (xf86KeyboardName
) {
1267 confInput
= xf86findInput(xf86KeyboardName
,
1268 xf86configptr
->conf_input_lst
);
1270 xf86Msg(X_ERROR
, "No InputDevice section called \"%s\"\n",
1276 * If one was already specified in the ServerLayout, it needs to be
1280 freeDevice(servlayoutp
->inputs
, coreKeyboard
);
1281 coreKeyboard
= NULL
;
1283 foundKeyboard
= TRUE
;
1286 /* 2. ServerLayout-specified core keyboard. */
1288 foundKeyboard
= TRUE
;
1292 /* 3. First core keyboard device. */
1293 if (!foundKeyboard
&& (xf86Info
.forceInputDevices
|| implicitLayout
)) {
1296 for (p
= xf86configptr
->conf_input_lst
; p
; p
= p
->list
.next
) {
1297 if (p
->inp_option_lst
&&
1298 xf86CheckBoolOption(p
->inp_option_lst
, "CoreKeyboard", FALSE
)) {
1300 foundKeyboard
= TRUE
;
1302 keyboardMsg
= "first core keyboard device";
1308 /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
1309 if (!foundKeyboard
&& xf86Info
.forceInputDevices
) {
1310 confInput
= xf86findInput(CONF_IMPLICIT_KEYBOARD
,
1311 xf86configptr
->conf_input_lst
);
1313 confInput
= xf86findInputByDriver("kbd",
1314 xf86configptr
->conf_input_lst
);
1317 foundKeyboard
= TRUE
;
1319 keyboardMsg
= "first keyboard device";
1323 /* 5. Built-in default. */
1324 if (!foundKeyboard
&& xf86Info
.forceInputDevices
) {
1325 memset(&defKbd
, 0, sizeof(defKbd
));
1326 defKbd
.inp_identifier
= strdup("<default keyboard>");
1327 defKbd
.inp_driver
= strdup("kbd");
1328 confInput
= &defKbd
;
1329 foundKeyboard
= TRUE
;
1330 keyboardMsg
= "default keyboard configuration";
1334 /* Add the core keyboard device to the layout, and set it to Core. */
1335 if (foundKeyboard
&& confInput
) {
1336 Keyboard
= xf86AllocateInput();
1338 foundKeyboard
= configInput(Keyboard
, confInput
, from
);
1339 if (foundKeyboard
) {
1340 Keyboard
->options
= xf86AddNewOption(Keyboard
->options
,
1341 "CoreKeyboard", "on");
1342 Keyboard
->options
= xf86AddNewOption(Keyboard
->options
,
1344 confInput
->inp_driver
);
1346 xf86AddNewOption(Keyboard
->options
, "identifier",
1347 confInput
->inp_identifier
);
1348 servlayoutp
->inputs
= addDevice(servlayoutp
->inputs
, Keyboard
);
1352 if (!foundKeyboard
&& xf86Info
.forceInputDevices
) {
1353 /* This shouldn't happen. */
1354 xf86Msg(X_ERROR
, "Cannot locate a core keyboard device.\n");
1355 xf86DeleteInput(Keyboard
, 0);
1361 xf86Msg(X_DEFAULT
, "No Layout section. Using the %s.\n",
1364 xf86Msg(X_DEFAULT
, "The core pointer device wasn't specified "
1365 "explicitly in the layout.\n"
1366 "\tUsing the %s.\n", pointerMsg
);
1371 xf86Msg(X_DEFAULT
, "No Layout section. Using the %s.\n",
1374 xf86Msg(X_DEFAULT
, "The core keyboard device wasn't specified "
1375 "explicitly in the layout.\n"
1376 "\tUsing the %s.\n", keyboardMsg
);
1379 if (!xf86Info
.forceInputDevices
&& !(foundPointer
&& foundKeyboard
)) {
1380 #if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1381 const char *config_backend
;
1383 #if defined(CONFIG_HAL)
1384 config_backend
= "HAL";
1385 #elif defined(CONFIG_UDEV)
1386 config_backend
= "udev";
1388 config_backend
= "wscons";
1390 xf86Msg(X_INFO
, "The server relies on %s to provide the list of "
1391 "input devices.\n\tIf no devices become available, "
1392 "reconfigure %s or disable AutoAddDevices.\n",
1393 config_backend
, config_backend
);
1395 xf86Msg(X_WARNING
, "Hotplugging requested but the server was "
1396 "compiled without a config backend. "
1397 "No input devices were configured, the server "
1398 "will start without any input devices.\n");
1406 LAYOUT_ISOLATEDEVICE
,
1410 static OptionInfoRec LayoutOptions
[] = {
1411 {LAYOUT_ISOLATEDEVICE
, "IsolateDevice", OPTV_STRING
,
1413 {LAYOUT_SINGLECARD
, "SingleCard", OPTV_BOOLEAN
,
1415 {-1, NULL
, OPTV_NONE
,
1420 configInputDevices(XF86ConfLayoutPtr layout
, serverLayoutPtr servlayoutp
)
1422 XF86ConfInputrefPtr irp
;
1427 * Count the number of input devices.
1429 irp
= layout
->lay_input_lst
;
1432 irp
= (XF86ConfInputrefPtr
) irp
->list
.next
;
1434 DebugF("Found %d input devices in the layout section %s\n",
1435 count
, layout
->lay_identifier
);
1436 indp
= xnfcalloc((count
+ 1), sizeof(InputInfoPtr
));
1438 irp
= layout
->lay_input_lst
;
1441 indp
[count
] = xf86AllocateInput();
1442 if (!configInput(indp
[count
], irp
->iref_inputdev
, X_CONFIG
)) {
1449 indp
[count
]->options
= xf86OptionListMerge(indp
[count
]->options
,
1450 irp
->iref_option_lst
);
1452 irp
= (XF86ConfInputrefPtr
) irp
->list
.next
;
1454 servlayoutp
->inputs
= indp
;
1460 * figure out which layout is active, which screens are used in that layout,
1461 * which drivers and monitors are used in these screens
1464 configLayout(serverLayoutPtr servlayoutp
, XF86ConfLayoutPtr conf_layout
,
1465 char *default_layout
)
1467 XF86ConfAdjacencyPtr adjp
;
1468 XF86ConfInactivePtr idp
;
1469 int saved_count
, count
= 0;
1471 XF86ConfLayoutPtr l
;
1473 screenLayoutPtr slp
;
1481 * which layout section is the active one?
1483 * If there is a -layout command line option, use that one, otherwise
1484 * pick the first one.
1487 if (xf86LayoutName
!= NULL
)
1489 else if (default_layout
) {
1490 xf86LayoutName
= default_layout
;
1493 if (xf86LayoutName
!= NULL
) {
1494 if ((l
= xf86findLayout(xf86LayoutName
, conf_layout
)) == NULL
) {
1495 xf86Msg(X_ERROR
, "No ServerLayout section called \"%s\"\n",
1501 xf86Msg(from
, "ServerLayout \"%s\"\n", conf_layout
->lay_identifier
);
1502 adjp
= conf_layout
->lay_adjacency_lst
;
1505 * we know that each screen is referenced exactly once on the left side
1506 * of a layout statement in the Layout section. So to allocate the right
1507 * size for the array we do a quick walk of the list to figure out how
1508 * many sections we have
1512 adjp
= (XF86ConfAdjacencyPtr
) adjp
->list
.next
;
1515 DebugF("Found %d screens in the layout section %s",
1516 count
, conf_layout
->lay_identifier
);
1517 if (!count
) /* alloc enough storage even if no screen is specified */
1520 slp
= xnfcalloc(1, (count
+ 1) * sizeof(screenLayoutRec
));
1521 slp
[count
].screen
= NULL
;
1523 * now that we have storage, loop over the list again and fill in our
1524 * data structure; at this point we do not fill in the adjacency
1525 * information as it is not clear if we need it at all
1527 adjp
= conf_layout
->lay_adjacency_lst
;
1530 slp
[count
].screen
= xnfcalloc(1, sizeof(confScreenRec
));
1531 if (adjp
->adj_scrnum
< 0)
1534 scrnum
= adjp
->adj_scrnum
;
1535 if (!configScreen(slp
[count
].screen
, adjp
->adj_screen
, scrnum
,
1538 free(slp
[count
].screen
);
1543 slp
[count
].x
= adjp
->adj_x
;
1544 slp
[count
].y
= adjp
->adj_y
;
1545 slp
[count
].refname
= adjp
->adj_refscreen
;
1546 switch (adjp
->adj_where
) {
1547 case CONF_ADJ_OBSOLETE
:
1548 slp
[count
].where
= PosObsolete
;
1549 slp
[count
].topname
= adjp
->adj_top_str
;
1550 slp
[count
].bottomname
= adjp
->adj_bottom_str
;
1551 slp
[count
].leftname
= adjp
->adj_left_str
;
1552 slp
[count
].rightname
= adjp
->adj_right_str
;
1554 case CONF_ADJ_ABSOLUTE
:
1555 slp
[count
].where
= PosAbsolute
;
1557 case CONF_ADJ_RIGHTOF
:
1558 slp
[count
].where
= PosRightOf
;
1560 case CONF_ADJ_LEFTOF
:
1561 slp
[count
].where
= PosLeftOf
;
1563 case CONF_ADJ_ABOVE
:
1564 slp
[count
].where
= PosAbove
;
1566 case CONF_ADJ_BELOW
:
1567 slp
[count
].where
= PosBelow
;
1569 case CONF_ADJ_RELATIVE
:
1570 slp
[count
].where
= PosRelative
;
1574 adjp
= (XF86ConfAdjacencyPtr
) adjp
->list
.next
;
1577 /* No screen was specified in the layout. take the first one from the
1578 * config file, or - if it is NULL - configScreen autogenerates one for
1581 slp
[0].screen
= xnfcalloc(1, sizeof(confScreenRec
));
1582 if (!configScreen(slp
[0].screen
, xf86configptr
->conf_screen_lst
,
1584 free(slp
[0].screen
);
1590 /* XXX Need to tie down the upper left screen. */
1592 /* Fill in the refscreen and top/bottom/left/right values */
1593 for (i
= 0; i
< count
; i
++) {
1594 for (j
= 0; j
< count
; j
++) {
1595 if (slp
[i
].refname
&&
1596 strcmp(slp
[i
].refname
, slp
[j
].screen
->id
) == 0) {
1597 slp
[i
].refscreen
= slp
[j
].screen
;
1599 if (slp
[i
].topname
&&
1600 strcmp(slp
[i
].topname
, slp
[j
].screen
->id
) == 0) {
1601 slp
[i
].top
= slp
[j
].screen
;
1603 if (slp
[i
].bottomname
&&
1604 strcmp(slp
[i
].bottomname
, slp
[j
].screen
->id
) == 0) {
1605 slp
[i
].bottom
= slp
[j
].screen
;
1607 if (slp
[i
].leftname
&&
1608 strcmp(slp
[i
].leftname
, slp
[j
].screen
->id
) == 0) {
1609 slp
[i
].left
= slp
[j
].screen
;
1611 if (slp
[i
].rightname
&&
1612 strcmp(slp
[i
].rightname
, slp
[j
].screen
->id
) == 0) {
1613 slp
[i
].right
= slp
[j
].screen
;
1616 if (slp
[i
].where
!= PosObsolete
1617 && slp
[i
].where
!= PosAbsolute
&& !slp
[i
].refscreen
) {
1618 xf86Msg(X_ERROR
, "Screen %s doesn't exist: deleting placement\n",
1620 slp
[i
].where
= PosAbsolute
;
1629 saved_count
= count
;
1631 * Count the number of inactive devices.
1634 idp
= conf_layout
->lay_inactive_lst
;
1637 idp
= (XF86ConfInactivePtr
) idp
->list
.next
;
1639 DebugF("Found %d inactive devices in the layout section %s\n",
1640 count
, conf_layout
->lay_identifier
);
1641 gdp
= xnfalloc((count
+ 1) * sizeof(GDevRec
));
1642 gdp
[count
].identifier
= NULL
;
1643 idp
= conf_layout
->lay_inactive_lst
;
1646 if (!configDevice(&gdp
[count
], idp
->inactive_device
, FALSE
))
1649 idp
= (XF86ConfInactivePtr
) idp
->list
.next
;
1652 if (!configInputDevices(conf_layout
, servlayoutp
))
1655 servlayoutp
->id
= conf_layout
->lay_identifier
;
1656 servlayoutp
->screens
= slp
;
1657 servlayoutp
->inactives
= gdp
;
1658 servlayoutp
->options
= conf_layout
->lay_option_lst
;
1665 free(slp
[saved_count
].screen
);
1666 } while (saved_count
--);
1673 * No layout section, so find the first Screen section and set that up as
1674 * the only active screen.
1677 configImpliedLayout(serverLayoutPtr servlayoutp
, XF86ConfScreenPtr conf_screen
,
1678 XF86ConfigPtr xf86configptr
)
1681 XF86ConfScreenPtr s
;
1682 screenLayoutPtr slp
;
1684 XF86ConfLayoutRec layout
;
1690 * which screen section is the active one?
1692 * If there is a -screen option, use that one, otherwise use the first
1697 if (xf86ScreenName
!= NULL
) {
1698 if ((s
= xf86findScreen(xf86ScreenName
, conf_screen
)) == NULL
) {
1699 xf86Msg(X_ERROR
, "No Screen section called \"%s\"\n",
1707 /* We have exactly one screen */
1709 slp
= xnfcalloc(1, 2 * sizeof(screenLayoutRec
));
1710 slp
[0].screen
= xnfcalloc(1, sizeof(confScreenRec
));
1711 slp
[1].screen
= NULL
;
1712 if (!configScreen(slp
[0].screen
, conf_screen
, 0, from
)) {
1716 servlayoutp
->id
= "(implicit)";
1717 servlayoutp
->screens
= slp
;
1718 servlayoutp
->inactives
= xnfcalloc(1, sizeof(GDevRec
));
1719 servlayoutp
->options
= NULL
;
1721 memset(&layout
, 0, sizeof(layout
));
1722 layout
.lay_identifier
= servlayoutp
->id
;
1723 if (xf86layoutAddInputDevices(xf86configptr
, &layout
) > 0) {
1724 if (!configInputDevices(&layout
, servlayoutp
))
1729 /* Set up an empty input device list, then look for some core devices. */
1730 indp
= xnfalloc(sizeof(InputInfoPtr
));
1732 servlayoutp
->inputs
= indp
;
1739 configXvAdaptor(confXvAdaptorPtr adaptor
, XF86ConfVideoAdaptorPtr conf_adaptor
)
1742 XF86ConfVideoPortPtr conf_port
;
1744 xf86Msg(X_CONFIG
, "| |-->VideoAdaptor \"%s\"\n",
1745 conf_adaptor
->va_identifier
);
1746 adaptor
->identifier
= conf_adaptor
->va_identifier
;
1747 adaptor
->options
= conf_adaptor
->va_option_lst
;
1748 if (conf_adaptor
->va_busid
|| conf_adaptor
->va_driver
) {
1749 xf86Msg(X_CONFIG
, "| | Unsupported device type, skipping entry\n");
1754 * figure out how many videoport subsections there are and fill them in
1756 conf_port
= conf_adaptor
->va_port_lst
;
1759 conf_port
= (XF86ConfVideoPortPtr
) conf_port
->list
.next
;
1761 adaptor
->ports
= xnfalloc((count
) * sizeof(confXvPortRec
));
1762 adaptor
->numports
= count
;
1764 conf_port
= conf_adaptor
->va_port_lst
;
1766 adaptor
->ports
[count
].identifier
= conf_port
->vp_identifier
;
1767 adaptor
->ports
[count
].options
= conf_port
->vp_option_lst
;
1769 conf_port
= (XF86ConfVideoPortPtr
) conf_port
->list
.next
;
1776 configScreen(confScreenPtr screenp
, XF86ConfScreenPtr conf_screen
, int scrnum
,
1780 XF86ConfDisplayPtr dispptr
;
1781 XF86ConfAdaptorLinkPtr conf_adaptor
;
1782 Bool defaultMonitor
= FALSE
;
1783 XF86ConfScreenRec local_conf_screen
;
1786 memset(&local_conf_screen
, 0, sizeof(local_conf_screen
));
1787 conf_screen
= &local_conf_screen
;
1788 conf_screen
->scrn_identifier
= "Default Screen Section";
1789 xf86Msg(X_DEFAULT
, "No screen section available. Using defaults.\n");
1792 xf86Msg(from
, "|-->Screen \"%s\" (%d)\n", conf_screen
->scrn_identifier
,
1795 * now we fill in the elements of the screen
1797 screenp
->id
= conf_screen
->scrn_identifier
;
1798 screenp
->screennum
= scrnum
;
1799 screenp
->defaultdepth
= conf_screen
->scrn_defaultdepth
;
1800 screenp
->defaultbpp
= conf_screen
->scrn_defaultbpp
;
1801 screenp
->defaultfbbpp
= conf_screen
->scrn_defaultfbbpp
;
1802 screenp
->monitor
= xnfcalloc(1, sizeof(MonRec
));
1803 /* If no monitor is specified, create a default one. */
1804 if (!conf_screen
->scrn_monitor
) {
1805 XF86ConfMonitorRec defMon
;
1807 memset(&defMon
, 0, sizeof(defMon
));
1808 defMon
.mon_identifier
= "<default monitor>";
1809 if (!configMonitor(screenp
->monitor
, &defMon
))
1811 defaultMonitor
= TRUE
;
1814 if (!configMonitor(screenp
->monitor
, conf_screen
->scrn_monitor
))
1817 /* Configure the device. If there isn't one configured, attach to the
1818 * first inactive one that we can configure. If there's none that work,
1819 * set it to NULL so that the section can be autoconfigured later */
1820 screenp
->device
= xnfcalloc(1, sizeof(GDevRec
));
1821 if ((!conf_screen
->scrn_device
) && (xf86configptr
->conf_device_lst
)) {
1822 conf_screen
->scrn_device
= xf86configptr
->conf_device_lst
;
1823 xf86Msg(X_DEFAULT
, "No device specified for screen \"%s\".\n"
1824 "\tUsing the first device section listed.\n", screenp
->id
);
1826 if (configDevice(screenp
->device
, conf_screen
->scrn_device
, TRUE
)) {
1827 screenp
->device
->myScreenSection
= screenp
;
1830 screenp
->device
= NULL
;
1832 screenp
->options
= conf_screen
->scrn_option_lst
;
1835 * figure out how many display subsections there are and fill them in
1837 dispptr
= conf_screen
->scrn_display_lst
;
1840 dispptr
= (XF86ConfDisplayPtr
) dispptr
->list
.next
;
1842 screenp
->displays
= xnfalloc((count
) * sizeof(DispRec
));
1843 screenp
->numdisplays
= count
;
1845 /* Fill in the default Virtual size, if any */
1846 if (conf_screen
->scrn_virtualX
&& conf_screen
->scrn_virtualY
) {
1847 for (count
= 0, dispptr
= conf_screen
->scrn_display_lst
;
1849 dispptr
= (XF86ConfDisplayPtr
) dispptr
->list
.next
, count
++) {
1850 screenp
->displays
[count
].virtualX
= conf_screen
->scrn_virtualX
;
1851 screenp
->displays
[count
].virtualY
= conf_screen
->scrn_virtualY
;
1855 /* Now do the per-Display Virtual sizes */
1857 dispptr
= conf_screen
->scrn_display_lst
;
1859 configDisplay(&(screenp
->displays
[count
]), dispptr
);
1861 dispptr
= (XF86ConfDisplayPtr
) dispptr
->list
.next
;
1865 * figure out how many videoadaptor references there are and fill them in
1867 conf_adaptor
= conf_screen
->scrn_adaptor_lst
;
1868 while (conf_adaptor
) {
1870 conf_adaptor
= (XF86ConfAdaptorLinkPtr
) conf_adaptor
->list
.next
;
1872 screenp
->xvadaptors
= xnfalloc((count
) * sizeof(confXvAdaptorRec
));
1873 screenp
->numxvadaptors
= 0;
1874 conf_adaptor
= conf_screen
->scrn_adaptor_lst
;
1875 while (conf_adaptor
) {
1876 if (configXvAdaptor(&(screenp
->xvadaptors
[screenp
->numxvadaptors
]),
1877 conf_adaptor
->al_adaptor
))
1878 screenp
->numxvadaptors
++;
1879 conf_adaptor
= (XF86ConfAdaptorLinkPtr
) conf_adaptor
->list
.next
;
1882 if (defaultMonitor
) {
1883 xf86Msg(X_DEFAULT
, "No monitor specified for screen \"%s\".\n"
1884 "\tUsing a default monitor configuration.\n", screenp
->id
);
1890 MON_REDUCEDBLANKING
,
1894 static OptionInfoRec MonitorOptions
[] = {
1895 {MON_REDUCEDBLANKING
, "ReducedBlanking", OPTV_BOOLEAN
,
1897 {MON_MAX_PIX_CLOCK
, "MaxPixClock", OPTV_FREQ
,
1899 {-1, NULL
, OPTV_NONE
,
1904 configMonitor(MonPtr monitorp
, XF86ConfMonitorPtr conf_monitor
)
1907 DisplayModePtr mode
, last
= NULL
;
1908 XF86ConfModeLinePtr cmodep
;
1909 XF86ConfModesPtr modes
;
1910 XF86ConfModesLinkPtr modeslnk
= conf_monitor
->mon_modes_sect_lst
;
1911 Gamma zeros
= { 0.0, 0.0, 0.0 };
1912 float badgamma
= 0.0;
1915 xf86Msg(X_CONFIG
, "| |-->Monitor \"%s\"\n", conf_monitor
->mon_identifier
);
1916 monitorp
->id
= conf_monitor
->mon_identifier
;
1917 monitorp
->vendor
= conf_monitor
->mon_vendor
;
1918 monitorp
->model
= conf_monitor
->mon_modelname
;
1919 monitorp
->Modes
= NULL
;
1920 monitorp
->Last
= NULL
;
1921 monitorp
->gamma
= zeros
;
1922 monitorp
->widthmm
= conf_monitor
->mon_width
;
1923 monitorp
->heightmm
= conf_monitor
->mon_height
;
1924 monitorp
->reducedblanking
= FALSE
;
1925 monitorp
->maxPixClock
= 0;
1926 monitorp
->options
= conf_monitor
->mon_option_lst
;
1929 * fill in the monitor structure
1932 count
< conf_monitor
->mon_n_hsync
&& count
< MAX_HSYNC
; count
++) {
1933 monitorp
->hsync
[count
].hi
= conf_monitor
->mon_hsync
[count
].hi
;
1934 monitorp
->hsync
[count
].lo
= conf_monitor
->mon_hsync
[count
].lo
;
1936 monitorp
->nHsync
= count
;
1938 count
< conf_monitor
->mon_n_vrefresh
&& count
< MAX_VREFRESH
;
1940 monitorp
->vrefresh
[count
].hi
= conf_monitor
->mon_vrefresh
[count
].hi
;
1941 monitorp
->vrefresh
[count
].lo
= conf_monitor
->mon_vrefresh
[count
].lo
;
1943 monitorp
->nVrefresh
= count
;
1946 * first we collect the mode lines from the UseModes directive
1949 modes
= xf86findModes(modeslnk
->ml_modes_str
,
1950 xf86configptr
->conf_modes_lst
);
1951 modeslnk
->ml_modes
= modes
;
1953 /* now add the modes found in the modes
1954 section to the list of modes for this
1955 monitor unless it has been added before
1956 because we are reusing the same section
1957 for another screen */
1958 if (xf86itemNotSublist((GenericListPtr
) conf_monitor
->mon_modeline_lst
,
1959 (GenericListPtr
) modes
->mon_modeline_lst
)) {
1960 conf_monitor
->mon_modeline_lst
= (XF86ConfModeLinePtr
)
1961 xf86addListItem((GenericListPtr
) conf_monitor
->mon_modeline_lst
,
1962 (GenericListPtr
) modes
->mon_modeline_lst
);
1964 modeslnk
= modeslnk
->list
.next
;
1968 * we need to hook in the mode lines now
1969 * here both data structures use lists, only our internal one
1972 cmodep
= conf_monitor
->mon_modeline_lst
;
1974 mode
= xnfcalloc(1, sizeof(DisplayModeRec
));
1976 mode
->Clock
= cmodep
->ml_clock
;
1977 mode
->HDisplay
= cmodep
->ml_hdisplay
;
1978 mode
->HSyncStart
= cmodep
->ml_hsyncstart
;
1979 mode
->HSyncEnd
= cmodep
->ml_hsyncend
;
1980 mode
->HTotal
= cmodep
->ml_htotal
;
1981 mode
->VDisplay
= cmodep
->ml_vdisplay
;
1982 mode
->VSyncStart
= cmodep
->ml_vsyncstart
;
1983 mode
->VSyncEnd
= cmodep
->ml_vsyncend
;
1984 mode
->VTotal
= cmodep
->ml_vtotal
;
1985 mode
->Flags
= cmodep
->ml_flags
;
1986 mode
->HSkew
= cmodep
->ml_hskew
;
1987 mode
->VScan
= cmodep
->ml_vscan
;
1988 mode
->name
= xnfstrdup(cmodep
->ml_identifier
);
1995 * this is the first mode
1997 monitorp
->Modes
= mode
;
2001 cmodep
= (XF86ConfModeLinePtr
) cmodep
->list
.next
;
2006 monitorp
->Last
= last
;
2008 /* add the (VESA) default modes */
2009 if (!addDefaultModes(monitorp
))
2012 if (conf_monitor
->mon_gamma_red
> GAMMA_ZERO
)
2013 monitorp
->gamma
.red
= conf_monitor
->mon_gamma_red
;
2014 if (conf_monitor
->mon_gamma_green
> GAMMA_ZERO
)
2015 monitorp
->gamma
.green
= conf_monitor
->mon_gamma_green
;
2016 if (conf_monitor
->mon_gamma_blue
> GAMMA_ZERO
)
2017 monitorp
->gamma
.blue
= conf_monitor
->mon_gamma_blue
;
2019 /* Check that the gamma values are within range */
2020 if (monitorp
->gamma
.red
> GAMMA_ZERO
&&
2021 (monitorp
->gamma
.red
< GAMMA_MIN
|| monitorp
->gamma
.red
> GAMMA_MAX
)) {
2022 badgamma
= monitorp
->gamma
.red
;
2024 else if (monitorp
->gamma
.green
> GAMMA_ZERO
&&
2025 (monitorp
->gamma
.green
< GAMMA_MIN
||
2026 monitorp
->gamma
.green
> GAMMA_MAX
)) {
2027 badgamma
= monitorp
->gamma
.green
;
2029 else if (monitorp
->gamma
.blue
> GAMMA_ZERO
&&
2030 (monitorp
->gamma
.blue
< GAMMA_MIN
||
2031 monitorp
->gamma
.blue
> GAMMA_MAX
)) {
2032 badgamma
= monitorp
->gamma
.blue
;
2034 if (badgamma
> GAMMA_ZERO
) {
2035 xf86ConfigError("Gamma value %.f is out of range (%.2f - %.1f)\n",
2036 badgamma
, GAMMA_MIN
, GAMMA_MAX
);
2040 xf86ProcessOptions(-1, monitorp
->options
, MonitorOptions
);
2041 xf86GetOptValBool(MonitorOptions
, MON_REDUCEDBLANKING
,
2042 &monitorp
->reducedblanking
);
2043 if (xf86GetOptValFreq(MonitorOptions
, MON_MAX_PIX_CLOCK
, OPTUNITS_KHZ
,
2044 &maxPixClock
) == TRUE
) {
2045 monitorp
->maxPixClock
= (int) maxPixClock
;
2052 lookupVisual(const char *visname
)
2056 if (!visname
|| !*visname
)
2059 for (i
= 0; i
<= DirectColor
; i
++) {
2060 if (!xf86nameCompare(visname
, xf86VisualNames
[i
]))
2064 if (i
<= DirectColor
)
2071 configDisplay(DispPtr displayp
, XF86ConfDisplayPtr conf_display
)
2076 displayp
->frameX0
= conf_display
->disp_frameX0
;
2077 displayp
->frameY0
= conf_display
->disp_frameY0
;
2078 displayp
->virtualX
= conf_display
->disp_virtualX
;
2079 displayp
->virtualY
= conf_display
->disp_virtualY
;
2080 displayp
->depth
= conf_display
->disp_depth
;
2081 displayp
->fbbpp
= conf_display
->disp_bpp
;
2082 displayp
->weight
.red
= conf_display
->disp_weight
.red
;
2083 displayp
->weight
.green
= conf_display
->disp_weight
.green
;
2084 displayp
->weight
.blue
= conf_display
->disp_weight
.blue
;
2085 displayp
->blackColour
.red
= conf_display
->disp_black
.red
;
2086 displayp
->blackColour
.green
= conf_display
->disp_black
.green
;
2087 displayp
->blackColour
.blue
= conf_display
->disp_black
.blue
;
2088 displayp
->whiteColour
.red
= conf_display
->disp_white
.red
;
2089 displayp
->whiteColour
.green
= conf_display
->disp_white
.green
;
2090 displayp
->whiteColour
.blue
= conf_display
->disp_white
.blue
;
2091 displayp
->options
= conf_display
->disp_option_lst
;
2092 if (conf_display
->disp_visual
) {
2093 displayp
->defaultVisual
= lookupVisual(conf_display
->disp_visual
);
2094 if (displayp
->defaultVisual
== -1) {
2095 xf86ConfigError("Invalid visual name: \"%s\"",
2096 conf_display
->disp_visual
);
2101 displayp
->defaultVisual
= -1;
2105 * now hook in the modes
2107 modep
= conf_display
->disp_mode_lst
;
2110 modep
= (XF86ModePtr
) modep
->list
.next
;
2112 displayp
->modes
= xnfalloc((count
+ 1) * sizeof(char *));
2113 modep
= conf_display
->disp_mode_lst
;
2116 displayp
->modes
[count
] = modep
->mode_name
;
2118 modep
= (XF86ModePtr
) modep
->list
.next
;
2120 displayp
->modes
[count
] = NULL
;
2126 configDevice(GDevPtr devicep
, XF86ConfDevicePtr conf_device
, Bool active
)
2135 xf86Msg(X_CONFIG
, "| |-->Device \"%s\"\n",
2136 conf_device
->dev_identifier
);
2138 xf86Msg(X_CONFIG
, "|-->Inactive Device \"%s\"\n",
2139 conf_device
->dev_identifier
);
2141 devicep
->identifier
= conf_device
->dev_identifier
;
2142 devicep
->vendor
= conf_device
->dev_vendor
;
2143 devicep
->board
= conf_device
->dev_board
;
2144 devicep
->chipset
= conf_device
->dev_chipset
;
2145 devicep
->ramdac
= conf_device
->dev_ramdac
;
2146 devicep
->driver
= conf_device
->dev_driver
;
2147 devicep
->active
= active
;
2148 devicep
->videoRam
= conf_device
->dev_videoram
;
2149 devicep
->BiosBase
= conf_device
->dev_bios_base
;
2150 devicep
->MemBase
= conf_device
->dev_mem_base
;
2151 devicep
->IOBase
= conf_device
->dev_io_base
;
2152 devicep
->clockchip
= conf_device
->dev_clockchip
;
2153 devicep
->busID
= conf_device
->dev_busid
;
2154 devicep
->textClockFreq
= conf_device
->dev_textclockfreq
;
2155 devicep
->chipID
= conf_device
->dev_chipid
;
2156 devicep
->chipRev
= conf_device
->dev_chiprev
;
2157 devicep
->options
= conf_device
->dev_option_lst
;
2158 devicep
->irq
= conf_device
->dev_irq
;
2159 devicep
->screen
= conf_device
->dev_screen
;
2161 for (i
= 0; i
< MAXDACSPEEDS
; i
++) {
2162 if (i
< CONF_MAXDACSPEEDS
)
2163 devicep
->dacSpeeds
[i
] = conf_device
->dev_dacSpeeds
[i
];
2165 devicep
->dacSpeeds
[i
] = 0;
2167 devicep
->numclocks
= conf_device
->dev_clocks
;
2168 if (devicep
->numclocks
> MAXCLOCKS
)
2169 devicep
->numclocks
= MAXCLOCKS
;
2170 for (i
= 0; i
< devicep
->numclocks
; i
++) {
2171 devicep
->clock
[i
] = conf_device
->dev_clock
[i
];
2173 devicep
->claimed
= FALSE
;
2180 configDRI(XF86ConfDRIPtr drip
)
2184 xf86ConfigDRI
.group
= -1;
2185 xf86ConfigDRI
.mode
= 0;
2188 if (drip
->dri_group_name
) {
2189 if ((grp
= getgrnam(drip
->dri_group_name
)))
2190 xf86ConfigDRI
.group
= grp
->gr_gid
;
2193 if (drip
->dri_group
>= 0)
2194 xf86ConfigDRI
.group
= drip
->dri_group
;
2196 xf86ConfigDRI
.mode
= drip
->dri_mode
;
2202 configExtensions(XF86ConfExtensionsPtr conf_ext
)
2206 if (conf_ext
&& conf_ext
->ext_option_lst
) {
2207 for (o
= conf_ext
->ext_option_lst
; o
; o
= xf86NextOption(o
)) {
2208 char *name
= xf86OptionName(o
);
2209 char *val
= xf86OptionValue(o
);
2213 /* Handle "No<ExtensionName>" */
2214 n
= xf86NormalizeName(name
);
2215 if (strncmp(n
, "no", 2) == 0) {
2221 xf86NameCmp(val
, "enable") == 0 ||
2222 xf86NameCmp(val
, "enabled") == 0 ||
2223 xf86NameCmp(val
, "on") == 0 ||
2224 xf86NameCmp(val
, "1") == 0 ||
2225 xf86NameCmp(val
, "yes") == 0 || xf86NameCmp(val
, "true") == 0) {
2226 /* NOTHING NEEDED -- enabling is handled below */
2228 else if (xf86NameCmp(val
, "disable") == 0 ||
2229 xf86NameCmp(val
, "disabled") == 0 ||
2230 xf86NameCmp(val
, "off") == 0 ||
2231 xf86NameCmp(val
, "0") == 0 ||
2232 xf86NameCmp(val
, "no") == 0 ||
2233 xf86NameCmp(val
, "false") == 0) {
2237 xf86Msg(X_WARNING
, "Ignoring unrecognized value \"%s\"\n", val
);
2242 if (EnableDisableExtension(name
, enable
)) {
2243 xf86Msg(X_CONFIG
, "Extension \"%s\" is %s\n",
2244 name
, enable
? "enabled" : "disabled");
2247 xf86Msg(X_WARNING
, "Ignoring unrecognized extension \"%s\"\n",
2256 configInput(InputInfoPtr inputp
, XF86ConfInputPtr conf_input
, MessageType from
)
2258 xf86Msg(from
, "|-->Input Device \"%s\"\n", conf_input
->inp_identifier
);
2259 inputp
->name
= conf_input
->inp_identifier
;
2260 inputp
->driver
= conf_input
->inp_driver
;
2261 inputp
->options
= conf_input
->inp_option_lst
;
2262 inputp
->attrs
= NULL
;
2268 modeIsPresent(DisplayModePtr mode
, MonPtr monitorp
)
2270 DisplayModePtr knownmodes
= monitorp
->Modes
;
2272 /* all I can think of is a linear search... */
2273 while (knownmodes
!= NULL
) {
2274 if (!strcmp(mode
->name
, knownmodes
->name
) &&
2275 !(knownmodes
->type
& M_T_DEFAULT
))
2277 knownmodes
= knownmodes
->next
;
2283 addDefaultModes(MonPtr monitorp
)
2285 DisplayModePtr mode
;
2286 DisplayModePtr last
= monitorp
->Last
;
2289 for (i
= 0; i
< xf86NumDefaultModes
; i
++) {
2290 mode
= xf86DuplicateMode(&xf86DefaultModes
[i
]);
2291 if (!modeIsPresent(mode
, monitorp
)) {
2292 monitorp
->Modes
= xf86ModesAdd(monitorp
->Modes
, mode
);
2299 monitorp
->Last
= last
;
2305 checkInput(serverLayoutPtr layout
, Bool implicit_layout
)
2307 checkCoreInputDevices(layout
, implicit_layout
);
2309 /* Unless we're forcing input devices, disable mouse/kbd devices in the
2310 * config. Otherwise the same physical device is added multiple times,
2311 * leading to duplicate events.
2313 if (!xf86Info
.forceInputDevices
&& layout
->inputs
) {
2314 InputInfoPtr
*dev
= layout
->inputs
;
2315 BOOL warned
= FALSE
;
2318 if (strcmp((*dev
)->driver
, "kbd") == 0 ||
2319 strcmp((*dev
)->driver
, "mouse") == 0 ||
2320 strcmp((*dev
)->driver
, "vmmouse") == 0) {
2321 InputInfoPtr
*current
;
2324 xf86Msg(X_WARNING
, "Hotplugging is on, devices using "
2325 "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
2329 xf86Msg(X_WARNING
, "Disabling %s\n", (*dev
)->name
);
2336 *current
= *(current
+ 1);
2347 * load the config file and fill the global data structure
2350 xf86HandleConfigFile(Bool autoconfig
)
2353 Bool singlecard
= 0;
2354 Bool implicit_layout
= FALSE
;
2357 char *filename
, *dirname
, *sysdirname
;
2358 const char *filesearch
, *dirsearch
;
2359 MessageType filefrom
= X_DEFAULT
;
2360 MessageType dirfrom
= X_DEFAULT
;
2362 if (!xf86PrivsElevated()) {
2363 filesearch
= ALL_CONFIGPATH
;
2364 dirsearch
= ALL_CONFIGDIRPATH
;
2367 filesearch
= RESTRICTED_CONFIGPATH
;
2368 dirsearch
= RESTRICTED_CONFIGDIRPATH
;
2372 filefrom
= X_CMDLINE
;
2374 dirfrom
= X_CMDLINE
;
2376 xf86initConfigFiles();
2377 sysdirname
= xf86openConfigDirFiles(SYS_CONFIGDIRPATH
, NULL
,
2379 dirname
= xf86openConfigDirFiles(dirsearch
, xf86ConfigDir
, PROJECTROOT
);
2380 filename
= xf86openConfigFile(filesearch
, xf86ConfigFile
, PROJECTROOT
);
2382 xf86MsgVerb(filefrom
, 0, "Using config file: \"%s\"\n", filename
);
2383 xf86ConfigFile
= xnfstrdup(filename
);
2387 xf86Msg(X_ERROR
, "Unable to locate/open config file: \"%s\"\n",
2391 xf86MsgVerb(dirfrom
, 0, "Using config directory: \"%s\"\n",
2393 xf86ConfigDir
= xnfstrdup(dirname
);
2398 "Unable to locate/open config directory: \"%s\"\n",
2402 xf86MsgVerb(X_DEFAULT
, 0, "Using system config directory \"%s\"\n",
2404 if (!filename
&& !dirname
&& !sysdirname
)
2405 return CONFIG_NOFILE
;
2412 if ((xf86configptr
= xf86readConfigFile()) == NULL
) {
2413 xf86Msg(X_ERROR
, "Problem parsing the config file\n");
2414 return CONFIG_PARSE_ERROR
;
2416 xf86closeConfigFile();
2418 /* Initialise a few things. */
2421 * now we convert part of the information contained in the parser
2422 * structures into our own structures.
2423 * The important part here is to figure out which Screen Sections
2424 * in the XF86Config file are active so that we can piece together
2425 * the modes that we need later down the road.
2426 * And while we are at it, we'll decode the rest of the stuff as well
2429 /* First check if a layout section is present, and if it is valid. */
2431 if (xf86configptr
->conf_layout_lst
== NULL
|| xf86ScreenName
!= NULL
) {
2432 if (xf86ScreenName
== NULL
) {
2434 "No Layout section. Using the first Screen section.\n");
2436 if (!configImpliedLayout(&xf86ConfigLayout
,
2437 xf86configptr
->conf_screen_lst
,
2439 xf86Msg(X_ERROR
, "Unable to determine the screen layout\n");
2440 return CONFIG_PARSE_ERROR
;
2442 implicit_layout
= TRUE
;
2445 if (xf86configptr
->conf_flags
!= NULL
) {
2446 char *dfltlayout
= NULL
;
2447 pointer optlist
= xf86configptr
->conf_flags
->flg_option_lst
;
2449 if (optlist
&& xf86FindOption(optlist
, "defaultserverlayout"))
2451 xf86SetStrOption(optlist
, "defaultserverlayout", NULL
);
2453 (&xf86ConfigLayout
, xf86configptr
->conf_layout_lst
,
2455 xf86Msg(X_ERROR
, "Unable to determine the screen layout\n");
2456 return CONFIG_PARSE_ERROR
;
2460 if (!configLayout(&xf86ConfigLayout
, xf86configptr
->conf_layout_lst
,
2462 xf86Msg(X_ERROR
, "Unable to determine the screen layout\n");
2463 return CONFIG_PARSE_ERROR
;
2468 xf86ProcessOptions(-1, xf86ConfigLayout
.options
, LayoutOptions
);
2469 #ifdef XSERVER_LIBPCIACCESS
2470 if ((scanptr
= xf86GetOptValString(LayoutOptions
, LAYOUT_ISOLATEDEVICE
))) {
2471 ; /* IsolateDevice specified; overrides SingleCard */
2474 xf86GetOptValBool(LayoutOptions
, LAYOUT_SINGLECARD
, &singlecard
);
2476 scanptr
= xf86ConfigLayout
.screens
->screen
->device
->busID
;
2479 if (strncmp(scanptr
, "PCI:", 4) != 0) {
2480 xf86Msg(X_WARNING
, "Bus types other than PCI not yet isolable.\n"
2481 "\tIgnoring IsolateDevice option.\n");
2484 xf86PciIsolateDevice(scanptr
);
2487 /* Now process everything else */
2488 if (!configServerFlags(xf86configptr
->conf_flags
, xf86ConfigLayout
.options
)) {
2489 ErrorF("Problem when converting the config data structures\n");
2490 return CONFIG_PARSE_ERROR
;
2493 configFiles(xf86configptr
->conf_files
);
2494 configExtensions(xf86configptr
->conf_extensions
);
2496 configDRI(xf86configptr
->conf_dri
);
2499 checkInput(&xf86ConfigLayout
, implicit_layout
);
2502 * Handle some command line options that can override some of the
2503 * ServerFlags settings.
2506 if (xf86VidModeDisabled
)
2507 xf86Info
.vidModeEnabled
= FALSE
;
2508 if (xf86VidModeAllowNonLocal
)
2509 xf86Info
.vidModeAllowNonLocal
= TRUE
;
2512 if (xf86AllowMouseOpenFail
)
2513 xf86Info
.allowMouseOpenFail
= TRUE
;
2519 xf86PathIsSafe(const char *path
)
2521 return (xf86pathIsSafe(path
) != 0);