i915_drm.h 55 KB

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