libdrm: add prime fd->handle and handle->fd interfaces
These are just basic ioctl wrappers around the prime ioctls, along with the capability reporting. Reviewed-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>main
parent
41dfb20cdc
commit
cc0a14575d
|
@ -685,6 +685,9 @@ struct drm_prime_handle {
|
||||||
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
|
#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)
|
||||||
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
|
#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)
|
||||||
|
|
||||||
|
#define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)
|
||||||
|
#define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle)
|
||||||
|
|
||||||
#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
|
#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)
|
||||||
#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
|
#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)
|
||||||
#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)
|
#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)
|
||||||
|
@ -697,9 +700,6 @@ struct drm_prime_handle {
|
||||||
#define DRM_IOCTL_SG_ALLOC DRM_IOWR(0x38, struct drm_scatter_gather)
|
#define DRM_IOCTL_SG_ALLOC DRM_IOWR(0x38, struct drm_scatter_gather)
|
||||||
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather)
|
#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather)
|
||||||
|
|
||||||
#define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)
|
|
||||||
#define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle)
|
|
||||||
|
|
||||||
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank)
|
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank)
|
||||||
|
|
||||||
#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
|
#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)
|
||||||
|
@ -778,6 +778,10 @@ struct drm_event_vblank {
|
||||||
#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
|
#define DRM_CAP_VBLANK_HIGH_CRTC 0x2
|
||||||
#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
|
#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3
|
||||||
#define DRM_CAP_DUMB_PREFER_SHADOW 0x4
|
#define DRM_CAP_DUMB_PREFER_SHADOW 0x4
|
||||||
|
#define DRM_CAP_PRIME 0x5
|
||||||
|
|
||||||
|
#define DRM_PRIME_CAP_IMPORT 0x1
|
||||||
|
#define DRM_PRIME_CAP_EXPORT 0x2
|
||||||
|
|
||||||
/* typedef area */
|
/* typedef area */
|
||||||
typedef struct drm_clip_rect drm_clip_rect_t;
|
typedef struct drm_clip_rect drm_clip_rect_t;
|
||||||
|
|
31
xf86drm.c
31
xf86drm.c
|
@ -2542,3 +2542,34 @@ char *drmGetDeviceNameFromFd(int fd)
|
||||||
|
|
||||||
return strdup(name);
|
return strdup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd)
|
||||||
|
{
|
||||||
|
struct drm_prime_handle args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
args.handle = handle;
|
||||||
|
args.flags = flags;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_PRIME_HANDLE_TO_FD, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*prime_fd = args.fd;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle)
|
||||||
|
{
|
||||||
|
struct drm_prime_handle args;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
args.fd = prime_fd;
|
||||||
|
args.flags = 0;
|
||||||
|
ret = drmIoctl(fd, DRM_IOCTL_PRIME_FD_TO_HANDLE, &args);
|
||||||
|
if (ret)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
*handle = args.handle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -727,6 +727,9 @@ extern int drmHandleEvent(int fd, drmEventContextPtr evctx);
|
||||||
|
|
||||||
extern char *drmGetDeviceNameFromFd(int fd);
|
extern char *drmGetDeviceNameFromFd(int fd);
|
||||||
|
|
||||||
|
extern int drmPrimeHandleToFD(int fd, uint32_t handle, uint32_t flags, int *prime_fd);
|
||||||
|
extern int drmPrimeFDToHandle(int fd, int prime_fd, uint32_t *handle);
|
||||||
|
|
||||||
#if defined(__cplusplus) || defined(c_plusplus)
|
#if defined(__cplusplus) || defined(c_plusplus)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue