#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
#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.
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 */
* 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 */
} drmDMAReq, *drmDMAReqPtr;
typedef struct _drmRegion {
- drmHandle handle;
+ drm_handle_t handle;
unsigned int offset;
drmSize size;
drmAddress map;
} 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 */
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,
/* 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,
/* 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);
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);
return 0;
}
-int drmGetMagic(int fd, drmMagicPtr magic)
+int drmGetMagic(int fd, drm_magic_t * magic)
{
drm_auth_t auth;
return 0;
}
-int drmAuthMagic(int fd, drmMagic magic)
+int drmAuthMagic(int fd, drm_magic_t magic)
{
drm_auth_t auth;
* 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;
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;
* This function is a wrapper for mmap().
*/
int drmMap(int fd,
- drmHandle handle,
+ drm_handle_t handle,
drmSize size,
drmAddressPtr address)
{
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;
retval->list[i].used = 0;
retval->list[i].address = bufs.list[i].address;
}
+
+ drmFree(bufs.list);
+
return retval;
- }
- return NULL;
}
* \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)
{
for (i = 0; i < bufs->count; i++) {
munmap(bufs->list[i].address, bufs->list[i].total);
}
+
+ drmFree(bufs->list);
+ drmFree(bufs);
+
return 0;
}
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 );
* 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;
* 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;
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;
return retval;
}
-void drmFreeReservedContextList(drmContextPtr pt)
+void drmFreeReservedContextList(drm_context_t * pt)
{
drmFree(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;
return 0;
}
-int drmSwitchToContext(int fd, drmContext context)
+int drmSwitchToContext(int fd, drm_context_t context)
{
drm_ctx_t ctx;
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;
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;
* 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;
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;
return 0;
}
-int drmDestroyDrawable(int fd, drmDrawable handle)
+int drmDestroyDrawable(int fd, drm_drawable_t handle)
{
drm_draw_t draw;
draw.handle = handle;
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);
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;
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;
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;
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;