Bool xf86SbusHandleColormaps(ScreenPtr pScreen, sbusDevicePtr psdp) { sbusCmapPtr cmap; struct fbcmap fbcmap; unsigned char data[2]; if (!dixRegisterPrivateKey(sbusPaletteKey, PRIVATE_SCREEN, 0)) FatalError("Cannot register sbus private key"); cmap = xnfcalloc(1, sizeof(sbusCmapRec)); dixSetPrivate(&pScreen->devPrivates, sbusPaletteKey, cmap); cmap->psdp = psdp; fbcmap.index = 0; fbcmap.count = 16; fbcmap.red = cmap->origRed; fbcmap.green = cmap->origGreen; fbcmap.blue = cmap->origBlue; if (ioctl(psdp->fd, FBIOGETCMAP, &fbcmap) >= 0) cmap->origCmapValid = TRUE; fbcmap.index = 0; fbcmap.count = 2; fbcmap.red = data; fbcmap.green = data; fbcmap.blue = data; if (pScreen->whitePixel == 0) { data[0] = 255; data[1] = 0; } else { data[0] = 0; data[1] = 255; } ioctl(psdp->fd, FBIOPUTCMAP, &fbcmap); cmap->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86SbusCmapCloseScreen; return xf86HandleColormaps(pScreen, 256, 8, xf86SbusCmapLoadPalette, NULL, 0); }
Bool radeon_glamor_init(ScreenPtr screen) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS | GLAMOR_USE_EGL_SCREEN | #ifdef GLAMOR_NO_DRI3 GLAMOR_NO_DRI3 | #endif GLAMOR_USE_SCREEN | GLAMOR_USE_PICTURE_SCREEN)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to initialize glamor.\n"); return FALSE; } if (!glamor_egl_init_textured_pixmap(screen)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to initialize textured pixmap of screen for glamor.\n"); return FALSE; } #if HAS_DIXREGISTERPRIVATEKEY if (!dixRegisterPrivateKey(&glamor_pixmap_index, PRIVATE_PIXMAP, 0)) #else if (!dixRequestPrivate(&glamor_pixmap_index, 0)) #endif return FALSE; screen->CreatePixmap = radeon_glamor_create_pixmap; screen->DestroyPixmap = radeon_glamor_destroy_pixmap; #ifdef RADEON_PIXMAP_SHARING screen->SharePixmapBacking = radeon_glamor_share_pixmap_backing; screen->SetSharedPixmapBacking = radeon_glamor_set_shared_pixmap_backing; #endif xf86DrvMsg(scrn->scrnIndex, X_INFO, "Use GLAMOR acceleration.\n"); return TRUE; }
Bool xf86InitFBManagerRegion(ScreenPtr pScreen, RegionPtr FullRegion) { FBManagerPtr offman; if (RegionNil(FullRegion)) return FALSE; if (!dixRegisterPrivateKey(&xf86FBScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!xf86RegisterOffscreenManager(pScreen, &xf86FBManFuncs)) return FALSE; offman = malloc(sizeof(FBManager)); if (!offman) return FALSE; dixSetPrivate(&pScreen->devPrivates, xf86FBScreenKey, offman); offman->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86FBCloseScreen; offman->InitialBoxes = RegionCreate(NULL, 1); offman->FreeBoxes = RegionCreate(NULL, 1); RegionCopy(offman->InitialBoxes, FullRegion); RegionCopy(offman->FreeBoxes, FullRegion); offman->pScreen = pScreen; offman->UsedAreas = NULL; offman->LinearAreas = NULL; offman->NumUsedAreas = 0; offman->NumCallbacks = 0; offman->FreeBoxesUpdateCallback = NULL; offman->devPrivates = NULL; return TRUE; }
Bool glamor_sync_init(ScreenPtr screen) { #if XSYNC glamor_screen_private *glamor = glamor_get_screen_private(screen); SyncScreenFuncsPtr screen_funcs; if (!dixPrivateKeyRegistered(&glamor_sync_fence_key)) { if (!dixRegisterPrivateKey(&glamor_sync_fence_key, PRIVATE_SYNC_FENCE, sizeof (struct glamor_sync_fence))) return FALSE; } if (!miSyncShmScreenInit(screen)) return FALSE; screen_funcs = miSyncGetScreenFuncs(screen); glamor->saved_procs.sync_screen_funcs.CreateFence = screen_funcs->CreateFence; screen_funcs->CreateFence = glamor_sync_create_fence; #endif return TRUE; }
/** Initialize the RENDER extension, allocate the picture privates and * wrap mi function hooks. If the shadow frame buffer is used, then * call the appropriate fb initialization function. */ Bool dmxPictureInit(ScreenPtr pScreen, PictFormatPtr formats, int nformats) { DMXScreenInfo *dmxScreen = &dmxScreens[pScreen->myNum]; PictureScreenPtr ps; /* The shadow framebuffer only relies on FB to be initialized */ if (dmxShadowFB) return fbPictureInit(pScreen, formats, nformats); if (!miPictureInit(pScreen, formats, nformats)) return FALSE; if (!dixRegisterPrivateKey (&dmxPictPrivateKeyRec, PRIVATE_PICTURE, sizeof(dmxPictPrivRec))) return FALSE; ps = GetPictureScreen(pScreen); DMX_WRAP(CreatePicture, dmxCreatePicture, dmxScreen, ps); DMX_WRAP(DestroyPicture, dmxDestroyPicture, dmxScreen, ps); DMX_WRAP(ChangePictureClip, dmxChangePictureClip, dmxScreen, ps); DMX_WRAP(DestroyPictureClip, dmxDestroyPictureClip, dmxScreen, ps); DMX_WRAP(ChangePicture, dmxChangePicture, dmxScreen, ps); DMX_WRAP(ValidatePicture, dmxValidatePicture, dmxScreen, ps); DMX_WRAP(Composite, dmxComposite, dmxScreen, ps); DMX_WRAP(Glyphs, dmxGlyphs, dmxScreen, ps); DMX_WRAP(CompositeRects, dmxCompositeRects, dmxScreen, ps); DMX_WRAP(Trapezoids, dmxTrapezoids, dmxScreen, ps); DMX_WRAP(Triangles, dmxTriangles, dmxScreen, ps); return TRUE; }
Bool AnimCurInit(ScreenPtr pScreen) { AnimCurScreenPtr as; if (!dixRegisterPrivateKey(&AnimCurScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; as = (AnimCurScreenPtr) malloc(sizeof(AnimCurScreenRec)); if (!as) return FALSE; Wrap(as, pScreen, CloseScreen, AnimCurCloseScreen); as->BlockHandler = NULL; Wrap(as, pScreen, CursorLimits, AnimCurCursorLimits); Wrap(as, pScreen, DisplayCursor, AnimCurDisplayCursor); Wrap(as, pScreen, SetCursorPosition, AnimCurSetCursorPosition); Wrap(as, pScreen, RealizeCursor, AnimCurRealizeCursor); Wrap(as, pScreen, UnrealizeCursor, AnimCurUnrealizeCursor); Wrap(as, pScreen, RecolorCursor, AnimCurRecolorCursor); SetAnimCurScreen(pScreen, as); return TRUE; }
Bool XAAInit(ScreenPtr pScreen, XAAInfoRecPtr infoRec) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAScreenPtr pScreenPriv; int i; PictureScreenPtr ps = GetPictureScreenIfSet(pScreen); /* Return successfully if no acceleration wanted */ if (!infoRec) return TRUE; if (!dixRegisterPrivateKey(&XAAGCKeyRec, PRIVATE_GC, sizeof(XAAGCRec))) return FALSE; if (!dixRegisterPrivateKey(&XAAPixmapKeyRec, PRIVATE_PIXMAP, sizeof(XAAPixmapRec))) return FALSE; if (!dixRegisterPrivateKey(&XAAScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!(pScreenPriv = malloc(sizeof(XAAScreenRec)))) return FALSE; dixSetPrivate(&pScreen->devPrivates, XAAScreenKey, pScreenPriv); if(!xf86FBManagerRunning(pScreen)) infoRec->Flags &= ~(PIXMAP_CACHE | OFFSCREEN_PIXMAPS); if(!(infoRec->Flags & LINEAR_FRAMEBUFFER)) infoRec->Flags &= ~OFFSCREEN_PIXMAPS; if(!infoRec->FullPlanemask) { /* for backwards compatibility */ infoRec->FullPlanemask = (1 << pScrn->depth) - 1; infoRec->FullPlanemasks[pScrn->depth - 1] = infoRec->FullPlanemask; } for(i = 0; i < 32; i++) { if(!infoRec->FullPlanemasks[i]) /* keep any set by caller */ infoRec->FullPlanemasks[i] = (1 << (i+1)) - 1; } if(!XAAInitAccel(pScreen, infoRec)) return FALSE; pScreenPriv->AccelInfoRec = infoRec; infoRec->ScratchGC.pScreen = pScreen; if(!infoRec->GetImage) infoRec->GetImage = XAAGetImage; if(!infoRec->GetSpans) infoRec->GetSpans = XAAGetSpans; if(!infoRec->CopyWindow) infoRec->CopyWindow = XAACopyWindow; pScreenPriv->CreateGC = pScreen->CreateGC; pScreen->CreateGC = XAACreateGC; pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = XAACloseScreen; pScreenPriv->GetImage = pScreen->GetImage; pScreen->GetImage = infoRec->GetImage; pScreenPriv->GetSpans = pScreen->GetSpans; pScreen->GetSpans = infoRec->GetSpans; pScreenPriv->CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = infoRec->CopyWindow; pScreenPriv->CreatePixmap = pScreen->CreatePixmap; pScreen->CreatePixmap = XAACreatePixmap; pScreenPriv->DestroyPixmap = pScreen->DestroyPixmap; pScreen->DestroyPixmap = XAADestroyPixmap; pScreenPriv->ChangeWindowAttributes = pScreen->ChangeWindowAttributes; pScreen->ChangeWindowAttributes = XAAChangeWindowAttributes; pScreenPriv->EnterVT = pScrn->EnterVT; pScrn->EnterVT = XAAEnterVT; pScreenPriv->LeaveVT = pScrn->LeaveVT; pScrn->LeaveVT = XAALeaveVT; pScreenPriv->SetDGAMode = pScrn->SetDGAMode; pScrn->SetDGAMode = XAASetDGAMode; pScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = XAAEnableDisableFBAccess; pScreenPriv->WindowExposures = pScreen->WindowExposures; if (ps) { pScreenPriv->Composite = ps->Composite; ps->Composite = XAAComposite; pScreenPriv->Glyphs = ps->Glyphs; ps->Glyphs = XAAGlyphs; } if(pScrn->overlayFlags & OVERLAY_8_32_PLANAR) XAASetupOverlay8_32Planar(pScreen); infoRec->PreAllocMem = malloc(MAX_PREALLOC_MEM); if(infoRec->PreAllocMem) infoRec->PreAllocSize = MAX_PREALLOC_MEM; if(infoRec->Flags & PIXMAP_CACHE) xf86RegisterFreeBoxCallback(pScreen, infoRec->InitPixmapCache, (pointer)infoRec); if(infoRec->Flags & MICROSOFT_ZERO_LINE_BIAS) miSetZeroLineBias(pScreen, OCTANT1 | OCTANT2 | OCTANT3 | OCTANT4); #ifdef COMPOSITE /* Initialize the composite wrapper. This needs to happen after the * wrapping above (so it comes before us), but before all other extensions, * so it doesn't confuse them. (particularly damage). */ miInitializeCompositeWrapper(pScreen); #endif return TRUE; }
/* ** Initialize the GLX extension. */ void GlxExtensionInit(void) { ExtensionEntry *extEntry; ScreenPtr pScreen; int i; __GLXprovider *p, **stack; Bool glx_provided = False; if (serverGeneration == 1) { for (stack = &__glXProviderStack; *stack; stack = &(*stack)->next) ; *stack = &__glXDRISWRastProvider; } __glXContextRes = CreateNewResourceType((DeleteType) ContextGone, "GLXContext"); __glXDrawableRes = CreateNewResourceType((DeleteType) DrawableGone, "GLXDrawable"); if (!__glXContextRes || !__glXDrawableRes) return; if (!dixRegisterPrivateKey (&glxClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(__GLXclientState))) return; if (!AddCallback(&ClientStateCallback, glxClientCallback, 0)) return; for (i = 0; i < screenInfo.numScreens; i++) { pScreen = screenInfo.screens[i]; for (p = __glXProviderStack; p != NULL; p = p->next) { __GLXscreen *glxScreen; glxScreen = p->screenProbe(pScreen); if (glxScreen != NULL) { if (glxScreen->GLXminor < glxMinorVersion) glxMinorVersion = glxScreen->GLXminor; LogMessage(X_INFO, "GLX: Initialized %s GL provider for screen %d\n", p->name, i); break; } } if (!p) LogMessage(X_INFO, "GLX: no usable GL providers found for screen %d\n", i); else glx_provided = True; } /* don't register extension if GL is not provided on any screen */ if (!glx_provided) return; /* ** Add extension to server extensions. */ extEntry = AddExtension(GLX_EXTENSION_NAME, __GLX_NUMBER_EVENTS, __GLX_NUMBER_ERRORS, __glXDispatch, __glXDispatch, ResetExtension, StandardMinorOpcode); if (!extEntry) { FatalError("__glXExtensionInit: AddExtensions failed\n"); return; } if (!AddExtensionAlias(GLX_EXTENSION_ALIAS, extEntry)) { ErrorF("__glXExtensionInit: AddExtensionAlias failed\n"); return; } __glXErrorBase = extEntry->errorBase; __glXEventBase = extEntry->eventBase; }
Bool XAAInitDualFramebufferOverlay(ScreenPtr pScreen, DepthChangeFuncPtr callback) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; XAAInfoRecPtr infoRec = GET_XAAINFORECPTR_FROM_SCREEN(pScreen); XAAOverlayPtr pOverPriv; if (!dixRegisterPrivateKey(&XAAOverlayKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!(pOverPriv = malloc(sizeof(XAAOverlayRec)))) return FALSE; dixSetPrivate(&pScreen->devPrivates, XAAOverlayKey, pOverPriv); pOverPriv->pScrn = pScrn; pOverPriv->callback = callback; pOverPriv->currentDepth = -1; /* Overwrite key screen functions. The XAA core will clean up */ pScreen->CopyWindow = XAAOverCopyWindow; pScreen->WindowExposures = XAAOverWindowExposures; pOverPriv->StippledFillChooser = infoRec->StippledFillChooser; pOverPriv->OpaqueStippledFillChooser = infoRec->OpaqueStippledFillChooser; pOverPriv->TiledFillChooser = infoRec->TiledFillChooser; infoRec->StippledFillChooser = XAAOverStippledFillChooser; infoRec->OpaqueStippledFillChooser = XAAOverOpaqueStippledFillChooser; infoRec->TiledFillChooser = XAAOverTiledFillChooser; /* wrap all XAA GC rendering */ pOverPriv->CopyArea = infoRec->CopyArea; pOverPriv->CopyPlane = infoRec->CopyPlane; pOverPriv->PushPixelsSolid = infoRec->PushPixelsSolid; pOverPriv->PolyFillRectSolid = infoRec->PolyFillRectSolid; pOverPriv->PolyFillRectStippled = infoRec->PolyFillRectStippled; pOverPriv->PolyFillRectOpaqueStippled = infoRec->PolyFillRectOpaqueStippled; pOverPriv->PolyFillRectTiled = infoRec->PolyFillRectTiled; pOverPriv->FillSpansSolid = infoRec->FillSpansSolid; pOverPriv->FillSpansStippled = infoRec->FillSpansStippled; pOverPriv->FillSpansOpaqueStippled = infoRec->FillSpansOpaqueStippled; pOverPriv->FillSpansTiled = infoRec->FillSpansTiled; pOverPriv->PolyText8TE = infoRec->PolyText8TE; pOverPriv->PolyText16TE = infoRec->PolyText16TE; pOverPriv->ImageText8TE = infoRec->ImageText8TE; pOverPriv->ImageText16TE = infoRec->ImageText16TE; pOverPriv->ImageGlyphBltTE = infoRec->ImageGlyphBltTE; pOverPriv->PolyGlyphBltTE = infoRec->PolyGlyphBltTE; pOverPriv->PolyText8NonTE = infoRec->PolyText8NonTE; pOverPriv->PolyText16NonTE = infoRec->PolyText16NonTE; pOverPriv->ImageText8NonTE = infoRec->ImageText8NonTE; pOverPriv->ImageText16NonTE = infoRec->ImageText16NonTE; pOverPriv->ImageGlyphBltNonTE = infoRec->ImageGlyphBltNonTE; pOverPriv->PolyGlyphBltNonTE = infoRec->PolyGlyphBltNonTE; pOverPriv->PolyRectangleThinSolid = infoRec->PolyRectangleThinSolid; pOverPriv->PolylinesWideSolid = infoRec->PolylinesWideSolid; pOverPriv->PolylinesThinSolid = infoRec->PolylinesThinSolid; pOverPriv->PolySegmentThinSolid = infoRec->PolySegmentThinSolid; pOverPriv->PolylinesThinDashed = infoRec->PolylinesThinDashed; pOverPriv->PolySegmentThinDashed = infoRec->PolySegmentThinDashed; pOverPriv->FillPolygonSolid = infoRec->FillPolygonSolid; pOverPriv->FillPolygonStippled = infoRec->FillPolygonStippled; pOverPriv->FillPolygonOpaqueStippled = infoRec->FillPolygonOpaqueStippled; pOverPriv->FillPolygonTiled = infoRec->FillPolygonTiled; pOverPriv->PolyFillArcSolid = infoRec->PolyFillArcSolid; pOverPriv->PutImage = infoRec->PutImage; if (infoRec->CopyArea) infoRec->CopyArea = XAAOverCopyArea; if (infoRec->CopyPlane) infoRec->CopyPlane = XAAOverCopyPlane; if (infoRec->PushPixelsSolid) infoRec->PushPixelsSolid = XAAOverPushPixelsSolid; if (infoRec->PolyFillRectSolid) infoRec->PolyFillRectSolid = XAAOverPolyFillRectSolid; if (infoRec->PolyFillRectStippled) infoRec->PolyFillRectStippled = XAAOverPolyFillRectStippled; if (infoRec->PolyFillRectOpaqueStippled) infoRec->PolyFillRectOpaqueStippled = XAAOverPolyFillRectOpaqueStippled; if (infoRec->PolyFillRectTiled) infoRec->PolyFillRectTiled = XAAOverPolyFillRectTiled; if (infoRec->FillSpansSolid) infoRec->FillSpansSolid = XAAOverFillSpansSolid; if (infoRec->FillSpansStippled) infoRec->FillSpansStippled = XAAOverFillSpansStippled; if (infoRec->FillSpansOpaqueStippled) infoRec->FillSpansOpaqueStippled = XAAOverFillSpansOpaqueStippled; if (infoRec->FillSpansTiled) infoRec->FillSpansTiled = XAAOverFillSpansTiled; if (infoRec->PolyText8TE) infoRec->PolyText8TE = XAAOverPolyText8TE; if (infoRec->PolyText16TE) infoRec->PolyText16TE = XAAOverPolyText16TE; if (infoRec->ImageText8TE) infoRec->ImageText8TE = XAAOverImageText8TE; if (infoRec->ImageText16TE) infoRec->ImageText16TE = XAAOverImageText16TE; if (infoRec->ImageGlyphBltTE) infoRec->ImageGlyphBltTE = XAAOverImageGlyphBltTE; if (infoRec->PolyGlyphBltTE) infoRec->PolyGlyphBltTE = XAAOverPolyGlyphBltTE; if (infoRec->PolyText8NonTE) infoRec->PolyText8NonTE = XAAOverPolyText8NonTE; if (infoRec->PolyText16NonTE) infoRec->PolyText16NonTE = XAAOverPolyText16NonTE; if (infoRec->ImageText8NonTE) infoRec->ImageText8NonTE = XAAOverImageText8NonTE; if (infoRec->ImageText16NonTE) infoRec->ImageText16NonTE = XAAOverImageText16NonTE; if (infoRec->ImageGlyphBltNonTE) infoRec->ImageGlyphBltNonTE = XAAOverImageGlyphBltNonTE; if (infoRec->PolyGlyphBltNonTE) infoRec->PolyGlyphBltNonTE = XAAOverPolyGlyphBltNonTE; if (infoRec->PolyRectangleThinSolid) infoRec->PolyRectangleThinSolid = XAAOverPolyRectangleThinSolid; if (infoRec->PolylinesWideSolid) infoRec->PolylinesWideSolid = XAAOverPolylinesWideSolid; if (infoRec->PolylinesThinSolid) infoRec->PolylinesThinSolid = XAAOverPolylinesThinSolid; if (infoRec->PolySegmentThinSolid) infoRec->PolySegmentThinSolid = XAAOverPolySegmentThinSolid; if (infoRec->PolylinesThinDashed) infoRec->PolylinesThinDashed = XAAOverPolylinesThinDashed; if (infoRec->PolySegmentThinDashed) infoRec->PolySegmentThinDashed = XAAOverPolySegmentThinDashed; if (infoRec->FillPolygonSolid) infoRec->FillPolygonSolid = XAAOverFillPolygonSolid; if (infoRec->FillPolygonStippled) infoRec->FillPolygonStippled = XAAOverFillPolygonStippled; if (infoRec->FillPolygonOpaqueStippled) infoRec->FillPolygonOpaqueStippled = XAAOverFillPolygonOpaqueStippled; if (infoRec->FillPolygonTiled) infoRec->FillPolygonTiled = XAAOverFillPolygonTiled; if (infoRec->PolyFillArcSolid) infoRec->PolyFillArcSolid = XAAOverPolyFillArcSolid; if (infoRec->PutImage) infoRec->PutImage = XAAOverPutImage; return TRUE; }
Bool xf86VGAarbiterWrapFunctions(void) { ScrnInfoPtr pScrn; VGAarbiterScreenPtr pScreenPriv; miPointerScreenPtr PointPriv; PictureScreenPtr ps; ScreenPtr pScreen; int vga_count, i; if (vga_no_arb) return FALSE; /* * we need to wrap the arbiter if we have more than * one VGA card - hotplug cries. */ pci_device_vgaarb_get_info(NULL, &vga_count, NULL); if (vga_count < 2 || !xf86Screens) return FALSE; xf86Msg(X_INFO, "Found %d VGA devices: arbiter wrapping enabled\n", vga_count); for (i = 0; i < xf86NumScreens; i++) { pScreen = xf86Screens[i]->pScreen; ps = GetPictureScreenIfSet(pScreen); pScrn = xf86ScreenToScrn(pScreen); PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); if (!dixRegisterPrivateKey (&VGAarbiterGCKeyRec, PRIVATE_GC, sizeof(VGAarbiterGCRec))) return FALSE; if (!dixRegisterPrivateKey(&VGAarbiterScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; if (!(pScreenPriv = malloc(sizeof(VGAarbiterScreenRec)))) return FALSE; dixSetPrivate(&pScreen->devPrivates, VGAarbiterScreenKey, pScreenPriv); WRAP_SCREEN(CloseScreen, VGAarbiterCloseScreen); WRAP_SCREEN(SaveScreen, VGAarbiterSaveScreen); WRAP_SCREEN(WakeupHandler, VGAarbiterWakeupHandler); WRAP_SCREEN(BlockHandler, VGAarbiterBlockHandler); WRAP_SCREEN(CreateGC, VGAarbiterCreateGC); WRAP_SCREEN(GetImage, VGAarbiterGetImage); WRAP_SCREEN(GetSpans, VGAarbiterGetSpans); WRAP_SCREEN(SourceValidate, VGAarbiterSourceValidate); WRAP_SCREEN(CopyWindow, VGAarbiterCopyWindow); WRAP_SCREEN(ClearToBackground, VGAarbiterClearToBackground); WRAP_SCREEN(CreatePixmap, VGAarbiterCreatePixmap); WRAP_SCREEN(StoreColors, VGAarbiterStoreColors); WRAP_SCREEN(DisplayCursor, VGAarbiterDisplayCursor); WRAP_SCREEN(RealizeCursor, VGAarbiterRealizeCursor); WRAP_SCREEN(UnrealizeCursor, VGAarbiterUnrealizeCursor); WRAP_SCREEN(RecolorCursor, VGAarbiterRecolorCursor); WRAP_SCREEN(SetCursorPosition, VGAarbiterSetCursorPosition); WRAP_PICT(Composite, VGAarbiterComposite); WRAP_PICT(Glyphs, VGAarbiterGlyphs); WRAP_PICT(CompositeRects, VGAarbiterCompositeRects); WRAP_SCREEN_INFO(AdjustFrame, VGAarbiterAdjustFrame); WRAP_SCREEN_INFO(SwitchMode, VGAarbiterSwitchMode); WRAP_SCREEN_INFO(EnterVT, VGAarbiterEnterVT); WRAP_SCREEN_INFO(LeaveVT, VGAarbiterLeaveVT); WRAP_SCREEN_INFO(FreeScreen, VGAarbiterFreeScreen); WRAP_SPRITE; } return TRUE; }
/** * @param pScreen screen being initialized * @param pScreenInfo SAA driver record * * saa_driver_init sets up SAA given a driver record filled in by the driver. * pScreenInfo should have been allocated by saa_driver_alloc(). See the * comments in _SaaDriver for what must be filled in and what is optional. * * @return TRUE if SAA was successfully initialized. */ Bool saa_driver_init(ScreenPtr screen, struct saa_driver * saa_driver) { struct saa_screen_priv *sscreen; if (!saa_driver) return FALSE; if (saa_driver->saa_major != SAA_VERSION_MAJOR || saa_driver->saa_minor > SAA_VERSION_MINOR) { LogMessage(X_ERROR, "SAA(%d): driver's SAA version requirements " "(%d.%d) are incompatible with SAA version (%d.%d)\n", screen->myNum, saa_driver->saa_major, saa_driver->saa_minor, SAA_VERSION_MAJOR, SAA_VERSION_MINOR); return FALSE; } #if 0 if (!saa_driver->prepare_solid) { LogMessage(X_ERROR, "SAA(%d): saa_driver_t::prepare_solid must be " "non-NULL\n", screen->myNum); return FALSE; } if (!saa_driver->prepare_copy) { LogMessage(X_ERROR, "SAA(%d): saa_driver_t::prepare_copy must be " "non-NULL\n", screen->myNum); return FALSE; } #endif #ifdef SAA_DEVPRIVATEKEYREC if (!dixRegisterPrivateKey(&saa_screen_index, PRIVATE_SCREEN, 0)) { LogMessage(X_ERROR, "Failed to register SAA screen private.\n"); return FALSE; } if (!dixRegisterPrivateKey(&saa_pixmap_index, PRIVATE_PIXMAP, saa_driver->pixmap_size)) { LogMessage(X_ERROR, "Failed to register SAA pixmap private.\n"); return FALSE; } if (!dixRegisterPrivateKey(&saa_gc_index, PRIVATE_GC, sizeof(struct saa_gc_priv))) { LogMessage(X_ERROR, "Failed to register SAA gc private.\n"); return FALSE; } #else if (!dixRequestPrivate(&saa_screen_index, 0)) { LogMessage(X_ERROR, "Failed to register SAA screen private.\n"); return FALSE; } if (!dixRequestPrivate(&saa_pixmap_index, saa_driver->pixmap_size)) { LogMessage(X_ERROR, "Failed to register SAA pixmap private.\n"); return FALSE; } if (!dixRequestPrivate(&saa_gc_index, sizeof(struct saa_gc_priv))) { LogMessage(X_ERROR, "Failed to register SAA gc private.\n"); return FALSE; } #endif sscreen = calloc(1, sizeof(*sscreen)); if (!sscreen) { LogMessage(X_WARNING, "SAA(%d): Failed to allocate screen private\n", screen->myNum); return FALSE; } sscreen->driver = saa_driver; dixSetPrivate(&screen->devPrivates, &saa_screen_index, sscreen); /* * Replace various fb screen functions */ saa_wrap(sscreen, screen, CloseScreen, saa_close_screen); saa_wrap(sscreen, screen, CreateGC, saa_create_gc); saa_wrap(sscreen, screen, ChangeWindowAttributes, saa_change_window_attributes); saa_wrap(sscreen, screen, CreatePixmap, saa_create_pixmap); saa_wrap(sscreen, screen, DestroyPixmap, saa_destroy_pixmap); saa_wrap(sscreen, screen, ModifyPixmapHeader, saa_modify_pixmap_header); saa_wrap(sscreen, screen, BitmapToRegion, saa_bitmap_to_region); saa_unaccel_setup(screen); #ifdef RENDER saa_render_setup(screen); #endif return TRUE; }
/** * This will be called during exaDriverInit, giving us the chance to set options * and hook in our EnableDisableFBAccess. */ void exaDDXDriverInit(ScreenPtr pScreen) { ExaScreenPriv(pScreen); ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); ExaXorgScreenPrivPtr pScreenPriv; if (!dixRegisterPrivateKey(&exaXorgScreenPrivateKeyRec, PRIVATE_SCREEN, 0)) return; pScreenPriv = calloc(1, sizeof(ExaXorgScreenPrivRec)); if (pScreenPriv == NULL) return; pScreenPriv->options = xnfalloc(sizeof(EXAOptions)); memcpy(pScreenPriv->options, EXAOptions, sizeof(EXAOptions)); xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, pScreenPriv->options); if (pExaScr->info->flags & EXA_OFFSCREEN_PIXMAPS) { if (!(pExaScr->info->flags & EXA_HANDLES_PIXMAPS) && pExaScr->info->offScreenBase < pExaScr->info->memorySize) { const char *heuristicName; heuristicName = xf86GetOptValString(pScreenPriv->options, EXAOPT_MIGRATION_HEURISTIC); if (heuristicName != NULL) { if (strcmp(heuristicName, "greedy") == 0) pExaScr->migration = ExaMigrationGreedy; else if (strcmp(heuristicName, "always") == 0) pExaScr->migration = ExaMigrationAlways; else if (strcmp(heuristicName, "smart") == 0) pExaScr->migration = ExaMigrationSmart; else { xf86DrvMsg(pScreen->myNum, X_WARNING, "EXA: unknown migration heuristic %s\n", heuristicName); } } } pExaScr->optimize_migration = xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_OPTIMIZE_MIGRATION, TRUE); } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_COMPOSITE, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling Composite operation " "(RENDER acceleration)\n"); pExaScr->info->CheckComposite = NULL; pExaScr->info->PrepareComposite = NULL; } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_UTS, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling UploadToScreen\n"); pExaScr->info->UploadToScreen = NULL; } if (xf86ReturnOptValBool(pScreenPriv->options, EXAOPT_NO_DFS, FALSE)) { xf86DrvMsg(pScreen->myNum, X_CONFIG, "EXA: Disabling DownloadFromScreen\n"); pExaScr->info->DownloadFromScreen = NULL; } dixSetPrivate(&pScreen->devPrivates, exaXorgScreenPrivateKey, pScreenPriv); pScreenPriv->SavedEnableDisableFBAccess = pScrn->EnableDisableFBAccess; pScrn->EnableDisableFBAccess = exaXorgEnableDisableFBAccess; pScreenPriv->SavedCloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = exaXorgCloseScreen; }
vfbScreenInit(ScreenPtr pScreen, int argc, char **argv) #endif { #if XORG < 113 vfbScreenInfoPtr pvfb = &vfbScreens[index]; #else vfbScreenInfoPtr pvfb = &vfbScreens[pScreen->myNum]; #endif int dpi; int ret; void *pbits; #ifdef RANDR rrScrPrivPtr rp; #endif #if XORG >= 113 if (!dixRegisterPrivateKey(&cmapScrPrivateKeyRec, PRIVATE_SCREEN, 0)) return FALSE; #endif /* 96 is the default used by most other systems */ dpi = 96; if (monitorResolution) dpi = monitorResolution; pbits = vfbAllocateFramebufferMemory(&pvfb->fb); if (!pbits) return FALSE; #if XORG < 113 vncFbptr[index] = pbits; vncFbstride[index] = pvfb->fb.paddedWidth; #else vncFbptr[pScreen->myNum] = pbits; vncFbstride[pScreen->myNum] = pvfb->fb.paddedWidth; #endif miSetPixmapDepths(); switch (pvfb->fb.depth) { case 8: miSetVisualTypesAndMasks (8, ((1 << StaticGray) | (1 << GrayScale) | (1 << StaticColor) | (1 << PseudoColor) | (1 << TrueColor) | (1 << DirectColor)), 8, PseudoColor, 0, 0, 0); break; case 16: miSetVisualTypesAndMasks (16, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xf800, 0x07e0, 0x001f); break; case 24: miSetVisualTypesAndMasks (24, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xff0000, 0x00ff00, 0x0000ff); break; case 32: miSetVisualTypesAndMasks (32, ((1 << TrueColor) | (1 << DirectColor)), 8, TrueColor, 0xff000000, 0x00ff0000, 0x0000ff00); break; default: return FALSE; } ret = fbScreenInit(pScreen, pbits, pvfb->fb.width, pvfb->fb.height, dpi, dpi, pvfb->fb.paddedWidth, pvfb->fb.bitsPerPixel); #ifdef RENDER if (ret && Render) ret = fbPictureInit (pScreen, 0, 0); #endif if (!ret) return FALSE; #if XORG < 110 miInitializeBackingStore(pScreen); #endif /* * Circumvent the backing store that was just initialised. This amounts * to a truely bizarre way of initialising SaveDoomedAreas and friends. */ pScreen->InstallColormap = vfbInstallColormap; pScreen->UninstallColormap = vfbUninstallColormap; pScreen->ListInstalledColormaps = vfbListInstalledColormaps; pScreen->SaveScreen = vfbSaveScreen; miPointerInitialize(pScreen, &vfbPointerSpriteFuncs, &vfbPointerCursorFuncs, FALSE); pScreen->blackPixel = pvfb->blackPixel; pScreen->whitePixel = pvfb->whitePixel; if (!pvfb->pixelFormatDefined) { switch (pvfb->fb.depth) { case 16: pvfb->pixelFormatDefined = TRUE; pvfb->rgbNotBgr = TRUE; pvfb->blueBits = pvfb->redBits = 5; pvfb->greenBits = 6; break; case 24: case 32: pvfb->pixelFormatDefined = TRUE; pvfb->rgbNotBgr = TRUE; pvfb->blueBits = pvfb->redBits = pvfb->greenBits = 8; break; } } if (pvfb->pixelFormatDefined) { VisualPtr vis = pScreen->visuals; for (int i = 0; i < pScreen->numVisuals; i++) { if (pvfb->rgbNotBgr) { vis->offsetBlue = 0; vis->blueMask = (1 << pvfb->blueBits) - 1; vis->offsetGreen = pvfb->blueBits; vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; vis->offsetRed = vis->offsetGreen + pvfb->greenBits; vis->redMask = ((1 << pvfb->redBits) - 1) << vis->offsetRed; } else { vis->offsetRed = 0; vis->redMask = (1 << pvfb->redBits) - 1; vis->offsetGreen = pvfb->redBits; vis->greenMask = ((1 << pvfb->greenBits) - 1) << vis->offsetGreen; vis->offsetBlue = vis->offsetGreen + pvfb->greenBits; vis->blueMask = ((1 << pvfb->blueBits) - 1) << vis->offsetBlue; } vis++; } } ret = fbCreateDefColormap(pScreen); if (!ret) return FALSE; miSetZeroLineBias(pScreen, pvfb->lineBias); pvfb->closeScreen = pScreen->CloseScreen; pScreen->CloseScreen = vfbCloseScreen; #ifdef RANDR ret = RRScreenInit(pScreen); if (!ret) return FALSE; rp = rrGetScrPriv(pScreen); rp->rrGetInfo = vncRandRGetInfo; rp->rrSetConfig = NULL; rp->rrScreenSetSize = vncRandRScreenSetSize; rp->rrCrtcSet = vncRandRCrtcSet; rp->rrOutputValidateMode = vncRandROutputValidateMode; rp->rrModeDestroy = vncRandRModeDestroy; ret = vncRandRInit(pScreen); if (!ret) return FALSE; #endif return TRUE; } /* end vfbScreenInit */
Bool radeon_glamor_init(ScreenPtr screen) { ScrnInfoPtr scrn = xf86ScreenToScrn(screen); RADEONInfoPtr info = RADEONPTR(scrn); #ifdef RENDER #ifdef HAVE_FBGLYPHS UnrealizeGlyphProcPtr SavedUnrealizeGlyph = NULL; #endif PictureScreenPtr ps = NULL; if (info->shadow_primary) { ps = GetPictureScreenIfSet(screen); if (ps) { #ifdef HAVE_FBGLYPHS SavedUnrealizeGlyph = ps->UnrealizeGlyph; #endif info->glamor.SavedGlyphs = ps->Glyphs; info->glamor.SavedTriangles = ps->Triangles; info->glamor.SavedTrapezoids = ps->Trapezoids; } } #endif /* RENDER */ if (!glamor_init(screen, GLAMOR_USE_EGL_SCREEN | GLAMOR_USE_SCREEN | GLAMOR_USE_PICTURE_SCREEN | GLAMOR_INVERTED_Y_AXIS | GLAMOR_NO_DRI3)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to initialize glamor.\n"); return FALSE; } if (!glamor_egl_init_textured_pixmap(screen)) { xf86DrvMsg(scrn->scrnIndex, X_ERROR, "Failed to initialize textured pixmap of screen for glamor.\n"); return FALSE; } #if HAS_DIXREGISTERPRIVATEKEY if (!dixRegisterPrivateKey(&glamor_pixmap_index, PRIVATE_PIXMAP, 0)) #else if (!dixRequestPrivate(&glamor_pixmap_index, 0)) #endif return FALSE; if (info->shadow_primary) radeon_glamor_screen_init(screen); #if defined(RENDER) && defined(HAVE_FBGLYPHS) /* For ShadowPrimary, we need fbUnrealizeGlyph instead of * glamor_unrealize_glyph */ if (ps) ps->UnrealizeGlyph = SavedUnrealizeGlyph; #endif screen->CreatePixmap = radeon_glamor_create_pixmap; screen->DestroyPixmap = radeon_glamor_destroy_pixmap; #ifdef RADEON_PIXMAP_SHARING screen->SharePixmapBacking = radeon_glamor_share_pixmap_backing; screen->SetSharedPixmapBacking = radeon_glamor_set_shared_pixmap_backing; #endif xf86DrvMsg(scrn->scrnIndex, X_INFO, "Use GLAMOR acceleration.\n"); return TRUE; }
Bool winAllocatePrivates (ScreenPtr pScreen) { winPrivScreenPtr pScreenPriv; #if CYGDEBUG winDebug ("winAllocateScreenPrivates - g_ulServerGeneration: %d " "serverGeneration: %d\n", g_ulServerGeneration, serverGeneration); #endif /* We need a new slot for our privates if the screen gen has changed */ if (g_ulServerGeneration != serverGeneration) { g_ulServerGeneration = serverGeneration; } /* Allocate memory for the screen private structure */ pScreenPriv = (winPrivScreenPtr) malloc (sizeof (winPrivScreenRec)); if (!pScreenPriv) { ErrorF ("winAllocateScreenPrivates - malloc () failed\n"); return FALSE; } /* Initialize the memory of the private structure */ ZeroMemory (pScreenPriv, sizeof (winPrivScreenRec)); /* Intialize private structure members */ pScreenPriv->fActive = TRUE; /* Register our screen private */ if (!dixRegisterPrivateKey(g_iScreenPrivateKey, PRIVATE_SCREEN, 0)) { ErrorF ("winAllocatePrivates - AllocateScreenPrivate () failed\n"); return FALSE; } /* Save the screen private pointer */ winSetScreenPriv (pScreen, pScreenPriv); /* Reserve GC memory for our privates */ if (!dixRegisterPrivateKey(g_iGCPrivateKey, PRIVATE_GC, sizeof (winPrivGCRec))) { ErrorF ("winAllocatePrivates - AllocateGCPrivate () failed\n"); return FALSE; } /* Reserve Pixmap memory for our privates */ if (!dixRegisterPrivateKey(g_iPixmapPrivateKey, PRIVATE_PIXMAP, sizeof (winPrivPixmapRec))) { ErrorF ("winAllocatePrivates - AllocatePixmapPrivates () failed\n"); return FALSE; } /* Reserve Window memory for our privates */ if (!dixRegisterPrivateKey(g_iWindowPrivateKey, PRIVATE_WINDOW, sizeof (winPrivWinRec))) { ErrorF ("winAllocatePrivates () - AllocateWindowPrivates () failed\n"); return FALSE; } return TRUE; }
/** Set up glamor for an already-configured GL context. */ Bool glamor_init(ScreenPtr screen, unsigned int flags) { glamor_screen_private *glamor_priv; int gl_version; int max_viewport_size[2]; #ifdef RENDER PictureScreenPtr ps = GetPictureScreenIfSet(screen); #endif if (flags & ~GLAMOR_VALID_FLAGS) { ErrorF("glamor_init: Invalid flags %x\n", flags); return FALSE; } glamor_priv = calloc(1, sizeof(*glamor_priv)); if (glamor_priv == NULL) return FALSE; glamor_priv->flags = flags; if (!dixRegisterPrivateKey(&glamor_screen_private_key, PRIVATE_SCREEN, 0)) { LogMessage(X_WARNING, "glamor%d: Failed to allocate screen private\n", screen->myNum); goto fail; } glamor_set_screen_private(screen, glamor_priv); if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, 0)) { LogMessage(X_WARNING, "glamor%d: Failed to allocate pixmap private\n", screen->myNum); goto fail; } if (!dixRegisterPrivateKey(&glamor_gc_private_key, PRIVATE_GC, sizeof (glamor_gc_private))) { LogMessage(X_WARNING, "glamor%d: Failed to allocate gc private\n", screen->myNum); goto fail; } if (epoxy_is_desktop_gl()) glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP; else glamor_priv->gl_flavor = GLAMOR_GL_ES2; gl_version = epoxy_gl_version(); /* Would be nice to have a cleaner test for GLSL 1.30 support, * but for now this should suffice */ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP && gl_version >= 30) glamor_priv->glsl_version = 130; else glamor_priv->glsl_version = 120; /* We'd like to require GL_ARB_map_buffer_range or * GL_OES_map_buffer_range, since it offers more information to * the driver than plain old glMapBuffer() or glBufferSubData(). * It's been supported on Mesa on the desktop since 2009 and on * GLES2 since October 2012. It's supported on Apple's iOS * drivers for SGX535 and A7, but apparently not on most Android * devices (the OES extension spec wasn't released until June * 2012). * * 82% of 0 A.D. players (desktop GL) submitting hardware reports * have support for it, with most of the ones lacking it being on * Windows with Intel 4-series (G45) graphics or older. */ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { if (gl_version < 21) { ErrorF("Require OpenGL version 2.1 or later.\n"); goto fail; } } else { if (gl_version < 20) { ErrorF("Require Open GLES2.0 or later.\n"); goto fail; } if (!epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) { ErrorF("GL_EXT_texture_format_BGRA8888 required\n"); goto fail; } } glamor_priv->has_rw_pbo = FALSE; if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) glamor_priv->has_rw_pbo = TRUE; glamor_priv->has_khr_debug = epoxy_has_gl_extension("GL_KHR_debug"); glamor_priv->has_pack_invert = epoxy_has_gl_extension("GL_MESA_pack_invert"); glamor_priv->has_fbo_blit = epoxy_has_gl_extension("GL_EXT_framebuffer_blit"); glamor_priv->has_map_buffer_range = epoxy_has_gl_extension("GL_ARB_map_buffer_range"); glamor_priv->has_buffer_storage = epoxy_has_gl_extension("GL_ARB_buffer_storage"); glamor_priv->has_nv_texture_barrier = epoxy_has_gl_extension("GL_NV_texture_barrier"); glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size); glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[0]); glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[1]); #ifdef MAX_FBO_SIZE glamor_priv->max_fbo_size = MAX_FBO_SIZE; #endif glamor_set_debug_level(&glamor_debug_level); /* If we are using egl screen, call egl screen init to * register correct close screen function. */ if (flags & GLAMOR_USE_EGL_SCREEN) { glamor_egl_screen_init(screen, &glamor_priv->ctx); } else { if (!glamor_glx_screen_init(&glamor_priv->ctx)) goto fail; } glamor_priv->saved_procs.close_screen = screen->CloseScreen; screen->CloseScreen = glamor_close_screen; glamor_priv->saved_procs.create_screen_resources = screen->CreateScreenResources; screen->CreateScreenResources = glamor_create_screen_resources; if (!glamor_font_init(screen)) goto fail; if (flags & GLAMOR_USE_SCREEN) { if (!RegisterBlockAndWakeupHandlers(_glamor_block_handler, _glamor_wakeup_handler, glamor_priv)) { goto fail; } glamor_priv->saved_procs.create_gc = screen->CreateGC; screen->CreateGC = glamor_create_gc; glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap; screen->CreatePixmap = glamor_create_pixmap; glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap; screen->DestroyPixmap = glamor_destroy_pixmap; glamor_priv->saved_procs.get_spans = screen->GetSpans; screen->GetSpans = glamor_get_spans; glamor_priv->saved_procs.get_image = screen->GetImage; screen->GetImage = glamor_get_image; glamor_priv->saved_procs.change_window_attributes = screen->ChangeWindowAttributes; screen->ChangeWindowAttributes = glamor_change_window_attributes; glamor_priv->saved_procs.copy_window = screen->CopyWindow; screen->CopyWindow = glamor_copy_window; glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion; screen->BitmapToRegion = glamor_bitmap_to_region; } #ifdef RENDER if (flags & GLAMOR_USE_PICTURE_SCREEN) { glamor_priv->saved_procs.composite = ps->Composite; ps->Composite = glamor_composite; glamor_priv->saved_procs.trapezoids = ps->Trapezoids; ps->Trapezoids = glamor_trapezoids; glamor_priv->saved_procs.triangles = ps->Triangles; ps->Triangles = glamor_triangles; glamor_priv->saved_procs.addtraps = ps->AddTraps; ps->AddTraps = glamor_add_traps; } glamor_priv->saved_procs.composite_rects = ps->CompositeRects; ps->CompositeRects = glamor_composite_rectangles; glamor_priv->saved_procs.glyphs = ps->Glyphs; ps->Glyphs = glamor_glyphs; glamor_priv->saved_procs.unrealize_glyph = ps->UnrealizeGlyph; ps->UnrealizeGlyph = glamor_glyph_unrealize; glamor_priv->saved_procs.create_picture = ps->CreatePicture; ps->CreatePicture = glamor_create_picture; glamor_priv->saved_procs.destroy_picture = ps->DestroyPicture; ps->DestroyPicture = glamor_destroy_picture; glamor_init_composite_shaders(screen); #endif glamor_priv->saved_procs.set_window_pixmap = screen->SetWindowPixmap; screen->SetWindowPixmap = glamor_set_window_pixmap; glamor_init_vbo(screen); glamor_init_pixmap_fbo(screen); #ifdef GLAMOR_TRAPEZOID_SHADER glamor_init_trapezoid_shader(screen); #endif glamor_init_finish_access_shaders(screen); #ifdef GLAMOR_GRADIENT_SHADER glamor_init_gradient_shader(screen); #endif glamor_pixmap_init(screen); glamor_glyphs_init(screen); glamor_sync_init(screen); glamor_priv->screen = screen; return TRUE; fail: free(glamor_priv); glamor_set_screen_private(screen, NULL); return FALSE; }
Bool xf86InitCursor( ScreenPtr pScreen, xf86CursorInfoPtr infoPtr ) { ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; xf86CursorScreenPtr ScreenPriv; miPointerScreenPtr PointPriv; if (!xf86InitHardwareCursor(pScreen, infoPtr)) return FALSE; if (!dixRegisterPrivateKey(&xf86CursorScreenKeyRec, PRIVATE_SCREEN, 0)) return FALSE; ScreenPriv = calloc(1, sizeof(xf86CursorScreenRec)); if (!ScreenPriv) return FALSE; dixSetPrivate(&pScreen->devPrivates, xf86CursorScreenKey, ScreenPriv); ScreenPriv->SWCursor = TRUE; ScreenPriv->isUp = FALSE; ScreenPriv->CurrentCursor = NULL; ScreenPriv->CursorInfoPtr = infoPtr; ScreenPriv->PalettedCursor = FALSE; ScreenPriv->pInstalledMap = NULL; ScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = xf86CursorCloseScreen; ScreenPriv->QueryBestSize = pScreen->QueryBestSize; pScreen->QueryBestSize = xf86CursorQueryBestSize; ScreenPriv->RecolorCursor = pScreen->RecolorCursor; pScreen->RecolorCursor = xf86CursorRecolorCursor; if ((infoPtr->pScrn->bitsPerPixel == 8) && !(infoPtr->Flags & HARDWARE_CURSOR_TRUECOLOR_AT_8BPP)) { ScreenPriv->InstallColormap = pScreen->InstallColormap; pScreen->InstallColormap = xf86CursorInstallColormap; ScreenPriv->PalettedCursor = TRUE; } PointPriv = dixLookupPrivate(&pScreen->devPrivates, miPointerScreenKey); ScreenPriv->showTransparent = PointPriv->showTransparent; if (infoPtr->Flags & HARDWARE_CURSOR_SHOW_TRANSPARENT) PointPriv->showTransparent = TRUE; else PointPriv->showTransparent = FALSE; ScreenPriv->spriteFuncs = PointPriv->spriteFuncs; PointPriv->spriteFuncs = &xf86CursorSpriteFuncs; ScreenPriv->EnableDisableFBAccess = pScrn->EnableDisableFBAccess; ScreenPriv->SwitchMode = pScrn->SwitchMode; ScreenPriv->ForceHWCursorCount = 0; ScreenPriv->HWCursorForced = FALSE; pScrn->EnableDisableFBAccess = xf86CursorEnableDisableFBAccess; if (pScrn->SwitchMode) pScrn->SwitchMode = xf86CursorSwitchMode; return TRUE; }
/** Set up glamor for an already-configured GL context. */ Bool glamor_init(ScreenPtr screen, unsigned int flags) { glamor_screen_private *glamor_priv; int gl_version; int glsl_major, glsl_minor; int max_viewport_size[2]; const char *shading_version_string; int shading_version_offset; PictureScreenPtr ps = GetPictureScreenIfSet(screen); if (flags & ~GLAMOR_VALID_FLAGS) { ErrorF("glamor_init: Invalid flags %x\n", flags); return FALSE; } glamor_priv = calloc(1, sizeof(*glamor_priv)); if (glamor_priv == NULL) return FALSE; glamor_priv->flags = flags; if (!dixRegisterPrivateKey(&glamor_screen_private_key, PRIVATE_SCREEN, 0)) { LogMessage(X_WARNING, "glamor%d: Failed to allocate screen private\n", screen->myNum); goto fail; } glamor_set_screen_private(screen, glamor_priv); if (!dixRegisterPrivateKey(&glamor_pixmap_private_key, PRIVATE_PIXMAP, sizeof(struct glamor_pixmap_private))) { LogMessage(X_WARNING, "glamor%d: Failed to allocate pixmap private\n", screen->myNum); goto fail; } if (!dixRegisterPrivateKey(&glamor_gc_private_key, PRIVATE_GC, sizeof (glamor_gc_private))) { LogMessage(X_WARNING, "glamor%d: Failed to allocate gc private\n", screen->myNum); goto fail; } glamor_priv->saved_procs.close_screen = screen->CloseScreen; screen->CloseScreen = glamor_close_screen; /* If we are using egl screen, call egl screen init to * register correct close screen function. */ if (flags & GLAMOR_USE_EGL_SCREEN) { glamor_egl_screen_init(screen, &glamor_priv->ctx); } else { if (!glamor_glx_screen_init(&glamor_priv->ctx)) goto fail; } glamor_make_current(glamor_priv); if (epoxy_is_desktop_gl()) glamor_priv->gl_flavor = GLAMOR_GL_DESKTOP; else glamor_priv->gl_flavor = GLAMOR_GL_ES2; gl_version = epoxy_gl_version(); shading_version_string = (char *) glGetString(GL_SHADING_LANGUAGE_VERSION); if (!shading_version_string) { LogMessage(X_WARNING, "glamor%d: Failed to get GLSL version\n", screen->myNum); goto fail; } shading_version_offset = 0; if (strncmp("OpenGL ES GLSL ES ", shading_version_string, 18) == 0) shading_version_offset = 18; if (sscanf(shading_version_string + shading_version_offset, "%i.%i", &glsl_major, &glsl_minor) != 2) { LogMessage(X_WARNING, "glamor%d: Failed to parse GLSL version string %s\n", screen->myNum, shading_version_string); goto fail; } glamor_priv->glsl_version = glsl_major * 100 + glsl_minor; if (glamor_priv->gl_flavor == GLAMOR_GL_ES2) { /* Force us back to the base version of our programs on an ES * context, anyway. Basically glamor only uses desktop 1.20 * or 1.30 currently. 1.30's new features are also present in * ES 3.0, but our glamor_program.c constructions use a lot of * compatibility features (to reduce the diff between 1.20 and * 1.30 programs). */ glamor_priv->glsl_version = 120; } /* We'd like to require GL_ARB_map_buffer_range or * GL_OES_map_buffer_range, since it offers more information to * the driver than plain old glMapBuffer() or glBufferSubData(). * It's been supported on Mesa on the desktop since 2009 and on * GLES2 since October 2012. It's supported on Apple's iOS * drivers for SGX535 and A7, but apparently not on most Android * devices (the OES extension spec wasn't released until June * 2012). * * 82% of 0 A.D. players (desktop GL) submitting hardware reports * have support for it, with most of the ones lacking it being on * Windows with Intel 4-series (G45) graphics or older. */ if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) { if (gl_version < 21) { ErrorF("Require OpenGL version 2.1 or later.\n"); goto fail; } if (!glamor_check_instruction_count(gl_version)) goto fail; } else { if (gl_version < 20) { ErrorF("Require Open GLES2.0 or later.\n"); goto fail; } if (!epoxy_has_gl_extension("GL_EXT_texture_format_BGRA8888")) { ErrorF("GL_EXT_texture_format_BGRA8888 required\n"); goto fail; } } glamor_priv->has_rw_pbo = FALSE; if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) glamor_priv->has_rw_pbo = TRUE; glamor_priv->has_khr_debug = epoxy_has_gl_extension("GL_KHR_debug"); glamor_priv->has_pack_invert = epoxy_has_gl_extension("GL_MESA_pack_invert"); glamor_priv->has_fbo_blit = epoxy_has_gl_extension("GL_EXT_framebuffer_blit"); glamor_priv->has_map_buffer_range = epoxy_has_gl_extension("GL_ARB_map_buffer_range") || epoxy_has_gl_extension("GL_EXT_map_buffer_range"); glamor_priv->has_buffer_storage = epoxy_has_gl_extension("GL_ARB_buffer_storage"); glamor_priv->has_nv_texture_barrier = epoxy_has_gl_extension("GL_NV_texture_barrier"); glamor_priv->has_unpack_subimage = glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP || epoxy_gl_version() >= 30 || epoxy_has_gl_extension("GL_EXT_unpack_subimage"); glamor_priv->has_pack_subimage = glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP || epoxy_gl_version() >= 30 || epoxy_has_gl_extension("GL_NV_pack_subimage"); glamor_priv->has_vertex_array_object = epoxy_has_gl_extension("GL_ARB_vertex_array_object"); glamor_priv->has_dual_blend = epoxy_has_gl_extension("GL_ARB_blend_func_extended"); /* assume a core profile if we are GL 3.1 and don't have ARB_compatibility */ glamor_priv->is_core_profile = gl_version >= 31 && !epoxy_has_gl_extension("GL_ARB_compatibility"); glamor_setup_debug_output(screen); glamor_priv->use_quads = (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP) && !glamor_priv->is_core_profile; /* Driver-specific hack: Avoid using GL_QUADS on VC4, where * they'll be emulated more expensively than we can with our * cached IB. */ if (strstr((char *)glGetString(GL_VENDOR), "Broadcom") && strstr((char *)glGetString(GL_RENDERER), "VC4")) glamor_priv->use_quads = FALSE; glGetIntegerv(GL_MAX_RENDERBUFFER_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glamor_priv->max_fbo_size); glGetIntegerv(GL_MAX_VIEWPORT_DIMS, max_viewport_size); glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[0]); glamor_priv->max_fbo_size = MIN(glamor_priv->max_fbo_size, max_viewport_size[1]); #ifdef MAX_FBO_SIZE glamor_priv->max_fbo_size = MAX_FBO_SIZE; #endif glamor_priv->one_channel_format = GL_ALPHA; if (epoxy_has_gl_extension("GL_ARB_texture_rg") && epoxy_has_gl_extension("GL_ARB_texture_swizzle")) glamor_priv->one_channel_format = GL_RED; glamor_set_debug_level(&glamor_debug_level); glamor_priv->saved_procs.create_screen_resources = screen->CreateScreenResources; screen->CreateScreenResources = glamor_create_screen_resources; if (!glamor_font_init(screen)) goto fail; glamor_priv->saved_procs.block_handler = screen->BlockHandler; screen->BlockHandler = _glamor_block_handler; if (!glamor_composite_glyphs_init(screen)) { ErrorF("Failed to initialize composite masks\n"); goto fail; } glamor_priv->saved_procs.create_gc = screen->CreateGC; screen->CreateGC = glamor_create_gc; glamor_priv->saved_procs.create_pixmap = screen->CreatePixmap; screen->CreatePixmap = glamor_create_pixmap; glamor_priv->saved_procs.destroy_pixmap = screen->DestroyPixmap; screen->DestroyPixmap = glamor_destroy_pixmap; glamor_priv->saved_procs.get_spans = screen->GetSpans; screen->GetSpans = glamor_get_spans; glamor_priv->saved_procs.get_image = screen->GetImage; screen->GetImage = glamor_get_image; glamor_priv->saved_procs.change_window_attributes = screen->ChangeWindowAttributes; screen->ChangeWindowAttributes = glamor_change_window_attributes; glamor_priv->saved_procs.copy_window = screen->CopyWindow; screen->CopyWindow = glamor_copy_window; glamor_priv->saved_procs.bitmap_to_region = screen->BitmapToRegion; screen->BitmapToRegion = glamor_bitmap_to_region; glamor_priv->saved_procs.composite = ps->Composite; ps->Composite = glamor_composite; glamor_priv->saved_procs.trapezoids = ps->Trapezoids; ps->Trapezoids = glamor_trapezoids; glamor_priv->saved_procs.triangles = ps->Triangles; ps->Triangles = glamor_triangles; glamor_priv->saved_procs.addtraps = ps->AddTraps; ps->AddTraps = glamor_add_traps; glamor_priv->saved_procs.composite_rects = ps->CompositeRects; ps->CompositeRects = glamor_composite_rectangles; glamor_priv->saved_procs.glyphs = ps->Glyphs; ps->Glyphs = glamor_composite_glyphs; glamor_init_vbo(screen); glamor_init_pixmap_fbo(screen); glamor_init_finish_access_shaders(screen); #ifdef GLAMOR_GRADIENT_SHADER glamor_init_gradient_shader(screen); #endif glamor_pixmap_init(screen); glamor_sync_init(screen); glamor_priv->screen = screen; return TRUE; fail: free(glamor_priv); glamor_set_screen_private(screen, NULL); return FALSE; }
static void dtlogin_process(struct dmuser *user, int user_logged_in) { struct project proj; char proj_buf[PROJECT_BUFSZ]; struct passwd *ppasswd; const char *auth_file = NULL; auth_file = GetAuthFilename(); if (auth_file) { if (chown(auth_file, user->uid, user->gid) < 0) DtloginError("Error in changing owner to %d", user->uid); } /* This gid dance is necessary in order to make sure our "saved-set-gid" is 0 so that we can regain gid 0 when necessary for priocntl & power management. The first step sets rgid to the user's gid and makes the egid & saved-gid be 0. The second then sets the egid to the users gid, but leaves the saved-gid as 0. */ if (user->gid != (gid_t) -1) { DtloginInfo("Setting gid to %d\n", user->gid); if (setregid(user->gid, 0) < 0) DtloginError("Error in setting regid to %d\n", user->gid); if (setegid(user->gid) < 0) DtloginError("Error in setting egid to %d\n", user->gid); } if (user->groupid_cnt >= 0) { if (setgroups(user->groupid_cnt, user->groupids) < 0) DtloginError("Error in setting supplemental (%d) groups", user->groupid_cnt); } /* * BUG: 4462531: Set project ID for Xserver * Get user name and default project. * Set before the uid value is set. */ if (user->projid != (uid_t) -1) { if (settaskid(user->projid, TASK_NORMAL) == (taskid_t) -1) { DtloginError("Error in setting project id to %d", user->projid); } } else if (user->uid != (uid_t) -1) { ppasswd = getpwuid(user->uid); if (ppasswd == NULL) { DtloginError("Error in getting user name for %d", user->uid); } else { if (getdefaultproj(ppasswd->pw_name, &proj, (void *)&proj_buf, PROJECT_BUFSZ) == NULL) { DtloginError("Error in getting project id for %s", ppasswd->pw_name); } else { DtloginInfo("Setting project to %s\n", proj.pj_name); if (setproject(proj.pj_name, ppasswd->pw_name, TASK_NORMAL) == -1) { DtloginError("Error in setting project to %s", proj.pj_name); } } } } if (user->uid != (uid_t) -1) { DtloginInfo("Setting uid to %d\n", user->uid); if (setreuid(user->uid, -1) < 0) DtloginError("Error in setting ruid to %d", user->uid); if (setreuid(-1, user->uid) < 0) DtloginError("Error in setting euid to %d", user->uid); /* Wrap closeScreen to allow resetting uid on closedown */ if ((user->uid != 0) && (user != &originalUser)) { int i; if (dixRegisterPrivateKey(dmScreenKey, PRIVATE_SCREEN, 0)) { for (i = 0; i < screenInfo.numScreens; i++) { ScreenPtr pScreen = screenInfo.screens[i]; struct dmScreenPriv *pScreenPriv = calloc(1, sizeof(struct dmScreenPriv)); dixSetPrivate(&pScreen->devPrivates, dmScreenKey, pScreenPriv); if (pScreenPriv != NULL) { pScreenPriv->CloseScreen = pScreen->CloseScreen; pScreen->CloseScreen = DtloginCloseScreen; } else { DtloginError("Failed to allocate %d bytes" " for uid reset info", sizeof(struct dmScreenPriv)); } } } else { DtloginError("Failed to register screen private %s", "for uid reset info"); } } } if (user->homedir != NULL) { char *env_str = Xprintf("HOME=%s", user->homedir); if (env_str == NULL) { DtloginError("Not enough memory to setenv HOME=%s", user->homedir); } else { DtloginInfo("Setting %s\n",env_str); if (putenv(env_str) < 0) DtloginError("Failed to setenv %s", env_str); } if (chdir(user->homedir) < 0) DtloginError("Error in changing working directory to %s", user->homedir); } /* Inform the kernel whether a user has logged in on this VT device */ if (xf86ConsoleFd != -1) ioctl(xf86ConsoleFd, VT_SETDISPLOGIN, user_logged_in); }
/** * @param pScreen screen being initialized * @param pScreenInfo UXA driver record * * uxa_driver_init sets up UXA given a driver record filled in by the driver. * pScreenInfo should have been allocated by uxa_driver_alloc(). See the * comments in _UxaDriver for what must be filled in and what is optional. * * @return TRUE if UXA was successfully initialized. */ Bool uxa_driver_init(ScreenPtr screen, uxa_driver_t * uxa_driver) { uxa_screen_t *uxa_screen; ScrnInfoPtr scrn = xf86Screens[screen->myNum]; if (!uxa_driver) return FALSE; if (uxa_driver->uxa_major != UXA_VERSION_MAJOR || uxa_driver->uxa_minor > UXA_VERSION_MINOR) { LogMessage(X_ERROR, "UXA(%d): driver's UXA version requirements " "(%d.%d) are incompatible with UXA version (%d.%d)\n", screen->myNum, uxa_driver->uxa_major, uxa_driver->uxa_minor, UXA_VERSION_MAJOR, UXA_VERSION_MINOR); return FALSE; } if (!uxa_driver->prepare_solid) { LogMessage(X_ERROR, "UXA(%d): uxa_driver_t::prepare_solid must be " "non-NULL\n", screen->myNum); return FALSE; } if (!uxa_driver->prepare_copy) { LogMessage(X_ERROR, "UXA(%d): uxa_driver_t::prepare_copy must be " "non-NULL\n", screen->myNum); return FALSE; } #if HAS_DIXREGISTERPRIVATEKEY if (!dixRegisterPrivateKey(&uxa_screen_index, PRIVATE_SCREEN, 0)) return FALSE; #endif uxa_screen = calloc(sizeof(uxa_screen_t), 1); if (!uxa_screen) { LogMessage(X_WARNING, "UXA(%d): Failed to allocate screen private\n", screen->myNum); return FALSE; } uxa_screen->info = uxa_driver; dixSetPrivate(&screen->devPrivates, &uxa_screen_index, uxa_screen); uxa_screen->force_fallback = FALSE; uxa_screen->solid_cache_size = 0; uxa_screen->solid_clear = 0; uxa_screen->solid_black = 0; uxa_screen->solid_white = 0; // exaDDXDriverInit(screen); /* * Replace various fb screen functions */ uxa_screen->SavedCloseScreen = screen->CloseScreen; screen->CloseScreen = uxa_close_screen; uxa_screen->SavedCreateGC = screen->CreateGC; screen->CreateGC = uxa_create_gc; uxa_screen->SavedGetImage = screen->GetImage; screen->GetImage = uxa_get_image; uxa_screen->SavedGetSpans = screen->GetSpans; screen->GetSpans = uxa_check_get_spans; uxa_screen->SavedCopyWindow = screen->CopyWindow; screen->CopyWindow = uxa_copy_window; uxa_screen->SavedChangeWindowAttributes = screen->ChangeWindowAttributes; screen->ChangeWindowAttributes = uxa_change_window_attributes; uxa_screen->SavedBitmapToRegion = screen->BitmapToRegion; screen->BitmapToRegion = uxa_bitmap_to_region; uxa_screen->SavedEnableDisableFBAccess = scrn->EnableDisableFBAccess; scrn->EnableDisableFBAccess = uxa_xorg_enable_disable_fb_access; #ifdef RENDER { PictureScreenPtr ps = GetPictureScreenIfSet(screen); if (ps) { uxa_screen->SavedComposite = ps->Composite; ps->Composite = uxa_composite; uxa_screen->SavedCompositeRects = ps->CompositeRects; ps->CompositeRects = uxa_solid_rects; uxa_screen->SavedGlyphs = ps->Glyphs; ps->Glyphs = uxa_glyphs; uxa_screen->SavedUnrealizeGlyph = ps->UnrealizeGlyph; ps->UnrealizeGlyph = uxa_glyph_unrealize; uxa_screen->SavedTriangles = ps->Triangles; ps->Triangles = uxa_triangles; uxa_screen->SavedTrapezoids = ps->Trapezoids; ps->Trapezoids = uxa_trapezoids; uxa_screen->SavedAddTraps = ps->AddTraps; ps->AddTraps = uxa_check_add_traps; } } #endif LogMessage(X_INFO, "UXA(%d): Driver registered support for the following" " operations:\n", screen->myNum); assert(uxa_driver->prepare_solid != NULL); LogMessage(X_INFO, " solid\n"); assert(uxa_driver->prepare_copy != NULL); LogMessage(X_INFO, " copy\n"); if (uxa_driver->prepare_composite != NULL) { LogMessage(X_INFO, " composite (RENDER acceleration)\n"); } if (uxa_driver->put_image != NULL) { LogMessage(X_INFO, " put_image\n"); } if (uxa_driver->get_image != NULL) { LogMessage(X_INFO, " get_image\n"); } return TRUE; }
void XInputExtensionInit(void) { ExtensionEntry *extEntry; XExtensionVersion thisversion = { XI_Present, SERVER_XI_MAJOR_VERSION, SERVER_XI_MINOR_VERSION, }; if (!dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT, sizeof(XIClientRec))) FatalError("Cannot request private for XI.\n"); if (!AddCallback(&ClientStateCallback, XIClientCallback, 0)) FatalError("Failed to add callback to XI.\n"); extEntry = AddExtension(INAME, IEVENTS, IERRORS, ProcIDispatch, SProcIDispatch, IResetProc, StandardMinorOpcode); if (extEntry) { IReqCode = extEntry->base; IEventBase = extEntry->eventBase; XIVersion = thisversion; MakeDeviceTypeAtoms(); RT_INPUTCLIENT = CreateNewResourceType((DeleteType) InputClientGone, "INPUTCLIENT"); if (!RT_INPUTCLIENT) FatalError("Failed to add resource type for XI.\n"); FixExtensionEvents(extEntry); ReplySwapVector[IReqCode] = (ReplySwapPtr) SReplyIDispatch; EventSwapVector[DeviceValuator] = SEventIDispatch; EventSwapVector[DeviceKeyPress] = SEventIDispatch; EventSwapVector[DeviceKeyRelease] = SEventIDispatch; EventSwapVector[DeviceButtonPress] = SEventIDispatch; EventSwapVector[DeviceButtonRelease] = SEventIDispatch; EventSwapVector[DeviceMotionNotify] = SEventIDispatch; EventSwapVector[DeviceFocusIn] = SEventIDispatch; EventSwapVector[DeviceFocusOut] = SEventIDispatch; EventSwapVector[ProximityIn] = SEventIDispatch; EventSwapVector[ProximityOut] = SEventIDispatch; EventSwapVector[DeviceStateNotify] = SEventIDispatch; EventSwapVector[DeviceKeyStateNotify] = SEventIDispatch; EventSwapVector[DeviceButtonStateNotify] = SEventIDispatch; EventSwapVector[DeviceMappingNotify] = SEventIDispatch; EventSwapVector[ChangeDeviceNotify] = SEventIDispatch; EventSwapVector[DevicePresenceNotify] = SEventIDispatch; GERegisterExtension(IReqCode, XI2EventSwap); memset(&xi_all_devices, 0, sizeof(xi_all_devices)); memset(&xi_all_master_devices, 0, sizeof(xi_all_master_devices)); xi_all_devices.id = XIAllDevices; xi_all_devices.name = "XIAllDevices"; xi_all_master_devices.id = XIAllMasterDevices; xi_all_master_devices.name = "XIAllMasterDevices"; inputInfo.all_devices = &xi_all_devices; inputInfo.all_master_devices = &xi_all_master_devices; XIResetProperties(); } else { FatalError("IExtensionInit: AddExtensions failed\n"); } }
/* * InitOutput -- * Initialize screenInfo for all actually accessible framebuffers. * That includes vt-manager setup, querying all possible devices and * collecting the pixmap formats. */ void InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv) { int i, j, k, scr_index, was_blocked = 0; char **modulelist; pointer *optionlist; Pix24Flags screenpix24, pix24; MessageType pix24From = X_DEFAULT; Bool pix24Fail = FALSE; Bool autoconfig = FALSE; GDevPtr configured_device; xf86Initialising = TRUE; if (serverGeneration == 1) { if ((xf86ServerName = strrchr(argv[0], '/')) != 0) xf86ServerName++; else xf86ServerName = argv[0]; xf86PrintBanner(); xf86PrintMarkers(); if (xf86LogFile) { time_t t; const char *ct; t = time(NULL); ct = ctime(&t); xf86MsgVerb(xf86LogFileFrom, 0, "Log file: \"%s\", Time: %s", xf86LogFile, ct); } /* Read and parse the config file */ if (!xf86DoConfigure && !xf86DoShowOptions) { switch (xf86HandleConfigFile(FALSE)) { case CONFIG_OK: break; case CONFIG_PARSE_ERROR: xf86Msg(X_ERROR, "Error parsing the config file\n"); return; case CONFIG_NOFILE: autoconfig = TRUE; break; } } InstallSignalHandlers(); /* Initialise the loader */ LoaderInit(); /* Tell the loader the default module search path */ LoaderSetPath(xf86ModulePath); if (xf86Info.ignoreABI) { LoaderSetOptions(LDR_OPT_ABI_MISMATCH_NONFATAL); } if (xf86DoShowOptions) DoShowOptions(); /* Do a general bus probe. This will be a PCI probe for x86 platforms */ xf86BusProbe(); if (xf86DoConfigure) DoConfigure(); if (autoconfig) { if (!xf86AutoConfig()) { xf86Msg(X_ERROR, "Auto configuration failed\n"); return; } } #ifdef XF86PM xf86OSPMClose = xf86OSPMOpen(); #endif /* Load all modules specified explicitly in the config file */ if ((modulelist = xf86ModulelistFromConfig(&optionlist))) { xf86LoadModules(modulelist, optionlist); free(modulelist); free(optionlist); } /* Load all driver modules specified in the config file */ /* If there aren't any specified in the config file, autoconfig them */ /* FIXME: Does not handle multiple active screen sections, but I'm not * sure if we really want to handle that case*/ configured_device = xf86ConfigLayout.screens->screen->device; if ((!configured_device) || (!configured_device->driver)) { if (!autoConfigDevice(configured_device)) { xf86Msg(X_ERROR, "Automatic driver configuration failed\n"); return ; } } if ((modulelist = xf86DriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); free(modulelist); } /* Load all input driver modules specified in the config file. */ if ((modulelist = xf86InputDriverlistFromConfig())) { xf86LoadModules(modulelist, NULL); free(modulelist); } /* * It is expected that xf86AddDriver()/xf86AddInputDriver will be * called for each driver as it is loaded. Those functions save the * module pointers for drivers. * XXX Nothing keeps track of them for other modules. */ /* XXX What do we do if not all of these could be loaded? */ /* * At this point, xf86DriverList[] is all filled in with entries for * each of the drivers to try and xf86NumDrivers has the number of * drivers. If there are none, return now. */ if (xf86NumDrivers == 0) { xf86Msg(X_ERROR, "No drivers available.\n"); return; } /* * Call each of the Identify functions and call the driverFunc to check * if HW access is required. The Identify functions print out some * identifying information, and anything else that might be * needed at this early stage. */ for (i = 0; i < xf86NumDrivers; i++) { if (xf86DriverList[i]->Identify != NULL) xf86DriverList[i]->Identify(0); if (!xorgHWAccess || !xorgHWOpenConsole) { xorgHWFlags flags; if(!xf86DriverList[i]->driverFunc || !xf86DriverList[i]->driverFunc(NULL, GET_REQUIRED_HW_INTERFACES, &flags)) flags = HW_IO; if(NEED_IO_ENABLED(flags)) xorgHWAccess = TRUE; if(!(flags & HW_SKIP_CONSOLE)) xorgHWOpenConsole = TRUE; } } if (xorgHWOpenConsole) xf86OpenConsole(); else xf86Info.dontVTSwitch = TRUE; if (xf86BusConfig() == FALSE) return; xf86PostProbe(); /* * Sort the drivers to match the requested ording. Using a slow * bubble sort. */ for (j = 0; j < xf86NumScreens - 1; j++) { for (i = 0; i < xf86NumScreens - j - 1; i++) { if (xf86Screens[i + 1]->confScreen->screennum < xf86Screens[i]->confScreen->screennum) { ScrnInfoPtr tmpScrn = xf86Screens[i + 1]; xf86Screens[i + 1] = xf86Screens[i]; xf86Screens[i] = tmpScrn; } } } /* Fix up the indexes */ for (i = 0; i < xf86NumScreens; i++) { xf86Screens[i]->scrnIndex = i; } /* * Call the driver's PreInit()'s to complete initialisation for the first * generation. */ for (i = 0; i < xf86NumScreens; i++) { xf86VGAarbiterScrnInit(xf86Screens[i]); xf86VGAarbiterLock(xf86Screens[i]); if (xf86Screens[i]->PreInit && xf86Screens[i]->PreInit(xf86Screens[i], 0)) xf86Screens[i]->configured = TRUE; xf86VGAarbiterUnlock(xf86Screens[i]); } for (i = 0; i < xf86NumScreens; i++) if (!xf86Screens[i]->configured) xf86DeleteScreen(i--, 0); /* * If no screens left, return now. */ if (xf86NumScreens == 0) { xf86Msg(X_ERROR, "Screen(s) found, but none have a usable configuration.\n"); return; } for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->name == NULL) { XNFasprintf(&xf86Screens[i]->name, "screen%d", i); xf86MsgVerb(X_WARNING, 0, "Screen driver %d has no name set, using `%s'.\n", i, xf86Screens[i]->name); } } /* Remove (unload) drivers that are not required */ for (i = 0; i < xf86NumDrivers; i++) if (xf86DriverList[i] && xf86DriverList[i]->refCount <= 0) xf86DeleteDriver(i); /* * At this stage we know how many screens there are. */ for (i = 0; i < xf86NumScreens; i++) xf86InitViewport(xf86Screens[i]); /* * Collect all pixmap formats and check for conflicts at the display * level. Should we die here? Or just delete the offending screens? */ screenpix24 = Pix24DontCare; for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->imageByteOrder != xf86Screens[0]->imageByteOrder) FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); if (xf86Screens[i]->bitmapScanlinePad != xf86Screens[0]->bitmapScanlinePad) FatalError("Inconsistent display bitmapScanlinePad. Exiting\n"); if (xf86Screens[i]->bitmapScanlineUnit != xf86Screens[0]->bitmapScanlineUnit) FatalError("Inconsistent display bitmapScanlineUnit. Exiting\n"); if (xf86Screens[i]->bitmapBitOrder != xf86Screens[0]->bitmapBitOrder) FatalError("Inconsistent display bitmapBitOrder. Exiting\n"); /* Determine the depth 24 pixmap format the screens would like */ if (xf86Screens[i]->pixmap24 != Pix24DontCare) { if (screenpix24 == Pix24DontCare) screenpix24 = xf86Screens[i]->pixmap24; else if (screenpix24 != xf86Screens[i]->pixmap24) FatalError("Inconsistent depth 24 pixmap format. Exiting\n"); } } /* check if screenpix24 is consistent with the config/cmdline */ if (xf86Info.pixmap24 != Pix24DontCare) { pix24 = xf86Info.pixmap24; pix24From = xf86Info.pix24From; if (screenpix24 != Pix24DontCare && screenpix24 != xf86Info.pixmap24) pix24Fail = TRUE; } else if (screenpix24 != Pix24DontCare) { pix24 = screenpix24; pix24From = X_PROBED; } else pix24 = Pix24Use32; if (pix24Fail) FatalError("Screen(s) can't use the required depth 24 pixmap format" " (%d). Exiting\n", PIX24TOBPP(pix24)); /* Initialise the depth 24 format */ for (j = 0; j < numFormats && formats[j].depth != 24; j++) ; formats[j].bitsPerPixel = PIX24TOBPP(pix24); /* Collect additional formats */ for (i = 0; i < xf86NumScreens; i++) { for (j = 0; j < xf86Screens[i]->numFormats; j++) { for (k = 0; ; k++) { if (k >= numFormats) { if (k >= MAXFORMATS) FatalError("Too many pixmap formats! Exiting\n"); formats[k] = xf86Screens[i]->formats[j]; numFormats++; break; } if (formats[k].depth == xf86Screens[i]->formats[j].depth) { if ((formats[k].bitsPerPixel == xf86Screens[i]->formats[j].bitsPerPixel) && (formats[k].scanlinePad == xf86Screens[i]->formats[j].scanlinePad)) break; FatalError("Inconsistent pixmap format for depth %d." " Exiting\n", formats[k].depth); } } } } formatsDone = TRUE; if (xf86Info.vtno >= 0 ) { #define VT_ATOM_NAME "XFree86_VT" Atom VTAtom=-1; CARD32 *VT = NULL; int ret; /* This memory needs to stay available until the screen has been initialized, and we can create the property for real. */ if ( (VT = malloc(sizeof(CARD32)))==NULL ) { FatalError("Unable to make VT property - out of memory. Exiting...\n"); } *VT = xf86Info.vtno; VTAtom = MakeAtom(VT_ATOM_NAME, sizeof(VT_ATOM_NAME) - 1, TRUE); for (i = 0, ret = Success; i < xf86NumScreens && ret == Success; i++) { ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, VTAtom, XA_INTEGER, 32, 1, VT ); if (ret != Success) xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, "Failed to register VT property\n"); } } if (SeatId) { Atom SeatAtom; SeatAtom = MakeAtom(SEAT_ATOM_NAME, sizeof(SEAT_ATOM_NAME) - 1, TRUE); for (i = 0; i < xf86NumScreens; i++) { int ret; ret = xf86RegisterRootWindowProperty(xf86Screens[i]->scrnIndex, SeatAtom, XA_STRING, 8, strlen(SeatId)+1, SeatId ); if (ret != Success) { xf86DrvMsg(xf86Screens[i]->scrnIndex, X_WARNING, "Failed to register seat property\n"); } } } /* If a screen uses depth 24, show what the pixmap format is */ for (i = 0; i < xf86NumScreens; i++) { if (xf86Screens[i]->depth == 24) { xf86Msg(pix24From, "Depth 24 pixmap format is %d bpp\n", PIX24TOBPP(pix24)); break; } } } else { /* * serverGeneration != 1; some OSs have to do things here, too. */ if (xorgHWOpenConsole) xf86OpenConsole(); #ifdef XF86PM /* should we reopen it here? We need to deal with an already opened device. We could leave this to the OS layer. For now we simply close it here */ if (xf86OSPMClose) xf86OSPMClose(); if ((xf86OSPMClose = xf86OSPMOpen()) != NULL) xf86MsgVerb(X_INFO, 3, "APM registered successfully\n"); #endif /* Make sure full I/O access is enabled */ if (xorgHWAccess) xf86EnableIO(); } /* * Use the previously collected parts to setup pScreenInfo */ pScreenInfo->imageByteOrder = xf86Screens[0]->imageByteOrder; pScreenInfo->bitmapScanlinePad = xf86Screens[0]->bitmapScanlinePad; pScreenInfo->bitmapScanlineUnit = xf86Screens[0]->bitmapScanlineUnit; pScreenInfo->bitmapBitOrder = xf86Screens[0]->bitmapBitOrder; pScreenInfo->numPixmapFormats = numFormats; for (i = 0; i < numFormats; i++) pScreenInfo->formats[i] = formats[i]; /* Make sure the server's VT is active */ if (serverGeneration != 1) { xf86Resetting = TRUE; /* All screens are in the same state, so just check the first */ if (!xf86Screens[0]->vtSema) { #ifdef HAS_USL_VTS ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ); #endif xf86AccessEnter(); was_blocked = xf86BlockSIGIO(); } } for (i = 0; i < xf86NumScreens; i++) if (!xf86ColormapAllocatePrivates(xf86Screens[i])) FatalError("Cannot register DDX private keys"); if (!dixRegisterPrivateKey(&xf86ScreenKeyRec, PRIVATE_SCREEN, 0) || !dixRegisterPrivateKey(&xf86CreateRootWindowKeyRec, PRIVATE_SCREEN, 0)) FatalError("Cannot register DDX private keys"); for (i = 0; i < xf86NumScreens; i++) { xf86VGAarbiterLock(xf86Screens[i]); /* * Almost everything uses these defaults, and many of those that * don't, will wrap them. */ xf86Screens[i]->EnableDisableFBAccess = xf86EnableDisableFBAccess; #ifdef XFreeXDGA xf86Screens[i]->SetDGAMode = xf86SetDGAMode; #endif xf86Screens[i]->DPMSSet = NULL; xf86Screens[i]->LoadPalette = NULL; xf86Screens[i]->SetOverscan = NULL; xf86Screens[i]->DriverFunc = NULL; xf86Screens[i]->pScreen = NULL; scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv); xf86VGAarbiterUnlock(xf86Screens[i]); if (scr_index == i) { /* * Hook in our ScrnInfoRec, and initialise some other pScreen * fields. */ dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, xf86ScreenKey, xf86Screens[i]); xf86Screens[i]->pScreen = screenInfo.screens[scr_index]; /* The driver should set this, but make sure it is set anyway */ xf86Screens[i]->vtSema = TRUE; } else { /* This shouldn't normally happen */ FatalError("AddScreen/ScreenInit failed for driver %d\n", i); } DebugF("InitOutput - xf86Screens[%d]->pScreen = %p\n", i, xf86Screens[i]->pScreen ); DebugF("xf86Screens[%d]->pScreen->CreateWindow = %p\n", i, xf86Screens[i]->pScreen->CreateWindow ); dixSetPrivate(&screenInfo.screens[scr_index]->devPrivates, xf86CreateRootWindowKey, xf86Screens[i]->pScreen->CreateWindow); xf86Screens[i]->pScreen->CreateWindow = xf86CreateRootWindow; if (PictureGetSubpixelOrder (xf86Screens[i]->pScreen) == SubPixelUnknown) { xf86MonPtr DDC = (xf86MonPtr)(xf86Screens[i]->monitor->DDC); PictureSetSubpixelOrder (xf86Screens[i]->pScreen, DDC ? (DDC->features.input_type ? SubPixelHorizontalRGB : SubPixelNone) : SubPixelUnknown); } #ifdef RANDR if (!xf86Info.disableRandR) xf86RandRInit (screenInfo.screens[scr_index]); xf86Msg(xf86Info.randRFrom, "RandR %s\n", xf86Info.disableRandR ? "disabled" : "enabled"); #endif } xf86VGAarbiterWrapFunctions(); xf86UnblockSIGIO(was_blocked); xf86InitOrigins(); xf86Resetting = FALSE; xf86Initialising = FALSE; RegisterBlockAndWakeupHandlers((BlockHandlerProcPtr)NoopDDA, xf86Wakeup, NULL); }