aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Airlie2017-06-16 20:01:01 -0500
committerDave Airlie2017-06-28 14:32:34 -0500
commitfc4922793f1871577bb44b1d69ec3801acb23eb6 (patch)
tree065a467df0d8341e14a51c898c2708d8b0546101 /xf86drm.c
parent3832374dafb8d0b1b69d8856be28352514afab5d (diff)
downloadexternal-libdrm-fc4922793f1871577bb44b1d69ec3801acb23eb6.tar.gz
external-libdrm-fc4922793f1871577bb44b1d69ec3801acb23eb6.tar.xz
external-libdrm-fc4922793f1871577bb44b1d69ec3801acb23eb6.zip
libdrm: add drm syncobj create/destroy/import/export
These ioctls are now in drm next so add the first set of libdrm APIs. Reviewed-by: Eric Anholt <eric@anholt.net> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'xf86drm.c')
-rw-r--r--xf86drm.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/xf86drm.c b/xf86drm.c
index 728ac78c..2ac3f265 100644
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
4146 return strdup(node); 4146 return strdup(node);
4147#endif 4147#endif
4148} 4148}
4149
4150int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
4151{
4152 struct drm_syncobj_create args;
4153 int ret;
4154
4155 memclear(args);
4156 args.flags = flags;
4157 args.handle = 0;
4158 ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
4159 if (ret)
4160 return ret;
4161 *handle = args.handle;
4162 return 0;
4163}
4164
4165int drmSyncobjDestroy(int fd, uint32_t handle)
4166{
4167 struct drm_syncobj_destroy args;
4168
4169 memclear(args);
4170 args.handle = handle;
4171 return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
4172}
4173
4174int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
4175{
4176 struct drm_syncobj_handle args;
4177 int ret;
4178
4179 memclear(args);
4180 args.fd = -1;
4181 args.handle = handle;
4182 ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
4183 if (ret)
4184 return ret;
4185 *obj_fd = args.fd;
4186 return 0;
4187}
4188
4189int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
4190{
4191 struct drm_syncobj_handle args;
4192 int ret;
4193
4194 memclear(args);
4195 args.fd = obj_fd;
4196 args.handle = 0;
4197 ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
4198 if (ret)
4199 return ret;
4200 *handle = args.handle;
4201 return 0;
4202}
4203
4204int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
4205{
4206 struct drm_syncobj_handle args;
4207
4208 memclear(args);
4209 args.fd = sync_file_fd;
4210 args.handle = handle;
4211 args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
4212 return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
4213}
4214
4215int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
4216{
4217 struct drm_syncobj_handle args;
4218 int ret;
4219
4220 memclear(args);
4221 args.fd = -1;
4222 args.handle = handle;
4223 args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
4224 ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
4225 if (ret)
4226 return ret;
4227 *sync_file_fd = args.fd;
4228 return 0;
4229}