Bool fakeRandRSetConfig (ScreenPtr pScreen, Rotation randr, int rate, RRScreenSizePtr pSize) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; FakeScrPriv *scrpriv = screen->driver; Bool wasEnabled = pScreenPriv->enabled; FakeScrPriv oldscr; int oldwidth; int oldheight; int oldmmwidth; int oldmmheight; int newwidth, newheight; if (screen->randr & (RR_Rotate_0|RR_Rotate_180)) { newwidth = pSize->width; newheight = pSize->height; } else { newwidth = pSize->height; newheight = pSize->width; } if (wasEnabled) KdDisableScreen (pScreen); oldscr = *scrpriv; oldwidth = screen->width; oldheight = screen->height; oldmmwidth = pScreen->mmWidth; oldmmheight = pScreen->mmHeight; /* * Set new configuration */ scrpriv->randr = KdAddRotation (screen->randr, randr); fakeUnmapFramebuffer (screen); if (!fakeMapFramebuffer (screen)) goto bail4; KdShadowUnset (screen->pScreen); if (!fakeSetShadow (screen->pScreen)) goto bail4; fakeSetScreenSizes (screen->pScreen); /* * Set frame buffer mapping */ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), pScreen->width, pScreen->height, screen->fb.depth, screen->fb.bitsPerPixel, screen->fb.byteStride, screen->fb.frameBuffer); /* set the subpixel order */ KdSetSubpixelOrder (pScreen, scrpriv->randr); if (wasEnabled) KdEnableScreen (pScreen); return TRUE; bail4: fakeUnmapFramebuffer (screen); *scrpriv = oldscr; (void) fakeMapFramebuffer (screen); pScreen->width = oldwidth; pScreen->height = oldheight; pScreen->mmWidth = oldmmwidth; pScreen->mmHeight = oldmmheight; if (wasEnabled) KdEnableScreen (pScreen); return FALSE; }
Bool KdScreenInit(ScreenPtr pScreen, int argc, char **argv) { KdScreenInfo *screen = kdCurrentScreen; KdCardInfo *card = screen->card; KdPrivScreenPtr pScreenPriv; /* * note that screen->fb is set up for the nominal orientation * of the screen; that means if randr is rotated, the values * there should reflect a rotated frame buffer (or shadow). */ Bool rotated = (screen->randr & (RR_Rotate_90 | RR_Rotate_270)) != 0; int width, height, *width_mmp, *height_mmp; KdAllocatePrivates(pScreen); pScreenPriv = KdGetScreenPriv(pScreen); if (!rotated) { width = screen->width; height = screen->height; width_mmp = &screen->width_mm; height_mmp = &screen->height_mm; } else { width = screen->height; height = screen->width; width_mmp = &screen->height_mm; height_mmp = &screen->width_mm; } screen->pScreen = pScreen; pScreenPriv->screen = screen; pScreenPriv->card = card; pScreenPriv->bytesPerPixel = screen->fb.bitsPerPixel >> 3; pScreenPriv->dpmsState = KD_DPMS_NORMAL; pScreen->x = screen->origin.x; pScreen->y = screen->origin.y; if (!monitorResolution) monitorResolution = 75; /* * This is done in this order so that backing store wraps * our GC functions; fbFinishScreenInit initializes MI * backing store */ if (!fbSetupScreen(pScreen, screen->fb.frameBuffer, width, height, monitorResolution, monitorResolution, screen->fb.pixelStride, screen->fb.bitsPerPixel)) { return FALSE; } /* * Set colormap functions */ pScreen->InstallColormap = KdInstallColormap; pScreen->UninstallColormap = KdUninstallColormap; pScreen->ListInstalledColormaps = KdListInstalledColormaps; pScreen->StoreColors = KdStoreColors; pScreen->SaveScreen = KdSaveScreen; pScreen->CreateWindow = KdCreateWindow; if (!fbFinishScreenInit(pScreen, screen->fb.frameBuffer, width, height, monitorResolution, monitorResolution, screen->fb.pixelStride, screen->fb.bitsPerPixel)) { return FALSE; } /* * Fix screen sizes; for some reason mi takes dpi instead of mm. * Rounding errors are annoying */ if (*width_mmp) pScreen->mmWidth = *width_mmp; else *width_mmp = pScreen->mmWidth; if (*height_mmp) pScreen->mmHeight = *height_mmp; else *height_mmp = pScreen->mmHeight; /* * Plug in our own block/wakeup handlers. * miScreenInit installs NoopDDA in both places */ pScreen->BlockHandler = KdBlockHandler; pScreen->WakeupHandler = KdWakeupHandler; if (!fbPictureInit(pScreen, 0, 0)) return FALSE; if (card->cfuncs->initScreen) if (!(*card->cfuncs->initScreen) (pScreen)) return FALSE; if (!screen->dumb && card->cfuncs->initAccel) if (!(*card->cfuncs->initAccel) (pScreen)) screen->dumb = TRUE; if (card->cfuncs->finishInitScreen) if (!(*card->cfuncs->finishInitScreen) (pScreen)) return FALSE; /* * Wrap CloseScreen, the order now is: * KdCloseScreen * miBSCloseScreen * fbCloseScreen */ pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = KdCloseScreen; pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = KdCreateScreenResources; if (screen->softCursor || !card->cfuncs->initCursor || !(*card->cfuncs->initCursor) (pScreen)) { /* Use MI for cursor display and event queueing. */ screen->softCursor = TRUE; miDCInitialize(pScreen, &kdPointerScreenFuncs); } if (!fbCreateDefColormap(pScreen)) { return FALSE; } KdSetSubpixelOrder(pScreen, screen->randr); /* * Enable the hardware */ if (!kdEnabled) { kdEnabled = TRUE; if (kdOsFuncs->Enable) (*kdOsFuncs->Enable) (); } if (screen->mynum == card->selected) { if (card->cfuncs->preserve) (*card->cfuncs->preserve) (card); if (card->cfuncs->enable) if (!(*card->cfuncs->enable) (pScreen)) return FALSE; pScreenPriv->enabled = TRUE; if (!screen->softCursor && card->cfuncs->enableCursor) (*card->cfuncs->enableCursor) (pScreen); KdEnableColormap(pScreen); if (!screen->dumb && card->cfuncs->enableAccel) (*card->cfuncs->enableAccel) (pScreen); } return TRUE; }
Bool ephyrRandRSetConfig(ScreenPtr pScreen, Rotation randr, int rate, RRScreenSizePtr pSize) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; EphyrScrPriv *scrpriv = screen->driver; Bool wasEnabled = pScreenPriv->enabled; EphyrScrPriv oldscr; int oldwidth, oldheight, oldmmwidth, oldmmheight; Bool oldshadow; int newwidth, newheight; if (screen->randr & (RR_Rotate_0 | RR_Rotate_180)) { newwidth = pSize->width; newheight = pSize->height; } else { newwidth = pSize->height; newheight = pSize->width; } if (wasEnabled) KdDisableScreen(pScreen); oldscr = *scrpriv; oldwidth = screen->width; oldheight = screen->height; oldmmwidth = pScreen->mmWidth; oldmmheight = pScreen->mmHeight; oldshadow = scrpriv->shadow; /* * Set new configuration */ /* * We need to store the rotation value for pointer coords transformation; * though initially the pointer and fb rotation are identical, when we map * the fb, the screen will be reinitialized and return into an unrotated * state (presumably the HW is taking care of the rotation of the fb), but the * pointer still needs to be transformed. */ ephyrRandr = KdAddRotation(screen->randr, randr); scrpriv->randr = ephyrRandr; ephyrUnmapFramebuffer(screen); screen->width = newwidth; screen->height = newheight; if (!ephyrMapFramebuffer(screen)) goto bail4; /* FIXME below should go in own call */ if (oldshadow) KdShadowUnset(screen->pScreen); else ephyrUnsetInternalDamage(screen->pScreen); if (scrpriv->shadow) { if (!KdShadowSet(screen->pScreen, scrpriv->randr, ephyrShadowUpdate, ephyrWindowLinear)) goto bail4; } else { /* Without shadow fb ( non rotated ) we need * to use damage to efficiently update display * via signal regions what to copy from 'fb'. */ if (!ephyrSetInternalDamage(screen->pScreen)) goto bail4; } ephyrSetScreenSizes(screen->pScreen); /* * Set frame buffer mapping */ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap(pScreen), pScreen->width, pScreen->height, screen->fb.depth, screen->fb.bitsPerPixel, screen->fb.byteStride, screen->fb.frameBuffer); /* set the subpixel order */ KdSetSubpixelOrder(pScreen, scrpriv->randr); if (wasEnabled) KdEnableScreen(pScreen); RRScreenSizeNotify(pScreen); return TRUE; bail4: EPHYR_LOG("bailed"); ephyrUnmapFramebuffer(screen); *scrpriv = oldscr; (void) ephyrMapFramebuffer(screen); pScreen->width = oldwidth; pScreen->height = oldheight; pScreen->mmWidth = oldmmwidth; pScreen->mmHeight = oldmmheight; if (wasEnabled) KdEnableScreen(pScreen); return FALSE; }
Bool KdScreenInit(int index, ScreenPtr pScreen, int argc, char **argv) { KdScreenInfo *screen = kdCurrentScreen; KdCardInfo *card = screen->card; KdPrivScreenPtr pScreenPriv; int fb; /* * note that screen->fb is set up for the nominal orientation * of the screen; that means if randr is rotated, the values * there should reflect a rotated frame buffer (or shadow). */ Bool rotated = (screen->randr & (RR_Rotate_90|RR_Rotate_270)) != 0; int width, height, *width_mmp, *height_mmp; KdAllocatePrivates (pScreen); pScreenPriv = KdGetScreenPriv(pScreen); if (!rotated) { width = screen->width; height = screen->height; width_mmp = &screen->width_mm; height_mmp = &screen->height_mm; } else { width = screen->height; height = screen->width; width_mmp = &screen->height_mm; height_mmp = &screen->width_mm; } screen->pScreen = pScreen; pScreenPriv->screen = screen; pScreenPriv->card = card; for (fb = 0; fb < KD_MAX_FB && screen->fb[fb].depth; fb++) pScreenPriv->bytesPerPixel[fb] = screen->fb[fb].bitsPerPixel >> 3; pScreenPriv->dpmsState = KD_DPMS_NORMAL; #ifdef PANORAMIX dixScreenOrigins[pScreen->myNum] = screen->origin; #endif if (!monitorResolution) monitorResolution = 75; /* * This is done in this order so that backing store wraps * our GC functions; fbFinishScreenInit initializes MI * backing store */ if (!fbSetupScreen (pScreen, screen->fb[0].frameBuffer, width, height, monitorResolution, monitorResolution, screen->fb[0].pixelStride, screen->fb[0].bitsPerPixel)) { return FALSE; } /* * Set colormap functions */ pScreen->InstallColormap = KdInstallColormap; pScreen->UninstallColormap = KdUninstallColormap; pScreen->ListInstalledColormaps = KdListInstalledColormaps; pScreen->StoreColors = KdStoreColors; pScreen->SaveScreen = KdSaveScreen; pScreen->CreateWindow = KdCreateWindow; #ifdef FB_OLD_SCREEN pScreenPriv->BackingStoreFuncs.SaveAreas = fbSaveAreas; pScreenPriv->BackingStoreFuncs.RestoreAreas = fbSaveAreas; pScreenPriv->BackingStoreFuncs.SetClipmaskRgn = 0; pScreenPriv->BackingStoreFuncs.GetImagePixmap = 0; pScreenPriv->BackingStoreFuncs.GetSpansPixmap = 0; #endif #if KD_MAX_FB > 1 if (screen->fb[1].depth) { if (!fbOverlayFinishScreenInit (pScreen, screen->fb[0].frameBuffer, screen->fb[1].frameBuffer, width, height, monitorResolution, monitorResolution, screen->fb[0].pixelStride, screen->fb[1].pixelStride, screen->fb[0].bitsPerPixel, screen->fb[1].bitsPerPixel, screen->fb[0].depth, screen->fb[1].depth)) { return FALSE; } } else #endif { if (!fbFinishScreenInit (pScreen, screen->fb[0].frameBuffer, width, height, monitorResolution, monitorResolution, screen->fb[0].pixelStride, screen->fb[0].bitsPerPixel)) { return FALSE; } } /* * Fix screen sizes; for some reason mi takes dpi instead of mm. * Rounding errors are annoying */ if (*width_mmp) pScreen->mmWidth = *width_mmp; else *width_mmp = pScreen->mmWidth; if (*height_mmp) pScreen->mmHeight = *height_mmp; else *height_mmp = pScreen->mmHeight; /* * Plug in our own block/wakeup handlers. * miScreenInit installs NoopDDA in both places */ pScreen->BlockHandler = KdBlockHandler; pScreen->WakeupHandler = KdWakeupHandler; #ifdef RENDER if (!fbPictureInit (pScreen, 0, 0)) return FALSE; #endif if (card->cfuncs->initScreen) if (!(*card->cfuncs->initScreen) (pScreen)) return FALSE; if (!screen->dumb && card->cfuncs->initAccel) if (!(*card->cfuncs->initAccel) (pScreen)) screen->dumb = TRUE; if (screen->off_screen_base < screen->memory_size) KdOffscreenInit (pScreen); #ifdef PSEUDO8 (void) p8Init (pScreen, PSEUDO8_USE_DEFAULT); #endif if (card->cfuncs->finishInitScreen) if (!(*card->cfuncs->finishInitScreen) (pScreen)) return FALSE; #if 0 fbInitValidateTree (pScreen); #endif #if 0 pScreen->backingStoreSupport = Always; #ifdef FB_OLD_SCREEN miInitializeBackingStore (pScreen, &pScreenPriv->BackingStoreFuncs); #else miInitializeBackingStore (pScreen); #endif #endif /* * Wrap CloseScreen, the order now is: * KdCloseScreen * miBSCloseScreen * fbCloseScreen */ pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = KdCloseScreen; pScreenPriv->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = KdCreateScreenResources; if (screen->softCursor || !card->cfuncs->initCursor || !(*card->cfuncs->initCursor) (pScreen)) { /* Use MI for cursor display and event queueing. */ screen->softCursor = TRUE; miDCInitialize(pScreen, &kdPointerScreenFuncs); } if (!fbCreateDefColormap (pScreen)) { return FALSE; } KdSetSubpixelOrder (pScreen, screen->randr); /* * Enable the hardware */ if (!kdEnabled) { kdEnabled = TRUE; if(kdOsFuncs->Enable) (*kdOsFuncs->Enable) (); } if (screen->mynum == card->selected) { if(card->cfuncs->preserve) (*card->cfuncs->preserve) (card); if(card->cfuncs->enable) if (!(*card->cfuncs->enable) (pScreen)) return FALSE; pScreenPriv->enabled = TRUE; if (!screen->softCursor && card->cfuncs->enableCursor) (*card->cfuncs->enableCursor) (pScreen); KdEnableColormap (pScreen); if (!screen->dumb && card->cfuncs->enableAccel) (*card->cfuncs->enableAccel) (pScreen); } return TRUE; }
static Bool sdlRandRSetConfig (ScreenPtr pScreen, Rotation randr, int rate, RRScreenSizePtr pSize) { KdScreenPriv(pScreen); KdScreenInfo *screen = pScreenPriv->screen; SdlDriver *driver = screen->driver; Bool wasEnabled = pScreenPriv->enabled; SdlDriver oldDriver; int oldwidth; int oldheight; int oldmmwidth; int oldmmheight; if (wasEnabled) KdDisableScreen (pScreen); oldDriver = *driver; oldwidth = screen->width; oldheight = screen->height; oldmmwidth = pScreen->mmWidth; oldmmheight = pScreen->mmHeight; /* * Set new configuration */ driver->randr = KdAddRotation (screen->randr, randr); printf("%s driver->randr %d", __func__, driver->randr); sdlUnmapFramebuffer (screen); if (!sdlMapFramebuffer (screen)) goto bail4; KdShadowUnset (screen->pScreen); if (!sdlCreateRes (screen->pScreen)) goto bail4; sdlSetScreenSizes (screen->pScreen); /* * Set frame buffer mapping */ (*pScreen->ModifyPixmapHeader) (fbGetScreenPixmap (pScreen), pScreen->width, pScreen->height, screen->fb.depth, screen->fb.bitsPerPixel, screen->fb.byteStride, screen->fb.frameBuffer); /* set the subpixel order */ KdSetSubpixelOrder (pScreen, driver->randr); if (wasEnabled) KdEnableScreen (pScreen); return TRUE; bail4: sdlUnmapFramebuffer (screen); *driver = oldDriver; (void) sdlMapFramebuffer (screen); pScreen->width = oldwidth; pScreen->height = oldheight; pScreen->mmWidth = oldmmwidth; pScreen->mmHeight = oldmmheight; if (wasEnabled) KdEnableScreen (pScreen); return FALSE; }