@@ -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);
@@ -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;
}
}
@@ -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
@@ -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;