xf86Config.c 75.6 KB
Newer Older
1
/*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
2
 * Loosely based on code bearing the following copyright:
3
 *
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
4
 *   Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
5 6 7 8 9 10 11 12 13 14 15 16
 */

/*
 * Copyright 1992-2003 by The XFree86 Project, Inc.
 * Copyright 1997 by Metro Link, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
17
 *
18 19
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
20
 *
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 * Except as contained in this notice, the name of the copyright holder(s)
 * and author(s) shall not be used in advertising or otherwise to promote
 * the sale, use or other dealings in this Software without prior written
 * authorization from the copyright holder(s) and author(s).
 */

/*
 *
 * Authors:
 *	Dirk Hohndel <hohndel@XFree86.Org>
 *	David Dawes <dawes@XFree86.Org>
 *      Marc La France <tsi@XFree86.Org>
 *      Egbert Eich <eich@XFree86.Org>
 *      ... and others
43 44
 */

45 46 47 48
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
49 50 51
#ifdef XF86DRI
#include <sys/types.h>
#include <grp.h>
52 53
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
54 55 56 57 58
#include "xf86.h"
#include "xf86Parser.h"
#include "xf86tokens.h"
#include "xf86Config.h"
#include "xf86Priv.h"
59
#include "xf86_OSlib.h"
60
#include "configProcs.h"
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
61
#include "globals.h"
62
#include "extension.h"
63
#include "Pci.h"
64 65 66

#ifdef XINPUT
#include "xf86Xinput.h"
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
67
extern DeviceAssocRec mouse_assoc;
68 69
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
70
#ifdef XKB
71
#undef XKB_IN_SERVER
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
72
#define XKB_IN_SERVER
73
#include <xkbsrv.h>
74 75
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
76 77
#ifdef RENDER
#include "picture.h"
78 79
#endif

80
#if (defined(__i386__)) && \
81 82
    (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
     defined(__NetBSD__) || defined(linux) || \
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
83 84
     (defined(SVR4) && !defined(sun)) || defined(__GNU__))
#define SUPPORT_PC98
85 86
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
/*
 * These paths define the way the config file search is done.  The escape
 * sequences are documented in parser/scan.c.
 */
#ifndef ROOT_CONFIGPATH
#define ROOT_CONFIGPATH	"%A," "%R," \
			"/etc/X11/%R," "%P/etc/X11/%R," \
			"%E," "%F," \
			"/etc/X11/%F," "%P/etc/X11/%F," \
			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#endif
#ifndef USER_CONFIGPATH
#define USER_CONFIGPATH	"/etc/X11/%S," "%P/etc/X11/%S," \
			"/etc/X11/%G," "%P/etc/X11/%G," \
			"/etc/X11/%X-%M," "/etc/X11/%X," "/etc/%X," \
			"%P/etc/X11/%X.%H," "%P/etc/X11/%X-%M," \
			"%P/etc/X11/%X," \
			"%P/lib/X11/%X.%H," "%P/lib/X11/%X-%M," \
			"%P/lib/X11/%X"
#endif
#ifndef PROJECTROOT
#define PROJECTROOT	"/usr/X11R6"
#endif

static char *fontPath = NULL;

117 118 119 120 121 122 123 124 125 126 127
static ModuleDefault ModuleDefaults[] = {
    {.name = "extmod",   .toLoad = TRUE,    .load_opt=NULL},
    {.name = "dbe",      .toLoad = TRUE,    .load_opt=NULL},
    {.name = "glx",      .toLoad = TRUE,    .load_opt=NULL},
    {.name = "freetype", .toLoad = TRUE,    .load_opt=NULL},
    {.name = "record",   .toLoad = TRUE,    .load_opt=NULL},
    {.name = "dri",      .toLoad = TRUE,    .load_opt=NULL},
    {.name = NULL,       .toLoad = FALSE,   .load_opt=NULL}
};


Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
128 129 130 131 132 133 134 135 136 137 138
/* Forward declarations */
static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
			 int scrnum, MessageType from);
static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
			 Bool active);
static Bool configInput(IDevPtr inputp, XF86ConfInputPtr conf_input,
			MessageType from);
static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
static Bool addDefaultModes(MonPtr monitorp);
#ifdef XF86DRI
139
static void configDRI(XF86ConfDRIPtr drip);
140
#endif
141
static void configExtensions(XF86ConfExtensionsPtr conf_ext);
142 143 144 145 146 147 148 149

