diff options
author | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-08-12 15:31:10 +0930 |
---|---|---|
committer | Peter Hutterer <peter@cs.unisa.edu.au> | 2007-08-12 15:31:10 +0930 |
commit | f367285fd5825e0adc271982a529c9904ad65c89 (patch) | |
tree | 4e7081da773c51cc9448cefe17c2c3639f33ad6d /hw/xfree86/dri | |
parent | b1272eefd9a3e340d65c14903f337747ec82d021 (diff) | |
parent | ff4bd3addb48df3eacc4b121cc249a7f38eb981a (diff) |
Merge branch 'master' into mpx
Conflicts:
Xi/exevents.c
dix/devices.c
dix/getevents.c
include/dix.h
mi/mieq.c
Diffstat (limited to 'hw/xfree86/dri')
-rw-r--r-- | hw/xfree86/dri/dri.c | 225 | ||||
-rw-r--r-- | hw/xfree86/dri/dri.h | 14 | ||||
-rw-r--r-- | hw/xfree86/dri/dristruct.h | 2 | ||||
-rw-r--r-- | hw/xfree86/dri/xf86dri.c | 11 |
4 files changed, 162 insertions, 90 deletions
diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c index 49e998c68..196f2d49e 100644 --- a/hw/xfree86/dri/dri.c +++ b/hw/xfree86/dri/dri.c @@ -312,12 +312,8 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) Bool xineramaInCore = FALSE; DRIEntPrivPtr pDRIEntPriv; ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum]; - - if (DRIGeneration != serverGeneration) { - if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) - return FALSE; - DRIGeneration = serverGeneration; - } + DRIContextFlags flags = 0; + DRIContextPrivPtr pDRIContextPriv; /* If the DRI extension is disabled, do not initialize the DRI */ if (noXFree86DRIExtension) { @@ -348,9 +344,16 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIEntPriv = DRI_ENT_PRIV(pScrn); + if (DRIGeneration != serverGeneration) { + if ((DRIScreenPrivIndex = AllocateScreenPrivateIndex()) < 0) + return FALSE; + DRIGeneration = serverGeneration; + } + pDRIPriv = (DRIScreenPrivPtr) xcalloc(1, sizeof(DRIScreenPrivRec)); if (!pDRIPriv) { pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + DRIScreenPrivIndex = -1; return FALSE; } @@ -416,23 +419,29 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIPriv->hLSAREA = pDRIEntPriv->hLSAREA; pDRIPriv->pLSAREA = pDRIEntPriv->pLSAREA; - if (drmAddMap( pDRIPriv->drmFD, - (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, - pDRIPriv->pDriverInfo->frameBufferSize, - DRM_FRAME_BUFFER, - 0, - &pDRIPriv->hFrameBuffer) < 0) + if (!pDRIPriv->pDriverInfo->dontMapFrameBuffer) { - pDRIPriv->directRenderingSupport = FALSE; - pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; - drmUnmap(pDRIPriv->pSAREA, pDRIPriv->pDriverInfo->SAREASize); - drmClose(pDRIPriv->drmFD); - DRIDrvMsg(pScreen->myNum, X_INFO, - "[drm] drmAddMap failed\n"); - return FALSE; + if (drmAddMap( pDRIPriv->drmFD, + (drm_handle_t)pDRIPriv->pDriverInfo->frameBufferPhysicalAddress, + pDRIPriv->pDriverInfo->frameBufferSize, + DRM_FRAME_BUFFER, + 0, + &pDRIPriv->pDriverInfo->hFrameBuffer) < 0) + { + pDRIPriv->directRenderingSupport = FALSE; + pScreen->devPrivates[DRIScreenPrivIndex].ptr = 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"); } - DRIDrvMsg(pScreen->myNum, X_INFO, "[drm] framebuffer handle = %p\n", - pDRIPriv->hFrameBuffer); if (pDRIEntPriv->resOwner == NULL) { pDRIEntPriv->resOwner = pScreen; @@ -479,21 +488,14 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD) pDRIEntPriv->refCount++; - return TRUE; -} - -Bool -DRIFinishScreenInit(ScreenPtr pScreen) -{ - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; - DRIContextFlags flags = 0; - DRIContextPrivPtr pDRIContextPriv; - - /* Set up flags for DRICreateContextPriv */ + /* Set up flags for DRICreateContextPriv */ switch (pDRIInfo->driverSwapMethod) { - case DRI_KERNEL_SWAP: flags = DRI_CONTEXT_2DONLY; break; - case DRI_HIDE_X_CONTEXT: flags = DRI_CONTEXT_PRESERVED; break; + case DRI_KERNEL_SWAP: + flags = DRI_CONTEXT_2DONLY; + break; + case DRI_HIDE_X_CONTEXT: + flags = DRI_CONTEXT_PRESERVED; + break; } if (!(pDRIContextPriv = DRICreateContextPriv(pScreen, @@ -580,6 +582,15 @@ DRIFinishScreenInit(ScreenPtr pScreen) break; } + return TRUE; +} + +Bool +DRIFinishScreenInit(ScreenPtr pScreen) +{ + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + DRIInfoPtr pDRIInfo = pDRIPriv->pDriverInfo; + /* Wrap DRI support */ if (pDRIInfo->wrap.ValidateTree) { pDRIPriv->wrap.ValidateTree = pScreen->ValidateTree; @@ -593,6 +604,10 @@ DRIFinishScreenInit(ScreenPtr pScreen) pDRIPriv->wrap.WindowExposures = pScreen->WindowExposures; pScreen->WindowExposures = pDRIInfo->wrap.WindowExposures; } + + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; + if (pDRIInfo->wrap.CopyWindow) { pDRIPriv->wrap.CopyWindow = pScreen->CopyWindow; pScreen->CopyWindow = pDRIInfo->wrap.CopyWindow; @@ -624,7 +639,7 @@ DRICloseScreen(ScreenPtr pScreen) DRIEntPrivPtr pDRIEntPriv = DRI_ENT_PRIV(pScrn); Bool closeMaster; - if (pDRIPriv && pDRIPriv->directRenderingSupport) { + if (pDRIPriv) { pDRIInfo = pDRIPriv->pDriverInfo; @@ -642,6 +657,10 @@ DRICloseScreen(ScreenPtr pScreen) pScreen->WindowExposures = pDRIPriv->wrap.WindowExposures; pDRIPriv->wrap.WindowExposures = NULL; } + if (pDRIPriv->DestroyWindow) { + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + pDRIPriv->DestroyWindow = NULL; + } if (pDRIInfo->wrap.CopyWindow) { pScreen->CopyWindow = pDRIPriv->wrap.CopyWindow; pDRIPriv->wrap.CopyWindow = NULL; @@ -727,6 +746,7 @@ DRICloseScreen(ScreenPtr pScreen) xfree(pDRIPriv); pScreen->devPrivates[DRIScreenPrivIndex].ptr = NULL; + DRIScreenPrivIndex = -1; } } @@ -1247,8 +1267,8 @@ DRIDecreaseNumberVisible(ScreenPtr pScreen) } Bool -DRICreateDrawable(ScreenPtr pScreen, Drawable id, - DrawablePtr pDrawable, drm_drawable_t * hHWDrawable) +DRICreateDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable, + drm_drawable_t * hHWDrawable) { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); DRIDrawablePrivPtr pDRIDrawablePriv; @@ -1290,11 +1310,12 @@ DRICreateDrawable(ScreenPtr pScreen, Drawable id, if (pDRIDrawablePriv->nrects) DRIIncreaseNumberVisible(pScreen); - - /* track this in case this window is destroyed */ - AddResource(id, DRIDrawablePrivResType, (pointer)pWin); } + /* track this in case the client dies */ + AddResource(FakeClientID(client->index), DRIDrawablePrivResType, + (pointer)pDrawable->id); + if (pDRIDrawablePriv->hwDrawable) { drmUpdateDrawableInfo(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable, @@ -1312,21 +1333,59 @@ DRICreateDrawable(ScreenPtr pScreen, Drawable id, return TRUE; } -Bool -DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable) +static void +DRIDrawablePrivDestroy(WindowPtr pWin) { - DRIDrawablePrivPtr pDRIDrawablePriv; - WindowPtr pWin; + DRIDrawablePrivPtr pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + ScreenPtr pScreen; + DRIScreenPrivPtr pDRIPriv; + + if (!pDRIDrawablePriv) + 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++; + /* release drawable table entry */ + pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; + } + + pDRIPriv->nrWindows--; + + if (pDRIDrawablePriv->nrects) + DRIDecreaseNumberVisible(pScreen); + + drmDestroyDrawable(pDRIPriv->drmFD, pDRIDrawablePriv->hwDrawable); + xfree(pDRIDrawablePriv); + pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; +} + +static Bool +DRIDestroyDrawableCB(pointer value, XID id, pointer data) +{ + if (value == data) { + /* This calls back DRIDrawablePrivDelete which frees private area */ + FreeResourceByType(id, DRIDrawablePrivResType, FALSE); + + return TRUE; + } + + return FALSE; +} + +Bool +DRIDestroyDrawable(ScreenPtr pScreen, ClientPtr client, DrawablePtr pDrawable) +{ if (pDrawable->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr)pDrawable; - pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - pDRIDrawablePriv->refCount--; - if (pDRIDrawablePriv->refCount <= 0) { - /* This calls back DRIDrawablePrivDelete which frees private area */ - FreeResourceByType(id, DRIDrawablePrivResType, FALSE); - } + LookupClientResourceComplex(client, DRIDrawablePrivResType, + DRIDestroyDrawableCB, + (pointer)pDrawable->id); } else { /* pixmap (or for GLX 1.3, a PBuffer) */ /* NOT_DONE */ @@ -1339,43 +1398,26 @@ DRIDestroyDrawable(ScreenPtr pScreen, Drawable id, DrawablePtr pDrawable) Bool DRIDrawablePrivDelete(pointer pResource, XID id) { - DrawablePtr pDrawable = (DrawablePtr)pResource; - DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pDrawable->pScreen); - DRIDrawablePrivPtr pDRIDrawablePriv; - WindowPtr pWin; + WindowPtr pWin; - if (pDrawable->type == DRAWABLE_WINDOW) { - pWin = (WindowPtr)pDrawable; - pDRIDrawablePriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); + id = (XID)pResource; + pWin = LookupIDByType(id, RT_WINDOW); - if (pDRIDrawablePriv->drawableIndex != -1) { - /* bump stamp to force outstanding 3D requests to resync */ - pDRIPriv->pSAREA->drawableTable[pDRIDrawablePriv->drawableIndex].stamp - = DRIDrawableValidationStamp++; + if (pWin) { + DRIDrawablePrivPtr pDRIDrwPriv = DRI_DRAWABLE_PRIV_FROM_WINDOW(pWin); - /* release drawable table entry */ - pDRIPriv->DRIDrawables[pDRIDrawablePriv->drawableIndex] = NULL; - } - - if (drmDestroyDrawable(pDRIPriv->drmFD, - pDRIDrawablePriv->hwDrawable)) { + if (!pDRIDrwPriv) return FALSE; - } - - xfree(pDRIDrawablePriv); - pWin->devPrivates[DRIWindowPrivIndex].ptr = NULL; - pDRIPriv->nrWindows--; + if (--pDRIDrwPriv->refCount == 0) + DRIDrawablePrivDestroy(pWin); - if (REGION_NUM_RECTS(&pWin->clipList)) - DRIDecreaseNumberVisible(pDrawable->pScreen); + return TRUE; } else { /* pixmap (or for GLX 1.3, a PBuffer) */ /* NOT_DONE */ return FALSE; } - - return TRUE; } Bool @@ -1561,7 +1603,7 @@ DRIGetDeviceInfo(ScreenPtr pScreen, { DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); - *hFrameBuffer = pDRIPriv->hFrameBuffer; + *hFrameBuffer = pDRIPriv->pDriverInfo->hFrameBuffer; *fbOrigin = 0; *fbSize = pDRIPriv->pDriverInfo->frameBufferSize; *fbStride = pDRIPriv->pDriverInfo->frameBufferStride; @@ -1883,6 +1925,31 @@ DRITreeTraversal(WindowPtr pWin, pointer data) return WT_WALKCHILDREN; } +Bool +DRIDestroyWindow(WindowPtr pWin) +{ + ScreenPtr pScreen = pWin->drawable.pScreen; + DRIScreenPrivPtr pDRIPriv = DRI_SCREEN_PRIV(pScreen); + Bool retval = TRUE; + + DRIDrawablePrivDestroy(pWin); + + /* call lower wrapped functions */ + if(pDRIPriv->DestroyWindow) { + /* unwrap */ + pScreen->DestroyWindow = pDRIPriv->DestroyWindow; + + /* call lower layers */ + retval = (*pScreen->DestroyWindow)(pWin); + + /* rewrap */ + pDRIPriv->DestroyWindow = pScreen->DestroyWindow; + pScreen->DestroyWindow = DRIDestroyWindow; + } + + return retval; +} + void DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc) { diff --git a/hw/xfree86/dri/dri.h b/hw/xfree86/dri/dri.h index e49bb6fa0..98e8b75be 100644 --- a/hw/xfree86/dri/dri.h +++ b/hw/xfree86/dri/dri.h @@ -107,7 +107,7 @@ typedef struct { */ #define DRIINFO_MAJOR_VERSION 5 -#define DRIINFO_MINOR_VERSION 3 +#define DRIINFO_MINOR_VERSION 4 #define DRIINFO_PATCH_VERSION 0 typedef unsigned long long (*DRITexOffsetStartProcPtr)(PixmapPtr pPix); @@ -187,6 +187,12 @@ typedef struct { /* New with DRI version 5.3.0 */ 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; @@ -231,12 +237,12 @@ extern Bool DRIDestroyContext(ScreenPtr pScreen, XID context); extern Bool DRIContextPrivDelete(pointer pResource, XID id); extern Bool DRICreateDrawable(ScreenPtr pScreen, - Drawable id, + ClientPtr client, DrawablePtr pDrawable, drm_drawable_t * hHWDrawable); extern Bool DRIDestroyDrawable(ScreenPtr pScreen, - Drawable id, + ClientPtr client, DrawablePtr pDrawable); extern Bool DRIDrawablePrivDelete(pointer pResource, @@ -299,6 +305,8 @@ extern void DRIWindowExposures(WindowPtr pWin, RegionPtr prgn, RegionPtr bsreg); +extern Bool DRIDestroyWindow(WindowPtr pWin); + extern void DRICopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr prgnSrc); diff --git a/hw/xfree86/dri/dristruct.h b/hw/xfree86/dri/dristruct.h index a3bac8556..c3b0aeede 100644 --- a/hw/xfree86/dri/dristruct.h +++ b/hw/xfree86/dri/dristruct.h @@ -85,7 +85,6 @@ typedef struct _DRIScreenPrivRec int drmFD; /* File descriptor for /dev/video/? */ drm_handle_t hSAREA; /* Handle to SAREA, for mapping */ XF86DRISAREAPtr pSAREA; /* Mapped pointer to SAREA */ - drm_handle_t hFrameBuffer; /* Handle to framebuffer, for mapping */ drm_context_t myContext; /* DDX Driver's context */ DRIContextPrivPtr myContextPriv;/* Pointer to server's private area */ DRIContextPrivPtr lastPartial3DContext; /* last one partially saved */ @@ -99,6 +98,7 @@ typedef struct _DRIScreenPrivRec 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; diff --git a/hw/xfree86/dri/xf86dri.c b/hw/xfree86/dri/xf86dri.c index 9690e8895..fdf0e9983 100644 --- a/hw/xfree86/dri/xf86dri.c +++ b/hw/xfree86/dri/xf86dri.c @@ -404,10 +404,8 @@ ProcXF86DRICreateDrawable( if (rc != Success) return rc; - if (!DRICreateDrawable( screenInfo.screens[stuff->screen], - (Drawable)stuff->drawable, - pDrawable, - (drm_drawable_t *)&rep.hHWDrawable)) { + if (!DRICreateDrawable(screenInfo.screens[stuff->screen], client, + pDrawable, (drm_drawable_t *)&rep.hHWDrawable)) { return BadValue; } @@ -435,9 +433,8 @@ ProcXF86DRIDestroyDrawable( if (rc != Success) return rc; - if (!DRIDestroyDrawable( screenInfo.screens[stuff->screen], - (Drawable)stuff->drawable, - pDrawable)) { + if (!DRIDestroyDrawable(screenInfo.screens[stuff->screen], client, + pDrawable)) { return BadValue; } |