Cleanup and workaround generation

master
itycodes 3 weeks ago
parent ca3f6c4d60
commit 20cf8a355d

@ -4,11 +4,408 @@
const __u64 _DRM_IOCTL_VERSION = DRM_IOCTL_VERSION; const __u64 _DRM_IOCTL_VERSION = DRM_IOCTL_VERSION;
#undef DRM_IOCTL_VERSION #undef DRM_IOCTL_VERSION
const __u64 DRM_IOCTL_VERSION = _DRM_IOCTL_VERSION; const __u64 DRM_IOCTL_VERSION = _DRM_IOCTL_VERSION;
const __u64 _DRM_IOCTL_GET_UNIQUE = DRM_IOCTL_GET_UNIQUE;
const __u64 _DRM_IOCTL_I915_QUERY = DRM_IOCTL_I915_QUERY; #undef DRM_IOCTL_GET_UNIQUE
#undef DRM_IOCTL_I915_QUERY const __u64 DRM_IOCTL_GET_UNIQUE = _DRM_IOCTL_GET_UNIQUE;
const __u64 DRM_IOCTL_I915_QUERY = _DRM_IOCTL_I915_QUERY; const __u64 _DRM_IOCTL_IRQ_BUSID = DRM_IOCTL_IRQ_BUSID;
#undef DRM_IOCTL_IRQ_BUSID
const __u64 DRM_IOCTL_IRQ_BUSID = _DRM_IOCTL_IRQ_BUSID;
const __u64 _DRM_IOCTL_GET_MAP = DRM_IOCTL_GET_MAP;
#undef DRM_IOCTL_GET_MAP
const __u64 DRM_IOCTL_GET_MAP = _DRM_IOCTL_GET_MAP;
const __u64 _DRM_IOCTL_GET_CLIENT = DRM_IOCTL_GET_CLIENT;
#undef DRM_IOCTL_GET_CLIENT
const __u64 DRM_IOCTL_GET_CLIENT = _DRM_IOCTL_GET_CLIENT;
const __u64 _DRM_IOCTL_SET_VERSION = DRM_IOCTL_SET_VERSION;
#undef DRM_IOCTL_SET_VERSION
const __u64 DRM_IOCTL_SET_VERSION = _DRM_IOCTL_SET_VERSION;
const __u64 _DRM_IOCTL_MODESET_CTL = DRM_IOCTL_MODESET_CTL;
#undef DRM_IOCTL_MODESET_CTL
const __u64 DRM_IOCTL_MODESET_CTL = _DRM_IOCTL_MODESET_CTL;
const __u64 _DRM_IOCTL_GEM_CLOSE = DRM_IOCTL_GEM_CLOSE;
#undef DRM_IOCTL_GEM_CLOSE
const __u64 DRM_IOCTL_GEM_CLOSE = _DRM_IOCTL_GEM_CLOSE;
const __u64 _DRM_IOCTL_GEM_FLINK = DRM_IOCTL_GEM_FLINK;
#undef DRM_IOCTL_GEM_FLINK
const __u64 DRM_IOCTL_GEM_FLINK = _DRM_IOCTL_GEM_FLINK;
const __u64 _DRM_IOCTL_GEM_OPEN = DRM_IOCTL_GEM_OPEN;
#undef DRM_IOCTL_GEM_OPEN
const __u64 DRM_IOCTL_GEM_OPEN = _DRM_IOCTL_GEM_OPEN;
const __u64 _DRM_IOCTL_GET_CAP = DRM_IOCTL_GET_CAP;
#undef DRM_IOCTL_GET_CAP
const __u64 DRM_IOCTL_GET_CAP = _DRM_IOCTL_GET_CAP;
const __u64 _DRM_IOCTL_BLOCK = DRM_IOCTL_BLOCK;
#undef DRM_IOCTL_BLOCK
const __u64 DRM_IOCTL_BLOCK = _DRM_IOCTL_BLOCK;
const __u64 _DRM_IOCTL_UNBLOCK = DRM_IOCTL_UNBLOCK;
#undef DRM_IOCTL_UNBLOCK
const __u64 DRM_IOCTL_UNBLOCK = _DRM_IOCTL_UNBLOCK;
const __u64 _DRM_IOCTL_ADD_MAP = DRM_IOCTL_ADD_MAP;
#undef DRM_IOCTL_ADD_MAP
const __u64 DRM_IOCTL_ADD_MAP = _DRM_IOCTL_ADD_MAP;
const __u64 _DRM_IOCTL_ADD_BUFS = DRM_IOCTL_ADD_BUFS;
#undef DRM_IOCTL_ADD_BUFS
const __u64 DRM_IOCTL_ADD_BUFS = _DRM_IOCTL_ADD_BUFS;
const __u64 _DRM_IOCTL_INFO_BUFS = DRM_IOCTL_INFO_BUFS;
#undef DRM_IOCTL_INFO_BUFS
const __u64 DRM_IOCTL_INFO_BUFS = _DRM_IOCTL_INFO_BUFS;
const __u64 _DRM_IOCTL_MAP_BUFS = DRM_IOCTL_MAP_BUFS;
#undef DRM_IOCTL_MAP_BUFS
const __u64 DRM_IOCTL_MAP_BUFS = _DRM_IOCTL_MAP_BUFS;
const __u64 _DRM_IOCTL_GET_SAREA_CTX = DRM_IOCTL_GET_SAREA_CTX;
#undef DRM_IOCTL_GET_SAREA_CTX
const __u64 DRM_IOCTL_GET_SAREA_CTX = _DRM_IOCTL_GET_SAREA_CTX;
const __u64 _DRM_IOCTL_SET_MASTER = DRM_IOCTL_SET_MASTER;
#undef DRM_IOCTL_SET_MASTER
const __u64 DRM_IOCTL_SET_MASTER = _DRM_IOCTL_SET_MASTER;
const __u64 _DRM_IOCTL_DROP_MASTER = DRM_IOCTL_DROP_MASTER;
#undef DRM_IOCTL_DROP_MASTER
const __u64 DRM_IOCTL_DROP_MASTER = _DRM_IOCTL_DROP_MASTER;
const __u64 _DRM_IOCTL_ADD_CTX = DRM_IOCTL_ADD_CTX;
#undef DRM_IOCTL_ADD_CTX
const __u64 DRM_IOCTL_ADD_CTX = _DRM_IOCTL_ADD_CTX;
const __u64 _DRM_IOCTL_RM_CTX = DRM_IOCTL_RM_CTX;
#undef DRM_IOCTL_RM_CTX
const __u64 DRM_IOCTL_RM_CTX = _DRM_IOCTL_RM_CTX;
const __u64 _DRM_IOCTL_GET_CTX = DRM_IOCTL_GET_CTX;
#undef DRM_IOCTL_GET_CTX
const __u64 DRM_IOCTL_GET_CTX = _DRM_IOCTL_GET_CTX;
const __u64 _DRM_IOCTL_RES_CTX = DRM_IOCTL_RES_CTX;
#undef DRM_IOCTL_RES_CTX
const __u64 DRM_IOCTL_RES_CTX = _DRM_IOCTL_RES_CTX;
const __u64 _DRM_IOCTL_ADD_DRAW = DRM_IOCTL_ADD_DRAW;
#undef DRM_IOCTL_ADD_DRAW
const __u64 DRM_IOCTL_ADD_DRAW = _DRM_IOCTL_ADD_DRAW;
const __u64 _DRM_IOCTL_RM_DRAW = DRM_IOCTL_RM_DRAW;
#undef DRM_IOCTL_RM_DRAW
const __u64 DRM_IOCTL_RM_DRAW = _DRM_IOCTL_RM_DRAW;
const __u64 _DRM_IOCTL_DMA = DRM_IOCTL_DMA;
#undef DRM_IOCTL_DMA
const __u64 DRM_IOCTL_DMA = _DRM_IOCTL_DMA;
const __u64 _DRM_IOCTL_PRIME_HANDLE_TO_FD = DRM_IOCTL_PRIME_HANDLE_TO_FD;
#undef DRM_IOCTL_PRIME_HANDLE_TO_FD
const __u64 DRM_IOCTL_PRIME_HANDLE_TO_FD = _DRM_IOCTL_PRIME_HANDLE_TO_FD;
const __u64 _DRM_IOCTL_PRIME_FD_TO_HANDLE = DRM_IOCTL_PRIME_FD_TO_HANDLE;
#undef DRM_IOCTL_PRIME_FD_TO_HANDLE
const __u64 DRM_IOCTL_PRIME_FD_TO_HANDLE = _DRM_IOCTL_PRIME_FD_TO_HANDLE;
const __u64 _DRM_IOCTL_AGP_ALLOC = DRM_IOCTL_AGP_ALLOC;
#undef DRM_IOCTL_AGP_ALLOC
const __u64 DRM_IOCTL_AGP_ALLOC = _DRM_IOCTL_AGP_ALLOC;
const __u64 _DRM_IOCTL_SG_ALLOC = DRM_IOCTL_SG_ALLOC;
#undef DRM_IOCTL_SG_ALLOC
const __u64 DRM_IOCTL_SG_ALLOC = _DRM_IOCTL_SG_ALLOC;
const __u64 _DRM_IOCTL_WAIT_VBLANK = DRM_IOCTL_WAIT_VBLANK;
#undef DRM_IOCTL_WAIT_VBLANK
const __u64 DRM_IOCTL_WAIT_VBLANK = _DRM_IOCTL_WAIT_VBLANK;
const __u64 _DRM_IOCTL_CRTC_GET_SEQUENCE = DRM_IOCTL_CRTC_GET_SEQUENCE;
#undef DRM_IOCTL_CRTC_GET_SEQUENCE
const __u64 DRM_IOCTL_CRTC_GET_SEQUENCE = _DRM_IOCTL_CRTC_GET_SEQUENCE;
const __u64 _DRM_IOCTL_CRTC_QUEUE_SEQUENCE = DRM_IOCTL_CRTC_QUEUE_SEQUENCE;
#undef DRM_IOCTL_CRTC_QUEUE_SEQUENCE
const __u64 DRM_IOCTL_CRTC_QUEUE_SEQUENCE = _DRM_IOCTL_CRTC_QUEUE_SEQUENCE;
const __u64 _DRM_IOCTL_UPDATE_DRAW = DRM_IOCTL_UPDATE_DRAW;
#undef DRM_IOCTL_UPDATE_DRAW
const __u64 DRM_IOCTL_UPDATE_DRAW = _DRM_IOCTL_UPDATE_DRAW;
const __u64 _DRM_IOCTL_MODE_GETRESOURCES = DRM_IOCTL_MODE_GETRESOURCES;
#undef DRM_IOCTL_MODE_GETRESOURCES
const __u64 DRM_IOCTL_MODE_GETRESOURCES = _DRM_IOCTL_MODE_GETRESOURCES;
const __u64 _DRM_IOCTL_MODE_GETCRTC = DRM_IOCTL_MODE_GETCRTC;
#undef DRM_IOCTL_MODE_GETCRTC
const __u64 DRM_IOCTL_MODE_GETCRTC = _DRM_IOCTL_MODE_GETCRTC;
const __u64 _DRM_IOCTL_MODE_SETCRTC = DRM_IOCTL_MODE_SETCRTC;
#undef DRM_IOCTL_MODE_SETCRTC
const __u64 DRM_IOCTL_MODE_SETCRTC = _DRM_IOCTL_MODE_SETCRTC;
const __u64 _DRM_IOCTL_MODE_CURSOR = DRM_IOCTL_MODE_CURSOR;
#undef DRM_IOCTL_MODE_CURSOR
const __u64 DRM_IOCTL_MODE_CURSOR = _DRM_IOCTL_MODE_CURSOR;
const __u64 _DRM_IOCTL_MODE_GETGAMMA = DRM_IOCTL_MODE_GETGAMMA;
#undef DRM_IOCTL_MODE_GETGAMMA
const __u64 DRM_IOCTL_MODE_GETGAMMA = _DRM_IOCTL_MODE_GETGAMMA;
const __u64 _DRM_IOCTL_MODE_SETGAMMA = DRM_IOCTL_MODE_SETGAMMA;
#undef DRM_IOCTL_MODE_SETGAMMA
const __u64 DRM_IOCTL_MODE_SETGAMMA = _DRM_IOCTL_MODE_SETGAMMA;
const __u64 _DRM_IOCTL_MODE_GETENCODER = DRM_IOCTL_MODE_GETENCODER;
#undef DRM_IOCTL_MODE_GETENCODER
const __u64 DRM_IOCTL_MODE_GETENCODER = _DRM_IOCTL_MODE_GETENCODER;
const __u64 _DRM_IOCTL_MODE_GETCONNECTOR = DRM_IOCTL_MODE_GETCONNECTOR;
#undef DRM_IOCTL_MODE_GETCONNECTOR
const __u64 DRM_IOCTL_MODE_GETCONNECTOR = _DRM_IOCTL_MODE_GETCONNECTOR;
const __u64 _DRM_IOCTL_MODE_ATTACHMODE = DRM_IOCTL_MODE_ATTACHMODE;
#undef DRM_IOCTL_MODE_ATTACHMODE
const __u64 DRM_IOCTL_MODE_ATTACHMODE = _DRM_IOCTL_MODE_ATTACHMODE;
const __u64 _DRM_IOCTL_MODE_DETACHMODE = DRM_IOCTL_MODE_DETACHMODE;
#undef DRM_IOCTL_MODE_DETACHMODE
const __u64 DRM_IOCTL_MODE_DETACHMODE = _DRM_IOCTL_MODE_DETACHMODE;
const __u64 _DRM_IOCTL_MODE_GETPROPERTY = DRM_IOCTL_MODE_GETPROPERTY;
#undef DRM_IOCTL_MODE_GETPROPERTY
const __u64 DRM_IOCTL_MODE_GETPROPERTY = _DRM_IOCTL_MODE_GETPROPERTY;
const __u64 _DRM_IOCTL_MODE_SETPROPERTY = DRM_IOCTL_MODE_SETPROPERTY;
#undef DRM_IOCTL_MODE_SETPROPERTY
const __u64 DRM_IOCTL_MODE_SETPROPERTY = _DRM_IOCTL_MODE_SETPROPERTY;
const __u64 _DRM_IOCTL_MODE_GETPROPBLOB = DRM_IOCTL_MODE_GETPROPBLOB;
#undef DRM_IOCTL_MODE_GETPROPBLOB
const __u64 DRM_IOCTL_MODE_GETPROPBLOB = _DRM_IOCTL_MODE_GETPROPBLOB;
const __u64 _DRM_IOCTL_MODE_GETFB = DRM_IOCTL_MODE_GETFB;
#undef DRM_IOCTL_MODE_GETFB
const __u64 DRM_IOCTL_MODE_GETFB = _DRM_IOCTL_MODE_GETFB;
const __u64 _DRM_IOCTL_MODE_ADDFB = DRM_IOCTL_MODE_ADDFB;
#undef DRM_IOCTL_MODE_ADDFB
const __u64 DRM_IOCTL_MODE_ADDFB = _DRM_IOCTL_MODE_ADDFB;
const __u64 _DRM_IOCTL_MODE_RMFB = DRM_IOCTL_MODE_RMFB;
#undef DRM_IOCTL_MODE_RMFB
const __u64 DRM_IOCTL_MODE_RMFB = _DRM_IOCTL_MODE_RMFB;
const __u64 _DRM_IOCTL_MODE_PAGE_FLIP = DRM_IOCTL_MODE_PAGE_FLIP;
#undef DRM_IOCTL_MODE_PAGE_FLIP
const __u64 DRM_IOCTL_MODE_PAGE_FLIP = _DRM_IOCTL_MODE_PAGE_FLIP;
const __u64 _DRM_IOCTL_MODE_DIRTYFB = DRM_IOCTL_MODE_DIRTYFB;
#undef DRM_IOCTL_MODE_DIRTYFB
const __u64 DRM_IOCTL_MODE_DIRTYFB = _DRM_IOCTL_MODE_DIRTYFB;
const __u64 _DRM_IOCTL_MODE_CREATE_DUMB = DRM_IOCTL_MODE_CREATE_DUMB;
#undef DRM_IOCTL_MODE_CREATE_DUMB
const __u64 DRM_IOCTL_MODE_CREATE_DUMB = _DRM_IOCTL_MODE_CREATE_DUMB;
const __u64 _DRM_IOCTL_MODE_MAP_DUMB = DRM_IOCTL_MODE_MAP_DUMB;
#undef DRM_IOCTL_MODE_MAP_DUMB
const __u64 DRM_IOCTL_MODE_MAP_DUMB = _DRM_IOCTL_MODE_MAP_DUMB;
const __u64 _DRM_IOCTL_MODE_DESTROY_DUMB = DRM_IOCTL_MODE_DESTROY_DUMB;
#undef DRM_IOCTL_MODE_DESTROY_DUMB
const __u64 DRM_IOCTL_MODE_DESTROY_DUMB = _DRM_IOCTL_MODE_DESTROY_DUMB;
const __u64 _DRM_IOCTL_MODE_GETPLANERESOURCES = DRM_IOCTL_MODE_GETPLANERESOURCES;
#undef DRM_IOCTL_MODE_GETPLANERESOURCES
const __u64 DRM_IOCTL_MODE_GETPLANERESOURCES = _DRM_IOCTL_MODE_GETPLANERESOURCES;
const __u64 _DRM_IOCTL_MODE_GETPLANE = DRM_IOCTL_MODE_GETPLANE;
#undef DRM_IOCTL_MODE_GETPLANE
const __u64 DRM_IOCTL_MODE_GETPLANE = _DRM_IOCTL_MODE_GETPLANE;
const __u64 _DRM_IOCTL_MODE_SETPLANE = DRM_IOCTL_MODE_SETPLANE;
#undef DRM_IOCTL_MODE_SETPLANE
const __u64 DRM_IOCTL_MODE_SETPLANE = _DRM_IOCTL_MODE_SETPLANE;
const __u64 _DRM_IOCTL_MODE_ADDFB2 = DRM_IOCTL_MODE_ADDFB2;
#undef DRM_IOCTL_MODE_ADDFB2
const __u64 DRM_IOCTL_MODE_ADDFB2 = _DRM_IOCTL_MODE_ADDFB2;
const __u64 _DRM_IOCTL_MODE_OBJ_GETPROPERTIES = DRM_IOCTL_MODE_OBJ_GETPROPERTIES;
#undef DRM_IOCTL_MODE_OBJ_GETPROPERTIES
const __u64 DRM_IOCTL_MODE_OBJ_GETPROPERTIES = _DRM_IOCTL_MODE_OBJ_GETPROPERTIES;
const __u64 _DRM_IOCTL_MODE_OBJ_SETPROPERTY = DRM_IOCTL_MODE_OBJ_SETPROPERTY;
#undef DRM_IOCTL_MODE_OBJ_SETPROPERTY
const __u64 DRM_IOCTL_MODE_OBJ_SETPROPERTY = _DRM_IOCTL_MODE_OBJ_SETPROPERTY;
const __u64 _DRM_IOCTL_MODE_CURSOR2 = DRM_IOCTL_MODE_CURSOR2;
#undef DRM_IOCTL_MODE_CURSOR2
const __u64 DRM_IOCTL_MODE_CURSOR2 = _DRM_IOCTL_MODE_CURSOR2;
const __u64 _DRM_IOCTL_MODE_ATOMIC = DRM_IOCTL_MODE_ATOMIC;
#undef DRM_IOCTL_MODE_ATOMIC
const __u64 DRM_IOCTL_MODE_ATOMIC = _DRM_IOCTL_MODE_ATOMIC;
const __u64 _DRM_IOCTL_MODE_CREATEPROPBLOB = DRM_IOCTL_MODE_CREATEPROPBLOB;
#undef DRM_IOCTL_MODE_CREATEPROPBLOB
const __u64 DRM_IOCTL_MODE_CREATEPROPBLOB = _DRM_IOCTL_MODE_CREATEPROPBLOB;
const __u64 _DRM_IOCTL_MODE_DESTROYPROPBLOB = DRM_IOCTL_MODE_DESTROYPROPBLOB;
#undef DRM_IOCTL_MODE_DESTROYPROPBLOB
const __u64 DRM_IOCTL_MODE_DESTROYPROPBLOB = _DRM_IOCTL_MODE_DESTROYPROPBLOB;
const __u64 _DRM_IOCTL_SYNCOBJ_CREATE = DRM_IOCTL_SYNCOBJ_CREATE;
#undef DRM_IOCTL_SYNCOBJ_CREATE
const __u64 DRM_IOCTL_SYNCOBJ_CREATE = _DRM_IOCTL_SYNCOBJ_CREATE;
const __u64 _DRM_IOCTL_SYNCOBJ_DESTROY = DRM_IOCTL_SYNCOBJ_DESTROY;
#undef DRM_IOCTL_SYNCOBJ_DESTROY
const __u64 DRM_IOCTL_SYNCOBJ_DESTROY = _DRM_IOCTL_SYNCOBJ_DESTROY;
const __u64 _DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD = DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD;
#undef DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD
const __u64 DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD = _DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD;
const __u64 _DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE = DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE;
#undef DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE
const __u64 DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE = _DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE;
const __u64 _DRM_IOCTL_SYNCOBJ_WAIT = DRM_IOCTL_SYNCOBJ_WAIT;
#undef DRM_IOCTL_SYNCOBJ_WAIT
const __u64 DRM_IOCTL_SYNCOBJ_WAIT = _DRM_IOCTL_SYNCOBJ_WAIT;
const __u64 _DRM_IOCTL_SYNCOBJ_RESET = DRM_IOCTL_SYNCOBJ_RESET;
#undef DRM_IOCTL_SYNCOBJ_RESET
const __u64 DRM_IOCTL_SYNCOBJ_RESET = _DRM_IOCTL_SYNCOBJ_RESET;
const __u64 _DRM_IOCTL_SYNCOBJ_SIGNAL = DRM_IOCTL_SYNCOBJ_SIGNAL;
#undef DRM_IOCTL_SYNCOBJ_SIGNAL
const __u64 DRM_IOCTL_SYNCOBJ_SIGNAL = _DRM_IOCTL_SYNCOBJ_SIGNAL;
const __u64 _DRM_IOCTL_MODE_CREATE_LEASE = DRM_IOCTL_MODE_CREATE_LEASE;
#undef DRM_IOCTL_MODE_CREATE_LEASE
const __u64 DRM_IOCTL_MODE_CREATE_LEASE = _DRM_IOCTL_MODE_CREATE_LEASE;
const __u64 _DRM_IOCTL_MODE_LIST_LESSEES = DRM_IOCTL_MODE_LIST_LESSEES;
#undef DRM_IOCTL_MODE_LIST_LESSEES
const __u64 DRM_IOCTL_MODE_LIST_LESSEES = _DRM_IOCTL_MODE_LIST_LESSEES;
const __u64 _DRM_IOCTL_MODE_GET_LEASE = DRM_IOCTL_MODE_GET_LEASE;
#undef DRM_IOCTL_MODE_GET_LEASE
const __u64 DRM_IOCTL_MODE_GET_LEASE = _DRM_IOCTL_MODE_GET_LEASE;
const __u64 _DRM_IOCTL_MODE_REVOKE_LEASE = DRM_IOCTL_MODE_REVOKE_LEASE;
#undef DRM_IOCTL_MODE_REVOKE_LEASE
const __u64 DRM_IOCTL_MODE_REVOKE_LEASE = _DRM_IOCTL_MODE_REVOKE_LEASE;
const __u64 _DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT = DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT;
#undef DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT
const __u64 DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT = _DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT;
const __u64 _DRM_IOCTL_SYNCOBJ_QUERY = DRM_IOCTL_SYNCOBJ_QUERY;
#undef DRM_IOCTL_SYNCOBJ_QUERY
const __u64 DRM_IOCTL_SYNCOBJ_QUERY = _DRM_IOCTL_SYNCOBJ_QUERY;
const __u64 _DRM_IOCTL_SYNCOBJ_TRANSFER = DRM_IOCTL_SYNCOBJ_TRANSFER;
#undef DRM_IOCTL_SYNCOBJ_TRANSFER
const __u64 DRM_IOCTL_SYNCOBJ_TRANSFER = _DRM_IOCTL_SYNCOBJ_TRANSFER;
const __u64 _DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL = DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL;
#undef DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL
const __u64 DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL = _DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL;
const __u64 _DRM_IOCTL_MODE_GETFB2 = DRM_IOCTL_MODE_GETFB2;
#undef DRM_IOCTL_MODE_GETFB2
const __u64 DRM_IOCTL_MODE_GETFB2 = _DRM_IOCTL_MODE_GETFB2;
const __u64 _DRM_IOCTL_SYNCOBJ_EVENTFD = DRM_IOCTL_SYNCOBJ_EVENTFD;
#undef DRM_IOCTL_SYNCOBJ_EVENTFD
const __u64 DRM_IOCTL_SYNCOBJ_EVENTFD = _DRM_IOCTL_SYNCOBJ_EVENTFD;
const __u64 _DRM_IOCTL_MODE_CLOSEFB = DRM_IOCTL_MODE_CLOSEFB;
#undef DRM_IOCTL_MODE_CLOSEFB
const __u64 DRM_IOCTL_MODE_CLOSEFB = _DRM_IOCTL_MODE_CLOSEFB;
const __u64 _DRM_IOCTL_I915_INIT = DRM_IOCTL_I915_INIT;
#undef DRM_IOCTL_I915_INIT
const __u64 DRM_IOCTL_I915_INIT = _DRM_IOCTL_I915_INIT;
const __u64 _DRM_IOCTL_I915_FLUSH = DRM_IOCTL_I915_FLUSH;
#undef DRM_IOCTL_I915_FLUSH
const __u64 DRM_IOCTL_I915_FLUSH = _DRM_IOCTL_I915_FLUSH;
const __u64 _DRM_IOCTL_I915_FLIP = DRM_IOCTL_I915_FLIP;
#undef DRM_IOCTL_I915_FLIP
const __u64 DRM_IOCTL_I915_FLIP = _DRM_IOCTL_I915_FLIP;
const __u64 _DRM_IOCTL_I915_BATCHBUFFER = DRM_IOCTL_I915_BATCHBUFFER;
#undef DRM_IOCTL_I915_BATCHBUFFER
const __u64 DRM_IOCTL_I915_BATCHBUFFER = _DRM_IOCTL_I915_BATCHBUFFER;
const __u64 _DRM_IOCTL_I915_IRQ_EMIT = DRM_IOCTL_I915_IRQ_EMIT;
#undef DRM_IOCTL_I915_IRQ_EMIT
const __u64 DRM_IOCTL_I915_IRQ_EMIT = _DRM_IOCTL_I915_IRQ_EMIT;
const __u64 _DRM_IOCTL_I915_IRQ_WAIT = DRM_IOCTL_I915_IRQ_WAIT;
#undef DRM_IOCTL_I915_IRQ_WAIT
const __u64 DRM_IOCTL_I915_IRQ_WAIT = _DRM_IOCTL_I915_IRQ_WAIT;
const __u64 _DRM_IOCTL_I915_GETPARAM = DRM_IOCTL_I915_GETPARAM; const __u64 _DRM_IOCTL_I915_GETPARAM = DRM_IOCTL_I915_GETPARAM;
#undef DRM_IOCTL_I915_GETPARAM #undef DRM_IOCTL_I915_GETPARAM
const __u64 DRM_IOCTL_I915_GETPARAM = _DRM_IOCTL_I915_GETPARAM; const __u64 DRM_IOCTL_I915_GETPARAM = _DRM_IOCTL_I915_GETPARAM;
const __u64 _DRM_IOCTL_I915_SETPARAM = DRM_IOCTL_I915_SETPARAM;
#undef DRM_IOCTL_I915_SETPARAM
const __u64 DRM_IOCTL_I915_SETPARAM = _DRM_IOCTL_I915_SETPARAM;
const __u64 _DRM_IOCTL_I915_ALLOC = DRM_IOCTL_I915_ALLOC;
#undef DRM_IOCTL_I915_ALLOC
const __u64 DRM_IOCTL_I915_ALLOC = _DRM_IOCTL_I915_ALLOC;
const __u64 _DRM_IOCTL_I915_FREE = DRM_IOCTL_I915_FREE;
#undef DRM_IOCTL_I915_FREE
const __u64 DRM_IOCTL_I915_FREE = _DRM_IOCTL_I915_FREE;
const __u64 _DRM_IOCTL_I915_INIT_HEAP = DRM_IOCTL_I915_INIT_HEAP;
#undef DRM_IOCTL_I915_INIT_HEAP
const __u64 DRM_IOCTL_I915_INIT_HEAP = _DRM_IOCTL_I915_INIT_HEAP;
const __u64 _DRM_IOCTL_I915_CMDBUFFER = DRM_IOCTL_I915_CMDBUFFER;
#undef DRM_IOCTL_I915_CMDBUFFER
const __u64 DRM_IOCTL_I915_CMDBUFFER = _DRM_IOCTL_I915_CMDBUFFER;
const __u64 _DRM_IOCTL_I915_DESTROY_HEAP = DRM_IOCTL_I915_DESTROY_HEAP;
#undef DRM_IOCTL_I915_DESTROY_HEAP
const __u64 DRM_IOCTL_I915_DESTROY_HEAP = _DRM_IOCTL_I915_DESTROY_HEAP;
const __u64 _DRM_IOCTL_I915_SET_VBLANK_PIPE = DRM_IOCTL_I915_SET_VBLANK_PIPE;
#undef DRM_IOCTL_I915_SET_VBLANK_PIPE
const __u64 DRM_IOCTL_I915_SET_VBLANK_PIPE = _DRM_IOCTL_I915_SET_VBLANK_PIPE;
const __u64 _DRM_IOCTL_I915_GET_VBLANK_PIPE = DRM_IOCTL_I915_GET_VBLANK_PIPE;
#undef DRM_IOCTL_I915_GET_VBLANK_PIPE
const __u64 DRM_IOCTL_I915_GET_VBLANK_PIPE = _DRM_IOCTL_I915_GET_VBLANK_PIPE;
const __u64 _DRM_IOCTL_I915_VBLANK_SWAP = DRM_IOCTL_I915_VBLANK_SWAP;
#undef DRM_IOCTL_I915_VBLANK_SWAP
const __u64 DRM_IOCTL_I915_VBLANK_SWAP = _DRM_IOCTL_I915_VBLANK_SWAP;
const __u64 _DRM_IOCTL_I915_HWS_ADDR = DRM_IOCTL_I915_HWS_ADDR;
#undef DRM_IOCTL_I915_HWS_ADDR
const __u64 DRM_IOCTL_I915_HWS_ADDR = _DRM_IOCTL_I915_HWS_ADDR;
const __u64 _DRM_IOCTL_I915_GEM_INIT = DRM_IOCTL_I915_GEM_INIT;
#undef DRM_IOCTL_I915_GEM_INIT
const __u64 DRM_IOCTL_I915_GEM_INIT = _DRM_IOCTL_I915_GEM_INIT;
const __u64 _DRM_IOCTL_I915_GEM_EXECBUFFER = DRM_IOCTL_I915_GEM_EXECBUFFER;
#undef DRM_IOCTL_I915_GEM_EXECBUFFER
const __u64 DRM_IOCTL_I915_GEM_EXECBUFFER = _DRM_IOCTL_I915_GEM_EXECBUFFER;
const __u64 _DRM_IOCTL_I915_GEM_EXECBUFFER2 = DRM_IOCTL_I915_GEM_EXECBUFFER2;
#undef DRM_IOCTL_I915_GEM_EXECBUFFER2
const __u64 DRM_IOCTL_I915_GEM_EXECBUFFER2 = _DRM_IOCTL_I915_GEM_EXECBUFFER2;
const __u64 _DRM_IOCTL_I915_GEM_EXECBUFFER2_WR = DRM_IOCTL_I915_GEM_EXECBUFFER2_WR;
#undef DRM_IOCTL_I915_GEM_EXECBUFFER2_WR
const __u64 DRM_IOCTL_I915_GEM_EXECBUFFER2_WR = _DRM_IOCTL_I915_GEM_EXECBUFFER2_WR;
const __u64 _DRM_IOCTL_I915_GEM_PIN = DRM_IOCTL_I915_GEM_PIN;
#undef DRM_IOCTL_I915_GEM_PIN
const __u64 DRM_IOCTL_I915_GEM_PIN = _DRM_IOCTL_I915_GEM_PIN;
const __u64 _DRM_IOCTL_I915_GEM_UNPIN = DRM_IOCTL_I915_GEM_UNPIN;
#undef DRM_IOCTL_I915_GEM_UNPIN
const __u64 DRM_IOCTL_I915_GEM_UNPIN = _DRM_IOCTL_I915_GEM_UNPIN;
const __u64 _DRM_IOCTL_I915_GEM_BUSY = DRM_IOCTL_I915_GEM_BUSY;
#undef DRM_IOCTL_I915_GEM_BUSY
const __u64 DRM_IOCTL_I915_GEM_BUSY = _DRM_IOCTL_I915_GEM_BUSY;
const __u64 _DRM_IOCTL_I915_GEM_SET_CACHING = DRM_IOCTL_I915_GEM_SET_CACHING;
#undef DRM_IOCTL_I915_GEM_SET_CACHING
const __u64 DRM_IOCTL_I915_GEM_SET_CACHING = _DRM_IOCTL_I915_GEM_SET_CACHING;
const __u64 _DRM_IOCTL_I915_GEM_GET_CACHING = DRM_IOCTL_I915_GEM_GET_CACHING;
#undef DRM_IOCTL_I915_GEM_GET_CACHING
const __u64 DRM_IOCTL_I915_GEM_GET_CACHING = _DRM_IOCTL_I915_GEM_GET_CACHING;
const __u64 _DRM_IOCTL_I915_GEM_THROTTLE = DRM_IOCTL_I915_GEM_THROTTLE;
#undef DRM_IOCTL_I915_GEM_THROTTLE
const __u64 DRM_IOCTL_I915_GEM_THROTTLE = _DRM_IOCTL_I915_GEM_THROTTLE;
const __u64 _DRM_IOCTL_I915_GEM_ENTERVT = DRM_IOCTL_I915_GEM_ENTERVT;
#undef DRM_IOCTL_I915_GEM_ENTERVT
const __u64 DRM_IOCTL_I915_GEM_ENTERVT = _DRM_IOCTL_I915_GEM_ENTERVT;
const __u64 _DRM_IOCTL_I915_GEM_LEAVEVT = DRM_IOCTL_I915_GEM_LEAVEVT;
#undef DRM_IOCTL_I915_GEM_LEAVEVT
const __u64 DRM_IOCTL_I915_GEM_LEAVEVT = _DRM_IOCTL_I915_GEM_LEAVEVT;
const __u64 _DRM_IOCTL_I915_GEM_CREATE = DRM_IOCTL_I915_GEM_CREATE;
#undef DRM_IOCTL_I915_GEM_CREATE
const __u64 DRM_IOCTL_I915_GEM_CREATE = _DRM_IOCTL_I915_GEM_CREATE;
const __u64 _DRM_IOCTL_I915_GEM_CREATE_EXT = DRM_IOCTL_I915_GEM_CREATE_EXT;
#undef DRM_IOCTL_I915_GEM_CREATE_EXT
const __u64 DRM_IOCTL_I915_GEM_CREATE_EXT = _DRM_IOCTL_I915_GEM_CREATE_EXT;
const __u64 _DRM_IOCTL_I915_GEM_PREAD = DRM_IOCTL_I915_GEM_PREAD;
#undef DRM_IOCTL_I915_GEM_PREAD
const __u64 DRM_IOCTL_I915_GEM_PREAD = _DRM_IOCTL_I915_GEM_PREAD;
const __u64 _DRM_IOCTL_I915_GEM_PWRITE = DRM_IOCTL_I915_GEM_PWRITE;
#undef DRM_IOCTL_I915_GEM_PWRITE
const __u64 DRM_IOCTL_I915_GEM_PWRITE = _DRM_IOCTL_I915_GEM_PWRITE;
const __u64 _DRM_IOCTL_I915_GEM_MMAP = DRM_IOCTL_I915_GEM_MMAP;
#undef DRM_IOCTL_I915_GEM_MMAP
const __u64 DRM_IOCTL_I915_GEM_MMAP = _DRM_IOCTL_I915_GEM_MMAP;
const __u64 _DRM_IOCTL_I915_GEM_MMAP_GTT = DRM_IOCTL_I915_GEM_MMAP_GTT;
#undef DRM_IOCTL_I915_GEM_MMAP_GTT
const __u64 DRM_IOCTL_I915_GEM_MMAP_GTT = _DRM_IOCTL_I915_GEM_MMAP_GTT;
const __u64 _DRM_IOCTL_I915_GEM_MMAP_OFFSET = DRM_IOCTL_I915_GEM_MMAP_OFFSET;
#undef DRM_IOCTL_I915_GEM_MMAP_OFFSET
const __u64 DRM_IOCTL_I915_GEM_MMAP_OFFSET = _DRM_IOCTL_I915_GEM_MMAP_OFFSET;
const __u64 _DRM_IOCTL_I915_GEM_SET_DOMAIN = DRM_IOCTL_I915_GEM_SET_DOMAIN;
#undef DRM_IOCTL_I915_GEM_SET_DOMAIN
const __u64 DRM_IOCTL_I915_GEM_SET_DOMAIN = _DRM_IOCTL_I915_GEM_SET_DOMAIN;
const __u64 _DRM_IOCTL_I915_GEM_SW_FINISH = DRM_IOCTL_I915_GEM_SW_FINISH;
#undef DRM_IOCTL_I915_GEM_SW_FINISH
const __u64 DRM_IOCTL_I915_GEM_SW_FINISH = _DRM_IOCTL_I915_GEM_SW_FINISH;
const __u64 _DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID = DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID;
#undef DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID
const __u64 DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID = _DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID;
const __u64 _DRM_IOCTL_I915_GEM_MADVISE = DRM_IOCTL_I915_GEM_MADVISE;
#undef DRM_IOCTL_I915_GEM_MADVISE
const __u64 DRM_IOCTL_I915_GEM_MADVISE = _DRM_IOCTL_I915_GEM_MADVISE;
const __u64 _DRM_IOCTL_I915_OVERLAY_PUT_IMAGE = DRM_IOCTL_I915_OVERLAY_PUT_IMAGE;
#undef DRM_IOCTL_I915_OVERLAY_PUT_IMAGE
const __u64 DRM_IOCTL_I915_OVERLAY_PUT_IMAGE = _DRM_IOCTL_I915_OVERLAY_PUT_IMAGE;
const __u64 _DRM_IOCTL_I915_OVERLAY_ATTRS = DRM_IOCTL_I915_OVERLAY_ATTRS;
#undef DRM_IOCTL_I915_OVERLAY_ATTRS
const __u64 DRM_IOCTL_I915_OVERLAY_ATTRS = _DRM_IOCTL_I915_OVERLAY_ATTRS;
const __u64 _DRM_IOCTL_I915_SET_SPRITE_COLORKEY = DRM_IOCTL_I915_SET_SPRITE_COLORKEY;
#undef DRM_IOCTL_I915_SET_SPRITE_COLORKEY
const __u64 DRM_IOCTL_I915_SET_SPRITE_COLORKEY = _DRM_IOCTL_I915_SET_SPRITE_COLORKEY;
const __u64 _DRM_IOCTL_I915_GET_SPRITE_COLORKEY = DRM_IOCTL_I915_GET_SPRITE_COLORKEY;
#undef DRM_IOCTL_I915_GET_SPRITE_COLORKEY
const __u64 DRM_IOCTL_I915_GET_SPRITE_COLORKEY = _DRM_IOCTL_I915_GET_SPRITE_COLORKEY;
const __u64 _DRM_IOCTL_I915_GEM_WAIT = DRM_IOCTL_I915_GEM_WAIT;
#undef DRM_IOCTL_I915_GEM_WAIT
const __u64 DRM_IOCTL_I915_GEM_WAIT = _DRM_IOCTL_I915_GEM_WAIT;
const __u64 _DRM_IOCTL_I915_GEM_CONTEXT_DESTROY = DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
#undef DRM_IOCTL_I915_GEM_CONTEXT_DESTROY
const __u64 DRM_IOCTL_I915_GEM_CONTEXT_DESTROY = _DRM_IOCTL_I915_GEM_CONTEXT_DESTROY;
const __u64 _DRM_IOCTL_I915_PERF_OPEN = DRM_IOCTL_I915_PERF_OPEN;
#undef DRM_IOCTL_I915_PERF_OPEN
const __u64 DRM_IOCTL_I915_PERF_OPEN = _DRM_IOCTL_I915_PERF_OPEN;
const __u64 _DRM_IOCTL_I915_PERF_ADD_CONFIG = DRM_IOCTL_I915_PERF_ADD_CONFIG;
#undef DRM_IOCTL_I915_PERF_ADD_CONFIG
const __u64 DRM_IOCTL_I915_PERF_ADD_CONFIG = _DRM_IOCTL_I915_PERF_ADD_CONFIG;
const __u64 _DRM_IOCTL_I915_PERF_REMOVE_CONFIG = DRM_IOCTL_I915_PERF_REMOVE_CONFIG;
#undef DRM_IOCTL_I915_PERF_REMOVE_CONFIG
const __u64 DRM_IOCTL_I915_PERF_REMOVE_CONFIG = _DRM_IOCTL_I915_PERF_REMOVE_CONFIG;
const __u64 _DRM_IOCTL_I915_QUERY = DRM_IOCTL_I915_QUERY;
#undef DRM_IOCTL_I915_QUERY
const __u64 DRM_IOCTL_I915_QUERY = _DRM_IOCTL_I915_QUERY;
const __u64 _DRM_IOCTL_I915_GEM_VM_CREATE = DRM_IOCTL_I915_GEM_VM_CREATE;
#undef DRM_IOCTL_I915_GEM_VM_CREATE
const __u64 DRM_IOCTL_I915_GEM_VM_CREATE = _DRM_IOCTL_I915_GEM_VM_CREATE;
const __u64 _DRM_IOCTL_I915_GEM_VM_DESTROY = DRM_IOCTL_I915_GEM_VM_DESTROY;
#undef DRM_IOCTL_I915_GEM_VM_DESTROY
const __u64 DRM_IOCTL_I915_GEM_VM_DESTROY = _DRM_IOCTL_I915_GEM_VM_DESTROY;