/*
 * xf86GetPathElem --
 *	Extract a single element from the font path string starting at
 *	pnt.  The font path element will be returned, and pnt will be
 *	updated to point to the start of the next element, or set to
 *	NULL if there are no more.
 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
150 151
static char *
xf86GetPathElem(char **pnt)
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
{
  char *p1;

  p1 = *pnt;
  *pnt = index(*pnt, ',');
  if (*pnt != NULL) {
    **pnt = '\0';
    *pnt += 1;
  }
  return(p1);
}

/*
 * xf86ValidateFontPath --
 *	Validates the user-specified font path.  Each element that
 *	begins with a '/' is checked to make sure the directory exists.
 *	If the directory exists, the existence of a file named 'fonts.dir'
 *	is checked.  If either check fails, an error is printed and the
 *	element is removed from the font path.
 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
172 173

#define DIR_FILE "/fonts.dir"
174
static char *
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
175
xf86ValidateFontPath(char *path)
176 177 178 179 180 181
{
  char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
  struct stat stat_buf;
  int flag;
  int dirlen;

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
182
  tmp_path = xcalloc(1,strlen(path)+1);
183 184 185 186 187 188
  out_pnt = tmp_path;
  path_elem = NULL;
  next = path;
  while (next != NULL) {
    path_elem = xf86GetPathElem(&next);
    if (*path_elem == '/') {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
189
      dir_elem = xnfcalloc(1, strlen(path_elem) + 1);
190 191 192 193 194 195 196 197
      if ((p1 = strchr(path_elem, ':')) != 0)
	dirlen = p1 - path_elem;
      else
	dirlen = strlen(path_elem);
      strncpy(dir_elem, path_elem, dirlen);
      dir_elem[dirlen] = '\0';
      flag = stat(dir_elem, &stat_buf);
      if (flag == 0)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
198
	if (!S_ISDIR(stat_buf.st_mode))
199 200
	  flag = -1;
      if (flag != 0) {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
201 202 203
        xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n", dir_elem);
	xf86ErrorF("\tEntry deleted from font path.\n");
	xfree(dir_elem);
204 205 206
	continue;
      }
      else {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
207
	p1 = xnfalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
208 209 210 211
	strcpy(p1, dir_elem);
	strcat(p1, DIR_FILE);
	flag = stat(p1, &stat_buf);
	if (flag == 0)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
212
	  if (!S_ISREG(stat_buf.st_mode))
213 214 215
	    flag = -1;
	xfree(p1);
	if (flag != 0) {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
216 217 218 219 220 221
	  xf86Msg(X_WARNING,
		  "`fonts.dir' not found (or not valid) in \"%s\".\n", 
		  dir_elem);
	  xf86ErrorF("\tEntry deleted from font path.\n");
	  xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
	  xfree(dir_elem);
222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
	  continue;
	}
      }
      xfree(dir_elem);
    }

    /*
     * Either an OK directory, or a font server name.  So add it to
     * the path.
     */
    if (out_pnt != tmp_path)
      *out_pnt++ = ',';
    strcat(out_pnt, path_elem);
    out_pnt += strlen(path_elem);
  }
  return(tmp_path);
}

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
240

241
/*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
242 243
 * use the datastructure that the parser provides and pick out the parts
 * that we need at this point
244
 */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
245 246
char **
xf86ModulelistFromConfig(pointer **optlist)
247
{
248
    int count = 0, i = 0;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
249
    char **modulearray;
250
    char *ignore[] = { "GLcore", "speedo", "bitmap", "drm", NULL };
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
251 252
    pointer *optarray;
    XF86LoadPtr modp;
253
    Bool found;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
254 255 256 257 258 259 260 261 262 263 264 265
    
    /*
     * make sure the config file has been parsed and that we have a
     * ModulePath set; if no ModulePath was given, use the default
     * ModulePath
     */
    if (xf86configptr == NULL) {
        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
        return NULL;
    }
    
    if (xf86configptr->conf_modules) {
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
        /* Walk the disable list and let people know what we've parsed to
         * not be loaded 
         */
        modp = xf86configptr->conf_modules->mod_disable_lst;
        while (modp) {
            xf86Msg(X_WARNING, "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n", modp->load_name);
	        modp = (XF86LoadPtr) modp->list.next;
        }
        /*
         * Walk the default settings table. For each module listed to be
         * loaded, make sure it's in the mod_load_lst. If it's not, make
         * sure it's not in the mod_no_load_lst. If it's not disabled,
         * append it to mod_load_lst
         */
         for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
            if (ModuleDefaults[i].toLoad == FALSE) {
                xf86Msg(X_WARNING, "\"%s\" is not to be loaded by default. Skipping.\n", ModuleDefaults[i].name);
                continue;
284
            }
285 286 287 288
            found = FALSE;
            modp = xf86configptr->conf_modules->mod_load_lst;
            while (modp) {
                if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
289
                    xf86Msg(X_INFO, "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n", ModuleDefaults[i].name);
290 291 292 293 294 295 296 297 298
                    found = TRUE;
                    break;
                }
	        modp = (XF86LoadPtr) modp->list.next;
            }
            if (found == FALSE) {
                modp = xf86configptr->conf_modules->mod_disable_lst;
                while (modp) {
                    if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
299
                        xf86Msg(X_INFO, "\"%s\" will be loaded even though the default is to disable it.\n", ModuleDefaults[i].name);
300 301 302 303 304 305 306 307 308
                        found = TRUE;
                        break;
                    }
	                modp = (XF86LoadPtr) modp->list.next;
                }
            }
            if (found == FALSE) {
	            XF86ConfModulePtr ptr = xf86configptr->conf_modules;
	            ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
309
                xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n", ModuleDefaults[i].name);
310 311
            }
         }
312 313
    } else {
	xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec));
