i965 XvMC: don't create any surface state in the ddx

Like for i915. Also drop that now totally superflous limit on the
available surfaces.

Move the surface struct into the userspace library header now that
the ddx doesn't use it anymore.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
This commit is contained in:
Daniel Vetter 2010-03-08 17:33:18 +01:00
parent 69218cc1b5
commit 036cd4bb82
5 changed files with 26 additions and 60 deletions

View File

@ -114,10 +114,6 @@ Bool intel_xvmc_screen_init(ScreenPtr pScreen)
/* i915 hwmc support */
#define _INTEL_XVMC_SERVER_
#define I915_XVMC_MAX_BUFFERS 2
#define I915_XVMC_MAX_CONTEXTS 4
#define I915_XVMC_MAX_SURFACES 20
static XF86MCSurfaceInfoRec i915_YV12_mpg2_surface = {
SURFACE_TYPE_MPEG2_MPML,
XVMC_CHROMA_FORMAT_420,
@ -337,49 +333,11 @@ static void destroy_context(ScrnInfoPtr scrn, XvMCContextPtr context)
static int create_surface(ScrnInfoPtr scrn, XvMCSurfacePtr surface,
int *num_priv, CARD32 ** priv)
{
XvMCContextPtr ctx = surface->context;
struct i965_xvmc_surface *priv_surface, *surface_dup;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
int i;
for (i = 0; i < I965_MAX_SURFACES; i++) {
if (priv_ctx->surfaces[i] == NULL) {
priv_surface = Xcalloc(sizeof(*priv_surface));
if (priv_surface == NULL)
return BadAlloc;
surface_dup = Xcalloc(sizeof(*priv_surface));
if (surface_dup == NULL)
return BadAlloc;
priv_surface->no = i;
priv_surface->handle = priv_surface;
priv_surface->w = ctx->width;
priv_surface->h = ctx->height;
priv_ctx->surfaces[i] = surface->driver_priv
= priv_surface;
memcpy(surface_dup, priv_surface,
sizeof(*priv_surface));
*num_priv = sizeof(*priv_surface) / sizeof(CARD32);
*priv = (CARD32 *) surface_dup;
break;
}
}
if (i >= I965_MAX_SURFACES) {
ErrorF("I965 XVMC too many surfaces in one context\n");
return BadAlloc;
}
return Success;
}
static void destory_surface(ScrnInfoPtr scrn, XvMCSurfacePtr surface)
{
XvMCContextPtr ctx = surface->context;
struct i965_xvmc_surface *priv_surface = surface->driver_priv;
struct i965_xvmc_context *priv_ctx = ctx->driver_priv;
priv_ctx->surfaces[priv_surface->no] = NULL;
Xfree(priv_surface);
}
static XF86MCSurfaceInfoRec yv12_mpeg2_vld_surface = {

View File

@ -1,15 +1,6 @@
#define I965_MC_STATIC_BUFFER_SIZE (1024*512)
#define I965_MAX_SURFACES 12
struct i965_xvmc_surface {
int w, h;
unsigned int no;
void *handle;
dri_bo *bo;
};
struct i965_xvmc_context {
struct _intel_xvmc_common comm;
struct i965_xvmc_surface *surfaces[I965_MAX_SURFACES];
unsigned int is_g4x:1;
unsigned int is_965_q:1;
unsigned int is_igdng:1;

View File

@ -256,12 +256,18 @@ static Status create_surface(Display * display,
XvMCContext * context, XvMCSurface * surface,
int priv_count, CARD32 * priv_data)
{
struct i965_xvmc_surface *priv_surface =
(struct i965_xvmc_surface *)priv_data;
size_t size = SIZE_YUV420(priv_surface->w, priv_surface->h);
surface->privData = priv_data;
struct i965_xvmc_surface *priv_surface = malloc(sizeof(struct i965_xvmc_surface));
if (!priv_surface)
return BadAlloc;
size_t size = SIZE_YUV420(context->width, context->height);
surface->privData = priv_surface;
priv_surface->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr, "surface",
size, 0x1000);
Xfree(priv_data);
return Success;
}
@ -269,8 +275,8 @@ static Status destroy_surface(Display * display, XvMCSurface * surface)
{
struct i965_xvmc_surface *priv_surface = surface->privData;
XSync(display, False);
drm_intel_bo_unreference(priv_surface->bo);
free(priv_surface);
return Success;
}

View File

@ -1 +1,6 @@
#include "intel_xvmc.h"
#define I965_MAX_SURFACES 12
struct i965_xvmc_surface {
dri_bo *bo;
};

View File

@ -620,13 +620,18 @@ static Status create_surface(Display * display,
XvMCContext * context, XvMCSurface * surface,
int priv_count, CARD32 * priv_data)
{
struct i965_xvmc_surface *priv_surface =
(struct i965_xvmc_surface *)priv_data;
size_t size = SIZE_YUV420(priv_surface->w, priv_surface->h);
surface->privData = priv_data;
struct i965_xvmc_surface *priv_surface = malloc(sizeof(struct i965_xvmc_surface));
if (!priv_surface)
return BadAlloc;
size_t size = SIZE_YUV420(context->width, context->height);
surface->privData = priv_surface;
priv_surface->bo = drm_intel_bo_alloc(xvmc_driver->bufmgr, "surface",
size, 0x1000);
Xfree(priv_data);
return Success;
}
@ -635,6 +640,7 @@ static Status destroy_surface(Display * display, XvMCSurface * surface)
struct i965_xvmc_surface *priv_surface = surface->privData;
XSync(display, False);
drm_intel_bo_unreference(priv_surface->bo);
free(priv_surface);
return Success;
}