summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-08-27 21:16:13 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-08-27 21:16:13 +0200
commitb4b7b997605f88f3ffdcb0cc7cd1271e0cb24073 (patch)
tree4b9d29ba4ced4638dc9ff07df4fb2d84105506cc /libdrm
parentac26b51503dfedf422d6ae49518adcf41dff1af3 (diff)
Remove the ioctl multiplexing, and instead allow for generic
drm ioctls 0x80 - 0xFF.
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drm.c96
-rw-r--r--libdrm/xf86drm.h7
2 files changed, 103 insertions, 0 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index a2a2e28c..e666df3c 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2362,4 +2362,100 @@ int drmFenceWait(int fd, drmFence *fence, unsigned flush_type,
return 0;
}
+static unsigned long combine64(unsigned lo, unsigned hi)
+{
+ unsigned long ret = lo;
+ if (sizeof(ret) == 8) {
+ int shift = 32;
+ ret |= (hi << shift);
+ }
+ return ret;
+}
+
+static void split32(unsigned long val, unsigned *lo, unsigned *hi)
+{
+ *lo = val & 0xFFFFFFFFUL;
+ if (sizeof(val) == 8) {
+ int shift = 32;
+ *hi = val >> shift;
+ } else {
+ *hi = 0;
+ }
+}
+
+int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
+{
+ drm_ttm_arg_t argTTM;
+ drm_bo_arg_t arg;
+
+ arg.num_requests = 1;
+ arg.op = drm_op_ttm;
+ split32((unsigned long) &argTTM, &arg.data_lo, &arg.data_hi);
+
+ argTTM.op = drm_ttm_create;
+ argTTM.flags = flags;
+ split32((unsigned long) &size, &argTTM.size_lo, &argTTM.size_hi);
+
+ if (ioctl(fd, DRM_IOCTL_TTM, &arg))
+ return -errno;
+
+ ttm->handle = argTTM.handle;
+ ttm->user_token = (drm_handle_t) argTTM.user_token;
+ ttm->flags = argTTM.flags;
+ ttm->size = combine64(argTTM.size_lo, argTTM.size_hi);
+ return 0;
+}
+
+int drmTTMDestroy(int fd, const drmTTM *ttm)
+{
+ drm_ttm_arg_t argTTM;
+ drm_bo_arg_t arg;
+ arg.num_requests = 1;
+ arg.op = drm_op_ttm;
+ split32((unsigned long) &argTTM, &arg.data_lo, &arg.data_hi);
+ argTTM.op = drm_ttm_destroy;
+ argTTM.handle = ttm->handle;
+ if (ioctl(fd, DRM_IOCTL_TTM, &arg))
+ return -errno;
+ return 0;
+}
+
+
+int drmTTMReference(int fd, unsigned handle, drmTTM *ttm)
+{
+ drm_ttm_arg_t argTTM;
+ drm_bo_arg_t arg;
+
+ arg.num_requests = 1;
+ arg.op = drm_op_ttm;
+ split32((unsigned long) &argTTM, &arg.data_lo, &arg.data_hi);
+
+ argTTM.handle = handle;
+ argTTM.op = drm_ttm_reference;
+ if (ioctl(fd, DRM_IOCTL_TTM, &arg))
+ return -errno;
+ ttm->handle = argTTM.handle;
+ ttm->user_token = (drm_handle_t) argTTM.user_token;
+ ttm->flags = argTTM.flags;
+ ttm->size = combine64(argTTM.size_lo, argTTM.size_hi);
+ return 0;
+}
+
+int drmTTMUnreference(int fd, const drmTTM *ttm)
+{
+ drm_ttm_arg_t argTTM;
+ drm_bo_arg_t arg;
+
+ argTTM.op = drm_ttm_destroy;
+ argTTM.handle = ttm->handle;
+ if (ioctl(fd, DRM_IOCTL_TTM, &arg))
+ return -errno;
+ return 0;
+}
+
+drm_handle_t drmTTMMapHandle(int fd, const drmTTM *ttm)
+{
+ (void) fd;
+ return ttm->user_token;
+}
diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h
index 78730785..92cef4c0 100644
--- a/libdrm/xf86drm.h
+++ b/libdrm/xf86drm.h
@@ -287,6 +287,13 @@ typedef struct _drmFence{
unsigned signaled;
} drmFence;
+typedef struct _drmTTM{
+ unsigned handle;
+ drm_handle_t user_token;
+ unsigned flags;
+ unsigned long size;
+} drmTTM;
+
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
#define DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */