diff options
author | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2012-03-23 10:05:55 +0100 |
commit | 0f834b91a4768673833ab4917e87d86c237bb1a6 (patch) | |
tree | 363489504ed4b2d360259b8de4c9e392918e5d02 /xorg-server/hw/xfree86/dri | |
parent | fc72edebf875378459368c5383d9023730cbca54 (diff) | |
download | vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.gz vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.tar.bz2 vcxsrv-0f834b91a4768673833ab4917e87d86c237bb1a6.zip |
libX11 xserver fontconfig mesa pixman xkbcomp xkeyboard-config git update
23 Mar 2012
Diffstat (limited to 'xorg-server/hw/xfree86/dri')
-rw-r--r-- | xorg-server/hw/xfree86/dri/dri.c | 2423 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri/dri.h | 295 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri/drimodule.c | 40 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri/dristruct.h | 253 | ||||
-rw-r--r-- | xorg-server/hw/xfree86/dri/xf86dri.c | 473 |
5 files changed, 1715 insertions, 1769 deletions
diff --git a/xorg-server/hw/xfree86/dri/dri.c b/xorg-server/hw/xfree86/dri/dri.c index 1726960ae..9530eb40e 100644 --- a/xorg-server/hw/xfree86/dri/dri.c +++ b/xorg-server/hw/xfree86/dri/dri.c @@ -71,23 +71,25 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static int DRIEntPrivIndex = -1; static DevPrivateKeyRec DRIScreenPrivKeyRec; + #define DRIScreenPrivKey (&DRIScreenPrivKeyRec) static DevPrivateKeyRec DRIWindowPrivKeyRec; + #define DRIWindowPrivKey (&DRIWindowPrivKeyRec) static unsigned long DRIGeneration = 0; static unsigned int DRIDrawableValidationStamp = 0; static RESTYPE DRIDrawablePrivResType; static RESTYPE DRIContextPrivResType; -static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv); +static void DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv); drmServerInfo DRIDRMServerInfo; - /* Wrapper just like xf86DrvMsg, but - without the verbosity level checking. - This will make it easy to turn off some - messages later, based on verbosity - level. */ + /* Wrapper just like xf86DrvMsg, but + without the verbosity level checking. + This will make it easy to turn off some + messages later, based on verbosity + level. */ /* * Since we're already referencing things from the XFree86 common layer in @@ -99,27 +101,26 @@ drmServerInfo DRIDRMServerInfo; static void DRIDrvMsg(int scrnIndex, MessageType type, const char *format, ...) { - va_list ap; + va_list ap; va_start(ap, format); xf86VDrvMsgVerb(scrnIndex, type, DRI_MSG_VERBOSITY, format, ap); va_end(ap); } - static void DRIOpenDRMCleanup(DRIEntPrivPtr pDRIEntPriv) { if (pDRIEntPriv->pLSAREA != NULL) { - drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize); - pDRIEntPriv->pLSAREA = NULL; + drmUnmap(pDRIEntPriv->pLSAREA, pDRIEntPriv->sAreaSize); + pDRIEntPriv->pLSAREA = NULL; } if (pDRIEntPriv->hLSAREA != 0) { - drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA); + drmRmMap(pDRIEntPriv->drmFD, pDRIEntPriv->hLSAREA); } if (pDRIEntPriv->drmFD >= 0) { - drmClose(pDRIEntPriv->drmFD); - pDRIEntPriv->drmFD = 0; + drmClose(pDRIEntPriv->drmFD); + pDRIEntPriv->drmFD = 0; } } @@ -141,12 +142,10 @@ DRIMasterSareaHandle(ScrnInfoPtr pScrn) return DRI_ENT_PRIV(pScrn)->hLSAREA; } - Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, - unsigned long sAreaSize, - const char *busID, - const char *drmDriverName) + unsigned long sAreaSize, + const char *busID, const char *drmDriverName) { drmSetVersion saveSv, sv; Bool drmWasAvailable; @@ -159,12 +158,12 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn, int err; if (DRIEntPrivIndex == -1) - DRIEntPrivIndex = xf86AllocateEntityPrivateIndex(); + DRIEntPrivIndex = xf86AllocateEntityPrivateIndex(); pDRIEntPriv = DRI_ENT_PRIV(pScrn); if (pDRIEntPriv && pDRIEntPriv->drmFD != -1) - return TRUE; + return TRUE; drmWasAvailable = drmAvailable(); @@ -178,12 +177,12 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn, drmlibmajor = 1; drmlibminor = 0; if (xf86LoaderCheckSymbol("drmGetLibVersion")) { - drmlibv = drmGetLibVersion(-1); - if (drmlibv != NULL) { - drmlibmajor = drmlibv->version_major; - drmlibminor = drmlibv->version_minor; - drmFreeVersion(drmlibv); - } + drmlibv = drmGetLibVersion(-1); + if (drmlibv != NULL) { + drmlibmajor = drmlibv->version_major; + drmlibminor = drmlibv->version_minor; + drmFreeVersion(drmlibv); + } } /* Check if the libdrm can handle falling back to loading based on name @@ -199,69 +198,69 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn, saveSv = sv; count = 10; while (count--) { - tmp.drmFD = drmOpen(drmDriverName, openBusID); + tmp.drmFD = drmOpen(drmDriverName, openBusID); - if (tmp.drmFD < 0) { - DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n"); - goto out_err; - } + if (tmp.drmFD < 0) { + DRIDrvMsg(-1, X_ERROR, "[drm] drmOpen failed.\n"); + goto out_err; + } - err = drmSetInterfaceVersion(tmp.drmFD, &sv); + err = drmSetInterfaceVersion(tmp.drmFD, &sv); - if (err != -EPERM) - break; + if (err != -EPERM) + break; - sv = saveSv; - drmClose(tmp.drmFD); - tmp.drmFD = -1; - usleep(100000); + sv = saveSv; + drmClose(tmp.drmFD); + tmp.drmFD = -1; + usleep(100000); } if (tmp.drmFD <= 0) { - DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n"); - goto out_err; + DRIDrvMsg(-1, X_ERROR, "[drm] DRM was busy with another master.\n"); + goto out_err; } if (!drmWasAvailable) { - DRIDrvMsg(-1, X_INFO, - "[drm] loaded kernel module for \"%s\" driver.\n", - drmDriverName); + DRIDrvMsg(-1, X_INFO, + "[drm] loaded kernel module for \"%s\" driver.\n", + drmDriverName); } if (err != 0) { - sv.drm_di_major = 1; - sv.drm_di_minor = 0; + sv.drm_di_major = 1; + sv.drm_di_minor = 0; } DRIDrvMsg(-1, X_INFO, "[drm] DRM interface version %d.%d\n", - sv.drm_di_major, sv.drm_di_minor); + sv.drm_di_major, sv.drm_di_minor); if (sv.drm_di_major == 1 && sv.drm_di_minor >= 1) - err = 0; + err = 0; else - err = drmSetBusid(tmp.drmFD, busID); + err = drmSetBusid(tmp.drmFD, busID); if (err) { - DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n"); - goto out_err; + DRIDrvMsg(-1, X_ERROR, "[drm] Could not set DRM device bus ID.\n"); + goto out_err; } /* * Create a lock-containing sarea. */ - if (drmAddMap( tmp.drmFD, 0, sAreaSize, DRM_SHM, - DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) { + if (drmAddMap(tmp.drmFD, 0, sAreaSize, DRM_SHM, + DRM_CONTAINS_LOCK, &tmp.hLSAREA) < 0) { DRIDrvMsg(-1, X_INFO, "[drm] Could not create SAREA for DRM lock.\n"); - tmp.hLSAREA = 0; - goto out_err; + tmp.hLSAREA = 0; + goto out_err; } - if (drmMap( tmp.drmFD, tmp.hLSAREA, sAreaSize, - (drmAddressPtr)(&tmp.pLSAREA)) < 0) { + if (drmMap(tmp.drmFD, tmp.hLSAREA, sAreaSize, + (drmAddressPtr) (&tmp.pLSAREA)) < 0) { DRIDrvMsg(-1, X_INFO, "[drm] Mapping SAREA for DRM lock failed.\n"); - tmp.pLSAREA = NULL; - goto out_err; + tmp.pLSAREA = NULL; + goto out_err; } memset(tmp.pLSAREA, 0, sAreaSize); @@ -273,62 +272,64 @@ DRIOpenDRMMaster(ScrnInfoPtr pScrn, tmp.resOwner = NULL; if (!pDRIEntPriv) - pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1); + pDRIEntPriv = xnfcalloc(sizeof(*pDRIEntPriv), 1); if (!pDRIEntPriv) { DRIDrvMsg(-1, X_INFO, "[drm] Failed to allocate memory for " - "DRM device.\n"); - goto out_err; + "DRM device.\n"); + goto out_err; } *pDRIEntPriv = tmp; - xf86GetEntityPrivate((pScrn)->entityList[0],DRIEntPrivIndex)->ptr = - pDRIEntPriv; + xf86GetEntityPrivate((pScrn)->entityList[0], DRIEntPrivIndex)->ptr = + pDRIEntPriv; DRIDrvMsg(-1, X_INFO, "[drm] DRM open master succeeded.\n"); return TRUE; - out_err: + out_err: DRIOpenDRMCleanup(&tmp); return FALSE; } static void -DRIClipNotifyAllDrawables(ScreenPtr pScreen); + DRIClipNotifyAllDrawables(ScreenPtr pScreen); static void dri_crtc_notify(ScreenPtr pScreen) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIClipNotifyAllDrawables(pScreen); xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify); xf86_crtc_notify(pScreen); - pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, dri_crtc_notify); + pDRIPriv->xf86_crtc_notify = + xf86_wrap_crtc_notify(pScreen, dri_crtc_notify); } Bool DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) { - DRIScreenPrivPtr pDRIPriv; - drm_context_t * reserved; - int reserved_count; - int i; - DRIEntPrivPtr pDRIEntPriv; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - DRIContextFlags flags = 0; - DRIContextPrivPtr pDRIContextPriv; + DRIScreenPrivPtr pDRIPriv; + drm_context_t *reserved; + int reserved_count; + int i; + DRIEntPrivPtr pDRIEntPriv; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DRIContextFlags flags = 0; + DRIContextPrivPtr pDRIContextPriv; /* If the DRI extension is disabled, do not initialize the DRI */ if (noXFree86DRIExtension) { - DRIDrvMsg(pScreen->myNum, X_WARNING, - "Direct rendering has been disabled.\n"); - return FALSE; + DRIDrvMsg(pScreen->myNum, X_WARNING, + "Direct rendering has been disabled.\n"); + return FALSE; } if (!xf86VGAarbiterAllowDRI(pScreen)) { DRIDrvMsg(pScreen->myNum, X_WARNING, "Direct rendering is not supported when VGA arb is necessary for the device\n"); - return FALSE; + return FALSE; } #ifdef PANORAMIX @@ -336,31 +337,30 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) * If Xinerama is on, don't allow DRI to initialise. It won't be usable * anyway. */ - if (!noPanoramiXExtension) { - DRIDrvMsg(pScreen->myNum, X_WARNING, - "Direct rendering is not supported when Xinerama is enabled\n"); - return FALSE; - } + if (!noPanoramiXExtension) { + DRIDrvMsg(pScreen->myNum, X_WARNING, + "Direct rendering is not supported when Xinerama is enabled\n"); + return FALSE; + } #endif if (!DRIOpenDRMMaster(pScrn, pDRIInfo->SAREASize, - pDRIInfo->busIdString, - pDRIInfo->drmDriverName)) - return FALSE; + pDRIInfo->busIdString, pDRIInfo->drmDriverName)) + return FALSE; pDRIEntPriv = DRI_ENT_PRIV(pScrn); if (DRIGeneration != serverGeneration) - DRIGeneration = serverGeneration; + DRIGeneration = serverGeneration; if (!dixRegisterPrivateKey(&DRIScreenPrivKeyRec, PRIVATE_SCREEN, 0)) - return FALSE; + return FALSE; if (!dixRegisterPrivateKey(&DRIWindowPrivKeyRec, PRIVATE_WINDOW, 0)) - return FALSE; + return FALSE; pDRIPriv = (DRIScreenPrivPtr) calloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); return FALSE; } @@ -372,7 +372,7 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->nrWindowsVisible = 0; pDRIPriv->fullscreen = NULL; - pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx; + pDRIPriv->createDummyCtx = pDRIInfo->createDummyCtx; pDRIPriv->createDummyCtxPriv = pDRIInfo->createDummyCtxPriv; pDRIPriv->grabbedDRILock = FALSE; @@ -381,141 +381,132 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) if (pDRIEntPriv->sAreaGrabbed || pDRIInfo->allocSarea) { - if (drmAddMap( pDRIPriv->drmFD, - 0, - pDRIPriv->pDriverInfo->SAREASize, - DRM_SHM, - 0, - &pDRIPriv->hSAREA) < 0) - { - pDRIPriv->directRenderingSupport = FALSE; - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); - drmClose(pDRIPriv->drmFD); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] drmAddMap failed\n"); - return FALSE; - } - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] added %d byte SAREA at %p\n", - pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA); - - /* Backwards compat. */ - if (drmMap( pDRIPriv->drmFD, - pDRIPriv->hSAREA, - pDRIPriv->pDriverInfo->SAREASize, - (drmAddressPtr)(&pDRIPriv->pSAREA)) < 0) - { - pDRIPriv->directRenderingSupport = FALSE; - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); - drmClose(pDRIPriv->drmFD); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] drmMap failed\n"); - return FALSE; - } - DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n", - pDRIPriv->hSAREA, pDRIPriv->pSAREA); - memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize); - } else { - DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock " - "SAREA also for drawables.\n"); - pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA; - pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA; - pDRIEntPriv->sAreaGrabbed = TRUE; + if (drmAddMap(pDRIPriv->drmFD, + 0, + pDRIPriv->pDriverInfo->SAREASize, + DRM_SHM, 0, &pDRIPriv->hSAREA) < 0) { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] added %d byte SAREA at %p\n", + pDRIPriv->pDriverInfo->SAREASize, pDRIPriv->hSAREA); + + /* Backwards compat. */ + if (drmMap(pDRIPriv->drmFD, + pDRIPriv->hSAREA, + pDRIPriv->pDriverInfo->SAREASize, + (drmAddressPtr) (&pDRIPriv->pSAREA)) < 0) { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] mapped SAREA %p to %p\n", + pDRIPriv->hSAREA, pDRIPriv->pSAREA); + memset(pDRIPriv->pSAREA, 0, pDRIPriv->pDriverInfo->SAREASize); + } + else { + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Using the DRM lock " + "SAREA also for drawables.\n"); + pDRIPriv->hSAREA = pDRIEntPriv->hLSAREA; + pDRIPriv->pSAREA = (XF86DRISAREAPtr) pDRIEntPriv->pLSAREA; + pDRIEntPriv->sAreaGrabbed = TRUE; } pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA; pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA; - if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) - { - if (drmAddMap( pDRIPriv->drmFD, - (uintptr_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, - pDRIPriv->pDriverInfo->frameBufferSize, - DRM_FRAME_BUFFER, - 0, - &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) - { - pDRIPriv->directRenderingSupport = FALSE; - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); - drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); - drmClose(pDRIPriv->drmFD); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] drmAddMap failed\n"); - return FALSE; - } - DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n", - pDRIPriv->pDriverInfo->hFrameBuffer); - } else { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] framebuffer mapped by ddx driver\n"); + if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) { + if (drmAddMap(pDRIPriv->drmFD, + (uintptr_t) pDRIPriv->pDriverInfo-> + frameBufferPhysicalAddress, + pDRIPriv->pDriverInfo->frameBufferSize, DRM_FRAME_BUFFER, + 0, &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) { + pDRIPriv->directRenderingSupport = FALSE; + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); + drmClose(pDRIPriv->drmFD); + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] drmAddMap failed\n"); + return FALSE; + } + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n", + pDRIPriv->pDriverInfo->hFrameBuffer); + } + else { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] framebuffer mapped by ddx driver\n"); } if (pDRIEntPriv->resOwner == NULL) { - pDRIEntPriv->resOwner = pScreen; - - /* Add tags for reserved contexts */ - if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, - &reserved_count))) { - int i; - void *tag; - - for (i = 0; i < reserved_count; i++) { - tag = DRICreateContextPrivFromHandle(pScreen, - reserved[i], - DRI_CONTEXT_RESERVED); - drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag); - } - drmFreeReservedContextList(reserved); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] added %d reserved context%s for kernel\n", - reserved_count, reserved_count > 1 ? "s" : ""); - } + pDRIEntPriv->resOwner = pScreen; + + /* Add tags for reserved contexts */ + if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, + &reserved_count))) { + int i; + void *tag; + + for (i = 0; i < reserved_count; i++) { + tag = DRICreateContextPrivFromHandle(pScreen, + reserved[i], + DRI_CONTEXT_RESERVED); + drmAddContextTag(pDRIPriv->drmFD, reserved[i], tag); + } + drmFreeReservedContextList(reserved); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] added %d reserved context%s for kernel\n", + reserved_count, reserved_count > 1 ? "s" : ""); + } } /* validate max drawable table entry set by driver */ if ((pDRIPriv->pDriverInfo->maxDrawableTableEntry <= 0) || (pDRIPriv->pDriverInfo->maxDrawableTableEntry > SAREA_MAX_DRAWABLES)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "Invalid max drawable table size set by driver: %d\n", - pDRIPriv->pDriverInfo->maxDrawableTableEntry); + DRIDrvMsg(pScreen->myNum, X_ERROR, + "Invalid max drawable table size set by driver: %d\n", + pDRIPriv->pDriverInfo->maxDrawableTableEntry); } /* Initialize drawable tables (screen private and SAREA) */ - for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { - pDRIPriv->DRIDrawables[i] = NULL; - pDRIPriv->pSAREA->drawableTable[i].stamp = 0; - pDRIPriv->pSAREA->drawableTable[i].flags = 0; + for (i = 0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { + pDRIPriv->DRIDrawables[i] = NULL; + pDRIPriv->pSAREA->drawableTable[i].stamp = 0; + pDRIPriv->pSAREA->drawableTable[i].flags = 0; } pDRIPriv->pLockRefCount = &pDRIEntPriv->lockRefCount; pDRIPriv->pLockingContext = &pDRIEntPriv->lockingContext; if (!pDRIEntPriv->keepFDOpen) - pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen; + pDRIEntPriv->keepFDOpen = pDRIInfo->keepFDOpen; pDRIEntPriv->refCount++; /* Set up flags for DRICreateContextPriv */ switch (pDRIInfo->driverSwapMethod) { case DRI_KERNEL_SWAP: - flags = DRI_CONTEXT_2DONLY; - break; + flags = DRI_CONTEXT_2DONLY; + break; case DRI_HIDE_X_CONTEXT: - flags = DRI_CONTEXT_PRESERVED; - break; + flags = DRI_CONTEXT_PRESERVED; + break; } if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, - &pDRIPriv->myContext, - flags))) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "failed to create server context\n"); - return FALSE; + &pDRIPriv->myContext, + flags))) { + DRIDrvMsg(pScreen->myNum, X_ERROR, "failed to create server context\n"); + return FALSE; } pDRIPriv->myContextPriv = pDRIContextPriv; DRIDrvMsg(pScreen->myNum, X_INFO, - "X context handle = %p\n", pDRIPriv->myContext); + "X context handle = %p\n", pDRIPriv->myContext); /* Now that we have created the X server's context, we can grab the * hardware lock for the X server. @@ -524,67 +515,66 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->grabbedDRILock = TRUE; /* pointers so that we can prevent memory leaks later */ - pDRIPriv->hiddenContextStore = NULL; + pDRIPriv->hiddenContextStore = NULL; pDRIPriv->partial3DContextStore = NULL; - switch(pDRIInfo->driverSwapMethod) { + switch (pDRIInfo->driverSwapMethod) { case DRI_HIDE_X_CONTEXT: - /* Server will handle 3D swaps, and hide 2D swaps from kernel. - * Register server context as a preserved context. - */ - - /* allocate memory for hidden context store */ - pDRIPriv->hiddenContextStore - = (void *)calloc(1, pDRIInfo->contextSize); - if (!pDRIPriv->hiddenContextStore) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "failed to allocate hidden context\n"); - DRIDestroyContextPriv(pDRIContextPriv); - return FALSE; - } - - /* allocate memory for partial 3D context store */ - pDRIPriv->partial3DContextStore - = (void *)calloc(1, pDRIInfo->contextSize); - if (!pDRIPriv->partial3DContextStore) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[DRI] failed to allocate partial 3D context\n"); - free(pDRIPriv->hiddenContextStore); - DRIDestroyContextPriv(pDRIContextPriv); - return FALSE; - } - - /* save initial context store */ - if (pDRIInfo->SwapContext) { - (*pDRIInfo->SwapContext)( - pScreen, - DRI_NO_SYNC, - DRI_2D_CONTEXT, - pDRIPriv->hiddenContextStore, - DRI_NO_CONTEXT, - NULL); - } - /* fall through */ + /* Server will handle 3D swaps, and hide 2D swaps from kernel. + * Register server context as a preserved context. + */ + + /* allocate memory for hidden context store */ + pDRIPriv->hiddenContextStore + = (void *) calloc(1, pDRIInfo->contextSize); + if (!pDRIPriv->hiddenContextStore) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "failed to allocate hidden context\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + + /* allocate memory for partial 3D context store */ + pDRIPriv->partial3DContextStore + = (void *) calloc(1, pDRIInfo->contextSize); + if (!pDRIPriv->partial3DContextStore) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] failed to allocate partial 3D context\n"); + free(pDRIPriv->hiddenContextStore); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + + /* save initial context store */ + if (pDRIInfo->SwapContext) { + (*pDRIInfo->SwapContext) (pScreen, + DRI_NO_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore, + DRI_NO_CONTEXT, NULL); + } + /* fall through */ case DRI_SERVER_SWAP: /* For swap methods of DRI_SERVER_SWAP and DRI_HIDE_X_CONTEXT * setup signal handler for receiving swap requests from kernel - */ - if (!(pDRIPriv->drmSIGIOHandlerInstalled = - drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[drm] failed to setup DRM signal handler\n"); - free(pDRIPriv->hiddenContextStore); - free(pDRIPriv->partial3DContextStore); - DRIDestroyContextPriv(pDRIContextPriv); - return FALSE; - } else { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] installed DRM signal handler\n"); - } + */ + if (!(pDRIPriv->drmSIGIOHandlerInstalled = + drmInstallSIGIOHandler(pDRIPriv->drmFD, DRISwapContext))) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to setup DRM signal handler\n"); + free(pDRIPriv->hiddenContextStore); + free(pDRIPriv->partial3DContextStore); + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } + else { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] installed DRM signal handler\n"); + } default: - break; + break; } return TRUE; @@ -593,41 +583,42 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) Bool DRIFinishScreenInit(ScreenPtr pScreen) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; /* Wrap DRI support */ if (pDRIInfo->wrap.ValidateTree) { - pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; - pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree; + pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; + pScreen->ValidateTree = pDRIInfo->wrap.ValidateTree; } if (pDRIInfo->wrap.PostValidateTree) { - pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; - pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree; + pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = pDRIInfo->wrap.PostValidateTree; } if (pDRIInfo->wrap.WindowExposures) { - pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; - pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures; + pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; + pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures; } - pDRIPriv->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = DRIDestroyWindow; + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; pDRIPriv->xf86_crtc_notify = xf86_wrap_crtc_notify(pScreen, - dri_crtc_notify); - + dri_crtc_notify); + if (pDRIInfo->wrap.CopyWindow) { - pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; - pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow; + pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow; } if (pDRIInfo->wrap.ClipNotify) { - pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; - pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify; + pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; + pScreen->ClipNotify = pDRIInfo->wrap.ClipNotify; } if (pDRIInfo->wrap.AdjustFrame) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; - pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; + pScrn->AdjustFrame = pDRIInfo->wrap.AdjustFrame; } pDRIPriv->wrapped = TRUE; @@ -640,161 +631,161 @@ void DRICloseScreen(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIInfoPtr pDRIInfo; - drm_context_t * reserved; - int reserved_count; - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn); + DRIInfoPtr pDRIInfo; + drm_context_t *reserved; + int reserved_count; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn); Bool closeMaster; if (pDRIPriv) { pDRIInfo = pDRIPriv->pDriverInfo; - if (pDRIPriv->wrapped) { - /* Unwrap DRI Functions */ - if (pDRIInfo->wrap.ValidateTree) { - pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; - pDRIPriv->wrap.ValidateTree = NULL; - } - if (pDRIInfo->wrap.PostValidateTree) { - pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; - pDRIPriv->wrap.PostValidateTree = NULL; - } - if (pDRIInfo->wrap.WindowExposures) { - pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; - pDRIPriv->wrap.WindowExposures = NULL; - } - if (pDRIPriv->DestroyWindow) { - pScreen->DestroyWindow = pDRIPriv->DestroyWindow; - pDRIPriv->DestroyWindow = NULL; - } - - xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify); - - if (pDRIInfo->wrap.CopyWindow) { - pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; - pDRIPriv->wrap.CopyWindow = NULL; - } - if (pDRIInfo->wrap.ClipNotify) { - pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; - pDRIPriv->wrap.ClipNotify = NULL; - } - if (pDRIInfo->wrap.AdjustFrame) { - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; - pDRIPriv->wrap.AdjustFrame = NULL; - } - - pDRIPriv->wrapped = FALSE; - } - - if (pDRIPriv->drmSIGIOHandlerInstalled) { - if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[drm] failed to remove DRM signal handler\n"); - } - } + if (pDRIPriv->wrapped) { + /* Unwrap DRI Functions */ + if (pDRIInfo->wrap.ValidateTree) { + pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; + pDRIPriv->wrap.ValidateTree = NULL; + } + if (pDRIInfo->wrap.PostValidateTree) { + pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; + pDRIPriv->wrap.PostValidateTree = NULL; + } + if (pDRIInfo->wrap.WindowExposures) { + pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; + pDRIPriv->wrap.WindowExposures = NULL; + } + if (pDRIPriv->DestroyWindow) { + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + pDRIPriv->DestroyWindow = NULL; + } + + xf86_unwrap_crtc_notify(pScreen, pDRIPriv->xf86_crtc_notify); + + if (pDRIInfo->wrap.CopyWindow) { + pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; + pDRIPriv->wrap.CopyWindow = NULL; + } + if (pDRIInfo->wrap.ClipNotify) { + pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; + pDRIPriv->wrap.ClipNotify = NULL; + } + if (pDRIInfo->wrap.AdjustFrame) { + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + + pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; + pDRIPriv->wrap.AdjustFrame = NULL; + } + + pDRIPriv->wrapped = FALSE; + } + + if (pDRIPriv->drmSIGIOHandlerInstalled) { + if (!drmRemoveSIGIOHandler(pDRIPriv->drmFD)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to remove DRM signal handler\n"); + } + } if (pDRIPriv->dummyCtxPriv && pDRIPriv->createDummyCtx) { - DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv); - } - - if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "failed to destroy server context\n"); - } - - /* Remove tags for reserved contexts */ - if (pDRIEntPriv->resOwner == pScreen) { - pDRIEntPriv->resOwner = NULL; - - if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, - &reserved_count))) { - int i; - - for (i = 0; i < reserved_count; i++) { - DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD, - reserved[i])); - } - drmFreeReservedContextList(reserved); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] removed %d reserved context%s for kernel\n", - reserved_count, reserved_count > 1 ? "s" : ""); - } - } - - /* Make sure signals get unblocked etc. */ - drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext); - pDRIPriv->pLockRefCount = NULL; - closeMaster = (--pDRIEntPriv->refCount == 0) && - !pDRIEntPriv->keepFDOpen; - if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] unmapping %d bytes of SAREA %p at %p\n", - pDRIInfo->SAREASize, - pDRIPriv->hSAREA, - pDRIPriv->pSAREA); - if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[drm] unable to unmap %d bytes" - " of SAREA %p at %p\n", - pDRIInfo->SAREASize, - pDRIPriv->hSAREA, - pDRIPriv->pSAREA); - } - } else { - pDRIEntPriv->sAreaGrabbed = FALSE; - } - - if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) { - drmClose(pDRIPriv->drmFD); - if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] Closed DRM master.\n"); - pDRIEntPriv->drmFD = -1; - } - } - - free(pDRIPriv); - dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); + DRIDestroyDummyContext(pScreen, pDRIPriv->createDummyCtxPriv); + } + + if (!DRIDestroyContextPriv(pDRIPriv->myContextPriv)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "failed to destroy server context\n"); + } + + /* Remove tags for reserved contexts */ + if (pDRIEntPriv->resOwner == pScreen) { + pDRIEntPriv->resOwner = NULL; + + if ((reserved = drmGetReservedContextList(pDRIPriv->drmFD, + &reserved_count))) { + int i; + + for (i = 0; i < reserved_count; i++) { + DRIDestroyContextPriv(drmGetContextTag(pDRIPriv->drmFD, + reserved[i])); + } + drmFreeReservedContextList(reserved); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] removed %d reserved context%s for kernel\n", + reserved_count, reserved_count > 1 ? "s" : ""); + } + } + + /* Make sure signals get unblocked etc. */ + drmUnlock(pDRIPriv->drmFD, pDRIPriv->myContext); + pDRIPriv->pLockRefCount = NULL; + closeMaster = (--pDRIEntPriv->refCount == 0) && + !pDRIEntPriv->keepFDOpen; + if (closeMaster || pDRIPriv->hSAREA != pDRIEntPriv->hLSAREA) { + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] unmapping %d bytes of SAREA %p at %p\n", + pDRIInfo->SAREASize, pDRIPriv->hSAREA, pDRIPriv->pSAREA); + if (drmUnmap(pDRIPriv->pSAREA, pDRIInfo->SAREASize)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] unable to unmap %d bytes" + " of SAREA %p at %p\n", + pDRIInfo->SAREASize, + pDRIPriv->hSAREA, pDRIPriv->pSAREA); + } + } + else { + pDRIEntPriv->sAreaGrabbed = FALSE; + } + + if (closeMaster || (pDRIEntPriv->drmFD != pDRIPriv->drmFD)) { + drmClose(pDRIPriv->drmFD); + if (pDRIEntPriv->drmFD == pDRIPriv->drmFD) { + DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] Closed DRM master.\n"); + pDRIEntPriv->drmFD = -1; + } + } + + free(pDRIPriv); + dixSetPrivate(&pScreen->devPrivates, DRIScreenPrivKey, NULL); } } #define DRM_MSG_VERBOSITY 3 -static int dri_drm_debug_print(const char *format, va_list ap) +static int +dri_drm_debug_print(const char *format, va_list ap) { - xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap); - return 0; + xf86VDrvMsgVerb(-1, X_NONE, DRM_MSG_VERBOSITY, format, ap); + return 0; } -static void dri_drm_get_perms(gid_t *group, mode_t *mode) +static void +dri_drm_get_perms(gid_t * group, mode_t * mode) { - *group = xf86ConfigDRI.group; - *mode = xf86ConfigDRI.mode; + *group = xf86ConfigDRI.group; + *mode = xf86ConfigDRI.mode; } -drmServerInfo DRIDRMServerInfo = { - dri_drm_debug_print, - xf86LoadKernelModule, - dri_drm_get_perms, +drmServerInfo DRIDRMServerInfo = { + dri_drm_debug_print, + xf86LoadKernelModule, + dri_drm_get_perms, }; Bool DRIExtensionInit(void) { if (DRIGeneration != serverGeneration) { - return FALSE; + return FALSE; } DRIDrawablePrivResType = CreateNewResourceType(DRIDrawablePrivDelete, - "DRIDrawable"); + "DRIDrawable"); DRIContextPrivResType = CreateNewResourceType(DRIContextPrivDelete, - "DRIContext"); + "DRIContext"); if (!DRIDrawablePrivResType || !DRIContextPrivResType) - return FALSE; + return FALSE; RegisterBlockAndWakeupHandlers(DRIBlockHandler, DRIWakeupHandler, NULL); @@ -814,14 +805,14 @@ DRIReset(void) } Bool -DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool* isCapable) +DRIQueryDirectRenderingCapable(ScreenPtr pScreen, Bool *isCapable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv) - *isCapable = pDRIPriv->directRenderingSupport; + *isCapable = pDRIPriv->directRenderingSupport; else - *isCapable = FALSE; + *isCapable = FALSE; return TRUE; } @@ -831,8 +822,8 @@ DRIOpenConnection(ScreenPtr pScreen, drm_handle_t * hSAREA, char **busIdString) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - *hSAREA = pDRIPriv->hSAREA; - *busIdString = pDRIPriv->pDriverInfo->busIdString; + *hSAREA = pDRIPriv->hSAREA; + *busIdString = pDRIPriv->pDriverInfo->busIdString; return TRUE; } @@ -842,7 +833,8 @@ DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (drmAuthMagic(pDRIPriv->drmFD, magic)) return FALSE; + if (drmAuthMagic(pDRIPriv->drmFD, magic)) + return FALSE; return TRUE; } @@ -856,15 +848,14 @@ Bool DRIGetClientDriverName(ScreenPtr pScreen, int *ddxDriverMajorVersion, int *ddxDriverMinorVersion, - int *ddxDriverPatchVersion, - char **clientDriverName) + int *ddxDriverPatchVersion, char **clientDriverName) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); *ddxDriverMajorVersion = pDRIPriv->pDriverInfo->ddxDriverMajorVersion; *ddxDriverMinorVersion = pDRIPriv->pDriverInfo->ddxDriverMinorVersion; *ddxDriverPatchVersion = pDRIPriv->pDriverInfo->ddxDriverPatchVersion; - *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName; + *clientDriverName = pDRIPriv->pDriverInfo->clientDriverName; return TRUE; } @@ -883,13 +874,12 @@ DRIGetClientDriverName(ScreenPtr pScreen, DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, - drm_context_t * pHWContext, - DRIContextFlags flags) + drm_context_t * pHWContext, DRIContextFlags flags) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (drmCreateContext(pDRIPriv->drmFD, pHWContext)) { - return NULL; + return NULL; } return DRICreateContextPrivFromHandle(pScreen, *pHWContext, flags); @@ -897,46 +887,42 @@ DRICreateContextPriv(ScreenPtr pScreen, DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, - drm_context_t hHWContext, - DRIContextFlags flags) + drm_context_t hHWContext, DRIContextFlags flags) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIContextPrivPtr pDRIContextPriv; - int contextPrivSize; + int contextPrivSize; contextPrivSize = sizeof(DRIContextPrivRec) + - pDRIPriv->pDriverInfo->contextSize; + pDRIPriv->pDriverInfo->contextSize; if (!(pDRIContextPriv = calloc(1, contextPrivSize))) { - return NULL; + return NULL; } - pDRIContextPriv->pContextStore = (void *)(pDRIContextPriv + 1); + pDRIContextPriv->pContextStore = (void *) (pDRIContextPriv + 1); drmAddContextTag(pDRIPriv->drmFD, hHWContext, pDRIContextPriv); pDRIContextPriv->hwContext = hHWContext; - pDRIContextPriv->pScreen = pScreen; - pDRIContextPriv->flags = flags; - pDRIContextPriv->valid3D = FALSE; + pDRIContextPriv->pScreen = pScreen; + pDRIContextPriv->flags = flags; + pDRIContextPriv->valid3D = FALSE; if (flags & DRI_CONTEXT_2DONLY) { - if (drmSetContextFlags(pDRIPriv->drmFD, - hHWContext, - DRM_CONTEXT_2DONLY)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[drm] failed to set 2D context flag\n"); - DRIDestroyContextPriv(pDRIContextPriv); - return NULL; - } + if (drmSetContextFlags(pDRIPriv->drmFD, hHWContext, DRM_CONTEXT_2DONLY)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to set 2D context flag\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return NULL; + } } if (flags & DRI_CONTEXT_PRESERVED) { - if (drmSetContextFlags(pDRIPriv->drmFD, - hHWContext, - DRM_CONTEXT_PRESERVED)) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[drm] failed to set preserved flag\n"); - DRIDestroyContextPriv(pDRIContextPriv); - return NULL; - } + if (drmSetContextFlags(pDRIPriv->drmFD, + hHWContext, DRM_CONTEXT_PRESERVED)) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[drm] failed to set preserved flag\n"); + DRIDestroyContextPriv(pDRIContextPriv); + return NULL; + } } return pDRIContextPriv; } @@ -946,23 +932,24 @@ DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv) { DRIScreenPrivPtr pDRIPriv; - if (!pDRIContextPriv) return TRUE; + if (!pDRIContextPriv) + return TRUE; pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen); if (!(pDRIContextPriv->flags & DRI_CONTEXT_RESERVED)) { - /* Don't delete reserved contexts from - kernel area -- the kernel manages its - reserved contexts itself. */ - if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext)) - return FALSE; - } - - /* Remove the tag last to prevent a race - condition where the context has pending - buffers. The context can't be re-used - while in this thread, but buffers can be - dispatched asynchronously. */ + /* Don't delete reserved contexts from + kernel area -- the kernel manages its + reserved contexts itself. */ + if (drmDestroyContext(pDRIPriv->drmFD, pDRIContextPriv->hwContext)) + return FALSE; + } + + /* Remove the tag last to prevent a race + condition where the context has pending + buffers. The context can't be re-used + while in this thread, but buffers can be + dispatched asynchronously. */ drmDelContextTag(pDRIPriv->drmFD, pDRIContextPriv->hwContext); free(pDRIContextPriv); return TRUE; @@ -976,20 +963,20 @@ DRICreateDummyContext(ScreenPtr pScreen, Bool needCtxPriv) void *contextStore; if (!(pDRIContextPriv = - DRICreateContextPriv(pScreen, - &pDRIPriv->pSAREA->dummy_context, 0))) { - return FALSE; + DRICreateContextPriv(pScreen, &pDRIPriv->pSAREA->dummy_context, 0))) { + return FALSE; } contextStore = DRIGetContextStore(pDRIContextPriv); if (pDRIPriv->pDriverInfo->CreateContext && needCtxPriv) { - if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL, - pDRIPriv->pSAREA->dummy_context, - NULL, - (DRIContextType)(long)contextStore)) { - DRIDestroyContextPriv(pDRIContextPriv); - return FALSE; - } + if (!pDRIPriv->pDriverInfo->CreateContext(pScreen, NULL, + pDRIPriv->pSAREA-> + dummy_context, NULL, + (DRIContextType) (long) + contextStore)) { + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } } pDRIPriv->dummyCtxPriv = pDRIContextPriv; @@ -1003,12 +990,14 @@ DRIDestroyDummyContext(ScreenPtr pScreen, Bool hasCtxPriv) DRIContextPrivPtr pDRIContextPriv = pDRIPriv->dummyCtxPriv; void *contextStore; - if (!pDRIContextPriv) return; + if (!pDRIContextPriv) + return; if (pDRIPriv->pDriverInfo->DestroyContext && hasCtxPriv) { - contextStore = DRIGetContextStore(pDRIContextPriv); - pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, - pDRIContextPriv->hwContext, - (DRIContextType)(long)contextStore); + contextStore = DRIGetContextStore(pDRIContextPriv); + pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, + pDRIContextPriv->hwContext, + (DRIContextType) (long) + contextStore); } DRIDestroyContextPriv(pDRIPriv->dummyCtxPriv); @@ -1025,28 +1014,29 @@ DRICreateContext(ScreenPtr pScreen, VisualPtr visual, if (pDRIPriv->createDummyCtx && !pDRIPriv->dummyCtxPriv) { if (!DRICreateDummyContext(pScreen, pDRIPriv->createDummyCtxPriv)) { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] Could not create dummy context\n"); - return FALSE; - } + DRIDrvMsg(pScreen->myNum, X_INFO, + "[drm] Could not create dummy context\n"); + return FALSE; + } } if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, pHWContext, 0))) { - return FALSE; + return FALSE; } contextStore = DRIGetContextStore(pDRIContextPriv); if (pDRIPriv->pDriverInfo->CreateContext) { - if (!((*pDRIPriv->pDriverInfo->CreateContext)(pScreen, NULL, - *pHWContext, NULL, - (DRIContextType)(long)contextStore))) { - DRIDestroyContextPriv(pDRIContextPriv); - return FALSE; - } + if (!((*pDRIPriv->pDriverInfo->CreateContext) (pScreen, NULL, + *pHWContext, NULL, + (DRIContextType) (long) + contextStore))) { + DRIDestroyContextPriv(pDRIContextPriv); + return FALSE; + } } /* track this in case the client dies before cleanup */ - AddResource(context, DRIContextPrivResType, (pointer)pDRIContextPriv); + AddResource(context, DRIContextPrivResType, (pointer) pDRIContextPriv); return TRUE; } @@ -1063,21 +1053,21 @@ DRIDestroyContext(ScreenPtr pScreen, XID context) Bool DRIContextPrivDelete(pointer pResource, XID id) { - DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr)pResource; + DRIContextPrivPtr pDRIContextPriv = (DRIContextPrivPtr) pResource; DRIScreenPrivPtr pDRIPriv; void *contextStore; pDRIPriv = DRI_SCREEN_PRIV(pDRIContextPriv->pScreen); if (pDRIPriv->pDriverInfo->DestroyContext) { - contextStore = DRIGetContextStore(pDRIContextPriv); - pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, - pDRIContextPriv->hwContext, - (DRIContextType)(long)contextStore); + contextStore = DRIGetContextStore(pDRIContextPriv); + pDRIPriv->pDriverInfo->DestroyContext(pDRIContextPriv->pScreen, + pDRIContextPriv->hwContext, + (DRIContextType) (long) + contextStore); } return DRIDestroyContextPriv(pDRIContextPriv); } - /* This walks the drawable timestamp array and invalidates all of them * in the case of transition from private to shared backbuffers. It's * not necessary for correctness, because DRIClipNotify gets called in @@ -1087,51 +1077,48 @@ DRIContextPrivDelete(pointer pResource, XID id) static void DRIClipNotifyAllDrawables(ScreenPtr pScreen) { - int i; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + int i; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - for( i=0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { - pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++; - } + for (i = 0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { + pDRIPriv->pSAREA->drawableTable[i].stamp = DRIDrawableValidationStamp++; + } } - static void DRITransitionToSharedBuffers(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - DRIClipNotifyAllDrawables( pScreen ); + DRIClipNotifyAllDrawables(pScreen); if (pDRIInfo->TransitionSingleToMulti3D) - pDRIInfo->TransitionSingleToMulti3D( pScreen ); + pDRIInfo->TransitionSingleToMulti3D(pScreen); } - static void DRITransitionToPrivateBuffers(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - DRIClipNotifyAllDrawables( pScreen ); + DRIClipNotifyAllDrawables(pScreen); if (pDRIInfo->TransitionMultiToSingle3D) - pDRIInfo->TransitionMultiToSingle3D( pScreen ); + pDRIInfo->TransitionMultiToSingle3D(pScreen); } - static void DRITransitionTo3d(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - DRIClipNotifyAllDrawables( pScreen ); + DRIClipNotifyAllDrawables(pScreen); if (pDRIInfo->TransitionTo3d) - pDRIInfo->TransitionTo3d( pScreen ); + pDRIInfo->TransitionTo3d(pScreen); } static void @@ -1140,36 +1127,35 @@ DRITransitionTo2d(ScreenPtr pScreen) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - DRIClipNotifyAllDrawables( pScreen ); + DRIClipNotifyAllDrawables(pScreen); if (pDRIInfo->TransitionTo2d) - pDRIInfo->TransitionTo2d( pScreen ); + pDRIInfo->TransitionTo2d(pScreen); } - static int DRIDCNTreeTraversal(WindowPtr pWin, pointer data) { DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); if (pDRIDrawablePriv) { - ScreenPtr pScreen = pWin->drawable.pScreen; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (RegionNumRects(&pWin->clipList) > 0) { - WindowPtr *pDRIWindows = (WindowPtr*)data; - int i = 0; + if (RegionNumRects(&pWin->clipList) > 0) { + WindowPtr *pDRIWindows = (WindowPtr *) data; + int i = 0; - while (pDRIWindows[i]) - i++; + while (pDRIWindows[i]) + i++; - pDRIWindows[i] = pWin; + pDRIWindows[i] = pWin; - pDRIPriv->nrWalked++; - } + pDRIPriv->nrWalked++; + } - if (pDRIPriv->nrWindows == pDRIPriv->nrWalked) - return WT_STOPWALKING; + if (pDRIPriv->nrWindows == pDRIPriv->nrWalked) + return WT_STOPWALKING; } return WT_WALKCHILDREN; @@ -1181,18 +1167,18 @@ DRIDriverClipNotify(ScreenPtr pScreen) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv->pDriverInfo->ClipNotify) { - WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows); - DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + WindowPtr *pDRIWindows = calloc(sizeof(WindowPtr), pDRIPriv->nrWindows); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - if (pDRIPriv->nrWindows > 0) { - pDRIPriv->nrWalked = 0; - TraverseTree(pScreen->root, DRIDCNTreeTraversal, - (pointer)pDRIWindows); - } + if (pDRIPriv->nrWindows > 0) { + pDRIPriv->nrWalked = 0; + TraverseTree(pScreen->root, DRIDCNTreeTraversal, + (pointer) pDRIWindows); + } - pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows); + pDRIInfo->ClipNotify(pScreen, pDRIWindows, pDRIPriv->nrWindows); - free(pDRIWindows); + free(pDRIWindows); } } @@ -1203,13 +1189,13 @@ DRIIncreaseNumberVisible(ScreenPtr pScreen) switch (++pDRIPriv->nrWindowsVisible) { case 1: - DRITransitionTo3d( pScreen ); - break; + DRITransitionTo3d(pScreen); + break; case 2: - DRITransitionToSharedBuffers( pScreen ); - break; + DRITransitionToSharedBuffers(pScreen); + break; default: - break; + break; } DRIDriverClipNotify(pScreen); @@ -1222,13 +1208,13 @@ DRIDecreaseNumberVisible(ScreenPtr pScreen) switch (--pDRIPriv->nrWindowsVisible) { case 0: - DRITransitionTo2d( pScreen ); - break; + DRITransitionTo2d(pScreen); + break; case 1: - DRITransitionToPrivateBuffers( pScreen ); - break; + DRITransitionToPrivateBuffers(pScreen); + break; default: - break; + break; } DRIDriverClipNotify(pScreen); @@ -1236,65 +1222,66 @@ DRIDecreaseNumberVisible(ScreenPtr pScreen) Bool DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, - drm_drawable_t * hHWDrawable) + drm_drawable_t * hHWDrawable) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv; - WindowPtr pWin; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv; + WindowPtr pWin; if (pDrawable->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr)pDrawable; - if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { - pDRIDrawablePriv->refCount++; - - if (!pDRIDrawablePriv->hwDrawable) { - drmCreateDrawable(pDRIPriv->drmFD, &pDRIDrawablePriv->hwDrawable); - } - } - else { - /* allocate a DRI Window Private record */ - if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) { - return FALSE; - } - - /* Only create a drm_drawable_t once */ - if (drmCreateDrawable(pDRIPriv->drmFD, - &pDRIDrawablePriv->hwDrawable)) { - free(pDRIDrawablePriv); - return FALSE; - } - - /* add it to the list of DRI drawables for this screen */ - pDRIDrawablePriv->pScreen = pScreen; - pDRIDrawablePriv->refCount = 1; - pDRIDrawablePriv->drawableIndex = -1; - pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList); - - /* save private off of preallocated index */ - dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, - pDRIDrawablePriv); - pDRIPriv->nrWindows++; - - if (pDRIDrawablePriv->nrects) - DRIIncreaseNumberVisible(pScreen); - } - - /* track this in case the client dies */ - AddResource(FakeClientID(client->index), DRIDrawablePrivResType, - (pointer)(intptr_t)pDrawable->id); - - if (pDRIDrawablePriv->hwDrawable) { - drmUpdateDrawableInfo(pDRIPriv->drmFD, - pDRIDrawablePriv->hwDrawable, - DRM_DRAWABLE_CLIPRECTS, - RegionNumRects(&pWin->clipList), - RegionRects(&pWin->clipList)); - *hHWDrawable = pDRIDrawablePriv->hwDrawable; - } - } - else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */ - /* NOT_DONE */ - return FALSE; + pWin = (WindowPtr) pDrawable; + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + pDRIDrawablePriv->refCount++; + + if (!pDRIDrawablePriv->hwDrawable) { + drmCreateDrawable(pDRIPriv->drmFD, + &pDRIDrawablePriv->hwDrawable); + } + } + else { + /* allocate a DRI Window Private record */ + if (!(pDRIDrawablePriv = malloc(sizeof(DRIDrawablePrivRec)))) { + return FALSE; + } + + /* Only create a drm_drawable_t once */ + if (drmCreateDrawable(pDRIPriv->drmFD, + &pDRIDrawablePriv->hwDrawable)) { + free(pDRIDrawablePriv); + return FALSE; + } + + /* add it to the list of DRI drawables for this screen */ + pDRIDrawablePriv->pScreen = pScreen; + pDRIDrawablePriv->refCount = 1; + pDRIDrawablePriv->drawableIndex = -1; + pDRIDrawablePriv->nrects = RegionNumRects(&pWin->clipList); + + /* save private off of preallocated index */ + dixSetPrivate(&pWin->devPrivates, DRIWindowPrivKey, + pDRIDrawablePriv); + pDRIPriv->nrWindows++; + + if (pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); + } + + /* track this in case the client dies */ + AddResource(FakeClientID(client->index), DRIDrawablePrivResType, + (pointer) (intptr_t) pDrawable->id); + + if (pDRIDrawablePriv->hwDrawable) { + drmUpdateDrawableInfo(pDRIPriv->drmFD, + pDRIDrawablePriv->hwDrawable, + DRM_DRAWABLE_CLIPRECTS, + RegionNumRects(&pWin->clipList), + RegionRects(&pWin->clipList)); + *hHWDrawable = pDRIDrawablePriv->hwDrawable; + } + } + else if (pDrawable->type != DRAWABLE_PIXMAP) { /* PBuffer */ + /* NOT_DONE */ + return FALSE; } return TRUE; @@ -1308,24 +1295,24 @@ DRIDrawablePrivDestroy(WindowPtr pWin) DRIScreenPrivPtr pDRIPriv; if (!pDRIDrawablePriv) - return; + return; pScreen = pWin->drawable.pScreen; pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIDrawablePriv->drawableIndex != -1) { - /* bump stamp to force outstanding 3D requests to resync */ - pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp - = DRIDrawableValidationStamp++; + /* bump stamp to force outstanding 3D requests to resync */ + pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp + = DRIDrawableValidationStamp++; - /* release drawable table entry */ - pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; + /* release drawable table entry */ + pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; } pDRIPriv->nrWindows--; if (pDRIDrawablePriv->nrects) - DRIDecreaseNumberVisible(pScreen); + DRIDecreaseNumberVisible(pScreen); drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable); @@ -1337,10 +1324,10 @@ static Bool DRIDestroyDrawableCB(pointer value, XID id, pointer data) { if (value == data) { - /* This calls back DRIDrawablePrivDelete which frees private area */ - FreeResourceByType(id, DRIDrawablePrivResType, FALSE); + /* This calls back DRIDrawablePrivDelete which frees private area */ + FreeResourceByType(id, DRIDrawablePrivResType, FALSE); - return TRUE; + return TRUE; } return FALSE; @@ -1350,13 +1337,13 @@ Bool DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable) { if (pDrawable->type == DRAWABLE_WINDOW) { - LookupClientResourceComplex(client, DRIDrawablePrivResType, - DRIDestroyDrawableCB, - (pointer)(intptr_t)pDrawable->id); + LookupClientResourceComplex(client, DRIDrawablePrivResType, + DRIDestroyDrawableCB, + (pointer) (intptr_t) pDrawable->id); } - else { /* pixmap (or for GLX 1.3, a PBuffer) */ - /* NOT_DONE */ - return FALSE; + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; } return TRUE; @@ -1370,189 +1357,198 @@ DRIDrawablePrivDelete(pointer pResource, XID id) /* For DRIDrawablePrivResType, the XID is the client's fake ID. The * important XID is the value in pResource. */ - id = (XID)(intptr_t)pResource; + id = (XID) (intptr_t) pResource; rc = dixLookupWindow(&pWin, id, serverClient, DixGetAttrAccess); if (rc == Success) { - DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - if (!pDRIDrwPriv) - return FALSE; + if (!pDRIDrwPriv) + return FALSE; - if (--pDRIDrwPriv->refCount == 0) - DRIDrawablePrivDestroy(pWin); + if (--pDRIDrwPriv->refCount == 0) + DRIDrawablePrivDestroy(pWin); - return TRUE; + return TRUE; } - else { /* pixmap (or for GLX 1.3, a PBuffer) */ - /* NOT_DONE */ - return FALSE; + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; } } Bool DRIGetDrawableInfo(ScreenPtr pScreen, DrawablePtr pDrawable, - unsigned int* index, - unsigned int* stamp, - int* X, - int* Y, - int* W, - int* H, - int* numClipRects, + unsigned int *index, + unsigned int *stamp, + int *X, + int *Y, + int *W, + int *H, + int *numClipRects, drm_clip_rect_t ** pClipRects, - int* backX, - int* backY, - int* numBackClipRects, - drm_clip_rect_t ** pBackClipRects) + int *backX, + int *backY, + int *numBackClipRects, drm_clip_rect_t ** pBackClipRects) { - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv; - WindowPtr pWin, pOldWin; - int i; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIDrawablePrivPtr pDRIDrawablePriv, pOldDrawPriv; + WindowPtr pWin, pOldWin; + int i; #if 0 - printf("maxDrawableTableEntry = %d\n", pDRIPriv->pDriverInfo->maxDrawableTableEntry); + printf("maxDrawableTableEntry = %d\n", + pDRIPriv->pDriverInfo->maxDrawableTableEntry); #endif if (pDrawable->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr)pDrawable; - if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { - - /* Manage drawable table */ - if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */ - - /* Search table for empty entry */ - i = 0; - while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) { - if (!(pDRIPriv->DRIDrawables[i])) { - pDRIPriv->DRIDrawables[i] = pDrawable; - pDRIDrawablePriv->drawableIndex = i; - pDRIPriv->pSAREA->drawableTable[i].stamp = - DRIDrawableValidationStamp++; - break; - } - i++; - } - - /* Search table for oldest entry */ - if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) { + pWin = (WindowPtr) pDrawable; + if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { + + /* Manage drawable table */ + if (pDRIDrawablePriv->drawableIndex == -1) { /* load SAREA table */ + + /* Search table for empty entry */ + i = 0; + while (i < pDRIPriv->pDriverInfo->maxDrawableTableEntry) { + if (!(pDRIPriv->DRIDrawables[i])) { + pDRIPriv->DRIDrawables[i] = pDrawable; + pDRIDrawablePriv->drawableIndex = i; + pDRIPriv->pSAREA->drawableTable[i].stamp = + DRIDrawableValidationStamp++; + break; + } + i++; + } + + /* Search table for oldest entry */ + if (i == pDRIPriv->pDriverInfo->maxDrawableTableEntry) { unsigned int oldestStamp = ~0; int oldestIndex = 0; - i = pDRIPriv->pDriverInfo->maxDrawableTableEntry; - while (i--) { - if (pDRIPriv->pSAREA->drawableTable[i].stamp < - oldestStamp) { - oldestIndex = i; - oldestStamp = - pDRIPriv->pSAREA->drawableTable[i].stamp; - } - } - pDRIDrawablePriv->drawableIndex = oldestIndex; - - /* release oldest drawable table entry */ - pOldWin = (WindowPtr)pDRIPriv->DRIDrawables[oldestIndex]; - pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin); - pOldDrawPriv->drawableIndex = -1; - - /* claim drawable table entry */ - pDRIPriv->DRIDrawables[oldestIndex] = pDrawable; - - /* validate SAREA entry */ - pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp = - DRIDrawableValidationStamp++; - - /* check for stamp wrap around */ - if (oldestStamp > DRIDrawableValidationStamp) { - - /* walk SAREA table and invalidate all drawables */ - for( i=0; + + i = pDRIPriv->pDriverInfo->maxDrawableTableEntry; + while (i--) { + if (pDRIPriv->pSAREA->drawableTable[i].stamp < + oldestStamp) { + oldestIndex = i; + oldestStamp = + pDRIPriv->pSAREA->drawableTable[i].stamp; + } + } + pDRIDrawablePriv->drawableIndex = oldestIndex; + + /* release oldest drawable table entry */ + pOldWin = (WindowPtr) pDRIPriv->DRIDrawables[oldestIndex]; + pOldDrawPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pOldWin); + pOldDrawPriv->drawableIndex = -1; + + /* claim drawable table entry */ + pDRIPriv->DRIDrawables[oldestIndex] = pDrawable; + + /* validate SAREA entry */ + pDRIPriv->pSAREA->drawableTable[oldestIndex].stamp = + DRIDrawableValidationStamp++; + + /* check for stamp wrap around */ + if (oldestStamp > DRIDrawableValidationStamp) { + + /* walk SAREA table and invalidate all drawables */ + for (i = 0; i < pDRIPriv->pDriverInfo->maxDrawableTableEntry; i++) { - pDRIPriv->pSAREA->drawableTable[i].stamp = - DRIDrawableValidationStamp++; - } - } - } - - /* If the driver wants to be notified when the index is - * set for a drawable, let it know now. - */ - if (pDRIPriv->pDriverInfo->SetDrawableIndex) - pDRIPriv->pDriverInfo->SetDrawableIndex(pWin, - pDRIDrawablePriv->drawableIndex); - - /* reinit drawable ID if window is visible */ - if ((pWin->viewable) && - (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS)) - { - (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, - &pWin->clipList, pDRIDrawablePriv->drawableIndex); - } - } - - *index = pDRIDrawablePriv->drawableIndex; - *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp; - *X = (int)(pWin->drawable.x); - *Y = (int)(pWin->drawable.y); - *W = (int)(pWin->drawable.width); - *H = (int)(pWin->drawable.height); - *numClipRects = RegionNumRects(&pWin->clipList); - *pClipRects = (drm_clip_rect_t *)RegionRects(&pWin->clipList); - - if (!*numClipRects && pDRIPriv->fullscreen) { - /* use fake full-screen clip rect */ - pDRIPriv->fullscreen_rect.x1 = *X; - pDRIPriv->fullscreen_rect.y1 = *Y; - pDRIPriv->fullscreen_rect.x2 = *X + *W; - pDRIPriv->fullscreen_rect.y2 = *Y + *H; - - *numClipRects = 1; - *pClipRects = &pDRIPriv->fullscreen_rect; - } - - *backX = *X; - *backY = *Y; - - if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) { - /* Use a single cliprect. */ - - int x0 = *X; - int y0 = *Y; - int x1 = x0 + *W; - int y1 = y0 + *H; - - if (x0 < 0) x0 = 0; - if (y0 < 0) y0 = 0; - if (x1 > pScreen->width) x1 = pScreen->width; - if (y1 > pScreen->height) y1 = pScreen->height; - - if (y0 >= y1 || x0 >= x1) { - *numBackClipRects = 0; - *pBackClipRects = NULL; - } else { - pDRIPriv->private_buffer_rect.x1 = x0; - pDRIPriv->private_buffer_rect.y1 = y0; - pDRIPriv->private_buffer_rect.x2 = x1; - pDRIPriv->private_buffer_rect.y2 = y1; - - *numBackClipRects = 1; - *pBackClipRects = &(pDRIPriv->private_buffer_rect); - } - } else { - /* Use the frontbuffer cliprects for back buffers. */ - *numBackClipRects = 0; - *pBackClipRects = 0; - } - } - else { - /* Not a DRIDrawable */ - return FALSE; - } - } - else { /* pixmap (or for GLX 1.3, a PBuffer) */ - /* NOT_DONE */ - return FALSE; + pDRIPriv->pSAREA->drawableTable[i].stamp = + DRIDrawableValidationStamp++; + } + } + } + + /* If the driver wants to be notified when the index is + * set for a drawable, let it know now. + */ + if (pDRIPriv->pDriverInfo->SetDrawableIndex) + pDRIPriv->pDriverInfo->SetDrawableIndex(pWin, + pDRIDrawablePriv-> + drawableIndex); + + /* reinit drawable ID if window is visible */ + if ((pWin->viewable) && + (pDRIPriv->pDriverInfo->bufferRequests != DRI_NO_WINDOWS)) { + (*pDRIPriv->pDriverInfo->InitBuffers) (pWin, + &pWin->clipList, + pDRIDrawablePriv-> + drawableIndex); + } + } + + *index = pDRIDrawablePriv->drawableIndex; + *stamp = pDRIPriv->pSAREA->drawableTable[*index].stamp; + *X = (int) (pWin->drawable.x); + *Y = (int) (pWin->drawable.y); + *W = (int) (pWin->drawable.width); + *H = (int) (pWin->drawable.height); + *numClipRects = RegionNumRects(&pWin->clipList); + *pClipRects = (drm_clip_rect_t *) RegionRects(&pWin->clipList); + + if (!*numClipRects && pDRIPriv->fullscreen) { + /* use fake full-screen clip rect */ + pDRIPriv->fullscreen_rect.x1 = *X; + pDRIPriv->fullscreen_rect.y1 = *Y; + pDRIPriv->fullscreen_rect.x2 = *X + *W; + pDRIPriv->fullscreen_rect.y2 = *Y + *H; + + *numClipRects = 1; + *pClipRects = &pDRIPriv->fullscreen_rect; + } + + *backX = *X; + *backY = *Y; + + if (pDRIPriv->nrWindowsVisible == 1 && *numClipRects) { + /* Use a single cliprect. */ + + int x0 = *X; + int y0 = *Y; + int x1 = x0 + *W; + int y1 = y0 + *H; + + if (x0 < 0) + x0 = 0; + if (y0 < 0) + y0 = 0; + if (x1 > pScreen->width) + x1 = pScreen->width; + if (y1 > pScreen->height) + y1 = pScreen->height; + + if (y0 >= y1 || x0 >= x1) { + *numBackClipRects = 0; + *pBackClipRects = NULL; + } + else { + pDRIPriv->private_buffer_rect.x1 = x0; + pDRIPriv->private_buffer_rect.y1 = y0; + pDRIPriv->private_buffer_rect.x2 = x1; + pDRIPriv->private_buffer_rect.y2 = y1; + + *numBackClipRects = 1; + *pBackClipRects = &(pDRIPriv->private_buffer_rect); + } + } + else { + /* Use the frontbuffer cliprects for back buffers. */ + *numBackClipRects = 0; + *pBackClipRects = 0; + } + } + else { + /* Not a DRIDrawable */ + return FALSE; + } + } + else { /* pixmap (or for GLX 1.3, a PBuffer) */ + /* NOT_DONE */ + return FALSE; } return TRUE; @@ -1561,11 +1557,9 @@ DRIGetDrawableInfo(ScreenPtr pScreen, Bool DRIGetDeviceInfo(ScreenPtr pScreen, drm_handle_t * hFrameBuffer, - int* fbOrigin, - int* fbSize, - int* fbStride, - int* devPrivateSize, - void** pDevPrivate) + int *fbOrigin, + int *fbSize, + int *fbStride, int *devPrivateSize, void **pDevPrivate) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); @@ -1582,21 +1576,23 @@ DRIGetDeviceInfo(ScreenPtr pScreen, DRIInfoPtr DRICreateInfoRec(void) { - DRIInfoPtr inforec = (DRIInfoPtr)calloc(1, sizeof(DRIInfoRec)); - if (!inforec) return NULL; + DRIInfoPtr inforec = (DRIInfoPtr) calloc(1, sizeof(DRIInfoRec)); + + if (!inforec) + return NULL; /* Initialize defaults */ inforec->busIdString = NULL; /* Wrapped function defaults */ - inforec->wrap.WakeupHandler = DRIDoWakeupHandler; - inforec->wrap.BlockHandler = DRIDoBlockHandler; - inforec->wrap.WindowExposures = DRIWindowExposures; - inforec->wrap.CopyWindow = DRICopyWindow; - inforec->wrap.ValidateTree = DRIValidateTree; - inforec->wrap.PostValidateTree = DRIPostValidateTree; - inforec->wrap.ClipNotify = DRIClipNotify; - inforec->wrap.AdjustFrame = DRIAdjustFrame; + inforec->wrap.WakeupHandler = DRIDoWakeupHandler; + inforec->wrap.BlockHandler = DRIDoBlockHandler; + inforec->wrap.WindowExposures = DRIWindowExposures; + inforec->wrap.CopyWindow = DRICopyWindow; + inforec->wrap.ValidateTree = DRIValidateTree; + inforec->wrap.PostValidateTree = DRIPostValidateTree; + inforec->wrap.ClipNotify = DRIClipNotify; + inforec->wrap.AdjustFrame = DRIAdjustFrame; inforec->TransitionTo2d = 0; inforec->TransitionTo3d = 0; @@ -1609,23 +1605,21 @@ void DRIDestroyInfoRec(DRIInfoPtr DRIInfo) { free(DRIInfo->busIdString); - free((char*)DRIInfo); + free((char *) DRIInfo); } - void DRIWakeupHandler(pointer wakeupData, int result, pointer pReadmask) { int i; for (i = 0; i < screenInfo.numScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + ScreenPtr pScreen = screenInfo.screens[i]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (pDRIPriv && - pDRIPriv->pDriverInfo->wrap.WakeupHandler) - (*pDRIPriv->pDriverInfo->wrap.WakeupHandler)(i, wakeupData, - result, pReadmask); + if (pDRIPriv && pDRIPriv->pDriverInfo->wrap.WakeupHandler) + (*pDRIPriv->pDriverInfo->wrap.WakeupHandler) (i, wakeupData, + result, pReadmask); } } @@ -1635,13 +1629,12 @@ DRIBlockHandler(pointer blockData, OSTimePtr pTimeout, pointer pReadmask) int i; for (i = 0; i < screenInfo.numScreens; i++) { - ScreenPtr pScreen = screenInfo.screens[i]; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + ScreenPtr pScreen = screenInfo.screens[i]; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (pDRIPriv && - pDRIPriv->pDriverInfo->wrap.BlockHandler) - (*pDRIPriv->pDriverInfo->wrap.BlockHandler)(i, blockData, - pTimeout, pReadmask); + if (pDRIPriv && pDRIPriv->pDriverInfo->wrap.BlockHandler) + (*pDRIPriv->pDriverInfo->wrap.BlockHandler) (i, blockData, + pTimeout, pReadmask); } } @@ -1654,13 +1647,13 @@ DRIDoWakeupHandler(int screenNum, pointer wakeupData, DRILock(pScreen, 0); if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { - /* hide X context by swapping 2D component here */ - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - DRI_3D_SYNC, - DRI_2D_CONTEXT, - pDRIPriv->partial3DContextStore, - DRI_2D_CONTEXT, - pDRIPriv->hiddenContextStore); + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + DRI_3D_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore); } } @@ -1672,13 +1665,13 @@ DRIDoBlockHandler(int screenNum, pointer blockData, DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { - /* hide X context by swapping 2D component here */ - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - DRI_2D_SYNC, - DRI_NO_CONTEXT, - NULL, - DRI_2D_CONTEXT, - pDRIPriv->partial3DContextStore); + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + DRI_2D_SYNC, + DRI_NO_CONTEXT, + NULL, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore); } if (pDRIPriv->windowsTouched) @@ -1691,154 +1684,155 @@ DRIDoBlockHandler(int screenNum, pointer blockData, void DRISwapContext(int drmFD, void *oldctx, void *newctx) { - DRIContextPrivPtr oldContext = (DRIContextPrivPtr)oldctx; - DRIContextPrivPtr newContext = (DRIContextPrivPtr)newctx; - ScreenPtr pScreen = newContext->pScreen; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - void* oldContextStore = NULL; - DRIContextType oldContextType; - void* newContextStore = NULL; - DRIContextType newContextType; - DRISyncType syncType; + DRIContextPrivPtr oldContext = (DRIContextPrivPtr) oldctx; + DRIContextPrivPtr newContext = (DRIContextPrivPtr) newctx; + ScreenPtr pScreen = newContext->pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + void *oldContextStore = NULL; + DRIContextType oldContextType; + void *newContextStore = NULL; + DRIContextType newContextType; + DRISyncType syncType; + #ifdef DEBUG - static int count = 0; + static int count = 0; if (!newContext) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n", - oldContext, newContext); - return; + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Context Switch Error: oldContext=%x, newContext=%x\n", + oldContext, newContext); + return; } /* usefull for debugging, just print out after n context switches */ if (!count || !(count % 1)) { - DRIDrvMsg(pScreen->myNum, X_INFO, - "[DRI] Context switch %5d from %p/0x%08x (%d)\n", - count, - oldContext, - oldContext ? oldContext->flags : 0, - oldContext ? oldContext->hwContext : -1); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[DRI] Context switch %5d to %p/0x%08x (%d)\n", - count, - newContext, - newContext ? newContext->flags : 0, - newContext ? newContext->hwContext : -1); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[DRI] Context switch %5d from %p/0x%08x (%d)\n", + count, + oldContext, + oldContext ? oldContext->flags : 0, + oldContext ? oldContext->hwContext : -1); + DRIDrvMsg(pScreen->myNum, X_INFO, + "[DRI] Context switch %5d to %p/0x%08x (%d)\n", + count, + newContext, + newContext ? newContext->flags : 0, + newContext ? newContext->hwContext : -1); } ++count; #endif if (!pDRIPriv->pDriverInfo->SwapContext) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[DRI] DDX driver missing context swap call back\n"); - return; + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] DDX driver missing context swap call back\n"); + return; } if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { /* only 3D contexts are swapped in this case */ - if (oldContext) { - oldContextStore = DRIGetContextStore(oldContext); - oldContext->valid3D = TRUE; - oldContextType = DRI_3D_CONTEXT; - } else { - oldContextType = DRI_NO_CONTEXT; - } - newContextStore = DRIGetContextStore(newContext); - if ((newContext->valid3D) && - (newContext->hwContext != pDRIPriv->myContext)) { - newContextType = DRI_3D_CONTEXT; - } - else { - newContextType = DRI_2D_CONTEXT; - } - syncType = DRI_3D_SYNC; - } - else /* default: driverSwapMethod == DRI_SERVER_SWAP */ { + if (oldContext) { + oldContextStore = DRIGetContextStore(oldContext); + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + } + else { + oldContextType = DRI_NO_CONTEXT; + } + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_3D_SYNC; + } + else { /* default: driverSwapMethod == DRI_SERVER_SWAP */ /* optimize 2D context swaps */ - if (newContext->flags & DRI_CONTEXT_2DONLY) { - /* go from 3D context to 2D context and only save 2D + if (newContext->flags & DRI_CONTEXT_2DONLY) { + /* go from 3D context to 2D context and only save 2D * subset of 3D state */ - oldContextStore = DRIGetContextStore(oldContext); - oldContextType = DRI_2D_CONTEXT; - newContextStore = DRIGetContextStore(newContext); - newContextType = DRI_2D_CONTEXT; - syncType = DRI_3D_SYNC; - pDRIPriv->lastPartial3DContext = oldContext; - } - else if (oldContext->flags & DRI_CONTEXT_2DONLY) { - if (pDRIPriv->lastPartial3DContext == newContext) { - /* go from 2D context back to previous 3D context and - * only restore 2D subset of previous 3D state - */ - oldContextStore = DRIGetContextStore(oldContext); - oldContextType = DRI_2D_CONTEXT; - newContextStore = DRIGetContextStore(newContext); - newContextType = DRI_2D_CONTEXT; - syncType = DRI_2D_SYNC; - } - else { - /* go from 2D context to a different 3D context */ - - /* call DDX driver to do partial restore */ - oldContextStore = DRIGetContextStore(oldContext); - newContextStore = - DRIGetContextStore(pDRIPriv->lastPartial3DContext); - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - DRI_2D_SYNC, - DRI_2D_CONTEXT, - oldContextStore, - DRI_2D_CONTEXT, - newContextStore); - - /* now setup for a complete 3D swap */ - oldContextStore = newContextStore; - oldContext->valid3D = TRUE; - oldContextType = DRI_3D_CONTEXT; - newContextStore = DRIGetContextStore(newContext); - if ((newContext->valid3D) && - (newContext->hwContext != pDRIPriv->myContext)) { - newContextType = DRI_3D_CONTEXT; - } - else { - newContextType = DRI_2D_CONTEXT; - } - syncType = DRI_NO_SYNC; - } - } - else { - /* now setup for a complete 3D swap */ - oldContextStore = newContextStore; - oldContext->valid3D = TRUE; - oldContextType = DRI_3D_CONTEXT; - newContextStore = DRIGetContextStore(newContext); - if ((newContext->valid3D) && - (newContext->hwContext != pDRIPriv->myContext)) { - newContextType = DRI_3D_CONTEXT; - } - else { - newContextType = DRI_2D_CONTEXT; - } - syncType = DRI_3D_SYNC; - } + oldContextStore = DRIGetContextStore(oldContext); + oldContextType = DRI_2D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + newContextType = DRI_2D_CONTEXT; + syncType = DRI_3D_SYNC; + pDRIPriv->lastPartial3DContext = oldContext; + } + else if (oldContext->flags & DRI_CONTEXT_2DONLY) { + if (pDRIPriv->lastPartial3DContext == newContext) { + /* go from 2D context back to previous 3D context and + * only restore 2D subset of previous 3D state + */ + oldContextStore = DRIGetContextStore(oldContext); + oldContextType = DRI_2D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + newContextType = DRI_2D_CONTEXT; + syncType = DRI_2D_SYNC; + } + else { + /* go from 2D context to a different 3D context */ + + /* call DDX driver to do partial restore */ + oldContextStore = DRIGetContextStore(oldContext); + newContextStore = + DRIGetContextStore(pDRIPriv->lastPartial3DContext); + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + DRI_2D_SYNC, + DRI_2D_CONTEXT, + oldContextStore, + DRI_2D_CONTEXT, + newContextStore); + + /* now setup for a complete 3D swap */ + oldContextStore = newContextStore; + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_NO_SYNC; + } + } + else { + /* now setup for a complete 3D swap */ + oldContextStore = newContextStore; + oldContext->valid3D = TRUE; + oldContextType = DRI_3D_CONTEXT; + newContextStore = DRIGetContextStore(newContext); + if ((newContext->valid3D) && + (newContext->hwContext != pDRIPriv->myContext)) { + newContextType = DRI_3D_CONTEXT; + } + else { + newContextType = DRI_2D_CONTEXT; + } + syncType = DRI_3D_SYNC; + } } /* call DDX driver to perform the swap */ - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - syncType, - oldContextType, - oldContextStore, - newContextType, - newContextStore); + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + syncType, + oldContextType, + oldContextStore, + newContextType, newContextStore); } -void* +void * DRIGetContextStore(DRIContextPrivPtr context) { - return((void *)context->pContextStore); + return ((void *) context->pContextStore); } void @@ -1848,45 +1842,44 @@ DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg) DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - if(pDRIDrawablePriv) { - (*pDRIPriv->pDriverInfo->InitBuffers)(pWin, prgn, + if (pDRIDrawablePriv) { + (*pDRIPriv->pDriverInfo->InitBuffers) (pWin, prgn, pDRIDrawablePriv->drawableIndex); } /* call lower wrapped functions */ if (pDRIPriv && pDRIPriv->wrap.WindowExposures) { - /* unwrap */ - pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; + /* unwrap */ + pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; - /* call lower layers */ - (*pScreen->WindowExposures)(pWin, prgn, bsreg); + /* call lower layers */ + (*pScreen->WindowExposures) (pWin, prgn, bsreg); - /* rewrap */ - pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; - pScreen->WindowExposures = DRIWindowExposures; + /* rewrap */ + pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; + pScreen->WindowExposures = DRIWindowExposures; } } - static int DRITreeTraversal(WindowPtr pWin, pointer data) { DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - if(pDRIDrawablePriv) { + if (pDRIDrawablePriv) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if(RegionNumRects(&(pWin->clipList)) > 0) { - RegionPtr reg = (RegionPtr)data; + if (RegionNumRects(&(pWin->clipList)) > 0) { + RegionPtr reg = (RegionPtr) data; - RegionUnion(reg, reg, &(pWin->clipList)); - pDRIPriv->nrWalked++; - } + RegionUnion(reg, reg, &(pWin->clipList)); + pDRIPriv->nrWalked++; + } - if(pDRIPriv->nrWindows == pDRIPriv->nrWalked) - return WT_STOPWALKING; + if (pDRIPriv->nrWindows == pDRIPriv->nrWalked) + return WT_STOPWALKING; } return WT_WALKCHILDREN; } @@ -1901,16 +1894,16 @@ DRIDestroyWindow(WindowPtr pWin) DRIDrawablePrivDestroy(pWin); /* call lower wrapped functions */ - if(pDRIPriv->DestroyWindow) { - /* unwrap */ - pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + if (pDRIPriv->DestroyWindow) { + /* unwrap */ + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; - /* call lower layers */ - retval = (*pScreen->DestroyWindow)(pWin); + /* call lower layers */ + retval = (*pScreen->DestroyWindow) (pWin); - /* rewrap */ - pDRIPriv->DestroyWindow = pScreen->DestroyWindow; - pScreen->DestroyWindow = DRIDestroyWindow; + /* rewrap */ + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; } return retval; @@ -1922,39 +1915,41 @@ DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if(!pDRIPriv) return; + if (!pDRIPriv) + return; - if(pDRIPriv->nrWindowsVisible > 0) { - RegionRec reg; + if (pDRIPriv->nrWindowsVisible > 0) { + RegionRec reg; - RegionNull(®); - pDRIPriv->nrWalked = 0; - TraverseTree(pWin, DRITreeTraversal, (pointer)(®)); + RegionNull(®); + pDRIPriv->nrWalked = 0; + TraverseTree(pWin, DRITreeTraversal, (pointer) (®)); - if(RegionNotEmpty(®)) { - RegionTranslate(®, ptOldOrg.x - pWin->drawable.x, - ptOldOrg.y - pWin->drawable.y); - RegionIntersect(®, ®, prgnSrc); + if (RegionNotEmpty(®)) { + RegionTranslate(®, ptOldOrg.x - pWin->drawable.x, + ptOldOrg.y - pWin->drawable.y); + RegionIntersect(®, ®, prgnSrc); - /* The MoveBuffers interface is not ideal */ - (*pDRIPriv->pDriverInfo->MoveBuffers)(pWin, ptOldOrg, ®, - pDRIPriv->pDriverInfo->ddxDrawableTableEntry); - } + /* The MoveBuffers interface is not ideal */ + (*pDRIPriv->pDriverInfo->MoveBuffers) (pWin, ptOldOrg, ®, + pDRIPriv->pDriverInfo-> + ddxDrawableTableEntry); + } - RegionUninit(®); + RegionUninit(®); } /* call lower wrapped functions */ - if(pDRIPriv->wrap.CopyWindow) { - /* unwrap */ - pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; + if (pDRIPriv->wrap.CopyWindow) { + /* unwrap */ + pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; - /* call lower layers */ - (*pScreen->CopyWindow)(pWin, ptOldOrg, prgnSrc); + /* call lower layers */ + (*pScreen->CopyWindow) (pWin, ptOldOrg, prgnSrc); - /* rewrap */ - pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; - pScreen->CopyWindow = DRICopyWindow; + /* rewrap */ + pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = DRICopyWindow; } } @@ -1965,25 +1960,26 @@ DRIGetSecs(long *secs, long *usecs) gettimeofday(&tv, NULL); - *secs = tv.tv_sec; + *secs = tv.tv_sec; *usecs = tv.tv_usec; } static unsigned long DRIComputeMilliSeconds(unsigned long s_secs, unsigned long s_usecs, - unsigned long f_secs, unsigned long f_usecs) + unsigned long f_secs, unsigned long f_usecs) { if (f_usecs < s_usecs) { - --f_secs; - f_usecs += 1000000; + --f_secs; + f_usecs += 1000000; } return (f_secs - s_secs) * 1000 + (f_usecs - s_usecs) / 1000; } static void -DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */) +DRISpinLockTimeout(drmLock * lock, int val, unsigned long timeout /* in mS */ ) { - int count = 10000; + int count = 10000; + #if !defined(__alpha__) && !defined(__powerpc__) char ret; #else @@ -1992,25 +1988,27 @@ DRISpinLockTimeout(drmLock *lock, int val, unsigned long timeout /* in mS */) long s_secs, s_usecs; long f_secs, f_usecs; long msecs; - long prev = 0; + long prev = 0; DRIGetSecs(&s_secs, &s_usecs); do { - DRM_SPINLOCK_COUNT(lock, val, count, ret); - if (!ret) return; /* Got lock */ - DRIGetSecs(&f_secs, &f_usecs); - msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs); - if (msecs - prev < 250) count *= 2; /* Not more than 0.5S */ + DRM_SPINLOCK_COUNT(lock, val, count, ret); + if (!ret) + return; /* Got lock */ + DRIGetSecs(&f_secs, &f_usecs); + msecs = DRIComputeMilliSeconds(s_secs, s_usecs, f_secs, f_usecs); + if (msecs - prev < 250) + count *= 2; /* Not more than 0.5S */ } while (msecs < timeout); - /* Didn't get lock, so take it. The worst - that can happen is that there is some - garbage written to the wrong part of the - framebuffer that a refresh will repair. - That's undesirable, but better than - locking the server. This should be a - very rare event. */ + /* Didn't get lock, so take it. The worst + that can happen is that there is some + garbage written to the wrong part of the + framebuffer that a refresh will repair. + That's undesirable, but better than + locking the server. This should be a + very rare event. */ DRM_SPINLOCK_TAKE(lock, val); } @@ -2019,16 +2017,17 @@ DRILockTree(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if(!pDRIPriv) return; + if (!pDRIPriv) + return; /* Restore the last known 3D context if the X context is hidden */ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - DRI_2D_SYNC, - DRI_NO_CONTEXT, - NULL, - DRI_2D_CONTEXT, - pDRIPriv->partial3DContextStore); + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + DRI_2D_SYNC, + DRI_NO_CONTEXT, + NULL, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore); } /* Call kernel to release lock */ @@ -2038,20 +2037,20 @@ DRILockTree(ScreenPtr pScreen) appropriate, since this should never time out except in the case of client death while the lock is being held. The timeout must be greater than any reasonable rendering time. */ - DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs*/ + DRISpinLockTimeout(&pDRIPriv->pSAREA->drawable_lock, 1, 10000); /*10 secs */ /* Call kernel flush outstanding buffers and relock */ - DRILock(pScreen, DRM_LOCK_QUIESCENT|DRM_LOCK_FLUSH_ALL); + DRILock(pScreen, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH_ALL); /* Switch back to our 2D context if the X context is hidden */ if (pDRIPriv->pDriverInfo->driverSwapMethod == DRI_HIDE_X_CONTEXT) { - /* hide X context by swapping 2D component here */ - (*pDRIPriv->pDriverInfo->SwapContext)(pScreen, - DRI_3D_SYNC, - DRI_2D_CONTEXT, - pDRIPriv->partial3DContextStore, - DRI_2D_CONTEXT, - pDRIPriv->hiddenContextStore); + /* hide X context by swapping 2D component here */ + (*pDRIPriv->pDriverInfo->SwapContext) (pScreen, + DRI_3D_SYNC, + DRI_2D_CONTEXT, + pDRIPriv->partial3DContextStore, + DRI_2D_CONTEXT, + pDRIPriv->hiddenContextStore); } } @@ -2061,21 +2060,22 @@ DRIValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) ScreenPtr pScreen = pParent->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - int returnValue = 1; /* always return 1, not checked by dix/window.c */ + int returnValue = 1; /* always return 1, not checked by dix/window.c */ - if(!pDRIPriv) return returnValue; + if (!pDRIPriv) + return returnValue; /* call lower wrapped functions */ - if(pDRIPriv->wrap.ValidateTree) { - /* unwrap */ - pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; + if (pDRIPriv->wrap.ValidateTree) { + /* unwrap */ + pScreen->ValidateTree = pDRIPriv->wrap.ValidateTree; - /* call lower layers */ - returnValue = (*pScreen->ValidateTree)(pParent, pChild, kind); + /* call lower layers */ + returnValue = (*pScreen->ValidateTree) (pParent, pChild, kind); - /* rewrap */ - pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; - pScreen->ValidateTree = DRIValidateTree; + /* rewrap */ + pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; + pScreen->ValidateTree = DRIValidateTree; } return returnValue; @@ -2088,22 +2088,24 @@ DRIPostValidateTree(WindowPtr pParent, WindowPtr pChild, VTKind kind) DRIScreenPrivPtr pDRIPriv; if (pParent) { - pScreen = pParent->drawable.pScreen; - } else { - pScreen = pChild->drawable.pScreen; + pScreen = pParent->drawable.pScreen; } - if(!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) return; + else { + pScreen = pChild->drawable.pScreen; + } + if (!(pDRIPriv = DRI_SCREEN_PRIV(pScreen))) + return; if (pDRIPriv->wrap.PostValidateTree) { - /* unwrap */ - pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; + /* unwrap */ + pScreen->PostValidateTree = pDRIPriv->wrap.PostValidateTree; - /* call lower layers */ - (*pScreen->PostValidateTree)(pParent, pChild, kind); + /* call lower layers */ + (*pScreen->PostValidateTree) (pParent, pChild, kind); - /* rewrap */ - pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; - pScreen->PostValidateTree = DRIPostValidateTree; + /* rewrap */ + pDRIPriv->wrap.PostValidateTree = pScreen->PostValidateTree; + pScreen->PostValidateTree = DRIPostValidateTree; } } @@ -2112,45 +2114,46 @@ DRIClipNotify(WindowPtr pWin, int dx, int dy) { ScreenPtr pScreen = pWin->drawable.pScreen; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv; + DRIDrawablePrivPtr pDRIDrawablePriv; - if(!pDRIPriv) return; + if (!pDRIPriv) + return; if ((pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin))) { int nrects = RegionNumRects(&pWin->clipList); - if(!pDRIPriv->windowsTouched) { + if (!pDRIPriv->windowsTouched) { DRILockTree(pScreen); pDRIPriv->windowsTouched = TRUE; } - if (nrects && !pDRIDrawablePriv->nrects) - DRIIncreaseNumberVisible(pScreen); - else if (!nrects && pDRIDrawablePriv->nrects) - DRIDecreaseNumberVisible(pScreen); - else - DRIDriverClipNotify(pScreen); + if (nrects && !pDRIDrawablePriv->nrects) + DRIIncreaseNumberVisible(pScreen); + else if (!nrects && pDRIDrawablePriv->nrects) + DRIDecreaseNumberVisible(pScreen); + else + DRIDriverClipNotify(pScreen); - pDRIDrawablePriv->nrects = nrects; + pDRIDrawablePriv->nrects = nrects; - pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp - = DRIDrawableValidationStamp++; + pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp + = DRIDrawableValidationStamp++; - drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, - DRM_DRAWABLE_CLIPRECTS, - nrects, RegionRects(&pWin->clipList)); + drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, + DRM_DRAWABLE_CLIPRECTS, + nrects, RegionRects(&pWin->clipList)); } /* call lower wrapped functions */ - if(pDRIPriv->wrap.ClipNotify) { + if (pDRIPriv->wrap.ClipNotify) { - /* unwrap */ + /* unwrap */ pScreen->ClipNotify = pDRIPriv->wrap.ClipNotify; - /* call lower layers */ - (*pScreen->ClipNotify)(pWin, dx, dy); + /* call lower layers */ + (*pScreen->ClipNotify) (pWin, dx, dy); - /* rewrap */ + /* rewrap */ pDRIPriv->wrap.ClipNotify = pScreen->ClipNotify; pScreen->ClipNotify = DRIClipNotify; } @@ -2165,10 +2168,10 @@ DRIGetDrawableIndex(WindowPtr pWin) CARD32 index; if (pDRIDrawablePriv) { - index = pDRIDrawablePriv->drawableIndex; + index = pDRIDrawablePriv->drawableIndex; } else { - index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry; + index = pDRIPriv->pDriverInfo->ddxDrawableTableEntry; } return index; @@ -2178,16 +2181,16 @@ unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, CARD32 drawable_index) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + return pDRIPriv->pSAREA->drawableTable[drawable_index].stamp; } - void DRIPrintDrawableLock(ScreenPtr pScreen, char *msg) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock); + ErrorF("%s: %d\n", msg, pDRIPriv->pSAREA->drawable_lock.lock); } void @@ -2195,18 +2198,20 @@ DRILock(ScreenPtr pScreen, int flags) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if(!pDRIPriv || !pDRIPriv->pLockRefCount) return; + if (!pDRIPriv || !pDRIPriv->pLockRefCount) + return; if (!*pDRIPriv->pLockRefCount) { - DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, flags); - *pDRIPriv->pLockingContext = pDRIPriv->myContext; - } else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[DRI] Locking deadlock.\n" - "\tAlready locked with context %d,\n" - "\ttrying to lock with context %d.\n", - pDRIPriv->pLockingContext, - pDRIPriv->myContext); + DRM_LOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext, + flags); + *pDRIPriv->pLockingContext = pDRIPriv->myContext; + } + else if (*pDRIPriv->pLockingContext != pDRIPriv->myContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Locking deadlock.\n" + "\tAlready locked with context %d,\n" + "\ttrying to lock with context %d.\n", + pDRIPriv->pLockingContext, pDRIPriv->myContext); } (*pDRIPriv->pLockRefCount)++; } @@ -2216,23 +2221,24 @@ DRIUnlock(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if(!pDRIPriv || !pDRIPriv->pLockRefCount) return; + if (!pDRIPriv || !pDRIPriv->pLockRefCount) + return; if (*pDRIPriv->pLockRefCount > 0) { - if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) { - DRIDrvMsg(pScreen->myNum, X_ERROR, - "[DRI] Unlocking inconsistency:\n" - "\tContext %d trying to unlock lock held by context %d\n", - pDRIPriv->pLockingContext, - pDRIPriv->myContext); - } - (*pDRIPriv->pLockRefCount)--; - } else { + if (pDRIPriv->myContext != *pDRIPriv->pLockingContext) { + DRIDrvMsg(pScreen->myNum, X_ERROR, + "[DRI] Unlocking inconsistency:\n" + "\tContext %d trying to unlock lock held by context %d\n", + pDRIPriv->pLockingContext, pDRIPriv->myContext); + } + (*pDRIPriv->pLockRefCount)--; + } + else { DRIDrvMsg(pScreen->myNum, X_ERROR, - "DRIUnlock called when not locked.\n"); + "DRIUnlock called when not locked.\n"); return; } - if (! *pDRIPriv->pLockRefCount) + if (!*pDRIPriv->pLockRefCount) DRM_UNLOCK(pDRIPriv->drmFD, pDRIPriv->pLSAREA, pDRIPriv->myContext); } @@ -2240,30 +2246,35 @@ void * DRIGetSAREAPrivate(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (!pDRIPriv) return 0; - return (void *)(((char*)pDRIPriv->pSAREA)+sizeof(XF86DRISAREARec)); + if (!pDRIPriv) + return 0; + + return (void *) (((char *) pDRIPriv->pSAREA) + sizeof(XF86DRISAREARec)); } drm_context_t DRIGetContext(ScreenPtr pScreen) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (!pDRIPriv) return 0; + + if (!pDRIPriv) + return 0; return pDRIPriv->myContext; } void DRIGetTexOffsetFuncs(ScreenPtr pScreen, - DRITexOffsetStartProcPtr *texOffsetStartFunc, - DRITexOffsetFinishProcPtr *texOffsetFinishFunc) + DRITexOffsetStartProcPtr * texOffsetStartFunc, + DRITexOffsetFinishProcPtr * texOffsetFinishFunc) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - if (!pDRIPriv) return; + if (!pDRIPriv) + return; - *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart; + *texOffsetStartFunc = pDRIPriv->pDriverInfo->texOffsetStart; *texOffsetFinishFunc = pDRIPriv->pDriverInfo->texOffsetFinish; } @@ -2279,9 +2290,7 @@ DRIGetWrappedFuncs(ScreenPtr pScreen) /* note that this returns the library version, not the protocol version */ void -DRIQueryVersion(int *majorVersion, - int *minorVersion, - int *patchVersion) +DRIQueryVersion(int *majorVersion, int *minorVersion, int *patchVersion) { *majorVersion = DRIINFO_MAJOR_VERSION; *minorVersion = DRIINFO_MINOR_VERSION; @@ -2291,51 +2300,57 @@ DRIQueryVersion(int *majorVersion, static void _DRIAdjustFrame(ScrnInfoPtr pScrn, DRIScreenPrivPtr pDRIPriv, int x, int y) { - pDRIPriv->pSAREA->frame.x = x; - pDRIPriv->pSAREA->frame.y = y; - pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1; + pDRIPriv->pSAREA->frame.x = x; + pDRIPriv->pSAREA->frame.y = y; + pDRIPriv->pSAREA->frame.width = pScrn->frameX1 - x + 1; pDRIPriv->pSAREA->frame.height = pScrn->frameY1 - y + 1; } void DRIAdjustFrame(int scrnIndex, int x, int y, int flags) { - ScreenPtr pScreen = screenInfo.screens[scrnIndex]; + ScreenPtr pScreen = screenInfo.screens[scrnIndex]; DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - int px, py; + ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; + int px, py; if (!pDRIPriv || !pDRIPriv->pSAREA) { - DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n", - pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL); - return; + DRIDrvMsg(scrnIndex, X_ERROR, "[DRI] No SAREA (%p %p)\n", + pDRIPriv, pDRIPriv ? pDRIPriv->pSAREA : NULL); + return; } if (pDRIPriv->fullscreen) { - /* Fix up frame */ - pScrn->frameX0 = pDRIPriv->pSAREA->frame.x; - pScrn->frameY0 = pDRIPriv->pSAREA->frame.y; - pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1; - pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1; - - /* Fix up cursor */ - miPointerGetPosition(inputInfo.pointer, &px, &py); - if (px < pScrn->frameX0) px = pScrn->frameX0; - if (px > pScrn->frameX1) px = pScrn->frameX1; - if (py < pScrn->frameY0) py = pScrn->frameY0; - if (py > pScrn->frameY1) py = pScrn->frameY1; - pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE); - return; + /* Fix up frame */ + pScrn->frameX0 = pDRIPriv->pSAREA->frame.x; + pScrn->frameY0 = pDRIPriv->pSAREA->frame.y; + pScrn->frameX1 = pScrn->frameX0 + pDRIPriv->pSAREA->frame.width - 1; + pScrn->frameY1 = pScrn->frameY0 + pDRIPriv->pSAREA->frame.height - 1; + + /* Fix up cursor */ + miPointerGetPosition(inputInfo.pointer, &px, &py); + + if (px < pScrn->frameX0) + px = pScrn->frameX0; + if (px > pScrn->frameX1) + px = pScrn->frameX1; + if (py < pScrn->frameY0) + py = pScrn->frameY0; + if (py > pScrn->frameY1) + py = pScrn->frameY1; + pScreen->SetCursorPosition(inputInfo.pointer, pScreen, px, py, TRUE); + + return; } if (pDRIPriv->wrap.AdjustFrame) { - /* unwrap */ - pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; - /* call lower layers */ - (*pScrn->AdjustFrame)(scrnIndex, x, y, flags); - /* rewrap */ - pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; - pScrn->AdjustFrame = DRIAdjustFrame; + /* unwrap */ + pScrn->AdjustFrame = pDRIPriv->wrap.AdjustFrame; + /* call lower layers */ + (*pScrn->AdjustFrame) (scrnIndex, x, y, flags); + /* rewrap */ + pDRIPriv->wrap.AdjustFrame = pScrn->AdjustFrame; + pScrn->AdjustFrame = DRIAdjustFrame; } _DRIAdjustFrame(pScrn, pDRIPriv, x, y); @@ -2350,145 +2365,147 @@ DRIAdjustFrame(int scrnIndex, int x, int y, int flags) */ void -DRIMoveBuffersHelper( - ScreenPtr pScreen, - int dx, - int dy, - int *xdir, - int *ydir, - RegionPtr reg -) -{ - BoxPtr extents, pbox, firstBox, lastBox; - BoxRec tmpBox; - int y, nbox; - - extents = RegionExtents(reg); - nbox = RegionNumRects(reg); - pbox = RegionRects(reg); - - if((dy > 0) && (dy < (extents->y2 - extents->y1))) { - *ydir = -1; - if(nbox > 1) { - firstBox = pbox; - lastBox = pbox + nbox - 1; - while((unsigned long)firstBox < (unsigned long)lastBox) { - tmpBox = *firstBox; - *firstBox = *lastBox; - *lastBox = tmpBox; - firstBox++; - lastBox--; +DRIMoveBuffersHelper(ScreenPtr pScreen, + int dx, int dy, int *xdir, int *ydir, RegionPtr reg) +{ + BoxPtr extents, pbox, firstBox, lastBox; + BoxRec tmpBox; + int y, nbox; + + extents = RegionExtents(reg); + nbox = RegionNumRects(reg); + pbox = RegionRects(reg); + + if ((dy > 0) && (dy < (extents->y2 - extents->y1))) { + *ydir = -1; + if (nbox > 1) { + firstBox = pbox; + lastBox = pbox + nbox - 1; + while ((unsigned long) firstBox < (unsigned long) lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } } - } - } else *ydir = 1; - - if((dx > 0) && (dx < (extents->x2 - extents->x1))) { - *xdir = -1; - if(nbox > 1) { - firstBox = lastBox = pbox; - y = pbox->y1; - while(--nbox) { - pbox++; - if(pbox->y1 == y) lastBox++; - else { - while((unsigned long)firstBox < (unsigned long)lastBox) { - tmpBox = *firstBox; - *firstBox = *lastBox; - *lastBox = tmpBox; - firstBox++; - lastBox--; - } - - firstBox = lastBox = pbox; - y = pbox->y1; - } - } - while((unsigned long)firstBox < (unsigned long)lastBox) { - tmpBox = *firstBox; - *firstBox = *lastBox; - *lastBox = tmpBox; - firstBox++; - lastBox--; + } + else + *ydir = 1; + + if ((dx > 0) && (dx < (extents->x2 - extents->x1))) { + *xdir = -1; + if (nbox > 1) { + firstBox = lastBox = pbox; + y = pbox->y1; + while (--nbox) { + pbox++; + if (pbox->y1 == y) + lastBox++; + else { + while ((unsigned long) firstBox < (unsigned long) lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } + + firstBox = lastBox = pbox; + y = pbox->y1; + } + } + while ((unsigned long) firstBox < (unsigned long) lastBox) { + tmpBox = *firstBox; + *firstBox = *lastBox; + *lastBox = tmpBox; + firstBox++; + lastBox--; + } } - } - } else *xdir = 1; + } + else + *xdir = 1; } char * -DRICreatePCIBusID(const struct pci_device * dev) +DRICreatePCIBusID(const struct pci_device *dev) { char *busID; if (asprintf(&busID, "pci:%04x:%02x:%02x.%d", - dev->domain, dev->bus, dev->dev, dev->func) == -1) - return NULL; + dev->domain, dev->bus, dev->dev, dev->func) == -1) + return NULL; return busID; } -static void drmSIGIOHandler(int interrupt, void *closure) +static void +drmSIGIOHandler(int interrupt, void *closure) { unsigned long key; - void *value; - ssize_t count; - drm_ctx_t ctx; - typedef void (*_drmCallback)(int, void *, void *); - char buf[256]; - drm_context_t old; - drm_context_t new; - void *oldctx; - void *newctx; - char *pt; - drmHashEntry *entry; + void *value; + ssize_t count; + drm_ctx_t ctx; + typedef void (*_drmCallback) (int, void *, void *); + char buf[256]; + drm_context_t old; + drm_context_t new; + void *oldctx; + void *newctx; + char *pt; + drmHashEntry *entry; void *hash_table; hash_table = drmGetHashTable(); - if (!hash_table) return; + if (!hash_table) + return; if (drmHashFirst(hash_table, &key, &value)) { - entry = value; - do { + entry = value; + do { #if 0 - fprintf(stderr, "Trying %d\n", entry->fd); + fprintf(stderr, "Trying %d\n", entry->fd); #endif - if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) { - buf[count] = '\0'; + if ((count = read(entry->fd, buf, sizeof(buf) - 1)) > 0) { + buf[count] = '\0'; #if 0 - fprintf(stderr, "Got %s\n", buf); + fprintf(stderr, "Got %s\n", buf); #endif - for (pt = buf; *pt != ' '; ++pt); /* Find first space */ - ++pt; - old = strtol(pt, &pt, 0); - new = strtol(pt, NULL, 0); - oldctx = drmGetContextTag(entry->fd, old); - newctx = drmGetContextTag(entry->fd, new); + for (pt = buf; *pt != ' '; ++pt); /* Find first space */ + ++pt; + old = strtol(pt, &pt, 0); + new = strtol(pt, NULL, 0); + oldctx = drmGetContextTag(entry->fd, old); + newctx = drmGetContextTag(entry->fd, new); #if 0 - fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx); + fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx); #endif - ((_drmCallback)entry->f)(entry->fd, oldctx, newctx); - ctx.handle = new; - ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx); - } - } while (drmHashNext(hash_table, &key, &value)); + ((_drmCallback) entry->f) (entry->fd, oldctx, newctx); + ctx.handle = new; + ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx); + } + } while (drmHashNext(hash_table, &key, &value)); } } - -int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *)) +int +drmInstallSIGIOHandler(int fd, void (*f) (int, void *, void *)) { - drmHashEntry *entry; + drmHashEntry *entry; - entry = drmGetEntry(fd); - entry->f = f; + entry = drmGetEntry(fd); + entry->f = f; return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0); } -int drmRemoveSIGIOHandler(int fd) +int +drmRemoveSIGIOHandler(int fd) { - drmHashEntry *entry = drmGetEntry(fd); + drmHashEntry *entry = drmGetEntry(fd); entry->f = NULL; diff --git a/xorg-server/hw/xfree86/dri/dri.h b/xorg-server/hw/xfree86/dri/dri.h index f690e234b..53458bb4a 100644 --- a/xorg-server/hw/xfree86/dri/dri.h +++ b/xorg-server/hw/xfree86/dri/dri.h @@ -50,11 +50,10 @@ typedef int DRIContextType; typedef struct _DRIContextPrivRec DRIContextPrivRec, *DRIContextPrivPtr; -typedef enum _DRIContextFlags -{ - DRI_CONTEXT_2DONLY = 0x01, +typedef enum _DRIContextFlags { + DRI_CONTEXT_2DONLY = 0x01, DRI_CONTEXT_PRESERVED = 0x02, - DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ + DRI_CONTEXT_RESERVED = 0x04 /* DRI Only -- no kernel equivalent */ } DRIContextFlags; #define DRI_NO_CONTEXT 0 @@ -73,10 +72,8 @@ typedef int DRIWindowRequests; #define DRI_3D_WINDOWS_ONLY 1 #define DRI_ALL_WINDOWS 2 - -typedef void (*ClipNotifyPtr)( WindowPtr, int, int ); -typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags); - +typedef void (*ClipNotifyPtr) (WindowPtr, int, int); +typedef void (*AdjustFramePtr) (int scrnIndex, int x, int y, int flags); /* * These functions can be wrapped by the DRI. Each of these have @@ -84,17 +81,16 @@ typedef void (*AdjustFramePtr)(int scrnIndex, int x, int y, int flags); * overridden by the driver in its [driver]DRIScreenInit function. */ typedef struct { - ScreenWakeupHandlerProcPtr WakeupHandler; - ScreenBlockHandlerProcPtr BlockHandler; - WindowExposuresProcPtr WindowExposures; - CopyWindowProcPtr CopyWindow; - ValidateTreeProcPtr ValidateTree; - PostValidateTreeProcPtr PostValidateTree; - ClipNotifyProcPtr ClipNotify; - AdjustFramePtr AdjustFrame; + ScreenWakeupHandlerProcPtr WakeupHandler; + ScreenBlockHandlerProcPtr BlockHandler; + WindowExposuresProcPtr WindowExposures; + CopyWindowProcPtr CopyWindow; + ValidateTreeProcPtr ValidateTree; + PostValidateTreeProcPtr PostValidateTree; + ClipNotifyProcPtr ClipNotify; + AdjustFramePtr AdjustFrame; } DRIWrappedFuncsRec, *DRIWrappedFuncsPtr; - /* * Prior to Xorg 6.8.99.8, the DRIInfoRec structure was implicitly versioned * by the XF86DRI_*_VERSION defines in xf86dristr.h. These numbers were also @@ -112,8 +108,8 @@ typedef struct { #define DRIINFO_MINOR_VERSION 4 #define DRIINFO_PATCH_VERSION 0 -typedef unsigned long long (*DRITexOffsetStartProcPtr)(PixmapPtr pPix); -typedef void (*DRITexOffsetFinishProcPtr)(PixmapPtr pPix); +typedef unsigned long long (*DRITexOffsetStartProcPtr) (PixmapPtr pPix); +typedef void (*DRITexOffsetFinishProcPtr) (PixmapPtr pPix); typedef struct { /* driver call back functions @@ -123,88 +119,81 @@ typedef struct { * Bump the DRIINFO minor number to indicate new fields. * Bump the DRIINFO major number to indicate binary-incompatible changes. */ - Bool (*CreateContext)(ScreenPtr pScreen, - VisualPtr visual, - drm_context_t hHWContext, - void* pVisualConfigPriv, - DRIContextType context); - void (*DestroyContext)(ScreenPtr pScreen, - drm_context_t hHWContext, - DRIContextType context); - void (*SwapContext)(ScreenPtr pScreen, - DRISyncType syncType, - DRIContextType readContextType, - void* readContextStore, - DRIContextType writeContextType, - void* writeContextStore); - void (*InitBuffers)(WindowPtr pWin, - RegionPtr prgn, - CARD32 indx); - void (*MoveBuffers)(WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc, - CARD32 indx); - void (*TransitionTo3d)(ScreenPtr pScreen); - void (*TransitionTo2d)(ScreenPtr pScreen); - - void (*SetDrawableIndex)(WindowPtr pWin, CARD32 indx); - Bool (*OpenFullScreen)(ScreenPtr pScreen); - Bool (*CloseFullScreen)(ScreenPtr pScreen); + Bool (*CreateContext) (ScreenPtr pScreen, + VisualPtr visual, + drm_context_t hHWContext, + void *pVisualConfigPriv, DRIContextType context); + void (*DestroyContext) (ScreenPtr pScreen, + drm_context_t hHWContext, DRIContextType context); + void (*SwapContext) (ScreenPtr pScreen, + DRISyncType syncType, + DRIContextType readContextType, + void *readContextStore, + DRIContextType writeContextType, + void *writeContextStore); + void (*InitBuffers) (WindowPtr pWin, RegionPtr prgn, CARD32 indx); + void (*MoveBuffers) (WindowPtr pWin, + DDXPointRec ptOldOrg, RegionPtr prgnSrc, CARD32 indx); + void (*TransitionTo3d) (ScreenPtr pScreen); + void (*TransitionTo2d) (ScreenPtr pScreen); + + void (*SetDrawableIndex) (WindowPtr pWin, CARD32 indx); + Bool (*OpenFullScreen) (ScreenPtr pScreen); + Bool (*CloseFullScreen) (ScreenPtr pScreen); /* wrapped functions */ - DRIWrappedFuncsRec wrap; + DRIWrappedFuncsRec wrap; /* device info */ - char* drmDriverName; - char* clientDriverName; - char* busIdString; - int ddxDriverMajorVersion; - int ddxDriverMinorVersion; - int ddxDriverPatchVersion; - pointer frameBufferPhysicalAddress; - long frameBufferSize; - long frameBufferStride; - long SAREASize; - int maxDrawableTableEntry; - int ddxDrawableTableEntry; - long contextSize; - DRISwapMethod driverSwapMethod; - DRIWindowRequests bufferRequests; - int devPrivateSize; - void* devPrivate; - Bool createDummyCtx; - Bool createDummyCtxPriv; + char *drmDriverName; + char *clientDriverName; + char *busIdString; + int ddxDriverMajorVersion; + int ddxDriverMinorVersion; + int ddxDriverPatchVersion; + pointer frameBufferPhysicalAddress; + long frameBufferSize; + long frameBufferStride; + long SAREASize; + int maxDrawableTableEntry; + int ddxDrawableTableEntry; + long contextSize; + DRISwapMethod driverSwapMethod; + DRIWindowRequests bufferRequests; + int devPrivateSize; + void *devPrivate; + Bool createDummyCtx; + Bool createDummyCtxPriv; /* New with DRI version 4.1.0 */ - void (*TransitionSingleToMulti3D)(ScreenPtr pScreen); - void (*TransitionMultiToSingle3D)(ScreenPtr pScreen); + void (*TransitionSingleToMulti3D) (ScreenPtr pScreen); + void (*TransitionMultiToSingle3D) (ScreenPtr pScreen); /* New with DRI version 5.1.0 */ - void (*ClipNotify)(ScreenPtr pScreen, WindowPtr *ppWin, int num); + void (*ClipNotify) (ScreenPtr pScreen, WindowPtr *ppWin, int num); /* New with DRI version 5.2.0 */ - Bool allocSarea; - Bool keepFDOpen; + Bool allocSarea; + Bool keepFDOpen; /* New with DRI version 5.3.0 */ - DRITexOffsetStartProcPtr texOffsetStart; + DRITexOffsetStartProcPtr texOffsetStart; DRITexOffsetFinishProcPtr texOffsetFinish; /* New with DRI version 5.4.0 */ - int dontMapFrameBuffer; - drm_handle_t hFrameBuffer; /* Handle to framebuffer, either - * mapped by DDX driver or DRI */ - -} DRIInfoRec, *DRIInfoPtr; + int dontMapFrameBuffer; + drm_handle_t hFrameBuffer; /* Handle to framebuffer, either + * mapped by DDX driver or DRI */ +} DRIInfoRec, *DRIInfoPtr; -extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, unsigned long sAreaSize, - const char *busID, - const char *drmDriverName); +extern _X_EXPORT Bool DRIOpenDRMMaster(ScrnInfoPtr pScrn, + unsigned long sAreaSize, + const char *busID, + const char *drmDriverName); extern _X_EXPORT Bool DRIScreenInit(ScreenPtr pScreen, - DRIInfoPtr pDRIInfo, - int *pDRMFD); + DRIInfoPtr pDRIInfo, int *pDRMFD); extern _X_EXPORT void DRICloseScreen(ScreenPtr pScreen); @@ -213,65 +202,62 @@ extern _X_EXPORT Bool DRIExtensionInit(void); extern _X_EXPORT void DRIReset(void); extern _X_EXPORT Bool DRIQueryDirectRenderingCapable(ScreenPtr pScreen, - Bool *isCapable); + Bool *isCapable); extern _X_EXPORT Bool DRIOpenConnection(ScreenPtr pScreen, - drm_handle_t * hSAREA, - char **busIdString); + drm_handle_t * hSAREA, + char **busIdString); extern _X_EXPORT Bool DRIAuthConnection(ScreenPtr pScreen, drm_magic_t magic); extern _X_EXPORT Bool DRICloseConnection(ScreenPtr pScreen); extern _X_EXPORT Bool DRIGetClientDriverName(ScreenPtr pScreen, - int* ddxDriverMajorVersion, - int* ddxDriverMinorVersion, - int* ddxDriverPatchVersion, - char** clientDriverName); + int *ddxDriverMajorVersion, + int *ddxDriverMinorVersion, + int *ddxDriverPatchVersion, + char **clientDriverName); extern _X_EXPORT Bool DRICreateContext(ScreenPtr pScreen, - VisualPtr visual, - XID context, - drm_context_t * pHWContext); + VisualPtr visual, + XID context, drm_context_t * pHWContext); extern _X_EXPORT Bool DRIDestroyContext(ScreenPtr pScreen, XID context); extern _X_EXPORT Bool DRIContextPrivDelete(pointer pResource, XID id); extern _X_EXPORT Bool DRICreateDrawable(ScreenPtr pScreen, - ClientPtr client, - DrawablePtr pDrawable, - drm_drawable_t * hHWDrawable); + ClientPtr client, + DrawablePtr pDrawable, + drm_drawable_t * hHWDrawable); extern _X_EXPORT Bool DRIDestroyDrawable(ScreenPtr pScreen, - ClientPtr client, - DrawablePtr pDrawable); + ClientPtr client, + DrawablePtr pDrawable); -extern _X_EXPORT Bool DRIDrawablePrivDelete(pointer pResource, - XID id); +extern _X_EXPORT Bool DRIDrawablePrivDelete(pointer pResource, XID id); extern _X_EXPORT Bool DRIGetDrawableInfo(ScreenPtr pScreen, - DrawablePtr pDrawable, - unsigned int* indx, - unsigned int* stamp, - int* X, - int* Y, - int* W, - int* H, - int* numClipRects, - drm_clip_rect_t ** pClipRects, - int* backX, - int* backY, - int* numBackClipRects, - drm_clip_rect_t ** pBackClipRects); + DrawablePtr pDrawable, + unsigned int *indx, + unsigned int *stamp, + int *X, + int *Y, + int *W, + int *H, + int *numClipRects, + drm_clip_rect_t ** pClipRects, + int *backX, + int *backY, + int *numBackClipRects, + drm_clip_rect_t ** pBackClipRects); extern _X_EXPORT Bool DRIGetDeviceInfo(ScreenPtr pScreen, - drm_handle_t * hFrameBuffer, - int* fbOrigin, - int* fbSize, - int* fbStride, - int* devPrivateSize, - void** pDevPrivate); + drm_handle_t * hFrameBuffer, + int *fbOrigin, + int *fbSize, + int *fbStride, + int *devPrivateSize, void **pDevPrivate); extern _X_EXPORT DRIInfoPtr DRICreateInfoRec(void); @@ -280,50 +266,39 @@ extern _X_EXPORT void DRIDestroyInfoRec(DRIInfoPtr DRIInfo); extern _X_EXPORT Bool DRIFinishScreenInit(ScreenPtr pScreen); extern _X_EXPORT void DRIWakeupHandler(pointer wakeupData, - int result, - pointer pReadmask); + int result, pointer pReadmask); extern _X_EXPORT void DRIBlockHandler(pointer blockData, - OSTimePtr pTimeout, - pointer pReadmask); + OSTimePtr pTimeout, pointer pReadmask); extern _X_EXPORT void DRIDoWakeupHandler(int screenNum, - pointer wakeupData, - unsigned long result, - pointer pReadmask); + pointer wakeupData, + unsigned long result, + pointer pReadmask); extern _X_EXPORT void DRIDoBlockHandler(int screenNum, - pointer blockData, - pointer pTimeout, - pointer pReadmask); + pointer blockData, + pointer pTimeout, pointer pReadmask); -extern _X_EXPORT void DRISwapContext(int drmFD, - void *oldctx, - void *newctx); +extern _X_EXPORT void DRISwapContext(int drmFD, void *oldctx, void *newctx); extern _X_EXPORT void *DRIGetContextStore(DRIContextPrivPtr context); extern _X_EXPORT void DRIWindowExposures(WindowPtr pWin, - RegionPtr prgn, - RegionPtr bsreg); + RegionPtr prgn, RegionPtr bsreg); extern _X_EXPORT Bool DRIDestroyWindow(WindowPtr pWin); extern _X_EXPORT void DRICopyWindow(WindowPtr pWin, - DDXPointRec ptOldOrg, - RegionPtr prgnSrc); + DDXPointRec ptOldOrg, RegionPtr prgnSrc); extern _X_EXPORT int DRIValidateTree(WindowPtr pParent, - WindowPtr pChild, - VTKind kind); + WindowPtr pChild, VTKind kind); extern _X_EXPORT void DRIPostValidateTree(WindowPtr pParent, - WindowPtr pChild, - VTKind kind); + WindowPtr pChild, VTKind kind); -extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, - int dx, - int dy); +extern _X_EXPORT void DRIClipNotify(WindowPtr pWin, int dx, int dy); extern _X_EXPORT CARD32 DRIGetDrawableIndex(WindowPtr pWin); @@ -338,36 +313,38 @@ extern _X_EXPORT DRIWrappedFuncsRec *DRIGetWrappedFuncs(ScreenPtr pScreen); extern _X_EXPORT void *DRIGetSAREAPrivate(ScreenPtr pScreen); extern _X_EXPORT unsigned int DRIGetDrawableStamp(ScreenPtr pScreen, - CARD32 drawable_index); + CARD32 drawable_index); extern _X_EXPORT DRIContextPrivPtr DRICreateContextPriv(ScreenPtr pScreen, - drm_context_t * pHWContext, - DRIContextFlags flags); - -extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr pScreen, - drm_context_t hHWContext, + drm_context_t * + pHWContext, DRIContextFlags flags); +extern _X_EXPORT DRIContextPrivPtr DRICreateContextPrivFromHandle(ScreenPtr + pScreen, + drm_context_t + hHWContext, + DRIContextFlags + flags); + extern _X_EXPORT Bool DRIDestroyContextPriv(DRIContextPrivPtr pDRIContextPriv); extern _X_EXPORT drm_context_t DRIGetContext(ScreenPtr pScreen); extern _X_EXPORT void DRIQueryVersion(int *majorVersion, - int *minorVersion, - int *patchVersion); + int *minorVersion, int *patchVersion); extern _X_EXPORT void DRIAdjustFrame(int scrnIndex, int x, int y, int flags); extern _X_EXPORT void DRIMoveBuffersHelper(ScreenPtr pScreen, - int dx, - int dy, - int *xdir, - int *ydir, - RegionPtr reg); + int dx, + int dy, + int *xdir, int *ydir, RegionPtr reg); extern _X_EXPORT char *DRICreatePCIBusID(const struct pci_device *PciInfo); -extern _X_EXPORT int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *)); +extern _X_EXPORT int drmInstallSIGIOHandler(int fd, + void (*f) (int, void *, void *)); extern _X_EXPORT int drmRemoveSIGIOHandler(int fd); extern _X_EXPORT int DRIMasterFD(ScrnInfoPtr pScrn); @@ -376,8 +353,10 @@ extern _X_EXPORT void *DRIMasterSareaPointer(ScrnInfoPtr pScrn); extern _X_EXPORT drm_handle_t DRIMasterSareaHandle(ScrnInfoPtr pScrn); extern _X_EXPORT void DRIGetTexOffsetFuncs(ScreenPtr pScreen, - DRITexOffsetStartProcPtr *texOffsetStartFunc, - DRITexOffsetFinishProcPtr *texOffsetFinishFunc); + DRITexOffsetStartProcPtr * + texOffsetStartFunc, + DRITexOffsetFinishProcPtr * + texOffsetFinishFunc); #define _DRI_H_ diff --git a/xorg-server/hw/xfree86/dri/drimodule.c b/xorg-server/hw/xfree86/dri/drimodule.c index 28f6ad8c0..83eca4eb9 100644 --- a/xorg-server/hw/xfree86/dri/drimodule.c +++ b/xorg-server/hw/xfree86/dri/drimodule.c @@ -44,26 +44,25 @@ static MODULESETUPPROTO(driSetup); drmServerInfo DRIDRMServerInfo; -static XF86ModuleVersionInfo VersRec = -{ - "dri", - MODULEVENDORSTRING, - MODINFOSTRING1, - MODINFOSTRING2, - XORG_VERSION_CURRENT, - 1, 0, 0, - ABI_CLASS_EXTENSION, - ABI_EXTENSION_VERSION, - MOD_CLASS_NONE, - {0,0,0,0} +static XF86ModuleVersionInfo VersRec = { + "dri", + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + 1, 0, 0, + ABI_CLASS_EXTENSION, + ABI_EXTENSION_VERSION, + MOD_CLASS_NONE, + {0, 0, 0, 0} }; extern void XFree86DRIExtensionInit(INITARGS); + #define _XF86DRI_SERVER_ #include <X11/dri/xf86driproto.h> -static ExtensionModule XF86DRIExt = -{ +static ExtensionModule XF86DRIExt = { XFree86DRIExtensionInit, XF86DRINAME, &noXFree86DRIExtension, @@ -79,15 +78,16 @@ driSetup(pointer module, pointer opts, int *errmaj, int *errmin) static Bool setupDone = FALSE; if (!setupDone) { - setupDone = TRUE; - LoadExtension(&XF86DRIExt, FALSE); - } else { - if (errmaj) *errmaj = LDR_ONCEONLY; + setupDone = TRUE; + LoadExtension(&XF86DRIExt, FALSE); + } + else { + if (errmaj) + *errmaj = LDR_ONCEONLY; } drmSetServerInfo(&DRIDRMServerInfo); /* Need a non-NULL return value to indicate success */ - return (pointer)1; + return (pointer) 1; } - diff --git a/xorg-server/hw/xfree86/dri/dristruct.h b/xorg-server/hw/xfree86/dri/dristruct.h index bbd158e11..9f944a793 100644 --- a/xorg-server/hw/xfree86/dri/dristruct.h +++ b/xorg-server/hw/xfree86/dri/dristruct.h @@ -1,129 +1,124 @@ -/**************************************************************************
-
-Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
-All Rights Reserved.
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sub license, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
-
-The above copyright notice and this permission notice (including the
-next paragraph) shall be included in all copies or substantial portions
-of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
-IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
-ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-**************************************************************************/
-
-/*
- * Authors:
- * Jens Owen <jens@tungstengraphics.com>
- *
- */
-
-#ifndef DRI_STRUCT_H
-#define DRI_STRUCT_H
-
-#include "xf86drm.h"
-#include "xf86Crtc.h"
-
-
-#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey))
-#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \
- dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey))
-
-typedef struct _DRIDrawablePrivRec
-{
- drm_drawable_t hwDrawable;
- int drawableIndex;
- ScreenPtr pScreen;
- int refCount;
- int nrects;
-} DRIDrawablePrivRec, *DRIDrawablePrivPtr;
-
-struct _DRIContextPrivRec
-{
- drm_context_t hwContext;
- ScreenPtr pScreen;
- Bool valid3D;
- DRIContextFlags flags;
- void** pContextStore;
-};
-
-#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \
- (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \
- dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL))
-
-#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \
- dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \
- DRIScreenPrivKey))
-
-#define DRI_ENT_PRIV(pScrn) \
- ((DRIEntPrivIndex < 0) ? \
- NULL: \
- ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \
- DRIEntPrivIndex)->ptr)))
-
-typedef struct _DRIScreenPrivRec
-{
- Bool directRenderingSupport;
- int drmFD; /* File descriptor for /dev/video/? */
- drm_handle_t hSAREA; /* Handle to SAREA, for mapping */
- XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */
- drm_context_t myContext; /* DDX Driver's context */
- DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */
- DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */
- void** hiddenContextStore; /* hidden X context */
- void** partial3DContextStore; /* parital 3D context */
- DRIInfoPtr pDriverInfo;
- int nrWindows;
- int nrWindowsVisible;
- int nrWalked;
- drm_clip_rect_t private_buffer_rect; /* management of private buffers */
- DrawablePtr fullscreen; /* pointer to fullscreen drawable */
- drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */
- DRIWrappedFuncsRec wrap;
- DestroyWindowProcPtr DestroyWindow;
- DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES];
- DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */
- Bool createDummyCtx;
- Bool createDummyCtxPriv;
- Bool grabbedDRILock;
- Bool drmSIGIOHandlerInstalled;
- Bool wrapped;
- Bool windowsTouched;
- int lockRefCount;
- drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */
- XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */
- int* pLockRefCount;
- int* pLockingContext;
- xf86_crtc_notify_proc_ptr xf86_crtc_notify;
-} DRIScreenPrivRec, *DRIScreenPrivPtr;
-
-
-typedef struct _DRIEntPrivRec {
- int drmFD;
- Bool drmOpened;
- Bool sAreaGrabbed;
- drm_handle_t hLSAREA;
- XF86DRILSAREAPtr pLSAREA;
- unsigned long sAreaSize;
- int lockRefCount;
- int lockingContext;
- ScreenPtr resOwner;
- Bool keepFDOpen;
- int refCount;
-} DRIEntPrivRec, *DRIEntPrivPtr;
-
-#endif /* DRI_STRUCT_H */
+/************************************************************************** + +Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. +All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sub license, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice (including the +next paragraph) shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. +IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR +ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +**************************************************************************/ + +/* + * Authors: + * Jens Owen <jens@tungstengraphics.com> + * + */ + +#ifndef DRI_STRUCT_H +#define DRI_STRUCT_H + +#include "xf86drm.h" +#include "xf86Crtc.h" + +#define DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pWin)->devPrivates, DRIWindowPrivKey)) +#define DRI_DRAWABLE_PRIV_FROM_PIXMAP(pPix) ((DRIDrawablePrivPtr) \ + dixLookupPrivate(&(pPix)->devPrivates, DRIWindowPrivKey)) + +typedef struct _DRIDrawablePrivRec { + drm_drawable_t hwDrawable; + int drawableIndex; + ScreenPtr pScreen; + int refCount; + int nrects; +} DRIDrawablePrivRec, *DRIDrawablePrivPtr; + +struct _DRIContextPrivRec { + drm_context_t hwContext; + ScreenPtr pScreen; + Bool valid3D; + DRIContextFlags flags; + void **pContextStore; +}; + +#define DRI_SCREEN_PRIV(pScreen) ((DRIScreenPrivPtr) \ + (dixPrivateKeyRegistered(DRIScreenPrivKey) ? \ + dixLookupPrivate(&(pScreen)->devPrivates, DRIScreenPrivKey) : NULL)) + +#define DRI_SCREEN_PRIV_FROM_INDEX(screenIndex) ((DRIScreenPrivPtr) \ + dixLookupPrivate(&screenInfo.screens[screenIndex]->devPrivates, \ + DRIScreenPrivKey)) + +#define DRI_ENT_PRIV(pScrn) \ + ((DRIEntPrivIndex < 0) ? \ + NULL: \ + ((DRIEntPrivPtr)(xf86GetEntityPrivate((pScrn)->entityList[0], \ + DRIEntPrivIndex)->ptr))) + +typedef struct _DRIScreenPrivRec { + Bool directRenderingSupport; + int drmFD; /* File descriptor for /dev/video/? */ + drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ + XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ + drm_context_t myContext; /* DDX Driver's context */ + DRIContextPrivPtr myContextPriv; /* Pointer to server's private area */ + DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ + void **hiddenContextStore; /* hidden X context */ + void **partial3DContextStore; /* parital 3D context */ + DRIInfoPtr pDriverInfo; + int nrWindows; + int nrWindowsVisible; + int nrWalked; + drm_clip_rect_t private_buffer_rect; /* management of private buffers */ + DrawablePtr fullscreen; /* pointer to fullscreen drawable */ + drm_clip_rect_t fullscreen_rect; /* fake rect for fullscreen mode */ + DRIWrappedFuncsRec wrap; + DestroyWindowProcPtr DestroyWindow; + DrawablePtr DRIDrawables[SAREA_MAX_DRAWABLES]; + DRIContextPrivPtr dummyCtxPriv; /* Pointer to dummy context */ + Bool createDummyCtx; + Bool createDummyCtxPriv; + Bool grabbedDRILock; + Bool drmSIGIOHandlerInstalled; + Bool wrapped; + Bool windowsTouched; + int lockRefCount; + drm_handle_t hLSAREA; /* Handle to SAREA containing lock, for mapping */ + XF86DRILSAREAPtr pLSAREA; /* Mapped pointer to SAREA containing lock */ + int *pLockRefCount; + int *pLockingContext; + xf86_crtc_notify_proc_ptr xf86_crtc_notify; +} DRIScreenPrivRec, *DRIScreenPrivPtr; + +typedef struct _DRIEntPrivRec { + int drmFD; + Bool drmOpened; + Bool sAreaGrabbed; + drm_handle_t hLSAREA; + XF86DRILSAREAPtr pLSAREA; + unsigned long sAreaSize; + int lockRefCount; + int lockingContext; + ScreenPtr resOwner; + Bool keepFDOpen; + int refCount; +} DRIEntPrivRec, *DRIEntPrivPtr; + +#endif /* DRI_STRUCT_H */ diff --git a/xorg-server/hw/xfree86/dri/xf86dri.c b/xorg-server/hw/xfree86/dri/xf86dri.c index c35ba2f94..72ce8690d 100644 --- a/xorg-server/hw/xfree86/dri/xf86dri.c +++ b/xorg-server/hw/xfree86/dri/xf86dri.c @@ -63,27 +63,20 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. static int DRIErrorBase; - - -static void XF86DRIResetProc(ExtensionEntry* extEntry); +static void XF86DRIResetProc(ExtensionEntry * extEntry); static unsigned char DRIReqCode = 0; extern void XFree86DRIExtensionInit(void); -/*ARGSUSED*/ -static void -XF86DRIResetProc ( - ExtensionEntry* extEntry -) + /*ARGSUSED*/ static void +XF86DRIResetProc(ExtensionEntry * extEntry) { DRIReset(); } static int -ProcXF86DRIQueryVersion( - register ClientPtr client -) +ProcXF86DRIQueryVersion(register ClientPtr client) { xXF86DRIQueryVersionReply rep; @@ -95,109 +88,105 @@ ProcXF86DRIQueryVersion( rep.minorVersion = SERVER_XF86DRI_MINOR_VERSION; rep.patchVersion = SERVER_XF86DRI_PATCH_VERSION; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); - swaps(&rep.majorVersion); - swaps(&rep.minorVersion); - swapl(&rep.patchVersion); + swaps(&rep.sequenceNumber); + swapl(&rep.length); + swaps(&rep.majorVersion); + swaps(&rep.minorVersion); + swapl(&rep.patchVersion); } - WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRIQueryVersionReply), (char *) &rep); return Success; } static int -ProcXF86DRIQueryDirectRenderingCapable( - register ClientPtr client -) +ProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) { - xXF86DRIQueryDirectRenderingCapableReply rep; + xXF86DRIQueryDirectRenderingCapableReply rep; Bool isCapable; REQUEST(xXF86DRIQueryDirectRenderingCapableReq); REQUEST_SIZE_MATCH(xXF86DRIQueryDirectRenderingCapableReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - if (!DRIQueryDirectRenderingCapable( screenInfo.screens[stuff->screen], - &isCapable)) { - return BadValue; + if (!DRIQueryDirectRenderingCapable(screenInfo.screens[stuff->screen], + &isCapable)) { + return BadValue; } rep.isCapable = isCapable; if (!LocalClient(client) || client->swapped) - rep.isCapable = 0; + rep.isCapable = 0; if (client->swapped) { - swaps(&rep.sequenceNumber); - swapl(&rep.length); + swaps(&rep.sequenceNumber); + swapl(&rep.length); } - WriteToClient(client, - sizeof(xXF86DRIQueryDirectRenderingCapableReply), (char *)&rep); + WriteToClient(client, + sizeof(xXF86DRIQueryDirectRenderingCapableReply), + (char *) &rep); return Success; } static int -ProcXF86DRIOpenConnection( - register ClientPtr client -) +ProcXF86DRIOpenConnection(register ClientPtr client) { xXF86DRIOpenConnectionReply rep; - drm_handle_t hSAREA; - char* busIdString; + drm_handle_t hSAREA; + char *busIdString; REQUEST(xXF86DRIOpenConnectionReq); REQUEST_SIZE_MATCH(xXF86DRIOpenConnectionReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } - if (!DRIOpenConnection( screenInfo.screens[stuff->screen], - &hSAREA, - &busIdString)) { - return BadValue; + if (!DRIOpenConnection(screenInfo.screens[stuff->screen], + &hSAREA, &busIdString)) { + return BadValue; } rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.busIdStringLength = 0; if (busIdString) - rep.busIdStringLength = strlen(busIdString); - rep.length = bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - SIZEOF(xGenericReply) + - pad_to_int32(rep.busIdStringLength)); + rep.busIdStringLength = strlen(busIdString); + rep.length = + bytes_to_int32(SIZEOF(xXF86DRIOpenConnectionReply) - + SIZEOF(xGenericReply) + + pad_to_int32(rep.busIdStringLength)); - rep.hSAREALow = (CARD32)(hSAREA & 0xffffffff); + rep.hSAREALow = (CARD32) (hSAREA & 0xffffffff); #if defined(LONG64) && !defined(__linux__) - rep.hSAREAHigh = (CARD32)(hSAREA >> 32); + rep.hSAREAHigh = (CARD32) (hSAREA >> 32); #else rep.hSAREAHigh = 0; #endif - WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRIOpenConnectionReply), (char *) &rep); if (rep.busIdStringLength) - WriteToClient(client, rep.busIdStringLength, busIdString); + WriteToClient(client, rep.busIdStringLength, busIdString); return Success; } static int -ProcXF86DRIAuthConnection( - register ClientPtr client -) +ProcXF86DRIAuthConnection(register ClientPtr client) { xXF86DRIAuthConnectionReply rep; - + REQUEST(xXF86DRIAuthConnectionReq); REQUEST_SIZE_MATCH(xXF86DRIAuthConnectionReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; @@ -205,83 +194,75 @@ ProcXF86DRIAuthConnection( rep.sequenceNumber = client->sequence; rep.authenticated = 1; - if (!DRIAuthConnection( screenInfo.screens[stuff->screen], stuff->magic)) { - ErrorF("Failed to authenticate %lu\n", (unsigned long)stuff->magic); - rep.authenticated = 0; + if (!DRIAuthConnection(screenInfo.screens[stuff->screen], stuff->magic)) { + ErrorF("Failed to authenticate %lu\n", (unsigned long) stuff->magic); + rep.authenticated = 0; } - WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRIAuthConnectionReply), (char *) &rep); return Success; } static int -ProcXF86DRICloseConnection( - register ClientPtr client -) +ProcXF86DRICloseConnection(register ClientPtr client) { REQUEST(xXF86DRICloseConnectionReq); REQUEST_SIZE_MATCH(xXF86DRICloseConnectionReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } - DRICloseConnection( screenInfo.screens[stuff->screen]); + DRICloseConnection(screenInfo.screens[stuff->screen]); return Success; } static int -ProcXF86DRIGetClientDriverName( - register ClientPtr client -) +ProcXF86DRIGetClientDriverName(register ClientPtr client) { - xXF86DRIGetClientDriverNameReply rep; - char* clientDriverName; + xXF86DRIGetClientDriverNameReply rep; + char *clientDriverName; REQUEST(xXF86DRIGetClientDriverNameReq); REQUEST_SIZE_MATCH(xXF86DRIGetClientDriverNameReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } - DRIGetClientDriverName( screenInfo.screens[stuff->screen], - (int *)&rep.ddxDriverMajorVersion, - (int *)&rep.ddxDriverMinorVersion, - (int *)&rep.ddxDriverPatchVersion, - &clientDriverName); + DRIGetClientDriverName(screenInfo.screens[stuff->screen], + (int *) &rep.ddxDriverMajorVersion, + (int *) &rep.ddxDriverMinorVersion, + (int *) &rep.ddxDriverPatchVersion, + &clientDriverName); rep.type = X_Reply; rep.sequenceNumber = client->sequence; rep.clientDriverNameLength = 0; if (clientDriverName) - rep.clientDriverNameLength = strlen(clientDriverName); + rep.clientDriverNameLength = strlen(clientDriverName); rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetClientDriverNameReply) - - SIZEOF(xGenericReply) + - pad_to_int32(rep.clientDriverNameLength)); + SIZEOF(xGenericReply) + + pad_to_int32(rep.clientDriverNameLength)); - WriteToClient(client, - sizeof(xXF86DRIGetClientDriverNameReply), (char *)&rep); + WriteToClient(client, + sizeof(xXF86DRIGetClientDriverNameReply), (char *) &rep); if (rep.clientDriverNameLength) - WriteToClient(client, - rep.clientDriverNameLength, - clientDriverName); + WriteToClient(client, rep.clientDriverNameLength, clientDriverName); return Success; } static int -ProcXF86DRICreateContext( - register ClientPtr client -) +ProcXF86DRICreateContext(register ClientPtr client) { - xXF86DRICreateContextReply rep; + xXF86DRICreateContextReply rep; ScreenPtr pScreen; REQUEST(xXF86DRICreateContextReq); REQUEST_SIZE_MATCH(xXF86DRICreateContextReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; @@ -290,51 +271,45 @@ ProcXF86DRICreateContext( pScreen = screenInfo.screens[stuff->screen]; - if (!DRICreateContext( pScreen, - NULL, - stuff->context, - (drm_context_t *)&rep.hHWContext)) { - return BadValue; + if (!DRICreateContext(pScreen, + NULL, + stuff->context, (drm_context_t *) & rep.hHWContext)) { + return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRICreateContextReply), (char *) &rep); return Success; } static int -ProcXF86DRIDestroyContext( - register ClientPtr client -) +ProcXF86DRIDestroyContext(register ClientPtr client) { REQUEST(xXF86DRIDestroyContextReq); REQUEST_SIZE_MATCH(xXF86DRIDestroyContextReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } - if (!DRIDestroyContext( screenInfo.screens[stuff->screen], - stuff->context)) { - return BadValue; + if (!DRIDestroyContext(screenInfo.screens[stuff->screen], stuff->context)) { + return BadValue; } return Success; } static int -ProcXF86DRICreateDrawable( - ClientPtr client -) +ProcXF86DRICreateDrawable(ClientPtr client) { - xXF86DRICreateDrawableReply rep; + xXF86DRICreateDrawableReply rep; DrawablePtr pDrawable; int rc; REQUEST(xXF86DRICreateDrawableReq); REQUEST_SIZE_MATCH(xXF86DRICreateDrawableReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; @@ -342,64 +317,61 @@ ProcXF86DRICreateDrawable( rep.sequenceNumber = client->sequence; rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); if (rc != Success) - return rc; + return rc; if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client, - pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) { - return BadValue; + pDrawable, (drm_drawable_t *) & rep.hHWDrawable)) { + return BadValue; } - WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRICreateDrawableReply), (char *) &rep); return Success; } static int -ProcXF86DRIDestroyDrawable( - register ClientPtr client -) +ProcXF86DRIDestroyDrawable(register ClientPtr client) { REQUEST(xXF86DRIDestroyDrawableReq); DrawablePtr pDrawable; int rc; + REQUEST_SIZE_MATCH(xXF86DRIDestroyDrawableReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); if (rc != Success) - return rc; + return rc; if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client, - pDrawable)) { - return BadValue; + pDrawable)) { + return BadValue; } return Success; } static int -ProcXF86DRIGetDrawableInfo( - register ClientPtr client -) +ProcXF86DRIGetDrawableInfo(register ClientPtr client) { - xXF86DRIGetDrawableInfoReply rep; + xXF86DRIGetDrawableInfoReply rep; DrawablePtr pDrawable; int X, Y, W, H; - drm_clip_rect_t * pClipRects, *pClippedRects; - drm_clip_rect_t * pBackClipRects; + drm_clip_rect_t *pClipRects, *pClippedRects; + drm_clip_rect_t *pBackClipRects; int backX, backY, rc; REQUEST(xXF86DRIGetDrawableInfoReq); REQUEST_SIZE_MATCH(xXF86DRIGetDrawableInfoReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; @@ -407,191 +379,181 @@ ProcXF86DRIGetDrawableInfo( rep.sequenceNumber = client->sequence; rc = dixLookupDrawable(&pDrawable, stuff->drawable, client, 0, - DixReadAccess); + DixReadAccess); if (rc != Success) - return rc; - - if (!DRIGetDrawableInfo( screenInfo.screens[stuff->screen], - pDrawable, - (unsigned int*)&rep.drawableTableIndex, - (unsigned int*)&rep.drawableTableStamp, - (int*)&X, - (int*)&Y, - (int*)&W, - (int*)&H, - (int*)&rep.numClipRects, - &pClipRects, - &backX, - &backY, - (int*)&rep.numBackClipRects, - &pBackClipRects)) { - return BadValue; + return rc; + + if (!DRIGetDrawableInfo(screenInfo.screens[stuff->screen], + pDrawable, + (unsigned int *) &rep.drawableTableIndex, + (unsigned int *) &rep.drawableTableStamp, + (int *) &X, + (int *) &Y, + (int *) &W, + (int *) &H, + (int *) &rep.numClipRects, + &pClipRects, + &backX, + &backY, + (int *) &rep.numBackClipRects, &pBackClipRects)) { + return BadValue; } rep.drawableX = X; rep.drawableY = Y; rep.drawableWidth = W; rep.drawableHeight = H; - rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - - SIZEOF(xGenericReply)); + rep.length = (SIZEOF(xXF86DRIGetDrawableInfoReply) - SIZEOF(xGenericReply)); rep.backX = backX; rep.backY = backY; - - if (rep.numBackClipRects) - rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; + + if (rep.numBackClipRects) + rep.length += sizeof(drm_clip_rect_t) * rep.numBackClipRects; pClippedRects = pClipRects; if (rep.numClipRects) { - /* Clip cliprects to screen dimensions (redirected windows) */ - pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t)); - - if (pClippedRects) { - ScreenPtr pScreen = screenInfo.screens[stuff->screen]; - int i, j; - - for (i = 0, j = 0; i < rep.numClipRects; i++) { - pClippedRects[j].x1 = max(pClipRects[i].x1, 0); - pClippedRects[j].y1 = max(pClipRects[i].y1, 0); - pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); - pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); - - if (pClippedRects[j].x1 < pClippedRects[j].x2 && - pClippedRects[j].y1 < pClippedRects[j].y2) { - j++; - } - } - - rep.numClipRects = j; - } else { - rep.numClipRects = 0; - } - - rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; + /* Clip cliprects to screen dimensions (redirected windows) */ + pClippedRects = malloc(rep.numClipRects * sizeof(drm_clip_rect_t)); + + if (pClippedRects) { + ScreenPtr pScreen = screenInfo.screens[stuff->screen]; + int i, j; + + for (i = 0, j = 0; i < rep.numClipRects; i++) { + pClippedRects[j].x1 = max(pClipRects[i].x1, 0); + pClippedRects[j].y1 = max(pClipRects[i].y1, 0); + pClippedRects[j].x2 = min(pClipRects[i].x2, pScreen->width); + pClippedRects[j].y2 = min(pClipRects[i].y2, pScreen->height); + + if (pClippedRects[j].x1 < pClippedRects[j].x2 && + pClippedRects[j].y1 < pClippedRects[j].y2) { + j++; + } + } + + rep.numClipRects = j; + } + else { + rep.numClipRects = 0; + } + + rep.length += sizeof(drm_clip_rect_t) * rep.numClipRects; } - + rep.length = bytes_to_int32(rep.length); - WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRIGetDrawableInfoReply), (char *) &rep); if (rep.numClipRects) { - WriteToClient(client, - sizeof(drm_clip_rect_t) * rep.numClipRects, - (char *)pClippedRects); - free(pClippedRects); + WriteToClient(client, + sizeof(drm_clip_rect_t) * rep.numClipRects, + (char *) pClippedRects); + free(pClippedRects); } if (rep.numBackClipRects) { - WriteToClient(client, - sizeof(drm_clip_rect_t) * rep.numBackClipRects, - (char *)pBackClipRects); + WriteToClient(client, + sizeof(drm_clip_rect_t) * rep.numBackClipRects, + (char *) pBackClipRects); } return Success; } static int -ProcXF86DRIGetDeviceInfo( - register ClientPtr client -) +ProcXF86DRIGetDeviceInfo(register ClientPtr client) { - xXF86DRIGetDeviceInfoReply rep; + xXF86DRIGetDeviceInfoReply rep; drm_handle_t hFrameBuffer; void *pDevPrivate; REQUEST(xXF86DRIGetDeviceInfoReq); REQUEST_SIZE_MATCH(xXF86DRIGetDeviceInfoReq); if (stuff->screen >= screenInfo.numScreens) { - client->errorValue = stuff->screen; - return BadValue; + client->errorValue = stuff->screen; + return BadValue; } rep.type = X_Reply; rep.length = 0; rep.sequenceNumber = client->sequence; - if (!DRIGetDeviceInfo( screenInfo.screens[stuff->screen], - &hFrameBuffer, - (int*)&rep.framebufferOrigin, - (int*)&rep.framebufferSize, - (int*)&rep.framebufferStride, - (int*)&rep.devPrivateSize, - &pDevPrivate)) { - return BadValue; + if (!DRIGetDeviceInfo(screenInfo.screens[stuff->screen], + &hFrameBuffer, + (int *) &rep.framebufferOrigin, + (int *) &rep.framebufferSize, + (int *) &rep.framebufferStride, + (int *) &rep.devPrivateSize, &pDevPrivate)) { + return BadValue; } - rep.hFrameBufferLow = (CARD32)(hFrameBuffer & 0xffffffff); + rep.hFrameBufferLow = (CARD32) (hFrameBuffer & 0xffffffff); #if defined(LONG64) && !defined(__linux__) - rep.hFrameBufferHigh = (CARD32)(hFrameBuffer >> 32); + rep.hFrameBufferHigh = (CARD32) (hFrameBuffer >> 32); #else rep.hFrameBufferHigh = 0; #endif rep.length = 0; if (rep.devPrivateSize) { - rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) - - SIZEOF(xGenericReply) + - pad_to_int32(rep.devPrivateSize)); + rep.length = bytes_to_int32(SIZEOF(xXF86DRIGetDeviceInfoReply) - + SIZEOF(xGenericReply) + + pad_to_int32(rep.devPrivateSize)); } - WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *)&rep); + WriteToClient(client, sizeof(xXF86DRIGetDeviceInfoReply), (char *) &rep); if (rep.length) { - WriteToClient(client, rep.devPrivateSize, (char *)pDevPrivate); + WriteToClient(client, rep.devPrivateSize, (char *) pDevPrivate); } return Success; } static int -ProcXF86DRIDispatch ( - register ClientPtr client -) +ProcXF86DRIDispatch(register ClientPtr client) { REQUEST(xReq); - switch (stuff->data) - { + switch (stuff->data) { case X_XF86DRIQueryVersion: - return ProcXF86DRIQueryVersion(client); + return ProcXF86DRIQueryVersion(client); case X_XF86DRIQueryDirectRenderingCapable: - return ProcXF86DRIQueryDirectRenderingCapable(client); + return ProcXF86DRIQueryDirectRenderingCapable(client); } if (!LocalClient(client)) - return DRIErrorBase + XF86DRIClientNotLocal; + return DRIErrorBase + XF86DRIClientNotLocal; - switch (stuff->data) - { + switch (stuff->data) { case X_XF86DRIOpenConnection: - return ProcXF86DRIOpenConnection(client); + return ProcXF86DRIOpenConnection(client); case X_XF86DRICloseConnection: - return ProcXF86DRICloseConnection(client); + return ProcXF86DRICloseConnection(client); case X_XF86DRIGetClientDriverName: - return ProcXF86DRIGetClientDriverName(client); + return ProcXF86DRIGetClientDriverName(client); case X_XF86DRICreateContext: - return ProcXF86DRICreateContext(client); + return ProcXF86DRICreateContext(client); case X_XF86DRIDestroyContext: - return ProcXF86DRIDestroyContext(client); + return ProcXF86DRIDestroyContext(client); case X_XF86DRICreateDrawable: - return ProcXF86DRICreateDrawable(client); + return ProcXF86DRICreateDrawable(client); case X_XF86DRIDestroyDrawable: - return ProcXF86DRIDestroyDrawable(client); + return ProcXF86DRIDestroyDrawable(client); case X_XF86DRIGetDrawableInfo: - return ProcXF86DRIGetDrawableInfo(client); + return ProcXF86DRIGetDrawableInfo(client); case X_XF86DRIGetDeviceInfo: - return ProcXF86DRIGetDeviceInfo(client); + return ProcXF86DRIGetDeviceInfo(client); case X_XF86DRIAuthConnection: - return ProcXF86DRIAuthConnection(client); - /* {Open,Close}FullScreen are deprecated now */ + return ProcXF86DRIAuthConnection(client); + /* {Open,Close}FullScreen are deprecated now */ default: - return BadRequest; + return BadRequest; } } static int -SProcXF86DRIQueryVersion( - register ClientPtr client -) +SProcXF86DRIQueryVersion(register ClientPtr client) { REQUEST(xXF86DRIQueryVersionReq); swaps(&stuff->length); @@ -599,9 +561,7 @@ SProcXF86DRIQueryVersion( } static int -SProcXF86DRIQueryDirectRenderingCapable( - register ClientPtr client -) +SProcXF86DRIQueryDirectRenderingCapable(register ClientPtr client) { REQUEST(xXF86DRIQueryDirectRenderingCapableReq); swaps(&stuff->length); @@ -610,9 +570,7 @@ SProcXF86DRIQueryDirectRenderingCapable( } static int -SProcXF86DRIDispatch ( - register ClientPtr client -) +SProcXF86DRIDispatch(register ClientPtr client) { REQUEST(xReq); @@ -620,39 +578,36 @@ SProcXF86DRIDispatch ( * Only local clients are allowed DRI access, but remote clients still need * these requests to find out cleanly. */ - switch (stuff->data) - { + switch (stuff->data) { case X_XF86DRIQueryVersion: - return SProcXF86DRIQueryVersion(client); + return SProcXF86DRIQueryVersion(client); case X_XF86DRIQueryDirectRenderingCapable: - return SProcXF86DRIQueryDirectRenderingCapable(client); + return SProcXF86DRIQueryDirectRenderingCapable(client); default: - return DRIErrorBase + XF86DRIClientNotLocal; + return DRIErrorBase + XF86DRIClientNotLocal; } } void XFree86DRIExtensionInit(void) { - ExtensionEntry* extEntry; + ExtensionEntry *extEntry; #ifdef XF86DRI_EVENTS EventType = CreateNewResourceType(XF86DRIFreeEvents, "DRIEvent"); #endif - if ( - DRIExtensionInit() && + if (DRIExtensionInit() && #ifdef XF86DRI_EVENTS EventType && ScreenPrivateIndex != -1 && #endif - (extEntry = AddExtension(XF86DRINAME, - XF86DRINumberEvents, - XF86DRINumberErrors, - ProcXF86DRIDispatch, - SProcXF86DRIDispatch, - XF86DRIResetProc, - StandardMinorOpcode))) { - DRIReqCode = (unsigned char)extEntry->base; - DRIErrorBase = extEntry->errorBase; + (extEntry = AddExtension(XF86DRINAME, + XF86DRINumberEvents, + XF86DRINumberErrors, + ProcXF86DRIDispatch, + SProcXF86DRIDispatch, + XF86DRIResetProc, StandardMinorOpcode))) { + DRIReqCode = (unsigned char) extEntry->base; + DRIErrorBase = extEntry->errorBase; } } |