diff options
author | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2007-08-08 09:39:55 +0800 |
---|---|---|
committer | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2007-08-08 09:39:55 +0800 |
commit | 87cc72ef509b85635bf0e84c47dfed6b7242170b (patch) | |
tree | 0993dd643baef27f90d55dc3484d96ea4c551365 /src/i915_hwmc.c | |
parent | fec6744b763f2b85b4e592c51326b9ee979bef5d (diff) |
check early if we have slot left for new context or surface
Diffstat (limited to 'src/i915_hwmc.c')
-rw-r--r-- | src/i915_hwmc.c | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/src/i915_hwmc.c b/src/i915_hwmc.c index 94759776..b6865c6f 100644 --- a/src/i915_hwmc.c +++ b/src/i915_hwmc.c @@ -208,6 +208,8 @@ static void initI915XvMC(I915XvMCPtr xvmc) xvmc->surfaces[i] = 0; xvmc->sfprivs[i] = NULL; } + xvmc->ncontexts = 0; + xvmc->nsurfaces = 0; } //XXX @@ -468,7 +470,13 @@ static int I915XvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext, return BadAlloc; } - if (pXvMC->ncontexts >= I915_XVMC_MAX_CONTEXTS) { + for (i = 0; i < I915_XVMC_MAX_CONTEXTS; i++) { + if (!pXvMC->contexts[i]) + break; + } + + if (i == I915_XVMC_MAX_CONTEXTS || + pXvMC->ncontexts >= I915_XVMC_MAX_CONTEXTS) { xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "[XvMC] I915XvMCCreateContext: Out of contexts.\n"); return BadAlloc; @@ -484,11 +492,6 @@ static int I915XvMCCreateContext (ScrnInfoPtr pScrn, XvMCContextPtr pContext, *num_priv = sizeof(I915XvMCCreateContextRec) >> 2; - for (i = 0; i < I915_XVMC_MAX_CONTEXTS; i++) { - if (!pXvMC->contexts[i]) - break; - } - ctxpriv = (I915XvMCContextPriv *)xcalloc(1, sizeof(I915XvMCContextPriv)); if (!ctxpriv) { @@ -572,10 +575,22 @@ static int I915XvMCCreateSurface(ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf, unsigned int srfno; unsigned long bufsize; + if (!pI830->XvMCEnabled) { + xf86DrvMsg(pScrn->scrnIndex, X_ERROR, + "[XvMC] I915XvMCCreateContext: Cannot use XvMC!\n"); + return BadAlloc; + } + *priv = NULL; *num_priv = 0; - if (pXvMC->nsurfaces >= I915_XVMC_MAX_SURFACES) { + 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(pScrn->scrnIndex, X_ERROR, "[XvMC] I915XvMCCreateSurface: Too many surfaces !\n"); return BadAlloc; @@ -631,10 +646,6 @@ static int I915XvMCCreateSurface(ScrnInfoPtr pScrn, XvMCSurfacePtr pSurf, return BadAlloc; } - for (srfno = 0; srfno < I915_XVMC_MAX_SURFACES; ++srfno) { - if (!pXvMC->surfaces[srfno]) - break; - } surfaceRec->srfno = srfno; surfaceRec->srf.handle = sfpriv->surface_handle; surfaceRec->srf.offset = sfpriv->surface->offset; @@ -661,7 +672,13 @@ static int I915XvMCCreateSubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp, *priv = NULL; *num_priv = 0; - if (pXvMC->nsurfaces >= I915_XVMC_MAX_SURFACES) { + 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(pScrn->scrnIndex, X_ERROR, "[XvMC] I915XvMCCreateSubpicture: Too many surfaces !\n"); return BadAlloc; @@ -717,11 +734,6 @@ static int I915XvMCCreateSubpicture (ScrnInfoPtr pScrn, XvMCSubpicturePtr pSubp, return BadAlloc; } - for (srfno = 0; srfno < I915_XVMC_MAX_SURFACES; ++srfno) { - if (!pXvMC->surfaces[srfno]) - break; - } - surfaceRec->srfno = srfno; surfaceRec->srf.handle = sfpriv->surface_handle; surfaceRec->srf.offset = sfpriv->surface->offset; @@ -820,7 +832,7 @@ static int I915XvMCPutImage(ScrnInfoPtr pScrn, short src_x, short src_y, "[XvMC] I915XvMCPutImage: Invalid parameters !\n"); return 1; } - + buf = pI830->FbBase + pXvMC->sfprivs[i915XvMCData->srfNo]->surface->offset; id = i915XvMCData->real_id; pI830->IsXvMCSurface = 1; |