314 315 316 317 318 319
	for (i=0 ; ModuleDefaults[i].name != NULL ; i++) {
	    if (ModuleDefaults[i].toLoad == TRUE) {
		XF86ConfModulePtr ptr = xf86configptr->conf_modules;
		ptr = xf86addNewLoadDirective(ptr, ModuleDefaults[i].name, XF86_LOAD_MODULE, ModuleDefaults[i].load_opt);
	    }
	}
320 321
    }

322 323 324 325 326 327 328 329 330 331 332 333 334 335
	    /*
	     * Walk the list of modules in the "Module" section to determine how
	     * many we have.
	    */
	    modp = xf86configptr->conf_modules->mod_load_lst;
	    while (modp) {
                for (i = 0; ignore[i]; i++) {
                    if (strcmp(modp->load_name, ignore[i]) == 0)
                        modp->ignore = 1;
                }
                if (!modp->ignore)
	            count++;
	        modp = (XF86LoadPtr) modp->list.next;
	    }
336

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
337 338 339 340 341 342 343
    /*
     * allocate the memory and walk the list again to fill in the pointers
     */
    modulearray = xnfalloc((count + 1) * sizeof(char*));
    optarray = xnfalloc((count + 1) * sizeof(pointer));
    count = 0;
    if (xf86configptr->conf_modules) {
344 345
	    modp = xf86configptr->conf_modules->mod_load_lst;
	    while (modp) {
346
            if (!modp->ignore) {
347 348 349
	            modulearray[count] = modp->load_name;
	            optarray[count] = modp->load_opt;
	            count++;
350
            }
351 352
	        modp = (XF86LoadPtr) modp->list.next;
	    }
353
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
354 355 356
    modulearray[count] = NULL;
    optarray[count] = NULL;
    if (optlist)
357
	    *optlist = optarray;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
358
    else
359
	    xfree(optarray);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
360 361 362 363 364 365 366 367 368 369 370
    return modulearray;
}


char **
xf86DriverlistFromConfig()
{
    int count = 0;
    int j;
    char **modulearray;
    screenLayoutPtr slp;
371
    
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
372 373 374 375 376 377 378 379
    /*
     * make sure the config file has been parsed and that we have a
     * ModulePath set; if no ModulePath was given, use the default
     * ModulePath
     */
    if (xf86configptr == NULL) {
        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
        return NULL;
380
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
381 382 383 384 385 386 387 388 389 390 391
    
    /*
     * Walk the list of driver lines in active "Device" sections to
     * determine now many implicitly loaded modules there are.
     *
     */
    if (xf86ConfigLayout.screens) {
        slp = xf86ConfigLayout.screens;
        while ((slp++)->screen) {
	    count++;
        }
392 393
    }

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
394 395 396 397 398 399
    /*
     * Handle the set of inactive "Device" sections.
     */
    j = 0;
    while (xf86ConfigLayout.inactives[j++].identifier)
	count++;
400

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
401 402
    if (count == 0)
	return NULL;
403

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
404 405 406 407 408 409 410 411 412 413 414
    /*
     * allocate the memory and walk the list again to fill in the pointers
     */
    modulearray = xnfalloc((count + 1) * sizeof(char*));
    count = 0;
    slp = xf86ConfigLayout.screens;
    while (slp->screen) {
	modulearray[count] = slp->screen->device->driver;
	count++;
	slp++;
    }
415

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
416
    j = 0;
417

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
418 419
    while (xf86ConfigLayout.inactives[j].identifier) 
	modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
420

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
421
    modulearray[count] = NULL;
422

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
423 424 425
    /* Remove duplicates */
    for (count = 0; modulearray[count] != NULL; count++) {
	int i;
426

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
427 428 429 430 431 432 433
	for (i = 0; i < count; i++)
	    if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
		modulearray[count] = "";
		break;
	    }
    }
    return modulearray;
434 435
}

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
436 437 438 439 440
char **
xf86InputDriverlistFromConfig()
{
    int count = 0;
    char **modulearray;
441
    IDevPtr* idp;
442 443
    
    /*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
444 445 446
     * make sure the config file has been parsed and that we have a
     * ModulePath set; if no ModulePath was given, use the default
     * ModulePath
447
     */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
448 449 450
    if (xf86configptr == NULL) {
        xf86Msg(X_ERROR, "Cannot access global config data structure\n");
        return NULL;
451 452 453
    }
    
    /*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
454 455
     * Walk the list of driver lines in active "InputDevice" sections to
     * determine now many implicitly loaded modules there are.
456
     */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
457 458
    if (xf86ConfigLayout.inputs) {
        idp = xf86ConfigLayout.inputs;
459
        while (*idp) {
460
	    count++;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
461 462 463
	    idp++;
        }
    }
464

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
465 466
    if (count == 0)
	return NULL;
467 468

    /*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
469
     * allocate the memory and walk the list again to fill in the pointers
470
     */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
471 472 473
    modulearray = xnfalloc((count + 1) * sizeof(char*));
    count = 0;
    idp = xf86ConfigLayout.inputs;
474 475
    while (idp && *idp) {
        modulearray[count] = (*idp)->driver;
476
	count++;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
477 478 479
	idp++;
    }
    modulearray[count] = NULL;
480

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
481 482 483 484 485 486 487 488 489 490 491
    /* Remove duplicates */
    for (count = 0; modulearray[count] != NULL; count++) {
	int i;

	for (i = 0; i < count; i++)
	    if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
		modulearray[count] = "";
		break;
	    }
    }
    return modulearray;
