i915_drm.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  1. /*
  2. * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
  3. * All Rights Reserved.
  4. *
  5. * Permission is hereby granted, free of charge, to any person obtaining a
  6. * copy of this software and associated documentation files (the
  7. * "Software"), to deal in the Software without restriction, including
  8. * without limitation the rights to use, copy, modify, merge, publish,
  9. * distribute, sub license, and/or sell copies of the Software, and to
  10. * permit persons to whom the Software is furnished to do so, subject to
  11. * the following conditions:
  12. *
  13. * The above copyright notice and this permission notice (including the
  14. * next paragraph) shall be included in all copies or substantial portions
  15. * of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
  20. * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
  21. * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  22. * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  23. * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24. *
  25. */
  26. #ifndef _UAPI_I915_DRM_H_
  27. #define _UAPI_I915_DRM_H_
  28. #include "drm.h"
  29. #if defined(__cplusplus)
  30. extern "C" {
  31. #endif
  32. /* Please note that modifications to all structs defined here are
  33. * subject to backwards-compatibility constraints.
  34. */
  35. /**
  36. * DOC: uevents generated by i915 on it's device node
  37. *
  38. * I915_L3_PARITY_UEVENT - Generated when the driver receives a parity mismatch
  39. * event from the gpu l3 cache. Additional information supplied is ROW,
  40. * BANK, SUBBANK, SLICE of the affected cacheline. Userspace should keep
  41. * track of these events and if a specific cache-line seems to have a
  42. * persistent error remap it with the l3 remapping tool supplied in
  43. * intel-gpu-tools. The value supplied with the event is always 1.
  44. *
  45. * I915_ERROR_UEVENT - Generated upon error detection, currently only via
  46. * hangcheck. The error detection event is a good indicator of when things
  47. * began to go badly. The value supplied with the event is a 1 upon error
  48. * detection, and a 0 upon reset completion, signifying no more error
  49. * exists. NOTE: Disabling hangcheck or reset via module parameter will
  50. * cause the related events to not be seen.
  51. *
  52. * I915_RESET_UEVENT - Event is generated just before an attempt to reset the
  53. * the GPU. The value supplied with the event is always 1. NOTE: Disable
  54. * reset via module parameter will cause this event to not be seen.
  55. */
  56. #define I915_L3_PARITY_UEVENT "L3_PARITY_ERROR"
  57. #define I915_ERROR_UEVENT "ERROR"
  58. #define I915_RESET_UEVENT "RESET"
  59. /*
  60. * MOCS indexes used for GPU surfaces, defining the cacheability of the
  61. * surface data and the coherency for this data wrt. CPU vs. GPU accesses.
  62. */
  63. enum i915_mocs_table_index {
  64. /*
  65. * Not cached anywhere, coherency between CPU and GPU accesses is
  66. * guaranteed.
  67. */
  68. I915_MOCS_UNCACHED,
  69. /*
  70. * Cacheability and coherency controlled by the kernel automatically
  71. * based on the DRM_I915_GEM_SET_CACHING IOCTL setting and the current
  72. * usage of the surface (used for display scanout or not).
  73. */
  74. I915_MOCS_PTE,
  75. /*
  76. * Cached in all GPU caches available on the platform.
  77. * Coherency between CPU and GPU accesses to the surface is not
  78. * guaranteed without extra synchronization.
  79. */
  80. I915_MOCS_CACHED,
  81. };
  82. /* Each region is a minimum of 16k, and there are at most 255 of them.
  83. */
  84. #define I915_NR_TEX_REGIONS 255 /* table size 2k - maximum due to use
  85. * of chars for next/prev indices */
  86. #define I915_LOG_MIN_TEX_REGION_SIZE 14
  87. typedef struct _drm_i915_init {
  88. enum {
  89. I915_INIT_DMA = 0x01,
  90. I915_CLEANUP_DMA = 0x02,
  91. I915_RESUME_DMA = 0x03
  92. } func;
  93. unsigned int mmio_offset;
  94. int sarea_priv_offset;
  95. unsigned int ring_start;
  96. unsigned int ring_end;
  97. unsigned int ring_size;
  98. unsigned int front_offset;
  99. unsigned int back_offset;
  100. unsigned int depth_offset;
  101. unsigned int w;
  102. unsigned int h;
  103. unsigned int pitch;
  104. unsigned int pitch_bits;
  105. unsigned int back_pitch;
  106. unsigned int depth_pitch;
  107. unsigned int cpp;
  108. unsigned int chipset;
  109. } drm_i915_init_t;
  110. typedef struct _drm_i915_sarea {
  111. struct drm_tex_region texList[I915_NR_TEX_REGIONS + 1];
  112. int last_upload; /* last time texture was uploaded */
  113. int last_enqueue; /* last time a buffer was enqueued */
  114. int last_dispatch; /* age of the most recently dispatched buffer */
  115. int ctxOwner; /* last context to upload state */
  116. int texAge;
  117. int pf_enabled; /* is pageflipping allowed? */
  118. int pf_active;
  119. int pf_current_page; /* which buffer is being displayed? */
  120. int perf_boxes; /* performance boxes to be displayed */
  121. int width, height; /* screen size in pixels */
  122. drm_handle_t front_handle;
  123. int front_offset;
  124. int front_size;
  125. drm_handle_t back_handle;
  126. int back_offset;
  127. int back_size;
  128. drm_handle_t depth_handle;
  129. int depth_offset;
  130. int depth_size;
  131. drm_handle_t tex_handle;
  132. int tex_offset;
  133. int tex_size;
  134. int log_tex_granularity;
  135. int pitch;
  136. int rotation; /* 0, 90, 180 or 270 */
  137. int rotated_offset;
  138. int rotated_size;
  139. int rotated_pitch;
  140. int virtualX, virtualY;
  141. unsigned int front_tiled;
  142. unsigned int back_tiled;
  143. unsigned int depth_tiled;
  144. unsigned int rotated_tiled;
  145. unsigned int rotated2_tiled;
  146. int pipeA_x;
  147. int pipeA_y;
  148. int pipeA_w;
  149. int pipeA_h;
  150. int pipeB_x;
  151. int pipeB_y;
  152. int pipeB_w;
  153. int pipeB_h;
  154. /* fill out some space for old userspace triple buffer */
  155. drm_handle_t unused_handle;
  156. __u32 unused1, unused2, unused3;
  157. /* buffer object handles for static buffers. May change
  158. * over the lifetime of the client.
  159. */
  160. __u32 front_bo_handle;
  161. __u32 back_bo_handle;
  162. __u32 unused_bo_handle;
  163. __u32 depth_bo_handle;
  164. } drm_i915_sarea_t;
  165. /* due to userspace building against these headers we need some compat here */
  166. #define planeA_x pipeA_x
  167. #define planeA_y pipeA_y
  168. #define planeA_w pipeA_w
  169. #define planeA_h pipeA_h
  170. #define planeB_x pipeB_x
  171. #define planeB_y pipeB_y
  172. #define planeB_w pipeB_w
  173. #define planeB_h pipeB_h
  174. /* Flags for perf_boxes
  175. */
  176. #define I915_BOX_RING_EMPTY 0x1
  177. #define I915_BOX_FLIP 0x2
  178. #define I915_BOX_WAIT 0x4
  179. #define I915_BOX_TEXTURE_LOAD 0x8
  180. #define I915_BOX_LOST_CONTEXT 0x10
  181. /*
  182. * i915 specific ioctls.
  183. *
  184. * The device specific ioctl range is [DRM_COMMAND_BASE, DRM_COMMAND_END) ie
  185. * [0x40, 0xa0) (a0 is excluded). The numbers below are defined as offset
  186. * against DRM_COMMAND_BASE and should be between [0x0, 0x60).
  187. */
  188. #define DRM_I915_INIT 0x00
  189. #define DRM_I915_FLUSH 0x01
  190. #define DRM_I915_FLIP 0x02
  191. #define DRM_I915_BATCHBUFFER 0x03
  192. #define DRM_I915_IRQ_EMIT 0x04
  193. #define DRM_I915_IRQ_WAIT 0x05
  194. #define DRM_I915_GETPARAM 0x06
  195. #define DRM_I915_SETPARAM 0x07
  196. #define DRM_I915_ALLOC 0x08
  197. #define DRM_I915_FREE 0x09
  198. #define DRM_I915_INIT_HEAP 0x0a
  199. #define DRM_I915_CMDBUFFER 0x0b
  200. #define DRM_I915_DESTROY_HEAP 0x0c
  201. #define DRM_I915_SET_VBLANK_PIPE 0x0d
  202. #define DRM_I915_GET_VBLANK_PIPE 0x0e
  203. #define DRM_I915_VBLANK_SWAP 0x0f
  204. #define DRM_I915_HWS_ADDR 0x11
  205. #define DRM_I915_GEM_INIT 0x13
  206. #define DRM_I915_GEM_EXECBUFFER 0x14
  207. #define DRM_I915_GEM_PIN 0x15
  208. #define DRM_I915_GEM_UNPIN 0x16
  209. #define DRM_I915_GEM_BUSY 0x17
  210. #define DRM_I915_GEM_THROTTLE 0x18
  211. #define DRM_I915_GEM_ENTERVT 0x19
  212. #define DRM_I915_GEM_LEAVEVT 0x1a
  213. #define DRM_I915_GEM_CREATE 0x1b
  214. #define DRM_I915_GEM_PREAD 0x1c
  215. #define DRM_I915_GEM_PWRITE 0x1d
  216. #define DRM_I915_GEM_MMAP 0x1e
  217. #define DRM_I915_GEM_SET_DOMAIN 0x1f
  218. #define DRM_I915_GEM_SW_FINISH 0x20
  219. #define DRM_I915_GEM_SET_TILING 0x21
  220. #define DRM_I915_GEM_GET_TILING 0x22
  221. #define DRM_I915_GEM_GET_APERTURE 0x23
  222. #define DRM_I915_GEM_MMAP_GTT 0x24
  223. #define DRM_I915_GET_PIPE_FROM_CRTC_ID 0x25
  224. #define DRM_I915_GEM_MADVISE 0x26
  225. #define DRM_I915_OVERLAY_PUT_IMAGE 0x27
  226. #define DRM_I915_OVERLAY_ATTRS 0x28
  227. #define DRM_I915_GEM_EXECBUFFER2 0x29
  228. #define DRM_I915_GEM_EXECBUFFER2_WR DRM_I915_GEM_EXECBUFFER2
  229. #define DRM_I915_GET_SPRITE_COLORKEY 0x2a
  230. #define DRM_I915_SET_SPRITE_COLORKEY 0x2b
  231. #define DRM_I915_GEM_WAIT 0x2c
  232. #define DRM_I915_GEM_CONTEXT_CREATE 0x2d
  233. #define DRM_I915_GEM_CONTEXT_DESTROY 0x2e
  234. #define DRM_I915_GEM_SET_CACHING 0x2f
  235. #define DRM_I915_GEM_GET_CACHING 0x30
  236. #define DRM_I915_REG_READ 0x31
  237. #define DRM_I915_GET_RESET_STATS 0x32
  238. #define DRM_I915_GEM_USERPTR 0x33
  239. #define DRM_I915_GEM_CONTEXT_GETPARAM 0x34
  240. #define DRM_I915_GEM_CONTEXT_SETPARAM 0x35
  241. #define DRM_I915_PERF_OPEN 0x36
  242. #define DRM_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
  243. #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
  244. #define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
  245. #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
  246. #define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
  247. #define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
  248. #define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
  249. #define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
  250. #define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
  251. #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
  252. #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
  253. #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
  254. #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
  255. #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  256. #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  257. #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
  258. #define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
  259. #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
  260. #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
  261. #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
  262. #define DRM_IOCTL_I915_GEM_EXECBUFFER2_WR DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2_WR, struct drm_i915_gem_execbuffer2)
  263. #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
  264. #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
  265. #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
  266. #define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
  267. #define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
  268. #define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
  269. #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
  270. #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
  271. #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
  272. #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
  273. #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
  274. #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
  275. #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
  276. #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
  277. #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
  278. #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
  279. #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
  280. #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
  281. #define DRM_IOCTL_I915_GET_PIPE_FROM_CRTC_ID DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_PIPE_FROM_CRTC_ID, struct drm_i915_get_pipe_from_crtc_id)
  282. #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
  283. #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
  284. #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
  285. #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  286. #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  287. #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
  288. #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
  289. #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
  290. #define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
  291. #define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
  292. #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
  293. #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
  294. #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
  295. #define DRM_IOCTL_I915_PERF_OPEN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_PERF_OPEN, struct drm_i915_perf_open_param)
  296. /* Allow drivers to submit batchbuffers directly to hardware, relying
  297. * on the security mechanisms provided by hardware.
  298. */
  299. typedef struct drm_i915_batchbuffer {
  300. int start; /* agp offset */
  301. int used; /* nr bytes in use */
  302. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  303. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  304. int num_cliprects; /* mulitpass with multiple cliprects? */
  305. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  306. } drm_i915_batchbuffer_t;
  307. /* As above, but pass a pointer to userspace buffer which can be
  308. * validated by the kernel prior to sending to hardware.
  309. */
  310. typedef struct _drm_i915_cmdbuffer {
  311. char __user *buf; /* pointer to userspace command buffer */
  312. int sz; /* nr bytes in buf */
  313. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  314. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  315. int num_cliprects; /* mulitpass with multiple cliprects? */
  316. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  317. } drm_i915_cmdbuffer_t;
  318. /* Userspace can request & wait on irq's:
  319. */
  320. typedef struct drm_i915_irq_emit {
  321. int __user *irq_seq;
  322. } drm_i915_irq_emit_t;
  323. typedef struct drm_i915_irq_wait {
  324. int irq_seq;
  325. } drm_i915_irq_wait_t;
  326. /* Ioctl to query kernel params:
  327. */
  328. #define I915_PARAM_IRQ_ACTIVE 1
  329. #define I915_PARAM_ALLOW_BATCHBUFFER 2
  330. #define I915_PARAM_LAST_DISPATCH 3
  331. #define I915_PARAM_CHIPSET_ID 4
  332. #define I915_PARAM_HAS_GEM 5
  333. #define I915_PARAM_NUM_FENCES_AVAIL 6
  334. #define I915_PARAM_HAS_OVERLAY 7
  335. #define I915_PARAM_HAS_PAGEFLIPPING 8
  336. #define I915_PARAM_HAS_EXECBUF2 9
  337. #define I915_PARAM_HAS_BSD 10
  338. #define I915_PARAM_HAS_BLT 11
  339. #define I915_PARAM_HAS_RELAXED_FENCING 12
  340. #define I915_PARAM_HAS_COHERENT_RINGS 13
  341. #define I915_PARAM_HAS_EXEC_CONSTANTS 14
  342. #define I915_PARAM_HAS_RELAXED_DELTA 15
  343. #define I915_PARAM_HAS_GEN7_SOL_RESET 16
  344. #define I915_PARAM_HAS_LLC 17
  345. #define I915_PARAM_HAS_ALIASING_PPGTT 18
  346. #define I915_PARAM_HAS_WAIT_TIMEOUT 19
  347. #define I915_PARAM_HAS_SEMAPHORES 20
  348. #define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21
  349. #define I915_PARAM_HAS_VEBOX 22
  350. #define I915_PARAM_HAS_SECURE_BATCHES 23
  351. #define I915_PARAM_HAS_PINNED_BATCHES 24
  352. #define I915_PARAM_HAS_EXEC_NO_RELOC 25
  353. #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
  354. #define I915_PARAM_HAS_WT 27
  355. #define I915_PARAM_CMD_PARSER_VERSION 28
  356. #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
  357. #define I915_PARAM_MMAP_VERSION 30
  358. #define I915_PARAM_HAS_BSD2 31
  359. #define I915_PARAM_REVISION 32
  360. #define I915_PARAM_SUBSLICE_TOTAL 33
  361. #define I915_PARAM_EU_TOTAL 34
  362. #define I915_PARAM_HAS_GPU_RESET 35
  363. #define I915_PARAM_HAS_RESOURCE_STREAMER 36
  364. #define I915_PARAM_HAS_EXEC_SOFTPIN 37
  365. #define I915_PARAM_HAS_POOLED_EU 38
  366. #define I915_PARAM_MIN_EU_IN_POOL 39
  367. #define I915_PARAM_MMAP_GTT_VERSION 40
  368. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports user defined execution
  369. * priorities and the driver will attempt to execute batches in priority order.
  370. */
  371. #define I915_PARAM_HAS_SCHEDULER 41
  372. #define I915_PARAM_HUC_STATUS 42
  373. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to opt-out of
  374. * synchronisation with implicit fencing on individual objects.
  375. * See EXEC_OBJECT_ASYNC.
  376. */
  377. #define I915_PARAM_HAS_EXEC_ASYNC 43
  378. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports explicit fence support -
  379. * both being able to pass in a sync_file fd to wait upon before executing,
  380. * and being able to return a new sync_file fd that is signaled when the
  381. * current request is complete. See I915_EXEC_FENCE_IN and I915_EXEC_FENCE_OUT.
  382. */
  383. #define I915_PARAM_HAS_EXEC_FENCE 44
  384. /* Query whether DRM_I915_GEM_EXECBUFFER2 supports the ability to capture
  385. * user specified bufffers for post-mortem debugging of GPU hangs. See
  386. * EXEC_OBJECT_CAPTURE.
  387. */
  388. #define I915_PARAM_HAS_EXEC_CAPTURE 45
  389. #define I915_PARAM_SLICE_MASK 46
  390. /* Assuming it's uniform for each slice, this queries the mask of subslices
  391. * per-slice for this system.
  392. */
  393. #define I915_PARAM_SUBSLICE_MASK 47
  394. /*
  395. * Query whether DRM_I915_GEM_EXECBUFFER2 supports supplying the batch buffer
  396. * as the first execobject as opposed to the last. See I915_EXEC_BATCH_FIRST.
  397. */
  398. #define I915_PARAM_HAS_EXEC_BATCH_FIRST 48
  399. typedef struct drm_i915_getparam {
  400. __s32 param;
  401. /*
  402. * WARNING: Using pointers instead of fixed-size u64 means we need to write
  403. * compat32 code. Don't repeat this mistake.
  404. */
  405. int __user *value;
  406. } drm_i915_getparam_t;
  407. /* Ioctl to set kernel params:
  408. */
  409. #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
  410. #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
  411. #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
  412. #define I915_SETPARAM_NUM_USED_FENCES 4
  413. typedef struct drm_i915_setparam {
  414. int param;
  415. int value;
  416. } drm_i915_setparam_t;
  417. /* A memory manager for regions of shared memory:
  418. */
  419. #define I915_MEM_REGION_AGP 1
  420. typedef struct drm_i915_mem_alloc {
  421. int region;
  422. int alignment;
  423. int size;
  424. int __user *region_offset; /* offset from start of fb or agp */
  425. } drm_i915_mem_alloc_t;
  426. typedef struct drm_i915_mem_free {
  427. int region;
  428. int region_offset;
  429. } drm_i915_mem_free_t;
  430. typedef struct drm_i915_mem_init_heap {
  431. int region;
  432. int size;
  433. int start;
  434. } drm_i915_mem_init_heap_t;
  435. /* Allow memory manager to be torn down and re-initialized (eg on
  436. * rotate):
  437. */
  438. typedef struct drm_i915_mem_destroy_heap {
  439. int region;
  440. } drm_i915_mem_destroy_heap_t;
  441. /* Allow X server to configure which pipes to monitor for vblank signals
  442. */
  443. #define DRM_I915_VBLANK_PIPE_A 1
  444. #define DRM_I915_VBLANK_PIPE_B 2
  445. typedef struct drm_i915_vblank_pipe {
  446. int pipe;
  447. } drm_i915_vblank_pipe_t;
  448. /* Schedule buffer swap at given vertical blank:
  449. */
  450. typedef struct drm_i915_vblank_swap {
  451. drm_drawable_t drawable;
  452. enum drm_vblank_seq_type seqtype;
  453. unsigned int sequence;
  454. } drm_i915_vblank_swap_t;
  455. typedef struct drm_i915_hws_addr {
  456. __u64 addr;
  457. } drm_i915_hws_addr_t;
  458. struct drm_i915_gem_init {
  459. /**
  460. * Beginning offset in the GTT to be managed by the DRM memory
  461. * manager.
  462. */
  463. __u64 gtt_start;
  464. /**
  465. * Ending offset in the GTT to be managed by the DRM memory
  466. * manager.
  467. */
  468. __u64 gtt_end;
  469. };
  470. struct drm_i915_gem_create {
  471. /**
  472. * Requested size for the object.
  473. *
  474. * The (page-aligned) allocated size for the object will be returned.
  475. */
  476. __u64 size;
  477. /**
  478. * Returned handle for the object.
  479. *
  480. * Object handles are nonzero.
  481. */
  482. __u32 handle;
  483. __u32 pad;
  484. };
  485. struct drm_i915_gem_pread {
  486. /** Handle for the object being read. */
  487. __u32 handle;
  488. __u32 pad;
  489. /** Offset into the object to read from */
  490. __u64 offset;
  491. /** Length of data to read */
  492. __u64 size;
  493. /**
  494. * Pointer to write the data into.
  495. *
  496. * This is a fixed-size type for 32/64 compatibility.
  497. */
  498. __u64 data_ptr;
  499. };
  500. struct drm_i915_gem_pwrite {
  501. /** Handle for the object being written to. */
  502. __u32 handle;
  503. __u32 pad;
  504. /** Offset into the object to write to */
  505. __u64 offset;
  506. /** Length of data to write */
  507. __u64 size;
  508. /**
  509. * Pointer to read the data from.
  510. *
  511. * This is a fixed-size type for 32/64 compatibility.
  512. */
  513. __u64 data_ptr;
  514. };
  515. struct drm_i915_gem_mmap {
  516. /** Handle for the object being mapped. */
  517. __u32 handle;
  518. __u32 pad;
  519. /** Offset in the object to map. */
  520. __u64 offset;
  521. /**
  522. * Length of data to map.
  523. *
  524. * The value will be page-aligned.
  525. */
  526. __u64 size;
  527. /**
  528. * Returned pointer the data was mapped at.
  529. *
  530. * This is a fixed-size type for 32/64 compatibility.
  531. */
  532. __u64 addr_ptr;
  533. /**
  534. * Flags for extended behaviour.
  535. *
  536. * Added in version 2.
  537. */
  538. __u64 flags;
  539. #define I915_MMAP_WC 0x1
  540. };
  541. struct drm_i915_gem_mmap_gtt {
  542. /** Handle for the object being mapped. */
  543. __u32 handle;
  544. __u32 pad;
  545. /**
  546. * Fake offset to use for subsequent mmap call
  547. *
  548. * This is a fixed-size type for 32/64 compatibility.
  549. */
  550. __u64 offset;
  551. };
  552. struct drm_i915_gem_set_domain {
  553. /** Handle for the object */
  554. __u32 handle;
  555. /** New read domains */
  556. __u32 read_domains;
  557. /** New write domain */
  558. __u32 write_domain;
  559. };
  560. struct drm_i915_gem_sw_finish {
  561. /** Handle for the object */
  562. __u32 handle;
  563. };
  564. struct drm_i915_gem_relocation_entry {
  565. /**
  566. * Handle of the buffer being pointed to by this relocation entry.
  567. *
  568. * It's appealing to make this be an index into the mm_validate_entry
  569. * list to refer to the buffer, but this allows the driver to create
  570. * a relocation list for state buffers and not re-write it per
  571. * exec using the buffer.
  572. */
  573. __u32 target_handle;
  574. /**
  575. * Value to be added to the offset of the target buffer to make up
  576. * the relocation entry.
  577. */
  578. __u32 delta;
  579. /** Offset in the buffer the relocation entry will be written into */
  580. __u64 offset;
  581. /**
  582. * Offset value of the target buffer that the relocation entry was last
  583. * written as.
  584. *
  585. * If the buffer has the same offset as last time, we can skip syncing
  586. * and writing the relocation. This value is written back out by
  587. * the execbuffer ioctl when the relocation is written.
  588. */
  589. __u64 presumed_offset;
  590. /**
  591. * Target memory domains read by this operation.
  592. */
  593. __u32 read_domains;
  594. /**
  595. * Target memory domains written by this operation.
  596. *
  597. * Note that only one domain may be written by the whole
  598. * execbuffer operation, so that where there are conflicts,
  599. * the application will get -EINVAL back.
  600. */
  601. __u32 write_domain;
  602. };
  603. /** @{
  604. * Intel memory domains
  605. *
  606. * Most of these just align with the various caches in
  607. * the system and are used to flush and invalidate as
  608. * objects end up cached in different domains.
  609. */
  610. /** CPU cache */
  611. #define I915_GEM_DOMAIN_CPU 0x00000001
  612. /** Render cache, used by 2D and 3D drawing */
  613. #define I915_GEM_DOMAIN_RENDER 0x00000002
  614. /** Sampler cache, used by texture engine */
  615. #define I915_GEM_DOMAIN_SAMPLER 0x00000004
  616. /** Command queue, used to load batch buffers */
  617. #define I915_GEM_DOMAIN_COMMAND 0x00000008
  618. /** Instruction cache, used by shader programs */
  619. #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
  620. /** Vertex address cache */
  621. #define I915_GEM_DOMAIN_VERTEX 0x00000020
  622. /** GTT domain - aperture and scanout */
  623. #define I915_GEM_DOMAIN_GTT 0x00000040
  624. /** WC domain - uncached access */
  625. #define I915_GEM_DOMAIN_WC 0x00000080
  626. /** @} */
  627. struct drm_i915_gem_exec_object {
  628. /**
  629. * User's handle for a buffer to be bound into the GTT for this
  630. * operation.
  631. */
  632. __u32 handle;
  633. /** Number of relocations to be performed on this buffer */
  634. __u32 relocation_count;
  635. /**
  636. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  637. * the relocations to be performed in this buffer.
  638. */
  639. __u64 relocs_ptr;
  640. /** Required alignment in graphics aperture */
  641. __u64 alignment;
  642. /**
  643. * Returned value of the updated offset of the object, for future
  644. * presumed_offset writes.
  645. */
  646. __u64 offset;
  647. };
  648. struct drm_i915_gem_execbuffer {
  649. /**
  650. * List of buffers to be validated with their relocations to be
  651. * performend on them.
  652. *
  653. * This is a pointer to an array of struct drm_i915_gem_validate_entry.
  654. *
  655. * These buffers must be listed in an order such that all relocations
  656. * a buffer is performing refer to buffers that have already appeared
  657. * in the validate list.
  658. */
  659. __u64 buffers_ptr;
  660. __u32 buffer_count;
  661. /** Offset in the batchbuffer to start execution from. */
  662. __u32 batch_start_offset;
  663. /** Bytes used in batchbuffer from batch_start_offset */
  664. __u32 batch_len;
  665. __u32 DR1;
  666. __u32 DR4;
  667. __u32 num_cliprects;
  668. /** This is a struct drm_clip_rect *cliprects */
  669. __u64 cliprects_ptr;
  670. };
  671. struct drm_i915_gem_exec_object2 {
  672. /**
  673. * User's handle for a buffer to be bound into the GTT for this
  674. * operation.
  675. */
  676. __u32 handle;
  677. /** Number of relocations to be performed on this buffer */
  678. __u32 relocation_count;
  679. /**
  680. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  681. * the relocations to be performed in this buffer.
  682. */
  683. __u64 relocs_ptr;
  684. /** Required alignment in graphics aperture */
  685. __u64 alignment;
  686. /**
  687. * When the EXEC_OBJECT_PINNED flag is specified this is populated by
  688. * the user with the GTT offset at which this object will be pinned.
  689. * When the I915_EXEC_NO_RELOC flag is specified this must contain the
  690. * presumed_offset of the object.
  691. * During execbuffer2 the kernel populates it with the value of the
  692. * current GTT offset of the object, for future presumed_offset writes.
  693. */
  694. __u64 offset;
  695. #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
  696. #define EXEC_OBJECT_NEEDS_GTT (1<<1)
  697. #define EXEC_OBJECT_WRITE (1<<2)
  698. #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
  699. #define EXEC_OBJECT_PINNED (1<<4)
  700. #define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
  701. /* The kernel implicitly tracks GPU activity on all GEM objects, and
  702. * synchronises operations with outstanding rendering. This includes
  703. * rendering on other devices if exported via dma-buf. However, sometimes
  704. * this tracking is too coarse and the user knows better. For example,
  705. * if the object is split into non-overlapping ranges shared between different
  706. * clients or engines (i.e. suballocating objects), the implicit tracking
  707. * by kernel assumes that each operation affects the whole object rather
  708. * than an individual range, causing needless synchronisation between clients.
  709. * The kernel will also forgo any CPU cache flushes prior to rendering from
  710. * the object as the client is expected to be also handling such domain
  711. * tracking.
  712. *
  713. * The kernel maintains the implicit tracking in order to manage resources
  714. * used by the GPU - this flag only disables the synchronisation prior to
  715. * rendering with this object in this execbuf.
  716. *
  717. * Opting out of implicit synhronisation requires the user to do its own
  718. * explicit tracking to avoid rendering corruption. See, for example,
  719. * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
  720. */
  721. #define EXEC_OBJECT_ASYNC (1<<6)
  722. /* Request that the contents of this execobject be copied into the error
  723. * state upon a GPU hang involving this batch for post-mortem debugging.
  724. * These buffers are recorded in no particular order as "user" in
  725. * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see
  726. * if the kernel supports this flag.
  727. */
  728. #define EXEC_OBJECT_CAPTURE (1<<7)
  729. /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
  730. #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)
  731. __u64 flags;
  732. union {
  733. __u64 rsvd1;
  734. __u64 pad_to_size;
  735. };
  736. __u64 rsvd2;
  737. };
  738. struct drm_i915_gem_execbuffer2 {
  739. /**
  740. * List of gem_exec_object2 structs
  741. */
  742. __u64 buffers_ptr;
  743. __u32 buffer_count;
  744. /** Offset in the batchbuffer to start execution from. */
  745. __u32 batch_start_offset;
  746. /** Bytes used in batchbuffer from batch_start_offset */
  747. __u32 batch_len;
  748. __u32 DR1;
  749. __u32 DR4;
  750. __u32 num_cliprects;
  751. /** This is a struct drm_clip_rect *cliprects */
  752. __u64 cliprects_ptr;
  753. #define I915_EXEC_RING_MASK (7<<0)
  754. #define I915_EXEC_DEFAULT (0<<0)
  755. #define I915_EXEC_RENDER (1<<0)
  756. #define I915_EXEC_BSD (2<<0)
  757. #define I915_EXEC_BLT (3<<0)
  758. #define I915_EXEC_VEBOX (4<<0)
  759. /* Used for switching the constants addressing mode on gen4+ RENDER ring.
  760. * Gen6+ only supports relative addressing to dynamic state (default) and
  761. * absolute addressing.
  762. *
  763. * These flags are ignored for the BSD and BLT rings.
  764. */
  765. #define I915_EXEC_CONSTANTS_MASK (3<<6)
  766. #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
  767. #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
  768. #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
  769. __u64 flags;
  770. __u64 rsvd1; /* now used for context info */
  771. __u64 rsvd2;
  772. };
  773. /** Resets the SO write offset registers for transform feedback on gen7. */
  774. #define I915_EXEC_GEN7_SOL_RESET (1<<8)
  775. /** Request a privileged ("secure") batch buffer. Note only available for
  776. * DRM_ROOT_ONLY | DRM_MASTER processes.
  777. */
  778. #define I915_EXEC_SECURE (1<<9)
  779. /** Inform the kernel that the batch is and will always be pinned. This
  780. * negates the requirement for a workaround to be performed to avoid
  781. * an incoherent CS (such as can be found on 830/845). If this flag is
  782. * not passed, the kernel will endeavour to make sure the batch is
  783. * coherent with the CS before execution. If this flag is passed,
  784. * userspace assumes the responsibility for ensuring the same.
  785. */
  786. #define I915_EXEC_IS_PINNED (1<<10)
  787. /** Provide a hint to the kernel that the command stream and auxiliary
  788. * state buffers already holds the correct presumed addresses and so the
  789. * relocation process may be skipped if no buffers need to be moved in
  790. * preparation for the execbuffer.
  791. */
  792. #define I915_EXEC_NO_RELOC (1<<11)
  793. /** Use the reloc.handle as an index into the exec object array rather
  794. * than as the per-file handle.
  795. */
  796. #define I915_EXEC_HANDLE_LUT (1<<12)
  797. /** Used for switching BSD rings on the platforms with two BSD rings */
  798. #define I915_EXEC_BSD_SHIFT (13)
  799. #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
  800. /* default ping-pong mode */
  801. #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
  802. #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
  803. #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
  804. /** Tell the kernel that the batchbuffer is processed by
  805. * the resource streamer.
  806. */
  807. #define I915_EXEC_RESOURCE_STREAMER (1<<15)
  808. /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
  809. * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
  810. * the batch.
  811. *
  812. * Returns -EINVAL if the sync_file fd cannot be found.
  813. */
  814. #define I915_EXEC_FENCE_IN (1<<16)
  815. /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
  816. * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
  817. * to the caller, and it should be close() after use. (The fd is a regular
  818. * file descriptor and will be cleaned up on process termination. It holds
  819. * a reference to the request, but nothing else.)
  820. *
  821. * The sync_file fd can be combined with other sync_file and passed either
  822. * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
  823. * will only occur after this request completes), or to other devices.
  824. *
  825. * Using I915_EXEC_FENCE_OUT requires use of
  826. * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
  827. * back to userspace. Failure to do so will cause the out-fence to always
  828. * be reported as zero, and the real fence fd to be leaked.
  829. */
  830. #define I915_EXEC_FENCE_OUT (1<<17)
  831. /*
  832. * Traditionally the execbuf ioctl has only considered the final element in
  833. * the execobject[] to be the executable batch. Often though, the client
  834. * will known the batch object prior to construction and being able to place
  835. * it into the execobject[] array first can simplify the relocation tracking.
  836. * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
  837. * execobject[] as the * batch instead (the default is to use the last
  838. * element).
  839. */
  840. #define I915_EXEC_BATCH_FIRST (1<<18)
  841. #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_BATCH_FIRST<<1))
  842. #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
  843. #define i915_execbuffer2_set_context_id(eb2, context) \
  844. (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
  845. #define i915_execbuffer2_get_context_id(eb2) \
  846. ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
  847. struct drm_i915_gem_pin {
  848. /** Handle of the buffer to be pinned. */
  849. __u32 handle;
  850. __u32 pad;
  851. /** alignment required within the aperture */
  852. __u64 alignment;
  853. /** Returned GTT offset of the buffer. */
  854. __u64 offset;
  855. };
  856. struct drm_i915_gem_unpin {
  857. /** Handle of the buffer to be unpinned. */
  858. __u32 handle;
  859. __u32 pad;
  860. };
  861. struct drm_i915_gem_busy {
  862. /** Handle of the buffer to check for busy */
  863. __u32 handle;
  864. /** Return busy status
  865. *
  866. * A return of 0 implies that the object is idle (after
  867. * having flushed any pending activity), and a non-zero return that
  868. * the object is still in-flight on the GPU. (The GPU has not yet
  869. * signaled completion for all pending requests that reference the
  870. * object.) An object is guaranteed to become idle eventually (so
  871. * long as no new GPU commands are executed upon it). Due to the
  872. * asynchronous nature of the hardware, an object reported
  873. * as busy may become idle before the ioctl is completed.
  874. *
  875. * Furthermore, if the object is busy, which engine is busy is only
  876. * provided as a guide. There are race conditions which prevent the
  877. * report of which engines are busy from being always accurate.
  878. * However, the converse is not true. If the object is idle, the
  879. * result of the ioctl, that all engines are idle, is accurate.
  880. *
  881. * The returned dword is split into two fields to indicate both
  882. * the engines on which the object is being read, and the
  883. * engine on which it is currently being written (if any).
  884. *
  885. * The low word (bits 0:15) indicate if the object is being written
  886. * to by any engine (there can only be one, as the GEM implicit
  887. * synchronisation rules force writes to be serialised). Only the
  888. * engine for the last write is reported.
  889. *
  890. * The high word (bits 16:31) are a bitmask of which engines are
  891. * currently reading from the object. Multiple engines may be
  892. * reading from the object simultaneously.
  893. *
  894. * The value of each engine is the same as specified in the
  895. * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
  896. * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
  897. * the I915_EXEC_RENDER engine for execution, and so it is never
  898. * reported as active itself. Some hardware may have parallel
  899. * execution engines, e.g. multiple media engines, which are
  900. * mapped to the same identifier in the EXECBUFFER2 ioctl and
  901. * so are not separately reported for busyness.
  902. *
  903. * Caveat emptor:
  904. * Only the boolean result of this query is reliable; that is whether
  905. * the object is idle or busy. The report of which engines are busy
  906. * should be only used as a heuristic.
  907. */
  908. __u32 busy;
  909. };
  910. /**
  911. * I915_CACHING_NONE
  912. *
  913. * GPU access is not coherent with cpu caches. Default for machines without an
  914. * LLC.
  915. */
  916. #define I915_CACHING_NONE 0
  917. /**
  918. * I915_CACHING_CACHED
  919. *
  920. * GPU access is coherent with cpu caches and furthermore the data is cached in
  921. * last-level caches shared between cpu cores and the gpu GT. Default on
  922. * machines with HAS_LLC.
  923. */
  924. #define I915_CACHING_CACHED 1
  925. /**
  926. * I915_CACHING_DISPLAY
  927. *
  928. * Special GPU caching mode which is coherent with the scanout engines.
  929. * Transparently falls back to I915_CACHING_NONE on platforms where no special
  930. * cache mode (like write-through or gfdt flushing) is available. The kernel
  931. * automatically sets this mode when using a buffer as a scanout target.
  932. * Userspace can manually set this mode to avoid a costly stall and clflush in
  933. * the hotpath of drawing the first frame.
  934. */
  935. #define I915_CACHING_DISPLAY 2
  936. struct drm_i915_gem_caching {
  937. /**
  938. * Handle of the buffer to set/get the caching level of. */
  939. __u32 handle;
  940. /**
  941. * Cacheing level to apply or return value
  942. *
  943. * bits0-15 are for generic caching control (i.e. the above defined
  944. * values). bits16-31 are reserved for platform-specific variations
  945. * (e.g. l3$ caching on gen7). */
  946. __u32 caching;
  947. };
  948. #define I915_TILING_NONE 0
  949. #define I915_TILING_X 1
  950. #define I915_TILING_Y 2
  951. #define I915_TILING_LAST I915_TILING_Y
  952. #define I915_BIT_6_SWIZZLE_NONE 0
  953. #define I915_BIT_6_SWIZZLE_9 1
  954. #define I915_BIT_6_SWIZZLE_9_10 2
  955. #define I915_BIT_6_SWIZZLE_9_11 3
  956. #define I915_BIT_6_SWIZZLE_9_10_11 4
  957. /* Not seen by userland */
  958. #define I915_BIT_6_SWIZZLE_UNKNOWN 5
  959. /* Seen by userland. */
  960. #define I915_BIT_6_SWIZZLE_9_17 6
  961. #define I915_BIT_6_SWIZZLE_9_10_17 7
  962. struct drm_i915_gem_set_tiling {
  963. /** Handle of the buffer to have its tiling state updated */
  964. __u32 handle;
  965. /**
  966. * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  967. * I915_TILING_Y).
  968. *
  969. * This value is to be set on request, and will be updated by the
  970. * kernel on successful return with the actual chosen tiling layout.
  971. *
  972. * The tiling mode may be demoted to I915_TILING_NONE when the system
  973. * has bit 6 swizzling that can't be managed correctly by GEM.
  974. *
  975. * Buffer contents become undefined when changing tiling_mode.
  976. */
  977. __u32 tiling_mode;
  978. /**
  979. * Stride in bytes for the object when in I915_TILING_X or
  980. * I915_TILING_Y.
  981. */
  982. __u32 stride;
  983. /**
  984. * Returned address bit 6 swizzling required for CPU access through
  985. * mmap mapping.
  986. */
  987. __u32 swizzle_mode;
  988. };
  989. struct drm_i915_gem_get_tiling {
  990. /** Handle of the buffer to get tiling state for. */
  991. __u32 handle;
  992. /**
  993. * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  994. * I915_TILING_Y).
  995. */
  996. __u32 tiling_mode;
  997. /**
  998. * Returned address bit 6 swizzling required for CPU access through
  999. * mmap mapping.
  1000. */
  1001. __u32 swizzle_mode;
  1002. /**
  1003. * Returned address bit 6 swizzling required for CPU access through
  1004. * mmap mapping whilst bound.
  1005. */
  1006. __u32 phys_swizzle_mode;
  1007. };
  1008. struct drm_i915_gem_get_aperture {
  1009. /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
  1010. __u64 aper_size;
  1011. /**
  1012. * Available space in the aperture used by i915_gem_execbuffer, in
  1013. * bytes
  1014. */
  1015. __u64 aper_available_size;
  1016. };
  1017. struct drm_i915_get_pipe_from_crtc_id {
  1018. /** ID of CRTC being requested **/
  1019. __u32 crtc_id;
  1020. /** pipe of requested CRTC **/
  1021. __u32 pipe;
  1022. };
  1023. #define I915_MADV_WILLNEED 0
  1024. #define I915_MADV_DONTNEED 1
  1025. #define __I915_MADV_PURGED 2 /* internal state */
  1026. struct drm_i915_gem_madvise {
  1027. /** Handle of the buffer to change the backing store advice */
  1028. __u32 handle;
  1029. /* Advice: either the buffer will be needed again in the near future,
  1030. * or wont be and could be discarded under memory pressure.
  1031. */
  1032. __u32 madv;
  1033. /** Whether the backing store still exists. */
  1034. __u32 retained;
  1035. };
  1036. /* flags */
  1037. #define I915_OVERLAY_TYPE_MASK 0xff
  1038. #define I915_OVERLAY_YUV_PLANAR 0x01
  1039. #define I915_OVERLAY_YUV_PACKED 0x02
  1040. #define I915_OVERLAY_RGB 0x03
  1041. #define I915_OVERLAY_DEPTH_MASK 0xff00
  1042. #define I915_OVERLAY_RGB24 0x1000
  1043. #define I915_OVERLAY_RGB16 0x2000
  1044. #define I915_OVERLAY_RGB15 0x3000
  1045. #define I915_OVERLAY_YUV422 0x0100
  1046. #define I915_OVERLAY_YUV411 0x0200
  1047. #define I915_OVERLAY_YUV420 0x0300
  1048. #define I915_OVERLAY_YUV410 0x0400
  1049. #define I915_OVERLAY_SWAP_MASK 0xff0000
  1050. #define I915_OVERLAY_NO_SWAP 0x000000
  1051. #define I915_OVERLAY_UV_SWAP 0x010000
  1052. #define I915_OVERLAY_Y_SWAP 0x020000
  1053. #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
  1054. #define I915_OVERLAY_FLAGS_MASK 0xff000000
  1055. #define I915_OVERLAY_ENABLE 0x01000000
  1056. struct drm_intel_overlay_put_image {
  1057. /* various flags and src format description */
  1058. __u32 flags;
  1059. /* source picture description */
  1060. __u32 bo_handle;
  1061. /* stride values and offsets are in bytes, buffer relative */
  1062. __u16 stride_Y; /* stride for packed formats */
  1063. __u16 stride_UV;
  1064. __u32 offset_Y; /* offset for packet formats */
  1065. __u32 offset_U;
  1066. __u32 offset_V;
  1067. /* in pixels */
  1068. __u16 src_width;
  1069. __u16 src_height;
  1070. /* to compensate the scaling factors for partially covered surfaces */
  1071. __u16 src_scan_width;
  1072. __u16 src_scan_height;
  1073. /* output crtc description */
  1074. __u32 crtc_id;
  1075. __u16 dst_x;
  1076. __u16 dst_y;
  1077. __u16 dst_width;
  1078. __u16 dst_height;
  1079. };
  1080. /* flags */
  1081. #define I915_OVERLAY_UPDATE_ATTRS (1<<0)
  1082. #define I915_OVERLAY_UPDATE_GAMMA (1<<1)
  1083. #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
  1084. struct drm_intel_overlay_attrs {
  1085. __u32 flags;
  1086. __u32 color_key;
  1087. __s32 brightness;
  1088. __u32 contrast;
  1089. __u32 saturation;
  1090. __u32 gamma0;
  1091. __u32 gamma1;
  1092. __u32 gamma2;
  1093. __u32 gamma3;
  1094. __u32 gamma4;
  1095. __u32 gamma5;
  1096. };
  1097. /*
  1098. * Intel sprite handling
  1099. *
  1100. * Color keying works with a min/mask/max tuple. Both source and destination
  1101. * color keying is allowed.
  1102. *
  1103. * Source keying:
  1104. * Sprite pixels within the min & max values, masked against the color channels
  1105. * specified in the mask field, will be transparent. All other pixels will
  1106. * be displayed on top of the primary plane. For RGB surfaces, only the min
  1107. * and mask fields will be used; ranged compares are not allowed.
  1108. *
  1109. * Destination keying:
  1110. * Primary plane pixels that match the min value, masked against the color
  1111. * channels specified in the mask field, will be replaced by corresponding
  1112. * pixels from the sprite plane.
  1113. *
  1114. * Note that source & destination keying are exclusive; only one can be
  1115. * active on a given plane.
  1116. */
  1117. #define I915_SET_COLORKEY_NONE (1<<0) /* disable color key matching */
  1118. #define I915_SET_COLORKEY_DESTINATION (1<<1)
  1119. #define I915_SET_COLORKEY_SOURCE (1<<2)
  1120. struct drm_intel_sprite_colorkey {
  1121. __u32 plane_id;
  1122. __u32 min_value;
  1123. __u32 channel_mask;
  1124. __u32 max_value;
  1125. __u32 flags;
  1126. };
  1127. struct drm_i915_gem_wait {
  1128. /** Handle of BO we shall wait on */
  1129. __u32 bo_handle;
  1130. __u32 flags;
  1131. /** Number of nanoseconds to wait, Returns time remaining. */
  1132. __s64 timeout_ns;
  1133. };
  1134. struct drm_i915_gem_context_create {
  1135. /* output: id of new context*/
  1136. __u32 ctx_id;
  1137. __u32 pad;
  1138. };
  1139. struct drm_i915_gem_context_destroy {
  1140. __u32 ctx_id;
  1141. __u32 pad;
  1142. };
  1143. struct drm_i915_reg_read {
  1144. /*
  1145. * Register offset.
  1146. * For 64bit wide registers where the upper 32bits don't immediately
  1147. * follow the lower 32bits, the offset of the lower 32bits must
  1148. * be specified
  1149. */
  1150. __u64 offset;
  1151. __u64 val; /* Return value */
  1152. };
  1153. /* Known registers:
  1154. *
  1155. * Render engine timestamp - 0x2358 + 64bit - gen7+
  1156. * - Note this register returns an invalid value if using the default
  1157. * single instruction 8byte read, in order to workaround that use
  1158. * offset (0x2538 | 1) instead.
  1159. *
  1160. */
  1161. struct drm_i915_reset_stats {
  1162. __u32 ctx_id;
  1163. __u32 flags;
  1164. /* All resets since boot/module reload, for all contexts */
  1165. __u32 reset_count;
  1166. /* Number of batches lost when active in GPU, for this context */
  1167. __u32 batch_active;
  1168. /* Number of batches lost pending for execution, for this context */
  1169. __u32 batch_pending;
  1170. __u32 pad;
  1171. };
  1172. struct drm_i915_gem_userptr {
  1173. __u64 user_ptr;
  1174. __u64 user_size;
  1175. __u32 flags;
  1176. #define I915_USERPTR_READ_ONLY 0x1
  1177. #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
  1178. /**
  1179. * Returned handle for the object.
  1180. *
  1181. * Object handles are nonzero.
  1182. */
  1183. __u32 handle;
  1184. };
  1185. struct drm_i915_gem_context_param {
  1186. __u32 ctx_id;
  1187. __u32 size;
  1188. __u64 param;
  1189. #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
  1190. #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
  1191. #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
  1192. #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
  1193. #define I915_CONTEXT_PARAM_BANNABLE 0x5
  1194. __u64 value;
  1195. };
  1196. enum drm_i915_oa_format {
  1197. I915_OA_FORMAT_A13 = 1, /* HSW only */
  1198. I915_OA_FORMAT_A29, /* HSW only */
  1199. I915_OA_FORMAT_A13_B8_C8, /* HSW only */
  1200. I915_OA_FORMAT_B4_C8, /* HSW only */
  1201. I915_OA_FORMAT_A45_B8_C8, /* HSW only */
  1202. I915_OA_FORMAT_B4_C8_A16, /* HSW only */
  1203. I915_OA_FORMAT_C4_B8, /* HSW+ */
  1204. /* Gen8+ */
  1205. I915_OA_FORMAT_A12,
  1206. I915_OA_FORMAT_A12_B8_C8,
  1207. I915_OA_FORMAT_A32u40_A4u32_B8_C8,
  1208. I915_OA_FORMAT_MAX /* non-ABI */
  1209. };
  1210. enum drm_i915_perf_property_id {
  1211. /**
  1212. * Open the stream for a specific context handle (as used with
  1213. * execbuffer2). A stream opened for a specific context this way
  1214. * won't typically require root privileges.
  1215. */
  1216. DRM_I915_PERF_PROP_CTX_HANDLE = 1,
  1217. /**
  1218. * A value of 1 requests the inclusion of raw OA unit reports as
  1219. * part of stream samples.
  1220. */
  1221. DRM_I915_PERF_PROP_SAMPLE_OA,
  1222. /**
  1223. * The value specifies which set of OA unit metrics should be
  1224. * be configured, defining the contents of any OA unit reports.
  1225. */
  1226. DRM_I915_PERF_PROP_OA_METRICS_SET,
  1227. /**
  1228. * The value specifies the size and layout of OA unit reports.
  1229. */
  1230. DRM_I915_PERF_PROP_OA_FORMAT,
  1231. /**
  1232. * Specifying this property implicitly requests periodic OA unit
  1233. * sampling and (at least on Haswell) the sampling frequency is derived
  1234. * from this exponent as follows:
  1235. *
  1236. * 80ns * 2^(period_exponent + 1)
  1237. */
  1238. DRM_I915_PERF_PROP_OA_EXPONENT,
  1239. DRM_I915_PERF_PROP_MAX /* non-ABI */
  1240. };
  1241. struct drm_i915_perf_open_param {
  1242. __u32 flags;
  1243. #define I915_PERF_FLAG_FD_CLOEXEC (1<<0)
  1244. #define I915_PERF_FLAG_FD_NONBLOCK (1<<1)
  1245. #define I915_PERF_FLAG_DISABLED (1<<2)
  1246. /** The number of u64 (id, value) pairs */
  1247. __u32 num_properties;
  1248. /**
  1249. * Pointer to array of u64 (id, value) pairs configuring the stream
  1250. * to open.
  1251. */
  1252. __u64 properties_ptr;
  1253. };
  1254. /**
  1255. * Enable data capture for a stream that was either opened in a disabled state
  1256. * via I915_PERF_FLAG_DISABLED or was later disabled via
  1257. * I915_PERF_IOCTL_DISABLE.
  1258. *
  1259. * It is intended to be cheaper to disable and enable a stream than it may be
  1260. * to close and re-open a stream with the same configuration.
  1261. *
  1262. * It's undefined whether any pending data for the stream will be lost.
  1263. */
  1264. #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)
  1265. /**
  1266. * Disable data capture for a stream.
  1267. *
  1268. * It is an error to try and read a stream that is disabled.
  1269. */
  1270. #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
  1271. /**
  1272. * Common to all i915 perf records
  1273. */
  1274. struct drm_i915_perf_record_header {
  1275. __u32 type;
  1276. __u16 pad;
  1277. __u16 size;
  1278. };
  1279. enum drm_i915_perf_record_type {
  1280. /**
  1281. * Samples are the work horse record type whose contents are extensible
  1282. * and defined when opening an i915 perf stream based on the given
  1283. * properties.
  1284. *
  1285. * Boolean properties following the naming convention
  1286. * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
  1287. * every sample.
  1288. *
  1289. * The order of these sample properties given by userspace has no
  1290. * affect on the ordering of data within a sample. The order is
  1291. * documented here.
  1292. *
  1293. * struct {
  1294. * struct drm_i915_perf_record_header header;
  1295. *
  1296. * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
  1297. * };
  1298. */
  1299. DRM_I915_PERF_RECORD_SAMPLE = 1,
  1300. /*
  1301. * Indicates that one or more OA reports were not written by the
  1302. * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
  1303. * command collides with periodic sampling - which would be more likely
  1304. * at higher sampling frequencies.
  1305. */
  1306. DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
  1307. /**
  1308. * An error occurred that resulted in all pending OA reports being lost.
  1309. */
  1310. DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
  1311. DRM_I915_PERF_RECORD_MAX /* non-ABI */
  1312. };
  1313. #if defined(__cplusplus)
  1314. }
  1315. #endif
  1316. #endif /* _UAPI_I915_DRM_H_ */