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>
48 #include <X11/Xproto.h>
49 #include <X11/Xatom.h>
52 #include "windowstr.h"
53 #include "scrnintstr.h"
59 #include "loaderProcs.h"
67 #include "xf86Config.h"
68 #include "xf86_OSlib.h"
70 #include "xorgVersion.h"
71 #include "xf86Build.h"
72 #include "mipointer.h"
73 #include <X11/extensions/XI.h>
74 #include <X11/extensions/XIproto.h>
76 #include "xf86Xinput.h"
77 #include "xf86InPriv.h"
78 #include "picturestr.h"
81 #ifdef XSERVER_LIBPCIACCESS
82 #include "xf86VGAarbiter.h"
85 #include "xserver-properties.h"
88 #include <X11/extensions/dpmsconst.h>
94 void (*xf86OSPMClose
) (void) = NULL
;
96 static Bool xorgHWOpenConsole
= FALSE
;
98 /* Common pixmap formats */
100 static PixmapFormatRec formats
[MAXFORMATS
] = {
101 {1, 1, BITMAP_SCANLINE_PAD
},
102 {4, 8, BITMAP_SCANLINE_PAD
},
103 {8, 8, BITMAP_SCANLINE_PAD
},
104 {15, 16, BITMAP_SCANLINE_PAD
},
105 {16, 16, BITMAP_SCANLINE_PAD
},
106 {24, 32, BITMAP_SCANLINE_PAD
},
107 {32, 32, BITMAP_SCANLINE_PAD
},
110 static int numFormats
= 7;
111 static Bool formatsDone
= FALSE
;
114 #define OSNAME " unknown"
120 #define PRE_RELEASE XORG_VERSION_SNAP
124 xf86PrintBanner(void)
127 xf86ErrorFVerb(0, "\n"
128 "This is a pre-release version of the X server from "
129 XVENDORNAME
".\n" "It is not supported in any way.\n"
130 "Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.\n"
131 "Select the \"xorg\" product for bugs you find in this release.\n"
132 "Before reporting bugs in pre-release versions please check the\n"
133 "latest version in the X.Org Foundation git repository.\n"
134 "See http://wiki.x.org/wiki/GitPage for git access instructions.\n");
136 xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d",
137 XORG_VERSION_MAJOR
, XORG_VERSION_MINOR
, XORG_VERSION_PATCH
);
138 #if XORG_VERSION_SNAP > 0
139 xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP
);
142 #if XORG_VERSION_SNAP >= 900
143 /* When the minor number is 99, that signifies that the we are making
144 * a release candidate for a major version. (X.0.0)
145 * When the patch number is 99, that signifies that the we are making
146 * a release candidate for a minor version. (X.Y.0)
147 * When the patch number is < 99, then we are making a release
148 * candidate for the next point release. (X.Y.Z)
150 #if XORG_VERSION_MINOR >= 99
151 xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR
+ 1,
152 XORG_VERSION_SNAP
- 900);
153 #elif XORG_VERSION_PATCH == 99
154 xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR
,
155 XORG_VERSION_MINOR
+ 1, XORG_VERSION_SNAP
- 900);
157 xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR
,
158 XORG_VERSION_MINOR
, XORG_VERSION_PATCH
+ 1,
159 XORG_VERSION_SNAP
- 900);
163 #ifdef XORG_CUSTOM_VERSION
164 xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION
);
167 #define XORG_DATE "Unknown"
169 xf86ErrorFVerb(0, "\nRelease Date: %s\n", XORG_DATE
);
170 xf86ErrorFVerb(0, "X Protocol Version %d, Revision %d\n",
171 X_PROTOCOL
, X_PROTOCOL_REVISION
);
172 xf86ErrorFVerb(0, "Build Operating System: %s %s\n", OSNAME
, OSVENDOR
);
177 /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX,
178 and Irix) and Single Unix Spec 3 just say that non-negative is success.
179 All agree that failure is represented by a negative number.
181 if (uname(&name
) >= 0) {
182 xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n",
183 name
.sysname
, name
.nodename
, name
.release
,
184 name
.version
, name
.machine
);
188 int fd
= open("/proc/cmdline", O_RDONLY
);
191 xf86ErrorFVerb(0, "Kernel command line: ");
193 while (read(fd
, buf
, 80) > 0) {
194 xf86ErrorFVerb(0, "%.80s", buf
);
204 #if defined(BUILD_DATE) && (BUILD_DATE > 19000000)
209 memset(&t
, 0, sizeof(t
));
210 memset(buf
, 0, sizeof(buf
));
211 t
.tm_mday
= BUILD_DATE
% 100;
212 t
.tm_mon
= (BUILD_DATE
/ 100) % 100 - 1;
213 t
.tm_year
= BUILD_DATE
/ 10000 - 1900;
214 #if defined(BUILD_TIME)
215 t
.tm_sec
= BUILD_TIME
% 100;
216 t
.tm_min
= (BUILD_TIME
/ 100) % 100;
217 t
.tm_hour
= (BUILD_TIME
/ 10000) % 100;
218 if (strftime(buf
, sizeof(buf
), "%d %B %Y %I:%M:%S%p", &t
))
219 xf86ErrorFVerb(0, "Build Date: %s\n", buf
);
221 if (strftime(buf
, sizeof(buf
), "%d %B %Y", &t
))
222 xf86ErrorFVerb(0, "Build Date: %s\n", buf
);
226 #if defined(BUILDERSTRING)
227 xf86ErrorFVerb(0, "%s \n", BUILDERSTRING
);
229 xf86ErrorFVerb(0, "Current version of pixman: %s\n",
230 pixman_version_string());
231 xf86ErrorFVerb(0, "\tBefore reporting problems, check "
232 "" __VENDORDWEBSUPPORT__
"\n"
233 "\tto make sure that you have the latest version.\n");
237 xf86PrintMarkers(void)
243 xf86PrivsElevated(void)
245 static Bool privsTested
= FALSE
;
246 static Bool privsElevated
= TRUE
;
250 privsElevated
= FALSE
;
252 if ((getuid() != geteuid()) || (getgid() != getegid())) {
253 privsElevated
= TRUE
;
256 #if defined(HAVE_ISSETUGID)
257 privsElevated
= issetugid();
258 #elif defined(HAVE_GETRESUID)
259 uid_t ruid
, euid
, suid
;
260 gid_t rgid
, egid
, sgid
;
262 if ((getresuid(&ruid
, &euid
, &suid
) == 0) &&
263 (getresgid(&rgid
, &egid
, &sgid
) == 0)) {
264 privsElevated
= (euid
!= suid
) || (egid
!= sgid
);
267 printf("Failed getresuid or getresgid");
268 /* Something went wrong, make defensive assumption */
269 privsElevated
= TRUE
;
273 /* running as root: uid==euid==0 */
274 privsElevated
= FALSE
;
278 * If there are saved ID's the process might still be privileged
279 * even though the above test succeeded. If issetugid() and
280 * getresgid() aren't available, test this by trying to set
283 unsigned int oldeuid
;
287 if (seteuid(0) != 0) {
288 privsElevated
= FALSE
;
291 if (seteuid(oldeuid
) != 0) {
292 FatalError("Failed to drop privileges. Exiting\n");
294 privsElevated
= TRUE
;
302 return privsElevated
;
306 xf86CreateRootWindow(WindowPtr pWin
)
310 ScreenPtr pScreen
= pWin
->drawable
.pScreen
;
311 RootWinPropPtr pProp
;
312 CreateWindowProcPtr CreateWindow
= (CreateWindowProcPtr
)
313 dixLookupPrivate(&pScreen
->devPrivates
, xf86CreateRootWindowKey
);
315 DebugF("xf86CreateRootWindow(%p)\n", pWin
);
317 if (pScreen
->CreateWindow
!= xf86CreateRootWindow
) {
318 /* Can't find hook we are hung on */
319 xf86DrvMsg(pScreen
->myNum
, X_WARNING
/* X_ERROR */ ,
320 "xf86CreateRootWindow %p called when not in pScreen->CreateWindow %p n",
321 (void *) xf86CreateRootWindow
,
322 (void *) pScreen
->CreateWindow
);
325 /* Unhook this function ... */
326 pScreen
->CreateWindow
= CreateWindow
;
327 dixSetPrivate(&pScreen
->devPrivates
, xf86CreateRootWindowKey
, NULL
);
329 /* ... and call the previous CreateWindow fuction, if any */
330 if (NULL
!= pScreen
->CreateWindow
) {
331 ret
= (*pScreen
->CreateWindow
) (pWin
);
334 /* Now do our stuff */
335 if (xf86RegisteredPropertiesTable
!= NULL
) {
336 if (pWin
->parent
== NULL
&& xf86RegisteredPropertiesTable
!= NULL
) {
337 for (pProp
= xf86RegisteredPropertiesTable
[pScreen
->myNum
];
338 pProp
!= NULL
&& err
== Success
; pProp
= pProp
->next
) {
341 prop
= MakeAtom(pProp
->name
, strlen(pProp
->name
), TRUE
);
342 err
= dixChangeWindowProperty(serverClient
, pWin
,
344 pProp
->format
, PropModeReplace
,
345 pProp
->size
, pProp
->data
, FALSE
);
349 ret
&= (err
== Success
);
353 xf86Msg(X_ERROR
, "xf86CreateRootWindow unexpectedly called with "
354 "non-root window %p (parent %p)\n",
355 (void *) pWin
, (void *) pWin
->parent
);
360 DebugF("xf86CreateRootWindow() returns %d\n", ret
);
365 InstallSignalHandlers(void)
368 * Install signal handler for unexpected signals
370 xf86Info
.caughtSignal
= FALSE
;
371 if (!xf86Info
.notrapSignals
) {
372 OsRegisterSigWrapper(xf86SigWrapper
);
375 signal(SIGSEGV
, SIG_DFL
);
376 signal(SIGILL
, SIG_DFL
);
378 signal(SIGEMT
, SIG_DFL
);
380 signal(SIGFPE
, SIG_DFL
);
381 signal(SIGBUS
, SIG_DFL
);
382 signal(SIGSYS
, SIG_DFL
);
383 signal(SIGXCPU
, SIG_DFL
);
384 signal(SIGXFSZ
, SIG_DFL
);
390 * Initialize screenInfo for all actually accessible framebuffers.
391 * That includes vt-manager setup, querying all possible devices and
392 * collecting the pixmap formats.
395 InitOutput(ScreenInfo
* pScreenInfo
, int argc
, char **argv
)
397 int i
, j
, k
, scr_index
;
400 Pix24Flags screenpix24
, pix24
;
401 MessageType pix24From
= X_DEFAULT
;
402 Bool pix24Fail
= FALSE
;
403 Bool autoconfig
= FALSE
;
404 Bool sigio_blocked
= FALSE
;
405 Bool want_hw_access
= FALSE
;
406 GDevPtr configured_device
;
408 xf86Initialising
= TRUE
;
412 if (serverGeneration
== 1) {
413 if ((xf86ServerName
= strrchr(argv
[0], '/')) != 0)
416 xf86ServerName
= argv
[0];
426 xf86MsgVerb(xf86LogFileFrom
, 0, "Log file: \"%s\", Time: %s",
430 /* Read and parse the config file */
431 if (!xf86DoConfigure
&& !xf86DoShowOptions
) {
432 switch (xf86HandleConfigFile(FALSE
)) {
435 case CONFIG_PARSE_ERROR
:
436 xf86Msg(X_ERROR
, "Error parsing the config file\n");
444 InstallSignalHandlers();
446 /* Initialise the loader */
449 /* Tell the loader the default module search path */
450 LoaderSetPath(xf86ModulePath
);
452 if (xf86Info
.ignoreABI
) {
453 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL
);
456 if (xf86DoShowOptions
)
459 /* Do a general bus probe. This will be a PCI probe for x86 platforms */
466 if (!xf86AutoConfig()) {
467 xf86Msg(X_ERROR
, "Auto configuration failed\n");
473 xf86OSPMClose
= xf86OSPMOpen();
478 /* Load all modules specified explicitly in the config file */
479 if ((modulelist
= xf86ModulelistFromConfig(&optionlist
))) {
480 xf86LoadModules(modulelist
, optionlist
);
485 /* Load all driver modules specified in the config file */
486 /* If there aren't any specified in the config file, autoconfig them */
487 /* FIXME: Does not handle multiple active screen sections, but I'm not
488 * sure if we really want to handle that case*/
489 configured_device
= xf86ConfigLayout
.screens
->screen
->device
;
490 if ((!configured_device
) || (!configured_device
->driver
)) {
491 if (!autoConfigDevice(configured_device
)) {
492 xf86Msg(X_ERROR
, "Automatic driver configuration failed\n");
496 if ((modulelist
= xf86DriverlistFromConfig())) {
497 xf86LoadModules(modulelist
, NULL
);
501 /* Load all input driver modules specified in the config file. */
502 if ((modulelist
= xf86InputDriverlistFromConfig())) {
503 xf86LoadModules(modulelist
, NULL
);
508 * It is expected that xf86AddDriver()/xf86AddInputDriver will be
509 * called for each driver as it is loaded. Those functions save the
510 * module pointers for drivers.
511 * XXX Nothing keeps track of them for other modules.
513 /* XXX What do we do if not all of these could be loaded? */
516 * At this point, xf86DriverList[] is all filled in with entries for
517 * each of the drivers to try and xf86NumDrivers has the number of
518 * drivers. If there are none, return now.
521 if (xf86NumDrivers
== 0) {
522 xf86Msg(X_ERROR
, "No drivers available.\n");
527 * Call each of the Identify functions and call the driverFunc to check
528 * if HW access is required. The Identify functions print out some
529 * identifying information, and anything else that might be
530 * needed at this early stage.
533 for (i
= 0; i
< xf86NumDrivers
; i
++) {
534 xorgHWFlags flags
= HW_IO
;
536 if (xf86DriverList
[i
]->Identify
!= NULL
)
537 xf86DriverList
[i
]->Identify(0);
539 if (xf86DriverList
[i
]->driverFunc
)
540 xf86DriverList
[i
]->driverFunc(NULL
,
541 GET_REQUIRED_HW_INTERFACES
,
544 if (NEED_IO_ENABLED(flags
))
545 want_hw_access
= TRUE
;
547 if (!(flags
& HW_SKIP_CONSOLE
))
548 xorgHWOpenConsole
= TRUE
;
551 if (xorgHWOpenConsole
)
554 xf86Info
.dontVTSwitch
= TRUE
;
556 /* Enable full I/O access */
558 xorgHWAccess
= xf86EnableIO();
560 if (xf86BusConfig() == FALSE
)
566 * Sort the drivers to match the requested ording. Using a slow
569 for (j
= 0; j
< xf86NumScreens
- 1; j
++) {
570 for (i
= 0; i
< xf86NumScreens
- j
- 1; i
++) {
571 if (xf86Screens
[i
+ 1]->confScreen
->screennum
<
572 xf86Screens
[i
]->confScreen
->screennum
) {
573 ScrnInfoPtr tmpScrn
= xf86Screens
[i
+ 1];
575 xf86Screens
[i
+ 1] = xf86Screens
[i
];
576 xf86Screens
[i
] = tmpScrn
;
580 /* Fix up the indexes */
581 for (i
= 0; i
< xf86NumScreens
; i
++) {
582 xf86Screens
[i
]->scrnIndex
= i
;
586 * Call the driver's PreInit()'s to complete initialisation for the first
590 for (i
= 0; i
< xf86NumScreens
; i
++) {
591 xf86VGAarbiterScrnInit(xf86Screens
[i
]);
592 xf86VGAarbiterLock(xf86Screens
[i
]);
593 if (xf86Screens
[i
]->PreInit
&&
594 xf86Screens
[i
]->PreInit(xf86Screens
[i
], 0))
595 xf86Screens
[i
]->configured
= TRUE
;
596 xf86VGAarbiterUnlock(xf86Screens
[i
]);
598 for (i
= 0; i
< xf86NumScreens
; i
++)
599 if (!xf86Screens
[i
]->configured
)
600 xf86DeleteScreen(xf86Screens
[i
--]);
602 for (i
= 0; i
< xf86NumGPUScreens
; i
++) {
603 xf86VGAarbiterScrnInit(xf86GPUScreens
[i
]);
604 xf86VGAarbiterLock(xf86GPUScreens
[i
]);
605 if (xf86GPUScreens
[i
]->PreInit
&&
606 xf86GPUScreens
[i
]->PreInit(xf86GPUScreens
[i
], 0))
607 xf86GPUScreens
[i
]->configured
= TRUE
;
608 xf86VGAarbiterUnlock(xf86GPUScreens
[i
]);
610 for (i
= 0; i
< xf86NumGPUScreens
; i
++)
611 if (!xf86GPUScreens
[i
]->configured
)
612 xf86DeleteScreen(xf86GPUScreens
[i
--]);
615 * If no screens left, return now.
618 if (xf86NumScreens
== 0) {
620 "Screen(s) found, but none have a usable configuration.\n");
624 for (i
= 0; i
< xf86NumScreens
; i
++) {
625 if (xf86Screens
[i
]->name
== NULL
) {
626 XNFasprintf(&xf86Screens
[i
]->name
, "screen%d", i
);
627 xf86MsgVerb(X_WARNING
, 0,
628 "Screen driver %d has no name set, using `%s'.\n",
629 i
, xf86Screens
[i
]->name
);
633 /* Remove (unload) drivers that are not required */
634 for (i
= 0; i
< xf86NumDrivers
; i
++)
635 if (xf86DriverList
[i
] && xf86DriverList
[i
]->refCount
<= 0)
639 * At this stage we know how many screens there are.
642 for (i
= 0; i
< xf86NumScreens
; i
++)
643 xf86InitViewport(xf86Screens
[i
]);
646 * Collect all pixmap formats and check for conflicts at the display
647 * level. Should we die here? Or just delete the offending screens?
649 screenpix24
= Pix24DontCare
;
650 for (i
= 0; i
< xf86NumScreens
; i
++) {
651 if (xf86Screens
[i
]->imageByteOrder
!=
652 xf86Screens
[0]->imageByteOrder
)
653 FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
654 if (xf86Screens
[i
]->bitmapScanlinePad
!=
655 xf86Screens
[0]->bitmapScanlinePad
)
657 ("Inconsistent display bitmapScanlinePad. Exiting\n");
658 if (xf86Screens
[i
]->bitmapScanlineUnit
!=
659 xf86Screens
[0]->bitmapScanlineUnit
)
661 ("Inconsistent display bitmapScanlineUnit. Exiting\n");
662 if (xf86Screens
[i
]->bitmapBitOrder
!=
663 xf86Screens
[0]->bitmapBitOrder
)
664 FatalError("Inconsistent display bitmapBitOrder. Exiting\n");
666 /* Determine the depth 24 pixmap format the screens would like */
667 if (xf86Screens
[i
]->pixmap24
!= Pix24DontCare
) {
668 if (screenpix24
== Pix24DontCare
)
669 screenpix24
= xf86Screens
[i
]->pixmap24
;
670 else if (screenpix24
!= xf86Screens
[i
]->pixmap24
)
672 ("Inconsistent depth 24 pixmap format. Exiting\n");
675 /* check if screenpix24 is consistent with the config/cmdline */
676 if (xf86Info
.pixmap24
!= Pix24DontCare
) {
677 pix24
= xf86Info
.pixmap24
;
678 pix24From
= xf86Info
.pix24From
;
679 if (screenpix24
!= Pix24DontCare
&&
680 screenpix24
!= xf86Info
.pixmap24
)
683 else if (screenpix24
!= Pix24DontCare
) {
685 pix24From
= X_PROBED
;
691 FatalError("Screen(s) can't use the required depth 24 pixmap format"
692 " (%d). Exiting\n", PIX24TOBPP(pix24
));
694 /* Initialise the depth 24 format */
695 for (j
= 0; j
< numFormats
&& formats
[j
].depth
!= 24; j
++);
696 formats
[j
].bitsPerPixel
= PIX24TOBPP(pix24
);
698 /* Collect additional formats */
699 for (i
= 0; i
< xf86NumScreens
; i
++) {
700 for (j
= 0; j
< xf86Screens
[i
]->numFormats
; j
++) {
702 if (k
>= numFormats
) {
704 FatalError("Too many pixmap formats! Exiting\n");
705 formats
[k
] = xf86Screens
[i
]->formats
[j
];
709 if (formats
[k
].depth
== xf86Screens
[i
]->formats
[j
].depth
) {
710 if ((formats
[k
].bitsPerPixel
==
711 xf86Screens
[i
]->formats
[j
].bitsPerPixel
) &&
712 (formats
[k
].scanlinePad
==
713 xf86Screens
[i
]->formats
[j
].scanlinePad
))
715 FatalError("Inconsistent pixmap format for depth %d."
716 " Exiting\n", formats
[k
].depth
);
723 if (xf86Info
.vtno
>= 0) {
724 #define VT_ATOM_NAME "XFree86_VT"
729 /* This memory needs to stay available until the screen has been
730 initialized, and we can create the property for real.
732 if ((VT
= malloc(sizeof(CARD32
))) == NULL
) {
734 ("Unable to make VT property - out of memory. Exiting...\n");
738 VTAtom
= MakeAtom(VT_ATOM_NAME
, sizeof(VT_ATOM_NAME
) - 1, TRUE
);
740 for (i
= 0, ret
= Success
; i
< xf86NumScreens
&& ret
== Success
;
743 xf86RegisterRootWindowProperty(xf86Screens
[i
]->scrnIndex
,
744 VTAtom
, XA_INTEGER
, 32, 1,
747 xf86DrvMsg(xf86Screens
[i
]->scrnIndex
, X_WARNING
,
748 "Failed to register VT property\n");
756 MakeAtom(SEAT_ATOM_NAME
, sizeof(SEAT_ATOM_NAME
) - 1, TRUE
);
758 for (i
= 0; i
< xf86NumScreens
; i
++) {
761 ret
= xf86RegisterRootWindowProperty(xf86Screens
[i
]->scrnIndex
,
762 SeatAtom
, XA_STRING
, 8,
765 if (ret
!= Success
) {
766 xf86DrvMsg(xf86Screens
[i
]->scrnIndex
, X_WARNING
,
767 "Failed to register seat property\n");
772 /* If a screen uses depth 24, show what the pixmap format is */
773 for (i
= 0; i
< xf86NumScreens
; i
++) {
774 if (xf86Screens
[i
]->depth
== 24) {
775 xf86Msg(pix24From
, "Depth 24 pixmap format is %d bpp\n",
783 * serverGeneration != 1; some OSs have to do things here, too.
785 if (xorgHWOpenConsole
)
790 should we reopen it here? We need to deal with an already opened
791 device. We could leave this to the OS layer. For now we simply
796 if ((xf86OSPMClose
= xf86OSPMOpen()) != NULL
)
797 xf86MsgVerb(X_INFO
, 3, "APM registered successfully\n");
800 /* Make sure full I/O access is enabled */
806 * Use the previously collected parts to setup pScreenInfo
809 pScreenInfo
->imageByteOrder
= xf86Screens
[0]->imageByteOrder
;
810 pScreenInfo
->bitmapScanlinePad
= xf86Screens
[0]->bitmapScanlinePad
;
811 pScreenInfo
->bitmapScanlineUnit
= xf86Screens
[0]->bitmapScanlineUnit
;
812 pScreenInfo
->bitmapBitOrder
= xf86Screens
[0]->bitmapBitOrder
;
813 pScreenInfo
->numPixmapFormats
= numFormats
;
814 for (i
= 0; i
< numFormats
; i
++)
815 pScreenInfo
->formats
[i
] = formats
[i
];
817 /* Make sure the server's VT is active */
819 if (serverGeneration
!= 1) {
820 xf86Resetting
= TRUE
;
821 /* All screens are in the same state, so just check the first */
822 if (!xf86VTOwner()) {
824 ioctl(xf86Info
.consoleFd
, VT_RELDISP
, VT_ACKACQ
);
828 sigio_blocked
= TRUE
;
832 for (i
= 0; i
< xf86NumScreens
; i
++)
833 if (!xf86ColormapAllocatePrivates(xf86Screens
[i
]))
834 FatalError("Cannot register DDX private keys");
836 if (!dixRegisterPrivateKey(&xf86ScreenKeyRec
, PRIVATE_SCREEN
, 0) ||
837 !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec
, PRIVATE_SCREEN
, 0))
838 FatalError("Cannot register DDX private keys");
840 for (i
= 0; i
< xf86NumGPUScreens
; i
++) {
841 ScrnInfoPtr pScrn
= xf86GPUScreens
[i
];
842 xf86VGAarbiterLock(pScrn
);
845 * Almost everything uses these defaults, and many of those that
846 * don't, will wrap them.
848 pScrn
->EnableDisableFBAccess
= xf86EnableDisableFBAccess
;
850 pScrn
->SetDGAMode
= xf86SetDGAMode
;
852 pScrn
->DPMSSet
= NULL
;
853 pScrn
->LoadPalette
= NULL
;
854 pScrn
->SetOverscan
= NULL
;
855 pScrn
->DriverFunc
= NULL
;
856 pScrn
->pScreen
= NULL
;
857 scr_index
= AddGPUScreen(pScrn
->ScreenInit
, argc
, argv
);
858 xf86VGAarbiterUnlock(pScrn
);
859 if (scr_index
== i
) {
860 dixSetPrivate(&screenInfo
.gpuscreens
[scr_index
]->devPrivates
,
861 xf86ScreenKey
, xf86GPUScreens
[i
]);
862 pScrn
->pScreen
= screenInfo
.gpuscreens
[scr_index
];
863 /* The driver should set this, but make sure it is set anyway */
864 pScrn
->vtSema
= TRUE
;
866 FatalError("AddScreen/ScreenInit failed for gpu driver %d %d\n", i
, scr_index
);
870 for (i
= 0; i
< xf86NumScreens
; i
++) {
871 xf86VGAarbiterLock(xf86Screens
[i
]);
873 * Almost everything uses these defaults, and many of those that
874 * don't, will wrap them.
876 xf86Screens
[i
]->EnableDisableFBAccess
= xf86EnableDisableFBAccess
;
878 xf86Screens
[i
]->SetDGAMode
= xf86SetDGAMode
;
880 xf86Screens
[i
]->DPMSSet
= NULL
;
881 xf86Screens
[i
]->LoadPalette
= NULL
;
882 xf86Screens
[i
]->SetOverscan
= NULL
;
883 xf86Screens
[i
]->DriverFunc
= NULL
;
884 xf86Screens
[i
]->pScreen
= NULL
;
885 scr_index
= AddScreen(xf86Screens
[i
]->ScreenInit
, argc
, argv
);
886 xf86VGAarbiterUnlock(xf86Screens
[i
]);
887 if (scr_index
== i
) {
889 * Hook in our ScrnInfoRec, and initialise some other pScreen
892 dixSetPrivate(&screenInfo
.screens
[scr_index
]->devPrivates
,
893 xf86ScreenKey
, xf86Screens
[i
]);
894 xf86Screens
[i
]->pScreen
= screenInfo
.screens
[scr_index
];
895 /* The driver should set this, but make sure it is set anyway */
896 xf86Screens
[i
]->vtSema
= TRUE
;
899 /* This shouldn't normally happen */
900 FatalError("AddScreen/ScreenInit failed for driver %d\n", i
);
903 DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n",
904 i
, xf86Screens
[i
]->pScreen
);
905 DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n",
906 i
, xf86Screens
[i
]->pScreen
->CreateWindow
);
908 dixSetPrivate(&screenInfo
.screens
[scr_index
]->devPrivates
,
909 xf86CreateRootWindowKey
,
910 xf86Screens
[i
]->pScreen
->CreateWindow
);
911 xf86Screens
[i
]->pScreen
->CreateWindow
= xf86CreateRootWindow
;
913 if (PictureGetSubpixelOrder(xf86Screens
[i
]->pScreen
) == SubPixelUnknown
) {
914 xf86MonPtr DDC
= (xf86MonPtr
) (xf86Screens
[i
]->monitor
->DDC
);
916 PictureSetSubpixelOrder(xf86Screens
[i
]->pScreen
,
918 (DDC
->features
.input_type
?
919 SubPixelHorizontalRGB
: SubPixelNone
) :
923 if (!xf86Info
.disableRandR
)
924 xf86RandRInit(screenInfo
.screens
[scr_index
]);
925 xf86Msg(xf86Info
.randRFrom
, "RandR %s\n",
926 xf86Info
.disableRandR
? "disabled" : "enabled");
930 for (i
= 0; i
< xf86NumGPUScreens
; i
++)
931 AttachUnboundGPU(xf86Screens
[0]->pScreen
, xf86GPUScreens
[i
]->pScreen
);
933 xf86VGAarbiterWrapFunctions();
939 xf86Resetting
= FALSE
;
940 xf86Initialising
= FALSE
;
942 RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr
) NoopDDA
, xf86Wakeup
,
947 * Initialize all supported input devices present and referenced in the
951 InitInput(int argc
, char **argv
)
956 xf86Info
.vtRequestsPending
= FALSE
;
960 /* Initialize all configured input devices */
961 for (pInfo
= xf86ConfigLayout
.inputs
; pInfo
&& *pInfo
; pInfo
++) {
963 xf86AddNewOption((*pInfo
)->options
, "driver", (*pInfo
)->driver
);
965 xf86AddNewOption((*pInfo
)->options
, "identifier", (*pInfo
)->name
);
966 /* If one fails, the others will too */
967 if (NewInputDeviceRequest((*pInfo
)->options
, NULL
, &dev
) == BadAlloc
)
983 * OS/Vendor-specific initialisations. Called from OsInit(), which
984 * is called by dix before establishing the well known sockets.
990 static Bool beenHere
= FALSE
;
992 signal(SIGCHLD
, SIG_DFL
); /* Need to wait for child processes */
999 /* Set stderr to non-blocking. */
1001 #if defined(FNDELAY)
1002 #define O_NONBLOCK FNDELAY
1003 #elif defined(O_NDELAY)
1004 #define O_NONBLOCK O_NDELAY
1009 if (xf86PrivsElevated()) {
1012 status
= fcntl(fileno(stderr
), F_GETFL
, 0);
1014 fcntl(fileno(stderr
), F_SETFL
, status
| O_NONBLOCK
);
1026 * Device dependent cleanup. Called by by dix before normal server death.
1027 * For SYSV386 we must switch the terminal back to normal mode. No error-
1028 * checking here, since there should be restored as much as possible.
1032 ddxGiveUp(enum ExitCode error
)
1036 xf86VGAarbiterFini();
1041 xf86OSPMClose
= NULL
;
1044 for (i
= 0; i
< xf86NumScreens
; i
++) {
1046 * zero all access functions to
1047 * trap calls when switched away.
1049 xf86Screens
[i
]->vtSema
= FALSE
;
1056 if (xorgHWOpenConsole
)
1059 xf86CloseLog(error
);
1061 /* If an unexpected signal was caught, dump a core for debugging */
1062 if (xf86Info
.caughtSignal
)
1068 * DDX - specific abort routine. Called by AbortServer(). The attempt is
1069 * made to restore all original setting of the displays. Also all devices
1074 AbortDDX(enum ExitCode error
)
1081 * try to restore the original video state
1083 #ifdef DPMSExtension /* Turn screens back on */
1084 if (DPMSPowerLevel
!= DPMSModeOn
)
1085 DPMSSet(serverClient
, DPMSModeOn
);
1088 for (i
= 0; i
< xf86NumScreens
; i
++)
1089 if (xf86Screens
[i
]->vtSema
) {
1091 * if we are aborting before ScreenInit() has finished
1092 * we might not have been wrapped yet. Therefore enable
1093 * screen explicitely.
1095 xf86VGAarbiterLock(xf86Screens
[i
]);
1096 (xf86Screens
[i
]->LeaveVT
) (xf86Screens
[i
]);
1097 xf86VGAarbiterUnlock(xf86Screens
[i
]);
1104 * This is needed for an abnormal server exit, since the normal exit stuff
1105 * MUST also be performed (i.e. the vt must be left in a defined state)
1111 OsVendorFatalError(const char *f
, va_list args
)
1113 #ifdef VENDORSUPPORT
1114 ErrorFSigSafe("\nPlease refer to your Operating System Vendor support "
1115 "pages\nat %s for support on this crash.\n", VENDORSUPPORT
);
1117 ErrorFSigSafe("\nPlease consult the " XVENDORNAME
" support \n\t at "
1118 __VENDORDWEBSUPPORT__
"\n for help. \n");
1120 if (xf86LogFile
&& xf86LogFileWasOpened
)
1121 ErrorFSigSafe("Please also check the log file at \"%s\" for additional "
1122 "information.\n", xf86LogFile
);
1123 ErrorFSigSafe("\n");
1127 xf86SetVerbosity(int verb
)
1129 int save
= xf86Verbose
;
1132 LogSetParameter(XLOG_VERBOSITY
, verb
);
1137 xf86SetLogVerbosity(int verb
)
1139 int save
= xf86LogVerbose
;
1141 xf86LogVerbose
= verb
;
1142 LogSetParameter(XLOG_FILE_VERBOSITY
, verb
);
1147 xf86PrintDefaultModulePath(void)
1149 ErrorF("%s\n", DEFAULT_MODULE_PATH
);
1153 xf86PrintDefaultLibraryPath(void)
1155 ErrorF("%s\n", DEFAULT_LIBRARY_PATH
);
1159 * ddxProcessArgument --
1160 * Process device-dependent command line args. Returns 0 if argument is
1161 * not device dependent, otherwise Count of number of elements of argv
1162 * that are part of a device dependent commandline option.
1168 ddxProcessArgument(int argc
, char **argv
, int i
)
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 not allowed with elevated privileges */
1178 if (!strcmp(argv
[i
], "-modulepath") || !strcmp(argv
[i
], "-logfile")) {
1179 if (xf86PrivsElevated()) {
1180 FatalError("The '%s' option cannot be used with "
1181 "elevated privileges.\n", argv
[i
]);
1183 else if (!strcmp(argv
[i
], "-modulepath")) {
1186 CHECK_FOR_REQUIRED_ARGUMENT();
1187 mp
= strdup(argv
[i
+ 1]);
1189 FatalError("Can't allocate memory for ModulePath\n");
1190 xf86ModulePath
= mp
;
1191 xf86ModPathFrom
= X_CMDLINE
;
1194 else if (!strcmp(argv
[i
], "-logfile")) {
1197 CHECK_FOR_REQUIRED_ARGUMENT();
1198 lf
= strdup(argv
[i
+ 1]);
1200 FatalError("Can't allocate memory for LogFile\n");
1202 xf86LogFileFrom
= X_CMDLINE
;
1206 if (!strcmp(argv
[i
], "-config") || !strcmp(argv
[i
], "-xf86config")) {
1207 CHECK_FOR_REQUIRED_ARGUMENT();
1208 if (xf86PrivsElevated() && !xf86PathIsSafe(argv
[i
+ 1])) {
1209 FatalError("\nInvalid argument for %s\n"
1210 "\tWith elevated privileges, the file specified with %s must be\n"
1211 "\ta relative path and must not contain any \"..\" elements.\n"
1212 "\tUsing default " __XCONFIGFILE__
" search path.\n\n",
1215 xf86ConfigFile
= argv
[i
+ 1];
1218 if (!strcmp(argv
[i
], "-configdir")) {
1219 CHECK_FOR_REQUIRED_ARGUMENT();
1220 if (xf86PrivsElevated() && !xf86PathIsSafe(argv
[i
+ 1])) {
1221 FatalError("\nInvalid argument for %s\n"
1222 "\tWith elevated privileges, the file specified with %s must be\n"
1223 "\ta relative path and must not contain any \"..\" elements.\n"
1224 "\tUsing default " __XCONFIGDIR__
" search path.\n\n",
1227 xf86ConfigDir
= argv
[i
+ 1];
1230 if (!strcmp(argv
[i
], "-flipPixels")) {
1231 xf86FlipPixels
= TRUE
;
1235 if (!strcmp(argv
[i
], "-disableVidMode")) {
1236 xf86VidModeDisabled
= TRUE
;
1239 if (!strcmp(argv
[i
], "-allowNonLocalXvidtune")) {
1240 xf86VidModeAllowNonLocal
= TRUE
;
1244 if (!strcmp(argv
[i
], "-allowMouseOpenFail")) {
1245 xf86AllowMouseOpenFail
= TRUE
;
1248 if (!strcmp(argv
[i
], "-ignoreABI")) {
1249 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL
);
1252 if (!strcmp(argv
[i
], "-verbose")) {
1253 if (++i
< argc
&& argv
[i
]) {
1257 val
= strtol(argv
[i
], &end
, 0);
1259 xf86SetVerbosity(val
);
1263 xf86SetVerbosity(++xf86Verbose
);
1266 if (!strcmp(argv
[i
], "-logverbose")) {
1267 if (++i
< argc
&& argv
[i
]) {
1271 val
= strtol(argv
[i
], &end
, 0);
1273 xf86SetLogVerbosity(val
);
1277 xf86SetLogVerbosity(++xf86LogVerbose
);
1280 if (!strcmp(argv
[i
], "-quiet")) {
1281 xf86SetVerbosity(-1);
1284 if (!strcmp(argv
[i
], "-showconfig") || !strcmp(argv
[i
], "-version")) {
1288 if (!strcmp(argv
[i
], "-showDefaultModulePath")) {
1289 xf86PrintDefaultModulePath();
1292 if (!strcmp(argv
[i
], "-showDefaultLibPath")) {
1293 xf86PrintDefaultLibraryPath();
1296 /* Notice the -fp flag, but allow it to pass to the dix layer */
1297 if (!strcmp(argv
[i
], "-fp")) {
1301 /* Notice the -bs flag, but allow it to pass to the dix layer */
1302 if (!strcmp(argv
[i
], "-bs")) {
1303 xf86bsDisableFlag
= TRUE
;
1306 /* Notice the +bs flag, but allow it to pass to the dix layer */
1307 if (!strcmp(argv
[i
], "+bs")) {
1308 xf86bsEnableFlag
= TRUE
;
1311 /* Notice the -s flag, but allow it to pass to the dix layer */
1312 if (!strcmp(argv
[i
], "-s")) {
1316 if (!strcmp(argv
[i
], "-pixmap24")) {
1317 xf86Pix24
= Pix24Use24
;
1320 if (!strcmp(argv
[i
], "-pixmap32")) {
1321 xf86Pix24
= Pix24Use32
;
1324 if (!strcmp(argv
[i
], "-fbbpp")) {
1327 CHECK_FOR_REQUIRED_ARGUMENT();
1328 if (sscanf(argv
[++i
], "%d", &bpp
) == 1) {
1333 ErrorF("Invalid fbbpp\n");
1337 if (!strcmp(argv
[i
], "-depth")) {
1340 CHECK_FOR_REQUIRED_ARGUMENT();
1341 if (sscanf(argv
[++i
], "%d", &depth
) == 1) {
1346 ErrorF("Invalid depth\n");
1350 if (!strcmp(argv
[i
], "-weight")) {
1351 int red
, green
, blue
;
1353 CHECK_FOR_REQUIRED_ARGUMENT();
1354 if (sscanf(argv
[++i
], "%1d%1d%1d", &red
, &green
, &blue
) == 3) {
1355 xf86Weight
.red
= red
;
1356 xf86Weight
.green
= green
;
1357 xf86Weight
.blue
= blue
;
1361 ErrorF("Invalid weighting\n");
1365 if (!strcmp(argv
[i
], "-gamma") || !strcmp(argv
[i
], "-rgamma") ||
1366 !strcmp(argv
[i
], "-ggamma") || !strcmp(argv
[i
], "-bgamma")) {
1369 CHECK_FOR_REQUIRED_ARGUMENT();
1370 if (sscanf(argv
[++i
], "%lf", &gamma
) == 1) {
1371 if (gamma
< GAMMA_MIN
|| gamma
> GAMMA_MAX
) {
1372 ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f"
1373 " is valid\n", GAMMA_MIN
, GAMMA_MAX
);
1376 if (!strcmp(argv
[i
- 1], "-gamma"))
1377 xf86Gamma
.red
= xf86Gamma
.green
= xf86Gamma
.blue
= gamma
;
1378 else if (!strcmp(argv
[i
- 1], "-rgamma"))
1379 xf86Gamma
.red
= gamma
;
1380 else if (!strcmp(argv
[i
- 1], "-ggamma"))
1381 xf86Gamma
.green
= gamma
;
1382 else if (!strcmp(argv
[i
- 1], "-bgamma"))
1383 xf86Gamma
.blue
= gamma
;
1387 if (!strcmp(argv
[i
], "-layout")) {
1388 CHECK_FOR_REQUIRED_ARGUMENT();
1389 xf86LayoutName
= argv
[++i
];
1392 if (!strcmp(argv
[i
], "-screen")) {
1393 CHECK_FOR_REQUIRED_ARGUMENT();
1394 xf86ScreenName
= argv
[++i
];
1397 if (!strcmp(argv
[i
], "-pointer")) {
1398 CHECK_FOR_REQUIRED_ARGUMENT();
1399 xf86PointerName
= argv
[++i
];
1402 if (!strcmp(argv
[i
], "-keyboard")) {
1403 CHECK_FOR_REQUIRED_ARGUMENT();
1404 xf86KeyboardName
= argv
[++i
];
1407 if (!strcmp(argv
[i
], "-nosilk")) {
1408 xf86silkenMouseDisableFlag
= TRUE
;
1412 if (!strcmp(argv
[i
], "-noacpi")) {
1413 xf86acpiDisableFlag
= TRUE
;
1417 if (!strcmp(argv
[i
], "-configure")) {
1418 if (getuid() != 0 && geteuid() == 0) {
1419 ErrorF("The '-configure' option can only be used by root.\n");
1422 xf86DoConfigure
= TRUE
;
1423 xf86AllowMouseOpenFail
= TRUE
;
1426 if (!strcmp(argv
[i
], "-showopts")) {
1427 if (getuid() != 0 && geteuid() == 0) {
1428 ErrorF("The '-showopts' option can only be used by root.\n");
1431 xf86DoShowOptions
= TRUE
;
1434 #ifdef XSERVER_LIBPCIACCESS
1435 if (!strcmp(argv
[i
], "-isolateDevice")) {
1436 CHECK_FOR_REQUIRED_ARGUMENT();
1437 if (strncmp(argv
[++i
], "PCI:", 4)) {
1438 FatalError("Bus types other than PCI not yet isolable\n");
1440 xf86PciIsolateDevice(argv
[i
]);
1444 /* Notice cmdline xkbdir, but pass to dix as well */
1445 if (!strcmp(argv
[i
], "-xkbdir")) {
1446 xf86xkbdirFlag
= TRUE
;
1449 if (!strcmp(argv
[i
], "-novtswitch")) {
1450 xf86Info
.autoVTSwitch
= FALSE
;
1453 if (!strcmp(argv
[i
], "-sharevts")) {
1454 xf86Info
.ShareVTs
= TRUE
;
1458 /* OS-specific processing */
1459 return xf86ProcessArgument(argc
, argv
, i
);
1464 * Print out correct use of device dependent commandline options.
1465 * Maybe the user now knows what really to do ...
1473 ErrorF("Device Dependent Usage\n");
1474 if (!xf86PrivsElevated()) {
1475 ErrorF("-modulepath paths specify the module search path\n");
1476 ErrorF("-logfile file specify a log file name\n");
1477 ErrorF("-configure probe for devices and write an "
1478 __XCONFIGFILE__
"\n");
1480 ("-showopts print available options for all installed drivers\n");
1483 ("-config file specify a configuration file, relative to the\n");
1484 ErrorF(" " __XCONFIGFILE__
1485 " search path, only root can use absolute\n");
1487 ("-configdir dir specify a configuration directory, relative to the\n");
1488 ErrorF(" " __XCONFIGDIR__
1489 " search path, only root can use absolute\n");
1490 ErrorF("-verbose [n] verbose startup messages\n");
1491 ErrorF("-logverbose [n] verbose log messages\n");
1492 ErrorF("-quiet minimal startup messages\n");
1493 ErrorF("-pixmap24 use 24bpp pixmaps for depth 24\n");
1494 ErrorF("-pixmap32 use 32bpp pixmaps for depth 24\n");
1495 ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n");
1496 ErrorF("-depth n set colour depth. Default: 8\n");
1498 ("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n");
1499 ErrorF("-rgamma f set gamma value for red phase\n");
1500 ErrorF("-ggamma f set gamma value for green phase\n");
1501 ErrorF("-bgamma f set gamma value for blue phase\n");
1503 ("-weight nnn set RGB weighting at 16 bpp. Default: 565\n");
1504 ErrorF("-layout name specify the ServerLayout section name\n");
1505 ErrorF("-screen name specify the Screen section name\n");
1507 ("-keyboard name specify the core keyboard InputDevice name\n");
1509 ("-pointer name specify the core pointer InputDevice name\n");
1510 ErrorF("-nosilk disable Silken Mouse\n");
1511 ErrorF("-flipPixels swap default black/white Pixel values\n");
1513 ErrorF("-disableVidMode disable mode adjustments with xvidtune\n");
1515 ("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n");
1518 ("-allowMouseOpenFail start server even if the mouse can't be initialized\n");
1519 ErrorF("-ignoreABI make module ABI mismatches non-fatal\n");
1520 #ifdef XSERVER_LIBPCIACCESS
1522 ("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n");
1524 ErrorF("-version show the server version\n");
1525 ErrorF("-showDefaultModulePath show the server default module path\n");
1526 ErrorF("-showDefaultLibPath show the server default library path\n");
1528 ("-novtswitch don't automatically switch VT at reset & exit\n");
1529 ErrorF("-sharevts share VTs with another X server\n");
1530 /* OS-specific usage */
1536 * xf86LoadModules iterates over a list that is being passed in.
1539 xf86LoadModules(char **list
, pointer
*optlist
)
1545 Bool failed
= FALSE
;
1550 for (i
= 0; list
[i
] != NULL
; i
++) {
1552 /* Normalise the module name */
1553 name
= xf86NormalizeName(list
[i
]);
1555 /* Skip empty names */
1556 if (name
== NULL
|| *name
== '\0') {
1561 /* Replace obsolete keyboard driver with kbd */
1562 if (!xf86NameCmp(name
, "keyboard")) {
1563 strcpy(name
, "kbd");
1571 if (!LoadModule(name
, NULL
, NULL
, NULL
, opt
, NULL
, &errmaj
, &errmin
)) {
1572 LoaderErrorMsg(NULL
, name
, errmaj
, errmin
);
1580 /* Pixmap format stuff */
1583 xf86GetPixFormat(ScrnInfoPtr pScrn
, int depth
)
1586 static PixmapFormatRec format
; /* XXX not reentrant */
1589 * When the formats[] list initialisation isn't complete, check the
1590 * depth 24 pixmap config/cmdline options and screen-specified formats.
1595 Pix24Flags pix24
= Pix24DontCare
;
1598 format
.scanlinePad
= BITMAP_SCANLINE_PAD
;
1599 if (xf86Info
.pixmap24
!= Pix24DontCare
)
1600 pix24
= xf86Info
.pixmap24
;
1601 else if (pScrn
->pixmap24
!= Pix24DontCare
)
1602 pix24
= pScrn
->pixmap24
;
1603 if (pix24
== Pix24Use24
)
1604 format
.bitsPerPixel
= 24;
1606 format
.bitsPerPixel
= 32;
1611 for (i
= 0; i
< numFormats
; i
++)
1612 if (formats
[i
].depth
== depth
)
1614 if (i
!= numFormats
)
1616 else if (!formatsDone
) {
1617 /* Check for screen-specified formats */
1618 for (i
= 0; i
< pScrn
->numFormats
; i
++)
1619 if (pScrn
->formats
[i
].depth
== depth
)
1621 if (i
!= pScrn
->numFormats
)
1622 return &pScrn
->formats
[i
];
1628 xf86GetBppFromDepth(ScrnInfoPtr pScrn
, int depth
)
1630 PixmapFormatPtr format
;
1632 format
= xf86GetPixFormat(pScrn
, depth
);
1634 return format
->bitsPerPixel
;
1639 #ifdef DDXBEFORERESET
1641 ddxBeforeReset(void)