Ticket #56: 1006-randr12.patch
File 1006-randr12.patch, 7.8 KB (added by , 7 years ago) |
---|
-
src/dummy_driver.c
Don't bother creating RandR outputs or creating or validating modes. Instead, just invent a dummy DisplayModeRec for the current screen size. Plug in a RandR framebuffer resize hook to allow resizing the screen. Update the screen pixmap, ScrnInfo structure, and dummy mode when that happens. Dispense with the pScrn->videoRam field. Instead, use the Virtual size from the Display subsection of the Screen section. If that's not set, default to something reasonable by today's standards. Based on an idea by Nicolas Boichat <drinkcat at chromium.org> (http://lists.x.org/archives/xorg-devel/2014-November/044580.html) Signed-off-by: Aaron Plattner <aplattner at nvidia.com> --- src/dummy_driver.c | 166 ++++++++++++++++++++++------------------------------- 1 file changed, 70 insertions(+), 96 deletions(-) diff --git a/src/dummy_driver.c b/src/dummy_driver.c index 8262f39f2563..48956ef72b50 100644
a b 22 22 #include "property.h" 23 23 24 24 #include "xf86cmap.h" 25 26 #include "xf86fbman.h" 25 #include "xf86Crtc.h" 27 26 28 27 #include "fb.h" 29 28 … … static Bool dummyDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, 71 70 #define DUMMY_MINOR_VERSION PACKAGE_VERSION_MINOR 72 71 #define DUMMY_PATCHLEVEL PACKAGE_VERSION_PATCHLEVEL 73 72 74 #define DUMMY_MAX_WIDTH 3276775 #define DUMMY_MAX_HEIGHT 3276776 77 73 /* 78 74 * This is intentionally screen-independent. It indicates the binding 79 75 * choice made in the first PreInit. … … dummySetup(pointer module, pointer opts, int *errmaj, int *errmin) 165 161 166 162 #endif /* XFree86LOADER */ 167 163 164 /* 165 * Build a DisplayModeRec that matches the screen's dimensions. 166 * 167 * Make up a fake pixel clock so that applications that use the VidMode 168 * extension to query the "refresh rate" get 60 Hz. 169 */ 170 static void ConstructFakeDisplayMode(ScrnInfoPtr pScrn, DisplayModePtr mode) 171 { 172 mode->HDisplay = mode->HSyncStart = mode->HSyncEnd = mode->HTotal = 173 pScrn->virtualX; 174 mode->VDisplay = mode->VSyncStart = mode->VSyncEnd = mode->VTotal = 175 pScrn->virtualY; 176 mode->Clock = mode->HTotal * mode->VTotal * 60 / 1000; 177 178 xf86SetCrtcForModes(pScrn, 0); 179 } 180 181 static Bool 182 dummy_xf86crtc_resize(ScrnInfoPtr pScrn, int width, int height) 183 { 184 ScreenPtr pScreen = pScrn->pScreen; 185 PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); 186 int newPitch = width * (pScrn->bitsPerPixel / 8); 187 void *oldScreen = rootPixmap->devPrivate.ptr; 188 void *newScreen = calloc(newPitch, height); 189 190 if (!newScreen) 191 return FALSE; 192 193 if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, 194 -1, -1, newPitch, newScreen)) { 195 free(newScreen); 196 return FALSE; 197 } 198 199 free(oldScreen); 200 201 pScrn->virtualX = width; 202 pScrn->virtualY = height; 203 pScrn->displayWidth = width; 204 ConstructFakeDisplayMode(pScrn, pScrn->modes); 205 206 return TRUE; 207 } 208 209 static const xf86CrtcConfigFuncsRec dummy_xf86crtc_config_funcs = { 210 dummy_xf86crtc_resize 211 }; 212 168 213 static Bool 169 214 DUMMYGetRec(ScrnInfoPtr pScrn) 170 215 { … … DUMMYProbe(DriverPtr drv, int flags) 266 311 Bool 267 312 DUMMYPreInit(ScrnInfoPtr pScrn, int flags) 268 313 { 269 ClockRangePtr clockRanges;270 int i;271 314 DUMMYPtr dPtr; 272 int maxClock = 230000;273 315 GDevPtr device = xf86GetEntityInfo(pScrn->entityList[0])->device; 274 316 275 317 if (flags & PROBE_DETECT) … … DUMMYPreInit(ScrnInfoPtr pScrn, int flags) 351 393 352 394 xf86GetOptValBool(dPtr->Options, OPTION_SW_CURSOR,&dPtr->swCursor); 353 395 354 if (device->videoRam != 0) { 355 pScrn->videoRam = device->videoRam; 356 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "VideoRAM: %d kByte\n", 357 pScrn->videoRam); 358 } else { 359 pScrn->videoRam = 4096; 360 xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "VideoRAM: %d kByte\n", 361 pScrn->videoRam); 362 } 363 364 if (device->dacSpeeds[0] != 0) { 365 maxClock = device->dacSpeeds[0]; 366 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Max Clock: %d kHz\n", 367 maxClock); 368 } else { 369 xf86DrvMsg(pScrn->scrnIndex, X_PROBED, "Max Clock: %d kHz\n", 370 maxClock); 371 } 372 373 pScrn->progClock = TRUE; 374 /* 375 * Setup the ClockRanges, which describe what clock ranges are available, 376 * and what sort of modes they can be used for. 377 */ 378 clockRanges = (ClockRangePtr)xnfcalloc(sizeof(ClockRange), 1); 379 clockRanges->next = NULL; 380 clockRanges->ClockMulFactor = 1; 381 clockRanges->minClock = 11000; /* guessed §§§ */ 382 clockRanges->maxClock = 300000; 383 clockRanges->clockIndex = -1; /* programmable */ 384 clockRanges->interlaceAllowed = TRUE; 385 clockRanges->doubleScanAllowed = TRUE; 386 387 /* Subtract memory for HW cursor */ 388 389 390 { 391 int apertureSize = (pScrn->videoRam * 1024); 392 i = xf86ValidateModes(pScrn, pScrn->monitor->Modes, 393 pScrn->display->modes, clockRanges, 394 NULL, 256, DUMMY_MAX_WIDTH, 395 (8 * pScrn->bitsPerPixel), 396 128, DUMMY_MAX_HEIGHT, pScrn->display->virtualX, 397 pScrn->display->virtualY, apertureSize, 398 LOOKUP_BEST_REFRESH); 399 400 if (i == -1) 401 RETURN; 402 } 403 404 /* Prune the modes marked as invalid */ 405 xf86PruneDriverModes(pScrn); 396 xf86CrtcConfigInit(pScrn, &dummy_xf86crtc_config_funcs); 397 xf86CrtcSetSizeRange(pScrn, 8, 8, SHRT_MAX, SHRT_MAX); 406 398 407 if (i == 0 || pScrn->modes == NULL) { 408 xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes found\n"); 409 RETURN; 399 /* Pick up size from the "Display" subsection if it exists */ 400 if (pScrn->display->virtualX) { 401 pScrn->virtualX = pScrn->display->virtualX; 402 pScrn->virtualY = pScrn->display->virtualY; 403 } else { 404 /* Pick a "modern" screen resolution */ 405 pScrn->virtualX = 3840; 406 pScrn->virtualY = 2160; 410 407 } 408 pScrn->displayWidth = pScrn->virtualX; 411 409 412 /* 413 * Set the CRTC parameters for all of the modes based on the type 414 * of mode, and the chipset's interlace requirements. 415 * 416 * Calling this is required if the mode->Crtc* values are used by the 417 * driver and if the driver doesn't provide code to set them. They 418 * are not pre-initialised at all. 419 */ 420 xf86SetCrtcForModes(pScrn, 0); 421 422 /* Set the current mode to the first in the list */ 410 /* Construct a mode with the screen's initial dimensions */ 411 pScrn->modes = calloc(sizeof(DisplayModeRec), 1); 412 ConstructFakeDisplayMode(pScrn, pScrn->modes); 413 pScrn->modes->next = pScrn->modes->prev = pScrn->modes; 423 414 pScrn->currentMode = pScrn->modes; 424 415 425 /* Print the list of modes being used */426 xf86PrintModes(pScrn);427 428 416 /* If monitor resolution is set on the command line, use it */ 429 417 xf86SetDpi(pScrn, 0, 0); 430 418 … … DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 515 503 dPtr = DUMMYPTR(pScrn); 516 504 DUMMYScrn = pScrn; 517 505 518 519 if (!(pixels = malloc(pScrn->videoRam * 1024)))506 if (!(pixels = malloc(pScrn->displayWidth * pScrn->bitsPerPixel * 8 * 507 pScrn->virtualY))) 520 508 return FALSE; 521 509 522 510 DUMMYAdjustFrame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); … … DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 569 557 if (dPtr->swCursor) 570 558 xf86DrvMsg(pScrn->scrnIndex, X_CONFIG, "Using Software Cursor.\n"); 571 559 572 {573 574 575 BoxRec AvailFBArea;576 int lines = pScrn->videoRam * 1024 /577 (pScrn->displayWidth * (pScrn->bitsPerPixel >> 3));578 AvailFBArea.x1 = 0;579 AvailFBArea.y1 = 0;580 AvailFBArea.x2 = pScrn->displayWidth;581 AvailFBArea.y2 = lines;582 xf86InitFBManager(pScreen, &AvailFBArea);583 584 xf86DrvMsg(pScrn->scrnIndex, X_INFO,585 "Using %i scanlines of offscreen memory \n"586 , lines - pScrn->virtualY);587 }588 589 560 xf86SetBackingStore(pScreen); 590 561 xf86SetSilkenMouse(pScreen); 591 562 … … DUMMYScreenInit(SCREEN_INIT_ARGS_DECL) 612 583 | CMAP_RELOAD_ON_MODE_SWITCH)) 613 584 return FALSE; 614 585 586 if (!xf86CrtcScreenInit(pScreen)) 587 return FALSE; 588 615 589 pScreen->SaveScreen = DUMMYSaveScreen; 616 590 617 591