diff options
-rw-r--r-- | src/mesa/drivers/dri/dri_client/imports/sarea.h | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/dri_client/imports/xf86drm.h | 76 | ||||
-rw-r--r-- | src/mesa/drivers/dri/dri_client/xf86drm.c | 75 |
3 files changed, 76 insertions, 77 deletions
diff --git a/src/mesa/drivers/dri/dri_client/imports/sarea.h b/src/mesa/drivers/dri/dri_client/imports/sarea.h index d4d83df930f..77c16e0efe2 100644 --- a/src/mesa/drivers/dri/dri_client/imports/sarea.h +++ b/src/mesa/drivers/dri/dri_client/imports/sarea.h @@ -88,7 +88,7 @@ typedef struct _XF86DRISAREA { drmLock drawable_lock; XF86DRISAREADrawableRec drawableTable[SAREA_MAX_DRAWABLES]; XF86DRISAREAFrameRec frame; - drmContext dummy_context; + drm_context_t dummy_context; } XF86DRISAREARec, *XF86DRISAREAPtr; #endif diff --git a/src/mesa/drivers/dri/dri_client/imports/xf86drm.h b/src/mesa/drivers/dri/dri_client/imports/xf86drm.h index c9f10074981..0b6e93fd3ef 100644 --- a/src/mesa/drivers/dri/dri_client/imports/xf86drm.h +++ b/src/mesa/drivers/dri/dri_client/imports/xf86drm.h @@ -36,6 +36,8 @@ #ifndef _XF86DRM_H_ #define _XF86DRM_H_ +#include <drm.h> + /* Defaults, if nothing set in xf86config */ #define DRM_DEV_UID 0 #define DRM_DEV_GID 0 @@ -56,12 +58,8 @@ #define DRM_AGP_NO_HANDLE 0 -typedef unsigned long drmHandle, *drmHandlePtr; /**< To mapped regions */ typedef unsigned int drmSize, *drmSizePtr; /**< For mapped regions */ typedef void *drmAddress, **drmAddressPtr; /**< For mapped regions */ -typedef unsigned int drmContext, *drmContextPtr; /**< GLXContext handle */ -typedef unsigned int drmDrawable, *drmDrawablePtr; /**< Unused */ -typedef unsigned int drmMagic, *drmMagicPtr; /**< Magic for authentication */ /** * Driver version information. @@ -168,7 +166,7 @@ typedef enum { DRM_CONTEXT_PRESERVED = 0x01, /**< This context is preserved and never swapped. */ DRM_CONTEXT_2DONLY = 0x02 /**< This context is for 2D rendering only. */ -} drmContextFlags, *drmContextFlagsPtr; +} drm_context_tFlags, *drm_context_tFlagsPtr; typedef struct _drmBufDesc { int count; /**< Number of buffers of this size */ @@ -221,7 +219,7 @@ typedef struct _drmLock { * list in drmBufInfo */ typedef struct _drmDMAReq { - drmContext context; /**< Context handle */ + drm_context_t context; /**< Context handle */ int send_count; /**< Number of buffers to send */ int *send_list; /**< List of handles to buffers */ int *send_sizes; /**< Lengths of data to send, in bytes */ @@ -234,7 +232,7 @@ typedef struct _drmDMAReq { } drmDMAReq, *drmDMAReqPtr; typedef struct _drmRegion { - drmHandle handle; + drm_handle_t handle; unsigned int offset; drmSize size; drmAddress map; @@ -249,14 +247,6 @@ typedef struct _drmTextureRegion { } drmTextureRegion, *drmTextureRegionPtr; -typedef struct _drmClipRect { - unsigned short x1; /* Upper left: inclusive */ - unsigned short y1; - unsigned short x2; /* Lower right: exclusive */ - unsigned short y2; -} drmClipRect, *drmClipRectPtr; - - typedef enum { DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */ DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */ @@ -499,13 +489,13 @@ extern int drmClose(int fd); extern drmVersionPtr drmGetVersion(int fd); extern drmVersionPtr drmGetLibVersion(int fd); extern void drmFreeVersion(drmVersionPtr); -extern int drmGetMagic(int fd, drmMagicPtr magic); +extern int drmGetMagic(int fd, drm_magic_t * magic); extern char *drmGetBusid(int fd); extern int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum); -extern int drmGetMap(int fd, int idx, drmHandle *offset, +extern int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size, drmMapType *type, - drmMapFlags *flags, drmHandle *handle, + drmMapFlags *flags, drm_handle_t *handle, int *mtrr); extern int drmGetClient(int fd, int idx, int *auth, int *pid, int *uid, unsigned long *magic, @@ -523,35 +513,35 @@ extern int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, /* General user-level programmer's API: X server (root) only */ extern void drmFreeBusid(const char *busid); extern int drmSetBusid(int fd, const char *busid); -extern int drmAuthMagic(int fd, drmMagic magic); +extern int drmAuthMagic(int fd, drm_magic_t magic); extern int drmAddMap(int fd, - drmHandle offset, + drm_handle_t offset, drmSize size, drmMapType type, drmMapFlags flags, - drmHandlePtr handle); -extern int drmRmMap(int fd, drmHandle handle); -extern int drmAddContextPrivateMapping(int fd, drmContext ctx_id, - drmHandle handle); + drm_handle_t * handle); +extern int drmRmMap(int fd, drm_handle_t handle); +extern int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, + drm_handle_t handle); extern int drmAddBufs(int fd, int count, int size, drmBufDescFlags flags, int agp_offset); extern int drmMarkBufs(int fd, double low, double high); -extern int drmCreateContext(int fd, drmContextPtr handle); -extern int drmSetContextFlags(int fd, drmContext context, - drmContextFlags flags); -extern int drmGetContextFlags(int fd, drmContext context, - drmContextFlagsPtr flags); -extern int drmAddContextTag(int fd, drmContext context, void *tag); -extern int drmDelContextTag(int fd, drmContext context); -extern void *drmGetContextTag(int fd, drmContext context); -extern drmContextPtr drmGetReservedContextList(int fd, int *count); -extern void drmFreeReservedContextList(drmContextPtr); -extern int drmSwitchToContext(int fd, drmContext context); -extern int drmDestroyContext(int fd, drmContext handle); -extern int drmCreateDrawable(int fd, drmDrawablePtr handle); -extern int drmDestroyDrawable(int fd, drmDrawable handle); +extern int drmCreateContext(int fd, drm_context_t * handle); +extern int drmSetContextFlags(int fd, drm_context_t context, + drm_context_tFlags flags); +extern int drmGetContextFlags(int fd, drm_context_t context, + drm_context_tFlagsPtr flags); +extern int drmAddContextTag(int fd, drm_context_t context, void *tag); +extern int drmDelContextTag(int fd, drm_context_t context); +extern void *drmGetContextTag(int fd, drm_context_t context); +extern drm_context_t * drmGetReservedContextList(int fd, int *count); +extern void drmFreeReservedContextList(drm_context_t *); +extern int drmSwitchToContext(int fd, drm_context_t context); +extern int drmDestroyContext(int fd, drm_context_t handle); +extern int drmCreateDrawable(int fd, drm_drawable_t * handle); +extern int drmDestroyDrawable(int fd, drm_drawable_t handle); extern int drmCtlInstHandler(int fd, int irq); extern int drmCtlUninstHandler(int fd); extern int drmInstallSIGIOHandler(int fd, @@ -562,7 +552,7 @@ extern int drmRemoveSIGIOHandler(int fd); /* General user-level programmer's API: authenticated client and/or X */ extern int drmMap(int fd, - drmHandle handle, + drm_handle_t handle, drmSize size, drmAddressPtr address); extern int drmUnmap(drmAddress address, drmSize size); @@ -572,12 +562,12 @@ extern int drmUnmapBufs(drmBufMapPtr bufs); extern int drmDMA(int fd, drmDMAReqPtr request); extern int drmFreeBufs(int fd, int count, int *list); extern int drmGetLock(int fd, - drmContext context, + drm_context_t context, drmLockFlags flags); -extern int drmUnlock(int fd, drmContext context); +extern int drmUnlock(int fd, drm_context_t context); extern int drmFinish(int fd, int context, drmLockFlags flags); -extern int drmGetContextPrivateMapping(int fd, drmContext ctx_id, - drmHandlePtr handle); +extern int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, + drm_handle_t * handle); /* AGP/GART support: X server (root) only */ extern int drmAgpAcquire(int fd); diff --git a/src/mesa/drivers/dri/dri_client/xf86drm.c b/src/mesa/drivers/dri/dri_client/xf86drm.c index 23750b9ca55..2b0b1b9cc4f 100644 --- a/src/mesa/drivers/dri/dri_client/xf86drm.c +++ b/src/mesa/drivers/dri/dri_client/xf86drm.c @@ -804,7 +804,7 @@ int drmSetBusid(int fd, const char *busid) return 0; } -int drmGetMagic(int fd, drmMagicPtr magic) +int drmGetMagic(int fd, drm_magic_t * magic) { drm_auth_t auth; @@ -814,7 +814,7 @@ int drmGetMagic(int fd, drmMagicPtr magic) return 0; } -int drmAuthMagic(int fd, drmMagic magic) +int drmAuthMagic(int fd, drm_magic_t magic) { drm_auth_t auth; @@ -874,11 +874,11 @@ int drmAuthMagic(int fd, drmMagic magic) * the arguments in a drm_map structure. */ int drmAddMap(int fd, - drmHandle offset, + drm_handle_t offset, drmSize size, drmMapType type, drmMapFlags flags, - drmHandlePtr handle) + drm_handle_t * handle) { drm_map_t map; @@ -894,11 +894,11 @@ int drmAddMap(int fd, map.type = type; map.flags = flags; if (ioctl(fd, DRM_IOCTL_ADD_MAP, &map)) return -errno; - if (handle) *handle = (drmHandle)map.handle; + if (handle) *handle = (drm_handle_t)map.handle; return 0; } -int drmRmMap(int fd, drmHandle handle) +int drmRmMap(int fd, drm_handle_t handle) { drm_map_t map; @@ -1041,7 +1041,7 @@ int drmClose(int fd) * This function is a wrapper for mmap(). */ int drmMap(int fd, - drmHandle handle, + drm_handle_t handle, drmSize size, drmAddressPtr address) { @@ -1135,9 +1135,11 @@ drmBufMapPtr drmMapBufs(int fd) bufs.count = 0; bufs.list = NULL; + bufs.virtual = NULL; if (ioctl(fd, DRM_IOCTL_MAP_BUFS, &bufs)) return NULL; - if (bufs.count) { + if (!bufs.count) return NULL; + if (!(bufs.list = drmMalloc(bufs.count * sizeof(*bufs.list)))) return NULL; @@ -1156,9 +1158,10 @@ drmBufMapPtr drmMapBufs(int fd) retval->list[i].used = 0; retval->list[i].address = bufs.list[i].address; } + + drmFree(bufs.list); + return retval; - } - return NULL; } @@ -1168,7 +1171,8 @@ drmBufMapPtr drmMapBufs(int fd) * \return zero on success, or negative value on failure. * * \internal - * Calls munmap() for every buffer stored in \p bufs. + * Calls munmap() for every buffer stored in \p bufs and frees the + * memory allocated by drmMapBufs(). */ int drmUnmapBufs(drmBufMapPtr bufs) { @@ -1177,6 +1181,10 @@ int drmUnmapBufs(drmBufMapPtr bufs) for (i = 0; i < bufs->count; i++) { munmap(bufs->list[i].address, bufs->list[i].total); } + + drmFree(bufs->list); + drmFree(bufs); + return 0; } @@ -1210,6 +1218,7 @@ int drmDMA(int fd, drmDMAReqPtr request) dma.request_size = request->request_size; dma.request_indices = request->request_list; dma.request_sizes = request->request_sizes; + dma.granted_count = 0; do { ret = ioctl( fd, DRM_IOCTL_DMA, &dma ); @@ -1238,7 +1247,7 @@ int drmDMA(int fd, drmDMAReqPtr request) * This function translates the arguments into a drm_lock structure and issue * the DRM_IOCTL_LOCK ioctl until the lock is successfully acquired. */ -int drmGetLock(int fd, drmContext context, drmLockFlags flags) +int drmGetLock(int fd, drm_context_t context, drmLockFlags flags) { drm_lock_t lock; @@ -1268,7 +1277,7 @@ int drmGetLock(int fd, drmContext context, drmLockFlags flags) * This function is a wrapper around the DRM_IOCTL_UNLOCK ioctl, passing the * argument in a drm_lock structure. */ -int drmUnlock(int fd, drmContext context) +int drmUnlock(int fd, drm_context_t context) { drm_lock_t lock; @@ -1277,11 +1286,11 @@ int drmUnlock(int fd, drmContext context) return ioctl(fd, DRM_IOCTL_UNLOCK, &lock); } -drmContextPtr drmGetReservedContextList(int fd, int *count) +drm_context_t * drmGetReservedContextList(int fd, int *count) { drm_ctx_res_t res; drm_ctx_t *list; - drmContextPtr retval; + drm_context_t * retval; int i; res.count = 0; @@ -1306,7 +1315,7 @@ drmContextPtr drmGetReservedContextList(int fd, int *count) return retval; } -void drmFreeReservedContextList(drmContextPtr pt) +void drmFreeReservedContextList(drm_context_t * pt) { drmFree(pt); } @@ -1329,7 +1338,7 @@ void drmFreeReservedContextList(drmContextPtr pt) * This function is a wrapper around the DRM_IOCTL_ADD_CTX ioctl, passing the * argument in a drm_ctx structure. */ -int drmCreateContext(int fd, drmContextPtr handle) +int drmCreateContext(int fd, drm_context_t * handle) { drm_ctx_t ctx; @@ -1339,7 +1348,7 @@ int drmCreateContext(int fd, drmContextPtr handle) return 0; } -int drmSwitchToContext(int fd, drmContext context) +int drmSwitchToContext(int fd, drm_context_t context) { drm_ctx_t ctx; @@ -1348,7 +1357,7 @@ int drmSwitchToContext(int fd, drmContext context) return 0; } -int drmSetContextFlags(int fd, drmContext context, drmContextFlags flags) +int drmSetContextFlags(int fd, drm_context_t context, drm_context_tFlags flags) { drm_ctx_t ctx; @@ -1368,7 +1377,7 @@ int drmSetContextFlags(int fd, drmContext context, drmContextFlags flags) return 0; } -int drmGetContextFlags(int fd, drmContext context, drmContextFlagsPtr flags) +int drmGetContextFlags(int fd, drm_context_t context, drm_context_tFlagsPtr flags) { drm_ctx_t ctx; @@ -1397,7 +1406,7 @@ int drmGetContextFlags(int fd, drmContext context, drmContextFlagsPtr flags) * This function is a wrapper around the DRM_IOCTL_RM_CTX ioctl, passing the * argument in a drm_ctx structure. */ -int drmDestroyContext(int fd, drmContext handle) +int drmDestroyContext(int fd, drm_context_t handle) { drm_ctx_t ctx; ctx.handle = handle; @@ -1405,7 +1414,7 @@ int drmDestroyContext(int fd, drmContext handle) return 0; } -int drmCreateDrawable(int fd, drmDrawablePtr handle) +int drmCreateDrawable(int fd, drm_drawable_t * handle) { drm_draw_t draw; if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) return -errno; @@ -1413,7 +1422,7 @@ int drmCreateDrawable(int fd, drmDrawablePtr handle) return 0; } -int drmDestroyDrawable(int fd, drmDrawable handle) +int drmDestroyDrawable(int fd, drm_drawable_t handle) { drm_draw_t draw; draw.handle = handle; @@ -1906,7 +1915,7 @@ int drmGetInterruptFromBusID(int fd, int busnum, int devnum, int funcnum) return p.irq; } -int drmAddContextTag(int fd, drmContext context, void *tag) +int drmAddContextTag(int fd, drm_context_t context, void *tag) { drmHashEntry *entry = drmGetEntry(fd); @@ -1917,14 +1926,14 @@ int drmAddContextTag(int fd, drmContext context, void *tag) return 0; } -int drmDelContextTag(int fd, drmContext context) +int drmDelContextTag(int fd, drm_context_t context) { drmHashEntry *entry = drmGetEntry(fd); return drmHashDelete(entry->tagTable, context); } -void *drmGetContextTag(int fd, drmContext context) +void *drmGetContextTag(int fd, drm_context_t context) { drmHashEntry *entry = drmGetEntry(fd); void *value; @@ -1934,7 +1943,7 @@ void *drmGetContextTag(int fd, drmContext context) return value; } -int drmAddContextPrivateMapping(int fd, drmContext ctx_id, drmHandle handle) +int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t handle) { drm_ctx_priv_map_t map; @@ -1945,20 +1954,20 @@ int drmAddContextPrivateMapping(int fd, drmContext ctx_id, drmHandle handle) return 0; } -int drmGetContextPrivateMapping(int fd, drmContext ctx_id, drmHandlePtr handle) +int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t * handle) { drm_ctx_priv_map_t map; map.ctx_id = ctx_id; if (ioctl(fd, DRM_IOCTL_GET_SAREA_CTX, &map)) return -errno; - if (handle) *handle = (drmHandle)map.handle; + if (handle) *handle = (drm_handle_t)map.handle; return 0; } -int drmGetMap(int fd, int idx, drmHandle *offset, drmSize *size, - drmMapType *type, drmMapFlags *flags, drmHandle *handle, +int drmGetMap(int fd, int idx, drm_handle_t *offset, drmSize *size, + drmMapType *type, drmMapFlags *flags, drm_handle_t *handle, int *mtrr) { drm_map_t map; @@ -2268,8 +2277,8 @@ static void drmSIGIOHandler(int interrupt, void *closure) drm_ctx_t ctx; typedef void (*_drmCallback)(int, void *, void *); char buf[256]; - drmContext old; - drmContext new; + drm_context_t old; + drm_context_t new; void *oldctx; void *newctx; char *pt; |