diff options
author | Xiang, Haihao <haihao.xiang@intel.com> | 2009-07-24 10:39:05 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2009-07-24 10:39:05 +0800 |
commit | 7dc95b4f1dfecbeb7e9f4a0c35fda32d020be8fe (patch) | |
tree | 559b862598c63d066dcc12ef728f514b53c33743 | |
parent | 12c5aeca7a3db92d3522d00f5daf338d522e2176 (diff) |
XvMC: pin XvMC buffers under KMS.
Under KMS, the buffer allocated by i830_allocate_memory
isn't pinned anymore. However currently 915 XvMC needs
static offsets.
Fixes bug #22872
-rw-r--r-- | src/i830.h | 1 | ||||
-rw-r--r-- | src/i830_hwmc.c | 2 | ||||
-rw-r--r-- | src/i830_memory.c | 26 | ||||
-rw-r--r-- | src/i915_hwmc.c | 20 |
4 files changed, 36 insertions, 13 deletions
@@ -726,6 +726,7 @@ void i830_init_bufmgr(ScrnInfoPtr pScrn); #ifdef INTEL_XVMC Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, i830_memory **buffer, unsigned long size, int flags); +void i830_free_xvmc_buffer(ScrnInfoPtr pScrn, i830_memory *buffer); #endif extern uint32_t i830_create_new_fb(ScrnInfoPtr pScrn, int width, int height, int *pitch); diff --git a/src/i830_hwmc.c b/src/i830_hwmc.c index dee17caf..72385de7 100644 --- a/src/i830_hwmc.c +++ b/src/i830_hwmc.c @@ -171,7 +171,7 @@ void intel_xvmc_fini_batch(ScrnInfoPtr pScrn) xvmc_driver->batch_handle = 0; } if (xvmc_driver->batch) { - i830_free_memory(pScrn, xvmc_driver->batch); + i830_free_xvmc_buffer(pScrn, xvmc_driver->batch); xvmc_driver->batch = NULL; } } diff --git a/src/i830_memory.c b/src/i830_memory.c index cc9d376d..d3c9299a 100644 --- a/src/i830_memory.c +++ b/src/i830_memory.c @@ -1652,6 +1652,8 @@ Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, i830_memory **buffer, unsigned long size, int flags) { + I830Ptr pI830 = I830PTR(pScrn); + *buffer = i830_allocate_memory(pScrn, name, size, PITCH_NONE, GTT_PAGE_SIZE, flags, TILE_NONE); @@ -1661,11 +1663,31 @@ Bool i830_allocate_xvmc_buffer(ScrnInfoPtr pScrn, const char *name, return FALSE; } - if (!i830_bind_memory(pScrn, *buffer)) - return FALSE; + if (pI830->use_drm_mode && (*buffer)->bo) { + if (drm_intel_bo_pin((*buffer)->bo, GTT_PAGE_SIZE)) { + i830_free_memory(pScrn, *buffer); + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "Failed to bind XvMC buffer bo!\n"); + return FALSE; + } + + (*buffer)->offset = (*buffer)->bo->offset; + } return TRUE; } + +void +i830_free_xvmc_buffer(ScrnInfoPtr pScrn, i830_memory *buffer) +{ + I830Ptr pI830 = I830PTR(pScrn); + + if (pI830->use_drm_mode && buffer->bo) + drm_intel_bo_unpin(buffer->bo); + + i830_free_memory(pScrn, buffer); +} + #endif void diff --git a/src/i915_hwmc.c b/src/i915_hwmc.c index 0723c801..6712caac 100644 --- a/src/i915_hwmc.c +++ b/src/i915_hwmc.c @@ -368,32 +368,32 @@ static Bool i915_allocate_xvmc_buffers(ScrnInfoPtr pScrn, I915XvMCContextPriv *c static void i915_free_xvmc_buffers(ScrnInfoPtr pScrn, I915XvMCContextPriv *ctxpriv) { if (ctxpriv->mcStaticIndirectState) { - i830_free_memory(pScrn, ctxpriv->mcStaticIndirectState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcStaticIndirectState); ctxpriv->mcStaticIndirectState = NULL; } if (ctxpriv->mcSamplerState) { - i830_free_memory(pScrn, ctxpriv->mcSamplerState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcSamplerState); ctxpriv->mcSamplerState = NULL; } if (ctxpriv->mcMapState) { - i830_free_memory(pScrn, ctxpriv->mcMapState); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcMapState); ctxpriv->mcMapState = NULL; } if (ctxpriv->mcPixelShaderProgram) { - i830_free_memory(pScrn, ctxpriv->mcPixelShaderProgram); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcPixelShaderProgram); ctxpriv->mcPixelShaderProgram = NULL; } if (ctxpriv->mcPixelShaderConstants) { - i830_free_memory(pScrn, ctxpriv->mcPixelShaderConstants); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcPixelShaderConstants); ctxpriv->mcPixelShaderConstants = NULL; } if (ctxpriv->mcCorrdata) { - i830_free_memory(pScrn, ctxpriv->mcCorrdata); + i830_free_xvmc_buffer(pScrn, ctxpriv->mcCorrdata); ctxpriv->mcCorrdata = NULL; } @@ -606,7 +606,7 @@ static int i915_xvmc_create_surface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf, (drmAddress)&sfpriv->surface_handle) < 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] drmAddMap(surface_handle) failed!\n"); - i830_free_memory(pScrn, sfpriv->surface); + i830_free_xvmc_buffer(pScrn, sfpriv->surface); xfree(sfpriv); xfree(*priv); *priv = NULL; @@ -694,7 +694,7 @@ static int i915_xvmc_create_subpict(ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp, (drmAddress)&sfpriv->surface_handle) < 0) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[drm] drmAddMap(surface_handle) failed!\n"); - i830_free_memory(pScrn, sfpriv->surface); + i830_free_xvmc_buffer(pScrn, sfpriv->surface); xfree(sfpriv); xfree(*priv); *priv = NULL; @@ -744,7 +744,7 @@ static void i915_xvmc_destroy_surface (ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf) for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) { if (pXvMC->surfaces[i] == pSurf->surface_id) { drmRmMap(pI830->drmSubFD, pXvMC->sfprivs[i]->surface_handle); - i830_free_memory(pScrn, pXvMC->sfprivs[i]->surface); + i830_free_xvmc_buffer(pScrn, pXvMC->sfprivs[i]->surface); xfree(pXvMC->sfprivs[i]); pXvMC->nsurfaces--; pXvMC->sfprivs[i] = 0; @@ -766,7 +766,7 @@ static void i915_xvmc_destroy_subpict (ScrnInfoPtr pScrn, for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) { if (pXvMC->surfaces[i] == pSubp->subpicture_id) { drmRmMap(pI830->drmSubFD, pXvMC->sfprivs[i]->surface_handle); - i830_free_memory(pScrn, pXvMC->sfprivs[i]->surface); + i830_free_xvmc_buffer(pScrn, pXvMC->sfprivs[i]->surface); xfree(pXvMC->sfprivs[i]); pXvMC->nsurfaces--; pXvMC->sfprivs[i] = 0; |