2 * Loosely based on code bearing the following copyright:
4 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
7 * Copyright (c) 1992-2003 by The XFree86 Project, Inc.
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
16 * The above copyright notice and this permission notice shall be included in
17 * all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
27 * Except as contained in this notice, the name of the copyright holder(s)
28 * and author(s) shall not be used in advertising or otherwise to promote
29 * the sale, use or other dealings in this Software without prior written
30 * authorization from the copyright holder(s) and author(s).
33 #ifdef HAVE_XORG_CONFIG_H
34 #include <xorg-config.h>
43 #include <sys/utsname.h>
49 #include <X11/Xproto.h>
50 #include <X11/Xatom.h>
53 #include "windowstr.h"
54 #include "scrnintstr.h"
60 #include "loaderProcs.h"
68 #include "xf86Config.h"
69 #include "xf86_OSlib.h"
70 #include "xorgVersion.h"
72 #include "xf86Build.h"
73 #include "mipointer.h"
75 #include <X11/extensions/XI.h>
76 #include <X11/extensions/XIproto.h>
81 #include "xf86Xinput.h"
82 #include "xf86InPriv.h"
84 #include "picturestr.h"
91 #include <X11/extensions/dpms.h>
96 /* forward declarations */
98 static void xf86PrintBanner(void);
99 static void xf86PrintMarkers(void);
100 static void xf86PrintDefaultModulePath(void);
101 static void xf86PrintDefaultLibraryPath(void);
102 static void xf86RunVtInit(void);
105 void (*xf86OSPMClose
)(void) = NULL
;
108 static char *baseModules
[] = {
113 /* Common pixmap formats */
115 static PixmapFormatRec formats
[MAXFORMATS
] = {
116 { 1, 1, BITMAP_SCANLINE_PAD
},
117 { 4, 8, BITMAP_SCANLINE_PAD
},
118 { 8, 8, BITMAP_SCANLINE_PAD
},
119 { 15, 16, BITMAP_SCANLINE_PAD
},
120 { 16, 16, BITMAP_SCANLINE_PAD
},
121 { 24, 32, BITMAP_SCANLINE_PAD
},
123 { 32, 32, BITMAP_SCANLINE_PAD
},
127 static int numFormats
= 7;
129 static int numFormats
= 6;
131 static Bool formatsDone
= FALSE
;
134 xf86CreateRootWindow(WindowPtr pWin
)
138 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
139 RootWinPropPtr pProp
;
140 CreateWindowProcPtr CreateWindow
=
141 (CreateWindowProcPtr
)(pScreen
->devPrivates
[xf86CreateRootWindowIndex
].ptr
);
144 ErrorF("xf86CreateRootWindow(%p)\n", pWin
);
147 if ( pScreen
->CreateWindow
!= xf86CreateRootWindow
) {
148 /* Can't find hook we are hung on */
149 xf86DrvMsg(pScreen
->myNum
, X_WARNING
/* X_ERROR */,
150 "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
151 (void *)xf86CreateRootWindow
,
152 (void *)pScreen
->CreateWindow
);
155 /* Unhook this function ... */
156 pScreen
->CreateWindow
= CreateWindow
;
157 pScreen
->devPrivates
[xf86CreateRootWindowIndex
].ptr
= NULL
;
159 /* ... and call the previous CreateWindow fuction, if any */
160 if (NULL
!=pScreen
->CreateWindow
) {
161 ret
= (*pScreen
->CreateWindow
)(pWin
);
164 /* Now do our stuff */
165 if (xf86RegisteredPropertiesTable
!= NULL
) {
166 if (pWin
->parent
== NULL
&& xf86RegisteredPropertiesTable
!= NULL
) {
167 for (pProp
= xf86RegisteredPropertiesTable
[pScreen
->myNum
];
168 pProp
!= NULL
&& err
==Success
;
169 pProp
= pProp
->next
)
173 prop
= MakeAtom(pProp
->name
, strlen(pProp
->name
), TRUE
);
174 err
= ChangeWindowProperty(pWin
,
176 pProp
->format
, PropModeReplace
,
177 pProp
->size
, pProp
->data
,
183 ret
&= (err
==Success
);
186 xf86Msg(X_ERROR
, "xf86CreateRootWindow unexpectedly called with "
187 "non-root window %p (parent %p)\n",
188 (void *)pWin
, (void *)pWin
->parent
);
194 ErrorF("xf86CreateRootWindow() returns %d\n", ret
);
202 * Initialize screenInfo for all actually accessible framebuffers.
203 * That includes vt-manager setup, querying all possible devices and
204 * collecting the pixmap formats.
211 * Install signal handler for unexpected signals
213 xf86Info
.caughtSignal
=FALSE
;
214 if (!xf86Info
.notrapSignals
) {
215 signal(SIGSEGV
,xf86SigHandler
);
216 signal(SIGILL
,xf86SigHandler
);
218 signal(SIGEMT
,xf86SigHandler
);
220 signal(SIGFPE
,xf86SigHandler
);
222 signal(SIGBUS
,xf86SigHandler
);
225 signal(SIGSYS
,xf86SigHandler
);
228 signal(SIGXCPU
,xf86SigHandler
);
231 signal(SIGXFSZ
,xf86SigHandler
);
236 xf86OSPMClose
= xf86OSPMOpen();
239 /* Run an external VT Init program if specified in the config file */
242 /* Do this after XF86Config is read (it's normally in OsInit()) */
247 InitOutput(ScreenInfo
*pScreenInfo
, int argc
, char **argv
)
249 int i
, j
, k
, scr_index
;
250 static unsigned long generation
= 0;
253 screenLayoutPtr layout
;
254 Pix24Flags screenpix24
, pix24
;
255 MessageType pix24From
= X_DEFAULT
;
256 Bool pix24Fail
= FALSE
;
257 Bool autoconfig
= FALSE
;
259 xf86Initialising
= TRUE
;
262 if (generation
!= serverGeneration
) {
263 xf86ScreenIndex
= AllocateScreenPrivateIndex();
264 xf86CreateRootWindowIndex
= AllocateScreenPrivateIndex();
265 xf86PixmapIndex
= AllocatePixmapPrivateIndex();
266 generation
= serverGeneration
;
269 if (serverGeneration
== 1) {
271 pScreenInfo
->numScreens
= 0;
273 if ((xf86ServerName
= strrchr(argv
[0], '/')) != 0)
276 xf86ServerName
= argv
[0];
285 xf86MsgVerb(xf86LogFileFrom
, 0, "Log file: \"%s\", Time: %s",
289 /* Read and parse the config file */
290 if (!xf86DoProbe
&& !xf86DoConfigure
) {
291 switch (xf86HandleConfigFile(FALSE
)) {
294 case CONFIG_PARSE_ERROR
:
295 xf86Msg(X_ERROR
, "Error parsing the config file\n");
306 /* Initialise the loader */
309 /* Tell the loader the default module search path */
310 LoaderSetPath(xf86ModulePath
);
312 if (xf86Info
.ignoreABI
) {
313 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL
);
316 /* Force load mandatory base modules */
317 if (!xf86LoadModules(baseModules
, NULL
))
318 FatalError("Unable to load required base modules, Exiting...\n");
322 /* Do a general bus probe. This will be a PCI probe for x86 platforms */
332 if (!xf86AutoConfig()) {
333 xf86Msg(X_ERROR
, "Auto configuration failed\n");
339 /* Initialise the resource broker */
340 xf86ResourceBrokerInit();
342 /* Load all modules specified explicitly in the config file */
343 if ((modulelist
= xf86ModulelistFromConfig(&optionlist
))) {
344 xf86LoadModules(modulelist
, optionlist
);
349 /* Load all driver modules specified in the config file */
350 if ((modulelist
= xf86DriverlistFromConfig())) {
351 xf86LoadModules(modulelist
, NULL
);
355 /* Load all input driver modules specified in the config file. */
356 if ((modulelist
= xf86InputDriverlistFromConfig())) {
357 xf86LoadModules(modulelist
, NULL
);
362 * It is expected that xf86AddDriver()/xf86AddInputDriver will be
363 * called for each driver as it is loaded. Those functions save the
364 * module pointers for drivers.
365 * XXX Nothing keeps track of them for other modules.
367 /* XXX What do we do if not all of these could be loaded? */
370 * At this point, xf86DriverList[] is all filled in with entries for
371 * each of the drivers to try and xf86NumDrivers has the number of
372 * drivers. If there are none, return now.
375 if (xf86NumDrivers
== 0) {
376 xf86Msg(X_ERROR
, "No drivers available.\n");
381 * Call each of the Identify functions and call the driverFunc to check
382 * if HW access is required. The Identify functions print out some
383 * identifying information, and anything else that might be
384 * needed at this early stage.
387 for (i
= 0; i
< xf86NumDrivers
; i
++) {
389 /* The Identify function is mandatory, but if it isn't there continue */
390 if (xf86DriverList
[i
]->Identify
!= NULL
)
391 xf86DriverList
[i
]->Identify(0);
393 xf86Msg(X_WARNING
, "Driver `%s' has no Identify function\n",
394 xf86DriverList
[i
]->driverName
? xf86DriverList
[i
]->driverName
398 && (!xf86DriverList
[i
]->driverFunc
399 || !xf86DriverList
[i
]->driverFunc(NULL
,
400 GET_REQUIRED_HW_INTERFACES
,
402 || NEED_IO_ENABLED(flags
)))
406 /* Enable full I/O access */
409 /* oops, we have failed */
410 xorgHWAccess
= FALSE
;
414 * Locate bus slot that had register IO enabled at server startup
418 xf86FindPrimaryDevice();
421 * Now call each of the Probe functions. Each successful probe will
422 * result in an extra entry added to the xf86Screens[] list for each
423 * instance of the hardware found.
426 for (i
= 0; i
< xf86NumDrivers
; i
++) {
429 if (!xf86DriverList
[i
]->driverFunc
430 || !xf86DriverList
[i
]->driverFunc(NULL
,
431 GET_REQUIRED_HW_INTERFACES
,
433 || NEED_IO_ENABLED(flags
))
437 if (xf86DriverList
[i
]->Probe
!= NULL
)
438 xf86DriverList
[i
]->Probe(xf86DriverList
[i
], PROBE_DEFAULT
);
440 xf86MsgVerb(X_WARNING
, 0,
441 "Driver `%s' has no Probe function (ignoring)\n",
442 xf86DriverList
[i
]->driverName
443 ? xf86DriverList
[i
]->driverName
: "noname");
445 xf86SetPciVideo(NULL
,NONE
);
449 * If nothing was detected, return now.
452 if (xf86NumScreens
== 0) {
453 xf86Msg(X_ERROR
, "No devices detected.\n");
458 * Match up the screens found by the probes against those specified
459 * in the config file. Remove the ones that won't be used. Sort
460 * them in the order specified.
464 * What is the best way to do this?
466 * For now, go through the screens allocated by the probes, and
467 * look for screen config entry which refers to the same device
468 * section as picked out by the probe.
472 for (i
= 0; i
< xf86NumScreens
; i
++) {
473 for (layout
= xf86ConfigLayout
.screens
; layout
->screen
!= NULL
;
476 for (j
= 0; j
< xf86Screens
[i
]->numEntities
; j
++) {
479 xf86GetDevFromEntity(xf86Screens
[i
]->entityList
[j
],
480 xf86Screens
[i
]->entityInstanceList
[j
]);
482 if (dev
== layout
->screen
->device
) {
483 /* A match has been found */
484 xf86Screens
[i
]->confScreen
= layout
->screen
;
491 if (layout
->screen
== NULL
) {
494 "Screen %d deleted because of no matching config section.\n", i
);
495 xf86DeleteScreen(i
--, 0);
500 * If no screens left, return now.
503 if (xf86NumScreens
== 0) {
505 "Device(s) detected, but none match those in the config file.\n");
513 * Sort the drivers to match the requested ording. Using a slow
516 for (j
= 0; j
< xf86NumScreens
- 1; j
++) {
517 for (i
= 0; i
< xf86NumScreens
- j
- 1; i
++) {
518 if (xf86Screens
[i
+ 1]->confScreen
->screennum
<
519 xf86Screens
[i
]->confScreen
->screennum
) {
520 ScrnInfoPtr tmpScrn
= xf86Screens
[i
+ 1];
521 xf86Screens
[i
+ 1] = xf86Screens
[i
];
522 xf86Screens
[i
] = tmpScrn
;
526 /* Fix up the indexes */
527 for (i
= 0; i
< xf86NumScreens
; i
++) {
528 xf86Screens
[i
]->scrnIndex
= i
;
532 * Call the driver's PreInit()'s to complete initialisation for the first
536 for (i
= 0; i
< xf86NumScreens
; i
++) {
537 xf86EnableAccess(xf86Screens
[i
]);
538 if (xf86Screens
[i
]->PreInit
&&
539 xf86Screens
[i
]->PreInit(xf86Screens
[i
], 0))
540 xf86Screens
[i
]->configured
= TRUE
;
542 for (i
= 0; i
< xf86NumScreens
; i
++)
543 if (!xf86Screens
[i
]->configured
)
544 xf86DeleteScreen(i
--, 0);
547 * If no screens left, return now.
550 if (xf86NumScreens
== 0) {
552 "Screen(s) found, but none have a usable configuration.\n");
556 /* This could be moved into a separate function */
559 * Check that all screens have initialised the mandatory function
560 * entry points. Delete those which have not.
563 #define WARN_SCREEN(func) \
564 xf86Msg(X_ERROR, "Driver `%s' has no %s function, deleting.\n", \
565 xf86Screens[i]->name, (warned++, func))
567 for (i
= 0; i
< xf86NumScreens
; i
++) {
569 if (xf86Screens
[i
]->name
== NULL
) {
570 xf86Screens
[i
]->name
= xnfalloc(strlen("screen") + 1 + 1);
572 sprintf(xf86Screens
[i
]->name
, "screen%c", i
+ '0');
574 sprintf(xf86Screens
[i
]->name
, "screen%c", i
- 10 + 'A');
575 xf86MsgVerb(X_WARNING
, 0,
576 "Screen driver %d has no name set, using `%s'.\n",
577 i
, xf86Screens
[i
]->name
);
579 if (xf86Screens
[i
]->ScreenInit
== NULL
)
580 WARN_SCREEN("ScreenInit");
581 if (xf86Screens
[i
]->EnterVT
== NULL
)
582 WARN_SCREEN("EnterVT");
583 if (xf86Screens
[i
]->LeaveVT
== NULL
)
584 WARN_SCREEN("LeaveVT");
586 xf86DeleteScreen(i
--, 0);
590 * If no screens left, return now.
593 if (xf86NumScreens
== 0) {
594 xf86Msg(X_ERROR
, "Screen(s) found, but drivers were unusable.\n");
598 /* XXX Should this be before or after loading dependent modules? */
607 /* Remove (unload) drivers that are not required */
608 for (i
= 0; i
< xf86NumDrivers
; i
++)
609 if (xf86DriverList
[i
] && xf86DriverList
[i
]->refCount
<= 0)
613 * At this stage we know how many screens there are.
616 for (i
= 0; i
< xf86NumScreens
; i
++)
617 xf86InitViewport(xf86Screens
[i
]);
620 * Collect all pixmap formats and check for conflicts at the display
621 * level. Should we die here? Or just delete the offending screens?
622 * Also, should this be done for -probeonly?
624 screenpix24
= Pix24DontCare
;
625 for (i
= 0; i
< xf86NumScreens
; i
++) {
626 if (xf86Screens
[i
]->imageByteOrder
!=
627 xf86Screens
[0]->imageByteOrder
)
628 FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
629 if (xf86Screens
[i
]->bitmapScanlinePad
!=
630 xf86Screens
[0]->bitmapScanlinePad
)
631 FatalError("Inconsistent display bitmapScanlinePad. Exiting\n");
632 if (xf86Screens
[i
]->bitmapScanlineUnit
!=
633 xf86Screens
[0]->bitmapScanlineUnit
)
634 FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n");
635 if (xf86Screens
[i
]->bitmapBitOrder
!=
636 xf86Screens
[0]->bitmapBitOrder
)
637 FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
639 /* Determine the depth 24 pixmap format the screens would like */
640 if (xf86Screens
[i
]->pixmap24
!= Pix24DontCare
) {
641 if (screenpix24
== Pix24DontCare
)
642 screenpix24
= xf86Screens
[i
]->pixmap24
;
643 else if (screenpix24
!= xf86Screens
[i
]->pixmap24
)
644 FatalError("Inconsistent depth 24 pixmap format. Exiting\n");
647 /* check if screenpix24 is consistent with the config/cmdline */
648 if (xf86Info
.pixmap24
!= Pix24DontCare
) {
649 pix24
= xf86Info
.pixmap24
;
650 pix24From
= xf86Info
.pix24From
;
651 if (screenpix24
!= Pix24DontCare
&& screenpix24
!= xf86Info
.pixmap24
)
653 } else if (screenpix24
!= Pix24DontCare
) {
655 pix24From
= X_PROBED
;
660 FatalError("Screen(s) can't use the required depth 24 pixmap format"
661 " (%d). Exiting\n", PIX24TOBPP(pix24
));
663 /* Initialise the depth 24 format */
664 for (j
= 0; j
< numFormats
&& formats
[j
].depth
!= 24; j
++)
666 formats
[j
].bitsPerPixel
= PIX24TOBPP(pix24
);
668 /* Collect additional formats */
669 for (i
= 0; i
< xf86NumScreens
; i
++) {
670 for (j
= 0; j
< xf86Screens
[i
]->numFormats
; j
++) {
672 if (k
>= numFormats
) {
674 FatalError("Too many pixmap formats! Exiting\n");
675 formats
[k
] = xf86Screens
[i
]->formats
[j
];
679 if (formats
[k
].depth
== xf86Screens
[i
]->formats
[j
].depth
) {
680 if ((formats
[k
].bitsPerPixel
==
681 xf86Screens
[i
]->formats
[j
].bitsPerPixel
) &&
682 (formats
[k
].scanlinePad
==
683 xf86Screens
[i
]->formats
[j
].scanlinePad
))
685 FatalError("Inconsistent pixmap format for depth %d."
686 " Exiting\n", formats
[k
].depth
);
693 if (xf86Info
.vtno
>= 0 ) {
694 #define VT_ATOM_NAME "XFree86_VT"
699 /* This memory needs to stay available until the screen has been
700 initialized, and we can create the property for real.
702 if ( (VT
= xalloc(sizeof(CARD32
)))==NULL
) {
703 FatalError("Unable to make VT property - out of memory. Exiting...\n");
707 VTAtom
= MakeAtom(VT_ATOM_NAME
, sizeof(VT_ATOM_NAME
) - 1, TRUE
);
709 for (i
= 0, ret
= Success
; i
< xf86NumScreens
&& ret
== Success
; i
++) {
710 ret
= xf86RegisterRootWindowProperty(xf86Screens
[i
]->scrnIndex
,
711 VTAtom
, XA_INTEGER
, 32,
714 xf86DrvMsg(xf86Screens
[i
]->scrnIndex
, X_WARNING
,
715 "Failed to register VT property\n");
719 /* If a screen uses depth 24, show what the pixmap format is */
720 for (i
= 0; i
< xf86NumScreens
; i
++) {
721 if (xf86Screens
[i
]->depth
== 24) {
722 xf86Msg(pix24From
, "Depth 24 pixmap format is %d bpp\n",
731 /* set up the proper access funcs */
734 AddCallback(&ServerGrabCallback
, xf86GrabServerCallback
, NULL
);
738 * serverGeneration != 1; some OSs have to do things here, too.
744 should we reopen it here? We need to deal with an already opened
745 device. We could leave this to the OS layer. For now we simply
750 if ((xf86OSPMClose
= xf86OSPMOpen()) != NULL
)
751 xf86MsgVerb(X_INFO
, 3, "APM registered successfully\n");
754 /* Make sure full I/O access is enabled */
761 * Install signal handler for unexpected signals
763 xf86Info
.caughtSignal
=FALSE
;
764 if (!xf86Info
.notrapSignals
)
766 signal(SIGSEGV
,xf86SigHandler
);
767 signal(SIGILL
,xf86SigHandler
);
769 signal(SIGEMT
,xf86SigHandler
);
771 signal(SIGFPE
,xf86SigHandler
);
773 signal(SIGBUS
,xf86SigHandler
);
776 signal(SIGSYS
,xf86SigHandler
);
779 signal(SIGXCPU
,xf86SigHandler
);
782 signal(SIGXFSZ
,xf86SigHandler
);
788 * Use the previously collected parts to setup pScreenInfo
791 pScreenInfo
->imageByteOrder
= xf86Screens
[0]->imageByteOrder
;
792 pScreenInfo
->bitmapScanlinePad
= xf86Screens
[0]->bitmapScanlinePad
;
793 pScreenInfo
->bitmapScanlineUnit
= xf86Screens
[0]->bitmapScanlineUnit
;
794 pScreenInfo
->bitmapBitOrder
= xf86Screens
[0]->bitmapBitOrder
;
795 pScreenInfo
->numPixmapFormats
= numFormats
;
796 for (i
= 0; i
< numFormats
; i
++)
797 pScreenInfo
->formats
[i
] = formats
[i
];
799 /* Make sure the server's VT is active */
801 if (serverGeneration
!= 1) {
802 xf86Resetting
= TRUE
;
803 /* All screens are in the same state, so just check the first */
804 if (!xf86Screens
[0]->vtSema
) {
806 ioctl(xf86Info
.consoleFd
, VT_RELDISP
, VT_ACKACQ
);
809 xf86EnterServerState(SETUP
);
815 * Under SCO we must ack that we got the console at startup,
816 * I think this is the safest way to assure it.
821 if (ioctl(xf86Info
.consoleFd
, VT_RELDISP
, VT_ACKACQ
) < 0)
822 xf86Msg(X_WARNING
, "VT_ACKACQ failed");
827 for (i
= 0; i
< xf86NumScreens
; i
++) {
828 xf86EnableAccess(xf86Screens
[i
]);
830 * Almost everything uses these defaults, and many of those that
831 * don't, will wrap them.
833 xf86Screens
[i
]->EnableDisableFBAccess
= xf86EnableDisableFBAccess
;
834 xf86Screens
[i
]->SetDGAMode
= xf86SetDGAMode
;
835 xf86Screens
[i
]->DPMSSet
= NULL
;
836 xf86Screens
[i
]->LoadPalette
= NULL
;
837 xf86Screens
[i
]->SetOverscan
= NULL
;
838 xf86Screens
[i
]->DriverFunc
= NULL
;
839 xf86Screens
[i
]->pScreen
= NULL
;
840 scr_index
= AddScreen(xf86Screens
[i
]->ScreenInit
, argc
, argv
);
841 if (scr_index
== i
) {
843 * Hook in our ScrnInfoRec, and initialise some other pScreen
846 screenInfo
.screens
[scr_index
]->devPrivates
[xf86ScreenIndex
].ptr
847 = (pointer
)xf86Screens
[i
];
848 xf86Screens
[i
]->pScreen
= screenInfo
.screens
[scr_index
];
849 /* The driver should set this, but make sure it is set anyway */
850 xf86Screens
[i
]->vtSema
= TRUE
;
852 /* This shouldn't normally happen */
853 FatalError("AddScreen/ScreenInit failed for driver %d\n", i
);
857 ErrorF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
858 i
, xf86Screens
[i
]->pScreen
);
859 ErrorF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
860 i
, xf86Screens
[i
]->pScreen
->CreateWindow
);
863 screenInfo
.screens
[scr_index
]->devPrivates
[xf86CreateRootWindowIndex
].ptr
864 = (void*)(xf86Screens
[i
]->pScreen
->CreateWindow
);
865 xf86Screens
[i
]->pScreen
->CreateWindow
= xf86CreateRootWindow
;
868 if (PictureGetSubpixelOrder (xf86Screens
[i
]->pScreen
) == SubPixelUnknown
)
870 xf86MonPtr DDC
= (xf86MonPtr
)(xf86Screens
[i
]->monitor
->DDC
);
871 PictureSetSubpixelOrder (xf86Screens
[i
]->pScreen
,
873 (DDC
->features
.input_type
?
874 SubPixelHorizontalRGB
: SubPixelNone
) :
879 if (!xf86Info
.disableRandR
)
880 xf86RandRInit (screenInfo
.screens
[scr_index
]);
881 xf86Msg(xf86Info
.randRFrom
, "RandR %s\n",
882 xf86Info
.disableRandR
? "disabled" : "enabled");
886 xf86PostScreenInit();
890 xf86Resetting
= FALSE
;
891 xf86Initialising
= FALSE
;
893 RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr
)NoopDDA
, xf86Wakeup
,
899 * Initialize all supported input devices.
903 InitInput(argc
, argv
)
911 xf86Info
.vtRequestsPending
= FALSE
;
912 xf86Info
.inputPending
= FALSE
;
914 if (serverGeneration
== 1) {
915 /* Call the PreInit function for each input device instance. */
916 for (pDev
= xf86ConfigLayout
.inputs
; pDev
&& *pDev
; pDev
++) {
917 /* Replace obsolete keyboard driver with kbd */
918 if (!xf86NameCmp((*pDev
)->driver
, "keyboard")) {
919 xf86MsgVerb(X_WARNING
, 0,
920 "*** WARNING the legacy keyboard driver \"%s\" has been removed\n",
922 xf86MsgVerb(X_WARNING
, 0,
923 "*** Using the new \"kbd\" driver for \"%s\".\n",
924 (*pDev
)->identifier
);
925 strcpy((*pDev
)->driver
, "kbd");
928 if ((pDrv
= xf86LookupInputDriver((*pDev
)->driver
)) == NULL
) {
929 xf86Msg(X_ERROR
, "No Input driver matching `%s'\n", (*pDev
)->driver
);
930 /* XXX For now, just continue. */
933 if (!pDrv
->PreInit
) {
934 xf86MsgVerb(X_WARNING
, 0,
935 "Input driver `%s' has no PreInit function (ignoring)\n",
939 pInfo
= pDrv
->PreInit(pDrv
, *pDev
, 0);
941 xf86Msg(X_ERROR
, "PreInit returned NULL for \"%s\"\n",
942 (*pDev
)->identifier
);
944 } else if (!(pInfo
->flags
& XI86_CONFIGURED
)) {
945 xf86Msg(X_ERROR
, "PreInit failed for input device \"%s\"\n",
946 (*pDev
)->identifier
);
947 xf86DeleteInput(pInfo
, 0);
953 /* Initialise all input devices. */
954 pInfo
= xf86InputDevs
;
956 xf86Msg(X_INFO
, "evaluating device (%s)\n", pInfo
->name
);
957 xf86ActivateDevice(pInfo
);
964 #ifndef SET_STDERR_NONBLOCKING
965 #define SET_STDERR_NONBLOCKING 1
970 * OS/Vendor-specific initialisations. Called from OsInit(), which
971 * is called by dix before establishing the well known sockets.
977 static Bool beenHere
= FALSE
;
982 signal(SIGCHLD
, SIG_DFL
); /* Need to wait for child processes */
984 OsDelayInitColors
= TRUE
;
985 #ifndef BUILTIN_FONTS
986 loadableFonts
= TRUE
;
992 #if SET_STDERR_NONBLOCKING
993 /* Set stderr to non-blocking. */
996 #define O_NONBLOCK FNDELAY
997 #elif defined(O_NDELAY)
998 #define O_NONBLOCK O_NDELAY
1004 if (geteuid() == 0 && getuid() != geteuid())
1008 status
= fcntl(fileno(stderr
), F_GETFL
, 0);
1010 fcntl(fileno(stderr
), F_SETFL
, status
| O_NONBLOCK
);
1022 * Device dependent cleanup. Called by by dix before normal server death.
1023 * For SYSV386 we must switch the terminal back to normal mode. No error-
1024 * checking here, since there should be restored as much as possible.
1035 xf86OSPMClose
= NULL
;
1038 xf86AccessLeaveState();
1040 for (i
= 0; i
< xf86NumScreens
; i
++) {
1042 * zero all access functions to
1043 * trap calls when switched away.
1045 xf86Screens
[i
]->vtSema
= FALSE
;
1046 xf86Screens
[i
]->access
= NULL
;
1047 xf86Screens
[i
]->busAccess
= NULL
;
1050 #ifdef USE_XF86_SERVERLOCK
1061 /* If an unexpected signal was caught, dump a core for debugging */
1062 if (xf86Info
.caughtSignal
)
1070 * DDX - specific abort routine. Called by AbortServer(). The attempt is
1071 * made to restore all original setting of the displays. Also all devices
1081 * try to restore the original video state
1084 /* Need the sleep when starting X from within another X session */
1087 #ifdef DPMSExtension /* Turn screens back on */
1088 if (DPMSPowerLevel
!= DPMSModeOn
)
1089 DPMSSet(DPMSModeOn
);
1092 if (xf86Screens
[0]->vtSema
)
1093 xf86EnterServerState(SETUP
);
1094 for (i
= 0; i
< xf86NumScreens
; i
++)
1095 if (xf86Screens
[i
]->vtSema
) {
1097 * if we are aborting before ScreenInit() has finished
1098 * we might not have been wrapped yet. Therefore enable
1099 * screen explicitely.
1101 xf86EnableAccess(xf86Screens
[i
]);
1102 (xf86Screens
[i
]->LeaveVT
)(i
, 0);
1109 * This is needed for an abnormal server exit, since the normal exit stuff
1110 * MUST also be performed (i.e. the vt must be left in a defined state)
1116 OsVendorFatalError()
1118 #ifdef VENDORSUPPORT
1119 ErrorF("\nPlease refer to your Operating System Vendor support pages\n"
1120 "at %s for support on this crash.\n",VENDORSUPPORT
);
1122 ErrorF("\nPlease consult the "XVENDORNAME
" support \n"
1123 "\t at "__VENDORDWEBSUPPORT__
"\n for help. \n");
1125 if (xf86LogFile
&& xf86LogFileWasOpened
)
1126 ErrorF("Please also check the log file at \"%s\" for additional "
1127 "information.\n", xf86LogFile
);
1132 xf86SetVerbosity(int verb
)
1134 int save
= xf86Verbose
;
1137 LogSetParameter(XLOG_VERBOSITY
, verb
);
1142 xf86SetLogVerbosity(int verb
)
1144 int save
= xf86LogVerbose
;
1146 xf86LogVerbose
= verb
;
1147 LogSetParameter(XLOG_FILE_VERBOSITY
, verb
);
1152 * ddxProcessArgument --
1153 * Process device-dependent command line args. Returns 0 if argument is
1154 * not device dependent, otherwise Count of number of elements of argv
1155 * that are part of a device dependent commandline option.
1163 ddxProcessArgument(int argc
, char **argv
, int i
)
1166 * Note: can't use xalloc/xfree here because OsInit() hasn't been called
1167 * yet. Use malloc/free instead.
1170 #define CHECK_FOR_REQUIRED_ARGUMENT() \
1171 if (((i + 1) >= argc) || (!argv[i + 1])) { \
1172 ErrorF("Required argument to %s not specified\n", argv[i]); \
1174 FatalError("Required argument to %s not specified\n", argv[i]); \
1177 /* First the options that are only allowed for root */
1178 if (getuid() == 0 || geteuid() != 0)
1180 if (!strcmp(argv
[i
], "-modulepath"))
1183 CHECK_FOR_REQUIRED_ARGUMENT();
1184 mp
= malloc(strlen(argv
[i
+ 1]) + 1);
1186 FatalError("Can't allocate memory for ModulePath\n");
1187 strcpy(mp
, argv
[i
+ 1]);
1188 xf86ModulePath
= mp
;
1189 xf86ModPathFrom
= X_CMDLINE
;
1192 else if (!strcmp(argv
[i
], "-logfile"))
1195 CHECK_FOR_REQUIRED_ARGUMENT();
1196 lf
= malloc(strlen(argv
[i
+ 1]) + 1);
1198 FatalError("Can't allocate memory for LogFile\n");
1199 strcpy(lf
, argv
[i
+ 1]);
1201 xf86LogFileFrom
= X_CMDLINE
;
1204 } else if (!strcmp(argv
[i
], "-modulepath") || !strcmp(argv
[i
], "-logfile")) {
1205 FatalError("The '%s' option can only be used by root.\n", argv
[i
]);
1207 if (!strcmp(argv
[i
], "-config") || !strcmp(argv
[i
], "-xf86config"))
1209 CHECK_FOR_REQUIRED_ARGUMENT();
1210 if (getuid() != 0 && !xf86PathIsSafe(argv
[i
+ 1])) {
1211 FatalError("\nInvalid argument for %s\n"
1212 "\tFor non-root users, the file specified with %s must be\n"
1213 "\ta relative path and must not contain any \"..\" elements.\n"
1214 "\tUsing default "__XCONFIGFILE__
" search path.\n\n",
1217 xf86ConfigFile
= argv
[i
+ 1];
1220 if (!strcmp(argv
[i
],"-showunresolved"))
1222 xf86ShowUnresolved
= TRUE
;
1225 if (!strcmp(argv
[i
],"-probeonly"))
1227 xf86ProbeOnly
= TRUE
;
1230 if (!strcmp(argv
[i
],"-flipPixels"))
1232 xf86FlipPixels
= TRUE
;
1236 if (!strcmp(argv
[i
],"-disableVidMode"))
1238 xf86VidModeDisabled
= TRUE
;
1241 if (!strcmp(argv
[i
],"-allowNonLocalXvidtune"))
1243 xf86VidModeAllowNonLocal
= TRUE
;
1248 if (!strcmp(argv
[i
],"-disableModInDev"))
1250 xf86MiscModInDevDisabled
= TRUE
;
1253 if (!strcmp(argv
[i
],"-allowNonLocalModInDev"))
1255 xf86MiscModInDevAllowNonLocal
= TRUE
;
1259 if (!strcmp(argv
[i
],"-allowMouseOpenFail"))
1261 xf86AllowMouseOpenFail
= TRUE
;
1264 if (!strcmp(argv
[i
],"-bestRefresh"))
1266 xf86BestRefresh
= TRUE
;
1269 if (!strcmp(argv
[i
],"-ignoreABI"))
1271 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL
);
1274 if (!strcmp(argv
[i
],"-verbose"))
1276 if (++i
< argc
&& argv
[i
])
1280 val
= strtol(argv
[i
], &end
, 0);
1283 xf86SetVerbosity(val
);
1287 xf86SetVerbosity(++xf86Verbose
);
1290 if (!strcmp(argv
[i
],"-logverbose"))
1292 if (++i
< argc
&& argv
[i
])
1296 val
= strtol(argv
[i
], &end
, 0);
1299 xf86SetLogVerbosity(val
);
1303 xf86SetLogVerbosity(++xf86LogVerbose
);
1306 if (!strcmp(argv
[i
],"-quiet"))
1308 xf86SetVerbosity(0);
1311 if (!strcmp(argv
[i
],"-showconfig") || !strcmp(argv
[i
],"-version"))
1316 if (!strcmp(argv
[i
],"-showDefaultModulePath"))
1318 xf86PrintDefaultModulePath();
1321 if (!strcmp(argv
[i
],"-showDefaultLibPath"))
1323 xf86PrintDefaultLibraryPath();
1326 /* Notice the -fp flag, but allow it to pass to the dix layer */
1327 if (!strcmp(argv
[i
], "-fp"))
1332 /* Notice the -co flag, but allow it to pass to the dix layer */
1333 if (!strcmp(argv
[i
], "-co"))
1338 /* Notice the -bs flag, but allow it to pass to the dix layer */
1339 if (!strcmp(argv
[i
], "-bs"))
1341 xf86bsDisableFlag
= TRUE
;
1344 /* Notice the +bs flag, but allow it to pass to the dix layer */
1345 if (!strcmp(argv
[i
], "+bs"))
1347 xf86bsEnableFlag
= TRUE
;
1350 /* Notice the -s flag, but allow it to pass to the dix layer */
1351 if (!strcmp(argv
[i
], "-s"))
1356 if (!strcmp(argv
[i
], "-bpp"))
1358 ErrorF("The -bpp option is no longer supported.\n"
1359 "\tUse -depth to set the color depth, and use -fbbpp if you really\n"
1360 "\tneed to force a non-default framebuffer (hardware) pixel format.\n");
1365 if (!strcmp(argv
[i
], "-pixmap24"))
1367 xf86Pix24
= Pix24Use24
;
1370 if (!strcmp(argv
[i
], "-pixmap32"))
1372 xf86Pix24
= Pix24Use32
;
1375 if (!strcmp(argv
[i
], "-fbbpp"))
1378 CHECK_FOR_REQUIRED_ARGUMENT();
1379 if (sscanf(argv
[++i
], "%d", &bpp
) == 1)
1386 ErrorF("Invalid fbbpp\n");
1390 if (!strcmp(argv
[i
], "-depth"))
1393 CHECK_FOR_REQUIRED_ARGUMENT();
1394 if (sscanf(argv
[++i
], "%d", &depth
) == 1)
1401 ErrorF("Invalid depth\n");
1405 if (!strcmp(argv
[i
], "-weight"))
1407 int red
, green
, blue
;
1408 CHECK_FOR_REQUIRED_ARGUMENT();
1409 if (sscanf(argv
[++i
], "%1d%1d%1d", &red
, &green
, &blue
) == 3)
1411 xf86Weight
.red
= red
;
1412 xf86Weight
.green
= green
;
1413 xf86Weight
.blue
= blue
;
1418 ErrorF("Invalid weighting\n");
1422 if (!strcmp(argv
[i
], "-gamma") || !strcmp(argv
[i
], "-rgamma") ||
1423 !strcmp(argv
[i
], "-ggamma") || !strcmp(argv
[i
], "-bgamma"))
1426 CHECK_FOR_REQUIRED_ARGUMENT();
1427 if (sscanf(argv
[++i
], "%lf", &gamma
) == 1) {
1428 if (gamma
< GAMMA_MIN
|| gamma
> GAMMA_MAX
) {
1429 ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
1430 " is valid\n", GAMMA_MIN
, GAMMA_MAX
);
1433 if (!strcmp(argv
[i
-1], "-gamma"))
1434 xf86Gamma
.red
= xf86Gamma
.green
= xf86Gamma
.blue
= gamma
;
1435 else if (!strcmp(argv
[i
-1], "-rgamma")) xf86Gamma
.red
= gamma
;
1436 else if (!strcmp(argv
[i
-1], "-ggamma")) xf86Gamma
.green
= gamma
;
1437 else if (!strcmp(argv
[i
-1], "-bgamma")) xf86Gamma
.blue
= gamma
;
1441 if (!strcmp(argv
[i
], "-layout"))
1443 CHECK_FOR_REQUIRED_ARGUMENT();
1444 xf86LayoutName
= argv
[++i
];
1447 if (!strcmp(argv
[i
], "-screen"))
1449 CHECK_FOR_REQUIRED_ARGUMENT();
1450 xf86ScreenName
= argv
[++i
];
1453 if (!strcmp(argv
[i
], "-pointer"))
1455 CHECK_FOR_REQUIRED_ARGUMENT();
1456 xf86PointerName
= argv
[++i
];
1459 if (!strcmp(argv
[i
], "-keyboard"))
1461 CHECK_FOR_REQUIRED_ARGUMENT();
1462 xf86KeyboardName
= argv
[++i
];
1465 if (!strcmp(argv
[i
], "-nosilk"))
1467 xf86silkenMouseDisableFlag
= TRUE
;
1471 if (!strcmp(argv
[i
], "-noacpi"))
1473 xf86acpiDisableFlag
= TRUE
;
1477 if (!strcmp(argv
[i
], "-scanpci"))
1479 DoScanPci(argc
, argv
, i
);
1481 if (!strcmp(argv
[i
], "-probe"))
1486 if (!strcmp(argv
[i
], "-configure"))
1488 if (getuid() != 0 && geteuid() == 0) {
1489 ErrorF("The '-configure' option can only be used by root.\n");
1492 xf86DoConfigure
= TRUE
;
1493 xf86AllowMouseOpenFail
= TRUE
;
1496 if (!strcmp(argv
[i
], "-isolateDevice"))
1498 int bus
, device
, func
;
1499 CHECK_FOR_REQUIRED_ARGUMENT();
1500 if (strncmp(argv
[++i
], "PCI:", 4)) {
1501 FatalError("Bus types other than PCI not yet isolable\n");
1503 if (sscanf(argv
[i
], "PCI:%d:%d:%d", &bus
, &device
, &func
) == 3) {
1504 xf86IsolateDevice
.bus
= bus
;
1505 xf86IsolateDevice
.device
= device
;
1506 xf86IsolateDevice
.func
= func
;
1509 FatalError("Invalid isolated device specification\n");
1512 /* OS-specific processing */
1513 return xf86ProcessArgument(argc
, argv
, i
);
1516 /* ddxInitGlobals - called by |InitGlobals| from os/util.c */
1517 void ddxInitGlobals(void)
1523 * Print out correct use of device dependent commandline options.
1524 * Maybe the user now knows what really to do ...
1532 ErrorF("Device Dependent Usage\n");
1533 if (getuid() == 0 || geteuid() != 0)
1535 ErrorF("-modulepath paths specify the module search path\n");
1536 ErrorF("-logfile file specify a log file name\n");
1537 ErrorF("-configure probe for devices and write an "__XCONFIGFILE__
"\n");
1539 ErrorF("-config file specify a configuration file, relative to the\n");
1540 ErrorF(" "__XCONFIGFILE__
" search path, only root can use absolute\n");
1541 ErrorF("-probeonly probe for devices, then exit\n");
1542 ErrorF("-scanpci execute the scanpci module and exit\n");
1543 ErrorF("-verbose [n] verbose startup messages\n");
1544 ErrorF("-logverbose [n] verbose log messages\n");
1545 ErrorF("-quiet minimal startup messages\n");
1546 ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
1547 ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
1548 ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
1549 ErrorF("-depth n set colour depth. Default: 8\n");
1550 ErrorF("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
1551 ErrorF("-rgamma f set gamma value for red phase\n");
1552 ErrorF("-ggamma f set gamma value for green phase\n");
1553 ErrorF("-bgamma f set gamma value for blue phase\n");
1554 ErrorF("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
1555 ErrorF("-layout name specify the ServerLayout section name\n");
1556 ErrorF("-screen name specify the Screen section name\n");
1557 ErrorF("-keyboard name specify the core keyboard InputDevice name\n");
1558 ErrorF("-pointer name specify the core pointer InputDevice name\n");
1559 ErrorF("-nosilk disable Silken Mouse\n");
1560 ErrorF("-flipPixels swap default black/white Pixel values\n");
1562 ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
1563 ErrorF("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
1566 ErrorF("-disableModInDev disable dynamic modification of input device settings\n");
1567 ErrorF("-allowNonLocalModInDev allow changes to keyboard and mouse settings\n");
1568 ErrorF(" from non-local clients\n");
1569 ErrorF("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
1571 ErrorF("-bestRefresh choose modes with the best refresh rate\n");
1572 ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
1573 ErrorF("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
1574 ErrorF("-version show the server version\n");
1575 ErrorF("-showDefaultModulePath show the server default module path\n");
1576 ErrorF("-showDefaultLibPath show the server default library path\n");
1577 /* OS-specific usage */
1584 #define OSNAME " unknown"
1590 #define PRE_RELEASE XORG_VERSION_SNAP
1598 "This is a pre-release version of the X server from " XVENDORNAME
".\n"
1599 "It is not supported in any way.\n"
1600 "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
1601 "Select the \"xorg\" product for bugs you find in this release.\n"
1602 "Before reporting bugs in pre-release versions please check the\n"
1603 "latest version in the X.Org Foundation git repository.\n"
1604 "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
1606 ErrorF("\nX.Org X Server %d.%d.%d",
1609 XORG_VERSION_PATCH
);
1610 #if XORG_VERSION_SNAP > 0
1611 ErrorF(".%d", XORG_VERSION_SNAP
);
1614 #if XORG_VERSION_SNAP >= 900
1615 /* When the minor number is 99, that signifies that the we are making
1616 * a release candidate for a major version. (X.0.0)
1617 * When the patch number is 99, that signifies that the we are making
1618 * a release candidate for a minor version. (X.Y.0)
1619 * When the patch number is < 99, then we are making a release
1620 * candidate for the next point release. (X.Y.Z)
1622 #if XORG_VERSION_MINOR >= 99
1623 ErrorF(" (%d.0.0 RC %d)", XORG_VERSION_MAJOR
+1, XORG_VERSION_SNAP
- 900);
1624 #elif XORG_VERSION_PATCH == 99
1625 ErrorF(" (%d.%d.0 RC %d)", XORG_VERSION_MAJOR
, XORG_VERSION_MINOR
+ 1,
1626 XORG_VERSION_SNAP
- 900);
1628 ErrorF(" (%d.%d.%d RC %d)", XORG_VERSION_MAJOR
, XORG_VERSION_MINOR
,
1629 XORG_VERSION_PATCH
+ 1, XORG_VERSION_SNAP
- 900);
1633 #ifdef XORG_CUSTOM_VERSION
1634 ErrorF(" (%s)", XORG_CUSTOM_VERSION
);
1637 #define XORG_DATE XF86_DATE
1639 ErrorF("\nRelease Date: %s\n", XORG_DATE
);
1640 ErrorF("X Protocol Version %d, Revision %d\n",
1641 X_PROTOCOL
, X_PROTOCOL_REVISION
);
1642 ErrorF("Build Operating System: %s %s\n", OSNAME
, OSVENDOR
);
1645 struct utsname name
;
1647 /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
1648 and Irix) and Single Unix Spec 3 just say that non-negative is success.
1649 All agree that failure is represented by a negative number.
1651 if (uname(&name
) >= 0) {
1652 ErrorF("Current Operating System: %s %s %s %s %s\n",
1653 name
.sysname
, name
.nodename
, name
.release
, name
.version
, name
.machine
);
1657 #if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
1662 bzero(&t
, sizeof(t
));
1663 bzero(buf
, sizeof(buf
));
1664 t
.tm_mday
= BUILD_DATE
% 100;
1665 t
.tm_mon
= (BUILD_DATE
/ 100) % 100 - 1;
1666 t
.tm_year
= BUILD_DATE
/ 10000 - 1900;
1667 #if defined(BUILD_TIME)
1668 t
.tm_sec
= BUILD_TIME
% 100;
1669 t
.tm_min
= (BUILD_TIME
/ 100) % 100;
1670 t
.tm_hour
= (BUILD_TIME
/ 10000) % 100;
1671 if (strftime(buf
, sizeof(buf
), "%d %B %Y %I:%M:%S%p", &t
))
1672 ErrorF("Build Date: %s\n", buf
);
1674 if (strftime(buf
, sizeof(buf
), "%d %B %Y", &t
))
1675 ErrorF("Build Date: %s\n", buf
);
1679 #if defined(CLOG_DATE) && (CLOG_DATE > 19000000)
1684 bzero(&t
, sizeof(t
));
1685 bzero(buf
, sizeof(buf
));
1686 t
.tm_mday
= CLOG_DATE
% 100;
1687 t
.tm_mon
= (CLOG_DATE
/ 100) % 100 - 1;
1688 t
.tm_year
= CLOG_DATE
/ 10000 - 1900;
1689 if (strftime(buf
, sizeof(buf
), "%d %B %Y", &t
))
1690 ErrorF("Changelog Date: %s\n", buf
);
1693 #if defined(BUILDERSTRING)
1694 ErrorF("%s \n",BUILDERSTRING
);
1696 ErrorF("\tBefore reporting problems, check "__VENDORDWEBSUPPORT__
"\n"
1697 "\tto make sure that you have the latest version.\n");
1698 ErrorF("Module Loader present\n");
1708 xf86PrintDefaultModulePath(void)
1710 ErrorF("%s\n", DEFAULT_MODULE_PATH
);
1714 xf86PrintDefaultLibraryPath(void)
1716 ErrorF("%s\n", DEFAULT_LIBRARY_PATH
);
1725 * If VTInit was set, run that program with consoleFd as stdin and stdout
1728 if (xf86Info
.vtinit
) {
1731 FatalError("xf86RunVtInit: fork failed (%s)\n", strerror(errno
));
1734 if (setuid(getuid()) == -1) {
1735 xf86Msg(X_ERROR
, "xf86RunVtInit: setuid failed (%s)\n",
1739 /* set stdin, stdout to the consoleFd */
1740 for (i
= 0; i
< 2; i
++) {
1741 if (xf86Info
.consoleFd
!= i
) {
1743 dup(xf86Info
.consoleFd
);
1746 execl("/bin/sh", "sh", "-c", xf86Info
.vtinit
, (void *)NULL
);
1747 xf86Msg(X_WARNING
, "exec of /bin/sh failed for VTInit (%s)\n",
1751 default: /* parent */
1758 * xf86LoadModules iterates over a list that is being passed in.
1761 xf86LoadModules(char **list
, pointer
*optlist
)
1767 Bool failed
= FALSE
;
1772 for (i
= 0; list
[i
] != NULL
; i
++) {
1774 /* Normalise the module name */
1775 name
= xf86NormalizeName(list
[i
]);
1777 /* Skip empty names */
1778 if (name
== NULL
|| *name
== '\0')
1781 /* Replace obsolete keyboard driver with kbd */
1782 if (!xf86NameCmp(name
, "keyboard")) {
1783 strcpy(name
, "kbd");
1791 if (!LoadModule(name
, NULL
, NULL
, NULL
, opt
, NULL
, &errmaj
, &errmin
)) {
1792 LoaderErrorMsg(NULL
, name
, errmaj
, errmin
);
1800 /* Pixmap format stuff */
1802 _X_EXPORT PixmapFormatPtr
1803 xf86GetPixFormat(ScrnInfoPtr pScrn
, int depth
)
1806 static PixmapFormatRec format
; /* XXX not reentrant */
1809 * When the formats[] list initialisation isn't complete, check the
1810 * depth 24 pixmap config/cmdline options and screen-specified formats.
1815 Pix24Flags pix24
= Pix24DontCare
;
1818 format
.scanlinePad
= BITMAP_SCANLINE_PAD
;
1819 if (xf86Info
.pixmap24
!= Pix24DontCare
)
1820 pix24
= xf86Info
.pixmap24
;
1821 else if (pScrn
->pixmap24
!= Pix24DontCare
)
1822 pix24
= pScrn
->pixmap24
;
1823 if (pix24
== Pix24Use24
)
1824 format
.bitsPerPixel
= 24;
1826 format
.bitsPerPixel
= 32;
1831 for (i
= 0; i
< numFormats
; i
++)
1832 if (formats
[i
].depth
== depth
)
1834 if (i
!= numFormats
)
1836 else if (!formatsDone
) {
1837 /* Check for screen-specified formats */
1838 for (i
= 0; i
< pScrn
->numFormats
; i
++)
1839 if (pScrn
->formats
[i
].depth
== depth
)
1841 if (i
!= pScrn
->numFormats
)
1842 return &pScrn
->formats
[i
];
1848 xf86GetBppFromDepth(ScrnInfoPtr pScrn
, int depth
)
1850 PixmapFormatPtr format
;
1853 format
= xf86GetPixFormat(pScrn
, depth
);
1855 return format
->bitsPerPixel
;