492 493
}

494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526
static void
fixup_video_driver_list(char **drivers)
{
    static const char *fallback[5] = { "vga", "vesa", "fbdev", "wsfb", NULL };
    char **end, **drv;
    char *x;
    char **ati, **atimisc;
    int i;

    /* walk to the end of the list */
    for (end = drivers; *end && **end; end++) ;
    end--;

    /*
     * for each of the fallback drivers, if we find it in the list,
     * swap it with the last available non-fallback driver.
     */
    for (i = 0; fallback[i]; i++) {
        for (drv = drivers; drv != end; drv++) {
            if (strstr(*drv, fallback[i])) {
                x = *drv; *drv = *end; *end = x;
                end--;
                break;
            }
        }
    }
    /*
     * since the ati wrapper driver is gross and awful, sort ati before
     * atimisc, which makes sure all the ati symbols are visible in xorgcfg.
     */
    for (drv = drivers; drv != end; drv++) {
        if (!strcmp(*drv, "atimisc")) {
            atimisc = drv;
527
            for (drv = atimisc; drv != end; drv++) {
528 529 530 531 532 533
                if (!strcmp(*drv, "ati")) {
                    ati = drv;
                    x = *ati; *ati = *atimisc; *atimisc = x;
                    return;
                }
            }
534
            /* if we get here, ati was already ahead of atimisc */
535
            return;
536 537 538 539
        }
    }
}

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
540
static char **
541
GenerateDriverlist(char * dirname)
542
{
543
    char **ret;
544
    const char *subdirs[] = { dirname, NULL };
545
    static const char *patlist[] = {"(.*)_drv\\.so", "(.*)_drv\\.o", NULL};
546 547 548
    ret = LoaderListDirs(subdirs, patlist);
    
    /* fix up the probe order for video drivers */
549
    if (strstr(dirname, "drivers") && ret != NULL)
550
        fixup_video_driver_list(ret);
551 552

    return ret;
553 554
}

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
555 556
char **
xf86DriverlistFromCompile(void)
557
{
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
558
    static char **driverlist = NULL;
559

560 561
    if (!driverlist)
        driverlist = GenerateDriverlist("drivers");
562

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583
    return driverlist;
}

/*
 * xf86ConfigError --
 *      Print a READABLE ErrorMessage!!!  All information that is 
 *      available is printed.
 */
static void
xf86ConfigError(char *msg, ...)
{
    va_list ap;

    ErrorF("\nConfig Error:\n");
    va_start(ap, msg);
    VErrorF(msg, ap);
    va_end(ap);
    ErrorF("\n");
    return;
}

