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>main
parent
3832374daf
commit
fc4922793f
81
xf86drm.c
81
xf86drm.c
|
@ -4146,3 +4146,84 @@ char *drmGetDeviceNameFromFd2(int fd)
|
||||||
return strdup(node);
|
return strdup(node);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_create args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.flags = flags;
|
||||||
|
args.handle = 0;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_CREATE, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
*handle = args.handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmSyncobjDestroy(int fd, uint32_t handle)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_destroy args;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.handle = handle;
|
||||||
|
return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_DESTROY, &args);
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_handle args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.fd = -1;
|
||||||
|
args.handle = handle;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
*obj_fd = args.fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_handle args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.fd = obj_fd;
|
||||||
|
args.handle = 0;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
*handle = args.handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_handle args;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.fd = sync_file_fd;
|
||||||
|
args.handle = handle;
|
||||||
|
args.flags = DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE;
|
||||||
|
return drmIoctl(fd, DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE, &args);
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd)
|
||||||
|
{
|
||||||
|
struct drm_syncobj_handle args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
memclear(args);
|
||||||
|
args.fd = -1;
|
||||||
|
args.handle = handle;
|
||||||
|
args.flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
*sync_file_fd = args.fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -853,6 +853,14 @@ extern int drmGetDevices2(uint32_t flags, drmDevicePtr devices[], int max_device
|
||||||
|
|
||||||
extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
|
extern int drmDevicesEqual(drmDevicePtr a, drmDevicePtr b);
|
||||||
|
|
||||||
|
extern int drmSyncobjCreate(int fd, uint32_t flags, uint32_t *handle);
|
||||||
|
extern int drmSyncobjDestroy(int fd, uint32_t handle);
|
||||||
|
extern int drmSyncobjHandleToFD(int fd, uint32_t handle, int *obj_fd);
|
||||||
|
extern int drmSyncobjFDToHandle(int fd, int obj_fd, uint32_t *handle);
|
||||||
|
|
||||||
|
extern int drmSyncobjImportSyncFile(int fd, uint32_t handle, int sync_file_fd);
|
||||||
|
extern int drmSyncobjExportSyncFile(int fd, uint32_t handle, int *sync_file_fd);
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue