summaryrefslogtreecommitdiff
path: root/libdrm
diff options
context:
space:
mode:
Diffstat (limited to 'libdrm')
-rw-r--r--libdrm/xf86drm.c119
-rw-r--r--libdrm/xf86drm.h20
2 files changed, 139 insertions, 0 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c
index c9f1b2db..6302db3a 100644
--- a/libdrm/xf86drm.c
+++ b/libdrm/xf86drm.c
@@ -2236,3 +2236,122 @@ int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
}
return 0;
}
+
+int drmFenceCreate(int fd, int shareable, unsigned type, int emit,
+ drmFence *fence)
+{
+ drm_fence_arg_t arg;
+
+ arg.type = type;
+ arg.flags = (shareable) ? DRM_FENCE_FLAG_SHAREABLE : 0;
+ arg.flags |= (emit) ? DRM_FENCE_FLAG_EMIT : 0;
+ arg.op = drm_fence_create;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ fence->handle = arg.handle;
+ fence->type = arg.type;
+ fence->signaled = 0;
+ return 0;
+}
+
+int drmFenceDestroy(int fd, const drmFence *fence)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = fence->handle;
+ arg.op = drm_fence_destroy;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ return 0;
+}
+
+int drmFenceReference(int fd, unsigned handle, drmFence *fence)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = handle;
+ arg.op = drm_fence_reference;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ fence->handle = arg.handle;
+ fence->type = arg.type;
+ fence->signaled = arg.signaled;
+ return 0;
+}
+
+int drmFenceUnreference(int fd, const drmFence *fence)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = fence->handle;
+ arg.op = drm_fence_unreference;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ return 0;
+}
+
+int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = fence->handle;
+ arg.type = flush_type;
+ arg.op = drm_fence_flush;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ fence->type = arg.type;
+ fence->signaled = arg.signaled;
+ return 0;
+}
+
+int drmFenceSignaled(int fd, drmFence *fence)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = fence->handle;
+ arg.op = drm_fence_signaled;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ fence->type = arg.type;
+ fence->signaled = arg.signaled;
+ return 0;
+}
+
+int drmFenceEmit(int fd, drmFence *fence, unsigned emit_type)
+{
+ drm_fence_arg_t arg;
+
+ arg.handle = fence->handle;
+ arg.type = emit_type;
+ arg.op = drm_fence_emit;
+ if (ioctl(fd, DRM_IOCTL_FENCE, &arg))
+ return -errno;
+ fence->type = arg.type;
+ fence->signaled = arg.signaled;
+ return 0;
+}
+
+int drmFenceWait(int fd, drmFence *fence, unsigned flush_type,
+ int lazy, int ignore_signals)
+{
+ drm_fence_arg_t arg;
+ int ret;
+
+ arg.handle = fence->handle;
+ arg.type = flush_type;
+ arg.flags = (lazy) ? DRM_FENCE_FLAG_WAIT_LAZY : 0;
+ arg.flags |= (ignore_signals) ? DRM_FENCE_FLAG_WAIT_IGNORE_SIGNALS : 0;
+ arg.op = drm_fence_wait;
+ do {
+ ret = ioctl(fd, DRM_IOCTL_FENCE, &arg);
+ } while (ret != 0 && errno == EAGAIN);
+
+ if (ret)
+ return -errno;
+
+ fence->type = arg.type;
+ fence->signaled = arg.signaled;
+ return 0;
+}
+
+
diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h
index 48a18f29..0e037daa 100644
--- a/libdrm/xf86drm.h
+++ b/libdrm/xf86drm.h
@@ -280,6 +280,11 @@ typedef struct _drmSetVersion {
int drm_dd_minor;
} drmSetVersion, *drmSetVersionPtr;
+typedef struct _drmFence{
+ unsigned handle;
+ unsigned type;
+ unsigned signaled;
+} drmFence;
#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
@@ -596,6 +601,21 @@ extern int drmScatterGatherFree(int fd, drm_handle_t handle);
extern int drmWaitVBlank(int fd, drmVBlankPtr vbl);
+/* Fencing */
+
+extern int drmFenceCreate(int fd, int shareable, unsigned type, int emit,
+ drmFence *fence);
+extern int drmFenceDestroy(int fd, const drmFence *fence);
+extern int drmFenceReference(int fd, unsigned handle, drmFence *fence);
+extern int drmFenceUnreference(int fd, const drmFence *fence);
+extern int drmFenceFlush(int fd, drmFence *fence, unsigned flush_type);
+extern int drmFenceSignaled(int fd, drmFence *fence);
+extern int drmFenceWait(int fd, drmFence *fence, unsigned flush_type,
+ int lazy, int ignore_signals);
+extern int drmFenceEmit(int fd, drmFence *fence, unsigned emit_type);
+
+
+
/* Support routines */
extern int drmError(int err, const char *label);
extern void *drmMalloc(int size);