584
static void
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
585 586 587
configFiles(XF86ConfFilesPtr fileconf)
{
  MessageType pathFrom = X_DEFAULT;
588 589 590
  int countDirs;
  char *temp_path;
  char *log_buf;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
591 592

  /* FontPath */
593
  /* Try XF86Config FontPath first */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
594 595 596 597 598
  if (!xf86fpFlag) {
   if (fileconf) {
    if (fileconf->file_fontpath) {
      char *f = xf86ValidateFontPath(fileconf->file_fontpath);
      pathFrom = X_CONFIG;
599 600
      if (*f) {
        if (xf86Info.useDefaultFontPath) {
601
          xf86Msg(X_DEFAULT, "Including the default font path %s.\n", defaultFontPath);
602 603 604 605 606 607 608 609 610
          char *g = xnfalloc(strlen(defaultFontPath) + strlen(f) + 3);
          strcpy(g, f);
          strcat(g, ",");
          defaultFontPath = strcat(g, defaultFontPath);
          xfree(f);
        } else {
          defaultFontPath = f;
        }
      } else {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
611 612 613 614 615 616 617
	xf86Msg(X_WARNING,
	    "FontPath is completely invalid.  Using compiled-in default.\n");
        fontPath = NULL;
        pathFrom = X_DEFAULT;
      }
    } 
   } else {
618
      xf86Msg(X_DEFAULT,
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
619 620 621 622 623
	    "No FontPath specified.  Using compiled-in default.\n");
      pathFrom = X_DEFAULT;
   }
  } else {
    /* Use fontpath specified with '-fp' */
624 625
    if (fontPath)
    {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
626
      fontPath = NULL;
627
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
628
    pathFrom = X_CMDLINE;
629
  }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
630 631
  if (!fileconf) {
      /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
632
       could be static, so we make a copy. */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
633
    char *f = xnfalloc(strlen(defaultFontPath) + 1);
634 635 636 637
    f[0] = '\0';
    strcpy (f, defaultFontPath);
    defaultFontPath = xf86ValidateFontPath(f);
    xfree(f);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
638 639 640 641 642 643 644 645 646 647 648 649
  } else {
   if (fileconf) {
    if (!fileconf->file_fontpath) {
      /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
       could be static, so we make a copy. */
     char *f = xnfalloc(strlen(defaultFontPath) + 1);
     f[0] = '\0';
     strcpy (f, defaultFontPath);
     defaultFontPath = xf86ValidateFontPath(f);
     xfree(f);
    }
   }
650 651 652 653 654
  }

  /* If defaultFontPath is still empty, exit here */

  if (! *defaultFontPath)
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
655
    FatalError("No valid FontPath could be found.");
656

657
  /* make fontpath more readable in the logfiles */
658 659
  countDirs = 1;
  temp_path = defaultFontPath;
660 661 662 663
  while((temp_path = index(temp_path, ',')) != NULL) {
    countDirs++;
    temp_path++;
  }
664
  log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1);
665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
  if(!log_buf) /* fallback to old method */
    xf86Msg(pathFrom, "FontPath set to \"%s\"\n", defaultFontPath);
  else {
    char *start, *end;
    int size;
    temp_path = log_buf;
    start = defaultFontPath;
    while((end = index(start, ',')) != NULL) {
      size = (end - start) + 1;
      *(temp_path++) = '\t';
      strncpy(temp_path, start, size);
      temp_path += size;
      *(temp_path++) = '\n';
      start += size;
    }
    /* copy last entry */
    *(temp_path++) = '\t';
    strcpy(temp_path, start);
    xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
    xfree(log_buf);
  }

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
687 688 689 690 691 692 693 694 695 696 697 698 699 700

  if (fileconf && fileconf->file_inputdevs) {
      xf86InputDeviceList = fileconf->file_inputdevs;
      xf86Msg(X_CONFIG, "Input device list set to \"%s\"\n",
	  xf86InputDeviceList);
  }
  
  
  /* ModulePath */

  if (fileconf) {
    if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
      xf86ModulePath = fileconf->file_modulepath;
      xf86ModPathFrom = X_CONFIG;
701
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
702 703 704
  }

  xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
705

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
706 707
#if 0
  /* LogFile */
708
  /*
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
709 710 711 712 713 714 715
   * XXX The problem with this is that the log file is already open.
   * One option might be to copy the exiting contents to the new location.
   * and re-open it.  The down side is that the default location would
   * already have been overwritten.  Another option would be to start with
   * unique temporary location, then copy it once the correct name is known.
   * A problem with this is what happens if the server exits before that
   * happens.
716
   */
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
717 718 719 720 721
  if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
    xf86LogFile = fileconf->file_logfile;
    xf86LogFileFrom = X_CONFIG;
  }
#endif
722

723
  return;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758
}

typedef enum {
    FLAG_NOTRAPSIGNALS,
    FLAG_DONTVTSWITCH,
    FLAG_DONTZAP,
    FLAG_DONTZOOM,
    FLAG_DISABLEVIDMODE,
    FLAG_ALLOWNONLOCAL,
    FLAG_DISABLEMODINDEV,
    FLAG_MODINDEVALLOWNONLOCAL,
    FLAG_ALLOWMOUSEOPENFAIL,
    FLAG_VTINIT,
    FLAG_VTSYSREQ,
    FLAG_XKBDISABLE,
    FLAG_PCIPROBE1,
    FLAG_PCIPROBE2,
    FLAG_PCIFORCECONFIG1,
    FLAG_PCIFORCECONFIG2,
    FLAG_PCIFORCENONE,
    FLAG_PCIOSCONFIG,
    FLAG_SAVER_BLANKTIME,
    FLAG_DPMS_STANDBYTIME,
    FLAG_DPMS_SUSPENDTIME,
    FLAG_DPMS_OFFTIME,
    FLAG_PIXMAP,
    FLAG_PC98,
    FLAG_ESTIMATE_SIZES_AGGRESSIVELY,
    FLAG_NOPM,
    FLAG_XINERAMA,
    FLAG_ALLOW_DEACTIVATE_GRABS,
    FLAG_ALLOW_CLOSEDOWN_GRABS,
    FLAG_LOG,
    FLAG_RENDER_COLORMAP_MODE,
    FLAG_HANDLE_SPECIAL_KEYS,
759
    FLAG_RANDR,
760
    FLAG_AIGLX,
761 762
    FLAG_IGNORE_ABI,
    FLAG_ALLOW_EMPTY_INPUT,
Daniel Stone's avatar
Daniel Stone committed
763 764 765
    FLAG_USE_DEFAULT_FONT_PATH,
    FLAG_AUTO_ADD_DEVICES,
    FLAG_AUTO_ENABLE_DEVICES,
766
    FLAG_GLX_VISUALS,
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835
} FlagValues;
   
