Bug Summary

File:hw/xfree86/common/xf86Config.c
Location:line 1732, column 9
Description:Value stored to 'from' is never read

Annotated Source Code

1/*
2 * Loosely based on code bearing the following copyright:
3 *
4 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
5 */
6
7/*
8 * Copyright 1992-2003 by The XFree86 Project, Inc.
9 * Copyright 1997 by Metro Link, Inc.
10 *
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:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 *
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.
28 *
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).
33 */
34
35/*
36 *
37 * Authors:
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>
42 * ... and others
43 */
44
45#ifdef HAVE_XORG_CONFIG_H1
46#include <xorg-config.h>
47#endif
48
49#include <sys/types.h>
50#include <grp.h>
51
52#include "xf86.h"
53#include "xf86Modes.h"
54#include "xf86Parser.h"
55#include "xf86tokens.h"
56#include "xf86Config.h"
57#include "xf86Priv.h"
58#include "xf86_OSlib.h"
59#include "configProcs.h"
60#include "globals.h"
61#include "extension.h"
62#include "xf86pciBus.h"
63
64#include "xf86Xinput.h"
65
66#include "xkbsrv.h"
67
68#include "picture.h"
69
70/*
71 * These paths define the way the config file search is done. The escape
72 * sequences are documented in parser/scan.c.
73 */
74#ifndef ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
75#define ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
"%A," "%R," \
76 "/etc/X11/%R," "%P/etc/X11/%R," \
77 "%E," "%F," \
78 "/etc/X11/%F," "%P/etc/X11/%F," \
79 "/etc/X11/%X," "/etc/%X," \
80 "%P/etc/X11/%X.%H," \
81 "%P/etc/X11/%X," \
82 "%P/lib/X11/%X.%H," \
83 "%P/lib/X11/%X"
84#endif
85#ifndef RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
86#define RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
"/etc/X11/%S," "%P/etc/X11/%S," \
87 "/etc/X11/%G," "%P/etc/X11/%G," \
88 "/etc/X11/%X," "/etc/%X," \
89 "%P/etc/X11/%X.%H," \
90 "%P/etc/X11/%X," \
91 "%P/lib/X11/%X.%H," \
92 "%P/lib/X11/%X"
93#endif
94#ifndef ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X"
95#define ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X" "%A," "%R," \
96 "/etc/X11/%R," "%C/X11/%R," \
97 "/etc/X11/%X," "%C/X11/%X"
98#endif
99#ifndef RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X"
100#define RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X" "/etc/X11/%R," "%C/X11/%R," \
101 "/etc/X11/%X," "%C/X11/%X"
102#endif
103#ifndef SYS_CONFIGDIRPATH"%D/X11/%X"
104#define SYS_CONFIGDIRPATH"%D/X11/%X" "%D/X11/%X"
105#endif
106#ifndef PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build"
107#define PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build" "/usr/X11R6"
108#endif
109
110static ModuleDefault ModuleDefaults[] = {
111#ifdef GLXEXT1
112 {.name = "glx",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
113#endif
114#ifdef __CYGWIN__
115 /* load DIX modules used by drivers first */
116 {.name = "fb",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
117 {.name = "shadow",.toLoad = TRUE1,.load_opt = NULL((void*)0)},
118#endif
119 {.name = NULL((void*)0),.toLoad = FALSE0,.load_opt = NULL((void*)0)}
120};
121
122/* Forward declarations */
123static Bool configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen,
124 int scrnum, MessageType from, Bool auto_gpu_device);
125static Bool configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor);
126static Bool configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device,
127 Bool active, Bool gpu);
128static Bool configInput(InputInfoPtr pInfo, XF86ConfInputPtr conf_input,
129 MessageType from);
130static Bool configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display);
131static Bool addDefaultModes(MonPtr monitorp);
132
133static void configDRI(XF86ConfDRIPtr drip);
134static void configExtensions(XF86ConfExtensionsPtr conf_ext);
135
136/*
137 * xf86GetPathElem --
138 * Extract a single element from the font path string starting at
139 * pnt. The font path element will be returned, and pnt will be
140 * updated to point to the start of the next element, or set to
141 * NULL if there are no more.
142 */
143static char *
144xf86GetPathElem(char **pnt)
145{
146 char *p1;
147
148 p1 = *pnt;
149 *pnt = index(*pnt, ',');
150 if (*pnt != NULL((void*)0)) {
151 **pnt = '\0';
152 *pnt += 1;
153 }
154 return p1;
155}
156
157/*
158 * xf86ValidateFontPath --
159 * Validates the user-specified font path. Each element that
160 * begins with a '/' is checked to make sure the directory exists.
161 * If the directory exists, the existence of a file named 'fonts.dir'
162 * is checked. If either check fails, an error is printed and the
163 * element is removed from the font path.
164 */
165
166#define DIR_FILE"/fonts.dir" "/fonts.dir"
167static char *
168xf86ValidateFontPath(char *path)
169{
170 char *next, *tmp_path, *out_pnt, *path_elem, *p1, *dir_elem;
171 struct stat stat_buf;
172 int flag;
173 int dirlen;
174
175 tmp_path = calloc(1, strlen(path) + 1);
176 out_pnt = tmp_path;
177 path_elem = NULL((void*)0);
178 next = path;
179 while (next != NULL((void*)0)) {
180 path_elem = xf86GetPathElem(&next);
181 if (*path_elem == '/') {
182 dir_elem = xnfcalloc(1, strlen(path_elem) + 1)XNFcallocarray((1), (strlen(path_elem) + 1));
183 if ((p1 = strchr(path_elem, ':')) != 0)
184 dirlen = p1 - path_elem;
185 else
186 dirlen = strlen(path_elem);
187 strlcpy(dir_elem, path_elem, dirlen + 1)__builtin___strlcpy_chk (dir_elem, path_elem, dirlen + 1, __builtin_object_size
(dir_elem, 2 > 1 ? 1 : 0))
;
188 flag = stat(dir_elem, &stat_buf);
189 if (flag == 0)
190 if (!S_ISDIR(stat_buf.st_mode)(((stat_buf.st_mode) & 0170000) == 0040000))
191 flag = -1;
192 if (flag != 0) {
193 xf86Msg(X_WARNING, "The directory \"%s\" does not exist.\n",
194 dir_elem);
195 xf86ErrorF("\tEntry deleted from font path.\n");
196 free(dir_elem);
197 continue;
198 }
199 else {
200 XNFasprintf(&p1, "%s%s", dir_elem, DIR_FILE"/fonts.dir");
201 flag = stat(p1, &stat_buf);
202 if (flag == 0)
203 if (!S_ISREG(stat_buf.st_mode)(((stat_buf.st_mode) & 0170000) == 0100000))
204 flag = -1;
205 free(p1);
206 if (flag != 0) {
207 xf86Msg(X_WARNING,
208 "`fonts.dir' not found (or not valid) in \"%s\".\n",
209 dir_elem);
210 xf86ErrorF("\tEntry deleted from font path.\n");
211 xf86ErrorF("\t(Run 'mkfontdir' on \"%s\").\n", dir_elem);
212 free(dir_elem);
213 continue;
214 }
215 }
216 free(dir_elem);
217 }
218
219 /*
220 * Either an OK directory, or a font server name. So add it to
221 * the path.
222 */
223 if (out_pnt != tmp_path)
224 *out_pnt++ = ',';
225 strcat(out_pnt, path_elem)__builtin___strcat_chk (out_pnt, path_elem, __builtin_object_size
(out_pnt, 2 > 1 ? 1 : 0))
;
226 out_pnt += strlen(path_elem);
227 }
228 return tmp_path;
229}
230
231#define FIND_SUITABLE(pointertype, listhead, ptr)do { pointertype _l, _p; for (_l = (listhead), _p = ((void*)0
); !_p && _l; _l = (pointertype)_l->list.next) { if
(!_l->match_seat || (SeatId && xf86nameCompare(_l
->match_seat, SeatId) == 0)) _p = _l; } (ptr) = _p; } while
(0)
\
232 do { \
233 pointertype _l, _p; \
234 \
235 for (_l = (listhead), _p = NULL((void*)0); !_p && _l; _l = (pointertype)_l->list.next) { \
236 if (!_l->match_seat || (SeatId && xf86nameCompare(_l->match_seat, SeatId) == 0)) \
237 _p = _l; \
238 } \
239 \
240 (ptr) = _p; \
241 } while(0)
242
243/*
244 * use the datastructure that the parser provides and pick out the parts
245 * that we need at this point
246 */
247const char **
248xf86ModulelistFromConfig(void ***optlist)
249{
250 int count = 0, i = 0;
251 const char **modulearray;
252
253 const char *ignore[] = { "GLcore", "speedo", "bitmap", "drm",
254 "freetype", "type1",
255 NULL((void*)0)
256 };
257 void **optarray;
258 XF86LoadPtr modp;
259 Bool found;
260
261 /*
262 * make sure the config file has been parsed and that we have a
263 * ModulePath set; if no ModulePath was given, use the default
264 * ModulePath
265 */
266 if (xf86configptr == NULL((void*)0)) {
267 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
268 return NULL((void*)0);
269 }
270
271 if (xf86configptr->conf_modules) {
272 /* Walk the disable list and let people know what we've parsed to
273 * not be loaded
274 */
275 modp = xf86configptr->conf_modules->mod_disable_lst;
276 while (modp) {
277 xf86Msg(X_WARNING,
278 "\"%s\" will not be loaded unless you've specified it to be loaded elsewhere.\n",
279 modp->load_name);
280 modp = (XF86LoadPtr) modp->list.next;
281 }
282 /*
283 * Walk the default settings table. For each module listed to be
284 * loaded, make sure it's in the mod_load_lst. If it's not, make
285 * sure it's not in the mod_no_load_lst. If it's not disabled,
286 * append it to mod_load_lst
287 */
288 for (i = 0; ModuleDefaults[i].name != NULL((void*)0); i++) {
289 if (ModuleDefaults[i].toLoad == FALSE0) {
290 xf86Msg(X_WARNING,
291 "\"%s\" is not to be loaded by default. Skipping.\n",
292 ModuleDefaults[i].name);
293 continue;
294 }
295 found = FALSE0;
296 modp = xf86configptr->conf_modules->mod_load_lst;
297 while (modp) {
298 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
299 xf86Msg(X_INFO,
300 "\"%s\" will be loaded. This was enabled by default and also specified in the config file.\n",
301 ModuleDefaults[i].name);
302 found = TRUE1;
303 break;
304 }
305 modp = (XF86LoadPtr) modp->list.next;
306 }
307 if (found == FALSE0) {
308 modp = xf86configptr->conf_modules->mod_disable_lst;
309 while (modp) {
310 if (strcmp(modp->load_name, ModuleDefaults[i].name) == 0) {
311 xf86Msg(X_INFO,
312 "\"%s\" will be loaded even though the default is to disable it.\n",
313 ModuleDefaults[i].name);
314 found = TRUE1;
315 break;
316 }
317 modp = (XF86LoadPtr) modp->list.next;
318 }
319 }
320 if (found == FALSE0) {
321 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
322
323 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
324 XF86_LOAD_MODULE0,
325 ModuleDefaults[i].load_opt);
326 xf86Msg(X_INFO, "\"%s\" will be loaded by default.\n",
327 ModuleDefaults[i].name);
328 }
329 }
330 }
331 else {
332 xf86configptr->conf_modules = xnfcalloc(1, sizeof(XF86ConfModuleRec))XNFcallocarray((1), (sizeof(XF86ConfModuleRec)));
333 for (i = 0; ModuleDefaults[i].name != NULL((void*)0); i++) {
334 if (ModuleDefaults[i].toLoad == TRUE1) {
335 XF86LoadPtr ptr = (XF86LoadPtr) xf86configptr->conf_modules;
336
337 xf86addNewLoadDirective(ptr, ModuleDefaults[i].name,
338 XF86_LOAD_MODULE0,
339 ModuleDefaults[i].load_opt);
340 }
341 }
342 }
343
344 /*
345 * Walk the list of modules in the "Module" section to determine how
346 * many we have.
347 */
348 modp = xf86configptr->conf_modules->mod_load_lst;
349 while (modp) {
350 for (i = 0; ignore[i]; i++) {
351 if (strcmp(modp->load_name, ignore[i]) == 0)
352 modp->ignore = 1;
353 }
354 if (!modp->ignore)
355 count++;
356 modp = (XF86LoadPtr) modp->list.next;
357 }
358
359 /*
360 * allocate the memory and walk the list again to fill in the pointers
361 */
362 modulearray = xnfallocarray(count + 1, sizeof(char *))XNFreallocarray(((void*)0), (count + 1), (sizeof(char *)));
363 optarray = xnfallocarray(count + 1, sizeof(void *))XNFreallocarray(((void*)0), (count + 1), (sizeof(void *)));
364 count = 0;
365 if (xf86configptr->conf_modules) {
366 modp = xf86configptr->conf_modules->mod_load_lst;
367 while (modp) {
368 if (!modp->ignore) {
369 modulearray[count] = modp->load_name;
370 optarray[count] = modp->load_opt;
371 count++;
372 }
373 modp = (XF86LoadPtr) modp->list.next;
374 }
375 }
376 modulearray[count] = NULL((void*)0);
377 optarray[count] = NULL((void*)0);
378 if (optlist)
379 *optlist = optarray;
380 else
381 free(optarray);
382 return modulearray;
383}
384
385const char **
386xf86DriverlistFromConfig(void)
387{
388 int count = 0;
389 int j, k;
390 const char **modulearray;
391 screenLayoutPtr slp;
392
393 /*
394 * make sure the config file has been parsed and that we have a
395 * ModulePath set; if no ModulePath was given, use the default
396 * ModulePath
397 */
398 if (xf86configptr == NULL((void*)0)) {
399 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
400 return NULL((void*)0);
401 }
402
403 /*
404 * Walk the list of driver lines in active "Device" sections to
405 * determine now many implicitly loaded modules there are.
406 *
407 */
408 if (xf86ConfigLayout.screens) {
409 slp = xf86ConfigLayout.screens;
410 while (slp->screen) {
411 count++;
412 count += slp->screen->num_gpu_devices;
413 slp++;
414 }
415 }
416
417 /*
418 * Handle the set of inactive "Device" sections.
419 */
420 j = 0;
421 while (xf86ConfigLayout.inactives[j++].identifier)
422 count++;
423
424 if (count == 0)
425 return NULL((void*)0);
426
427 /*
428 * allocate the memory and walk the list again to fill in the pointers
429 */
430 modulearray = xnfallocarray(count + 1, sizeof(char *))XNFreallocarray(((void*)0), (count + 1), (sizeof(char *)));
431 count = 0;
432 slp = xf86ConfigLayout.screens;
433 while (slp->screen) {
434 modulearray[count] = slp->screen->device->driver;
435 count++;
436 for (k = 0; k < slp->screen->num_gpu_devices; k++) {
437 modulearray[count] = slp->screen->gpu_devices[k]->driver;
438 count++;
439 }
440 slp++;
441 }
442
443 j = 0;
444
445 while (xf86ConfigLayout.inactives[j].identifier)
446 modulearray[count++] = xf86ConfigLayout.inactives[j++].driver;
447
448 modulearray[count] = NULL((void*)0);
449
450 /* Remove duplicates */
451 for (count = 0; modulearray[count] != NULL((void*)0); count++) {
452 int i;
453
454 for (i = 0; i < count; i++)
455 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
456 modulearray[count] = "";
457 break;
458 }
459 }
460 return modulearray;
461}
462
463const char **
464xf86InputDriverlistFromConfig(void)
465{
466 int count = 0;
467 const char **modulearray;
468 InputInfoPtr *idp;
469
470 /*
471 * make sure the config file has been parsed and that we have a
472 * ModulePath set; if no ModulePath was given, use the default
473 * ModulePath
474 */
475 if (xf86configptr == NULL((void*)0)) {
476 xf86Msg(X_ERROR, "Cannot access global config data structure\n");
477 return NULL((void*)0);
478 }
479
480 /*
481 * Walk the list of driver lines in active "InputDevice" sections to
482 * determine now many implicitly loaded modules there are.
483 */
484 if (xf86ConfigLayout.inputs) {
485 idp = xf86ConfigLayout.inputs;
486 while (*idp) {
487 count++;
488 idp++;
489 }
490 }
491
492 if (count == 0)
493 return NULL((void*)0);
494
495 /*
496 * allocate the memory and walk the list again to fill in the pointers
497 */
498 modulearray = xnfallocarray(count + 1, sizeof(char *))XNFreallocarray(((void*)0), (count + 1), (sizeof(char *)));
499 count = 0;
500 idp = xf86ConfigLayout.inputs;
501 while (idp && *idp) {
502 modulearray[count] = (*idp)->driver;
503 count++;
504 idp++;
505 }
506 modulearray[count] = NULL((void*)0);
507
508 /* Remove duplicates */
509 for (count = 0; modulearray[count] != NULL((void*)0); count++) {
510 int i;
511
512 for (i = 0; i < count; i++)
513 if (xf86NameCmp(modulearray[i], modulearray[count]) == 0) {
514 modulearray[count] = "";
515 break;
516 }
517 }
518 return modulearray;
519}
520
521static void
522fixup_video_driver_list(const char **drivers)
523{
524 static const char *fallback[5] = { "modesetting", "fbdev", "vesa", "wsfb", NULL((void*)0) };
525 const char **end, **drv;
526 const char *x;
527 int i;
528
529 /* walk to the end of the list */
530 for (end = drivers; *end && **end; end++);
531 end--;
532
533 /*
534 * for each of the fallback drivers, if we find it in the list,
535 * swap it with the last available non-fallback driver.
536 */
537 for (i = 0; fallback[i]; i++) {
538 for (drv = drivers; drv != end; drv++) {
539 if (strstr(*drv, fallback[i])) {
540 x = *drv;
541 *drv = *end;
542 *end = x;
543 end--;
544 break;
545 }
546 }
547 }
548}
549
550static const char **
551GenerateDriverlist(const char *dirname)
552{
553 const char **ret;
554 const char *subdirs[] = { dirname, NULL((void*)0) };
555 static const char *patlist[] = { "(.*)_drv\\.so", NULL((void*)0) };
556 ret = LoaderListDirs(subdirs, patlist);
557
558 /* fix up the probe order for video drivers */
559 if (strstr(dirname, "drivers") && ret != NULL((void*)0))
560 fixup_video_driver_list(ret);
561
562 return ret;
563}
564
565const char **
566xf86DriverlistFromCompile(void)
567{
568 static const char **driverlist = NULL((void*)0);
569
570 if (!driverlist)
571 driverlist = GenerateDriverlist("drivers");
572
573 return driverlist;
574}
575
576static void
577configFiles(XF86ConfFilesPtr fileconf)
578{
579 MessageType pathFrom;
580 Bool must_copy;
581 int size, countDirs;
582 char *temp_path, *log_buf, *start, *end;
583
584 /* FontPath */
585 must_copy = TRUE1;
586
587 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
588 if (xf86fpFlag)
589 pathFrom = X_CMDLINE;
590 else if (fileconf && fileconf->file_fontpath) {
591 pathFrom = X_CONFIG;
592 if (xf86Info.useDefaultFontPath) {
593 char *new_font_path;
594 if (asprintf(&new_font_path, "%s%s%s", fileconf->file_fontpath,
595 *temp_path ? "," : "", temp_path) == -1)
596 new_font_path = NULL((void*)0);
597 else
598 must_copy = FALSE0;
599 defaultFontPath = new_font_path;
600 }
601 else
602 defaultFontPath = fileconf->file_fontpath;
603 }
604 else
605 pathFrom = X_DEFAULT;
606 temp_path = defaultFontPath ? (char *) defaultFontPath : (char *) "";
607
608 /* xf86ValidateFontPath modifies its argument, but returns a copy of it. */
609 temp_path = must_copy ? xnfstrdup(defaultFontPath)XNFstrdup(defaultFontPath) : (char *) defaultFontPath;
610 defaultFontPath = xf86ValidateFontPath(temp_path);
611 free(temp_path);
612
613 /* make fontpath more readable in the logfiles */
614 countDirs = 1;
615 temp_path = (char *) defaultFontPath;
616 while ((temp_path = index(temp_path, ',')) != NULL((void*)0)) {
617 countDirs++;
618 temp_path++;
619 }
620
621 log_buf = xnfalloc(strlen(defaultFontPath) + (2 * countDirs) + 1)XNFalloc((unsigned long)(strlen(defaultFontPath) + (2 * countDirs
) + 1))
;
622 temp_path = log_buf;
623 start = (char *) defaultFontPath;
624 while ((end = index(start, ',')) != NULL((void*)0)) {
625 size = (end - start) + 1;
626 *(temp_path++) = '\t';
627 strncpy(temp_path, start, size)__builtin___strncpy_chk (temp_path, start, size, __builtin_object_size
(temp_path, 2 > 1 ? 1 : 0))
;
628 temp_path += size;
629 *(temp_path++) = '\n';
630 start += size;
631 }
632 /* copy last entry */
633 *(temp_path++) = '\t';
634 strcpy(temp_path, start)__builtin___strcpy_chk (temp_path, start, __builtin_object_size
(temp_path, 2 > 1 ? 1 : 0))
;
635 xf86Msg(pathFrom, "FontPath set to:\n%s\n", log_buf);
636 free(log_buf);
637
638 /* ModulePath */
639
640 if (fileconf) {
641 if (xf86ModPathFrom != X_CMDLINE && fileconf->file_modulepath) {
642 xf86ModulePath = fileconf->file_modulepath;
643 xf86ModPathFrom = X_CONFIG;
644 }
645 }
646
647 xf86Msg(xf86ModPathFrom, "ModulePath set to \"%s\"\n", xf86ModulePath);
648
649 if (!xf86xkbdirFlag && fileconf && fileconf->file_xkbdir) {
650 XkbBaseDirectory = fileconf->file_xkbdir;
651 xf86Msg(X_CONFIG, "XKB base directory set to \"%s\"\n",
652 XkbBaseDirectory);
653 }
654#if 0
655 /* LogFile */
656 /*
657 * XXX The problem with this is that the log file is already open.
658 * One option might be to copy the exiting contents to the new location.
659 * and re-open it. The down side is that the default location would
660 * already have been overwritten. Another option would be to start with
661 * unique temporary location, then copy it once the correct name is known.
662 * A problem with this is what happens if the server exits before that
663 * happens.
664 */
665 if (xf86LogFileFrom == X_DEFAULT && fileconf->file_logfile) {
666 xf86LogFile = fileconf->file_logfile;
667 xf86LogFileFrom = X_CONFIG;
668 }
669#endif
670
671 return;
672}
673
674typedef enum {
675 FLAG_NOTRAPSIGNALS,
676 FLAG_DONTVTSWITCH,
677 FLAG_DONTZAP,
678 FLAG_DONTZOOM,
679 FLAG_DISABLEVIDMODE,
680 FLAG_ALLOWNONLOCAL,
681 FLAG_ALLOWMOUSEOPENFAIL,
682 FLAG_SAVER_BLANKTIME,
683 FLAG_DPMS_STANDBYTIME,
684 FLAG_DPMS_SUSPENDTIME,
685 FLAG_DPMS_OFFTIME,
686 FLAG_PIXMAP,
687 FLAG_NOPM,
688 FLAG_XINERAMA,
689 FLAG_LOG,
690 FLAG_RENDER_COLORMAP_MODE,
691 FLAG_RANDR,
692 FLAG_AIGLX,
693 FLAG_IGNORE_ABI,
694 FLAG_ALLOW_EMPTY_INPUT,
695 FLAG_USE_DEFAULT_FONT_PATH,
696 FLAG_AUTO_ADD_DEVICES,
697 FLAG_AUTO_ENABLE_DEVICES,
698 FLAG_GLX_VISUALS,
699 FLAG_DRI2,
700 FLAG_USE_SIGIO,
701 FLAG_AUTO_ADD_GPU,
702 FLAG_MAX_CLIENTS,
703} FlagValues;
704
705/**
706 * NOTE: the last value for each entry is NOT the default. It is set to TRUE
707 * if the parser found the option in the config file.
708 */
709static OptionInfoRec FlagOptions[] = {
710 {FLAG_NOTRAPSIGNALS, "NoTrapSignals", OPTV_BOOLEAN,
711 {0}, FALSE0},
712 {FLAG_DONTVTSWITCH, "DontVTSwitch", OPTV_BOOLEAN,
713 {0}, FALSE0},
714 {FLAG_DONTZAP, "DontZap", OPTV_BOOLEAN,
715 {0}, FALSE0},
716 {FLAG_DONTZOOM, "DontZoom", OPTV_BOOLEAN,
717 {0}, FALSE0},
718 {FLAG_DISABLEVIDMODE, "DisableVidModeExtension", OPTV_BOOLEAN,
719 {0}, FALSE0},
720 {FLAG_ALLOWNONLOCAL, "AllowNonLocalXvidtune", OPTV_BOOLEAN,
721 {0}, FALSE0},
722 {FLAG_ALLOWMOUSEOPENFAIL, "AllowMouseOpenFail", OPTV_BOOLEAN,
723 {0}, FALSE0},
724 {FLAG_SAVER_BLANKTIME, "BlankTime", OPTV_INTEGER,
725 {0}, FALSE0},
726 {FLAG_DPMS_STANDBYTIME, "StandbyTime", OPTV_INTEGER,
727 {0}, FALSE0},
728 {FLAG_DPMS_SUSPENDTIME, "SuspendTime", OPTV_INTEGER,
729 {0}, FALSE0},
730 {FLAG_DPMS_OFFTIME, "OffTime", OPTV_INTEGER,
731 {0}, FALSE0},
732 {FLAG_PIXMAP, "Pixmap", OPTV_INTEGER,
733 {0}, FALSE0},
734 {FLAG_NOPM, "NoPM", OPTV_BOOLEAN,
735 {0}, FALSE0},
736 {FLAG_XINERAMA, "Xinerama", OPTV_BOOLEAN,
737 {0}, FALSE0},
738 {FLAG_LOG, "Log", OPTV_STRING,
739 {0}, FALSE0},
740 {FLAG_RENDER_COLORMAP_MODE, "RenderColormapMode", OPTV_STRING,
741 {0}, FALSE0},
742 {FLAG_RANDR, "RandR", OPTV_BOOLEAN,
743 {0}, FALSE0},
744 {FLAG_AIGLX, "AIGLX", OPTV_BOOLEAN,
745 {0}, FALSE0},
746 {FLAG_IGNORE_ABI, "IgnoreABI", OPTV_BOOLEAN,
747 {0}, FALSE0},
748 {FLAG_USE_DEFAULT_FONT_PATH, "UseDefaultFontPath", OPTV_BOOLEAN,
749 {0}, FALSE0},
750 {FLAG_AUTO_ADD_DEVICES, "AutoAddDevices", OPTV_BOOLEAN,
751 {0}, FALSE0},
752 {FLAG_AUTO_ENABLE_DEVICES, "AutoEnableDevices", OPTV_BOOLEAN,
753 {0}, FALSE0},
754 {FLAG_GLX_VISUALS, "GlxVisuals", OPTV_STRING,
755 {0}, FALSE0},
756 {FLAG_DRI2, "DRI2", OPTV_BOOLEAN,
757 {0}, FALSE0},
758 {FLAG_USE_SIGIO, "UseSIGIO", OPTV_BOOLEAN,
759 {0}, FALSE0},
760 {FLAG_AUTO_ADD_GPU, "AutoAddGPU", OPTV_BOOLEAN,
761 {0}, FALSE0},
762 {FLAG_MAX_CLIENTS, "MaxClients", OPTV_INTEGER,
763 {0}, FALSE0 },
764 {-1, NULL((void*)0), OPTV_NONE,
765 {0}, FALSE0},
766};
767
768static void
769configServerFlags(XF86ConfFlagsPtr flagsconf, XF86OptionPtr layoutopts)
770{
771 XF86OptionPtr optp, tmp;
772 int i;
773 Pix24Flags pix24 = Pix24DontCare;
774 Bool value;
775 MessageType from;
776 const char *s;
777 XkbRMLVOSet set;
778 const char *rules;
779
780 /*
781 * Merge the ServerLayout and ServerFlags options. The former have
782 * precedence over the latter.
783 */
784 optp = NULL((void*)0);
785 if (flagsconf && flagsconf->flg_option_lst)
786 optp = xf86optionListDup(flagsconf->flg_option_lst);
787 if (layoutopts) {
788 tmp = xf86optionListDup(layoutopts);
789 if (optp)
790 optp = xf86optionListMerge(optp, tmp);
791 else
792 optp = tmp;
793 }
794
795 xf86ProcessOptions(-1, optp, FlagOptions);
796
797 xf86GetOptValBool(FlagOptions, FLAG_NOTRAPSIGNALS, &xf86Info.notrapSignals);
798 xf86GetOptValBool(FlagOptions, FLAG_DONTVTSWITCH, &xf86Info.dontVTSwitch);
799 xf86GetOptValBool(FlagOptions, FLAG_DONTZAP, &xf86Info.dontZap);
800 xf86GetOptValBool(FlagOptions, FLAG_DONTZOOM, &xf86Info.dontZoom);
801
802 xf86GetOptValBool(FlagOptions, FLAG_IGNORE_ABI, &xf86Info.ignoreABI);
803 if (xf86Info.ignoreABI) {
804 xf86Msg(X_CONFIG, "Ignoring ABI Version\n");
805 }
806
807 if (xf86SIGIOSupported()) {
808 xf86Info.useSIGIO =
809 xf86ReturnOptValBool(FlagOptions, FLAG_USE_SIGIO,
810 USE_SIGIO_BY_DEFAULT1);
811 if (xf86IsOptionSet(FlagOptions, FLAG_USE_SIGIO)) {
812 from = X_CONFIG;
813 }
814 else {
815 from = X_DEFAULT;
816 }
817 if (!xf86Info.useSIGIO) {
818 xf86Msg(from, "Disabling SIGIO handlers for input devices\n");
819 }
820 else if (from == X_CONFIG) {
821 xf86Msg(from, "Enabling SIGIO handlers for input devices\n");
822 }
823 }
824 else {
825 xf86Info.useSIGIO = FALSE0;
826 }
827
828 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_DEVICES)) {
829 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_DEVICES,
830 &xf86Info.autoAddDevices);
831 from = X_CONFIG;
832 }
833 else {
834 from = X_DEFAULT;
835 }
836 xf86Msg(from, "%sutomatically adding devices\n",
837 xf86Info.autoAddDevices ? "A" : "Not a");
838
839 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ENABLE_DEVICES)) {
840 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ENABLE_DEVICES,
841 &xf86Info.autoEnableDevices);
842 from = X_CONFIG;
843 }
844 else {
845 from = X_DEFAULT;
846 }
847 xf86Msg(from, "%sutomatically enabling devices\n",
848 xf86Info.autoEnableDevices ? "A" : "Not a");
849
850 if (xf86IsOptionSet(FlagOptions, FLAG_AUTO_ADD_GPU)) {
851 xf86GetOptValBool(FlagOptions, FLAG_AUTO_ADD_GPU,
852 &xf86Info.autoAddGPU);
853 from = X_CONFIG;
854 }
855 else {
856 from = X_DEFAULT;
857 }
858 xf86Msg(from, "%sutomatically adding GPU devices\n",
859 xf86Info.autoAddGPU ? "A" : "Not a");
860 /*
861 * Set things up based on the config file information. Some of these
862 * settings may be overridden later when the command line options are
863 * checked.
864 */
865#ifdef XF86VIDMODE1
866 if (xf86GetOptValBool(FlagOptions, FLAG_DISABLEVIDMODE, &value))
867 xf86Info.vidModeEnabled = !value;
868 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWNONLOCAL, &value))
869 xf86Info.vidModeAllowNonLocal = value;
870#endif
871
872 if (xf86GetOptValBool(FlagOptions, FLAG_ALLOWMOUSEOPENFAIL, &value))
873 xf86Info.allowMouseOpenFail = value;
874
875 xf86Info.pmFlag = TRUE1;
876 if (xf86GetOptValBool(FlagOptions, FLAG_NOPM, &value))
877 xf86Info.pmFlag = !value;
878 {
879 if ((s = xf86GetOptValString(FlagOptions, FLAG_LOG))) {
880 if (!xf86NameCmp(s, "flush")) {
881 xf86Msg(X_CONFIG, "Flushing logfile enabled\n");
882 LogSetParameter(XLOG_FLUSH, TRUE1);
883 }
884 else if (!xf86NameCmp(s, "sync")) {
885 xf86Msg(X_CONFIG, "Syncing logfile enabled\n");
886 LogSetParameter(XLOG_FLUSH, TRUE1);
887 LogSetParameter(XLOG_SYNC, TRUE1);
888 }
889 else {
890 xf86Msg(X_WARNING, "Unknown Log option\n");
891 }
892 }
893 }
894
895 {
896 if ((s = xf86GetOptValString(FlagOptions, FLAG_RENDER_COLORMAP_MODE))) {
897 int policy = PictureParseCmapPolicy(s);
898
899 if (policy == PictureCmapPolicyInvalid-1)
900 xf86Msg(X_WARNING, "Unknown colormap policy \"%s\"\n", s);
901 else {
902 xf86Msg(X_CONFIG, "Render colormap policy set to %s\n", s);
903 PictureCmapPolicy = policy;
904 }
905 }
906 }
907
908#ifdef RANDR1
909 xf86Info.disableRandR = FALSE0;
910 xf86Info.randRFrom = X_DEFAULT;
911 if (xf86GetOptValBool(FlagOptions, FLAG_RANDR, &value)) {
912 xf86Info.disableRandR = !value;
913 xf86Info.randRFrom = X_CONFIG;
914 }
915#endif
916
917 xf86Info.aiglx = TRUE1;
918 xf86Info.aiglxFrom = X_DEFAULT;
919 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
920 xf86Info.aiglx = value;
921 xf86Info.aiglxFrom = X_CONFIG;
922 }
923
924#ifdef GLXEXT1
925 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
926 xf86Info.glxVisualsFrom = X_DEFAULT;
927 if ((s = xf86GetOptValString(FlagOptions, FLAG_GLX_VISUALS))) {
928 if (!xf86NameCmp(s, "minimal")) {
929 xf86Info.glxVisuals = XF86_GlxVisualsMinimal;
930 }
931 else if (!xf86NameCmp(s, "typical")) {
932 xf86Info.glxVisuals = XF86_GlxVisualsTypical;
933 }
934 else if (!xf86NameCmp(s, "all")) {
935 xf86Info.glxVisuals = XF86_GlxVisualsAll;
936 }
937 else {
938 xf86Msg(X_WARNING, "Unknown GlxVisuals option\n");
939 }
940 }
941
942 if (xf86GetOptValBool(FlagOptions, FLAG_AIGLX, &value)) {
943 xf86Info.aiglx = value;
944 xf86Info.aiglxFrom = X_CONFIG;
945 }
946#endif
947
948 /* if we're not hotplugging, force some input devices to exist */
949 xf86Info.forceInputDevices = !(xf86Info.autoAddDevices &&
950 xf86Info.autoEnableDevices);
951
952 /* when forcing input devices, we use kbd. otherwise evdev, so use the
953 * evdev rules set. */
954#if defined(linux)
955 if (!xf86Info.forceInputDevices)
956 rules = "evdev";
957 else
958#endif
959 rules = "base";
960
961 /* Xkb default options. */
962 XkbInitRules(&set, rules, "pc105", "us", NULL((void*)0), NULL((void*)0));
963 XkbSetRulesDflts(&set);
964 XkbFreeRMLVOSet(&set, FALSE0);
965
966 xf86Info.useDefaultFontPath = TRUE1;
967 if (xf86GetOptValBool(FlagOptions, FLAG_USE_DEFAULT_FONT_PATH, &value)) {
968 xf86Info.useDefaultFontPath = value;
969 }
970
971/* Make sure that timers don't overflow CARD32's after multiplying */
972#define MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)) (0x7fffffff / MILLI_PER_MIN(1000 * 60))
973
974 i = -1;
975 xf86GetOptValInteger(FlagOptions, FLAG_SAVER_BLANKTIME, &i);
976 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
977 ScreenSaverTime = defaultScreenSaverTime = i * MILLI_PER_MIN(1000 * 60);
978 else if (i != -1)
979 ErrorF("BlankTime value %d outside legal range of 0 - %d minutes\n",
980 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
981
982#ifdef DPMSExtension1
983 i = -1;
984 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_STANDBYTIME, &i);
985 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
986 DPMSStandbyTime = i * MILLI_PER_MIN(1000 * 60);
987 else if (i != -1)
988 ErrorF("StandbyTime value %d outside legal range of 0 - %d minutes\n",
989 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
990 i = -1;
991 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_SUSPENDTIME, &i);
992 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
993 DPMSSuspendTime = i * MILLI_PER_MIN(1000 * 60);
994 else if (i != -1)
995 ErrorF("SuspendTime value %d outside legal range of 0 - %d minutes\n",
996 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
997 i = -1;
998 xf86GetOptValInteger(FlagOptions, FLAG_DPMS_OFFTIME, &i);
999 if ((i >= 0) && (i < MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60))))
1000 DPMSOffTime = i * MILLI_PER_MIN(1000 * 60);
1001 else if (i != -1)
1002 ErrorF("OffTime value %d outside legal range of 0 - %d minutes\n",
1003 i, MAX_TIME_IN_MIN(0x7fffffff / (1000 * 60)));
1004#endif
1005
1006 i = -1;
1007 xf86GetOptValInteger(FlagOptions, FLAG_PIXMAP, &i);
1008 switch (i) {
1009 case 24:
1010 pix24 = Pix24Use24;
1011 break;
1012 case 32:
1013 pix24 = Pix24Use32;
1014 break;
1015 case -1:
1016 break;
1017 default:
1018 ErrorF("Pixmap option's value (%d) must be 24 or 32\n", i);
1019 break;
1020 }
1021 if (xf86Pix24 != Pix24DontCare) {
1022 xf86Info.pixmap24 = xf86Pix24;
1023 xf86Info.pix24From = X_CMDLINE;
1024 }
1025 else if (pix24 != Pix24DontCare) {
1026 xf86Info.pixmap24 = pix24;
1027 xf86Info.pix24From = X_CONFIG;
1028 }
1029 else {
1030 xf86Info.pixmap24 = Pix24DontCare;
1031 xf86Info.pix24From = X_DEFAULT;
1032 }
1033
1034#ifdef PANORAMIX1
1035 from = X_DEFAULT;
1036 if (!noPanoramiXExtension)
1037 from = X_CMDLINE;
1038 else if (xf86GetOptValBool(FlagOptions, FLAG_XINERAMA, &value)) {
1039 noPanoramiXExtension = !value;
1040 from = X_CONFIG;
1041 }
1042 if (!noPanoramiXExtension)
1043 xf86Msg(from, "Xinerama: enabled\n");
1044#endif
1045
1046#ifdef DRI2
1047 xf86Info.dri2 = FALSE0;
1048 xf86Info.dri2From = X_DEFAULT;
1049 if (xf86GetOptValBool(FlagOptions, FLAG_DRI2, &value)) {
1050 xf86Info.dri2 = value;
1051 xf86Info.dri2From = X_CONFIG;
1052 }
1053#endif
1054
1055 from = X_DEFAULT;
1056 if (LimitClients != LIMITCLIENTS256)
1057 from = X_CMDLINE;
1058 i = -1;
1059 if (xf86GetOptValInteger(FlagOptions, FLAG_MAX_CLIENTS, &i)) {
1060 if (i != 64 && i != 128 && i != 256 && i != 512)
1061 ErrorF("MaxClients must be one of 64, 128, 256 or 512\n");
1062 from = X_CONFIG;
1063 LimitClients = i;
1064 }
1065 xf86Msg(from, "Max clients allowed: %i, resource mask: 0x%x\n",
1066 LimitClients, RESOURCE_ID_MASK((1 << (29 - ResourceClientBits())) - 1));
1067}
1068
1069Bool
1070xf86DRI2Enabled(void)
1071{
1072 return xf86Info.dri2;
1073}
1074
1075/**
1076 * Search for the pInfo in the null-terminated list given and remove (and
1077 * free) it if present. All other devices are moved forward.
1078 */
1079static void
1080freeDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1081{
1082 InputInfoPtr *devs;
1083
1084 for (devs = list; devs && *devs; devs++) {
1085 if (*devs == pInfo) {
1086 free(*devs);
1087 for (; devs && *devs; devs++)
1088 devs[0] = devs[1];
1089 break;
1090 }
1091 }
1092}
1093
1094/**
1095 * Append pInfo to the null-terminated list, allocating space as necessary.
1096 * pInfo is used as the last element.
1097 */
1098static InputInfoPtr *
1099addDevice(InputInfoPtr * list, InputInfoPtr pInfo)
1100{
1101 InputInfoPtr *devs;
1102 int count = 1;
1103
1104 for (devs = list; devs && *devs; devs++)
1105 count++;
1106
1107 list = xnfreallocarray(list, count + 1, sizeof(InputInfoPtr))XNFreallocarray((list), (count + 1), (sizeof(InputInfoPtr)));
1108 list[count] = NULL((void*)0);
1109
1110 list[count - 1] = pInfo;
1111 return list;
1112}
1113
1114/*
1115 * Locate the core input devices. These can be specified/located in
1116 * the following ways, in order of priority:
1117 *
1118 * 1. The InputDevices named by the -pointer and -keyboard command line
1119 * options.
1120 * 2. The "CorePointer" and "CoreKeyboard" InputDevices referred to by
1121 * the active ServerLayout.
1122 * 3. The first InputDevices marked as "CorePointer" and "CoreKeyboard".
1123 * 4. The first InputDevices that use 'keyboard' or 'kbd' and a valid mouse
1124 * driver (mouse, synaptics, evdev, vmmouse, void)
1125 * 5. Default devices with an empty (default) configuration. These defaults
1126 * will reference the 'mouse' and 'keyboard' drivers.
1127 */
1128
1129static Bool
1130checkCoreInputDevices(serverLayoutPtr servlayoutp, Bool implicitLayout)
1131{
1132 InputInfoPtr corePointer = NULL((void*)0), coreKeyboard = NULL((void*)0);
1133 Bool foundPointer = FALSE0, foundKeyboard = FALSE0;
1134 const char *pointerMsg = NULL((void*)0), *keyboardMsg = NULL((void*)0);
1135 InputInfoPtr *devs, /* iterator */
1136 indp;
1137 InputInfoPtr Pointer, Keyboard;
1138 XF86ConfInputPtr confInput;
1139 XF86ConfInputRec defPtr, defKbd;
1140 MessageType from = X_DEFAULT;
1141
1142 const char *mousedrivers[] = { "mouse", "synaptics", "evdev", "vmmouse",
1143 "void", NULL((void*)0)
1144 };
1145
1146 /*
1147 * First check if a core pointer or core keyboard have been specified
1148 * in the active ServerLayout. If more than one is specified for either,
1149 * remove the core attribute from the later ones.
1150 */
1151 for (devs = servlayoutp->inputs; devs && *devs; devs++) {
1152 indp = *devs;
1153 if (indp->options &&
1154 xf86CheckBoolOption(indp->options, "CorePointer", FALSE0)) {
1155 if (!corePointer) {
1156 corePointer = indp;
1157 }
1158 }
1159 if (indp->options &&
1160 xf86CheckBoolOption(indp->options, "CoreKeyboard", FALSE0)) {
1161 if (!coreKeyboard) {
1162 coreKeyboard = indp;
1163 }
1164 }
1165 }
1166
1167 confInput = NULL((void*)0);
1168
1169 /* 1. Check for the -pointer command line option. */
1170 if (xf86PointerName) {
1171 confInput = xf86findInput(xf86PointerName,
1172 xf86configptr->conf_input_lst);
1173 if (!confInput) {
1174 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1175 xf86PointerName);
1176 return FALSE0;
1177 }
1178 from = X_CMDLINE;
1179 /*
1180 * If one was already specified in the ServerLayout, it needs to be
1181 * removed.
1182 */
1183 if (corePointer) {
1184 freeDevice(servlayoutp->inputs, corePointer);
1185 corePointer = NULL((void*)0);
1186 }
1187 foundPointer = TRUE1;
1188 }
1189
1190 /* 2. ServerLayout-specified core pointer. */
1191 if (corePointer) {
1192 foundPointer = TRUE1;
1193 from = X_CONFIG;
1194 }
1195
1196 /* 3. First core pointer device. */
1197 if (!foundPointer && (xf86Info.forceInputDevices || implicitLayout)) {
1198 XF86ConfInputPtr p;
1199
1200 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1201 if (p->inp_option_lst &&
1202 xf86CheckBoolOption(p->inp_option_lst, "CorePointer", FALSE0)) {
1203 confInput = p;
1204 foundPointer = TRUE1;
1205 from = X_DEFAULT;
1206 pointerMsg = "first core pointer device";
1207 break;
1208 }
1209 }
1210 }
1211
1212 /* 4. First pointer with an allowed mouse driver. */
1213 if (!foundPointer && xf86Info.forceInputDevices) {
1214 const char **driver = mousedrivers;
1215
1216 confInput = xf86findInput(CONF_IMPLICIT_POINTER"Implicit Core Pointer",
1217 xf86configptr->conf_input_lst);
1218 while (*driver && !confInput) {
1219 confInput = xf86findInputByDriver(*driver,
1220 xf86configptr->conf_input_lst);
1221 driver++;
1222 }
1223 if (confInput) {
1224 foundPointer = TRUE1;
1225 from = X_DEFAULT;
1226 pointerMsg = "first mouse device";
1227 }
1228 }
1229
1230 /* 5. Built-in default. */
1231 if (!foundPointer && xf86Info.forceInputDevices) {
1232 memset(&defPtr, 0, sizeof(defPtr))__builtin___memset_chk (&defPtr, 0, sizeof(defPtr), __builtin_object_size
(&defPtr, 0))
;
1233 defPtr.inp_identifier = strdup("<default pointer>");
1234 defPtr.inp_driver = strdup("mouse");
1235 confInput = &defPtr;
1236 foundPointer = TRUE1;
1237 from = X_DEFAULT;
1238 pointerMsg = "default mouse configuration";
1239 }
1240
1241 /* Add the core pointer device to the layout, and set it to Core. */
1242 if (foundPointer && confInput) {
1243 Pointer = xf86AllocateInput();
1244 if (Pointer)
1245 foundPointer = configInput(Pointer, confInput, from);
1246 if (foundPointer) {
1247 Pointer->options = xf86AddNewOption(Pointer->options,
1248 "CorePointer", "on");
1249 Pointer->options = xf86AddNewOption(Pointer->options,
1250 "driver",
1251 confInput->inp_driver);
1252 Pointer->options =
1253 xf86AddNewOption(Pointer->options, "identifier",
1254 confInput->inp_identifier);
1255 servlayoutp->inputs = addDevice(servlayoutp->inputs, Pointer);
1256 }
1257 }
1258
1259 if (!foundPointer && xf86Info.forceInputDevices) {
1260 /* This shouldn't happen. */
1261 xf86Msg(X_ERROR, "Cannot locate a core pointer device.\n");
1262 xf86DeleteInput(Pointer, 0);
1263 return FALSE0;
1264 }
1265
1266 confInput = NULL((void*)0);
1267
1268 /* 1. Check for the -keyboard command line option. */
1269 if (xf86KeyboardName) {
1270 confInput = xf86findInput(xf86KeyboardName,
1271 xf86configptr->conf_input_lst);
1272 if (!confInput) {
1273 xf86Msg(X_ERROR, "No InputDevice section called \"%s\"\n",
1274 xf86KeyboardName);
1275 return FALSE0;
1276 }
1277 from = X_CMDLINE;
1278 /*
1279 * If one was already specified in the ServerLayout, it needs to be
1280 * removed.
1281 */
1282 if (coreKeyboard) {
1283 freeDevice(servlayoutp->inputs, coreKeyboard);
1284 coreKeyboard = NULL((void*)0);
1285 }
1286 foundKeyboard = TRUE1;
1287 }
1288
1289 /* 2. ServerLayout-specified core keyboard. */
1290 if (coreKeyboard) {
1291 foundKeyboard = TRUE1;
1292 from = X_CONFIG;
1293 }
1294
1295 /* 3. First core keyboard device. */
1296 if (!foundKeyboard && (xf86Info.forceInputDevices || implicitLayout)) {
1297 XF86ConfInputPtr p;
1298
1299 for (p = xf86configptr->conf_input_lst; p; p = p->list.next) {
1300 if (p->inp_option_lst &&
1301 xf86CheckBoolOption(p->inp_option_lst, "CoreKeyboard", FALSE0)) {
1302 confInput = p;
1303 foundKeyboard = TRUE1;
1304 from = X_DEFAULT;
1305 keyboardMsg = "first core keyboard device";
1306 break;
1307 }
1308 }
1309 }
1310
1311 /* 4. First keyboard with 'keyboard' or 'kbd' as the driver. */
1312 if (!foundKeyboard && xf86Info.forceInputDevices) {
1313 confInput = xf86findInput(CONF_IMPLICIT_KEYBOARD"Implicit Core Keyboard",
1314 xf86configptr->conf_input_lst);
1315 if (!confInput) {
1316 confInput = xf86findInputByDriver("kbd",
1317 xf86configptr->conf_input_lst);
1318 }
1319 if (confInput) {
1320 foundKeyboard = TRUE1;
1321 from = X_DEFAULT;
1322 keyboardMsg = "first keyboard device";
1323 }
1324 }
1325
1326 /* 5. Built-in default. */
1327 if (!foundKeyboard && xf86Info.forceInputDevices) {
1328 memset(&defKbd, 0, sizeof(defKbd))__builtin___memset_chk (&defKbd, 0, sizeof(defKbd), __builtin_object_size
(&defKbd, 0))
;
1329 defKbd.inp_identifier = strdup("<default keyboard>");
1330 defKbd.inp_driver = strdup("kbd");
1331 confInput = &defKbd;
1332 foundKeyboard = TRUE1;
1333 keyboardMsg = "default keyboard configuration";
1334 from = X_DEFAULT;
1335 }
1336
1337 /* Add the core keyboard device to the layout, and set it to Core. */
1338 if (foundKeyboard && confInput) {
1339 Keyboard = xf86AllocateInput();
1340 if (Keyboard)
1341 foundKeyboard = configInput(Keyboard, confInput, from);
1342 if (foundKeyboard) {
1343 Keyboard->options = xf86AddNewOption(Keyboard->options,
1344 "CoreKeyboard", "on");
1345 Keyboard->options = xf86AddNewOption(Keyboard->options,
1346 "driver",
1347 confInput->inp_driver);
1348 Keyboard->options =
1349 xf86AddNewOption(Keyboard->options, "identifier",
1350 confInput->inp_identifier);
1351 servlayoutp->inputs = addDevice(servlayoutp->inputs, Keyboard);
1352 }
1353 }
1354
1355 if (!foundKeyboard && xf86Info.forceInputDevices) {
1356 /* This shouldn't happen. */
1357 xf86Msg(X_ERROR, "Cannot locate a core keyboard device.\n");
1358 xf86DeleteInput(Keyboard, 0);
1359 return FALSE0;
1360 }
1361
1362 if (pointerMsg) {
1363 if (implicitLayout)
1364 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1365 pointerMsg);
1366 else
1367 xf86Msg(X_DEFAULT, "The core pointer device wasn't specified "
1368 "explicitly in the layout.\n"
1369 "\tUsing the %s.\n", pointerMsg);
1370 }
1371
1372 if (keyboardMsg) {
1373 if (implicitLayout)
1374 xf86Msg(X_DEFAULT, "No Layout section. Using the %s.\n",
1375 keyboardMsg);
1376 else
1377 xf86Msg(X_DEFAULT, "The core keyboard device wasn't specified "
1378 "explicitly in the layout.\n"
1379 "\tUsing the %s.\n", keyboardMsg);
1380 }
1381
1382 if (!xf86Info.forceInputDevices && !(foundPointer && foundKeyboard)) {
1383#if defined(CONFIG_HAL) || defined(CONFIG_UDEV) || defined(CONFIG_WSCONS)
1384 const char *config_backend;
1385
1386#if defined(CONFIG_HAL)
1387 config_backend = "HAL";
1388#elif defined(CONFIG_UDEV)
1389 config_backend = "udev";
1390#else
1391 config_backend = "wscons";
1392#endif
1393 xf86Msg(X_INFO, "The server relies on %s to provide the list of "
1394 "input devices.\n\tIf no devices become available, "
1395 "reconfigure %s or disable AutoAddDevices.\n",
1396 config_backend, config_backend);
1397#else
1398 xf86Msg(X_WARNING, "Hotplugging requested but the server was "
1399 "compiled without a config backend. "
1400 "No input devices were configured, the server "
1401 "will start without any input devices.\n");
1402#endif
1403 }
1404
1405 return TRUE1;
1406}
1407
1408typedef enum {
1409 LAYOUT_ISOLATEDEVICE,
1410 LAYOUT_SINGLECARD
1411} LayoutValues;
1412
1413static OptionInfoRec LayoutOptions[] = {
1414 {LAYOUT_ISOLATEDEVICE, "IsolateDevice", OPTV_STRING,
1415 {0}, FALSE0},
1416 {LAYOUT_SINGLECARD, "SingleCard", OPTV_BOOLEAN,
1417 {0}, FALSE0},
1418 {-1, NULL((void*)0), OPTV_NONE,
1419 {0}, FALSE0},
1420};
1421
1422static Bool
1423configInputDevices(XF86ConfLayoutPtr layout, serverLayoutPtr servlayoutp)
1424{
1425 XF86ConfInputrefPtr irp;
1426 InputInfoPtr *indp;
1427 int count = 0;
1428
1429 /*
1430 * Count the number of input devices.
1431 */
1432 irp = layout->lay_input_lst;
1433 while (irp) {
1434 count++;
1435 irp = (XF86ConfInputrefPtr) irp->list.next;
1436 }
1437 DebugF("Found %d input devices in the layout section %s\n",
1438 count, layout->lay_identifier);
1439 indp = xnfcalloc((count + 1), sizeof(InputInfoPtr))XNFcallocarray(((count + 1)), (sizeof(InputInfoPtr)));
1440 indp[count] = NULL((void*)0);
1441 irp = layout->lay_input_lst;
1442 count = 0;
1443 while (irp) {
1444 indp[count] = xf86AllocateInput();
1445 if (!configInput(indp[count], irp->iref_inputdev, X_CONFIG)) {
1446 do {
1447 free(indp[count]);
1448 } while (count--);
1449 free(indp);
1450 return FALSE0;
1451 }
1452 indp[count]->options = xf86OptionListMerge(indp[count]->options,
1453 irp->iref_option_lst);
1454 count++;
1455 irp = (XF86ConfInputrefPtr) irp->list.next;
1456 }
1457 servlayoutp->inputs = indp;
1458
1459 return TRUE1;
1460}
1461
1462/*
1463 * figure out which layout is active, which screens are used in that layout,
1464 * which drivers and monitors are used in these screens
1465 */
1466static Bool
1467configLayout(serverLayoutPtr servlayoutp, XF86ConfLayoutPtr conf_layout,
1468 char *default_layout)
1469{
1470 XF86ConfAdjacencyPtr adjp;
1471 XF86ConfInactivePtr idp;
1472 int saved_count, count = 0;
1473 int scrnum;
1474 XF86ConfLayoutPtr l;
1475 MessageType from;
1476 screenLayoutPtr slp;
1477 GDevPtr gdp;
1478 int i = 0, j;
1479
1480 if (!servlayoutp)
1481 return FALSE0;
1482
1483 /*
1484 * which layout section is the active one?
1485 *
1486 * If there is a -layout command line option, use that one, otherwise
1487 * pick the first one.
1488 */
1489 from = X_DEFAULT;
1490 if (xf86LayoutName != NULL((void*)0))
1491 from = X_CMDLINE;
1492 else if (default_layout) {
1493 xf86LayoutName = default_layout;
1494 from = X_CONFIG;
1495 }
1496 if (xf86LayoutName != NULL((void*)0)) {
1497 if ((l = xf86findLayout(xf86LayoutName, conf_layout)) == NULL((void*)0)) {
1498 xf86Msg(X_ERROR, "No ServerLayout section called \"%s\"\n",
1499 xf86LayoutName);
1500 return FALSE0;
1501 }
1502 conf_layout = l;
1503 }
1504 xf86Msg(from, "ServerLayout \"%s\"\n", conf_layout->lay_identifier);
1505 adjp = conf_layout->lay_adjacency_lst;
1506
1507 /*
1508 * we know that each screen is referenced exactly once on the left side
1509 * of a layout statement in the Layout section. So to allocate the right
1510 * size for the array we do a quick walk of the list to figure out how
1511 * many sections we have
1512 */
1513 while (adjp) {
1514 count++;
1515 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1516 }
1517
1518 DebugF("Found %d screens in the layout section %s",
1519 count, conf_layout->lay_identifier);
1520 if (!count) /* alloc enough storage even if no screen is specified */
1521 count = 1;
1522
1523 slp = xnfcalloc((count + 1), sizeof(screenLayoutRec))XNFcallocarray(((count + 1)), (sizeof(screenLayoutRec)));
1524 slp[count].screen = NULL((void*)0);
1525 /*
1526 * now that we have storage, loop over the list again and fill in our
1527 * data structure; at this point we do not fill in the adjacency
1528 * information as it is not clear if we need it at all
1529 */
1530 adjp = conf_layout->lay_adjacency_lst;
1531 count = 0;
1532 while (adjp) {
1533 slp[count].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcallocarray((1), (sizeof(confScreenRec)));
1534 if (adjp->adj_scrnum < 0)
1535 scrnum = count;
1536 else
1537 scrnum = adjp->adj_scrnum;
1538 if (!configScreen(slp[count].screen, adjp->adj_screen, scrnum,
1539 X_CONFIG, (scrnum == 0 && !adjp->list.next))) {
1540 do {
1541 free(slp[count].screen);
1542 } while (count--);
1543 free(slp);
1544 return FALSE0;
1545 }
1546 slp[count].x = adjp->adj_x;
1547 slp[count].y = adjp->adj_y;
1548 slp[count].refname = adjp->adj_refscreen;
1549 switch (adjp->adj_where) {
1550 case CONF_ADJ_OBSOLETE-1:
1551 slp[count].where = PosObsolete;
1552 slp[count].topname = adjp->adj_top_str;
1553 slp[count].bottomname = adjp->adj_bottom_str;
1554 slp[count].leftname = adjp->adj_left_str;
1555 slp[count].rightname = adjp->adj_right_str;
1556 break;
1557 case CONF_ADJ_ABSOLUTE0:
1558 slp[count].where = PosAbsolute;
1559 break;
1560 case CONF_ADJ_RIGHTOF1:
1561 slp[count].where = PosRightOf;
1562 break;
1563 case CONF_ADJ_LEFTOF2:
1564 slp[count].where = PosLeftOf;
1565 break;
1566 case CONF_ADJ_ABOVE3:
1567 slp[count].where = PosAbove;
1568 break;
1569 case CONF_ADJ_BELOW4:
1570 slp[count].where = PosBelow;
1571 break;
1572 case CONF_ADJ_RELATIVE5:
1573 slp[count].where = PosRelative;
1574 break;
1575 }
1576 count++;
1577 adjp = (XF86ConfAdjacencyPtr) adjp->list.next;
1578 }
1579
1580 /* No screen was specified in the layout. take the first one from the
1581 * config file, or - if it is NULL - configScreen autogenerates one for
1582 * us */
1583 if (!count) {
1584 XF86ConfScreenPtr screen;
1585
1586 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen)do { XF86ConfScreenPtr _l, _p; for (_l = (xf86configptr->conf_screen_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfScreenPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(screen) = _p; } while(0)
;
1587 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcallocarray((1), (sizeof(confScreenRec)));
1588 if (!configScreen(slp[0].screen, screen,
1589 0, X_CONFIG, TRUE1)) {
1590 free(slp[0].screen);
1591 free(slp);
1592 return FALSE0;
1593 }
1594 }
1595
1596 /* XXX Need to tie down the upper left screen. */
1597
1598 /* Fill in the refscreen and top/bottom/left/right values */
1599 for (i = 0; i < count; i++) {
1600 for (j = 0; j < count; j++) {
1601 if (slp[i].refname &&
1602 strcmp(slp[i].refname, slp[j].screen->id) == 0) {
1603 slp[i].refscreen = slp[j].screen;
1604 }
1605 if (slp[i].topname &&
1606 strcmp(slp[i].topname, slp[j].screen->id) == 0) {
1607 slp[i].top = slp[j].screen;
1608 }
1609 if (slp[i].bottomname &&
1610 strcmp(slp[i].bottomname, slp[j].screen->id) == 0) {
1611 slp[i].bottom = slp[j].screen;
1612 }
1613 if (slp[i].leftname &&
1614 strcmp(slp[i].leftname, slp[j].screen->id) == 0) {
1615 slp[i].left = slp[j].screen;
1616 }
1617 if (slp[i].rightname &&
1618 strcmp(slp[i].rightname, slp[j].screen->id) == 0) {
1619 slp[i].right = slp[j].screen;
1620 }
1621 }
1622 if (slp[i].where != PosObsolete
1623 && slp[i].where != PosAbsolute && !slp[i].refscreen) {
1624 xf86Msg(X_ERROR, "Screen %s doesn't exist: deleting placement\n",
1625 slp[i].refname);
1626 slp[i].where = PosAbsolute;
1627 slp[i].x = 0;
1628 slp[i].y = 0;
1629 }
1630 }
1631
1632 if (!count)
1633 saved_count = 1;
1634 else
1635 saved_count = count;
1636 /*
1637 * Count the number of inactive devices.
1638 */
1639 count = 0;
1640 idp = conf_layout->lay_inactive_lst;
1641 while (idp) {
1642 count++;
1643 idp = (XF86ConfInactivePtr) idp->list.next;
1644 }
1645 DebugF("Found %d inactive devices in the layout section %s\n",
1646 count, conf_layout->lay_identifier);
1647 gdp = xnfallocarray(count + 1, sizeof(GDevRec))XNFreallocarray(((void*)0), (count + 1), (sizeof(GDevRec)));
1648 gdp[count].identifier = NULL((void*)0);
1649 idp = conf_layout->lay_inactive_lst;
1650 count = 0;
1651 while (idp) {
1652 if (!configDevice(&gdp[count], idp->inactive_device, FALSE0, FALSE0))
1653 goto bail;
1654 count++;
1655 idp = (XF86ConfInactivePtr) idp->list.next;
1656 }
1657
1658 if (!configInputDevices(conf_layout, servlayoutp))
1659 goto bail;
1660
1661 servlayoutp->id = conf_layout->lay_identifier;
1662 servlayoutp->screens = slp;
1663 servlayoutp->inactives = gdp;
1664 servlayoutp->options = conf_layout->lay_option_lst;
1665 from = X_DEFAULT;
1666
1667 return TRUE1;
1668
1669 bail:
1670 do {
1671 free(slp[saved_count].screen);
1672 } while (saved_count--);
1673 free(slp);
1674 free(gdp);
1675 return FALSE0;
1676}
1677
1678/*
1679 * No layout section, so find the first Screen section and set that up as
1680 * the only active screen.
1681 */
1682static Bool
1683configImpliedLayout(serverLayoutPtr servlayoutp, XF86ConfScreenPtr conf_screen,
1684 XF86ConfigPtr conf_ptr)
1685{
1686 MessageType from;
1687 XF86ConfScreenPtr s;
1688 screenLayoutPtr slp;
1689 InputInfoPtr *indp;
1690 XF86ConfLayoutRec layout;
1691
1692 if (!servlayoutp)
1693 return FALSE0;
1694
1695 /*
1696 * which screen section is the active one?
1697 *
1698 * If there is a -screen option, use that one, otherwise use the first
1699 * one.
1700 */
1701
1702 from = X_CONFIG;
1703 if (xf86ScreenName != NULL((void*)0)) {
1704 if ((s = xf86findScreen(xf86ScreenName, conf_screen)) == NULL((void*)0)) {
1705 xf86Msg(X_ERROR, "No Screen section called \"%s\"\n",
1706 xf86ScreenName);
1707 return FALSE0;
1708 }
1709 conf_screen = s;
1710 from = X_CMDLINE;
1711 }
1712
1713 /* We have exactly one screen */
1714
1715 slp = xnfcalloc(1, 2 * sizeof(screenLayoutRec))XNFcallocarray((1), (2 * sizeof(screenLayoutRec)));
1716 slp[0].screen = xnfcalloc(1, sizeof(confScreenRec))XNFcallocarray((1), (sizeof(confScreenRec)));
1717 slp[1].screen = NULL((void*)0);
1718 if (!configScreen(slp[0].screen, conf_screen, 0, from, TRUE1)) {
1719 free(slp);
1720 return FALSE0;
1721 }
1722 servlayoutp->id = "(implicit)";
1723 servlayoutp->screens = slp;
1724 servlayoutp->inactives = xnfcalloc(1, sizeof(GDevRec))XNFcallocarray((1), (sizeof(GDevRec)));
1725 servlayoutp->options = NULL((void*)0);
1726
1727 memset(&layout, 0, sizeof(layout))__builtin___memset_chk (&layout, 0, sizeof(layout), __builtin_object_size
(&layout, 0))
;
1728 layout.lay_identifier = servlayoutp->id;
1729 if (xf86layoutAddInputDevices(conf_ptr, &layout) > 0) {
1730 if (!configInputDevices(&layout, servlayoutp))
1731 return FALSE0;
1732 from = X_DEFAULT;
Value stored to 'from' is never read
1733 }
1734 else {
1735 /* Set up an empty input device list, then look for some core devices. */
1736 indp = xnfalloc(sizeof(InputInfoPtr))XNFalloc((unsigned long)(sizeof(InputInfoPtr)));
1737 *indp = NULL((void*)0);
1738 servlayoutp->inputs = indp;
1739 }
1740
1741 return TRUE1;
1742}
1743
1744static Bool
1745configXvAdaptor(confXvAdaptorPtr adaptor, XF86ConfVideoAdaptorPtr conf_adaptor)
1746{
1747 int count = 0;
1748 XF86ConfVideoPortPtr conf_port;
1749
1750 xf86Msg(X_CONFIG, "| |-->VideoAdaptor \"%s\"\n",
1751 conf_adaptor->va_identifier);
1752 adaptor->identifier = conf_adaptor->va_identifier;
1753 adaptor->options = conf_adaptor->va_option_lst;
1754 if (conf_adaptor->va_busid || conf_adaptor->va_driver) {
1755 xf86Msg(X_CONFIG, "| | Unsupported device type, skipping entry\n");
1756 return FALSE0;
1757 }
1758
1759 /*
1760 * figure out how many videoport subsections there are and fill them in
1761 */
1762 conf_port = conf_adaptor->va_port_lst;
1763 while (conf_port) {
1764 count++;
1765 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1766 }
1767 adaptor->ports = xnfallocarray(count, sizeof(confXvPortRec))XNFreallocarray(((void*)0), (count), (sizeof(confXvPortRec)));
1768 adaptor->numports = count;
1769 count = 0;
1770 conf_port = conf_adaptor->va_port_lst;
1771 while (conf_port) {
1772 adaptor->ports[count].identifier = conf_port->vp_identifier;
1773 adaptor->ports[count].options = conf_port->vp_option_lst;
1774 count++;
1775 conf_port = (XF86ConfVideoPortPtr) conf_port->list.next;
1776 }
1777
1778 return TRUE1;
1779}
1780
1781static Bool
1782configScreen(confScreenPtr screenp, XF86ConfScreenPtr conf_screen, int scrnum,
1783 MessageType from, Bool auto_gpu_device)
1784{
1785 int count = 0;
1786 XF86ConfDisplayPtr dispptr;
1787 XF86ConfAdaptorLinkPtr conf_adaptor;
1788 Bool defaultMonitor = FALSE0;
1789 XF86ConfScreenRec local_conf_screen;
1790 int i;
1791
1792 if (!conf_screen) {
1793 memset(&local_conf_screen, 0, sizeof(local_conf_screen))__builtin___memset_chk (&local_conf_screen, 0, sizeof(local_conf_screen
), __builtin_object_size (&local_conf_screen, 0))
;
1794 conf_screen = &local_conf_screen;
1795 conf_screen->scrn_identifier = "Default Screen Section";
1796 xf86Msg(X_DEFAULT, "No screen section available. Using defaults.\n");
1797 }
1798
1799 xf86Msg(from, "|-->Screen \"%s\" (%d)\n", conf_screen->scrn_identifier,
1800 scrnum);
1801 /*
1802 * now we fill in the elements of the screen
1803 */
1804 screenp->id = conf_screen->scrn_identifier;
1805 screenp->screennum = scrnum;
1806 screenp->defaultdepth = conf_screen->scrn_defaultdepth;
1807 screenp->defaultbpp = conf_screen->scrn_defaultbpp;
1808 screenp->defaultfbbpp = conf_screen->scrn_defaultfbbpp;
1809 screenp->monitor = xnfcalloc(1, sizeof(MonRec))XNFcallocarray((1), (sizeof(MonRec)));
1810 /* If no monitor is specified, create a default one. */
1811 if (!conf_screen->scrn_monitor) {
1812 XF86ConfMonitorRec defMon;
1813
1814 memset(&defMon, 0, sizeof(defMon))__builtin___memset_chk (&defMon, 0, sizeof(defMon), __builtin_object_size
(&defMon, 0))
;
1815 defMon.mon_identifier = "<default monitor>";
1816 if (!configMonitor(screenp->monitor, &defMon))
1817 return FALSE0;
1818 defaultMonitor = TRUE1;
1819 }
1820 else {
1821 if (!configMonitor(screenp->monitor, conf_screen->scrn_monitor))
1822 return FALSE0;
1823 }
1824 /* Configure the device. If there isn't one configured, attach to the
1825 * first inactive one that we can configure. If there's none that work,
1826 * set it to NULL so that the section can be autoconfigured later */
1827 screenp->device = xnfcalloc(1, sizeof(GDevRec))XNFcallocarray((1), (sizeof(GDevRec)));
1828 if ((!conf_screen->scrn_device) && (xf86configptr->conf_device_lst)) {
1829 FIND_SUITABLE (XF86ConfDevicePtr, xf86configptr->conf_device_lst, conf_screen->scrn_device)do { XF86ConfDevicePtr _l, _p; for (_l = (xf86configptr->conf_device_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfDevicePtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(conf_screen->scrn_device) = _p; } while(0)
;
1830 xf86Msg(X_DEFAULT, "No device specified for screen \"%s\".\n"
1831 "\tUsing the first device section listed.\n", screenp->id);
1832 }
1833 if (configDevice(screenp->device, conf_screen->scrn_device, TRUE1, FALSE0)) {
1834 screenp->device->myScreenSection = screenp;
1835 }
1836 else {
1837 screenp->device = NULL((void*)0);
1838 }
1839
1840 if (auto_gpu_device && conf_screen->num_gpu_devices == 0 &&
1841 xf86configptr->conf_device_lst) {
1842 XF86ConfDevicePtr sdevice = xf86configptr->conf_device_lst->list.next;
1843
1844 for (i = 0; i < MAX_GPUDEVICES4; i++) {
1845 if (!sdevice)
1846 break;
1847
1848 FIND_SUITABLE (XF86ConfDevicePtr, sdevice, conf_screen->scrn_gpu_devices[i])do { XF86ConfDevicePtr _l, _p; for (_l = (sdevice), _p = ((void
*)0); !_p && _l; _l = (XF86ConfDevicePtr)_l->list.
next) { if (!_l->match_seat || (SeatId && xf86nameCompare
(_l->match_seat, SeatId) == 0)) _p = _l; } (conf_screen->
scrn_gpu_devices[i]) = _p; } while(0)
;
1849 if (!conf_screen->scrn_gpu_devices[i])
1850 break;
1851 screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec))XNFcallocarray((1), (sizeof(GDevRec)));
1852 if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE1, TRUE1)) {
1853 screenp->gpu_devices[i]->myScreenSection = screenp;
1854 }
1855 sdevice = conf_screen->scrn_gpu_devices[i]->list.next;
1856 }
1857 screenp->num_gpu_devices = i;
1858
1859 } else {
1860 for (i = 0; i < conf_screen->num_gpu_devices; i++) {
1861 screenp->gpu_devices[i] = xnfcalloc(1, sizeof(GDevRec))XNFcallocarray((1), (sizeof(GDevRec)));
1862 if (configDevice(screenp->gpu_devices[i], conf_screen->scrn_gpu_devices[i], TRUE1, TRUE1)) {
1863 screenp->gpu_devices[i]->myScreenSection = screenp;
1864 }
1865 }
1866 screenp->num_gpu_devices = conf_screen->num_gpu_devices;
1867 }
1868
1869 screenp->options = conf_screen->scrn_option_lst;
1870
1871 /*
1872 * figure out how many display subsections there are and fill them in
1873 */
1874 dispptr = conf_screen->scrn_display_lst;
1875 while (dispptr) {
1876 count++;
1877 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1878 }
1879 screenp->displays = xnfallocarray(count, sizeof(DispRec))XNFreallocarray(((void*)0), (count), (sizeof(DispRec)));
1880 screenp->numdisplays = count;
1881
1882 /* Fill in the default Virtual size, if any */
1883 if (conf_screen->scrn_virtualX && conf_screen->scrn_virtualY) {
1884 for (count = 0, dispptr = conf_screen->scrn_display_lst;
1885 dispptr;
1886 dispptr = (XF86ConfDisplayPtr) dispptr->list.next, count++) {
1887 screenp->displays[count].virtualX = conf_screen->scrn_virtualX;
1888 screenp->displays[count].virtualY = conf_screen->scrn_virtualY;
1889 }
1890 }
1891
1892 /* Now do the per-Display Virtual sizes */
1893 count = 0;
1894 dispptr = conf_screen->scrn_display_lst;
1895 while (dispptr) {
1896 configDisplay(&(screenp->displays[count]), dispptr);
1897 count++;
1898 dispptr = (XF86ConfDisplayPtr) dispptr->list.next;
1899 }
1900
1901 /*
1902 * figure out how many videoadaptor references there are and fill them in
1903 */
1904 conf_adaptor = conf_screen->scrn_adaptor_lst;
1905 while (conf_adaptor) {
1906 count++;
1907 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1908 }
1909 screenp->xvadaptors = xnfallocarray(count, sizeof(confXvAdaptorRec))XNFreallocarray(((void*)0), (count), (sizeof(confXvAdaptorRec
)))
;
1910 screenp->numxvadaptors = 0;
1911 conf_adaptor = conf_screen->scrn_adaptor_lst;
1912 while (conf_adaptor) {
1913 if (configXvAdaptor(&(screenp->xvadaptors[screenp->numxvadaptors]),
1914 conf_adaptor->al_adaptor))
1915 screenp->numxvadaptors++;
1916 conf_adaptor = (XF86ConfAdaptorLinkPtr) conf_adaptor->list.next;
1917 }
1918
1919 if (defaultMonitor) {
1920 xf86Msg(X_DEFAULT, "No monitor specified for screen \"%s\".\n"
1921 "\tUsing a default monitor configuration.\n", screenp->id);
1922 }
1923 return TRUE1;
1924}
1925
1926typedef enum {
1927 MON_REDUCEDBLANKING,
1928 MON_MAX_PIX_CLOCK,
1929} MonitorValues;
1930
1931static OptionInfoRec MonitorOptions[] = {
1932 {MON_REDUCEDBLANKING, "ReducedBlanking", OPTV_BOOLEAN,
1933 {0}, FALSE0},
1934 {MON_MAX_PIX_CLOCK, "MaxPixClock", OPTV_FREQ,
1935 {0}, FALSE0},
1936 {-1, NULL((void*)0), OPTV_NONE,
1937 {0}, FALSE0},
1938};
1939
1940static Bool
1941configMonitor(MonPtr monitorp, XF86ConfMonitorPtr conf_monitor)
1942{
1943 int count;
1944 DisplayModePtr mode, last = NULL((void*)0);
1945 XF86ConfModeLinePtr cmodep;
1946 XF86ConfModesPtr modes;
1947 XF86ConfModesLinkPtr modeslnk = conf_monitor->mon_modes_sect_lst;
1948 Gamma zeros = { 0.0, 0.0, 0.0 };
1949 float badgamma = 0.0;
1950 double maxPixClock;
1951
1952 xf86Msg(X_CONFIG, "| |-->Monitor \"%s\"\n", conf_monitor->mon_identifier);
1953 monitorp->id = conf_monitor->mon_identifier;
1954 monitorp->vendor = conf_monitor->mon_vendor;
1955 monitorp->model = conf_monitor->mon_modelname;
1956 monitorp->Modes = NULL((void*)0);
1957 monitorp->Last = NULL((void*)0);
1958 monitorp->gamma = zeros;
1959 monitorp->widthmm = conf_monitor->mon_width;
1960 monitorp->heightmm = conf_monitor->mon_height;
1961 monitorp->reducedblanking = FALSE0;
1962 monitorp->maxPixClock = 0;
1963 monitorp->options = conf_monitor->mon_option_lst;
1964
1965 /*
1966 * fill in the monitor structure
1967 */
1968 for (count = 0;
1969 count < conf_monitor->mon_n_hsync && count < MAX_HSYNC8; count++) {
1970 monitorp->hsync[count].hi = conf_monitor->mon_hsync[count].hi;
1971 monitorp->hsync[count].lo = conf_monitor->mon_hsync[count].lo;
1972 }
1973 monitorp->nHsync = count;
1974 for (count = 0;
1975 count < conf_monitor->mon_n_vrefresh && count < MAX_VREFRESH8;
1976 count++) {
1977 monitorp->vrefresh[count].hi = conf_monitor->mon_vrefresh[count].hi;
1978 monitorp->vrefresh[count].lo = conf_monitor->mon_vrefresh[count].lo;
1979 }
1980 monitorp->nVrefresh = count;
1981
1982 /*
1983 * first we collect the mode lines from the UseModes directive
1984 */
1985 while (modeslnk) {
1986 modes = xf86findModes(modeslnk->ml_modes_str,
1987 xf86configptr->conf_modes_lst);
1988 modeslnk->ml_modes = modes;
1989
1990 /* now add the modes found in the modes
1991 section to the list of modes for this
1992 monitor unless it has been added before
1993 because we are reusing the same section
1994 for another screen */
1995 if (xf86itemNotSublist((GenericListPtr) conf_monitor->mon_modeline_lst,
1996 (GenericListPtr) modes->mon_modeline_lst)) {
1997 conf_monitor->mon_modeline_lst = (XF86ConfModeLinePtr)
1998 xf86addListItem((GenericListPtr) conf_monitor->mon_modeline_lst,
1999 (GenericListPtr) modes->mon_modeline_lst);
2000 }
2001 modeslnk = modeslnk->list.next;
2002 }
2003
2004 /*
2005 * we need to hook in the mode lines now
2006 * here both data structures use lists, only our internal one
2007 * is double linked
2008 */
2009 cmodep = conf_monitor->mon_modeline_lst;
2010 while (cmodep) {
2011 mode = xnfcalloc(1, sizeof(DisplayModeRec))XNFcallocarray((1), (sizeof(DisplayModeRec)));
2012 mode->type = 0;
2013 mode->Clock = cmodep->ml_clock;
2014 mode->HDisplay = cmodep->ml_hdisplay;
2015 mode->HSyncStart = cmodep->ml_hsyncstart;
2016 mode->HSyncEnd = cmodep->ml_hsyncend;
2017 mode->HTotal = cmodep->ml_htotal;
2018 mode->VDisplay = cmodep->ml_vdisplay;
2019 mode->VSyncStart = cmodep->ml_vsyncstart;
2020 mode->VSyncEnd = cmodep->ml_vsyncend;
2021 mode->VTotal = cmodep->ml_vtotal;
2022 mode->Flags = cmodep->ml_flags;
2023 mode->HSkew = cmodep->ml_hskew;
2024 mode->VScan = cmodep->ml_vscan;
2025 mode->name = xnfstrdup(cmodep->ml_identifier)XNFstrdup(cmodep->ml_identifier);
2026 if (last) {
2027 mode->prev = last;
2028 last->next = mode;
2029 }
2030 else {
2031 /*
2032 * this is the first mode
2033 */
2034 monitorp->Modes = mode;
2035 mode->prev = NULL((void*)0);
2036 }
2037 last = mode;
2038 cmodep = (XF86ConfModeLinePtr) cmodep->list.next;
2039 }
2040 if (last) {
2041 last->next = NULL((void*)0);
2042 }
2043 monitorp->Last = last;
2044
2045 /* add the (VESA) default modes */
2046 if (!addDefaultModes(monitorp))
2047 return FALSE0;
2048
2049 if (conf_monitor->mon_gamma_red > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2050 monitorp->gamma.red = conf_monitor->mon_gamma_red;
2051 if (conf_monitor->mon_gamma_green > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2052 monitorp->gamma.green = conf_monitor->mon_gamma_green;
2053 if (conf_monitor->mon_gamma_blue > GAMMA_ZERO((1.0 / 10.0) / 100.0))
2054 monitorp->gamma.blue = conf_monitor->mon_gamma_blue;
2055
2056 /* Check that the gamma values are within range */
2057 if (monitorp->gamma.red > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2058 (monitorp->gamma.red < GAMMA_MIN(1.0 / 10.0) || monitorp->gamma.red > GAMMA_MAX10.0)) {
2059 badgamma = monitorp->gamma.red;
2060 }
2061 else if (monitorp->gamma.green > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2062 (monitorp->gamma.green < GAMMA_MIN(1.0 / 10.0) ||
2063 monitorp->gamma.green > GAMMA_MAX10.0)) {
2064 badgamma = monitorp->gamma.green;
2065 }
2066 else if (monitorp->gamma.blue > GAMMA_ZERO((1.0 / 10.0) / 100.0) &&
2067 (monitorp->gamma.blue < GAMMA_MIN(1.0 / 10.0) ||
2068 monitorp->gamma.blue > GAMMA_MAX10.0)) {
2069 badgamma = monitorp->gamma.blue;
2070 }
2071 if (badgamma > GAMMA_ZERO((1.0 / 10.0) / 100.0)) {
2072 ErrorF("Gamma value %.f is out of range (%.2f - %.1f)\n", badgamma,
2073 GAMMA_MIN(1.0 / 10.0), GAMMA_MAX10.0);
2074 return FALSE0;
2075 }
2076
2077 xf86ProcessOptions(-1, monitorp->options, MonitorOptions);
2078 xf86GetOptValBool(MonitorOptions, MON_REDUCEDBLANKING,
2079 &monitorp->reducedblanking);
2080 if (xf86GetOptValFreq(MonitorOptions, MON_MAX_PIX_CLOCK, OPTUNITS_KHZ,
2081 &maxPixClock) == TRUE1) {
2082 monitorp->maxPixClock = (int) maxPixClock;
2083 }
2084
2085 return TRUE1;
2086}
2087
2088static int
2089lookupVisual(const char *visname)
2090{
2091 int i;
2092
2093 if (!visname || !*visname)
2094 return -1;
2095
2096 for (i = 0; i <= DirectColor5; i++) {
2097 if (!xf86nameCompare(visname, xf86VisualNames[i]))
2098 break;
2099 }
2100
2101 if (i <= DirectColor5)
2102 return i;
2103
2104 return -1;
2105}
2106
2107static Bool
2108configDisplay(DispPtr displayp, XF86ConfDisplayPtr conf_display)
2109{
2110 int count = 0;
2111 XF86ModePtr modep;
2112
2113 displayp->frameX0 = conf_display->disp_frameX0;
2114 displayp->frameY0 = conf_display->disp_frameY0;
2115 displayp->virtualX = conf_display->disp_virtualX;
2116 displayp->virtualY = conf_display->disp_virtualY;
2117 displayp->depth = conf_display->disp_depth;
2118 displayp->fbbpp = conf_display->disp_bpp;
2119 displayp->weight.red = conf_display->disp_weight.red;
2120 displayp->weight.green = conf_display->disp_weight.green;
2121 displayp->weight.blue = conf_display->disp_weight.blue;
2122 displayp->blackColour.red = conf_display->disp_black.red;
2123 displayp->blackColour.green = conf_display->disp_black.green;
2124 displayp->blackColour.blue = conf_display->disp_black.blue;
2125 displayp->whiteColour.red = conf_display->disp_white.red;
2126 displayp->whiteColour.green = conf_display->disp_white.green;
2127 displayp->whiteColour.blue = conf_display->disp_white.blue;
2128 displayp->options = conf_display->disp_option_lst;
2129 if (conf_display->disp_visual) {
2130 displayp->defaultVisual = lookupVisual(conf_display->disp_visual);
2131 if (displayp->defaultVisual == -1) {
2132 ErrorF("Invalid visual name: \"%s\"\n", conf_display->disp_visual);
2133 return FALSE0;
2134 }
2135 }
2136 else {
2137 displayp->defaultVisual = -1;
2138 }
2139
2140 /*
2141 * now hook in the modes
2142 */
2143 modep = conf_display->disp_mode_lst;
2144 while (modep) {
2145 count++;
2146 modep = (XF86ModePtr) modep->list.next;
2147 }
2148 displayp->modes = xnfallocarray(count + 1, sizeof(char *))XNFreallocarray(((void*)0), (count + 1), (sizeof(char *)));
2149 modep = conf_display->disp_mode_lst;
2150 count = 0;
2151 while (modep) {
2152 displayp->modes[count] = modep->mode_name;
2153 count++;
2154 modep = (XF86ModePtr) modep->list.next;
2155 }
2156 displayp->modes[count] = NULL((void*)0);
2157
2158 return TRUE1;
2159}
2160
2161static Bool
2162configDevice(GDevPtr devicep, XF86ConfDevicePtr conf_device, Bool active, Bool gpu)
2163{
2164 int i;
2165
2166 if (!conf_device) {
2167 return FALSE0;
2168 }
2169
2170 if (active) {
2171 if (gpu)
2172 xf86Msg(X_CONFIG, "| |-->GPUDevice \"%s\"\n",
2173 conf_device->dev_identifier);
2174 else
2175 xf86Msg(X_CONFIG, "| |-->Device \"%s\"\n",
2176 conf_device->dev_identifier);
2177 } else
2178 xf86Msg(X_CONFIG, "|-->Inactive Device \"%s\"\n",
2179 conf_device->dev_identifier);
2180
2181 devicep->identifier = conf_device->dev_identifier;
2182 devicep->vendor = conf_device->dev_vendor;
2183 devicep->board = conf_device->dev_board;
2184 devicep->chipset = conf_device->dev_chipset;
2185 devicep->ramdac = conf_device->dev_ramdac;
2186 devicep->driver = conf_device->dev_driver;
2187 devicep->active = active;
2188 devicep->videoRam = conf_device->dev_videoram;
2189 devicep->BiosBase = conf_device->dev_bios_base;
2190 devicep->MemBase = conf_device->dev_mem_base;
2191 devicep->IOBase = conf_device->dev_io_base;
2192 devicep->clockchip = conf_device->dev_clockchip;
2193 devicep->busID = conf_device->dev_busid;
2194 devicep->chipID = conf_device->dev_chipid;
2195 devicep->chipRev = conf_device->dev_chiprev;
2196 devicep->options = conf_device->dev_option_lst;
2197 devicep->irq = conf_device->dev_irq;
2198 devicep->screen = conf_device->dev_screen;
2199
2200 for (i = 0; i < MAXDACSPEEDS; i++) {
2201 if (i < CONF_MAXDACSPEEDS4)
2202 devicep->dacSpeeds[i] = conf_device->dev_dacSpeeds[i];
2203 else
2204 devicep->dacSpeeds[i] = 0;
2205 }
2206 devicep->numclocks = conf_device->dev_clocks;
2207 if (devicep->numclocks > MAXCLOCKS128)
2208 devicep->numclocks = MAXCLOCKS128;
2209 for (i = 0; i < devicep->numclocks; i++) {
2210 devicep->clock[i] = conf_device->dev_clock[i];
2211 }
2212 devicep->claimed = FALSE0;
2213
2214 return TRUE1;
2215}
2216
2217static void
2218configDRI(XF86ConfDRIPtr drip)
2219{
2220 struct group *grp;
2221
2222 xf86ConfigDRI.group = -1;
2223 xf86ConfigDRI.mode = 0;
2224
2225 if (drip) {
2226 if (drip->dri_group_name) {
2227 if ((grp = getgrnam(drip->dri_group_name)))
2228 xf86ConfigDRI.group = grp->gr_gid;
2229 }
2230 else {
2231 if (drip->dri_group >= 0)
2232 xf86ConfigDRI.group = drip->dri_group;
2233 }
2234 xf86ConfigDRI.mode = drip->dri_mode;
2235 }
2236}
2237
2238static void
2239configExtensions(XF86ConfExtensionsPtr conf_ext)
2240{
2241 XF86OptionPtr o;
2242
2243 if (conf_ext && conf_ext->ext_option_lst) {
2244 for (o = conf_ext->ext_option_lst; o; o = xf86NextOption(o)) {
2245 char *name = xf86OptionName(o);
2246 char *val = xf86OptionValue(o);
2247 char *n;
2248 Bool enable = TRUE1;
2249
2250 /* Handle "No<ExtensionName>" */
2251 n = xf86NormalizeName(name);
2252 if (strncmp(n, "no", 2) == 0) {
2253 name += 2;
2254 enable = FALSE0;
2255 }
2256
2257 if (!val ||
2258 xf86NameCmp(val, "enable") == 0 ||
2259 xf86NameCmp(val, "enabled") == 0 ||
2260 xf86NameCmp(val, "on") == 0 ||
2261 xf86NameCmp(val, "1") == 0 ||
2262 xf86NameCmp(val, "yes") == 0 || xf86NameCmp(val, "true") == 0) {
2263 /* NOTHING NEEDED -- enabling is handled below */
2264 }
2265 else if (xf86NameCmp(val, "disable") == 0 ||
2266 xf86NameCmp(val, "disabled") == 0 ||
2267 xf86NameCmp(val, "off") == 0 ||
2268 xf86NameCmp(val, "0") == 0 ||
2269 xf86NameCmp(val, "no") == 0 ||
2270 xf86NameCmp(val, "false") == 0) {
2271 enable = !enable;
2272 }
2273 else {
2274 xf86Msg(X_WARNING, "Ignoring unrecognized value \"%s\"\n", val);
2275 free(n);
2276 continue;
2277 }
2278
2279 if (EnableDisableExtension(name, enable)) {
2280 xf86Msg(X_CONFIG, "Extension \"%s\" is %s\n",
2281 name, enable ? "enabled" : "disabled");
2282 }
2283 else {
2284 xf86Msg(X_WARNING, "Ignoring unrecognized extension \"%s\"\n",
2285 name);
2286 }
2287 free(n);
2288 }
2289 }
2290}
2291
2292static Bool
2293configInput(InputInfoPtr inputp, XF86ConfInputPtr conf_input, MessageType from)
2294{
2295 xf86Msg(from, "|-->Input Device \"%s\"\n", conf_input->inp_identifier);
2296 inputp->name = conf_input->inp_identifier;
2297 inputp->driver = conf_input->inp_driver;
2298 inputp->options = conf_input->inp_option_lst;
2299 inputp->attrs = NULL((void*)0);
2300
2301 return TRUE1;
2302}
2303
2304static Bool
2305modeIsPresent(DisplayModePtr mode, MonPtr monitorp)
2306{
2307 DisplayModePtr knownmodes = monitorp->Modes;
2308
2309 /* all I can think of is a linear search... */
2310 while (knownmodes != NULL((void*)0)) {
2311 if (!strcmp(mode->name, knownmodes->name) &&
2312 !(knownmodes->type & M_T_DEFAULT0x10))
2313 return TRUE1;
2314 knownmodes = knownmodes->next;
2315 }
2316 return FALSE0;
2317}
2318
2319static Bool
2320addDefaultModes(MonPtr monitorp)
2321{
2322 DisplayModePtr mode;
2323 DisplayModePtr last = monitorp->Last;
2324 int i = 0;
2325
2326 for (i = 0; i < xf86NumDefaultModes; i++) {
2327 mode = xf86DuplicateMode(&xf86DefaultModes[i]);
2328 if (!modeIsPresent(mode, monitorp)) {
2329 monitorp->Modes = xf86ModesAdd(monitorp->Modes, mode);
2330 last = mode;
2331 }
2332 else {
2333 free(mode);
2334 }
2335 }
2336 monitorp->Last = last;
2337
2338 return TRUE1;
2339}
2340
2341static void
2342checkInput(serverLayoutPtr layout, Bool implicit_layout)
2343{
2344 checkCoreInputDevices(layout, implicit_layout);
2345
2346 /* Unless we're forcing input devices, disable mouse/kbd devices in the
2347 * config. Otherwise the same physical device is added multiple times,
2348 * leading to duplicate events.
2349 */
2350 if (!xf86Info.forceInputDevices && layout->inputs) {
2351 InputInfoPtr *dev = layout->inputs;
2352 BOOL warned = FALSE0;
2353
2354 while (*dev) {
2355 if (strcmp((*dev)->driver, "kbd") == 0 ||
2356 strcmp((*dev)->driver, "mouse") == 0 ||
2357 strcmp((*dev)->driver, "vmmouse") == 0) {
2358 InputInfoPtr *current;
2359
2360 if (!warned) {
2361 xf86Msg(X_WARNING, "Hotplugging is on, devices using "
2362 "drivers 'kbd', 'mouse' or 'vmmouse' will be disabled.\n");
2363 warned = TRUE1;
2364 }
2365
2366 xf86Msg(X_WARNING, "Disabling %s\n", (*dev)->name);
2367
2368 current = dev;
2369 free(*dev);
2370 *dev = NULL((void*)0);
2371
2372 do {
2373 *current = *(current + 1);
2374 current++;
2375 } while (*current);
2376 }
2377 else
2378 dev++;
2379 }
2380 }
2381}
2382
2383/*
2384 * load the config file and fill the global data structure
2385 */
2386ConfigStatus
2387xf86HandleConfigFile(Bool autoconfig)
2388{
2389 const char *scanptr;
2390 Bool singlecard = 0;
2391 Bool implicit_layout = FALSE0;
2392 XF86ConfLayoutPtr layout;
2393
2394 if (!autoconfig) {
2395 char *filename, *dirname, *sysdirname;
2396 const char *filesearch, *dirsearch;
2397 MessageType filefrom = X_DEFAULT;
2398 MessageType dirfrom = X_DEFAULT;
2399
2400 if (!xf86PrivsElevated()) {
2401 filesearch = ALL_CONFIGPATH"%A," "%R," "/etc/X11/%R," "%P/etc/X11/%R," "%E," "%F," "/etc/X11/%F,"
"%P/etc/X11/%F," "/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H,"
"%P/etc/X11/%X," "%P/lib/X11/%X.%H," "%P/lib/X11/%X"
;
2402 dirsearch = ALL_CONFIGDIRPATH"%A," "%R," "/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X";
2403 }
2404 else {
2405 filesearch = RESTRICTED_CONFIGPATH"/etc/X11/%S," "%P/etc/X11/%S," "/etc/X11/%G," "%P/etc/X11/%G,"
"/etc/X11/%X," "/etc/%X," "%P/etc/X11/%X.%H," "%P/etc/X11/%X,"
"%P/lib/X11/%X.%H," "%P/lib/X11/%X"
;
2406 dirsearch = RESTRICTED_CONFIGDIRPATH"/etc/X11/%R," "%C/X11/%R," "/etc/X11/%X," "%C/X11/%X";
2407 }
2408
2409 if (xf86ConfigFile)
2410 filefrom = X_CMDLINE;
2411 if (xf86ConfigDir)
2412 dirfrom = X_CMDLINE;
2413
2414 xf86initConfigFiles();
2415 sysdirname = xf86openConfigDirFiles(SYS_CONFIGDIRPATH"%D/X11/%X", NULL((void*)0),
2416 PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2417 dirname = xf86openConfigDirFiles(dirsearch, xf86ConfigDir, PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2418 filename = xf86openConfigFile(filesearch, xf86ConfigFile, PROJECTROOT"/Users/jeremy/src/freedesktop/jhbuild/build");
2419 if (filename) {
2420 xf86MsgVerb(filefrom, 0, "Using config file: \"%s\"\n", filename);
2421 xf86ConfigFile = xnfstrdup(filename)XNFstrdup(filename);
2422 }
2423 else {
2424 if (xf86ConfigFile)
2425 xf86Msg(X_ERROR, "Unable to locate/open config file: \"%s\"\n",
2426 xf86ConfigFile);
2427 }
2428 if (dirname) {
2429 xf86MsgVerb(dirfrom, 0, "Using config directory: \"%s\"\n",
2430 dirname);
2431 xf86ConfigDir = xnfstrdup(dirname)XNFstrdup(dirname);
2432 }
2433 else {
2434 if (xf86ConfigDir)
2435 xf86Msg(X_ERROR,
2436 "Unable to locate/open config directory: \"%s\"\n",
2437 xf86ConfigDir);
2438 }
2439 if (sysdirname)
2440 xf86MsgVerb(X_DEFAULT, 0, "Using system config directory \"%s\"\n",
2441 sysdirname);
2442 if (!filename && !dirname && !sysdirname)
2443 return CONFIG_NOFILE;
2444
2445 free(filename);
2446 free(dirname);
2447 free(sysdirname);
2448 }
2449
2450 if ((xf86configptr = xf86readConfigFile()) == NULL((void*)0)) {
2451 xf86Msg(X_ERROR, "Problem parsing the config file\n");
2452 return CONFIG_PARSE_ERROR;
2453 }
2454 xf86closeConfigFile();
2455
2456 /* Initialise a few things. */
2457
2458 /*
2459 * now we convert part of the information contained in the parser
2460 * structures into our own structures.
2461 * The important part here is to figure out which Screen Sections
2462 * in the XF86Config file are active so that we can piece together
2463 * the modes that we need later down the road.
2464 * And while we are at it, we'll decode the rest of the stuff as well
2465 */
2466
2467 /* First check if a layout section is present, and if it is valid. */
2468 FIND_SUITABLE(XF86ConfLayoutPtr, xf86configptr->conf_layout_lst, layout)do { XF86ConfLayoutPtr _l, _p; for (_l = (xf86configptr->conf_layout_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfLayoutPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(layout) = _p; } while(0)
;
2469 if (layout == NULL((void*)0) || xf86ScreenName != NULL((void*)0)) {
2470 XF86ConfScreenPtr screen;
2471
2472 if (xf86ScreenName == NULL((void*)0)) {
2473 xf86Msg(X_DEFAULT,
2474 "No Layout section. Using the first Screen section.\n");
2475 }
2476 FIND_SUITABLE (XF86ConfScreenPtr, xf86configptr->conf_screen_lst, screen)do { XF86ConfScreenPtr _l, _p; for (_l = (xf86configptr->conf_screen_lst
), _p = ((void*)0); !_p && _l; _l = (XF86ConfScreenPtr
)_l->list.next) { if (!_l->match_seat || (SeatId &&
xf86nameCompare(_l->match_seat, SeatId) == 0)) _p = _l; }
(screen) = _p; } while(0)
;
2477 if (!configImpliedLayout(&xf86ConfigLayout,
2478 screen,
2479 xf86configptr)) {
2480 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2481 return CONFIG_PARSE_ERROR;
2482 }
2483 implicit_layout = TRUE1;
2484 }
2485 else {
2486 if (xf86configptr->conf_flags != NULL((void*)0)) {
2487 char *dfltlayout = NULL((void*)0);
2488 void *optlist = xf86configptr->conf_flags->flg_option_lst;
2489
2490 if (optlist && xf86FindOption(optlist, "defaultserverlayout"))
2491 dfltlayout =
2492 xf86SetStrOption(optlist, "defaultserverlayout", NULL((void*)0));
2493 if (!configLayout(&xf86ConfigLayout, layout, dfltlayout)) {
2494 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2495 return CONFIG_PARSE_ERROR;
2496 }
2497 }
2498 else {
2499 if (!configLayout(&xf86ConfigLayout, layout, NULL((void*)0))) {
2500 xf86Msg(X_ERROR, "Unable to determine the screen layout\n");
2501 return CONFIG_PARSE_ERROR;
2502 }
2503 }
2504 }
2505
2506 xf86ProcessOptions(-1, xf86ConfigLayout.options, LayoutOptions);
2507#ifdef XSERVER_LIBPCIACCESS
2508 if ((scanptr = xf86GetOptValString(LayoutOptions, LAYOUT_ISOLATEDEVICE))) {
2509 ; /* IsolateDevice specified; overrides SingleCard */
2510 }
2511 else {
2512 xf86GetOptValBool(LayoutOptions, LAYOUT_SINGLECARD, &singlecard);
2513 if (singlecard)
2514 scanptr = xf86ConfigLayout.screens->screen->device->busID;
2515 }
2516 if (scanptr) {
2517 if (strncmp(scanptr, "PCI:", 4) != 0) {
2518 xf86Msg(X_WARNING, "Bus types other than PCI not yet isolable.\n"
2519 "\tIgnoring IsolateDevice option.\n");
2520 }
2521 else
2522 xf86PciIsolateDevice(scanptr);
2523 }
2524#endif
2525 /* Now process everything else */
2526 configServerFlags(xf86configptr->conf_flags, xf86ConfigLayout.options);
2527 configFiles(xf86configptr->conf_files);
2528 configExtensions(xf86configptr->conf_extensions);
2529 configDRI(xf86configptr->conf_dri);
2530
2531 checkInput(&xf86ConfigLayout, implicit_layout);
2532
2533 /*
2534 * Handle some command line options that can override some of the
2535 * ServerFlags settings.
2536 */
2537#ifdef XF86VIDMODE1
2538 if (xf86VidModeDisabled)
2539 xf86Info.vidModeEnabled = FALSE0;
2540 if (xf86VidModeAllowNonLocal)
2541 xf86Info.vidModeAllowNonLocal = TRUE1;
2542#endif
2543
2544 if (xf86AllowMouseOpenFail)
2545 xf86Info.allowMouseOpenFail = TRUE1;
2546
2547 return CONFIG_OK;
2548}
2549
2550Bool
2551xf86PathIsSafe(const char *path)
2552{
2553 return (xf86pathIsSafe(path) != 0);
2554}