@ -0,0 +1,13 @@
FILES=$(rg 'DRM_IO(.?)(.?)\(0' /usr/include/libdrm/drm.h | awk '{print $2}')
for F in $FILES; do
echo "const __u64 _$F = $F;"
echo "#undef $F"
echo "const __u64 $F = _$F;"
done
FILES=$(rg 'DRM_IO(.?)(.?)\(' /usr/include/libdrm/i915_drm.h | awk '{print $2}')
for F in $FILES; do
echo "const __u64 _$F = $F;"
echo "#undef $F"
echo "const __u64 $F = _$F;"
done

@ -17,11 +17,11 @@ pub struct Device {
#[derive(Debug)] #[derive(Debug)]
pub struct Engine { pub struct Engine {
pub info: uapi::DrmI915EngineInfo, pub info: uapi::i915::EngineInfo,
} }
pub fn find_i915_device() -> Option<Device> { pub fn find_device() -> Option<Device> {
uapi::find_i915_node().and_then(|file| Device::from_path(file.path?)) uapi::i915::find_node().and_then(|file| Device::from_path(file.path?))
} }
impl Device { impl Device {
@ -47,7 +47,7 @@ impl Device {
}) })
} }
pub fn get_engines(&self) -> Option<Vec<Engine>> { pub fn get_engines(&self) -> Option<Vec<Engine>> {
uapi::get_engines(self.node.fd.as_raw_fd()).map(|engines| { uapi::i915::get_engines(self.node.fd.as_raw_fd()).map(|engines| {
engines.into_iter().map(|engine_info| { engines.into_iter().map(|engine_info| {
Engine { Engine {
info: engine_info, info: engine_info,
@ -56,6 +56,6 @@ impl Device {
}) })
} }
pub fn get_param(&self, param: u32) -> Option<i32> { pub fn get_param(&self, param: u32) -> Option<i32> {
uapi::get_param(self.node.fd.as_raw_fd(), param as i32) uapi::i915::get_param(self.node.fd.as_raw_fd(), param as i32)
} }
} }

@ -1 +1 @@
pub mod drm_i915; pub mod i915;

@ -0,0 +1,159 @@
use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::ffi::{OsString, c_void};
use libc;
use crate::gpu::i915::DrmDeviceNode;
use super::native;
use super::get_drm_version;
use std::fs;
use std::fs::File;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EngineClass {
Render, Copy, Video, VideoEnhance, Compute, Invalid
}
#[derive(Debug)]
pub struct EngineClassInstance {
pub engine_class: EngineClass,
pub engine_instance: u16,
}
pub type EngineInfoFlags = u64;
#[derive(Debug)]
pub struct EngineInfo {
pub engine: EngineClassInstance,
pub logical_instance: u16,
pub flags: EngineInfoFlags,
pub capabilities: u64,
}
fn engine_class_from_u16(engine_class: u16) -> EngineClass {
match engine_class {
0 => EngineClass::Render,
1 => EngineClass::Copy,
2 => EngineClass::Video,
3 => EngineClass::VideoEnhance,
4 => EngineClass::Compute,
_ => EngineClass::Invalid,
}
}
fn engine_class_instance_from_native(engine_class_instance: native::i915_engine_class_instance) -> EngineClassInstance {
EngineClassInstance {
engine_class: engine_class_from_u16(engine_class_instance.engine_class),
engine_instance: engine_class_instance.engine_instance,
}
}
fn engine_info_from_native(engine_info: native::drm_i915_engine_info) -> EngineInfo {
EngineInfo {
engine: engine_class_instance_from_native(engine_info.engine),
logical_instance: engine_info.logical_instance,
flags: engine_info.flags,
capabilities: engine_info.capabilities,
}
}
impl EngineInfo {
pub fn to_native(&self) -> native::drm_i915_engine_info {
native::drm_i915_engine_info {
engine: native::i915_engine_class_instance {
engine_class: match self.engine.engine_class {
EngineClass::Render => 0,
EngineClass::Copy => 1,
EngineClass::Video => 2,
EngineClass::VideoEnhance => 3,
EngineClass::Compute => 4,
EngineClass::Invalid => 0xFFFF,
},
engine_instance: self.engine.engine_instance,
},
logical_instance: self.logical_instance,
flags: self.flags,
capabilities: self.capabilities,
rsvd0: 0,
rsvd1: [0; 3],
rsvd2: [0; 3],
}
}
pub fn from_native(engine_info: native::drm_i915_engine_info) -> EngineInfo {
engine_info_from_native(engine_info)
}
}
pub fn get_engines(fd: RawFd) -> Option<Vec<EngineInfo>> {
unsafe {
let mut query_item = native::drm_i915_query_item {
query_id: native::DRM_I915_QUERY_ENGINE_INFO as u64,
length: 0,
data_ptr: core::ptr::null_mut::<c_void>() as u64,
flags: 0,
};
let mut query = native::drm_i915_query {
items_ptr: (&mut query_item) as *mut native::drm_i915_query_item as u64,
num_items: 1,
flags: 0,
};
let res = libc::ioctl(fd.as_raw_fd(), native::DRM_IOCTL_I915_QUERY, &mut query);
if res != 0 {
return None;
}
let engine_info = libc::malloc(query_item.length as usize)
as *mut native::drm_i915_query_engine_info;
libc::memset(engine_info as *mut c_void, 0, query_item.length as usize);
query_item.data_ptr = engine_info as u64;
let res = libc::ioctl(fd.as_raw_fd(), native::DRM_IOCTL_I915_QUERY, &mut query);
if res != 0 {
return None;
}
let engine_data = engine_info.as_mut().unwrap();
let engines = engine_data.engines.as_mut_slice(engine_data.num_engines as usize);
let mut engines_res: Vec<EngineInfo> = Vec::new();
for i in 0..engine_data.num_engines {
let engine = EngineInfo::from_native(engines[i as usize]);
engines_res.push(engine);
}
Some(engines_res)
}
}
pub fn get_param(fd: RawFd, param_id: i32) -> Option<i32> {
unsafe {
let mut value: i32 = 0;
let mut param = native::drm_i915_getparam {
param: param_id,
value: &mut value as *mut i32
};
let res = libc::ioctl(fd, native::DRM_IOCTL_I915_GETPARAM, &mut param);
if res != 0 {
return None;
}
Some(value)
}
}
pub fn find_node() -> Option<DrmDeviceNode> {
let inodes = fs::read_dir("/dev/dri").ok()?;
for inode in inodes {
let inode = inode.ok()?;
let path = inode.path();
let path = path.to_str()?;
if path.starts_with("/dev/dri/renderD") {
let file = File::open(path).unwrap();
let dev = get_drm_version(file.as_raw_fd());
if dev.is_some() && dev.unwrap().name.to_str().unwrap() == "i915" {
return Some(DrmDeviceNode {
fd: OwnedFd::from(file),
path: Some(OsString::from(path)),
});
}
}
}
None
}
pub fn find_fd() -> Option<RawFd> {
return find_node().map(|node| node.fd.as_raw_fd());
}

@ -1,13 +1,12 @@
#![allow(non_camel_case_types)] #![allow(non_camel_case_types)]
use std::os::fd::{AsRawFd, OwnedFd, RawFd}; use std::os::fd::RawFd;
use std::ffi::{CStr, OsString, c_void}; use std::ffi::{CStr, OsString};
use libc; use libc;
use crate::gpu::drm_i915::DrmDeviceNode;
use super::native; use super::native;
use std::fs;
use std::fs::File; pub mod i915;
#[derive(Debug)] #[derive(Debug)]
pub struct DrmVersion { pub struct DrmVersion {
@ -57,153 +56,3 @@ pub fn get_drm_version(fd: RawFd) -> Option<DrmVersion> {
res res
} }
} }
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum DrmI915EngineClass {
Render, Copy, Video, VideoEnhance, Compute, Invalid
}
#[derive(Debug)]
pub struct DrmI915EngineClassInstance {
pub engine_class: DrmI915EngineClass,
pub engine_instance: u16,
}
pub type DrmI915EngineInfoFlags = u64;
#[derive(Debug)]
pub struct DrmI915EngineInfo {
pub engine: DrmI915EngineClassInstance,
pub logical_instance: u16,
pub flags: DrmI915EngineInfoFlags,
pub capabilities: u64,
}
fn engine_class_from_u16(engine_class: u16) -> DrmI915EngineClass {
match engine_class {
0 => DrmI915EngineClass::Render,
1 => DrmI915EngineClass::Copy,
2 => DrmI915EngineClass::Video,
3 => DrmI915EngineClass::VideoEnhance,
4 => DrmI915EngineClass::Compute,
_ => DrmI915EngineClass::Invalid,
}
}
fn engine_class_instance_from_native(engine_class_instance: native::i915_engine_class_instance) -> DrmI915EngineClassInstance {
DrmI915EngineClassInstance {
engine_class: engine_class_from_u16(engine_class_instance.engine_class),
engine_instance: engine_class_instance.engine_instance,
}
}
fn engine_info_from_native(engine_info: native::drm_i915_engine_info) -> DrmI915EngineInfo {
DrmI915EngineInfo {
engine: engine_class_instance_from_native(engine_info.engine),
logical_instance: engine_info.logical_instance,
flags: engine_info.flags,
capabilities: engine_info.capabilities,
}
}
impl DrmI915EngineInfo {
pub fn to_native(&self) -> native::drm_i915_engine_info {
native::drm_i915_engine_info {
engine: native::i915_engine_class_instance {
engine_class: match self.engine.engine_class {
DrmI915EngineClass::Render => 0,
DrmI915EngineClass::Copy => 1,
DrmI915EngineClass::Video => 2,
DrmI915EngineClass::VideoEnhance => 3,
DrmI915EngineClass::Compute => 4,
DrmI915EngineClass::Invalid => 0xFFFF,
},
engine_instance: self.engine.engine_instance,
},
logical_instance: self.logical_instance,
flags: self.flags,
capabilities: self.capabilities,
rsvd0: 0,
rsvd1: [0; 3],
rsvd2: [0; 3],
}
}
pub fn from_native(engine_info: native::drm_i915_engine_info) -> DrmI915EngineInfo {
engine_info_from_native(engine_info)
}
}
pub fn get_engines(fd: RawFd) -> Option<Vec<DrmI915EngineInfo>> {
unsafe {
let mut query_item = native::drm_i915_query_item {
query_id: native::DRM_I915_QUERY_ENGINE_INFO as u64,
length: 0,
data_ptr: core::ptr::null_mut::<c_void>() as u64,
flags: 0,
};
let mut query = native::drm_i915_query {
items_ptr: (&mut query_item) as *mut native::drm_i915_query_item as u64,
num_items: 1,
flags: 0,
};
let res = libc::ioctl(fd.as_raw_fd(), native::DRM_IOCTL_I915_QUERY, &mut query);
if res != 0 {
return None;
}
let engine_info = libc::malloc(query_item.length as usize)
as *mut native::drm_i915_query_engine_info;
libc::memset(engine_info as *mut c_void, 0, query_item.length as usize);
query_item.data_ptr = engine_info as u64;
let res = libc::ioctl(fd.as_raw_fd(), native::DRM_IOCTL_I915_QUERY, &mut query);
if res != 0 {
return None;
}
let engine_data = engine_info.as_mut().unwrap();
let engines = engine_data.engines.as_mut_slice(engine_data.num_engines as usize);
let mut engines_res: Vec<DrmI915EngineInfo> = Vec::new();
for i in 0..engine_data.num_engines {
let engine = DrmI915EngineInfo::from_native(engines[i as usize]);
engines_res.push(engine);
}
Some(engines_res)
}
}
pub fn get_param(fd: RawFd, param_id: i32) -> Option<i32> {
unsafe {
let mut value: i32 = 0;
let mut param = native::drm_i915_getparam {
param: param_id,
value: &mut value as *mut i32
};
let res = libc::ioctl(fd, native::DRM_IOCTL_I915_GETPARAM, &mut param);
if res != 0 {
return None;
}
Some(value)
}
}
pub fn find_i915_node() -> Option<DrmDeviceNode> {
let inodes = fs::read_dir("/dev/dri").ok()?;
for inode in inodes {
let inode = inode.ok()?;
let path = inode.path();
let path = path.to_str()?;
if path.starts_with("/dev/dri/renderD") {
let file = File::open(path).unwrap();
let dev = get_drm_version(file.as_raw_fd());
if dev.is_some() && dev.unwrap().name.to_str().unwrap() == "i915" {
return Some(DrmDeviceNode {
fd: OwnedFd::from(file),
path: Some(OsString::from(path)),
});
}
}
}
None
}
pub fn find_i915_fd() -> Option<RawFd> {
return find_i915_node().map(|node| node.fd.as_raw_fd());
}

@ -1,12 +1,12 @@
use intel_gpu_uapi::*; use intel_gpu_uapi::*;
use std::fmt::format; use gpu::i915;
use std::os::fd::{AsRawFd, OwnedFd, RawFd}; use std::os::fd::{AsRawFd, OwnedFd, RawFd};
use std::fs::File; use std::fs::File;
use std::path::Path; use std::path::Path;
#[test] #[test]
fn test_i915_find_device() { fn test_i915_gpu_find_device() {
let device = gpu::drm_i915::find_i915_device(); let device = i915::find_device();
assert!(device.is_some()); assert!(device.is_some());
let drm_version = device.unwrap().driver; let drm_version = device.unwrap().driver;
assert_eq!(drm_version.name.to_str().unwrap(), "i915"); assert_eq!(drm_version.name.to_str().unwrap(), "i915");
@ -14,34 +14,34 @@ fn test_i915_find_device() {
} }
#[test] #[test]
fn test_drm_version() { fn test_i915_gpu_get_version() {
let device = gpu::drm_i915::find_i915_device(); let device = i915::find_device();
assert!(device.is_some()); assert!(device.is_some());
let drm_version = device.unwrap().driver; let drm_version = device.unwrap().driver;
assert_eq!(drm_version.name.to_str().unwrap(), "i915"); assert_eq!(drm_version.name.to_str().unwrap(), "i915");
assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics"); assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics");
let fd_null = File::open("/dev/null").expect("Failed to open /dev/null"); let fd_null = File::open("/dev/null").expect("Failed to open /dev/null");
assert!(gpu::drm_i915::Device::from_fd(OwnedFd::from(fd_null)).is_none()); assert!(i915::Device::from_fd(OwnedFd::from(fd_null)).is_none());
} }
fn has_engine_class(engines: &Vec<gpu::drm_i915::Engine>, engine_class: uapi::DrmI915EngineClass) -> bool { fn has_engine_class(engines: &Vec<i915::Engine>, engine_class: uapi::i915::EngineClass) -> bool {
engines.iter().filter(|engine| engine.info.engine.engine_class == engine_class).count() > 0 engines.iter().filter(|engine| engine.info.engine.engine_class == engine_class).count() > 0
} }
#[test] #[test]
fn test_i915_get_engines() { fn test_i915_gpu_get_engines() {
let device = gpu::drm_i915::find_i915_device().expect("Failed to find i915 device"); let device = i915::find_device().expect("Failed to find i915 device");
let drm_version = &device.driver; let drm_version = &device.driver;
assert_eq!(drm_version.name.to_str().unwrap(), "i915"); assert_eq!(drm_version.name.to_str().unwrap(), "i915");
assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics"); assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics");
let engines = device.get_engines().expect("Failed to get engines"); let engines = device.get_engines().expect("Failed to get engines");
assert!(engines.len() > 0); assert!(engines.len() > 0);
assert!(has_engine_class(&engines, uapi::DrmI915EngineClass::Render)); assert!(has_engine_class(&engines, uapi::i915::EngineClass::Render));
assert!(has_engine_class(&engines, uapi::DrmI915EngineClass::Copy)); assert!(has_engine_class(&engines, uapi::i915::EngineClass::Copy));
assert!(has_engine_class(&engines, uapi::DrmI915EngineClass::Video)); assert!(has_engine_class(&engines, uapi::i915::EngineClass::Video));
assert!(has_engine_class(&engines, uapi::DrmI915EngineClass::VideoEnhance)); assert!(has_engine_class(&engines, uapi::i915::EngineClass::VideoEnhance));
// Compute engine is not always present // Compute engine is not always present
// assert!(has_engine_class(&engines, uapi::DrmI915EngineClass::Compute)); // assert!(has_engine_class(&engines, uapi::i915::EngineClass::Compute));
} }
fn get_vendor_for_fd(fd: RawFd) -> String{ fn get_vendor_for_fd(fd: RawFd) -> String{
@ -58,8 +58,8 @@ fn get_vendor_for_fd(fd: RawFd) -> String{
} }
#[test] #[test]
fn test_i915_get_param() { fn test_i915_gpu_get_param() {
let device = gpu::drm_i915::find_i915_device().expect("Failed to find i915 device"); let device = i915::find_device().expect("Failed to find i915 device");
let drm_version = &device.driver; let drm_version = &device.driver;
assert_eq!(drm_version.name.to_str().unwrap(), "i915"); assert_eq!(drm_version.name.to_str().unwrap(), "i915");
assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics"); assert_eq!(drm_version.desc.to_str().unwrap(), "Intel Graphics");

@ -4,7 +4,7 @@ use std::ffi::CStr;
use nix::{self}; use nix::{self};
#[test] #[test]
fn test_drm_version_raw() { fn test_raw_drm_version() {
// TODO more robust render node detection // TODO more robust render node detection
let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty()) let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
.expect("Failed to open /dev/dri/renderD129"); .expect("Failed to open /dev/dri/renderD129");
@ -36,7 +36,7 @@ fn test_drm_version_raw() {
} }
#[test] #[test]
fn test_i915_query_raw() { fn test_i915_raw_query() {
let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty()) let fd = nix::fcntl::open("/dev/dri/renderD129", nix::fcntl::OFlag::O_RDWR | nix::fcntl::OFlag::O_CLOEXEC, nix::sys::stat::Mode::empty())
.expect("Failed to open /dev/dri/renderD129"); .expect("Failed to open /dev/dri/renderD129");
unsafe { unsafe {

@ -1,20 +1,20 @@
#![allow(unused_imports)] #![allow(unused_imports)]
use intel_gpu_uapi::*; use intel_gpu_uapi::*;
use uapi::find_i915_node; use uapi::i915;
use std::fs; use std::fs;
use std::{fs::File, os::fd::AsRawFd}; use std::{fs::File, os::fd::AsRawFd};
#[test] #[test]
fn test_drm_version() { fn test_i915_uapi_get_version() {
let node = find_i915_node().expect("Failed to find i915 fd"); let node = i915::find_node().expect("Failed to find i915 fd");
let drm_version = uapi::get_drm_version(node.fd.as_raw_fd()).expect("Failed to get drm version"); let drm_version = uapi::get_drm_version(node.fd.as_raw_fd()).expect("Failed to get drm version");
println!("{:?}", drm_version); println!("{:?}", drm_version);
} }
#[test] #[test]
fn test_i915_get_engines() { fn test_i915_uapi_get_engines() {
let node = find_i915_node().expect("Failed to find i915 fd"); let node = i915::find_node().expect("Failed to find i915 fd");
let engines = uapi::get_engines(node.fd.as_raw_fd()).expect("Failed to get engines"); let engines = i915::get_engines(node.fd.as_raw_fd()).expect("Failed to get engines");
println!("{:?}", engines); println!("{:?}", engines);
} }
Loading…
Cancel
Save