static Bool BW2ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { ScrnInfoPtr pScrn; Bw2Ptr pBw2; int ret; /* * First get the ScrnInfoRec */ pScrn = xf86Screens[pScreen->myNum]; pBw2 = GET_BW2_FROM_SCRN(pScrn); /* Map the BW2 memory */ pBw2->fb = xf86MapSbusMem(pBw2->psdp, BW2_RAM_VOFF, pBw2->psdp->width * pBw2->psdp->height / 8); if (!pBw2->fb) return FALSE; /* Darken the screen for aesthetic reasons and set the viewport */ BW2SaveScreen(pScreen, SCREEN_SAVER_ON); /* * The next step is to setup the screen's visuals, and initialise the * framebuffer code. In cases where the framebuffer's default * choices for things like visual layouts and bits per RGB are OK, * this may be as simple as calling the framebuffer's ScreenInit() * function. If not, the visuals will need to be setup before calling * a fb ScreenInit() function and fixed up after. */ /* * Reset visual list. */ miClearVisualTypes(); /* Set the bits per RGB for 8bpp mode */ pScrn->rgbBits = 8; /* Setup the visuals we support. */ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; /* * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. */ ret = xf1bppScreenInit(pScreen, pBw2->fb, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, pScrn->virtualX); if (!ret) return FALSE; miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); xf86SetBlackWhitePixels(pScreen); /* Initialise cursor functions */ miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); /* Initialise default colourmap */ if (!miCreateDefColormap(pScreen)) return FALSE; pBw2->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = BW2CloseScreen; pScreen->SaveScreen = BW2SaveScreen; /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) { xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } /* unblank the screen */ BW2SaveScreen(pScreen, SCREEN_SAVER_OFF); /* Done */ return TRUE; }
Bool winFinishScreenInitNativeGDI (int index, ScreenPtr pScreen, int argc, char **argv) { winScreenPriv(pScreen); winScreenInfoPtr pScreenInfo = &g_ScreenInfo[index]; VisualPtr pVisuals = NULL; DepthPtr pDepths = NULL; VisualID rootVisual = 0; int nVisuals = 0, nDepths = 0, nRootDepth = 0; /* Ignore user input (mouse, keyboard) */ pScreenInfo->fIgnoreInput = FALSE; /* Get device contexts for the screen and shadow bitmap */ pScreenPriv->hdcScreen = GetDC (pScreenPriv->hwndScreen); if (pScreenPriv->hdcScreen == NULL) FatalError ("winFinishScreenInitNativeGDI - Couldn't get a DC\n"); /* Init visuals */ if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) { ErrorF ("winFinishScreenInitNativeGDI - pwinInitVisuals failed\n"); return FALSE; } /* Initialize the mi visuals */ if (!miInitVisuals (&pVisuals, &pDepths, &nVisuals, &nDepths, &nRootDepth, &rootVisual, ((unsigned long)1 << (pScreenInfo->dwDepth - 1)), 8, TrueColor)) { ErrorF ("winFinishScreenInitNativeGDI - miInitVisuals () failed\n"); return FALSE; } /* Initialize the CloseScreen procedure pointer */ pScreen->CloseScreen = NULL; /* Initialize the mi code */ if (!miScreenInit (pScreen, NULL, /* No framebuffer */ pScreenInfo->dwWidth, pScreenInfo->dwHeight, monitorResolution, monitorResolution, pScreenInfo->dwStride, nRootDepth, nDepths, pDepths, rootVisual, nVisuals, pVisuals)) { ErrorF ("winFinishScreenInitNativeGDI - miScreenInit failed\n"); return FALSE; } pScreen->defColormap = FakeClientID(0); /* * Register our block and wakeup handlers; these procedures * process messages in our Windows message queue; specifically, * they process mouse and keyboard input. */ pScreen->BlockHandler = winBlockHandler; pScreen->WakeupHandler = winWakeupHandler; pScreen->blockData = pScreen; pScreen->wakeupData = pScreen; /* Place our save screen function */ pScreen->SaveScreen = winSaveScreen; /* Pixmaps */ pScreen->CreatePixmap = winCreatePixmapNativeGDI; pScreen->DestroyPixmap = winDestroyPixmapNativeGDI; /* Other Screen Routines */ pScreen->QueryBestSize = winQueryBestSizeNativeGDI; pScreen->SaveScreen = winSaveScreen; pScreen->GetImage = miGetImage; pScreen->GetSpans = winGetSpansNativeGDI; /* Window Procedures */ pScreen->CreateWindow = winCreateWindowNativeGDI; pScreen->DestroyWindow = winDestroyWindowNativeGDI; pScreen->PositionWindow = winPositionWindowNativeGDI; /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesNativeGDI;*/ pScreen->RealizeWindow = winMapWindowNativeGDI; pScreen->UnrealizeWindow = winUnmapWindowNativeGDI; /* Paint window */ pScreen->CopyWindow = winCopyWindowNativeGDI; /* Fonts */ pScreen->RealizeFont = winRealizeFontNativeGDI; pScreen->UnrealizeFont = winUnrealizeFontNativeGDI; /* GC */ pScreen->CreateGC = winCreateGCNativeGDI; /* Colormap Routines */ pScreen->CreateColormap = miInitializeColormap; pScreen->DestroyColormap = (DestroyColormapProcPtr) (void (*)(void)) NoopDDA; pScreen->InstallColormap = miInstallColormap; pScreen->UninstallColormap = miUninstallColormap; pScreen->ListInstalledColormaps = miListInstalledColormaps; pScreen->StoreColors = (StoreColorsProcPtr) (void (*)(void)) NoopDDA; pScreen->ResolveColor = miResolveColor; /* Bitmap */ pScreen->BitmapToRegion = winPixmapToRegionNativeGDI; ErrorF ("winFinishScreenInitNativeGDI - calling miDCInitialize\n"); /* Set the default white and black pixel positions */ pScreen->whitePixel = pScreen->blackPixel = (Pixel) 0; /* Initialize the cursor */ if (!miDCInitialize (pScreen, &g_winPointerCursorFuncs)) { ErrorF ("winFinishScreenInitNativeGDI - miDCInitialize failed\n"); return FALSE; } /* Create a default colormap */ if (!miCreateDefColormap (pScreen)) { ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () " "failed\n"); return FALSE; } ErrorF ("winFinishScreenInitNativeGDI - miCreateDefColormap () " "returned\n"); /* mi doesn't use a CloseScreen procedure, so no need to wrap */ pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; /* Tell the server that we are enabled */ pScreenPriv->fEnabled = TRUE; ErrorF ("winFinishScreenInitNativeGDI - Successful addition of " "screen %08x\n", (unsigned int) pScreen); return TRUE; }
/* Called at each server generation */ static Bool NestedScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) { ScrnInfoPtr pScrn; NestedPrivatePtr pNested; Pixel redMask, greenMask, blueMask; xf86DrvMsg(scrnIndex, X_INFO, "NestedScreenInit\n"); pScrn = xf86Screens[pScreen->myNum]; pNested = PNESTED(pScrn); /*NESTEDScrn = pScrn;*/ NestedPrintPscreen(pScrn); /* Save state: * NestedSave(pScrn); */ //Load_Nested_Mouse(); pNested->clientData = NestedClientCreateScreen(scrnIndex, pNested->displayName, pScrn->virtualX, pScrn->virtualY, pNested->originX, pNested->originY, pScrn->depth, pScrn->bitsPerPixel, &redMask, &greenMask, &blueMask); if (!pNested->clientData) { xf86DrvMsg(scrnIndex, X_ERROR, "Failed to create client screen\n"); return FALSE; } TimerSet(NULL, 0, 1, NestedMouseTimer, pNested->clientData); miClearVisualTypes(); if (!miSetVisualTypesAndMasks(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual, redMask, greenMask, blueMask)) return FALSE; if (!miSetPixmapDepths()) return FALSE; if (!fbScreenInit(pScreen, NestedClientGetFrameBuffer(PCLIENTDATA(pScrn)), pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, pScrn->bitsPerPixel)) return FALSE; fbPictureInit(pScreen, 0, 0); xf86SetBlackWhitePixels(pScreen); miInitializeBackingStore(pScreen); xf86SetBackingStore(pScreen); miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); if (!miCreateDefColormap(pScreen)) return FALSE; pNested->update = NestedShadowUpdate; /*pNested->window = NestedShadowWindow;*/ pScreen->SaveScreen = NestedSaveScreen; if (!shadowSetup(pScreen)) return FALSE; pNested->CreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = NestedCreateScreenResources; pNested->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = NestedCloseScreen; // Schedule the NestedInputLoadDriver function to load once the // input core is initialized. pNested->timer = TimerSet(NULL, 0, TIMER_CALLBACK_INTERVAL, NestedTimerCallback, (pointer)pScrn); return TRUE; }
/* See Porting Layer Definition - p. 20 */ Bool winFinishScreenInitFB (int index, ScreenPtr pScreen, int argc, char **argv) { winScreenPriv(pScreen); winScreenInfo *pScreenInfo = pScreenPriv->pScreenInfo; VisualPtr pVisual = NULL; char *pbits = NULL; #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) int iReturn; #endif /* Create framebuffer */ if (!(*pScreenPriv->pwinAllocateFB) (pScreen)) { ErrorF ("winFinishScreenInitFB - Could not allocate framebuffer\n"); return FALSE; } /* * Grab the number of bits that are used to represent color in each pixel. */ if (pScreenInfo->dwBPP == 8) pScreenInfo->dwDepth = 8; else pScreenInfo->dwDepth = winCountBits (pScreenPriv->dwRedMask) + winCountBits (pScreenPriv->dwGreenMask) + winCountBits (pScreenPriv->dwBlueMask); winErrorFVerb (2, "winFinishScreenInitFB - Masks: %08x %08x %08x\n", (unsigned int) pScreenPriv->dwRedMask, (unsigned int) pScreenPriv->dwGreenMask, (unsigned int) pScreenPriv->dwBlueMask); /* Init visuals */ if (!(*pScreenPriv->pwinInitVisuals) (pScreen)) { ErrorF ("winFinishScreenInitFB - winInitVisuals failed\n"); return FALSE; } /* Setup a local variable to point to the framebuffer */ pbits = pScreenInfo->pfb; /* Apparently we need this for the render extension */ miSetPixmapDepths (); /* Start fb initialization */ if (!fbSetupScreen (pScreen, pScreenInfo->pfb, pScreenInfo->dwWidth, pScreenInfo->dwHeight, monitorResolution, monitorResolution, pScreenInfo->dwStride, pScreenInfo->dwBPP)) { ErrorF ("winFinishScreenInitFB - fbSetupScreen failed\n"); return FALSE; } /* Override default colormap routines if visual class is dynamic */ if (pScreenInfo->dwDepth == 8 && (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL && pScreenInfo->fFullScreen) || (pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD && pScreenInfo->fFullScreen))) { winSetColormapFunctions (pScreen); /* * NOTE: Setting whitePixel to 255 causes Magic 7.1 to allocate its * own colormap, as it cannot allocate 7 planes in the default * colormap. Setting whitePixel to 1 allows Magic to get 7 * planes in the default colormap, so it doesn't create its * own colormap. This latter situation is highly desireable, * as it keeps the Magic window viewable when switching to * other X clients that use the default colormap. */ pScreen->blackPixel = 0; pScreen->whitePixel = 1; } /* Place our save screen function */ pScreen->SaveScreen = winSaveScreen; /* Finish fb initialization */ if (!fbFinishScreenInit (pScreen, pScreenInfo->pfb, pScreenInfo->dwWidth, pScreenInfo->dwHeight, monitorResolution, monitorResolution, pScreenInfo->dwStride, pScreenInfo->dwBPP)) { ErrorF ("winFinishScreenInitFB - fbFinishScreenInit failed\n"); return FALSE; } /* Save a pointer to the root visual */ for (pVisual = pScreen->visuals; pVisual->vid != pScreen->rootVisual; pVisual++); pScreenPriv->pRootVisual = pVisual; /* * Setup points to the block and wakeup handlers. Pass a pointer * to the current screen as pWakeupdata. */ pScreen->BlockHandler = winBlockHandler; pScreen->WakeupHandler = winWakeupHandler; pScreen->blockData = pScreen; pScreen->wakeupData = pScreen; /* Render extension initialization, calls miPictureInit */ if (!fbPictureInit (pScreen, NULL, 0)) { ErrorF ("winFinishScreenInitFB - fbPictureInit () failed\n"); return FALSE; } #ifdef RANDR /* Initialize resize and rotate support */ if (!winRandRInit (pScreen)) { ErrorF ("winFinishScreenInitFB - winRandRInit () failed\n"); return FALSE; } #endif /* * Backing store support should reduce network traffic and increase * performance. */ miInitializeBackingStore (pScreen); /* KDrive does miDCInitialize right after miInitializeBackingStore */ /* Setup the cursor routines */ #if CYGDEBUG winDebug ("winFinishScreenInitFB - Calling miDCInitialize ()\n"); #endif miDCInitialize (pScreen, &g_winPointerCursorFuncs); /* KDrive does winCreateDefColormap right after miDCInitialize */ /* Create a default colormap */ #if CYGDEBUG winDebug ("winFinishScreenInitFB - Calling winCreateDefColormap ()\n"); #endif if (!winCreateDefColormap (pScreen)) { ErrorF ("winFinishScreenInitFB - Could not create colormap\n"); return FALSE; } /* Initialize the shadow framebuffer layer */ if ((pScreenInfo->dwEngine == WIN_SERVER_SHADOW_GDI || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DD || pScreenInfo->dwEngine == WIN_SERVER_SHADOW_DDNL) #ifdef XWIN_MULTIWINDOWEXTWM && !pScreenInfo->fMWExtWM #endif ) { #if CYGDEBUG winDebug ("winFinishScreenInitFB - Calling shadowSetup ()\n"); #endif if (!shadowSetup(pScreen)) { ErrorF ("winFinishScreenInitFB - shadowSetup () failed\n"); return FALSE; } /* Wrap CreateScreenResources so we can add the screen pixmap to the Shadow framebuffer after it's been created */ pScreenPriv->pwinCreateScreenResources = pScreen->CreateScreenResources; pScreen->CreateScreenResources = winCreateScreenResources; } #ifdef XWIN_MULTIWINDOWEXTWM /* Handle multi-window external window manager mode */ if (pScreenInfo->fMWExtWM) { winDebug ("winScreenInit - MultiWindowExtWM - Calling RootlessInit\n"); RootlessInit(pScreen, &winMWExtWMProcs); winDebug ("winScreenInit - MultiWindowExtWM - RootlessInit returned\n"); rootless_CopyBytes_threshold = 0; /* FIXME: How many? Profiling needed? */ rootless_CopyWindow_threshold = 1; winWindowsWMExtensionInit (); } #endif /* Handle rootless mode */ if (pScreenInfo->fRootless) { /* Define the WRAP macro temporarily for local use */ #define WRAP(a) \ if (pScreen->a) { \ pScreenPriv->a = pScreen->a; \ } else { \ ErrorF("null screen fn " #a "\n"); \ pScreenPriv->a = NULL; \ } /* Save a pointer to each lower-level window procedure */ WRAP(CreateWindow); WRAP(DestroyWindow); WRAP(RealizeWindow); WRAP(UnrealizeWindow); WRAP(PositionWindow); WRAP(ChangeWindowAttributes); WRAP(SetShape); /* Assign rootless window procedures to be top level procedures */ pScreen->CreateWindow = winCreateWindowRootless; pScreen->DestroyWindow = winDestroyWindowRootless; pScreen->PositionWindow = winPositionWindowRootless; /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesRootless;*/ pScreen->RealizeWindow = winMapWindowRootless; pScreen->UnrealizeWindow = winUnmapWindowRootless; pScreen->SetShape = winSetShapeRootless; /* Undefine the WRAP macro, as it is not needed elsewhere */ #undef WRAP } #ifdef XWIN_MULTIWINDOW /* Handle multi window mode */ else if (pScreenInfo->fMultiWindow) { /* Define the WRAP macro temporarily for local use */ #define WRAP(a) \ if (pScreen->a) { \ pScreenPriv->a = pScreen->a; \ } else { \ ErrorF("null screen fn " #a "\n"); \ pScreenPriv->a = NULL; \ } /* Save a pointer to each lower-level window procedure */ WRAP(CreateWindow); WRAP(DestroyWindow); WRAP(RealizeWindow); WRAP(UnrealizeWindow); WRAP(PositionWindow); WRAP(ChangeWindowAttributes); WRAP(ReparentWindow); WRAP(RestackWindow); WRAP(ResizeWindow); WRAP(MoveWindow); WRAP(CopyWindow); WRAP(SetShape); /* Assign multi-window window procedures to be top level procedures */ pScreen->CreateWindow = winCreateWindowMultiWindow; pScreen->DestroyWindow = winDestroyWindowMultiWindow; pScreen->PositionWindow = winPositionWindowMultiWindow; /*pScreen->ChangeWindowAttributes = winChangeWindowAttributesMultiWindow;*/ pScreen->RealizeWindow = winMapWindowMultiWindow; pScreen->UnrealizeWindow = winUnmapWindowMultiWindow; pScreen->ReparentWindow = winReparentWindowMultiWindow; pScreen->RestackWindow = winRestackWindowMultiWindow; pScreen->ResizeWindow = winResizeWindowMultiWindow; pScreen->MoveWindow = winMoveWindowMultiWindow; pScreen->CopyWindow = winCopyWindowMultiWindow; pScreen->SetShape = winSetShapeMultiWindow; /* Undefine the WRAP macro, as it is not needed elsewhere */ #undef WRAP } #endif /* Wrap either fb's or shadow's CloseScreen with our CloseScreen */ pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = pScreenPriv->pwinCloseScreen; #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) /* Create a mutex for modules in separate threads to wait for */ iReturn = pthread_mutex_init (&pScreenPriv->pmServerStarted, NULL); if (iReturn != 0) { ErrorF ("winFinishScreenInitFB - pthread_mutex_init () failed: %d\n", iReturn); return FALSE; } /* Own the mutex for modules in separate threads */ iReturn = pthread_mutex_lock (&pScreenPriv->pmServerStarted); if (iReturn != 0) { ErrorF ("winFinishScreenInitFB - pthread_mutex_lock () failed: %d\n", iReturn); return FALSE; } /* Set the ServerStarted flag to false */ pScreenPriv->fServerStarted = FALSE; #endif #ifdef XWIN_MULTIWINDOWEXTWM pScreenPriv->fRestacking = FALSE; #endif #if defined(XWIN_MULTIWINDOW) || defined(XWIN_MULTIWINDOWEXTWM) if (FALSE #ifdef XWIN_MULTIWINDOW || pScreenInfo->fMultiWindow #endif #ifdef XWIN_MULTIWINDOWEXTWM || pScreenInfo->fInternalWM #endif ) { #if CYGDEBUG || YES winDebug ("winFinishScreenInitFB - Calling winInitWM.\n"); #endif /* Initialize multi window mode */ if (!winInitWM (&pScreenPriv->pWMInfo, &pScreenPriv->ptWMProc, &pScreenPriv->ptXMsgProc, &pScreenPriv->pmServerStarted, pScreenInfo->dwScreen, (HWND)&pScreenPriv->hwndScreen, #ifdef XWIN_MULTIWINDOWEXTWM pScreenInfo->fInternalWM || #endif FALSE)) { ErrorF ("winFinishScreenInitFB - winInitWM () failed.\n"); return FALSE; } } #endif /* Tell the server that we are enabled */ pScreenPriv->fEnabled = TRUE; /* Tell the server that we have a valid depth */ pScreenPriv->fBadDepth = FALSE; #if CYGDEBUG || YES winDebug ("winFinishScreenInitFB - returning\n"); #endif return TRUE; }
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 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 CG3ScreenInit(SCREEN_INIT_ARGS_DECL) { ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); Cg3Ptr pCg3; int ret; pCg3 = GET_CG3_FROM_SCRN(pScrn); /* Map the CG3 memory */ pCg3->fb = xf86MapSbusMem (pCg3->psdp, CG3_RAM_VOFF, (pCg3->psdp->width * pCg3->psdp->height)); if (! pCg3->fb) return FALSE; /* Darken the screen for aesthetic reasons and set the viewport */ CG3SaveScreen(pScreen, SCREEN_SAVER_ON); /* * The next step is to setup the screen's visuals, and initialise the * framebuffer code. In cases where the framebuffer's default * choices for things like visual layouts and bits per RGB are OK, * this may be as simple as calling the framebuffer's ScreenInit() * function. If not, the visuals will need to be setup before calling * a fb ScreenInit() function and fixed up after. */ /* * Reset visual list. */ miClearVisualTypes(); /* Set the bits per RGB for 8bpp mode */ pScrn->rgbBits = 8; /* Setup the visuals we support. */ if (!miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), pScrn->rgbBits, pScrn->defaultVisual)) return FALSE; miSetPixmapDepths (); /* * Call the framebuffer layer's ScreenInit function, and fill in other * pScreen fields. */ ret = fbScreenInit(pScreen, pCg3->fb, pScrn->virtualX, pScrn->virtualY, pScrn->xDpi, pScrn->yDpi, pScrn->virtualX, 8); if (!ret) return FALSE; #ifdef RENDER fbPictureInit (pScreen, 0, 0); #endif xf86SetBackingStore(pScreen); xf86SetSilkenMouse(pScreen); xf86SetBlackWhitePixels(pScreen); /* Initialise cursor functions */ miDCInitialize (pScreen, xf86GetPointerScreenFuncs()); /* Initialise default colourmap */ if (!miCreateDefColormap(pScreen)) return FALSE; if(!xf86SbusHandleColormaps(pScreen, pCg3->psdp)) return FALSE; pCg3->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = CG3CloseScreen; pScreen->SaveScreen = CG3SaveScreen; /* Report any unused options (only for the first generation) */ if (serverGeneration == 1) { xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); } /* unblank the screen */ CG3SaveScreen(pScreen, SCREEN_SAVER_OFF); /* Done */ return TRUE; }
static Bool xeglScreenInit (int index, ScreenPtr pScreen, int argc, char **argv) { EGLSurface eSurface; EGLModeMESA mode; int count; xeglScreenPtr pScreenPriv; glitz_drawable_format_t *format; glitz_drawable_t *drawable; EGLint screenAttribs[] = { EGL_WIDTH, 1024, EGL_HEIGHT, 768, EGL_NONE }; if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0) { xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH; xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT; } screenAttribs[1] = xglScreenInfo.width; screenAttribs[3] = xglScreenInfo.height; format = xglVisuals[0].format; if (!xeglAllocatePrivates (pScreen)) return FALSE; currentScreen = pScreen; pScreenPriv = XEGL_GET_SCREEN_PRIV (pScreen); if (xglScreenInfo.width == 0 || xglScreenInfo.height == 0) { xglScreenInfo.width = XEGL_DEFAULT_SCREEN_WIDTH; xglScreenInfo.height = XEGL_DEFAULT_SCREEN_HEIGHT; } eglGetModesMESA (eDisplay, eScreen, &mode, 1, &count); eSurface = eglCreateScreenSurfaceMESA (eDisplay, format->id, screenAttribs); if (eSurface == EGL_NO_SURFACE) { ErrorF ("failed to create screen surface\n"); return FALSE; } eglShowScreenSurfaceMESA (eDisplay, eScreen, eSurface, mode); drawable = glitz_egl_create_surface (eDisplay, eScreen, format, eSurface, xglScreenInfo.width, xglScreenInfo.height); if (!drawable) { ErrorF ("[%d] couldn't create glitz drawable for window\n", index); return FALSE; } xglScreenInfo.drawable = drawable; if (!xglScreenInit (pScreen)) return FALSE; #ifdef GLXEXT if (!xglInitVisualConfigs (pScreen)) return FALSE; #endif XGL_SCREEN_WRAP (CloseScreen, xeglCloseScreen); miDCInitialize (pScreen, &kdPointerScreenFuncs); miCreateDefColormap(pScreen); if (!xglFinishScreenInit (pScreen)) return FALSE; return TRUE; }