static OptionInfoRec FlagOptions[] = {
  { FLAG_NOTRAPSIGNALS,		"NoTrapSignals",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_DONTVTSWITCH,		"DontVTSwitch",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_DONTZAP,		"DontZap",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_DONTZOOM,		"DontZoom",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_DISABLEVIDMODE,	"DisableVidModeExtension",	OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_ALLOWNONLOCAL,		"AllowNonLocalXvidtune",	OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_DISABLEMODINDEV,	"DisableModInDev",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_MODINDEVALLOWNONLOCAL,	"AllowNonLocalModInDev",	OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_ALLOWMOUSEOPENFAIL,	"AllowMouseOpenFail",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_VTINIT,		"VTInit",			OPTV_STRING,
	{0}, FALSE },
  { FLAG_VTSYSREQ,		"VTSysReq",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_XKBDISABLE,		"XkbDisable",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIPROBE1,		"PciProbe1"		,	OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIPROBE2,		"PciProbe2",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIFORCECONFIG1,	"PciForceConfig1",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIFORCECONFIG2,	"PciForceConfig2",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIFORCENONE,		"PciForceNone",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_PCIOSCONFIG,	        "PciOsConfig",   		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_SAVER_BLANKTIME,	"BlankTime"		,	OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_DPMS_STANDBYTIME,	"StandbyTime",			OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_DPMS_SUSPENDTIME,	"SuspendTime",			OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_DPMS_OFFTIME,		"OffTime",			OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_PIXMAP,		"Pixmap",			OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_PC98,			"PC98",				OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_ESTIMATE_SIZES_AGGRESSIVELY,"EstimateSizesAggressively",OPTV_INTEGER,
	{0}, FALSE },
  { FLAG_NOPM,			"NoPM",				OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_XINERAMA,		"Xinerama",			OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_ALLOW_DEACTIVATE_GRABS,"AllowDeactivateGrabs",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_ALLOW_CLOSEDOWN_GRABS, "AllowClosedownGrabs",		OPTV_BOOLEAN,
	{0}, FALSE },
  { FLAG_LOG,			"Log",				OPTV_STRING,
	{0}, FALSE },
  { FLAG_RENDER_COLORMAP_MODE,	"RenderColormapMode",		OPTV_STRING,
        {0}, FALSE },
  { FLAG_HANDLE_SPECIAL_KEYS,	"HandleSpecialKeys",		OPTV_STRING,
        {0}, FALSE },
  { FLAG_RANDR,			"RandR",			OPTV_BOOLEAN,
	{0}, FALSE },
836 837
  { FLAG_AIGLX,			"AIGLX",			OPTV_BOOLEAN,
	{0}, FALSE },
838 839
  { FLAG_ALLOW_EMPTY_INPUT,     "AllowEmptyInput",              OPTV_BOOLEAN,
        {0}, FALSE },
840 841
  { FLAG_IGNORE_ABI,			"IgnoreABI",			OPTV_BOOLEAN,
	{0}, FALSE },
842 843
  { FLAG_USE_DEFAULT_FONT_PATH,  "UseDefaultFontPath",			OPTV_BOOLEAN,
	{0}, FALSE },
Daniel Stone's avatar
Daniel Stone committed
844 845 846 847
  { FLAG_AUTO_ADD_DEVICES,       "AutoAddDevices",                      OPTV_BOOLEAN,
        {0}, TRUE },
  { FLAG_AUTO_ENABLE_DEVICES,    "AutoEnableDevices",                   OPTV_BOOLEAN,
        {0}, TRUE },
848 849
  { FLAG_GLX_VISUALS,		"GlxVisuals",			OPTV_STRING,
        {0}, FALSE },
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
850 851 852 853
  { -1,				NULL,				OPTV_NONE,
	{0}, FALSE },
};

854
#ifdef __i386__
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
855 856 857 858 859
static Bool
detectPC98(void)
{
#ifdef SUPPORT_PC98
    unsigned char buf[2];
860

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
861 862 863 864 865 866 867 868
    if (xf86ReadBIOS(0xf8000, 0xe80, buf, 2) != 2)
	return FALSE;
    if ((buf[0] == 0x98) && (buf[1] == 0x21))
	return TRUE;
    else
	return FALSE;
#else
    return FALSE;
869 870
#endif
}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
871
#endif /* __i386__ */
872

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
873 874
static Bool
configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
875
{
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
876 877 878 879 880
    XF86OptionPtr optp, tmp;
    int i;
    Pix24Flags pix24 = Pix24DontCare;
    Bool value;
    MessageType from;
881
    const char *s;
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908

    /*
     * Merge the ServerLayout and ServerFlags options.  The former have
     * precedence over the latter.
     */
    optp = NULL;
    if (flagsconf && flagsconf->flg_option_lst)
	optp = xf86optionListDup(flagsconf->flg_option_lst);
    if (layoutopts) {
	tmp = xf86optionListDup(layoutopts);
	if (optp)
	    optp = xf86optionListMerge(optp, tmp);
	else
	    optp = tmp;
    }

    xf86ProcessOptions(-1, optp, FlagOptions);

    xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
    xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
    xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
    xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);

    xf86GetOptValBool(FlagOptions, FLAG_ALLOW_DEACTIVATE_GRABS,
		      &(xf86Info.grabInfo.allowDeactivate));
    xf86GetOptValBool(FlagOptions, FLAG_ALLOW_CLOSEDOWN_GRABS,
		      &(xf86Info.grabInfo.allowClosedown));
909
    xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
