diff options
author | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2007-11-15 02:23:07 +0800 |
---|---|---|
committer | Zhenyu Wang <zhenyu.z.wang@intel.com> | 2007-11-15 02:23:07 +0800 |
commit | 619044b242d4abf605b42cfff538b63f445fe709 (patch) | |
tree | 16de2213ac2b889d380e3103b7bc7618fd2bf784 /src/xvmc | |
parent | ae805ac379ccfdae9ee272896665e73f5bc7d2cf (diff) |
xvmc: move batch buffer init/fini to intel_batchbuffer.c
Diffstat (limited to 'src/xvmc')
-rw-r--r-- | src/xvmc/I915XvMC.c | 13 | ||||
-rw-r--r-- | src/xvmc/intel_batchbuffer.c | 36 | ||||
-rw-r--r-- | src/xvmc/intel_batchbuffer.h | 3 | ||||
-rw-r--r-- | src/xvmc/intel_xvmc.c | 1 |
4 files changed, 30 insertions, 23 deletions
diff --git a/src/xvmc/I915XvMC.c b/src/xvmc/I915XvMC.c index cc051670..1ff3629e 100644 --- a/src/xvmc/I915XvMC.c +++ b/src/xvmc/I915XvMC.c @@ -1241,14 +1241,6 @@ static int i915_xvmc_map_buffers(i915XvMCContext *pI915XvMC) (drmAddress *)&pI915XvMC->corrdata.map) != 0) { return -1; } - - /* XXX */ - if (drmMap(xvmc_driver->fd, - xvmc_driver->batchbuffer.handle, - xvmc_driver->batchbuffer.size, - (drmAddress *)&xvmc_driver->batchbuffer.map) != 0) { - return -1; - } return 0; } @@ -1284,11 +1276,6 @@ static void i915_xvmc_unmap_buffers(i915XvMCContext *pI915XvMC) drmUnmap(pI915XvMC->corrdata.map, pI915XvMC->corrdata.size); pI915XvMC->corrdata.map = NULL; } - - if (xvmc_driver->batchbuffer.map) { - drmUnmap(xvmc_driver->batchbuffer.map, xvmc_driver->batchbuffer.size); - xvmc_driver->batchbuffer.map = NULL; - } } /* diff --git a/src/xvmc/intel_batchbuffer.c b/src/xvmc/intel_batchbuffer.c index 77682188..c96bd459 100644 --- a/src/xvmc/intel_batchbuffer.c +++ b/src/xvmc/intel_batchbuffer.c @@ -96,20 +96,38 @@ void intelDestroyBatchBuffer(void) } -void intelInitBatchBuffer(void) +Bool intelInitBatchBuffer(void) { if (xvmc_driver->batchbuffer.map) { - xvmc_driver->alloc.size = xvmc_driver->batchbuffer.size; - xvmc_driver->alloc.offset = xvmc_driver->batchbuffer.offset; - xvmc_driver->alloc.ptr = xvmc_driver->batchbuffer.map; + xvmc_driver->alloc.size = xvmc_driver->batchbuffer.size; + xvmc_driver->alloc.offset = xvmc_driver->batchbuffer.offset; + xvmc_driver->alloc.ptr = xvmc_driver->batchbuffer.map; } else { - xvmc_driver->alloc.size = 8 * 1024; - xvmc_driver->alloc.offset = 0; - xvmc_driver->alloc.ptr = malloc(xvmc_driver->alloc.size); + xvmc_driver->alloc.size = 8 * 1024; + xvmc_driver->alloc.offset = 0; + xvmc_driver->alloc.ptr = malloc(xvmc_driver->alloc.size); } - xvmc_driver->alloc.active_buf = 0; - assert(xvmc_driver->alloc.ptr); + xvmc_driver->alloc.active_buf = 0; + assert(xvmc_driver->alloc.ptr); + + if (drmMap(xvmc_driver->fd, + xvmc_driver->batchbuffer.handle, + xvmc_driver->batchbuffer.size, + (drmAddress *)&xvmc_driver->batchbuffer.map) != 0) { + XVMC_ERR("fail to map batch buffer\n"); + return False; + } +} + +void intelFiniBatchBuffer(void) +{ + intelFlushBatch(TRUE); + + if (xvmc_driver->batchbuffer.map) { + drmUnmap(xvmc_driver->batchbuffer.map, xvmc_driver->batchbuffer.size); + xvmc_driver->batchbuffer.map = NULL; + } } void intelBatchbufferRequireSpace(unsigned int sz) diff --git a/src/xvmc/intel_batchbuffer.h b/src/xvmc/intel_batchbuffer.h index c44a0ad3..20e7406b 100644 --- a/src/xvmc/intel_batchbuffer.h +++ b/src/xvmc/intel_batchbuffer.h @@ -36,7 +36,8 @@ extern int VERBOSE; extern void intelFlushBatch(Bool); extern void intelBatchbufferData(const void *, unsigned, unsigned); -extern void intelInitBatchBuffer(void); +extern Bool intelInitBatchBuffer(void); +extern Bool intelFnitBatchBuffer(void); extern void intelDestroyBatchBuffer(void); extern void intelCmdIoctl(char *, unsigned); #endif /* _INTEL_BATCHBUFFER_H */ diff --git a/src/xvmc/intel_xvmc.c b/src/xvmc/intel_xvmc.c index 6a99d6d4..6c9a9501 100644 --- a/src/xvmc/intel_xvmc.c +++ b/src/xvmc/intel_xvmc.c @@ -238,6 +238,7 @@ Status XvMCDestroyContext(Display *display, XvMCContext *context) /* Pass Control to the X server to destroy the drm_context_t */ //XXX move generic destroy method here //i915_release_resource(display,context); + intelFiniBatchBuffer(); return Success; } |