static Bool PSB_SetMode(ScrnInfoPtr pScrn, DGAModePtr pMode) { if (!pMode) { if (saved) { pScrn->AdjustFrame(pScrn->pScreen->myNum, 0, 0, 0); xf86SwitchMode(pScrn->pScreen, saved); pScrn->displayWidth = saved->HDisplay; saved = NULL; } } else { if (!saved) { saved = pScrn->currentMode; xf86SwitchMode(pScrn->pScreen, pMode->mode); pScrn->displayWidth = pMode->mode->HDisplay; pMode->bytesPerScanline = pScrn->displayWidth * (pScrn->bitsPerPixel >> 3); pMode->pixmapWidth = pScrn->displayWidth; } }
static Bool xf86_dga_set_mode(ScrnInfoPtr scrn, DGAModePtr display_mode) { ScreenPtr pScreen = scrn->pScreen; xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(scrn); if (!display_mode) { if (xf86_config->dga_save_mode) { xf86SwitchMode(pScreen, xf86_config->dga_save_mode); xf86_config->dga_save_mode = NULL; } } else { if (!xf86_config->dga_save_mode) { xf86_config->dga_save_mode = scrn->currentMode; xf86SwitchMode(pScreen, display_mode->mode); } } return TRUE; }
void xf86ZoomViewport(ScreenPtr pScreen, int zoom) { ScrnInfoPtr pScr = XF86SCRNINFO(pScreen); DisplayModePtr mode; if (pScr->zoomLocked || !(mode = pScr->currentMode)) return; do { if (zoom > 0) mode = mode->next; else mode = mode->prev; } while (mode != pScr->currentMode && !(mode->type & M_T_USERDEF)); (void)xf86SwitchMode(pScreen, mode); }
Bool VidModeSwitchMode(int scrnIndex, void *mode) { ScrnInfoPtr pScrn; DisplayModePtr pTmpMode; Bool retval; if (!VidModeAvailable(scrnIndex)) return FALSE; pScrn = xf86Screens[scrnIndex]; /* save in case we fail */ pTmpMode = pScrn->currentMode; /* Force a mode switch */ pScrn->currentMode = NULL; retval = xf86SwitchMode(pScrn->pScreen, mode); /* we failed: restore it */ if (retval == FALSE) pScrn->currentMode = pTmpMode; return retval; }
static Bool xf86RandRSetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; int oldVirtualX = scrp->virtualX; int oldVirtualY = scrp->virtualY; WindowPtr pRoot = pScreen->root; Bool ret = TRUE; if (pRoot && scrp->vtSema) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } /* * The DIX forgets the physical dimensions we passed into RRRegisterSize, so * reconstruct them if possible. */ if(scrp->DriverFunc) { xorgRRModeMM RRModeMM; RRModeMM.mode = mode; RRModeMM.virtX = scrp->virtualX; RRModeMM.virtY = scrp->virtualY; RRModeMM.mmWidth = mmWidth; RRModeMM.mmHeight = mmHeight; (*scrp->DriverFunc)(scrp, RR_GET_MODE_MM, &RRModeMM); mmWidth = RRModeMM.mmWidth; mmHeight = RRModeMM.mmHeight; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (!xf86SwitchMode (pScreen, mode)) { pScreen->width = oldWidth; pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; scrp->virtualX = oldVirtualX; scrp->virtualY = oldVirtualY; ret = FALSE; } /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot && scrp->vtSema) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return ret; }
static Bool xf86RandR12SetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; WindowPtr pRoot = WindowTable[pScreen->myNum]; DisplayModePtr currentMode = NULL; Bool ret = TRUE; PixmapPtr pspix = NULL; if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (scrp->currentMode == mode) { /* Save current mode */ currentMode = scrp->currentMode; /* Reset, just so we ensure the drivers SwitchMode is called */ scrp->currentMode = NULL; } /* * We know that if the driver failed to SwitchMode to the rotated * version, then it should revert back to it's prior mode. */ if (!xf86SwitchMode (pScreen, mode)) { ret = FALSE; scrp->virtualX = pScreen->width = oldWidth; scrp->virtualY = pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; scrp->currentMode = currentMode; } /* * Get the new Screen pixmap ptr as SwitchMode might have called * ModifyPixmapHeader and xf86EnableDisableFBAccess will put it back... * Unfortunately. */ pspix = (*pScreen->GetScreenPixmap) (pScreen); if (pspix->devPrivate.ptr) scrp->pixmapPrivate = pspix->devPrivate; /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return ret; }
static Bool xf86RandRSetMode (ScreenPtr pScreen, DisplayModePtr mode, Bool useVirtual, int mmWidth, int mmHeight) { ScrnInfoPtr scrp = XF86SCRNINFO(pScreen); XF86RandRInfoPtr randrp = XF86RANDRINFO(pScreen); int oldWidth = pScreen->width; int oldHeight = pScreen->height; int oldmmWidth = pScreen->mmWidth; int oldmmHeight = pScreen->mmHeight; WindowPtr pRoot = WindowTable[pScreen->myNum]; if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, FALSE); if (useVirtual) { scrp->virtualX = randrp->virtualX; scrp->virtualY = randrp->virtualY; } else { scrp->virtualX = mode->HDisplay; scrp->virtualY = mode->VDisplay; } if(randrp->rotation & (RR_Rotate_90 | RR_Rotate_270)) { /* If the screen is rotated 90 or 270 degrees, swap the sizes. */ pScreen->width = scrp->virtualY; pScreen->height = scrp->virtualX; pScreen->mmWidth = mmHeight; pScreen->mmHeight = mmWidth; } else { pScreen->width = scrp->virtualX; pScreen->height = scrp->virtualY; pScreen->mmWidth = mmWidth; pScreen->mmHeight = mmHeight; } if (!xf86SwitchMode (pScreen, mode)) { scrp->virtualX = pScreen->width = oldWidth; scrp->virtualY = pScreen->height = oldHeight; pScreen->mmWidth = oldmmWidth; pScreen->mmHeight = oldmmHeight; return FALSE; } /* * Make sure the layout is correct */ xf86ReconfigureLayout(); /* * Make sure the whole screen is visible */ xf86SetViewport (pScreen, pScreen->width, pScreen->height); xf86SetViewport (pScreen, 0, 0); if (pRoot) (*scrp->EnableDisableFBAccess) (pScreen->myNum, TRUE); return TRUE; }