| File: | hw/kdrive/src/kdrive.c |
| Location: | line 417, column 9 |
| Description: | Value stored to 'arg' is never read |
| 1 | /* |
| 2 | * Copyright © 1999 Keith Packard |
| 3 | * |
| 4 | * Permission to use, copy, modify, distribute, and sell this software and its |
| 5 | * documentation for any purpose is hereby granted without fee, provided that |
| 6 | * the above copyright notice appear in all copies and that both that |
| 7 | * copyright notice and this permission notice appear in supporting |
| 8 | * documentation, and that the name of Keith Packard not be used in |
| 9 | * advertising or publicity pertaining to distribution of the software without |
| 10 | * specific, written prior permission. Keith Packard makes no |
| 11 | * representations about the suitability of this software for any purpose. It |
| 12 | * is provided "as is" without express or implied warranty. |
| 13 | * |
| 14 | * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, |
| 15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO |
| 16 | * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR |
| 17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, |
| 18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
| 19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
| 20 | * PERFORMANCE OF THIS SOFTWARE. |
| 21 | */ |
| 22 | |
| 23 | #ifdef HAVE_CONFIG_H1 |
| 24 | #include <kdrive-config.h> |
| 25 | #endif |
| 26 | #include "kdrive.h" |
| 27 | #include <mivalidate.h> |
| 28 | #include <dixstruct.h> |
| 29 | #include "privates.h" |
| 30 | #ifdef RANDR1 |
| 31 | #include <randrstr.h> |
| 32 | #endif |
| 33 | |
| 34 | #ifdef XV1 |
| 35 | #include "kxv.h" |
| 36 | #endif |
| 37 | |
| 38 | #ifdef DPMSExtension1 |
| 39 | #include "dpmsproc.h" |
| 40 | #endif |
| 41 | |
| 42 | #ifdef HAVE_EXECINFO_H1 |
| 43 | #include <execinfo.h> |
| 44 | #endif |
| 45 | |
| 46 | #include <signal.h> |
| 47 | |
| 48 | #if defined(CONFIG_UDEV) || defined(CONFIG_HAL) |
| 49 | #include <hotplug.h> |
| 50 | #endif |
| 51 | |
| 52 | /* This stub can be safely removed once we can |
| 53 | * split input and GPU parts in hotplug.h et al. */ |
| 54 | #include <systemd-logind.h> |
| 55 | |
| 56 | typedef struct _kdDepths { |
| 57 | CARD8 depth; |
| 58 | CARD8 bpp; |
| 59 | } KdDepths; |
| 60 | |
| 61 | KdDepths kdDepths[] = { |
| 62 | {1, 1}, |
| 63 | {4, 4}, |
| 64 | {8, 8}, |
| 65 | {15, 16}, |
| 66 | {16, 16}, |
| 67 | {24, 32}, |
| 68 | {32, 32} |
| 69 | }; |
| 70 | |
| 71 | #define NUM_KD_DEPTHS(sizeof (kdDepths) / sizeof (kdDepths[0])) (sizeof (kdDepths) / sizeof (kdDepths[0])) |
| 72 | |
| 73 | #define KD_DEFAULT_BUTTONS5 5 |
| 74 | |
| 75 | DevPrivateKeyRec kdScreenPrivateKeyRec; |
| 76 | unsigned long kdGeneration; |
| 77 | |
| 78 | Bool kdVideoTest; |
| 79 | unsigned long kdVideoTestTime; |
| 80 | Bool kdEmulateMiddleButton; |
| 81 | Bool kdRawPointerCoordinates; |
| 82 | Bool kdDisableZaphod; |
| 83 | Bool kdAllowZap; |
| 84 | Bool kdEnabled; |
| 85 | int kdSubpixelOrder; |
| 86 | int kdVirtualTerminal = -1; |
| 87 | Bool kdSwitchPending; |
| 88 | char *kdSwitchCmd; |
| 89 | DDXPointRec kdOrigin; |
| 90 | Bool kdHasPointer = FALSE0; |
| 91 | Bool kdHasKbd = FALSE0; |
| 92 | const char *kdGlobalXkbRules = NULL((void*)0); |
| 93 | const char *kdGlobalXkbModel = NULL((void*)0); |
| 94 | const char *kdGlobalXkbLayout = NULL((void*)0); |
| 95 | const char *kdGlobalXkbVariant = NULL((void*)0); |
| 96 | const char *kdGlobalXkbOptions = NULL((void*)0); |
| 97 | |
| 98 | static Bool kdCaughtSignal = FALSE0; |
| 99 | |
| 100 | /* |
| 101 | * Carry arguments from InitOutput through driver initialization |
| 102 | * to KdScreenInit |
| 103 | */ |
| 104 | |
| 105 | KdOsFuncs *kdOsFuncs; |
| 106 | |
| 107 | void |
| 108 | KdDisableScreen(ScreenPtr pScreen) |
| 109 | { |
| 110 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 111 | |
| 112 | if (!pScreenPriv->enabled) |
| 113 | return; |
| 114 | if (!pScreenPriv->closed) |
| 115 | SetRootClip(pScreen, ROOT_CLIP_NONE); |
| 116 | KdDisableColormap(pScreen); |
| 117 | if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->disableAccel) |
| 118 | (*pScreenPriv->card->cfuncs->disableAccel) (pScreen); |
| 119 | if (!pScreenPriv->screen->softCursor && |
| 120 | pScreenPriv->card->cfuncs->disableCursor) |
| 121 | (*pScreenPriv->card->cfuncs->disableCursor) (pScreen); |
| 122 | if (pScreenPriv->card->cfuncs->dpms) |
| 123 | (*pScreenPriv->card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL0); |
| 124 | pScreenPriv->enabled = FALSE0; |
| 125 | if (pScreenPriv->card->cfuncs->disable) |
| 126 | (*pScreenPriv->card->cfuncs->disable) (pScreen); |
| 127 | } |
| 128 | |
| 129 | static void |
| 130 | KdDoSwitchCmd(const char *reason) |
| 131 | { |
| 132 | if (kdSwitchCmd) { |
| 133 | char *command; |
| 134 | int ret; |
| 135 | |
| 136 | if (asprintf(&command, "%s %s", kdSwitchCmd, reason) == -1) |
| 137 | return; |
| 138 | |
| 139 | /* Ignore the return value from system; I'm not sure |
| 140 | * there's anything more useful to be done when |
| 141 | * it fails |
| 142 | */ |
| 143 | ret = system(command); |
| 144 | (void) ret; |
| 145 | free(command); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | void |
| 150 | KdSuspend(void) |
| 151 | { |
| 152 | KdCardInfo *card; |
| 153 | KdScreenInfo *screen; |
| 154 | |
| 155 | if (kdEnabled) { |
| 156 | for (card = kdCardInfo; card; card = card->next) { |
| 157 | for (screen = card->screenList; screen; screen = screen->next) |
| 158 | if (screen->mynum == card->selected && screen->pScreen) |
| 159 | KdDisableScreen(screen->pScreen); |
| 160 | if (card->driver && card->cfuncs->restore) |
| 161 | (*card->cfuncs->restore) (card); |
| 162 | } |
| 163 | KdDisableInput(); |
| 164 | KdDoSwitchCmd("suspend"); |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | void |
| 169 | KdDisableScreens(void) |
| 170 | { |
| 171 | KdSuspend(); |
| 172 | if (kdEnabled) { |
| 173 | if (kdOsFuncs->Disable) |
| 174 | (*kdOsFuncs->Disable) (); |
| 175 | kdEnabled = FALSE0; |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | Bool |
| 180 | KdEnableScreen(ScreenPtr pScreen) |
| 181 | { |
| 182 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 183 | |
| 184 | if (pScreenPriv->enabled) |
| 185 | return TRUE1; |
| 186 | if (pScreenPriv->card->cfuncs->enable) |
| 187 | if (!(*pScreenPriv->card->cfuncs->enable) (pScreen)) |
| 188 | return FALSE0; |
| 189 | pScreenPriv->enabled = TRUE1; |
| 190 | pScreenPriv->dpmsState = KD_DPMS_NORMAL0; |
| 191 | pScreenPriv->card->selected = pScreenPriv->screen->mynum; |
| 192 | if (!pScreenPriv->screen->softCursor && |
| 193 | pScreenPriv->card->cfuncs->enableCursor) |
| 194 | (*pScreenPriv->card->cfuncs->enableCursor) (pScreen); |
| 195 | if (!pScreenPriv->screen->dumb && pScreenPriv->card->cfuncs->enableAccel) |
| 196 | (*pScreenPriv->card->cfuncs->enableAccel) (pScreen); |
| 197 | KdEnableColormap(pScreen); |
| 198 | SetRootClip(pScreen, ROOT_CLIP_FULL); |
| 199 | if (pScreenPriv->card->cfuncs->dpms) |
| 200 | (*pScreenPriv->card->cfuncs->dpms) (pScreen, pScreenPriv->dpmsState); |
| 201 | return TRUE1; |
| 202 | } |
| 203 | |
| 204 | void |
| 205 | KdResume(void) |
| 206 | { |
| 207 | KdCardInfo *card; |
| 208 | KdScreenInfo *screen; |
| 209 | |
| 210 | if (kdEnabled) { |
| 211 | KdDoSwitchCmd("resume"); |
| 212 | for (card = kdCardInfo; card; card = card->next) { |
| 213 | if (card->cfuncs->preserve) |
| 214 | (*card->cfuncs->preserve) (card); |
| 215 | for (screen = card->screenList; screen; screen = screen->next) |
| 216 | if (screen->mynum == card->selected && screen->pScreen) |
| 217 | KdEnableScreen(screen->pScreen); |
| 218 | } |
| 219 | KdEnableInput(); |
| 220 | KdReleaseAllKeys(); |
| 221 | } |
| 222 | } |
| 223 | |
| 224 | void |
| 225 | KdEnableScreens(void) |
| 226 | { |
| 227 | if (!kdEnabled) { |
| 228 | kdEnabled = TRUE1; |
| 229 | if (kdOsFuncs->Enable) |
| 230 | (*kdOsFuncs->Enable) (); |
| 231 | } |
| 232 | KdResume(); |
| 233 | } |
| 234 | |
| 235 | void |
| 236 | KdProcessSwitch(void) |
| 237 | { |
| 238 | if (kdEnabled) |
| 239 | KdDisableScreens(); |
| 240 | else |
| 241 | KdEnableScreens(); |
| 242 | } |
| 243 | |
| 244 | void |
| 245 | AbortDDX(enum ExitCode error) |
| 246 | { |
| 247 | KdDisableScreens(); |
| 248 | if (kdOsFuncs) { |
| 249 | if (kdEnabled && kdOsFuncs->Disable) |
| 250 | (*kdOsFuncs->Disable) (); |
| 251 | if (kdOsFuncs->Fini) |
| 252 | (*kdOsFuncs->Fini) (); |
| 253 | KdDoSwitchCmd("stop"); |
| 254 | } |
| 255 | |
| 256 | if (kdCaughtSignal) |
| 257 | OsAbort(); |
| 258 | } |
| 259 | |
| 260 | void |
| 261 | ddxGiveUp(enum ExitCode error) |
| 262 | { |
| 263 | AbortDDX(error); |
| 264 | } |
| 265 | |
| 266 | Bool kdDumbDriver; |
| 267 | Bool kdSoftCursor; |
| 268 | |
| 269 | const char * |
| 270 | KdParseFindNext(const char *cur, const char *delim, char *save, char *last) |
| 271 | { |
| 272 | while (*cur && !strchr(delim, *cur)) { |
| 273 | *save++ = *cur++; |
| 274 | } |
| 275 | *save = 0; |
| 276 | *last = *cur; |
| 277 | if (*cur) |
| 278 | cur++; |
| 279 | return cur; |
| 280 | } |
| 281 | |
| 282 | Rotation |
| 283 | KdAddRotation(Rotation a, Rotation b) |
| 284 | { |
| 285 | Rotation rotate = (a & RR_Rotate_All(1|2|4|8)) * (b & RR_Rotate_All(1|2|4|8)); |
| 286 | Rotation reflect = (a & RR_Reflect_All(16|32)) ^ (b & RR_Reflect_All(16|32)); |
| 287 | |
| 288 | if (rotate > RR_Rotate_2708) |
| 289 | rotate /= (RR_Rotate_2708 * RR_Rotate_902); |
| 290 | return reflect | rotate; |
| 291 | } |
| 292 | |
| 293 | Rotation |
| 294 | KdSubRotation(Rotation a, Rotation b) |
| 295 | { |
| 296 | Rotation rotate = (a & RR_Rotate_All(1|2|4|8)) * 16 / (b & RR_Rotate_All(1|2|4|8)); |
| 297 | Rotation reflect = (a & RR_Reflect_All(16|32)) ^ (b & RR_Reflect_All(16|32)); |
| 298 | |
| 299 | if (rotate > RR_Rotate_2708) |
| 300 | rotate /= (RR_Rotate_2708 * RR_Rotate_902); |
| 301 | return reflect | rotate; |
| 302 | } |
| 303 | |
| 304 | void |
| 305 | KdParseScreen(KdScreenInfo * screen, const char *arg) |
| 306 | { |
| 307 | char delim; |
| 308 | char save[1024]; |
| 309 | int i; |
| 310 | int pixels, mm; |
| 311 | |
| 312 | screen->dumb = kdDumbDriver; |
| 313 | screen->softCursor = kdSoftCursor; |
| 314 | screen->origin = kdOrigin; |
| 315 | screen->randr = RR_Rotate_01; |
| 316 | screen->x = 0; |
| 317 | screen->y = 0; |
| 318 | screen->width = 0; |
| 319 | screen->height = 0; |
| 320 | screen->width_mm = 0; |
| 321 | screen->height_mm = 0; |
| 322 | screen->subpixel_order = kdSubpixelOrder; |
| 323 | screen->rate = 0; |
| 324 | screen->fb.depth = 0; |
| 325 | if (!arg) |
| 326 | return; |
| 327 | if (strlen(arg) >= sizeof(save)) |
| 328 | return; |
| 329 | |
| 330 | for (i = 0; i < 2; i++) { |
| 331 | arg = KdParseFindNext(arg, "x/+@XY", save, &delim); |
| 332 | if (!save[0]) |
| 333 | return; |
| 334 | |
| 335 | pixels = atoi(save); |
| 336 | mm = 0; |
| 337 | |
| 338 | if (delim == '/') { |
| 339 | arg = KdParseFindNext(arg, "x+@XY", save, &delim); |
| 340 | if (!save[0]) |
| 341 | return; |
| 342 | mm = atoi(save); |
| 343 | } |
| 344 | |
| 345 | if (i == 0) { |
| 346 | screen->width = pixels; |
| 347 | screen->width_mm = mm; |
| 348 | } |
| 349 | else { |
| 350 | screen->height = pixels; |
| 351 | screen->height_mm = mm; |
| 352 | } |
| 353 | if (delim != 'x' && delim != '+' && delim != '@' && |
| 354 | delim != 'X' && delim != 'Y' && |
| 355 | (delim != '\0' || i == 0)) |
| 356 | return; |
| 357 | } |
| 358 | |
| 359 | kdOrigin.x += screen->width; |
| 360 | kdOrigin.y = 0; |
| 361 | kdDumbDriver = FALSE0; |
| 362 | kdSoftCursor = FALSE0; |
| 363 | kdSubpixelOrder = SubPixelUnknown0; |
| 364 | |
| 365 | if (delim == '+') { |
| 366 | arg = KdParseFindNext(arg, "+@xXY", save, &delim); |
| 367 | if (save[0]) |
| 368 | screen->x = atoi(save); |
| 369 | } |
| 370 | |
| 371 | if (delim == '+') { |
| 372 | arg = KdParseFindNext(arg, "@xXY", save, &delim); |
| 373 | if (save[0]) |
| 374 | screen->y = atoi(save); |
| 375 | } |
| 376 | |
| 377 | if (delim == '@') { |
| 378 | arg = KdParseFindNext(arg, "xXY", save, &delim); |
| 379 | if (save[0]) { |
| 380 | int rotate = atoi(save); |
| 381 | |
| 382 | if (rotate < 45) |
| 383 | screen->randr = RR_Rotate_01; |
| 384 | else if (rotate < 135) |
| 385 | screen->randr = RR_Rotate_902; |
| 386 | else if (rotate < 225) |
| 387 | screen->randr = RR_Rotate_1804; |
| 388 | else if (rotate < 315) |
| 389 | screen->randr = RR_Rotate_2708; |
| 390 | else |
| 391 | screen->randr = RR_Rotate_01; |
| 392 | } |
| 393 | } |
| 394 | if (delim == 'X') { |
| 395 | arg = KdParseFindNext(arg, "xY", save, &delim); |
| 396 | screen->randr |= RR_Reflect_X16; |
| 397 | } |
| 398 | |
| 399 | if (delim == 'Y') { |
| 400 | arg = KdParseFindNext(arg, "xY", save, &delim); |
| 401 | screen->randr |= RR_Reflect_Y32; |
| 402 | } |
| 403 | |
| 404 | arg = KdParseFindNext(arg, "x/,", save, &delim); |
| 405 | if (save[0]) { |
| 406 | screen->fb.depth = atoi(save); |
| 407 | if (delim == '/') { |
| 408 | arg = KdParseFindNext(arg, "x,", save, &delim); |
| 409 | if (save[0]) |
| 410 | screen->fb.bitsPerPixel = atoi(save); |
| 411 | } |
| 412 | else |
| 413 | screen->fb.bitsPerPixel = 0; |
| 414 | } |
| 415 | |
| 416 | if (delim == 'x') { |
| 417 | arg = KdParseFindNext(arg, "x", save, &delim); |
Value stored to 'arg' is never read | |
| 418 | if (save[0]) |
| 419 | screen->rate = atoi(save); |
| 420 | } |
| 421 | } |
| 422 | |
| 423 | /* |
| 424 | * Mouse argument syntax: |
| 425 | * |
| 426 | * device,protocol,options... |
| 427 | * |
| 428 | * Options are any of: |
| 429 | * 1-5 n button mouse |
| 430 | * 2button emulate middle button |
| 431 | * {NMO} Reorder buttons |
| 432 | */ |
| 433 | |
| 434 | void |
| 435 | KdParseRgba(char *rgba) |
| 436 | { |
| 437 | if (!strcmp(rgba, "rgb")) |
| 438 | kdSubpixelOrder = SubPixelHorizontalRGB1; |
| 439 | else if (!strcmp(rgba, "bgr")) |
| 440 | kdSubpixelOrder = SubPixelHorizontalBGR2; |
| 441 | else if (!strcmp(rgba, "vrgb")) |
| 442 | kdSubpixelOrder = SubPixelVerticalRGB3; |
| 443 | else if (!strcmp(rgba, "vbgr")) |
| 444 | kdSubpixelOrder = SubPixelVerticalBGR4; |
| 445 | else if (!strcmp(rgba, "none")) |
| 446 | kdSubpixelOrder = SubPixelNone5; |
| 447 | else |
| 448 | kdSubpixelOrder = SubPixelUnknown0; |
| 449 | } |
| 450 | |
| 451 | void |
| 452 | KdUseMsg(void) |
| 453 | { |
| 454 | ErrorF("\nTinyX Device Dependent Usage:\n"); |
| 455 | ErrorF |
| 456 | ("-screen WIDTH[/WIDTHMM]xHEIGHT[/HEIGHTMM][+[-]XOFFSET][+[-]YOFFSET][@ROTATION][X][Y][xDEPTH/BPP[xFREQ]] Specify screen characteristics\n"); |
| 457 | ErrorF |
| 458 | ("-rgba rgb/bgr/vrgb/vbgr/none Specify subpixel ordering for LCD panels\n"); |
| 459 | ErrorF |
| 460 | ("-mouse driver [,n,,options] Specify the pointer driver and its options (n is the number of buttons)\n"); |
| 461 | ErrorF |
| 462 | ("-keybd driver [,,options] Specify the keyboard driver and its options\n"); |
| 463 | ErrorF("-xkb-rules Set default XkbRules value (can be overriden by -keybd options)\n"); |
| 464 | ErrorF("-xkb-model Set default XkbModel value (can be overriden by -keybd options)\n"); |
| 465 | ErrorF("-xkb-layout Set default XkbLayout value (can be overriden by -keybd options)\n"); |
| 466 | ErrorF("-xkb-variant Set default XkbVariant value (can be overriden by -keybd options)\n"); |
| 467 | ErrorF("-xkb-options Set default XkbOptions value (can be overriden by -keybd options)\n"); |
| 468 | ErrorF("-zaphod Disable cursor screen switching\n"); |
| 469 | ErrorF("-2button Emulate 3 button mouse\n"); |
| 470 | ErrorF("-3button Disable 3 button mouse emulation\n"); |
| 471 | ErrorF |
| 472 | ("-rawcoord Don't transform pointer coordinates on rotation\n"); |
| 473 | ErrorF("-dumb Disable hardware acceleration\n"); |
| 474 | ErrorF("-softCursor Force software cursor\n"); |
| 475 | ErrorF("-videoTest Start the server, pause momentarily and exit\n"); |
| 476 | ErrorF |
| 477 | ("-origin X,Y Locates the next screen in the the virtual screen (Xinerama)\n"); |
| 478 | ErrorF("-switchCmd Command to execute on vt switch\n"); |
| 479 | ErrorF("-zap Terminate server on Ctrl+Alt+Backspace\n"); |
| 480 | ErrorF |
| 481 | ("vtxx Use virtual terminal xx instead of the next available\n"); |
| 482 | } |
| 483 | |
| 484 | int |
| 485 | KdProcessArgument(int argc, char **argv, int i) |
| 486 | { |
| 487 | KdCardInfo *card; |
| 488 | KdScreenInfo *screen; |
| 489 | |
| 490 | if (!strcmp(argv[i], "-screen")) { |
| 491 | if ((i + 1) < argc) { |
| 492 | card = KdCardInfoLast(); |
| 493 | if (!card) { |
| 494 | InitCard(0); |
| 495 | card = KdCardInfoLast(); |
| 496 | } |
| 497 | if (card) { |
| 498 | screen = KdScreenInfoAdd(card); |
| 499 | KdParseScreen(screen, argv[i + 1]); |
| 500 | } |
| 501 | else |
| 502 | ErrorF("No matching card found!\n"); |
| 503 | } |
| 504 | else |
| 505 | UseMsg(); |
| 506 | return 2; |
| 507 | } |
| 508 | if (!strcmp(argv[i], "-zaphod")) { |
| 509 | kdDisableZaphod = TRUE1; |
| 510 | return 1; |
| 511 | } |
| 512 | if (!strcmp(argv[i], "-zap")) { |
| 513 | kdAllowZap = TRUE1; |
| 514 | return 1; |
| 515 | } |
| 516 | if (!strcmp(argv[i], "-3button")) { |
| 517 | kdEmulateMiddleButton = FALSE0; |
| 518 | return 1; |
| 519 | } |
| 520 | if (!strcmp(argv[i], "-2button")) { |
| 521 | kdEmulateMiddleButton = TRUE1; |
| 522 | return 1; |
| 523 | } |
| 524 | if (!strcmp(argv[i], "-rawcoord")) { |
| 525 | kdRawPointerCoordinates = 1; |
| 526 | return 1; |
| 527 | } |
| 528 | if (!strcmp(argv[i], "-dumb")) { |
| 529 | kdDumbDriver = TRUE1; |
| 530 | return 1; |
| 531 | } |
| 532 | if (!strcmp(argv[i], "-softCursor")) { |
| 533 | kdSoftCursor = TRUE1; |
| 534 | return 1; |
| 535 | } |
| 536 | if (!strcmp(argv[i], "-videoTest")) { |
| 537 | kdVideoTest = TRUE1; |
| 538 | return 1; |
| 539 | } |
| 540 | if (!strcmp(argv[i], "-origin")) { |
| 541 | if ((i + 1) < argc) { |
| 542 | char *x = argv[i + 1]; |
| 543 | char *y = strchr(x, ','); |
| 544 | |
| 545 | if (x) |
| 546 | kdOrigin.x = atoi(x); |
| 547 | else |
| 548 | kdOrigin.x = 0; |
| 549 | if (y) |
| 550 | kdOrigin.y = atoi(y + 1); |
| 551 | else |
| 552 | kdOrigin.y = 0; |
| 553 | } |
| 554 | else |
| 555 | UseMsg(); |
| 556 | return 2; |
| 557 | } |
| 558 | if (!strcmp(argv[i], "-rgba")) { |
| 559 | if ((i + 1) < argc) |
| 560 | KdParseRgba(argv[i + 1]); |
| 561 | else |
| 562 | UseMsg(); |
| 563 | return 2; |
| 564 | } |
| 565 | if (!strcmp(argv[i], "-switchCmd")) { |
| 566 | if ((i + 1) < argc) |
| 567 | kdSwitchCmd = argv[i + 1]; |
| 568 | else |
| 569 | UseMsg(); |
| 570 | return 2; |
| 571 | } |
| 572 | if (!strncmp(argv[i], "vt", 2) && |
| 573 | sscanf(argv[i], "vt%2d", &kdVirtualTerminal) == 1) { |
| 574 | return 1; |
| 575 | } |
| 576 | if (!strcmp(argv[i], "-xkb-rules")) { |
| 577 | if (i + 1 >= argc) { |
| 578 | UseMsg(); |
| 579 | FatalError("Missing argument for option -xkb-rules.\n"); |
| 580 | } |
| 581 | kdGlobalXkbRules = argv[i + 1]; |
| 582 | return 2; |
| 583 | } |
| 584 | if (!strcmp(argv[i], "-xkb-model")) { |
| 585 | if (i + 1 >= argc) { |
| 586 | UseMsg(); |
| 587 | FatalError("Missing argument for option -xkb-model.\n"); |
| 588 | } |
| 589 | kdGlobalXkbModel = argv[i + 1]; |
| 590 | return 2; |
| 591 | } |
| 592 | if (!strcmp(argv[i], "-xkb-layout")) { |
| 593 | if (i + 1 >= argc) { |
| 594 | UseMsg(); |
| 595 | FatalError("Missing argument for option -xkb-layout.\n"); |
| 596 | } |
| 597 | kdGlobalXkbLayout = argv[i + 1]; |
| 598 | return 2; |
| 599 | } |
| 600 | if (!strcmp(argv[i], "-xkb-variant")) { |
| 601 | if (i + 1 >= argc) { |
| 602 | UseMsg(); |
| 603 | FatalError("Missing argument for option -xkb-variant.\n"); |
| 604 | } |
| 605 | kdGlobalXkbVariant = argv[i + 1]; |
| 606 | return 2; |
| 607 | } |
| 608 | if (!strcmp(argv[i], "-xkb-options")) { |
| 609 | if (i + 1 >= argc) { |
| 610 | UseMsg(); |
| 611 | FatalError("Missing argument for option -xkb-options.\n"); |
| 612 | } |
| 613 | kdGlobalXkbOptions = argv[i + 1]; |
| 614 | return 2; |
| 615 | } |
| 616 | if (!strcmp(argv[i], "-mouse") || !strcmp(argv[i], "-pointer")) { |
| 617 | if (i + 1 >= argc) |
| 618 | UseMsg(); |
| 619 | KdAddConfigPointer(argv[i + 1]); |
| 620 | kdHasPointer = TRUE1; |
| 621 | return 2; |
| 622 | } |
| 623 | if (!strcmp(argv[i], "-keybd")) { |
| 624 | if (i + 1 >= argc) |
| 625 | UseMsg(); |
| 626 | KdAddConfigKeyboard(argv[i + 1]); |
| 627 | kdHasKbd = TRUE1; |
| 628 | return 2; |
| 629 | } |
| 630 | |
| 631 | return 0; |
| 632 | } |
| 633 | |
| 634 | /* |
| 635 | * These are getting tossed in here until I can think of where |
| 636 | * they really belong |
| 637 | */ |
| 638 | |
| 639 | void |
| 640 | KdOsInit(KdOsFuncs * pOsFuncs) |
| 641 | { |
| 642 | kdOsFuncs = pOsFuncs; |
| 643 | if (pOsFuncs) { |
| 644 | if (serverGeneration == 1) { |
| 645 | KdDoSwitchCmd("start"); |
| 646 | if (pOsFuncs->Init) |
| 647 | (*pOsFuncs->Init) (); |
| 648 | } |
| 649 | } |
| 650 | } |
| 651 | |
| 652 | Bool |
| 653 | KdAllocatePrivates(ScreenPtr pScreen) |
| 654 | { |
| 655 | KdPrivScreenPtr pScreenPriv; |
| 656 | |
| 657 | if (kdGeneration != serverGeneration) |
| 658 | kdGeneration = serverGeneration; |
| 659 | |
| 660 | if (!dixRegisterPrivateKey(&kdScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) |
| 661 | return FALSE0; |
| 662 | |
| 663 | pScreenPriv = calloc(1, sizeof(*pScreenPriv)); |
| 664 | if (!pScreenPriv) |
| 665 | return FALSE0; |
| 666 | KdSetScreenPriv(pScreen, pScreenPriv)dixSetPrivate(&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec ), pScreenPriv); |
| 667 | return TRUE1; |
| 668 | } |
| 669 | |
| 670 | Bool |
| 671 | KdCreateScreenResources(ScreenPtr pScreen) |
| 672 | { |
| 673 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 674 | KdCardInfo *card = pScreenPriv->card; |
| 675 | Bool ret; |
| 676 | |
| 677 | pScreen->CreateScreenResources = pScreenPriv->CreateScreenResources; |
| 678 | if (pScreen->CreateScreenResources) |
| 679 | ret = (*pScreen->CreateScreenResources) (pScreen); |
| 680 | else |
| 681 | ret = -1; |
| 682 | pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; |
| 683 | pScreen->CreateScreenResources = KdCreateScreenResources; |
| 684 | if (ret && card->cfuncs->createRes) |
| 685 | ret = (*card->cfuncs->createRes) (pScreen); |
| 686 | return ret; |
| 687 | } |
| 688 | |
| 689 | Bool |
| 690 | KdCloseScreen(ScreenPtr pScreen) |
| 691 | { |
| 692 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 693 | KdScreenInfo *screen = pScreenPriv->screen; |
| 694 | KdCardInfo *card = pScreenPriv->card; |
| 695 | Bool ret; |
| 696 | |
| 697 | if (card->cfuncs->closeScreen) |
| 698 | (*card->cfuncs->closeScreen)(pScreen); |
| 699 | |
| 700 | pScreenPriv->closed = TRUE1; |
| 701 | pScreen->CloseScreen = pScreenPriv->CloseScreen; |
| 702 | |
| 703 | if (pScreen->CloseScreen) |
| 704 | ret = (*pScreen->CloseScreen) (pScreen); |
| 705 | else |
| 706 | ret = TRUE1; |
| 707 | |
| 708 | if (pScreenPriv->dpmsState != KD_DPMS_NORMAL0) |
| 709 | (*card->cfuncs->dpms) (pScreen, KD_DPMS_NORMAL0); |
| 710 | |
| 711 | if (screen->mynum == card->selected) |
| 712 | KdDisableScreen(pScreen); |
| 713 | |
| 714 | /* |
| 715 | * Restore video hardware when last screen is closed |
| 716 | */ |
| 717 | if (screen == card->screenList) { |
| 718 | if (kdEnabled && card->cfuncs->restore) |
| 719 | (*card->cfuncs->restore) (card); |
| 720 | } |
| 721 | |
| 722 | if (!pScreenPriv->screen->dumb && card->cfuncs->finiAccel) |
| 723 | (*card->cfuncs->finiAccel) (pScreen); |
| 724 | |
| 725 | if (!pScreenPriv->screen->softCursor && card->cfuncs->finiCursor) |
| 726 | (*card->cfuncs->finiCursor) (pScreen); |
| 727 | |
| 728 | if (card->cfuncs->scrfini) |
| 729 | (*card->cfuncs->scrfini) (screen); |
| 730 | |
| 731 | /* |
| 732 | * Clean up card when last screen is closed, DIX closes them in |
| 733 | * reverse order, thus we check for when the first in the list is closed |
| 734 | */ |
| 735 | if (screen == card->screenList) { |
| 736 | if (card->cfuncs->cardfini) |
| 737 | (*card->cfuncs->cardfini) (card); |
| 738 | /* |
| 739 | * Clean up OS when last card is closed |
| 740 | */ |
| 741 | if (card == kdCardInfo) { |
| 742 | if (kdEnabled) { |
| 743 | kdEnabled = FALSE0; |
| 744 | if (kdOsFuncs->Disable) |
| 745 | (*kdOsFuncs->Disable) (); |
| 746 | } |
| 747 | } |
| 748 | } |
| 749 | |
| 750 | pScreenPriv->screen->pScreen = 0; |
| 751 | |
| 752 | free((void *) pScreenPriv); |
| 753 | return ret; |
| 754 | } |
| 755 | |
| 756 | Bool |
| 757 | KdSaveScreen(ScreenPtr pScreen, int on) |
| 758 | { |
| 759 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 760 | int dpmsState; |
| 761 | |
| 762 | if (!pScreenPriv->card->cfuncs->dpms) |
| 763 | return FALSE0; |
| 764 | |
| 765 | dpmsState = pScreenPriv->dpmsState; |
| 766 | switch (on) { |
| 767 | case SCREEN_SAVER_OFF1: |
| 768 | dpmsState = KD_DPMS_NORMAL0; |
| 769 | break; |
| 770 | case SCREEN_SAVER_ON0: |
| 771 | if (dpmsState == KD_DPMS_NORMAL0) |
| 772 | dpmsState = KD_DPMS_NORMAL0 + 1; |
| 773 | break; |
| 774 | case SCREEN_SAVER_CYCLE3: |
| 775 | if (dpmsState < KD_DPMS_MAX3) |
| 776 | dpmsState++; |
| 777 | break; |
| 778 | case SCREEN_SAVER_FORCER2: |
| 779 | break; |
| 780 | } |
| 781 | if (dpmsState != pScreenPriv->dpmsState) { |
| 782 | if (pScreenPriv->enabled) |
| 783 | (*pScreenPriv->card->cfuncs->dpms) (pScreen, dpmsState); |
| 784 | pScreenPriv->dpmsState = dpmsState; |
| 785 | } |
| 786 | return TRUE1; |
| 787 | } |
| 788 | |
| 789 | static Bool |
| 790 | KdCreateWindow(WindowPtr pWin) |
| 791 | { |
| 792 | #ifndef PHOENIX |
| 793 | if (!pWin->parent) { |
| 794 | KdScreenPriv(pWin->drawable.pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pWin->drawable.pScreen)->devPrivates, (&kdScreenPrivateKeyRec ))); |
| 795 | |
| 796 | if (!pScreenPriv->enabled) { |
| 797 | RegionEmpty(&pWin->borderClip); |
| 798 | RegionBreak(&pWin->clipList); |
| 799 | } |
| 800 | } |
| 801 | #endif |
| 802 | return fbCreateWindow(pWin); |
| 803 | } |
| 804 | |
| 805 | void |
| 806 | KdSetSubpixelOrder(ScreenPtr pScreen, Rotation randr) |
| 807 | { |
| 808 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 809 | KdScreenInfo *screen = pScreenPriv->screen; |
| 810 | int subpixel_order = screen->subpixel_order; |
| 811 | Rotation subpixel_dir; |
| 812 | int i; |
| 813 | |
| 814 | static struct { |
| 815 | int subpixel_order; |
| 816 | Rotation direction; |
| 817 | } orders[] = { |
| 818 | {SubPixelHorizontalRGB1, RR_Rotate_01}, |
| 819 | {SubPixelHorizontalBGR2, RR_Rotate_1804}, |
| 820 | {SubPixelVerticalRGB3, RR_Rotate_2708}, |
| 821 | {SubPixelVerticalBGR4, RR_Rotate_902}, |
| 822 | }; |
| 823 | |
| 824 | static struct { |
| 825 | int bit; |
| 826 | int normal; |
| 827 | int reflect; |
| 828 | } reflects[] = { |
| 829 | {RR_Reflect_X16, SubPixelHorizontalRGB1, SubPixelHorizontalBGR2}, |
| 830 | {RR_Reflect_X16, SubPixelHorizontalBGR2, SubPixelHorizontalRGB1}, |
| 831 | {RR_Reflect_Y32, SubPixelVerticalRGB3, SubPixelVerticalBGR4}, |
| 832 | {RR_Reflect_Y32, SubPixelVerticalRGB3, SubPixelVerticalRGB3}, |
| 833 | }; |
| 834 | |
| 835 | /* map subpixel to direction */ |
| 836 | for (i = 0; i < 4; i++) |
| 837 | if (orders[i].subpixel_order == subpixel_order) |
| 838 | break; |
| 839 | if (i < 4) { |
| 840 | subpixel_dir = |
| 841 | KdAddRotation(randr & RR_Rotate_All(1|2|4|8), orders[i].direction); |
| 842 | |
| 843 | /* map back to subpixel order */ |
| 844 | for (i = 0; i < 4; i++) |
| 845 | if (orders[i].direction & subpixel_dir) { |
| 846 | subpixel_order = orders[i].subpixel_order; |
| 847 | break; |
| 848 | } |
| 849 | /* reflect */ |
| 850 | for (i = 0; i < 4; i++) |
| 851 | if ((randr & reflects[i].bit) && |
| 852 | reflects[i].normal == subpixel_order) { |
| 853 | subpixel_order = reflects[i].reflect; |
| 854 | break; |
| 855 | } |
| 856 | } |
| 857 | PictureSetSubpixelOrder(pScreen, subpixel_order); |
| 858 | } |
| 859 | |
| 860 | /* Pass through AddScreen, which doesn't take any closure */ |
| 861 | static KdScreenInfo *kdCurrentScreen; |
| 862 | |
| 863 | Bool |
| 864 | KdScreenInit(ScreenPtr pScreen, int argc, char **argv) |
| 865 | { |
| 866 | KdScreenInfo *screen = kdCurrentScreen; |
| 867 | KdCardInfo *card = screen->card; |
| 868 | KdPrivScreenPtr pScreenPriv; |
| 869 | |
| 870 | /* |
| 871 | * note that screen->fb is set up for the nominal orientation |
| 872 | * of the screen; that means if randr is rotated, the values |
| 873 | * there should reflect a rotated frame buffer (or shadow). |
| 874 | */ |
| 875 | Bool rotated = (screen->randr & (RR_Rotate_902 | RR_Rotate_2708)) != 0; |
| 876 | int width, height, *width_mmp, *height_mmp; |
| 877 | |
| 878 | KdAllocatePrivates(pScreen); |
| 879 | |
| 880 | pScreenPriv = KdGetScreenPriv(pScreen)((KdPrivScreenPtr) dixLookupPrivate(&(pScreen)->devPrivates , (&kdScreenPrivateKeyRec))); |
| 881 | |
| 882 | if (!rotated) { |
| 883 | width = screen->width; |
| 884 | height = screen->height; |
| 885 | width_mmp = &screen->width_mm; |
| 886 | height_mmp = &screen->height_mm; |
| 887 | } |
| 888 | else { |
| 889 | width = screen->height; |
| 890 | height = screen->width; |
| 891 | width_mmp = &screen->height_mm; |
| 892 | height_mmp = &screen->width_mm; |
| 893 | } |
| 894 | screen->pScreen = pScreen; |
| 895 | pScreenPriv->screen = screen; |
| 896 | pScreenPriv->card = card; |
| 897 | pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3; |
| 898 | pScreenPriv->dpmsState = KD_DPMS_NORMAL0; |
| 899 | pScreen->x = screen->origin.x; |
| 900 | pScreen->y = screen->origin.y; |
| 901 | |
| 902 | if (!monitorResolution) |
| 903 | monitorResolution = 75; |
| 904 | /* |
| 905 | * This is done in this order so that backing store wraps |
| 906 | * our GC functions; fbFinishScreenInit initializes MI |
| 907 | * backing store |
| 908 | */ |
| 909 | if (!fbSetupScreen(pScreen, |
| 910 | screen->fb.frameBuffer, |
| 911 | width, height, |
| 912 | monitorResolution, monitorResolution, |
| 913 | screen->fb.pixelStride, screen->fb.bitsPerPixel)) { |
| 914 | return FALSE0; |
| 915 | } |
| 916 | |
| 917 | /* |
| 918 | * Set colormap functions |
| 919 | */ |
| 920 | pScreen->InstallColormap = KdInstallColormap; |
| 921 | pScreen->UninstallColormap = KdUninstallColormap; |
| 922 | pScreen->ListInstalledColormaps = KdListInstalledColormaps; |
| 923 | pScreen->StoreColors = KdStoreColors; |
| 924 | |
| 925 | pScreen->SaveScreen = KdSaveScreen; |
| 926 | pScreen->CreateWindow = KdCreateWindow; |
| 927 | |
| 928 | if (!fbFinishScreenInit(pScreen, |
| 929 | screen->fb.frameBuffer, |
| 930 | width, height, |
| 931 | monitorResolution, monitorResolution, |
| 932 | screen->fb.pixelStride, screen->fb.bitsPerPixel)) { |
| 933 | return FALSE0; |
| 934 | } |
| 935 | |
| 936 | /* |
| 937 | * Fix screen sizes; for some reason mi takes dpi instead of mm. |
| 938 | * Rounding errors are annoying |
| 939 | */ |
| 940 | if (*width_mmp) |
| 941 | pScreen->mmWidth = *width_mmp; |
| 942 | else |
| 943 | *width_mmp = pScreen->mmWidth; |
| 944 | if (*height_mmp) |
| 945 | pScreen->mmHeight = *height_mmp; |
| 946 | else |
| 947 | *height_mmp = pScreen->mmHeight; |
| 948 | |
| 949 | /* |
| 950 | * Plug in our own block/wakeup handlers. |
| 951 | * miScreenInit installs NoopDDA in both places |
| 952 | */ |
| 953 | pScreen->BlockHandler = KdBlockHandler; |
| 954 | pScreen->WakeupHandler = KdWakeupHandler; |
| 955 | |
| 956 | if (!fbPictureInit(pScreen, 0, 0)) |
| 957 | return FALSE0; |
| 958 | if (card->cfuncs->initScreen) |
| 959 | if (!(*card->cfuncs->initScreen) (pScreen)) |
| 960 | return FALSE0; |
| 961 | |
| 962 | if (!screen->dumb && card->cfuncs->initAccel) |
| 963 | if (!(*card->cfuncs->initAccel) (pScreen)) |
| 964 | screen->dumb = TRUE1; |
| 965 | |
| 966 | if (card->cfuncs->finishInitScreen) |
| 967 | if (!(*card->cfuncs->finishInitScreen) (pScreen)) |
| 968 | return FALSE0; |
| 969 | |
| 970 | /* |
| 971 | * Wrap CloseScreen, the order now is: |
| 972 | * KdCloseScreen |
| 973 | * miBSCloseScreen |
| 974 | * fbCloseScreen |
| 975 | */ |
| 976 | pScreenPriv->CloseScreen = pScreen->CloseScreen; |
| 977 | pScreen->CloseScreen = KdCloseScreen; |
| 978 | |
| 979 | pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; |
| 980 | pScreen->CreateScreenResources = KdCreateScreenResources; |
| 981 | |
| 982 | if (screen->softCursor || |
| 983 | !card->cfuncs->initCursor || !(*card->cfuncs->initCursor) (pScreen)) { |
| 984 | /* Use MI for cursor display and event queueing. */ |
| 985 | screen->softCursor = TRUE1; |
| 986 | miDCInitialize(pScreen, &kdPointerScreenFuncs); |
| 987 | } |
| 988 | |
| 989 | if (!fbCreateDefColormap(pScreen)) { |
| 990 | return FALSE0; |
| 991 | } |
| 992 | |
| 993 | KdSetSubpixelOrder(pScreen, screen->randr); |
| 994 | |
| 995 | /* |
| 996 | * Enable the hardware |
| 997 | */ |
| 998 | if (!kdEnabled) { |
| 999 | kdEnabled = TRUE1; |
| 1000 | if (kdOsFuncs->Enable) |
| 1001 | (*kdOsFuncs->Enable) (); |
| 1002 | } |
| 1003 | |
| 1004 | if (screen->mynum == card->selected) { |
| 1005 | if (card->cfuncs->preserve) |
| 1006 | (*card->cfuncs->preserve) (card); |
| 1007 | if (card->cfuncs->enable) |
| 1008 | if (!(*card->cfuncs->enable) (pScreen)) |
| 1009 | return FALSE0; |
| 1010 | pScreenPriv->enabled = TRUE1; |
| 1011 | if (!screen->softCursor && card->cfuncs->enableCursor) |
| 1012 | (*card->cfuncs->enableCursor) (pScreen); |
| 1013 | KdEnableColormap(pScreen); |
| 1014 | if (!screen->dumb && card->cfuncs->enableAccel) |
| 1015 | (*card->cfuncs->enableAccel) (pScreen); |
| 1016 | } |
| 1017 | |
| 1018 | return TRUE1; |
| 1019 | } |
| 1020 | |
| 1021 | void |
| 1022 | KdInitScreen(ScreenInfo * pScreenInfo, |
| 1023 | KdScreenInfo * screen, int argc, char **argv) |
| 1024 | { |
| 1025 | KdCardInfo *card = screen->card; |
| 1026 | |
| 1027 | if (!(*card->cfuncs->scrinit) (screen)) |
| 1028 | FatalError("Screen initialization failed!\n"); |
| 1029 | |
| 1030 | if (!card->cfuncs->initAccel) |
| 1031 | screen->dumb = TRUE1; |
| 1032 | if (!card->cfuncs->initCursor) |
| 1033 | screen->softCursor = TRUE1; |
| 1034 | } |
| 1035 | |
| 1036 | static Bool |
| 1037 | KdSetPixmapFormats(ScreenInfo * pScreenInfo) |
| 1038 | { |
| 1039 | CARD8 depthToBpp[33]; /* depth -> bpp map */ |
| 1040 | KdCardInfo *card; |
| 1041 | KdScreenInfo *screen; |
| 1042 | int i; |
| 1043 | int bpp; |
| 1044 | PixmapFormatRec *format; |
| 1045 | |
| 1046 | for (i = 1; i <= 32; i++) |
| 1047 | depthToBpp[i] = 0; |
| 1048 | |
| 1049 | /* |
| 1050 | * Generate mappings between bitsPerPixel and depth, |
| 1051 | * also ensure that all screens comply with protocol |
| 1052 | * restrictions on equivalent formats for the same |
| 1053 | * depth on different screens |
| 1054 | */ |
| 1055 | for (card = kdCardInfo; card; card = card->next) { |
| 1056 | for (screen = card->screenList; screen; screen = screen->next) { |
| 1057 | bpp = screen->fb.bitsPerPixel; |
| 1058 | if (bpp == 24) |
| 1059 | bpp = 32; |
| 1060 | if (!depthToBpp[screen->fb.depth]) |
| 1061 | depthToBpp[screen->fb.depth] = bpp; |
| 1062 | else if (depthToBpp[screen->fb.depth] != bpp) |
| 1063 | return FALSE0; |
| 1064 | } |
| 1065 | } |
| 1066 | |
| 1067 | /* |
| 1068 | * Fill in additional formats |
| 1069 | */ |
| 1070 | for (i = 0; i < NUM_KD_DEPTHS(sizeof (kdDepths) / sizeof (kdDepths[0])); i++) |
| 1071 | if (!depthToBpp[kdDepths[i].depth]) |
| 1072 | depthToBpp[kdDepths[i].depth] = kdDepths[i].bpp; |
| 1073 | |
| 1074 | pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER0; |
| 1075 | pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT32; |
| 1076 | pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD32; |
| 1077 | pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER0; |
| 1078 | |
| 1079 | pScreenInfo->numPixmapFormats = 0; |
| 1080 | |
| 1081 | for (i = 1; i <= 32; i++) { |
| 1082 | if (depthToBpp[i]) { |
| 1083 | format = &pScreenInfo->formats[pScreenInfo->numPixmapFormats++]; |
| 1084 | format->depth = i; |
| 1085 | format->bitsPerPixel = depthToBpp[i]; |
| 1086 | format->scanlinePad = BITMAP_SCANLINE_PAD32; |
| 1087 | } |
| 1088 | } |
| 1089 | |
| 1090 | return TRUE1; |
| 1091 | } |
| 1092 | |
| 1093 | static void |
| 1094 | KdAddScreen(ScreenInfo * pScreenInfo, |
| 1095 | KdScreenInfo * screen, int argc, char **argv) |
| 1096 | { |
| 1097 | int i; |
| 1098 | |
| 1099 | /* |
| 1100 | * Fill in fb visual type masks for this screen |
| 1101 | */ |
| 1102 | for (i = 0; i < pScreenInfo->numPixmapFormats; i++) { |
| 1103 | unsigned long visuals; |
| 1104 | Pixel rm, gm, bm; |
| 1105 | |
| 1106 | visuals = 0; |
| 1107 | rm = gm = bm = 0; |
| 1108 | if (pScreenInfo->formats[i].depth == screen->fb.depth) { |
| 1109 | visuals = screen->fb.visuals; |
| 1110 | rm = screen->fb.redMask; |
| 1111 | gm = screen->fb.greenMask; |
| 1112 | bm = screen->fb.blueMask; |
| 1113 | } |
| 1114 | fbSetVisualTypesAndMasks(pScreenInfo->formats[i].depth, |
| 1115 | visuals, 8, rm, gm, bm); |
| 1116 | } |
| 1117 | |
| 1118 | kdCurrentScreen = screen; |
| 1119 | |
| 1120 | AddScreen(KdScreenInit, argc, argv); |
| 1121 | } |
| 1122 | |
| 1123 | #if 0 /* This function is not used currently */ |
| 1124 | |
| 1125 | int |
| 1126 | KdDepthToFb(ScreenPtr pScreen, int depth) |
| 1127 | { |
| 1128 | KdScreenPriv(pScreen)KdPrivScreenPtr pScreenPriv = ((KdPrivScreenPtr) dixLookupPrivate (&(pScreen)->devPrivates, (&kdScreenPrivateKeyRec) )); |
| 1129 | |
| 1130 | for (fb = 0; fb <= KD_MAX_FB && pScreenPriv->screen->fb.frameBuffer; fb++) |
| 1131 | if (pScreenPriv->screen->fb.depth == depth) |
| 1132 | return fb; |
| 1133 | } |
| 1134 | |
| 1135 | #endif |
| 1136 | |
| 1137 | static int |
| 1138 | KdSignalWrapper(int signum) |
| 1139 | { |
| 1140 | kdCaughtSignal = TRUE1; |
| 1141 | return 1; /* use generic OS layer cleanup & abort */ |
| 1142 | } |
| 1143 | |
| 1144 | void |
| 1145 | KdInitOutput(ScreenInfo * pScreenInfo, int argc, char **argv) |
| 1146 | { |
| 1147 | KdCardInfo *card; |
| 1148 | KdScreenInfo *screen; |
| 1149 | |
| 1150 | if (!kdCardInfo) { |
| 1151 | InitCard(0); |
| 1152 | if (!(card = KdCardInfoLast())) |
| 1153 | FatalError("No matching cards found!\n"); |
| 1154 | screen = KdScreenInfoAdd(card); |
| 1155 | KdParseScreen(screen, 0); |
| 1156 | } |
| 1157 | /* |
| 1158 | * Initialize all of the screens for all of the cards |
| 1159 | */ |
| 1160 | for (card = kdCardInfo; card; card = card->next) { |
| 1161 | int ret = 1; |
| 1162 | |
| 1163 | if (card->cfuncs->cardinit) |
| 1164 | ret = (*card->cfuncs->cardinit) (card); |
| 1165 | if (ret) { |
| 1166 | for (screen = card->screenList; screen; screen = screen->next) |
| 1167 | KdInitScreen(pScreenInfo, screen, argc, argv); |
| 1168 | } |
| 1169 | } |
| 1170 | |
| 1171 | /* |
| 1172 | * Merge the various pixmap formats together, this can fail |
| 1173 | * when two screens share depth but not bitsPerPixel |
| 1174 | */ |
| 1175 | if (!KdSetPixmapFormats(pScreenInfo)) |
| 1176 | return; |
| 1177 | |
| 1178 | /* |
| 1179 | * Add all of the screens |
| 1180 | */ |
| 1181 | for (card = kdCardInfo; card; card = card->next) |
| 1182 | for (screen = card->screenList; screen; screen = screen->next) |
| 1183 | KdAddScreen(pScreenInfo, screen, argc, argv); |
| 1184 | |
| 1185 | OsRegisterSigWrapper(KdSignalWrapper); |
| 1186 | |
| 1187 | #if defined(CONFIG_UDEV) || defined(CONFIG_HAL) |
| 1188 | if (SeatId) /* Enable input hot-plugging */ |
| 1189 | config_pre_init(); |
| 1190 | #endif |
| 1191 | } |
| 1192 | |
| 1193 | void |
| 1194 | OsVendorFatalError(const char *f, va_list args) |
| 1195 | { |
| 1196 | } |
| 1197 | |
| 1198 | int |
| 1199 | DPMSSet(ClientPtr client, int level) |
| 1200 | { |
| 1201 | return Success0; |
| 1202 | } |
| 1203 | |
| 1204 | Bool |
| 1205 | DPMSSupported(void) |
| 1206 | { |
| 1207 | return FALSE0; |
| 1208 | } |
| 1209 | |
| 1210 | /* These stubs can be safely removed once we can |
| 1211 | * split input and GPU parts in hotplug.h et al. */ |
| 1212 | #ifdef CONFIG_UDEV_KMS |
| 1213 | void |
| 1214 | NewGPUDeviceRequest(struct OdevAttributes *attribs) |
| 1215 | { |
| 1216 | } |
| 1217 | |
| 1218 | void |
| 1219 | DeleteGPUDeviceRequest(struct OdevAttributes *attribs) |
| 1220 | { |
| 1221 | } |
| 1222 | #endif |
| 1223 | |
| 1224 | struct xf86_platform_device * |
| 1225 | xf86_find_platform_device_by_devnum(int major, int minor) |
| 1226 | { |
| 1227 | return NULL((void*)0); |
| 1228 | } |
| 1229 | |
| 1230 | #ifdef SYSTEMD_LOGIND |
| 1231 | void |
| 1232 | systemd_logind_vtenter(void) |
| 1233 | { |
| 1234 | } |
| 1235 | |
| 1236 | void |
| 1237 | systemd_logind_release_fd(int major, int minor, int fd)close(int fd) |
| 1238 | { |
| 1239 | close(fd); |
| 1240 | } |
| 1241 | #endif |