910
    if (xf86Info.ignoreABI) {
911 912
	    xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
913

Daniel Stone's avatar
Daniel Stone committed
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937
    if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
        xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
                          &xf86Info.autoAddDevices);
        from = X_CONFIG;
    }
    else {
        xf86Info.autoAddDevices = TRUE;
        from = X_DEFAULT;
    }
    xf86Msg(from, "%sutomatically adding devices\n",
            xf86Info.autoAddDevices ? "A" : "Not a");

    if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
        xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
                          &xf86Info.autoEnableDevices);
        from = X_CONFIG;
    }
    else {
        xf86Info.autoEnableDevices = TRUE;
        from = X_DEFAULT;
    }
    xf86Msg(from, "%sutomatically enabling devices\n",
            xf86Info.autoEnableDevices ? "A" : "Not a");

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963
    /*
     * Set things up based on the config file information.  Some of these
     * settings may be overridden later when the command line options are
     * checked.
     */
#ifdef XF86VIDMODE
    if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
	xf86Info.vidModeEnabled = !value;
    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
	xf86Info.vidModeAllowNonLocal = value;
#endif

#ifdef XF86MISC
    if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEMODINDEV, &value))
	xf86Info.miscModInDevEnabled = !value;
    if (xf86GetOptValBool(FlagOptions, FLAG_MODINDEVALLOWNONLOCAL, &value))
	xf86Info.miscModInDevAllowNonLocal = value;
#endif

    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
	xf86Info.allowMouseOpenFail = value;

    if (xf86GetOptValBool(FlagOptions, FLAG_VTSYSREQ, &value)) {
#ifdef USE_VT_SYSREQ
	xf86Info.vtSysreq = value;
	xf86Msg(X_CONFIG, "VTSysReq %s\n", value ? "enabled" : "disabled");
964
#else
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
965 966
	if (value)
	    xf86Msg(X_WARNING, "VTSysReq is not supported on this OS\n");
967
#endif
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002
    }

    if (xf86GetOptValBool(FlagOptions, FLAG_XKBDISABLE, &value)) {
#ifdef XKB
	noXkbExtension = value;
	xf86Msg(X_CONFIG, "Xkb %s\n", value ? "disabled" : "enabled");
#else
	if (!value)
	    xf86Msg(X_WARNING, "Xserver doesn't support XKB\n");
#endif
    }

    xf86Info.vtinit = xf86GetOptValString(FlagOptions, FLAG_VTINIT);

    if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE1))
	xf86Info.pciFlags = PCIProbe1;
    if (xf86IsOptionSet(FlagOptions, FLAG_PCIPROBE2))
	xf86Info.pciFlags = PCIProbe2;
    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG1))
	xf86Info.pciFlags = PCIForceConfig1;
    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCECONFIG2))
	xf86Info.pciFlags = PCIForceConfig2;
    if (xf86IsOptionSet(FlagOptions, FLAG_PCIOSCONFIG))
	xf86Info.pciFlags = PCIOsConfig;
    if (xf86IsOptionSet(FlagOptions, FLAG_PCIFORCENONE))
	xf86Info.pciFlags = PCIForceNone;

    xf86Info.pmFlag = TRUE;
    if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value)) 
	xf86Info.pmFlag = !value;
    {
	if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
	    if (!xf86NameCmp(s,"flush")) {
		xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
		xf86Info.log = LogFlush;
1003
		LogSetParameter(XLOG_FLUSH, TRUE);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1004 1005 1006
	    } else if (!xf86NameCmp(s,"sync")) {
		xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
		xf86Info.log = LogSync;
1007
		LogSetParameter(XLOG_FLUSH, TRUE);
1008
		LogSetParameter(XLOG_SYNC, TRUE);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1009 1010 1011 1012 1013
	    } else {
		xf86Msg(X_WARNING,"Unknown Log option\n");
	    }
        }
    }
1014
    
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1015 1016 1017 1018 1019 1020 1021
#ifdef RENDER
    {
	if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))){
	    int policy = PictureParseCmapPolicy (s);
	    if (policy == PictureCmapPolicyInvalid)
		xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
	    else
1022
	    {
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1023 1024
		xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
		PictureCmapPolicy = policy;
1025 1026
	    }
	}
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
    }
#endif
    {
	if ((s = xf86GetOptValString(FlagOptions, FLAG_HANDLE_SPECIAL_KEYS))) {
	    if (!xf86NameCmp(s,"always")) {
		xf86Msg(X_CONFIG, "Always handling special keys in DDX\n");
		xf86Info.ddxSpecialKeys = SKAlways;
	    } else if (!xf86NameCmp(s,"whenneeded")) {
		xf86Msg(X_CONFIG, "Special keys handled in DDX only if needed\n");
		xf86Info.ddxSpecialKeys = SKWhenNeeded;
	    } else if (!xf86NameCmp(s,"never")) {
		xf86Msg(X_CONFIG, "Never handling special keys in DDX\n");
		xf86Info.ddxSpecialKeys = SKNever;
	    } else {
		xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
1042
	    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058
        }
    }
#ifdef RANDR
    xf86Info.disableRandR = FALSE;
    xf86Info.randRFrom = X_DEFAULT;
    if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
	xf86Info.disableRandR = !value;
	xf86Info.randRFrom = X_CONFIG;
    }
