1/* 2 * Loosely based on code bearing the following copyright: 3 * 4 * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany. 5 */ 6/* 7 * Copyright (c) 1992-2003 by The XFree86 Project, Inc. 8 * 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: 15 * 16 * The above copyright notice and this permission notice shall be included in 17 * all copies or substantial portions of the Software. 18 * 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. 26 * 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). 31 */ 32 33#ifdef HAVE_XORG_CONFIG_H 34#include <xorg-config.h> 35#endif 36 37#include <stdlib.h> 38#include <errno.h> 39 40#undef HAS_UTSNAME 41#if !defined(WIN32) 42#define HAS_UTSNAME 1 43#include <sys/utsname.h> 44#endif 45 46#include <X11/X.h> 47#include <X11/Xmd.h> 48#include <X11/Xproto.h> 49#include <X11/Xatom.h> 50#include "input.h" 51#include "servermd.h" 52#include "windowstr.h" 53#include "scrnintstr.h" 54#include "mi.h" 55#include "dbus-core.h" 56#include "systemd-logind.h" 57 58#include "loaderProcs.h" 59 60#define XF86_OS_PRIVS 61#include "xf86.h" 62#include "xf86Priv.h" 63#include "xf86Config.h" 64#include "xf86_OSlib.h" 65#include "xf86cmap.h" 66#include "xorgVersion.h" 67#include "mipointer.h" 68#include <X11/extensions/XI.h> 69#include <X11/extensions/XIproto.h> 70#include "xf86Extensions.h" 71#include "xf86DDC.h" 72#include "xf86Xinput.h" 73#include "xf86InPriv.h" 74#include "xf86Crtc.h" 75#include "picturestr.h" 76#include "randrstr.h" 77#include "xf86Bus.h" 78#ifdef XSERVER_LIBPCIACCESS 79#include "xf86VGAarbiter.h" 80#endif 81#include "globals.h" 82#include "xserver-properties.h" 83 84#ifdef DPMSExtension 85#include <X11/extensions/dpmsconst.h> 86#include "dpmsproc.h" 87#endif 88 89#ifdef __linux__ 90#include <linux/major.h> 91#include <sys/sysmacros.h> 92#endif 93#include <hotplug.h> 94 95void (*xf86OSPMClose) (void) = NULL; 96static Bool xorgHWOpenConsole = FALSE; 97 98/* Common pixmap formats */ 99 100static 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}, 108}; 109 110static int numFormats = 7; 111static Bool formatsDone = FALSE; 112 113 114static void 115xf86PrintBanner(void) 116{ 117 xf86ErrorFVerb(0, "\nX.Org X Server %d.%d.%d", 118 XORG_VERSION_MAJOR, XORG_VERSION_MINOR, XORG_VERSION_PATCH); 119#if XORG_VERSION_SNAP > 0 120 xf86ErrorFVerb(0, ".%d", XORG_VERSION_SNAP); 121#endif 122 123#if XORG_VERSION_SNAP >= 900 124 /* When the minor number is 99, that signifies that the we are making 125 * a release candidate for a major version. (X.0.0) 126 * When the patch number is 99, that signifies that the we are making 127 * a release candidate for a minor version. (X.Y.0) 128 * When the patch number is < 99, then we are making a release 129 * candidate for the next point release. (X.Y.Z) 130 */ 131#if XORG_VERSION_MINOR >= 99 132 xf86ErrorFVerb(0, " (%d.0.0 RC %d)", XORG_VERSION_MAJOR + 1, 133 XORG_VERSION_SNAP - 900); 134#elif XORG_VERSION_PATCH == 99 135 xf86ErrorFVerb(0, " (%d.%d.0 RC %d)", XORG_VERSION_MAJOR, 136 XORG_VERSION_MINOR + 1, XORG_VERSION_SNAP - 900); 137#else 138 xf86ErrorFVerb(0, " (%d.%d.%d RC %d)", XORG_VERSION_MAJOR, 139 XORG_VERSION_MINOR, XORG_VERSION_PATCH + 1, 140 XORG_VERSION_SNAP - 900); 141#endif 142#endif 143 144#ifdef XORG_CUSTOM_VERSION 145 xf86ErrorFVerb(0, " (%s)", XORG_CUSTOM_VERSION); 146#endif 147 xf86ErrorFVerb(0, "\nX Protocol Version %d, Revision %d\n", 148 X_PROTOCOL, X_PROTOCOL_REVISION); 149#ifdef HAS_UTSNAME 150 { 151 struct utsname name; 152 153 /* Linux & BSD state that 0 is success, SysV (including Solaris, HP-UX, 154 and Irix) and Single Unix Spec 3 just say that non-negative is success. 155 All agree that failure is represented by a negative number. 156 */ 157 if (uname(&name) >= 0) { 158 xf86ErrorFVerb(0, "Current Operating System: %s %s %s %s %s\n", 159 name.sysname, name.nodename, name.release, 160 name.version, name.machine); 161#ifdef __linux__ 162 do { 163 char buf[80]; 164 int fd = open("/proc/cmdline", O_RDONLY); 165 166 if (fd != -1) { 167 xf86ErrorFVerb(0, "Kernel command line: "); 168 memset(buf, 0, 80); 169 while (read(fd, buf, 80) > 0) { 170 xf86ErrorFVerb(0, "%.80s", buf); 171 memset(buf, 0, 80); 172 } 173 close(fd); 174 } 175 } while (0); 176#endif 177 } 178 } 179#endif 180#if defined(BUILDERSTRING) 181 xf86ErrorFVerb(0, "%s \n", BUILDERSTRING); 182#endif 183 xf86ErrorFVerb(0, "Current version of pixman: %s\n", 184 pixman_version_string()); 185 xf86ErrorFVerb(0, "\tBefore reporting problems, check " 186 "" __VENDORDWEBSUPPORT__ "\n" 187 "\tto make sure that you have the latest version.\n"); 188} 189 190Bool 191xf86PrivsElevated(void) 192{ 193 return PrivsElevated(); 194} 195 196Bool 197xf86HasTTYs(void) 198{ 199#ifdef __linux__ 200 struct stat tty0devAttributes; 201 return (stat("/dev/tty0", &tty0devAttributes) == 0 && major(tty0devAttributes.st_rdev) == TTY_MAJOR); 202#else 203 return TRUE; 204#endif 205} 206 207static void 208xf86AutoConfigOutputDevices(void) 209{ 210 int i; 211 212 if (!xf86Info.autoBindGPU) 213 return; 214 215 for (i = 0; i < xf86NumGPUScreens; i++) { 216 int scrnum = xf86GPUScreens[i]->confScreen->screennum; 217 RRProviderAutoConfigGpuScreen(xf86ScrnToScreen(xf86GPUScreens[i]), 218 xf86ScrnToScreen(xf86Screens[scrnum])); 219 } 220} 221 222static void 223AddSeatId(CallbackListPtr *pcbl, void *data, void *screen) 224{ 225 ScreenPtr pScreen = screen; 226 Atom SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE); 227 int err; 228 229 err = dixChangeWindowProperty(serverClient, pScreen->root, SeatAtom, 230 XA_STRING, 8, PropModeReplace, 231 strlen(data) + 1, data, FALSE); 232 233 if (err != Success) 234 xf86DrvMsg(pScreen->myNum, X_WARNING, 235 "Failed to register seat property\n"); 236} 237 238static void 239AddVTAtoms(CallbackListPtr *pcbl, void *data, void *screen) 240{ 241#define VT_ATOM_NAME "XFree86_VT" 242 int err, HasVT = 1; 243 ScreenPtr pScreen = screen; 244 Atom VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE); 245 Atom HasVTAtom = MakeAtom(HAS_VT_ATOM_NAME, sizeof(HAS_VT_ATOM_NAME) - 1, 246 TRUE); 247 248 err = dixChangeWindowProperty(serverClient, pScreen->root, VTAtom, 249 XA_INTEGER, 32, PropModeReplace, 1, 250 &xf86Info.vtno, FALSE); 251 252 err |= dixChangeWindowProperty(serverClient, pScreen->root, HasVTAtom, 253 XA_INTEGER, 32, PropModeReplace, 1, 254 &HasVT, FALSE); 255 256 if (err != Success) 257 xf86DrvMsg(pScreen->myNum, X_WARNING, 258 "Failed to register VT properties\n"); 259} 260 261static Bool 262xf86ScreenInit(ScreenPtr pScreen, int argc, char **argv) 263{ 264 ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); 265 266 pScrn->pScreen = pScreen; 267 return pScrn->ScreenInit (pScreen, argc, argv); 268} 269 270static void 271xf86EnsureRANDR(ScreenPtr pScreen) 272{ 273#ifdef RANDR 274 if (!dixPrivateKeyRegistered(rrPrivKey) || 275 !rrGetScrPriv(pScreen)) 276 xf86RandRInit(pScreen); 277#endif 278} 279 280/* 281 * InitOutput -- 282 * Initialize screenInfo for all actually accessible framebuffers. 283 * That includes vt-manager setup, querying all possible devices and 284 * collecting the pixmap formats. 285 */ 286void 287InitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) 288{ 289 int i, j, k, scr_index; 290 const char **modulelist; 291 void **optionlist; 292 Bool autoconfig = FALSE; 293 Bool sigio_blocked = FALSE; 294 Bool want_hw_access = FALSE; 295 GDevPtr configured_device; 296 297 xf86Initialising = TRUE; 298 299 config_pre_init(); 300 301 if (serverGeneration == 1) { 302 xf86PrintBanner(); 303 LogPrintMarkers(); 304 if (xf86LogFile) { 305 time_t t; 306 const char *ct; 307 308 t = time(NULL); 309 ct = ctime(&t); 310 xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s", 311 xf86LogFile, ct); 312 } 313 314 /* Read and parse the config file */ 315 if (!xf86DoConfigure && !xf86DoShowOptions) { 316 switch (xf86HandleConfigFile(FALSE)) { 317 case CONFIG_OK: 318 break; 319 case CONFIG_PARSE_ERROR: 320 xf86Msg(X_ERROR, "Error parsing the config file\n"); 321 return; 322 case CONFIG_NOFILE: 323 autoconfig = TRUE; 324 break; 325 } 326 } 327 328 /* Initialise the loader */ 329 LoaderInit(); 330 331 /* Tell the loader the default module search path */ 332 LoaderSetPath(xf86ModulePath); 333 334 if (xf86Info.ignoreABI) { 335 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); 336 } 337 338 if (xf86DoShowOptions) 339 DoShowOptions(); 340 341 dbus_core_init(); 342 systemd_logind_init(); 343 344 /* Do a general bus probe. This will be a PCI probe for x86 platforms */ 345 xf86BusProbe(); 346 347 if (xf86DoConfigure) 348 DoConfigure(); 349 350 if (autoconfig) { 351 if (!xf86AutoConfig()) { 352 xf86Msg(X_ERROR, "Auto configuration failed\n"); 353 return; 354 } 355 } 356 357 xf86OSPMClose = xf86OSPMOpen(); 358 359 xf86ExtensionInit(); 360 361 /* Load all modules specified explicitly in the config file */ 362 if ((modulelist = xf86ModulelistFromConfig(&optionlist))) { 363 xf86LoadModules(modulelist, optionlist); 364 free(modulelist); 365 free(optionlist); 366 } 367 368 /* Load all driver modules specified in the config file */ 369 /* If there aren't any specified in the config file, autoconfig them */ 370 /* FIXME: Does not handle multiple active screen sections, but I'm not 371 * sure if we really want to handle that case*/ 372 configured_device = xf86ConfigLayout.screens->screen->device; 373 if ((!configured_device) || (!configured_device->driver)) { 374 if (!autoConfigDevice(configured_device)) { 375 xf86Msg(X_ERROR, "Automatic driver configuration failed\n"); 376 return; 377 } 378 } 379 if ((modulelist = xf86DriverlistFromConfig())) { 380 xf86LoadModules(modulelist, NULL); 381 free(modulelist); 382 } 383 384 /* Load all input driver modules specified in the config file. */ 385 if ((modulelist = xf86InputDriverlistFromConfig())) { 386 xf86LoadModules(modulelist, NULL); 387 free(modulelist); 388 } 389 390 /* 391 * It is expected that xf86AddDriver()/xf86AddInputDriver will be 392 * called for each driver as it is loaded. Those functions save the 393 * module pointers for drivers. 394 * XXX Nothing keeps track of them for other modules. 395 */ 396 /* XXX What do we do if not all of these could be loaded? */ 397 398 /* 399 * At this point, xf86DriverList[] is all filled in with entries for 400 * each of the drivers to try and xf86NumDrivers has the number of 401 * drivers. If there are none, return now. 402 */ 403 404 if (xf86NumDrivers == 0) { 405 xf86Msg(X_ERROR, "No drivers available.\n"); 406 return; 407 } 408 409 /* 410 * Call each of the Identify functions and call the driverFunc to check 411 * if HW access is required. The Identify functions print out some 412 * identifying information, and anything else that might be 413 * needed at this early stage. 414 */ 415 416 for (i = 0; i < xf86NumDrivers; i++) { 417 xorgHWFlags flags = HW_IO; 418 419 if (xf86DriverList[i]->Identify != NULL) 420 xf86DriverList[i]->Identify(0); 421 422 if (xf86DriverList[i]->driverFunc) 423 xf86DriverList[i]->driverFunc(NULL, 424 GET_REQUIRED_HW_INTERFACES, 425 &flags); 426 427 if (NEED_IO_ENABLED(flags)) 428 want_hw_access = TRUE; 429 430 /* Non-seat0 X servers should not open console */ 431 if (!(flags & HW_SKIP_CONSOLE) && !ServerIsNotSeat0() && xf86HasTTYs()) 432 xorgHWOpenConsole = TRUE; 433 } 434 435 if (xorgHWOpenConsole) 436 xf86OpenConsole(); 437 else 438 xf86Info.dontVTSwitch = TRUE; 439 440 /* Enable full I/O access */ 441 if (want_hw_access) 442 xorgHWAccess = xf86EnableIO(); 443 444 if (xf86BusConfig() == FALSE) 445 return; 446 447 xf86PostProbe(); 448 449 /* 450 * Sort the drivers to match the requested ording. Using a slow 451 * bubble sort. 452 */ 453 for (j = 0; j < xf86NumScreens - 1; j++) { 454 for (i = 0; i < xf86NumScreens - j - 1; i++) { 455 if (xf86Screens[i + 1]->confScreen->screennum < 456 xf86Screens[i]->confScreen->screennum) { 457 ScrnInfoPtr tmpScrn = xf86Screens[i + 1]; 458 459 xf86Screens[i + 1] = xf86Screens[i]; 460 xf86Screens[i] = tmpScrn; 461 } 462 } 463 } 464 /* Fix up the indexes */ 465 for (i = 0; i < xf86NumScreens; i++) { 466 xf86Screens[i]->scrnIndex = i; 467 } 468 469 /* 470 * Call the driver's PreInit()'s to complete initialisation for the first 471 * generation. 472 */ 473 474 for (i = 0; i < xf86NumScreens; i++) { 475 xf86VGAarbiterScrnInit(xf86Screens[i]); 476 xf86VGAarbiterLock(xf86Screens[i]); 477 if (xf86Screens[i]->PreInit && 478 xf86Screens[i]->PreInit(xf86Screens[i], 0)) 479 xf86Screens[i]->configured = TRUE; 480 xf86VGAarbiterUnlock(xf86Screens[i]); 481 } 482 for (i = 0; i < xf86NumScreens; i++) 483 if (!xf86Screens[i]->configured) 484 xf86DeleteScreen(xf86Screens[i--]); 485 486 for (i = 0; i < xf86NumGPUScreens; i++) { 487 xf86VGAarbiterScrnInit(xf86GPUScreens[i]); 488 xf86VGAarbiterLock(xf86GPUScreens[i]); 489 if (xf86GPUScreens[i]->PreInit && 490 xf86GPUScreens[i]->PreInit(xf86GPUScreens[i], 0)) 491 xf86GPUScreens[i]->configured = TRUE; 492 xf86VGAarbiterUnlock(xf86GPUScreens[i]); 493 } 494 for (i = 0; i < xf86NumGPUScreens; i++) 495 if (!xf86GPUScreens[i]->configured) 496 xf86DeleteScreen(xf86GPUScreens[i--]); 497 498 /* 499 * If no screens left, return now. 500 */ 501 502 if (xf86NumScreens == 0) { 503 xf86Msg(X_ERROR, 504 "Screen(s) found, but none have a usable configuration.\n"); 505 return; 506 } 507 508 /* Remove (unload) drivers that are not required */ 509 for (i = 0; i < xf86NumDrivers; i++) 510 if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0) 511 xf86DeleteDriver(i); 512 513 /* 514 * At this stage we know how many screens there are. 515 */ 516 517 for (i = 0; i < xf86NumScreens; i++) 518 xf86InitViewport(xf86Screens[i]); 519 520 /* 521 * Collect all pixmap formats and check for conflicts at the display 522 * level. Should we die here? Or just delete the offending screens? 523 */ 524 for (i = 0; i < xf86NumScreens; i++) { 525 if (xf86Screens[i]->imageByteOrder != 526 xf86Screens[0]->imageByteOrder) 527 FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); 528 if (xf86Screens[i]->bitmapScanlinePad != 529 xf86Screens[0]->bitmapScanlinePad) 530 FatalError 531 ("Inconsistent display bitmapScanlinePad. Exiting\n"); 532 if (xf86Screens[i]->bitmapScanlineUnit != 533 xf86Screens[0]->bitmapScanlineUnit) 534 FatalError 535 ("Inconsistent display bitmapScanlineUnit. Exiting\n"); 536 if (xf86Screens[i]->bitmapBitOrder != 537 xf86Screens[0]->bitmapBitOrder) 538 FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); 539 } 540 541 /* Collect additional formats */ 542 for (i = 0; i < xf86NumScreens; i++) { 543 for (j = 0; j < xf86Screens[i]->numFormats; j++) { 544 for (k = 0;; k++) { 545 if (k >= numFormats) { 546 if (k >= MAXFORMATS) 547 FatalError("Too many pixmap formats! Exiting\n"); 548 formats[k] = xf86Screens[i]->formats[j]; 549 numFormats++; 550 break; 551 } 552 if (formats[k].depth == xf86Screens[i]->formats[j].depth) { 553 if ((formats[k].bitsPerPixel == 554 xf86Screens[i]->formats[j].bitsPerPixel) && 555 (formats[k].scanlinePad == 556 xf86Screens[i]->formats[j].scanlinePad)) 557 break; 558 FatalError("Inconsistent pixmap format for depth %d." 559 " Exiting\n", formats[k].depth); 560 } 561 } 562 } 563 } 564 formatsDone = TRUE; 565 } 566 else { 567 /* 568 * serverGeneration != 1; some OSs have to do things here, too. 569 */ 570 if (xorgHWOpenConsole) 571 xf86OpenConsole(); 572 573 /* 574 should we reopen it here? We need to deal with an already opened 575 device. We could leave this to the OS layer. For now we simply 576 close it here 577 */ 578 if (xf86OSPMClose) 579 xf86OSPMClose(); 580 if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) 581 xf86MsgVerb(X_INFO, 3, "APM registered successfully\n"); 582 583 /* Make sure full I/O access is enabled */ 584 if (xorgHWAccess) 585 xf86EnableIO(); 586 } 587 588 if (xf86Info.vtno >= 0) 589 AddCallback(&RootWindowFinalizeCallback, AddVTAtoms, NULL); 590 591 if (SeatId) 592 AddCallback(&RootWindowFinalizeCallback, AddSeatId, SeatId); 593 594 /* 595 * Use the previously collected parts to setup pScreenInfo 596 */ 597 598 pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder; 599 pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad; 600 pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit; 601 pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder; 602 pScreenInfo->numPixmapFormats = numFormats; 603 for (i = 0; i < numFormats; i++) 604 pScreenInfo->formats[i] = formats[i]; 605 606 /* Make sure the server's VT is active */ 607 608 if (serverGeneration != 1) { 609 xf86Resetting = TRUE; 610 /* All screens are in the same state, so just check the first */ 611 if (!xf86VTOwner()) { 612#ifdef HAS_USL_VTS 613 ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ); 614#endif 615 input_lock(); 616 sigio_blocked = TRUE; 617 } 618 } 619 620 for (i = 0; i < xf86NumScreens; i++) 621 if (!xf86ColormapAllocatePrivates(xf86Screens[i])) 622 FatalError("Cannot register DDX private keys"); 623 624 if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0)) 625 FatalError("Cannot register DDX private keys"); 626 627 for (i = 0; i < xf86NumScreens; i++) { 628 xf86VGAarbiterLock(xf86Screens[i]); 629 /* 630 * Almost everything uses these defaults, and many of those that 631 * don't, will wrap them. 632 */ 633 xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; 634#ifdef XFreeXDGA 635 xf86Screens[i]->SetDGAMode = xf86SetDGAMode; 636#endif 637 scr_index = AddScreen(xf86ScreenInit, argc, argv); 638 xf86VGAarbiterUnlock(xf86Screens[i]); 639 if (scr_index == i) { 640 /* 641 * Hook in our ScrnInfoRec, and initialise some other pScreen 642 * fields. 643 */ 644 dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, 645 xf86ScreenKey, xf86Screens[i]); 646 xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; 647 /* The driver should set this, but make sure it is set anyway */ 648 xf86Screens[i]->vtSema = TRUE; 649 } 650 else { 651 /* This shouldn't normally happen */ 652 FatalError("AddScreen/ScreenInit failed for driver %d\n", i); 653 } 654 655 if (PictureGetSubpixelOrder(xf86Screens[i]->pScreen) == SubPixelUnknown) { 656 xf86MonPtr DDC = (xf86MonPtr) (xf86Screens[i]->monitor->DDC); 657 658 PictureSetSubpixelOrder(xf86Screens[i]->pScreen, 659 DDC ? 660 (DDC->features.input_type ? 661 SubPixelHorizontalRGB : SubPixelNone) : 662 SubPixelUnknown); 663 } 664 665 /* 666 * If the driver hasn't set up its own RANDR support, install the 667 * fallback support. 668 */ 669 xf86EnsureRANDR(xf86Screens[i]->pScreen); 670 } 671 672 for (i = 0; i < xf86NumGPUScreens; i++) { 673 ScrnInfoPtr pScrn = xf86GPUScreens[i]; 674 xf86VGAarbiterLock(pScrn); 675 676 /* 677 * Almost everything uses these defaults, and many of those that 678 * don't, will wrap them. 679 */ 680 pScrn->EnableDisableFBAccess = xf86EnableDisableFBAccess; 681#ifdef XFreeXDGA 682 pScrn->SetDGAMode = xf86SetDGAMode; 683#endif 684 scr_index = AddGPUScreen(xf86ScreenInit, argc, argv); 685 xf86VGAarbiterUnlock(pScrn); 686 if (scr_index == i) { 687 dixSetPrivate(&screenInfo.gpuscreens[scr_index]->devPrivates, 688 xf86ScreenKey, xf86GPUScreens[i]); 689 pScrn->pScreen = screenInfo.gpuscreens[scr_index]; 690 /* The driver should set this, but make sure it is set anyway */ 691 pScrn->vtSema = TRUE; 692 } else { 693 FatalError("AddScreen/ScreenInit failed for gpu driver %d %d\n", i, scr_index); 694 } 695 } 696 697 for (i = 0; i < xf86NumGPUScreens; i++) { 698 int scrnum = xf86GPUScreens[i]->confScreen->screennum; 699 AttachUnboundGPU(xf86Screens[scrnum]->pScreen, xf86GPUScreens[i]->pScreen); 700 } 701 702 xf86AutoConfigOutputDevices(); 703 704 xf86VGAarbiterWrapFunctions(); 705 if (sigio_blocked) 706 input_unlock(); 707 708 xf86InitOrigins(); 709 710 xf86Resetting = FALSE; 711 xf86Initialising = FALSE; 712 713 RegisterBlockAndWakeupHandlers((ServerBlockHandlerProcPtr) NoopDDA, xf86Wakeup, 714 NULL); 715} 716 717/** 718 * Initialize all supported input devices present and referenced in the 719 * xorg.conf. 720 */ 721void 722InitInput(int argc, char **argv) 723{ 724 InputInfoPtr *pInfo; 725 DeviceIntPtr dev; 726 727 xf86Info.vtRequestsPending = FALSE; 728 729 /* Enable threaded input */ 730 InputThreadPreInit(); 731 732 mieqInit(); 733 734 /* Initialize all configured input devices */ 735 for (pInfo = xf86ConfigLayout.inputs; pInfo && *pInfo; pInfo++) { 736 (*pInfo)->options = 737 xf86AddNewOption((*pInfo)->options, "driver", (*pInfo)->driver); 738 (*pInfo)->options = 739 xf86AddNewOption((*pInfo)->options, "identifier", (*pInfo)->name); 740 /* If one fails, the others will too */ 741 if (NewInputDeviceRequest((*pInfo)->options, NULL, &dev) == BadAlloc) 742 break; 743 } 744 745 config_init(); 746} 747 748void 749CloseInput(void) 750{ 751 config_fini(); 752 mieqFini(); 753} 754 755/* 756 * OsVendorInit -- 757 * OS/Vendor-specific initialisations. Called from OsInit(), which 758 * is called by dix before establishing the well known sockets. 759 */ 760 761void 762OsVendorInit(void) 763{ 764 static Bool beenHere = FALSE; 765 766 OsSignal(SIGCHLD, SIG_DFL); /* Need to wait for child processes */ 767 768 if (!beenHere) { 769 umask(022); 770 xf86LogInit(); 771 } 772 773 /* Set stderr to non-blocking. */ 774#ifndef O_NONBLOCK 775#if defined(FNDELAY) 776#define O_NONBLOCK FNDELAY 777#elif defined(O_NDELAY) 778#define O_NONBLOCK O_NDELAY 779#endif 780 781#ifdef O_NONBLOCK 782 if (!beenHere) { 783 if (PrivsElevated()) { 784 int status; 785 786 status = fcntl(fileno(stderr), F_GETFL, 0); 787 if (status != -1) { 788 fcntl(fileno(stderr), F_SETFL, status | O_NONBLOCK); 789 } 790 } 791 } 792#endif 793#endif 794 795 beenHere = TRUE; 796} 797 798/* 799 * ddxGiveUp -- 800 * Device dependent cleanup. Called by by dix before normal server death. 801 * For SYSV386 we must switch the terminal back to normal mode. No error- 802 * checking here, since there should be restored as much as possible. 803 */ 804 805void 806ddxGiveUp(enum ExitCode error) 807{ 808 int i; 809 810 if (error == EXIT_ERR_ABORT) { 811 input_lock(); 812 813 /* try to restore the original video state */ 814#ifdef DPMSExtension /* Turn screens back on */ 815 if (DPMSPowerLevel != DPMSModeOn) 816 DPMSSet(serverClient, DPMSModeOn); 817#endif 818 if (xf86Screens) { 819 for (i = 0; i < xf86NumScreens; i++) 820 if (xf86Screens[i]->vtSema) { 821 /* 822 * if we are aborting before ScreenInit() has finished we 823 * might not have been wrapped yet. Therefore enable screen 824 * explicitly. 825 */ 826 xf86VGAarbiterLock(xf86Screens[i]); 827 (xf86Screens[i]->LeaveVT) (xf86Screens[i]); 828 xf86VGAarbiterUnlock(xf86Screens[i]); 829 } 830 } 831 } 832 833 xf86VGAarbiterFini(); 834 835 if (xf86OSPMClose) 836 xf86OSPMClose(); 837 xf86OSPMClose = NULL; 838 839 for (i = 0; i < xf86NumScreens; i++) { 840 /* 841 * zero all access functions to 842 * trap calls when switched away. 843 */ 844 xf86Screens[i]->vtSema = FALSE; 845 } 846 847 if (xorgHWOpenConsole) 848 xf86CloseConsole(); 849 850 systemd_logind_fini(); 851 dbus_core_fini(); 852 853 xf86CloseLog(error); 854} 855 856void 857OsVendorFatalError(const char *f, va_list args) 858{ 859#ifdef VENDORSUPPORT 860 ErrorFSigSafe("\nPlease refer to your Operating System Vendor support " 861 "pages\nat %s for support on this crash.\n", VENDORSUPPORT); 862#else 863 ErrorFSigSafe("\nPlease consult the " XVENDORNAME " support \n\t at " 864 __VENDORDWEBSUPPORT__ "\n for help. \n"); 865#endif 866 if (xf86LogFile && xf86LogFileWasOpened) 867 ErrorFSigSafe("Please also check the log file at \"%s\" for additional " 868 "information.\n", xf86LogFile); 869 ErrorFSigSafe("\n"); 870} 871 872int 873xf86SetVerbosity(int verb) 874{ 875 int save = xf86Verbose; 876 877 xf86Verbose = verb; 878 LogSetParameter(XLOG_VERBOSITY, verb); 879 return save; 880} 881 882int 883xf86SetLogVerbosity(int verb) 884{ 885 int save = xf86LogVerbose; 886 887 xf86LogVerbose = verb; 888 LogSetParameter(XLOG_FILE_VERBOSITY, verb); 889 return save; 890} 891 892static void 893xf86PrintDefaultModulePath(void) 894{ 895 ErrorF("%s\n", DEFAULT_MODULE_PATH); 896} 897 898static void 899xf86PrintDefaultLibraryPath(void) 900{ 901 ErrorF("%s\n", DEFAULT_LIBRARY_PATH); 902} 903 904static void 905xf86CheckPrivs(const char *option, const char *arg) 906{ 907 if (PrivsElevated() && !xf86PathIsSafe(arg)) { 908 FatalError("\nInvalid argument for %s - \"%s\"\n" 909 "\tWith elevated privileges %s must specify a relative path\n" 910 "\twithout any \"..\" elements.\n\n", option, arg, option); 911 } 912} 913 914/* 915 * ddxProcessArgument -- 916 * Process device-dependent command line args. Returns 0 if argument is 917 * not device dependent, otherwise Count of number of elements of argv 918 * that are part of a device dependent commandline option. 919 * 920 */ 921 922/* ARGSUSED */ 923int 924ddxProcessArgument(int argc, char **argv, int i) 925{ 926 /* First the options that are not allowed with elevated privileges */ 927 if (!strcmp(argv[i], "-modulepath")) { 928 CHECK_FOR_REQUIRED_ARGUMENTS(1); 929 if (xf86PrivsElevated()) 930 FatalError("\nInvalid argument -modulepath " 931 "with elevated privileges\n"); 932 xf86ModulePath = argv[i + 1]; 933 xf86ModPathFrom = X_CMDLINE; 934 return 2; 935 } 936 if (!strcmp(argv[i], "-logfile")) { 937 CHECK_FOR_REQUIRED_ARGUMENTS(1); 938 if (xf86PrivsElevated()) 939 FatalError("\nInvalid argument -logfile " 940 "with elevated privileges\n"); 941 xf86LogFile = argv[i + 1]; 942 xf86LogFileFrom = X_CMDLINE; 943 return 2; 944 } 945 if (!strcmp(argv[i], "-config") || !strcmp(argv[i], "-xf86config")) { 946 CHECK_FOR_REQUIRED_ARGUMENTS(1); 947 xf86CheckPrivs(argv[i], argv[i + 1]); 948 xf86ConfigFile = argv[i + 1]; 949 return 2; 950 } 951 if (!strcmp(argv[i], "-configdir")) { 952 CHECK_FOR_REQUIRED_ARGUMENTS(1); 953 xf86CheckPrivs(argv[i], argv[i + 1]); 954 xf86ConfigDir = argv[i + 1]; 955 return 2; 956 } 957 if (!strcmp(argv[i], "-flipPixels")) { 958 xf86FlipPixels = TRUE; 959 return 1; 960 } 961#ifdef XF86VIDMODE 962 if (!strcmp(argv[i], "-disableVidMode")) { 963 xf86VidModeDisabled = TRUE; 964 return 1; 965 } 966 if (!strcmp(argv[i], "-allowNonLocalXvidtune")) { 967 xf86VidModeAllowNonLocal = TRUE; 968 return 1; 969 } 970#endif 971 if (!strcmp(argv[i], "-allowMouseOpenFail")) { 972 xf86AllowMouseOpenFail = TRUE; 973 return 1; 974 } 975 if (!strcmp(argv[i], "-ignoreABI")) { 976 LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); 977 return 1; 978 } 979 if (!strcmp(argv[i], "-verbose")) { 980 if (++i < argc && argv[i]) { 981 char *end; 982 long val; 983 984 val = strtol(argv[i], &end, 0); 985 if (*end == '\0') { 986 xf86SetVerbosity(val); 987 return 2; 988 } 989 } 990 xf86SetVerbosity(++xf86Verbose); 991 return 1; 992 } 993 if (!strcmp(argv[i], "-logverbose")) { 994 if (++i < argc && argv[i]) { 995 char *end; 996 long val; 997 998 val = strtol(argv[i], &end, 0); 999 if (*end == '\0') { 1000 xf86SetLogVerbosity(val); 1001 return 2; 1002 } 1003 } 1004 xf86SetLogVerbosity(++xf86LogVerbose); 1005 return 1; 1006 } 1007 if (!strcmp(argv[i], "-quiet")) { 1008 xf86SetVerbosity(-1); 1009 return 1; 1010 } 1011 if (!strcmp(argv[i], "-showconfig") || !strcmp(argv[i], "-version")) { 1012 xf86PrintBanner(); 1013 exit(0); 1014 } 1015 if (!strcmp(argv[i], "-showDefaultModulePath")) { 1016 xf86PrintDefaultModulePath(); 1017 exit(0); 1018 } 1019 if (!strcmp(argv[i], "-showDefaultLibPath")) { 1020 xf86PrintDefaultLibraryPath(); 1021 exit(0); 1022 } 1023 /* Notice the -fp flag, but allow it to pass to the dix layer */ 1024 if (!strcmp(argv[i], "-fp")) { 1025 xf86fpFlag = TRUE; 1026 return 0; 1027 } 1028 /* Notice the -bs flag, but allow it to pass to the dix layer */ 1029 if (!strcmp(argv[i], "-bs")) { 1030 xf86bsDisableFlag = TRUE; 1031 return 0; 1032 } 1033 /* Notice the +bs flag, but allow it to pass to the dix layer */ 1034 if (!strcmp(argv[i], "+bs")) { 1035 xf86bsEnableFlag = TRUE; 1036 return 0; 1037 } 1038 /* Notice the -s flag, but allow it to pass to the dix layer */ 1039 if (!strcmp(argv[i], "-s")) { 1040 xf86sFlag = TRUE; 1041 return 0; 1042 } 1043 if (!strcmp(argv[i], "-pixmap32") || !strcmp(argv[i], "-pixmap24")) { 1044 /* silently accept */ 1045 return 1; 1046 } 1047 if (!strcmp(argv[i], "-fbbpp")) { 1048 int bpp; 1049 1050 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1051 if (sscanf(argv[++i], "%d", &bpp) == 1) { 1052 xf86FbBpp = bpp; 1053 return 2; 1054 } 1055 else { 1056 ErrorF("Invalid fbbpp\n"); 1057 return 0; 1058 } 1059 } 1060 if (!strcmp(argv[i], "-depth")) { 1061 int depth; 1062 1063 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1064 if (sscanf(argv[++i], "%d", &depth) == 1) { 1065 xf86Depth = depth; 1066 return 2; 1067 } 1068 else { 1069 ErrorF("Invalid depth\n"); 1070 return 0; 1071 } 1072 } 1073 if (!strcmp(argv[i], "-weight")) { 1074 int red, green, blue; 1075 1076 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1077 if (sscanf(argv[++i], "%1d%1d%1d", &red, &green, &blue) == 3) { 1078 xf86Weight.red = red; 1079 xf86Weight.green = green; 1080 xf86Weight.blue = blue; 1081 return 2; 1082 } 1083 else { 1084 ErrorF("Invalid weighting\n"); 1085 return 0; 1086 } 1087 } 1088 if (!strcmp(argv[i], "-gamma") || !strcmp(argv[i], "-rgamma") || 1089 !strcmp(argv[i], "-ggamma") || !strcmp(argv[i], "-bgamma")) { 1090 double gamma; 1091 1092 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1093 if (sscanf(argv[++i], "%lf", &gamma) == 1) { 1094 if (gamma < GAMMA_MIN || gamma > GAMMA_MAX) { 1095 ErrorF("gamma out of range, only %.2f <= gamma_value <= %.1f" 1096 " is valid\n", GAMMA_MIN, GAMMA_MAX); 1097 return 0; 1098 } 1099 if (!strcmp(argv[i - 1], "-gamma")) 1100 xf86Gamma.red = xf86Gamma.green = xf86Gamma.blue = gamma; 1101 else if (!strcmp(argv[i - 1], "-rgamma")) 1102 xf86Gamma.red = gamma; 1103 else if (!strcmp(argv[i - 1], "-ggamma")) 1104 xf86Gamma.green = gamma; 1105 else if (!strcmp(argv[i - 1], "-bgamma")) 1106 xf86Gamma.blue = gamma; 1107 return 2; 1108 } 1109 } 1110 if (!strcmp(argv[i], "-layout")) { 1111 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1112 xf86LayoutName = argv[++i]; 1113 return 2; 1114 } 1115 if (!strcmp(argv[i], "-screen")) { 1116 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1117 xf86ScreenName = argv[++i]; 1118 return 2; 1119 } 1120 if (!strcmp(argv[i], "-pointer")) { 1121 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1122 xf86PointerName = argv[++i]; 1123 return 2; 1124 } 1125 if (!strcmp(argv[i], "-keyboard")) { 1126 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1127 xf86KeyboardName = argv[++i]; 1128 return 2; 1129 } 1130 if (!strcmp(argv[i], "-nosilk")) { 1131 xf86silkenMouseDisableFlag = TRUE; 1132 return 1; 1133 } 1134#ifdef HAVE_ACPI 1135 if (!strcmp(argv[i], "-noacpi")) { 1136 xf86acpiDisableFlag = TRUE; 1137 return 1; 1138 } 1139#endif 1140 if (!strcmp(argv[i], "-configure")) { 1141 if (getuid() != 0 && geteuid() == 0) { 1142 ErrorF("The '-configure' option can only be used by root.\n"); 1143 exit(1); 1144 } 1145 xf86DoConfigure = TRUE; 1146 xf86AllowMouseOpenFail = TRUE; 1147 return 1; 1148 } 1149 if (!strcmp(argv[i], "-showopts")) { 1150 if (getuid() != 0 && geteuid() == 0) { 1151 ErrorF("The '-showopts' option can only be used by root.\n"); 1152 exit(1); 1153 } 1154 xf86DoShowOptions = TRUE; 1155 return 1; 1156 } 1157#ifdef XSERVER_LIBPCIACCESS 1158 if (!strcmp(argv[i], "-isolateDevice")) { 1159 CHECK_FOR_REQUIRED_ARGUMENTS(1); 1160 if (strncmp(argv[++i], "PCI:", 4)) { 1161 FatalError("Bus types other than PCI not yet isolable\n"); 1162 } 1163 xf86PciIsolateDevice(argv[i]); 1164 return 2; 1165 } 1166#endif 1167 /* Notice cmdline xkbdir, but pass to dix as well */ 1168 if (!strcmp(argv[i], "-xkbdir")) { 1169 xf86xkbdirFlag = TRUE; 1170 return 0; 1171 } 1172 if (!strcmp(argv[i], "-novtswitch")) { 1173 xf86Info.autoVTSwitch = FALSE; 1174 return 1; 1175 } 1176 if (!strcmp(argv[i], "-sharevts")) { 1177 xf86Info.ShareVTs = TRUE; 1178 return 1; 1179 } 1180 if (!strcmp(argv[i], "-iglx") || !strcmp(argv[i], "+iglx")) { 1181 xf86Info.iglxFrom = X_CMDLINE; 1182 return 0; 1183 } 1184 if (!strcmp(argv[i], "-noautoBindGPU")) { 1185 xf86AutoBindGPUDisabled = TRUE; 1186 return 1; 1187 } 1188 1189 /* OS-specific processing */ 1190 return xf86ProcessArgument(argc, argv, i); 1191} 1192 1193/* 1194 * ddxUseMsg -- 1195 * Print out correct use of device dependent commandline options. 1196 * Maybe the user now knows what really to do ... 1197 */ 1198 1199void 1200ddxUseMsg(void) 1201{ 1202 ErrorF("\n"); 1203 ErrorF("\n"); 1204 ErrorF("Device Dependent Usage\n"); 1205 if (!PrivsElevated()) { 1206 ErrorF("-modulepath paths specify the module search path\n"); 1207 ErrorF("-logfile file specify a log file name\n"); 1208 ErrorF("-configure probe for devices and write an " 1209 XCONFIGFILE "\n"); 1210 ErrorF 1211 ("-showopts print available options for all installed drivers\n"); 1212 } 1213 ErrorF 1214 ("-config file specify a configuration file, relative to the\n"); 1215 ErrorF(" " XCONFIGFILE 1216 " search path, only root can use absolute\n"); 1217 ErrorF 1218 ("-configdir dir specify a configuration directory, relative to the\n"); 1219 ErrorF(" " XCONFIGDIR 1220 " search path, only root can use absolute\n"); 1221 ErrorF("-verbose [n] verbose startup messages\n"); 1222 ErrorF("-logverbose [n] verbose log messages\n"); 1223 ErrorF("-quiet minimal startup messages\n"); 1224 ErrorF("-fbbpp n set bpp for the framebuffer. Default: 8\n"); 1225 ErrorF("-depth n set colour depth. Default: 8\n"); 1226 ErrorF 1227 ("-gamma f set gamma value (0.1 < f < 10.0) Default: 1.0\n"); 1228 ErrorF("-rgamma f set gamma value for red phase\n"); 1229 ErrorF("-ggamma f set gamma value for green phase\n"); 1230 ErrorF("-bgamma f set gamma value for blue phase\n"); 1231 ErrorF 1232 ("-weight nnn set RGB weighting at 16 bpp. Default: 565\n"); 1233 ErrorF("-layout name specify the ServerLayout section name\n"); 1234 ErrorF("-screen name specify the Screen section name\n"); 1235 ErrorF 1236 ("-keyboard name specify the core keyboard InputDevice name\n"); 1237 ErrorF 1238 ("-pointer name specify the core pointer InputDevice name\n"); 1239 ErrorF("-nosilk disable Silken Mouse\n"); 1240 ErrorF("-flipPixels swap default black/white Pixel values\n"); 1241#ifdef XF86VIDMODE 1242 ErrorF("-disableVidMode disable mode adjustments with xvidtune\n"); 1243 ErrorF 1244 ("-allowNonLocalXvidtune allow xvidtune to be run as a non-local client\n"); 1245#endif 1246 ErrorF 1247 ("-allowMouseOpenFail start server even if the mouse can't be initialized\n"); 1248 ErrorF("-ignoreABI make module ABI mismatches non-fatal\n"); 1249#ifdef XSERVER_LIBPCIACCESS 1250 ErrorF 1251 ("-isolateDevice bus_id restrict device resets to bus_id (PCI only)\n"); 1252#endif 1253 ErrorF("-version show the server version\n"); 1254 ErrorF("-showDefaultModulePath show the server default module path\n"); 1255 ErrorF("-showDefaultLibPath show the server default library path\n"); 1256 ErrorF 1257 ("-novtswitch don't automatically switch VT at reset & exit\n"); 1258 ErrorF("-sharevts share VTs with another X server\n"); 1259 /* OS-specific usage */ 1260 xf86UseMsg(); 1261 ErrorF("\n"); 1262} 1263 1264/* 1265 * xf86LoadModules iterates over a list that is being passed in. 1266 */ 1267Bool 1268xf86LoadModules(const char **list, void **optlist) 1269{ 1270 int errmaj; 1271 void *opt; 1272 int i; 1273 char *name; 1274 Bool failed = FALSE; 1275 1276 if (!list) 1277 return TRUE; 1278 1279 for (i = 0; list[i] != NULL; i++) { 1280 1281 /* Normalise the module name */ 1282 name = xf86NormalizeName(list[i]); 1283 1284 /* Skip empty names */ 1285 if (name == NULL || *name == '\0') { 1286 free(name); 1287 continue; 1288 } 1289 1290 /* Replace obsolete keyboard driver with kbd */ 1291 if (!xf86NameCmp(name, "keyboard")) { 1292 strcpy(name, "kbd"); 1293 } 1294 1295 if (optlist) 1296 opt = optlist[i]; 1297 else 1298 opt = NULL; 1299 1300 if (!LoadModule(name, opt, NULL, &errmaj)) { 1301 LoaderErrorMsg(NULL, name, errmaj, 0); 1302 failed = TRUE; 1303 } 1304 free(name); 1305 } 1306 return !failed; 1307} 1308 1309/* Pixmap format stuff */ 1310 1311PixmapFormatPtr 1312xf86GetPixFormat(ScrnInfoPtr pScrn, int depth) 1313{ 1314 int i; 1315 1316 for (i = 0; i < numFormats; i++) 1317 if (formats[i].depth == depth) 1318 break; 1319 if (i != numFormats) 1320 return &formats[i]; 1321 else if (!formatsDone) { 1322 /* Check for screen-specified formats */ 1323 for (i = 0; i < pScrn->numFormats; i++) 1324 if (pScrn->formats[i].depth == depth) 1325 break; 1326 if (i != pScrn->numFormats) 1327 return &pScrn->formats[i]; 1328 } 1329 return NULL; 1330} 1331 1332int 1333xf86GetBppFromDepth(ScrnInfoPtr pScrn, int depth) 1334{ 1335 PixmapFormatPtr format; 1336 1337 format = xf86GetPixFormat(pScrn, depth); 1338 if (format) 1339 return format->bitsPerPixel; 1340 else 1341 return 0; 1342} 1343 1344#ifdef DDXBEFORERESET 1345void 1346ddxBeforeReset(void) 1347{ 1348} 1349#endif 1350 1351#if INPUTTHREAD 1352/** This function is called in Xserver/os/inputthread.c when starting 1353 the input thread. */ 1354void 1355ddxInputThreadInit(void) 1356{ 1357 xf86OSInputThreadInit(); 1358} 1359#endif 1360