summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2010-03-02 21:53:26 +0100
committerCarl Worth <cworth@cworth.org>2010-03-04 09:38:38 -0800
commitd5a20c81ab76129a1e0bcefecd9c4a10b5040af4 (patch)
treebecb327e638592313b652b5afa5ad2260965d7e5
parente6eb257ad32b393fb67c506943d8ece98b9a8061 (diff)
i915 XvMC: kill pinned surface buffer in the ddx code
Like with the per context stuff, also drop the now artificial limit on surfaces. Again, with that gone, a lot of code can be deleted. Reviewed-by: Carl Worth <cworth@cworth.org>
-rw-r--r--src/i915_hwmc.c234
-rw-r--r--src/i915_hwmc.h5
-rw-r--r--src/xvmc/i915_xvmc.c17
3 files changed, 2 insertions, 254 deletions
diff --git a/src/i915_hwmc.c b/src/i915_hwmc.c
index 6e5d553e..6943a071 100644
--- a/src/i915_hwmc.c
+++ b/src/i915_hwmc.c
@@ -60,16 +60,7 @@
#define I915_XVMC_MAX_CONTEXTS 4
#define I915_XVMC_MAX_SURFACES 20
-typedef struct _I915XvMCSurfacePriv {
- i830_memory *surface;
- unsigned long offsets[I915_XVMC_MAX_BUFFERS];
- drm_handle_t surface_handle;
-} I915XvMCSurfacePriv;
-
typedef struct _I915XvMC {
- XID surfaces[I915_XVMC_MAX_SURFACES];
- I915XvMCSurfacePriv *sfprivs[I915_XVMC_MAX_SURFACES];
- int nsurfaces;
PutImageFuncPtr savePutImage;
} I915XvMC, *I915XvMCPtr;
@@ -149,33 +140,6 @@ static void i915_check_context_size(XvMCContextPtr ctx)
}
/*
- * Init and clean up the screen private parts of XvMC.
- */
-static void initI915XvMC(I915XvMCPtr xvmc)
-{
- unsigned int i;
-
- for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) {
- xvmc->surfaces[i] = 0;
- xvmc->sfprivs[i] = NULL;
- }
- xvmc->nsurfaces = 0;
-}
-
-static void cleanupI915XvMC(I915XvMCPtr xvmc)
-{
- int i;
-
- for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) {
- xvmc->surfaces[i] = 0;
- if (xvmc->sfprivs[i]) {
- xfree(xvmc->sfprivs[i]);
- xvmc->sfprivs[i] = NULL;
- }
- }
-}
-
-/*
* i915_xvmc_create_context
*
* Some info about the private data:
@@ -226,12 +190,6 @@ static int i915_xvmc_create_surface(ScrnInfoPtr scrn, XvMCSurfacePtr pSurf,
int *num_priv, long **priv)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
- I915XvMCPtr pXvMC = (I915XvMCPtr) xvmc_driver->devPrivate;
- I915XvMCSurfacePriv *sfpriv = NULL;
- I915XvMCCreateSurfaceRec *surfaceRec = NULL;
- XvMCContextPtr ctx = NULL;
- unsigned int srfno;
- unsigned long bufsize;
if (!intel->XvMCEnabled) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
@@ -242,167 +200,15 @@ static int i915_xvmc_create_surface(ScrnInfoPtr scrn, XvMCSurfacePtr pSurf,
*priv = NULL;
*num_priv = 0;
- for (srfno = 0; srfno < I915_XVMC_MAX_SURFACES; ++srfno) {
- if (!pXvMC->surfaces[srfno])
- break;
- }
-
- if (srfno == I915_XVMC_MAX_SURFACES ||
- pXvMC->nsurfaces >= I915_XVMC_MAX_SURFACES) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: Too many surfaces !\n");
- return BadAlloc;
- }
-
- *priv = xcalloc(1, sizeof(I915XvMCCreateSurfaceRec));
- surfaceRec = (I915XvMCCreateSurfaceRec *) * priv;
-
- if (!*priv) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915:Unable to allocate surface priv ret memory!\n");
- return BadAlloc;
- }
-
- *num_priv = sizeof(I915XvMCCreateSurfaceRec) >> 2;
- sfpriv =
- (I915XvMCSurfacePriv *) xcalloc(1, sizeof(I915XvMCSurfacePriv));
-
- if (!sfpriv) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: Unable to allocate surface priv memory!\n");
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- ctx = pSurf->context;
- bufsize = SIZE_YUV420(ctx->width, ctx->height);
-
- if (!i830_allocate_xvmc_buffer(scrn, "XvMC surface",
- &(sfpriv->surface), bufsize,
- 0)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915 : Failed to allocate XvMC surface space!\n");
- xfree(sfpriv);
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- if (drmAddMap(intel->drmSubFD,
- (drm_handle_t) (sfpriv->surface->bo->offset +
- intel->LinearAddr), sfpriv->surface->bo->size,
- DRM_AGP, 0, (drmAddress) & sfpriv->surface_handle) < 0) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[drm] drmAddMap(surface_handle) failed!\n");
- i830_free_xvmc_buffer(scrn, sfpriv->surface);
- xfree(sfpriv);
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- surfaceRec->srfno = srfno;
- surfaceRec->srf.handle = sfpriv->surface_handle;
- surfaceRec->srf.offset = sfpriv->surface->bo->offset;
- surfaceRec->srf.size = sfpriv->surface->bo->size;
-
- pXvMC->surfaces[srfno] = pSurf->surface_id;
- pXvMC->sfprivs[srfno] = sfpriv;
- pXvMC->nsurfaces++;
-
return Success;
}
static int i915_xvmc_create_subpict(ScrnInfoPtr scrn, XvMCSubpicturePtr pSubp,
int *num_priv, long **priv)
{
- intel_screen_private *intel = intel_get_screen_private(scrn);
- I915XvMCPtr pXvMC = (I915XvMCPtr) xvmc_driver->devPrivate;
- I915XvMCSurfacePriv *sfpriv = NULL;
- I915XvMCCreateSurfaceRec *surfaceRec = NULL;
- XvMCContextPtr ctx = NULL;
- unsigned int srfno;
- unsigned int bufsize;
-
*priv = NULL;
*num_priv = 0;
- for (srfno = 0; srfno < I915_XVMC_MAX_SURFACES; ++srfno) {
- if (!pXvMC->surfaces[srfno])
- break;
- }
-
- if (srfno == I915_XVMC_MAX_SURFACES ||
- pXvMC->nsurfaces >= I915_XVMC_MAX_SURFACES) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: Too many surfaces !\n");
- return BadAlloc;
- }
-
- *priv = xcalloc(1, sizeof(I915XvMCCreateSurfaceRec));
- surfaceRec = (I915XvMCCreateSurfaceRec *) * priv;
-
- if (!*priv) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: Unable to allocate memory!\n");
- return BadAlloc;
- }
-
- *num_priv = sizeof(I915XvMCCreateSurfaceRec) >> 2;
- sfpriv =
- (I915XvMCSurfacePriv *) xcalloc(1, sizeof(I915XvMCSurfacePriv));
-
- if (!sfpriv) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] i915: Unable to allocate memory!\n");
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- ctx = pSubp->context;
- bufsize = SIZE_XX44(ctx->width, ctx->height);
-
- if (!i830_allocate_xvmc_buffer(scrn, "XvMC surface",
- &(sfpriv->surface), bufsize,
- 0)) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[XvMC] I915XvMCCreateSurface: Failed to allocate XvMC surface space!\n");
- xfree(sfpriv);
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- if (drmAddMap(intel->drmSubFD,
- (drm_handle_t) (sfpriv->surface->bo->offset +
- intel->LinearAddr), sfpriv->surface->bo->size,
- DRM_AGP, 0, (drmAddress) & sfpriv->surface_handle) < 0) {
- xf86DrvMsg(scrn->scrnIndex, X_ERROR,
- "[drm] drmAddMap(surface_handle) failed!\n");
- i830_free_xvmc_buffer(scrn, sfpriv->surface);
- xfree(sfpriv);
- xfree(*priv);
- *priv = NULL;
- *num_priv = 0;
- return BadAlloc;
- }
-
- surfaceRec->srfno = srfno;
- surfaceRec->srf.handle = sfpriv->surface_handle;
- surfaceRec->srf.offset = sfpriv->surface->bo->offset;
- surfaceRec->srf.size = sfpriv->surface->bo->size;
-
- pXvMC->sfprivs[srfno] = sfpriv;
- pXvMC->surfaces[srfno] = pSubp->subpicture_id;
- pXvMC->nsurfaces++;
-
return Success;
}
@@ -414,48 +220,12 @@ static void i915_xvmc_destroy_context(ScrnInfoPtr scrn,
static void i915_xvmc_destroy_surface(ScrnInfoPtr scrn, XvMCSurfacePtr pSurf)
{
- intel_screen_private *intel = intel_get_screen_private(scrn);
- I915XvMCPtr pXvMC = (I915XvMCPtr) xvmc_driver->devPrivate;
- int i;
-
- for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) {
- if (pXvMC->surfaces[i] == pSurf->surface_id) {
- drmRmMap(intel->drmSubFD,
- pXvMC->sfprivs[i]->surface_handle);
- i830_free_xvmc_buffer(scrn,
- pXvMC->sfprivs[i]->surface);
- xfree(pXvMC->sfprivs[i]);
- pXvMC->nsurfaces--;
- pXvMC->sfprivs[i] = 0;
- pXvMC->surfaces[i] = 0;
- return;
- }
- }
-
return;
}
static void i915_xvmc_destroy_subpict(ScrnInfoPtr scrn,
XvMCSubpicturePtr pSubp)
{
- intel_screen_private *intel = intel_get_screen_private(scrn);
- I915XvMCPtr pXvMC = (I915XvMCPtr) xvmc_driver->devPrivate;
- int i;
-
- for (i = 0; i < I915_XVMC_MAX_SURFACES; i++) {
- if (pXvMC->surfaces[i] == pSubp->subpicture_id) {
- drmRmMap(intel->drmSubFD,
- pXvMC->sfprivs[i]->surface_handle);
- i830_free_xvmc_buffer(scrn,
- pXvMC->sfprivs[i]->surface);
- xfree(pXvMC->sfprivs[i]);
- pXvMC->nsurfaces--;
- pXvMC->sfprivs[i] = 0;
- pXvMC->surfaces[i] = 0;
- return;
- }
- }
-
return;
}
@@ -520,7 +290,6 @@ static Bool i915_xvmc_init(ScrnInfoPtr scrn, XF86VideoAdaptorPtr XvAdapt)
xfree(pXvMC);
return FALSE;
}
- initI915XvMC(pXvMC);
/* set up wrappers */
pXvMC->savePutImage = XvAdapt->PutImage;
@@ -530,9 +299,6 @@ static Bool i915_xvmc_init(ScrnInfoPtr scrn, XF86VideoAdaptorPtr XvAdapt)
static void i915_xvmc_fini(ScrnInfoPtr scrn)
{
- I915XvMCPtr pXvMC = (I915XvMCPtr) xvmc_driver->devPrivate;
-
- cleanupI915XvMC(pXvMC);
intel_xvmc_fini_batch(scrn);
xfree(xvmc_driver->devPrivate);
}
diff --git a/src/i915_hwmc.h b/src/i915_hwmc.h
index 52c8b3d4..c036b638 100644
--- a/src/i915_hwmc.h
+++ b/src/i915_hwmc.h
@@ -44,9 +44,4 @@ typedef struct {
int deviceID;
} I915XvMCCreateContextRec;
-typedef struct {
- unsigned int srfno;
- struct hwmc_buffer srf;
-} I915XvMCCreateSurfaceRec;
-
#endif /* _I915_HWMC_H */
diff --git a/src/xvmc/i915_xvmc.c b/src/xvmc/i915_xvmc.c
index 3ae612a5..190b7369 100644
--- a/src/xvmc/i915_xvmc.c
+++ b/src/xvmc/i915_xvmc.c
@@ -975,24 +975,12 @@ static Status i915_xvmc_mc_create_surface(Display * display,
{
i915XvMCContext *pI915XvMC;
i915XvMCSurface *pI915Surface;
- I915XvMCCreateSurfaceRec *tmpComm = NULL;
if (!(pI915XvMC = context->privData))
return XvMCBadContext;
XVMC_DBG("%s\n", __FUNCTION__);
- if (priv_count != (sizeof(I915XvMCCreateSurfaceRec) >> 2)) {
- XVMC_ERR
- ("_xvmc_create_surface() returned incorrect data size!");
- XVMC_INFO("\tExpected %d, got %d",
- (int)(sizeof(I915XvMCCreateSurfaceRec) >> 2),
- priv_count);
- _xvmc_destroy_surface(display, surface);
- XFree(priv_data);
- return BadAlloc;
- }
-
PPTHREAD_MUTEX_LOCK();
surface->privData = (i915XvMCSurface *) malloc(sizeof(i915XvMCSurface));
@@ -1009,11 +997,10 @@ static Status i915_xvmc_mc_create_surface(Display * display,
pI915Surface->privContext = pI915XvMC;
pI915Surface->privSubPic = NULL;
- tmpComm = (I915XvMCCreateSurfaceRec *) priv_data;
-
pI915Surface->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr,
"surface",
- tmpComm->srf.size,
+ SIZE_YUV420(context->width,
+ context->height),
GTT_PAGE_SIZE);
/* X may still use this buffer when XVMC is already done with it. */