#endif
    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_ESTIMATE_SIZES_AGGRESSIVELY, &i);
    if (i >= 0)
	xf86Info.estimateSizesAggressively = i;
    else
	xf86Info.estimateSizesAggressively = 0;
1059

1060 1061 1062 1063 1064 1065 1066
    xf86Info.aiglx = TRUE;
    xf86Info.aiglxFrom = X_DEFAULT;
    if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
	xf86Info.aiglx = value;
	xf86Info.aiglxFrom = X_CONFIG;
    }

1067
#ifdef GLXEXT
1068
    xf86Info.glxVisuals = XF86_GlxVisualsTypical;
1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
    xf86Info.glxVisualsFrom = X_DEFAULT;
    if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
	if (!xf86NameCmp(s, "minimal")) {
	    xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
	} else if (!xf86NameCmp(s, "typical")) {
	    xf86Info.glxVisuals = XF86_GlxVisualsTypical;
	} else if (!xf86NameCmp(s, "all")) {
	    xf86Info.glxVisuals = XF86_GlxVisualsAll;
	} else {
	    xf86Msg(X_WARNING,"Unknown HandleSpecialKeys option\n");
	}
    }

    if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
	xf86Info.aiglx = value;
	xf86Info.aiglxFrom = X_CONFIG;
    }
#endif

1088 1089 1090 1091
    xf86Info.allowEmptyInput = FALSE;
    if (xf86GetOptValBool(FlagOptions, FLAG_ALLOW_EMPTY_INPUT, &value))
        xf86Info.allowEmptyInput = TRUE;

1092 1093 1094 1095 1096 1097 1098
    xf86Info.useDefaultFontPath = TRUE;
    xf86Info.useDefaultFontPathFrom = X_DEFAULT;
    if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
	xf86Info.useDefaultFontPath = value;
	xf86Info.useDefaultFontPathFrom = X_CONFIG;
    }

1099 1100 1101
/* Make sure that timers don't overflow CARD32's after multiplying */
#define MAX_TIME_IN_MIN (0x7fffffff / MILLI_PER_MIN)

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1102 1103
    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
1104
    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1105
	ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN;
1106 1107 1108
    else if (i != -1)
	xf86ConfigError("BlankTime value %d outside legal range of 0 - %d minutes",
			i, MAX_TIME_IN_MIN);
1109

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1110 1111 1112
#ifdef DPMSExtension
    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
1113
    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1114
	DPMSStandbyTime = defaultDPMSStandbyTime = i * MILLI_PER_MIN;
1115 1116 1117
    else if (i != -1)
	xf86ConfigError("StandbyTime value %d outside legal range of 0 - %d minutes",
			i, MAX_TIME_IN_MIN);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1118 1119
    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
1120
    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1121
	DPMSSuspendTime = defaultDPMSSuspendTime = i * MILLI_PER_MIN;
1122 1123 1124
    else if (i != -1)
	xf86ConfigError("SuspendTime value %d outside legal range of 0 - %d minutes",
			i, MAX_TIME_IN_MIN);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1125 1126
    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
1127
    if ((i >= 0) && (i < MAX_TIME_IN_MIN))
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1128
	DPMSOffTime = defaultDPMSOffTime = i * MILLI_PER_MIN;
1129 1130 1131
    else if (i != -1)
	xf86ConfigError("OffTime value %d outside legal range of 0 - %d minutes",
			i, MAX_TIME_IN_MIN);
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144
#endif

    i = -1;
    xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
    switch (i) {
    case 24:
	pix24 = Pix24Use24;
	break;
    case 32:
	pix24 = Pix24Use32;
	break;
    case -1:
	break;
1145
    default:
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1146 1147
	xf86ConfigError("Pixmap option's value (%d) must be 24 or 32\n", i);
	return FALSE;
1148
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
    if (xf86Pix24 != Pix24DontCare) {
	xf86Info.pixmap24 = xf86Pix24;
	xf86Info.pix24From = X_CMDLINE;
    } else if (pix24 != Pix24DontCare) {
	xf86Info.pixmap24 = pix24;
	xf86Info.pix24From = X_CONFIG;
    } else {
	xf86Info.pixmap24 = Pix24DontCare;
	xf86Info.pix24From = X_DEFAULT;
    }
1159
#ifdef __i386__
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169
    if (xf86GetOptValBool(FlagOptions, FLAG_PC98, &value)) {
	xf86Info.pc98 = value;
	if (value) {
	    xf86Msg(X_CONFIG, "Japanese PC98 architecture\n");
	}
    } else
	if (detectPC98()) {
	    xf86Info.pc98 = TRUE;
	    xf86Msg(X_PROBED, "Japanese PC98 architecture\n");
	}
1170 1171
#endif

Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1172 1173 1174 1175 1176 1177 1178
#ifdef PANORAMIX
    from = X_DEFAULT;
    if (!noPanoramiXExtension)
      from = X_CMDLINE;
    else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
      noPanoramiXExtension = !value;
      from = X_CONFIG;
1179
    }
Kaleb Keithley Keithley's avatar
Kaleb Keithley Keithley committed
1180 1181
    if (!noPanoramiXExtension)