i915_drm.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431
  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. typedef struct drm_i915_getparam {
  385. __s32 param;
  386. /*
  387. * WARNING: Using pointers instead of fixed-size u64 means we need to write
  388. * compat32 code. Don't repeat this mistake.
  389. */
  390. int __user *value;
  391. } drm_i915_getparam_t;
  392. /* Ioctl to set kernel params:
  393. */
  394. #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
  395. #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
  396. #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
  397. #define I915_SETPARAM_NUM_USED_FENCES 4
  398. typedef struct drm_i915_setparam {
  399. int param;
  400. int value;
  401. } drm_i915_setparam_t;
  402. /* A memory manager for regions of shared memory:
  403. */
  404. #define I915_MEM_REGION_AGP 1
  405. typedef struct drm_i915_mem_alloc {
  406. int region;
  407. int alignment;
  408. int size;
  409. int __user *region_offset; /* offset from start of fb or agp */
  410. } drm_i915_mem_alloc_t;
  411. typedef struct drm_i915_mem_free {
  412. int region;
  413. int region_offset;
  414. } drm_i915_mem_free_t;
  415. typedef struct drm_i915_mem_init_heap {
  416. int region;
  417. int size;
  418. int start;
  419. } drm_i915_mem_init_heap_t;
  420. /* Allow memory manager to be torn down and re-initialized (eg on
  421. * rotate):
  422. */
  423. typedef struct drm_i915_mem_destroy_heap {
  424. int region;
  425. } drm_i915_mem_destroy_heap_t;
  426. /* Allow X server to configure which pipes to monitor for vblank signals
  427. */
  428. #define DRM_I915_VBLANK_PIPE_A 1
  429. #define DRM_I915_VBLANK_PIPE_B 2
  430. typedef struct drm_i915_vblank_pipe {
  431. int pipe;
  432. } drm_i915_vblank_pipe_t;
  433. /* Schedule buffer swap at given vertical blank:
  434. */
  435. typedef struct drm_i915_vblank_swap {
  436. drm_drawable_t drawable;
  437. enum drm_vblank_seq_type seqtype;
  438. unsigned int sequence;
  439. } drm_i915_vblank_swap_t;
  440. typedef struct drm_i915_hws_addr {
  441. __u64 addr;
  442. } drm_i915_hws_addr_t;
  443. struct drm_i915_gem_init {
  444. /**
  445. * Beginning offset in the GTT to be managed by the DRM memory
  446. * manager.
  447. */
  448. __u64 gtt_start;
  449. /**
  450. * Ending offset in the GTT to be managed by the DRM memory
  451. * manager.
  452. */
  453. __u64 gtt_end;
  454. };
  455. struct drm_i915_gem_create {
  456. /**
  457. * Requested size for the object.
  458. *
  459. * The (page-aligned) allocated size for the object will be returned.
  460. */
  461. __u64 size;
  462. /**
  463. * Returned handle for the object.
  464. *
  465. * Object handles are nonzero.
  466. */
  467. __u32 handle;
  468. __u32 pad;
  469. };
  470. struct drm_i915_gem_pread {
  471. /** Handle for the object being read. */
  472. __u32 handle;
  473. __u32 pad;
  474. /** Offset into the object to read from */
  475. __u64 offset;
  476. /** Length of data to read */
  477. __u64 size;
  478. /**
  479. * Pointer to write the data into.
  480. *
  481. * This is a fixed-size type for 32/64 compatibility.
  482. */
  483. __u64 data_ptr;
  484. };
  485. struct drm_i915_gem_pwrite {
  486. /** Handle for the object being written to. */
  487. __u32 handle;
  488. __u32 pad;
  489. /** Offset into the object to write to */
  490. __u64 offset;
  491. /** Length of data to write */
  492. __u64 size;
  493. /**
  494. * Pointer to read the data from.
  495. *
  496. * This is a fixed-size type for 32/64 compatibility.
  497. */
  498. __u64 data_ptr;
  499. };
  500. struct drm_i915_gem_mmap {
  501. /** Handle for the object being mapped. */
  502. __u32 handle;
  503. __u32 pad;
  504. /** Offset in the object to map. */
  505. __u64 offset;
  506. /**
  507. * Length of data to map.
  508. *
  509. * The value will be page-aligned.
  510. */
  511. __u64 size;
  512. /**
  513. * Returned pointer the data was mapped at.
  514. *
  515. * This is a fixed-size type for 32/64 compatibility.
  516. */
  517. __u64 addr_ptr;
  518. /**
  519. * Flags for extended behaviour.
  520. *
  521. * Added in version 2.
  522. */
  523. __u64 flags;
  524. #define I915_MMAP_WC 0x1
  525. };
  526. struct drm_i915_gem_mmap_gtt {
  527. /** Handle for the object being mapped. */
  528. __u32 handle;
  529. __u32 pad;
  530. /**
  531. * Fake offset to use for subsequent mmap call
  532. *
  533. * This is a fixed-size type for 32/64 compatibility.
  534. */
  535. __u64 offset;
  536. };
  537. struct drm_i915_gem_set_domain {
  538. /** Handle for the object */
  539. __u32 handle;
  540. /** New read domains */
  541. __u32 read_domains;
  542. /** New write domain */
  543. __u32 write_domain;
  544. };
  545. struct drm_i915_gem_sw_finish {
  546. /** Handle for the object */
  547. __u32 handle;
  548. };
  549. struct drm_i915_gem_relocation_entry {
  550. /**
  551. * Handle of the buffer being pointed to by this relocation entry.
  552. *
  553. * It's appealing to make this be an index into the mm_validate_entry
  554. * list to refer to the buffer, but this allows the driver to create
  555. * a relocation list for state buffers and not re-write it per
  556. * exec using the buffer.
  557. */
  558. __u32 target_handle;
  559. /**
  560. * Value to be added to the offset of the target buffer to make up
  561. * the relocation entry.
  562. */
  563. __u32 delta;
  564. /** Offset in the buffer the relocation entry will be written into */
  565. __u64 offset;
  566. /**
  567. * Offset value of the target buffer that the relocation entry was last
  568. * written as.
  569. *
  570. * If the buffer has the same offset as last time, we can skip syncing
  571. * and writing the relocation. This value is written back out by
  572. * the execbuffer ioctl when the relocation is written.
  573. */
  574. __u64 presumed_offset;
  575. /**
  576. * Target memory domains read by this operation.
  577. */
  578. __u32 read_domains;
  579. /**
  580. * Target memory domains written by this operation.
  581. *
  582. * Note that only one domain may be written by the whole
  583. * execbuffer operation, so that where there are conflicts,
  584. * the application will get -EINVAL back.
  585. */
  586. __u32 write_domain;
  587. };
  588. /** @{
  589. * Intel memory domains
  590. *
  591. * Most of these just align with the various caches in
  592. * the system and are used to flush and invalidate as
  593. * objects end up cached in different domains.
  594. */
  595. /** CPU cache */
  596. #define I915_GEM_DOMAIN_CPU 0x00000001
  597. /** Render cache, used by 2D and 3D drawing */
  598. #define I915_GEM_DOMAIN_RENDER 0x00000002
  599. /** Sampler cache, used by texture engine */
  600. #define I915_GEM_DOMAIN_SAMPLER 0x00000004
  601. /** Command queue, used to load batch buffers */
  602. #define I915_GEM_DOMAIN_COMMAND 0x00000008
  603. /** Instruction cache, used by shader programs */
  604. #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
  605. /** Vertex address cache */
  606. #define I915_GEM_DOMAIN_VERTEX 0x00000020
  607. /** GTT domain - aperture and scanout */
  608. #define I915_GEM_DOMAIN_GTT 0x00000040
  609. /** @} */
  610. struct drm_i915_gem_exec_object {
  611. /**
  612. * User's handle for a buffer to be bound into the GTT for this
  613. * operation.
  614. */
  615. __u32 handle;
  616. /** Number of relocations to be performed on this buffer */
  617. __u32 relocation_count;
  618. /**
  619. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  620. * the relocations to be performed in this buffer.
  621. */
  622. __u64 relocs_ptr;
  623. /** Required alignment in graphics aperture */
  624. __u64 alignment;
  625. /**
  626. * Returned value of the updated offset of the object, for future
  627. * presumed_offset writes.
  628. */
  629. __u64 offset;
  630. };
  631. struct drm_i915_gem_execbuffer {
  632. /**
  633. * List of buffers to be validated with their relocations to be
  634. * performend on them.
  635. *
  636. * This is a pointer to an array of struct drm_i915_gem_validate_entry.
  637. *
  638. * These buffers must be listed in an order such that all relocations
  639. * a buffer is performing refer to buffers that have already appeared
  640. * in the validate list.
  641. */
  642. __u64 buffers_ptr;
  643. __u32 buffer_count;
  644. /** Offset in the batchbuffer to start execution from. */
  645. __u32 batch_start_offset;
  646. /** Bytes used in batchbuffer from batch_start_offset */
  647. __u32 batch_len;
  648. __u32 DR1;
  649. __u32 DR4;
  650. __u32 num_cliprects;
  651. /** This is a struct drm_clip_rect *cliprects */
  652. __u64 cliprects_ptr;
  653. };
  654. struct drm_i915_gem_exec_object2 {
  655. /**
  656. * User's handle for a buffer to be bound into the GTT for this
  657. * operation.
  658. */
  659. __u32 handle;
  660. /** Number of relocations to be performed on this buffer */
  661. __u32 relocation_count;
  662. /**
  663. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  664. * the relocations to be performed in this buffer.
  665. */
  666. __u64 relocs_ptr;
  667. /** Required alignment in graphics aperture */
  668. __u64 alignment;
  669. /**
  670. * When the EXEC_OBJECT_PINNED flag is specified this is populated by
  671. * the user with the GTT offset at which this object will be pinned.
  672. * When the I915_EXEC_NO_RELOC flag is specified this must contain the
  673. * presumed_offset of the object.
  674. * During execbuffer2 the kernel populates it with the value of the
  675. * current GTT offset of the object, for future presumed_offset writes.
  676. */
  677. __u64 offset;
  678. #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
  679. #define EXEC_OBJECT_NEEDS_GTT (1<<1)
  680. #define EXEC_OBJECT_WRITE (1<<2)
  681. #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
  682. #define EXEC_OBJECT_PINNED (1<<4)
  683. #define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
  684. /* The kernel implicitly tracks GPU activity on all GEM objects, and
  685. * synchronises operations with outstanding rendering. This includes
  686. * rendering on other devices if exported via dma-buf. However, sometimes
  687. * this tracking is too coarse and the user knows better. For example,
  688. * if the object is split into non-overlapping ranges shared between different
  689. * clients or engines (i.e. suballocating objects), the implicit tracking
  690. * by kernel assumes that each operation affects the whole object rather
  691. * than an individual range, causing needless synchronisation between clients.
  692. * The kernel will also forgo any CPU cache flushes prior to rendering from
  693. * the object as the client is expected to be also handling such domain
  694. * tracking.
  695. *
  696. * The kernel maintains the implicit tracking in order to manage resources
  697. * used by the GPU - this flag only disables the synchronisation prior to
  698. * rendering with this object in this execbuf.
  699. *
  700. * Opting out of implicit synhronisation requires the user to do its own
  701. * explicit tracking to avoid rendering corruption. See, for example,
  702. * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
  703. */
  704. #define EXEC_OBJECT_ASYNC (1<<6)
  705. /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
  706. #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_ASYNC<<1)
  707. __u64 flags;
  708. union {
  709. __u64 rsvd1;
  710. __u64 pad_to_size;
  711. };
  712. __u64 rsvd2;
  713. };
  714. struct drm_i915_gem_execbuffer2 {
  715. /**
  716. * List of gem_exec_object2 structs
  717. */
  718. __u64 buffers_ptr;
  719. __u32 buffer_count;
  720. /** Offset in the batchbuffer to start execution from. */
  721. __u32 batch_start_offset;
  722. /** Bytes used in batchbuffer from batch_start_offset */
  723. __u32 batch_len;
  724. __u32 DR1;
  725. __u32 DR4;
  726. __u32 num_cliprects;
  727. /** This is a struct drm_clip_rect *cliprects */
  728. __u64 cliprects_ptr;
  729. #define I915_EXEC_RING_MASK (7<<0)
  730. #define I915_EXEC_DEFAULT (0<<0)
  731. #define I915_EXEC_RENDER (1<<0)
  732. #define I915_EXEC_BSD (2<<0)
  733. #define I915_EXEC_BLT (3<<0)
  734. #define I915_EXEC_VEBOX (4<<0)
  735. /* Used for switching the constants addressing mode on gen4+ RENDER ring.
  736. * Gen6+ only supports relative addressing to dynamic state (default) and
  737. * absolute addressing.
  738. *
  739. * These flags are ignored for the BSD and BLT rings.
  740. */
  741. #define I915_EXEC_CONSTANTS_MASK (3<<6)
  742. #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
  743. #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
  744. #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
  745. __u64 flags;
  746. __u64 rsvd1; /* now used for context info */
  747. __u64 rsvd2;
  748. };
  749. /** Resets the SO write offset registers for transform feedback on gen7. */
  750. #define I915_EXEC_GEN7_SOL_RESET (1<<8)
  751. /** Request a privileged ("secure") batch buffer. Note only available for
  752. * DRM_ROOT_ONLY | DRM_MASTER processes.
  753. */
  754. #define I915_EXEC_SECURE (1<<9)
  755. /** Inform the kernel that the batch is and will always be pinned. This
  756. * negates the requirement for a workaround to be performed to avoid
  757. * an incoherent CS (such as can be found on 830/845). If this flag is
  758. * not passed, the kernel will endeavour to make sure the batch is
  759. * coherent with the CS before execution. If this flag is passed,
  760. * userspace assumes the responsibility for ensuring the same.
  761. */
  762. #define I915_EXEC_IS_PINNED (1<<10)
  763. /** Provide a hint to the kernel that the command stream and auxiliary
  764. * state buffers already holds the correct presumed addresses and so the
  765. * relocation process may be skipped if no buffers need to be moved in
  766. * preparation for the execbuffer.
  767. */
  768. #define I915_EXEC_NO_RELOC (1<<11)
  769. /** Use the reloc.handle as an index into the exec object array rather
  770. * than as the per-file handle.
  771. */
  772. #define I915_EXEC_HANDLE_LUT (1<<12)
  773. /** Used for switching BSD rings on the platforms with two BSD rings */
  774. #define I915_EXEC_BSD_SHIFT (13)
  775. #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
  776. /* default ping-pong mode */
  777. #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
  778. #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
  779. #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
  780. /** Tell the kernel that the batchbuffer is processed by
  781. * the resource streamer.
  782. */
  783. #define I915_EXEC_RESOURCE_STREAMER (1<<15)
  784. /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
  785. * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
  786. * the batch.
  787. *
  788. * Returns -EINVAL if the sync_file fd cannot be found.
  789. */
  790. #define I915_EXEC_FENCE_IN (1<<16)
  791. /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
  792. * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
  793. * to the caller, and it should be close() after use. (The fd is a regular
  794. * file descriptor and will be cleaned up on process termination. It holds
  795. * a reference to the request, but nothing else.)
  796. *
  797. * The sync_file fd can be combined with other sync_file and passed either
  798. * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
  799. * will only occur after this request completes), or to other devices.
  800. *
  801. * Using I915_EXEC_FENCE_OUT requires use of
  802. * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
  803. * back to userspace. Failure to do so will cause the out-fence to always
  804. * be reported as zero, and the real fence fd to be leaked.
  805. */
  806. #define I915_EXEC_FENCE_OUT (1<<17)
  807. #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_OUT<<1))
  808. #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
  809. #define i915_execbuffer2_set_context_id(eb2, context) \
  810. (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
  811. #define i915_execbuffer2_get_context_id(eb2) \
  812. ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
  813. struct drm_i915_gem_pin {
  814. /** Handle of the buffer to be pinned. */
  815. __u32 handle;
  816. __u32 pad;
  817. /** alignment required within the aperture */
  818. __u64 alignment;
  819. /** Returned GTT offset of the buffer. */
  820. __u64 offset;
  821. };
  822. struct drm_i915_gem_unpin {
  823. /** Handle of the buffer to be unpinned. */
  824. __u32 handle;
  825. __u32 pad;
  826. };
  827. struct drm_i915_gem_busy {
  828. /** Handle of the buffer to check for busy */
  829. __u32 handle;
  830. /** Return busy status
  831. *
  832. * A return of 0 implies that the object is idle (after
  833. * having flushed any pending activity), and a non-zero return that
  834. * the object is still in-flight on the GPU. (The GPU has not yet
  835. * signaled completion for all pending requests that reference the
  836. * object.) An object is guaranteed to become idle eventually (so
  837. * long as no new GPU commands are executed upon it). Due to the
  838. * asynchronous nature of the hardware, an object reported
  839. * as busy may become idle before the ioctl is completed.
  840. *
  841. * Furthermore, if the object is busy, which engine is busy is only
  842. * provided as a guide. There are race conditions which prevent the
  843. * report of which engines are busy from being always accurate.
  844. * However, the converse is not true. If the object is idle, the
  845. * result of the ioctl, that all engines are idle, is accurate.
  846. *
  847. * The returned dword is split into two fields to indicate both
  848. * the engines on which the object is being read, and the
  849. * engine on which it is currently being written (if any).
  850. *
  851. * The low word (bits 0:15) indicate if the object is being written
  852. * to by any engine (there can only be one, as the GEM implicit
  853. * synchronisation rules force writes to be serialised). Only the
  854. * engine for the last write is reported.
  855. *
  856. * The high word (bits 16:31) are a bitmask of which engines are
  857. * currently reading from the object. Multiple engines may be
  858. * reading from the object simultaneously.
  859. *
  860. * The value of each engine is the same as specified in the
  861. * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
  862. * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
  863. * the I915_EXEC_RENDER engine for execution, and so it is never
  864. * reported as active itself. Some hardware may have parallel
  865. * execution engines, e.g. multiple media engines, which are
  866. * mapped to the same identifier in the EXECBUFFER2 ioctl and
  867. * so are not separately reported for busyness.
  868. *
  869. * Caveat emptor:
  870. * Only the boolean result of this query is reliable; that is whether
  871. * the object is idle or busy. The report of which engines are busy
  872. * should be only used as a heuristic.
  873. */
  874. __u32 busy;
  875. };
  876. /**
  877. * I915_CACHING_NONE
  878. *
  879. * GPU access is not coherent with cpu caches. Default for machines without an
  880. * LLC.
  881. */
  882. #define I915_CACHING_NONE 0
  883. /**
  884. * I915_CACHING_CACHED
  885. *
  886. * GPU access is coherent with cpu caches and furthermore the data is cached in
  887. * last-level caches shared between cpu cores and the gpu GT. Default on
  888. * machines with HAS_LLC.
  889. */
  890. #define I915_CACHING_CACHED 1
  891. /**
  892. * I915_CACHING_DISPLAY
  893. *
  894. * Special GPU caching mode which is coherent with the scanout engines.
  895. * Transparently falls back to I915_CACHING_NONE on platforms where no special
  896. * cache mode (like write-through or gfdt flushing) is available. The kernel
  897. * automatically sets this mode when using a buffer as a scanout target.
  898. * Userspace can manually set this mode to avoid a costly stall and clflush in
  899. * the hotpath of drawing the first frame.
  900. */
  901. #define I915_CACHING_DISPLAY 2
  902. struct drm_i915_gem_caching {
  903. /**
  904. * Handle of the buffer to set/get the caching level of. */
  905. __u32 handle;
  906. /**
  907. * Cacheing level to apply or return value
  908. *
  909. * bits0-15 are for generic caching control (i.e. the above defined
  910. * values). bits16-31 are reserved for platform-specific variations
  911. * (e.g. l3$ caching on gen7). */
  912. __u32 caching;
  913. };
  914. #define I915_TILING_NONE 0
  915. #define I915_TILING_X 1
  916. #define I915_TILING_Y 2
  917. #define I915_TILING_LAST I915_TILING_Y
  918. #define I915_BIT_6_SWIZZLE_NONE 0
  919. #define I915_BIT_6_SWIZZLE_9 1
  920. #define I915_BIT_6_SWIZZLE_9_10 2
  921. #define I915_BIT_6_SWIZZLE_9_11 3
  922. #define I915_BIT_6_SWIZZLE_9_10_11 4
  923. /* Not seen by userland */
  924. #define I915_BIT_6_SWIZZLE_UNKNOWN 5
  925. /* Seen by userland. */
  926. #define I915_BIT_6_SWIZZLE_9_17 6
  927. #define I915_BIT_6_SWIZZLE_9_10_17 7
  928. struct drm_i915_gem_set_tiling {
  929. /** Handle of the buffer to have its tiling state updated */
  930. __u32 handle;
  931. /**
  932. * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  933. * I915_TILING_Y).
  934. *
  935. * This value is to be set on request, and will be updated by the
  936. * kernel on successful return with the actual chosen tiling layout.
  937. *
  938. * The tiling mode may be demoted to I915_TILING_NONE when the system
  939. * has bit 6 swizzling that can't be managed correctly by GEM.
  940. *
  941. * Buffer contents become undefined when changing tiling_mode.
  942. */
  943. __u32 tiling_mode;
  944. /**
  945. * Stride in bytes for the object when in I915_TILING_X or
  946. * I915_TILING_Y.
  947. */
  948. __u32 stride;
  949. /**
  950. * Returned address bit 6 swizzling required for CPU access through
  951. * mmap mapping.
  952. */
  953. __u32 swizzle_mode;
  954. };
  955. struct drm_i915_gem_get_tiling {
  956. /** Handle of the buffer to get tiling state for. */
  957. __u32 handle;
  958. /**
  959. * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  960. * I915_TILING_Y).
  961. */
  962. __u32 tiling_mode;
  963. /**
  964. * Returned address bit 6 swizzling required for CPU access through
  965. * mmap mapping.
  966. */
  967. __u32 swizzle_mode;
  968. /**
  969. * Returned address bit 6 swizzling required for CPU access through
  970. * mmap mapping whilst bound.
  971. */
  972. __u32 phys_swizzle_mode;
  973. };
  974. struct drm_i915_gem_get_aperture {
  975. /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
  976. __u64 aper_size;
  977. /**
  978. * Available space in the aperture used by i915_gem_execbuffer, in
  979. * bytes
  980. */
  981. __u64 aper_available_size;
  982. };
  983. struct drm_i915_get_pipe_from_crtc_id {
  984. /** ID of CRTC being requested **/
  985. __u32 crtc_id;
  986. /** pipe of requested CRTC **/
  987. __u32 pipe;
  988. };
  989. #define I915_MADV_WILLNEED 0
  990. #define I915_MADV_DONTNEED 1
  991. #define __I915_MADV_PURGED 2 /* internal state */
  992. struct drm_i915_gem_madvise {
  993. /** Handle of the buffer to change the backing store advice */
  994. __u32 handle;
  995. /* Advice: either the buffer will be needed again in the near future,
  996. * or wont be and could be discarded under memory pressure.
  997. */
  998. __u32 madv;
  999. /** Whether the backing store still exists. */
  1000. __u32 retained;
  1001. };
  1002. /* flags */
  1003. #define I915_OVERLAY_TYPE_MASK 0xff
  1004. #define I915_OVERLAY_YUV_PLANAR 0x01
  1005. #define I915_OVERLAY_YUV_PACKED 0x02
  1006. #define I915_OVERLAY_RGB 0x03
  1007. #define I915_OVERLAY_DEPTH_MASK 0xff00
  1008. #define I915_OVERLAY_RGB24 0x1000
  1009. #define I915_OVERLAY_RGB16 0x2000
  1010. #define I915_OVERLAY_RGB15 0x3000
  1011. #define I915_OVERLAY_YUV422 0x0100
  1012. #define I915_OVERLAY_YUV411 0x0200
  1013. #define I915_OVERLAY_YUV420 0x0300
  1014. #define I915_OVERLAY_YUV410 0x0400
  1015. #define I915_OVERLAY_SWAP_MASK 0xff0000
  1016. #define I915_OVERLAY_NO_SWAP 0x000000
  1017. #define I915_OVERLAY_UV_SWAP 0x010000
  1018. #define I915_OVERLAY_Y_SWAP 0x020000
  1019. #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
  1020. #define I915_OVERLAY_FLAGS_MASK 0xff000000
  1021. #define I915_OVERLAY_ENABLE 0x01000000
  1022. struct drm_intel_overlay_put_image {
  1023. /* various flags and src format description */
  1024. __u32 flags;
  1025. /* source picture description */
  1026. __u32 bo_handle;
  1027. /* stride values and offsets are in bytes, buffer relative */
  1028. __u16 stride_Y; /* stride for packed formats */
  1029. __u16 stride_UV;
  1030. __u32 offset_Y; /* offset for packet formats */
  1031. __u32 offset_U;
  1032. __u32 offset_V;
  1033. /* in pixels */
  1034. __u16 src_width;
  1035. __u16 src_height;
  1036. /* to compensate the scaling factors for partially covered surfaces */
  1037. __u16 src_scan_width;
  1038. __u16 src_scan_height;
  1039. /* output crtc description */
  1040. __u32 crtc_id;
  1041. __u16 dst_x;
  1042. __u16 dst_y;
  1043. __u16 dst_width;
  1044. __u16 dst_height;
  1045. };
  1046. /* flags */
  1047. #define I915_OVERLAY_UPDATE_ATTRS (1<<0)
  1048. #define I915_OVERLAY_UPDATE_GAMMA (1<<1)
  1049. #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
  1050. struct drm_intel_overlay_attrs {
  1051. __u32 flags;
  1052. __u32 color_key;
  1053. __s32 brightness;
  1054. __u32 contrast;
  1055. __u32 saturation;
  1056. __u32 gamma0;
  1057. __u32 gamma1;
  1058. __u32 gamma2;
  1059. __u32 gamma3;
  1060. __u32 gamma4;
  1061. __u32 gamma5;
  1062. };
  1063. /*
  1064. * Intel sprite handling
  1065. *
  1066. * Color keying works with a min/mask/max tuple. Both source and destination
  1067. * color keying is allowed.
  1068. *
  1069. * Source keying:
  1070. * Sprite pixels within the min & max values, masked against the color channels
  1071. * specified in the mask field, will be transparent. All other pixels will
  1072. * be displayed on top of the primary plane. For RGB surfaces, only the min
  1073. * and mask fields will be used; ranged compares are not allowed.
  1074. *
  1075. * Destination keying:
  1076. * Primary plane pixels that match the min value, masked against the color
  1077. * channels specified in the mask field, will be replaced by corresponding
  1078. * pixels from the sprite plane.
  1079. *
  1080. * Note that source & destination keying are exclusive; only one can be
  1081. * active on a given plane.
  1082. */
  1083. #define I915_SET_COLORKEY_NONE (1<<0) /* disable color key matching */
  1084. #define I915_SET_COLORKEY_DESTINATION (1<<1)
  1085. #define I915_SET_COLORKEY_SOURCE (1<<2)
  1086. struct drm_intel_sprite_colorkey {
  1087. __u32 plane_id;
  1088. __u32 min_value;
  1089. __u32 channel_mask;
  1090. __u32 max_value;
  1091. __u32 flags;
  1092. };
  1093. struct drm_i915_gem_wait {
  1094. /** Handle of BO we shall wait on */
  1095. __u32 bo_handle;
  1096. __u32 flags;
  1097. /** Number of nanoseconds to wait, Returns time remaining. */
  1098. __s64 timeout_ns;
  1099. };
  1100. struct drm_i915_gem_context_create {
  1101. /* output: id of new context*/
  1102. __u32 ctx_id;
  1103. __u32 pad;
  1104. };
  1105. struct drm_i915_gem_context_destroy {
  1106. __u32 ctx_id;
  1107. __u32 pad;
  1108. };
  1109. struct drm_i915_reg_read {
  1110. /*
  1111. * Register offset.
  1112. * For 64bit wide registers where the upper 32bits don't immediately
  1113. * follow the lower 32bits, the offset of the lower 32bits must
  1114. * be specified
  1115. */
  1116. __u64 offset;
  1117. __u64 val; /* Return value */
  1118. };
  1119. /* Known registers:
  1120. *
  1121. * Render engine timestamp - 0x2358 + 64bit - gen7+
  1122. * - Note this register returns an invalid value if using the default
  1123. * single instruction 8byte read, in order to workaround that use
  1124. * offset (0x2538 | 1) instead.
  1125. *
  1126. */
  1127. struct drm_i915_reset_stats {
  1128. __u32 ctx_id;
  1129. __u32 flags;
  1130. /* All resets since boot/module reload, for all contexts */
  1131. __u32 reset_count;
  1132. /* Number of batches lost when active in GPU, for this context */
  1133. __u32 batch_active;
  1134. /* Number of batches lost pending for execution, for this context */
  1135. __u32 batch_pending;
  1136. __u32 pad;
  1137. };
  1138. struct drm_i915_gem_userptr {
  1139. __u64 user_ptr;
  1140. __u64 user_size;
  1141. __u32 flags;
  1142. #define I915_USERPTR_READ_ONLY 0x1
  1143. #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
  1144. /**
  1145. * Returned handle for the object.
  1146. *
  1147. * Object handles are nonzero.
  1148. */
  1149. __u32 handle;
  1150. };
  1151. struct drm_i915_gem_context_param {
  1152. __u32 ctx_id;
  1153. __u32 size;
  1154. __u64 param;
  1155. #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
  1156. #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
  1157. #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
  1158. #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
  1159. #define I915_CONTEXT_PARAM_BANNABLE 0x5
  1160. __u64 value;
  1161. };
  1162. enum drm_i915_oa_format {
  1163. I915_OA_FORMAT_A13 = 1,
  1164. I915_OA_FORMAT_A29,
  1165. I915_OA_FORMAT_A13_B8_C8,
  1166. I915_OA_FORMAT_B4_C8,
  1167. I915_OA_FORMAT_A45_B8_C8,
  1168. I915_OA_FORMAT_B4_C8_A16,
  1169. I915_OA_FORMAT_C4_B8,
  1170. I915_OA_FORMAT_MAX /* non-ABI */
  1171. };
  1172. enum drm_i915_perf_property_id {
  1173. /**
  1174. * Open the stream for a specific context handle (as used with
  1175. * execbuffer2). A stream opened for a specific context this way
  1176. * won't typically require root privileges.
  1177. */
  1178. DRM_I915_PERF_PROP_CTX_HANDLE = 1,
  1179. /**
  1180. * A value of 1 requests the inclusion of raw OA unit reports as
  1181. * part of stream samples.
  1182. */
  1183. DRM_I915_PERF_PROP_SAMPLE_OA,
  1184. /**
  1185. * The value specifies which set of OA unit metrics should be
  1186. * be configured, defining the contents of any OA unit reports.
  1187. */
  1188. DRM_I915_PERF_PROP_OA_METRICS_SET,
  1189. /**
  1190. * The value specifies the size and layout of OA unit reports.
  1191. */
  1192. DRM_I915_PERF_PROP_OA_FORMAT,
  1193. /**
  1194. * Specifying this property implicitly requests periodic OA unit
  1195. * sampling and (at least on Haswell) the sampling frequency is derived
  1196. * from this exponent as follows:
  1197. *
  1198. * 80ns * 2^(period_exponent + 1)
  1199. */
  1200. DRM_I915_PERF_PROP_OA_EXPONENT,
  1201. DRM_I915_PERF_PROP_MAX /* non-ABI */
  1202. };
  1203. struct drm_i915_perf_open_param {
  1204. __u32 flags;
  1205. #define I915_PERF_FLAG_FD_CLOEXEC (1<<0)
  1206. #define I915_PERF_FLAG_FD_NONBLOCK (1<<1)
  1207. #define I915_PERF_FLAG_DISABLED (1<<2)
  1208. /** The number of u64 (id, value) pairs */
  1209. __u32 num_properties;
  1210. /**
  1211. * Pointer to array of u64 (id, value) pairs configuring the stream
  1212. * to open.
  1213. */
  1214. __u64 properties_ptr;
  1215. };
  1216. /**
  1217. * Enable data capture for a stream that was either opened in a disabled state
  1218. * via I915_PERF_FLAG_DISABLED or was later disabled via
  1219. * I915_PERF_IOCTL_DISABLE.
  1220. *
  1221. * It is intended to be cheaper to disable and enable a stream than it may be
  1222. * to close and re-open a stream with the same configuration.
  1223. *
  1224. * It's undefined whether any pending data for the stream will be lost.
  1225. */
  1226. #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)
  1227. /**
  1228. * Disable data capture for a stream.
  1229. *
  1230. * It is an error to try and read a stream that is disabled.
  1231. */
  1232. #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
  1233. /**
  1234. * Common to all i915 perf records
  1235. */
  1236. struct drm_i915_perf_record_header {
  1237. __u32 type;
  1238. __u16 pad;
  1239. __u16 size;
  1240. };
  1241. enum drm_i915_perf_record_type {
  1242. /**
  1243. * Samples are the work horse record type whose contents are extensible
  1244. * and defined when opening an i915 perf stream based on the given
  1245. * properties.
  1246. *
  1247. * Boolean properties following the naming convention
  1248. * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
  1249. * every sample.
  1250. *
  1251. * The order of these sample properties given by userspace has no
  1252. * affect on the ordering of data within a sample. The order is
  1253. * documented here.
  1254. *
  1255. * struct {
  1256. * struct drm_i915_perf_record_header header;
  1257. *
  1258. * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
  1259. * };
  1260. */
  1261. DRM_I915_PERF_RECORD_SAMPLE = 1,
  1262. /*
  1263. * Indicates that one or more OA reports were not written by the
  1264. * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
  1265. * command collides with periodic sampling - which would be more likely
  1266. * at higher sampling frequencies.
  1267. */
  1268. DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
  1269. /**
  1270. * An error occurred that resulted in all pending OA reports being lost.
  1271. */
  1272. DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
  1273. DRM_I915_PERF_RECORD_MAX /* non-ABI */
  1274. };
  1275. #if defined(__cplusplus)
  1276. }
  1277. #endif
  1278. #endif /* _UAPI_I915_DRM_H_ */