i915_drm.h 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746
  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 _I915_DRM_H_
  27. #define _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 *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 *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 *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 *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. /*
  482. * Once upon a time we supposed that writes through the GGTT would be
  483. * immediately in physical memory (once flushed out of the CPU path). However,
  484. * on a few different processors and chipsets, this is not necessarily the case
  485. * as the writes appear to be buffered internally. Thus a read of the backing
  486. * storage (physical memory) via a different path (with different physical tags
  487. * to the indirect write via the GGTT) will see stale values from before
  488. * the GGTT write. Inside the kernel, we can for the most part keep track of
  489. * the different read/write domains in use (e.g. set-domain), but the assumption
  490. * of coherency is baked into the ABI, hence reporting its true state in this
  491. * parameter.
  492. *
  493. * Reports true when writes via mmap_gtt are immediately visible following an
  494. * lfence to flush the WCB.
  495. *
  496. * Reports false when writes via mmap_gtt are indeterminately delayed in an in
  497. * internal buffer and are _not_ immediately visible to third parties accessing
  498. * directly via mmap_cpu/mmap_wc. Use of mmap_gtt as part of an IPC
  499. * communications channel when reporting false is strongly disadvised.
  500. */
  501. #define I915_PARAM_MMAP_GTT_COHERENT 52
  502. typedef struct drm_i915_getparam {
  503. __s32 param;
  504. /*
  505. * WARNING: Using pointers instead of fixed-size u64 means we need to write
  506. * compat32 code. Don't repeat this mistake.
  507. */
  508. int *value;
  509. } drm_i915_getparam_t;
  510. /* Ioctl to set kernel params:
  511. */
  512. #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
  513. #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
  514. #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
  515. #define I915_SETPARAM_NUM_USED_FENCES 4
  516. typedef struct drm_i915_setparam {
  517. int param;
  518. int value;
  519. } drm_i915_setparam_t;
  520. /* A memory manager for regions of shared memory:
  521. */
  522. #define I915_MEM_REGION_AGP 1
  523. typedef struct drm_i915_mem_alloc {
  524. int region;
  525. int alignment;
  526. int size;
  527. int *region_offset; /* offset from start of fb or agp */
  528. } drm_i915_mem_alloc_t;
  529. typedef struct drm_i915_mem_free {
  530. int region;
  531. int region_offset;
  532. } drm_i915_mem_free_t;
  533. typedef struct drm_i915_mem_init_heap {
  534. int region;
  535. int size;
  536. int start;
  537. } drm_i915_mem_init_heap_t;
  538. /* Allow memory manager to be torn down and re-initialized (eg on
  539. * rotate):
  540. */
  541. typedef struct drm_i915_mem_destroy_heap {
  542. int region;
  543. } drm_i915_mem_destroy_heap_t;
  544. /* Allow X server to configure which pipes to monitor for vblank signals
  545. */
  546. #define DRM_I915_VBLANK_PIPE_A 1
  547. #define DRM_I915_VBLANK_PIPE_B 2
  548. typedef struct drm_i915_vblank_pipe {
  549. int pipe;
  550. } drm_i915_vblank_pipe_t;
  551. /* Schedule buffer swap at given vertical blank:
  552. */
  553. typedef struct drm_i915_vblank_swap {
  554. drm_drawable_t drawable;
  555. enum drm_vblank_seq_type seqtype;
  556. unsigned int sequence;
  557. } drm_i915_vblank_swap_t;
  558. typedef struct drm_i915_hws_addr {
  559. __u64 addr;
  560. } drm_i915_hws_addr_t;
  561. struct drm_i915_gem_init {
  562. /**
  563. * Beginning offset in the GTT to be managed by the DRM memory
  564. * manager.
  565. */
  566. __u64 gtt_start;
  567. /**
  568. * Ending offset in the GTT to be managed by the DRM memory
  569. * manager.
  570. */
  571. __u64 gtt_end;
  572. };
  573. struct drm_i915_gem_create {
  574. /**
  575. * Requested size for the object.
  576. *
  577. * The (page-aligned) allocated size for the object will be returned.
  578. */
  579. __u64 size;
  580. /**
  581. * Returned handle for the object.
  582. *
  583. * Object handles are nonzero.
  584. */
  585. __u32 handle;
  586. __u32 pad;
  587. };
  588. struct drm_i915_gem_pread {
  589. /** Handle for the object being read. */
  590. __u32 handle;
  591. __u32 pad;
  592. /** Offset into the object to read from */
  593. __u64 offset;
  594. /** Length of data to read */
  595. __u64 size;
  596. /**
  597. * Pointer to write the data into.
  598. *
  599. * This is a fixed-size type for 32/64 compatibility.
  600. */
  601. __u64 data_ptr;
  602. };
  603. struct drm_i915_gem_pwrite {
  604. /** Handle for the object being written to. */
  605. __u32 handle;
  606. __u32 pad;
  607. /** Offset into the object to write to */
  608. __u64 offset;
  609. /** Length of data to write */
  610. __u64 size;
  611. /**
  612. * Pointer to read the data from.
  613. *
  614. * This is a fixed-size type for 32/64 compatibility.
  615. */
  616. __u64 data_ptr;
  617. };
  618. struct drm_i915_gem_mmap {
  619. /** Handle for the object being mapped. */
  620. __u32 handle;
  621. __u32 pad;
  622. /** Offset in the object to map. */
  623. __u64 offset;
  624. /**
  625. * Length of data to map.
  626. *
  627. * The value will be page-aligned.
  628. */
  629. __u64 size;
  630. /**
  631. * Returned pointer the data was mapped at.
  632. *
  633. * This is a fixed-size type for 32/64 compatibility.
  634. */
  635. __u64 addr_ptr;
  636. /**
  637. * Flags for extended behaviour.
  638. *
  639. * Added in version 2.
  640. */
  641. __u64 flags;
  642. #define I915_MMAP_WC 0x1
  643. };
  644. struct drm_i915_gem_mmap_gtt {
  645. /** Handle for the object being mapped. */
  646. __u32 handle;
  647. __u32 pad;
  648. /**
  649. * Fake offset to use for subsequent mmap call
  650. *
  651. * This is a fixed-size type for 32/64 compatibility.
  652. */
  653. __u64 offset;
  654. };
  655. struct drm_i915_gem_set_domain {
  656. /** Handle for the object */
  657. __u32 handle;
  658. /** New read domains */
  659. __u32 read_domains;
  660. /** New write domain */
  661. __u32 write_domain;
  662. };
  663. struct drm_i915_gem_sw_finish {
  664. /** Handle for the object */
  665. __u32 handle;
  666. };
  667. struct drm_i915_gem_relocation_entry {
  668. /**
  669. * Handle of the buffer being pointed to by this relocation entry.
  670. *
  671. * It's appealing to make this be an index into the mm_validate_entry
  672. * list to refer to the buffer, but this allows the driver to create
  673. * a relocation list for state buffers and not re-write it per
  674. * exec using the buffer.
  675. */
  676. __u32 target_handle;
  677. /**
  678. * Value to be added to the offset of the target buffer to make up
  679. * the relocation entry.
  680. */
  681. __u32 delta;
  682. /** Offset in the buffer the relocation entry will be written into */
  683. __u64 offset;
  684. /**
  685. * Offset value of the target buffer that the relocation entry was last
  686. * written as.
  687. *
  688. * If the buffer has the same offset as last time, we can skip syncing
  689. * and writing the relocation. This value is written back out by
  690. * the execbuffer ioctl when the relocation is written.
  691. */
  692. __u64 presumed_offset;
  693. /**
  694. * Target memory domains read by this operation.
  695. */
  696. __u32 read_domains;
  697. /**
  698. * Target memory domains written by this operation.
  699. *
  700. * Note that only one domain may be written by the whole
  701. * execbuffer operation, so that where there are conflicts,
  702. * the application will get -EINVAL back.
  703. */
  704. __u32 write_domain;
  705. };
  706. /** @{
  707. * Intel memory domains
  708. *
  709. * Most of these just align with the various caches in
  710. * the system and are used to flush and invalidate as
  711. * objects end up cached in different domains.
  712. */
  713. /** CPU cache */
  714. #define I915_GEM_DOMAIN_CPU 0x00000001
  715. /** Render cache, used by 2D and 3D drawing */
  716. #define I915_GEM_DOMAIN_RENDER 0x00000002
  717. /** Sampler cache, used by texture engine */
  718. #define I915_GEM_DOMAIN_SAMPLER 0x00000004
  719. /** Command queue, used to load batch buffers */
  720. #define I915_GEM_DOMAIN_COMMAND 0x00000008
  721. /** Instruction cache, used by shader programs */
  722. #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
  723. /** Vertex address cache */
  724. #define I915_GEM_DOMAIN_VERTEX 0x00000020
  725. /** GTT domain - aperture and scanout */
  726. #define I915_GEM_DOMAIN_GTT 0x00000040
  727. /** WC domain - uncached access */
  728. #define I915_GEM_DOMAIN_WC 0x00000080
  729. /** @} */
  730. struct drm_i915_gem_exec_object {
  731. /**
  732. * User's handle for a buffer to be bound into the GTT for this
  733. * operation.
  734. */
  735. __u32 handle;
  736. /** Number of relocations to be performed on this buffer */
  737. __u32 relocation_count;
  738. /**
  739. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  740. * the relocations to be performed in this buffer.
  741. */
  742. __u64 relocs_ptr;
  743. /** Required alignment in graphics aperture */
  744. __u64 alignment;
  745. /**
  746. * Returned value of the updated offset of the object, for future
  747. * presumed_offset writes.
  748. */
  749. __u64 offset;
  750. };
  751. struct drm_i915_gem_execbuffer {
  752. /**
  753. * List of buffers to be validated with their relocations to be
  754. * performend on them.
  755. *
  756. * This is a pointer to an array of struct drm_i915_gem_validate_entry.
  757. *
  758. * These buffers must be listed in an order such that all relocations
  759. * a buffer is performing refer to buffers that have already appeared
  760. * in the validate list.
  761. */
  762. __u64 buffers_ptr;
  763. __u32 buffer_count;
  764. /** Offset in the batchbuffer to start execution from. */
  765. __u32 batch_start_offset;
  766. /** Bytes used in batchbuffer from batch_start_offset */
  767. __u32 batch_len;
  768. __u32 DR1;
  769. __u32 DR4;
  770. __u32 num_cliprects;
  771. /** This is a struct drm_clip_rect *cliprects */
  772. __u64 cliprects_ptr;
  773. };
  774. struct drm_i915_gem_exec_object2 {
  775. /**
  776. * User's handle for a buffer to be bound into the GTT for this
  777. * operation.
  778. */
  779. __u32 handle;
  780. /** Number of relocations to be performed on this buffer */
  781. __u32 relocation_count;
  782. /**
  783. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  784. * the relocations to be performed in this buffer.
  785. */
  786. __u64 relocs_ptr;
  787. /** Required alignment in graphics aperture */
  788. __u64 alignment;
  789. /**
  790. * When the EXEC_OBJECT_PINNED flag is specified this is populated by
  791. * the user with the GTT offset at which this object will be pinned.
  792. * When the I915_EXEC_NO_RELOC flag is specified this must contain the
  793. * presumed_offset of the object.
  794. * During execbuffer2 the kernel populates it with the value of the
  795. * current GTT offset of the object, for future presumed_offset writes.
  796. */
  797. __u64 offset;
  798. #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
  799. #define EXEC_OBJECT_NEEDS_GTT (1<<1)
  800. #define EXEC_OBJECT_WRITE (1<<2)
  801. #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
  802. #define EXEC_OBJECT_PINNED (1<<4)
  803. #define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
  804. /* The kernel implicitly tracks GPU activity on all GEM objects, and
  805. * synchronises operations with outstanding rendering. This includes
  806. * rendering on other devices if exported via dma-buf. However, sometimes
  807. * this tracking is too coarse and the user knows better. For example,
  808. * if the object is split into non-overlapping ranges shared between different
  809. * clients or engines (i.e. suballocating objects), the implicit tracking
  810. * by kernel assumes that each operation affects the whole object rather
  811. * than an individual range, causing needless synchronisation between clients.
  812. * The kernel will also forgo any CPU cache flushes prior to rendering from
  813. * the object as the client is expected to be also handling such domain
  814. * tracking.
  815. *
  816. * The kernel maintains the implicit tracking in order to manage resources
  817. * used by the GPU - this flag only disables the synchronisation prior to
  818. * rendering with this object in this execbuf.
  819. *
  820. * Opting out of implicit synhronisation requires the user to do its own
  821. * explicit tracking to avoid rendering corruption. See, for example,
  822. * I915_PARAM_HAS_EXEC_FENCE to order execbufs and execute them asynchronously.
  823. */
  824. #define EXEC_OBJECT_ASYNC (1<<6)
  825. /* Request that the contents of this execobject be copied into the error
  826. * state upon a GPU hang involving this batch for post-mortem debugging.
  827. * These buffers are recorded in no particular order as "user" in
  828. * /sys/class/drm/cardN/error. Query I915_PARAM_HAS_EXEC_CAPTURE to see
  829. * if the kernel supports this flag.
  830. */
  831. #define EXEC_OBJECT_CAPTURE (1<<7)
  832. /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
  833. #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_CAPTURE<<1)
  834. __u64 flags;
  835. union {
  836. __u64 rsvd1;
  837. __u64 pad_to_size;
  838. };
  839. __u64 rsvd2;
  840. };
  841. struct drm_i915_gem_exec_fence {
  842. /**
  843. * User's handle for a drm_syncobj to wait on or signal.
  844. */
  845. __u32 handle;
  846. #define I915_EXEC_FENCE_WAIT (1<<0)
  847. #define I915_EXEC_FENCE_SIGNAL (1<<1)
  848. #define __I915_EXEC_FENCE_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_SIGNAL << 1))
  849. __u32 flags;
  850. };
  851. struct drm_i915_gem_execbuffer2 {
  852. /**
  853. * List of gem_exec_object2 structs
  854. */
  855. __u64 buffers_ptr;
  856. __u32 buffer_count;
  857. /** Offset in the batchbuffer to start execution from. */
  858. __u32 batch_start_offset;
  859. /** Bytes used in batchbuffer from batch_start_offset */
  860. __u32 batch_len;
  861. __u32 DR1;
  862. __u32 DR4;
  863. __u32 num_cliprects;
  864. /**
  865. * This is a struct drm_clip_rect *cliprects if I915_EXEC_FENCE_ARRAY
  866. * is not set. If I915_EXEC_FENCE_ARRAY is set, then this is a
  867. * struct drm_i915_gem_exec_fence *fences.
  868. */
  869. __u64 cliprects_ptr;
  870. #define I915_EXEC_RING_MASK (7<<0)
  871. #define I915_EXEC_DEFAULT (0<<0)
  872. #define I915_EXEC_RENDER (1<<0)
  873. #define I915_EXEC_BSD (2<<0)
  874. #define I915_EXEC_BLT (3<<0)
  875. #define I915_EXEC_VEBOX (4<<0)
  876. /* Used for switching the constants addressing mode on gen4+ RENDER ring.
  877. * Gen6+ only supports relative addressing to dynamic state (default) and
  878. * absolute addressing.
  879. *
  880. * These flags are ignored for the BSD and BLT rings.
  881. */
  882. #define I915_EXEC_CONSTANTS_MASK (3<<6)
  883. #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
  884. #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
  885. #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
  886. __u64 flags;
  887. __u64 rsvd1; /* now used for context info */
  888. __u64 rsvd2;
  889. };
  890. /** Resets the SO write offset registers for transform feedback on gen7. */
  891. #define I915_EXEC_GEN7_SOL_RESET (1<<8)
  892. /** Request a privileged ("secure") batch buffer. Note only available for
  893. * DRM_ROOT_ONLY | DRM_MASTER processes.
  894. */
  895. #define I915_EXEC_SECURE (1<<9)
  896. /** Inform the kernel that the batch is and will always be pinned. This
  897. * negates the requirement for a workaround to be performed to avoid
  898. * an incoherent CS (such as can be found on 830/845). If this flag is
  899. * not passed, the kernel will endeavour to make sure the batch is
  900. * coherent with the CS before execution. If this flag is passed,
  901. * userspace assumes the responsibility for ensuring the same.
  902. */
  903. #define I915_EXEC_IS_PINNED (1<<10)
  904. /** Provide a hint to the kernel that the command stream and auxiliary
  905. * state buffers already holds the correct presumed addresses and so the
  906. * relocation process may be skipped if no buffers need to be moved in
  907. * preparation for the execbuffer.
  908. */
  909. #define I915_EXEC_NO_RELOC (1<<11)
  910. /** Use the reloc.handle as an index into the exec object array rather
  911. * than as the per-file handle.
  912. */
  913. #define I915_EXEC_HANDLE_LUT (1<<12)
  914. /** Used for switching BSD rings on the platforms with two BSD rings */
  915. #define I915_EXEC_BSD_SHIFT (13)
  916. #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
  917. /* default ping-pong mode */
  918. #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
  919. #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
  920. #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
  921. /** Tell the kernel that the batchbuffer is processed by
  922. * the resource streamer.
  923. */
  924. #define I915_EXEC_RESOURCE_STREAMER (1<<15)
  925. /* Setting I915_EXEC_FENCE_IN implies that lower_32_bits(rsvd2) represent
  926. * a sync_file fd to wait upon (in a nonblocking manner) prior to executing
  927. * the batch.
  928. *
  929. * Returns -EINVAL if the sync_file fd cannot be found.
  930. */
  931. #define I915_EXEC_FENCE_IN (1<<16)
  932. /* Setting I915_EXEC_FENCE_OUT causes the ioctl to return a sync_file fd
  933. * in the upper_32_bits(rsvd2) upon success. Ownership of the fd is given
  934. * to the caller, and it should be close() after use. (The fd is a regular
  935. * file descriptor and will be cleaned up on process termination. It holds
  936. * a reference to the request, but nothing else.)
  937. *
  938. * The sync_file fd can be combined with other sync_file and passed either
  939. * to execbuf using I915_EXEC_FENCE_IN, to atomic KMS ioctls (so that a flip
  940. * will only occur after this request completes), or to other devices.
  941. *
  942. * Using I915_EXEC_FENCE_OUT requires use of
  943. * DRM_IOCTL_I915_GEM_EXECBUFFER2_WR ioctl so that the result is written
  944. * back to userspace. Failure to do so will cause the out-fence to always
  945. * be reported as zero, and the real fence fd to be leaked.
  946. */
  947. #define I915_EXEC_FENCE_OUT (1<<17)
  948. /*
  949. * Traditionally the execbuf ioctl has only considered the final element in
  950. * the execobject[] to be the executable batch. Often though, the client
  951. * will known the batch object prior to construction and being able to place
  952. * it into the execobject[] array first can simplify the relocation tracking.
  953. * Setting I915_EXEC_BATCH_FIRST tells execbuf to use element 0 of the
  954. * execobject[] as the * batch instead (the default is to use the last
  955. * element).
  956. */
  957. #define I915_EXEC_BATCH_FIRST (1<<18)
  958. /* Setting I915_FENCE_ARRAY implies that num_cliprects and cliprects_ptr
  959. * define an array of i915_gem_exec_fence structures which specify a set of
  960. * dma fences to wait upon or signal.
  961. */
  962. #define I915_EXEC_FENCE_ARRAY (1<<19)
  963. #define __I915_EXEC_UNKNOWN_FLAGS (-(I915_EXEC_FENCE_ARRAY<<1))
  964. #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
  965. #define i915_execbuffer2_set_context_id(eb2, context) \
  966. (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
  967. #define i915_execbuffer2_get_context_id(eb2) \
  968. ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
  969. struct drm_i915_gem_pin {
  970. /** Handle of the buffer to be pinned. */
  971. __u32 handle;
  972. __u32 pad;
  973. /** alignment required within the aperture */
  974. __u64 alignment;
  975. /** Returned GTT offset of the buffer. */
  976. __u64 offset;
  977. };
  978. struct drm_i915_gem_unpin {
  979. /** Handle of the buffer to be unpinned. */
  980. __u32 handle;
  981. __u32 pad;
  982. };
  983. struct drm_i915_gem_busy {
  984. /** Handle of the buffer to check for busy */
  985. __u32 handle;
  986. /** Return busy status
  987. *
  988. * A return of 0 implies that the object is idle (after
  989. * having flushed any pending activity), and a non-zero return that
  990. * the object is still in-flight on the GPU. (The GPU has not yet
  991. * signaled completion for all pending requests that reference the
  992. * object.) An object is guaranteed to become idle eventually (so
  993. * long as no new GPU commands are executed upon it). Due to the
  994. * asynchronous nature of the hardware, an object reported
  995. * as busy may become idle before the ioctl is completed.
  996. *
  997. * Furthermore, if the object is busy, which engine is busy is only
  998. * provided as a guide. There are race conditions which prevent the
  999. * report of which engines are busy from being always accurate.
  1000. * However, the converse is not true. If the object is idle, the
  1001. * result of the ioctl, that all engines are idle, is accurate.
  1002. *
  1003. * The returned dword is split into two fields to indicate both
  1004. * the engines on which the object is being read, and the
  1005. * engine on which it is currently being written (if any).
  1006. *
  1007. * The low word (bits 0:15) indicate if the object is being written
  1008. * to by any engine (there can only be one, as the GEM implicit
  1009. * synchronisation rules force writes to be serialised). Only the
  1010. * engine for the last write is reported.
  1011. *
  1012. * The high word (bits 16:31) are a bitmask of which engines are
  1013. * currently reading from the object. Multiple engines may be
  1014. * reading from the object simultaneously.
  1015. *
  1016. * The value of each engine is the same as specified in the
  1017. * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
  1018. * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
  1019. * the I915_EXEC_RENDER engine for execution, and so it is never
  1020. * reported as active itself. Some hardware may have parallel
  1021. * execution engines, e.g. multiple media engines, which are
  1022. * mapped to the same identifier in the EXECBUFFER2 ioctl and
  1023. * so are not separately reported for busyness.
  1024. *
  1025. * Caveat emptor:
  1026. * Only the boolean result of this query is reliable; that is whether
  1027. * the object is idle or busy. The report of which engines are busy
  1028. * should be only used as a heuristic.
  1029. */
  1030. __u32 busy;
  1031. };
  1032. /**
  1033. * I915_CACHING_NONE
  1034. *
  1035. * GPU access is not coherent with cpu caches. Default for machines without an
  1036. * LLC.
  1037. */
  1038. #define I915_CACHING_NONE 0
  1039. /**
  1040. * I915_CACHING_CACHED
  1041. *
  1042. * GPU access is coherent with cpu caches and furthermore the data is cached in
  1043. * last-level caches shared between cpu cores and the gpu GT. Default on
  1044. * machines with HAS_LLC.
  1045. */
  1046. #define I915_CACHING_CACHED 1
  1047. /**
  1048. * I915_CACHING_DISPLAY
  1049. *
  1050. * Special GPU caching mode which is coherent with the scanout engines.
  1051. * Transparently falls back to I915_CACHING_NONE on platforms where no special
  1052. * cache mode (like write-through or gfdt flushing) is available. The kernel
  1053. * automatically sets this mode when using a buffer as a scanout target.
  1054. * Userspace can manually set this mode to avoid a costly stall and clflush in
  1055. * the hotpath of drawing the first frame.
  1056. */
  1057. #define I915_CACHING_DISPLAY 2
  1058. struct drm_i915_gem_caching {
  1059. /**
  1060. * Handle of the buffer to set/get the caching level of. */
  1061. __u32 handle;
  1062. /**
  1063. * Cacheing level to apply or return value
  1064. *
  1065. * bits0-15 are for generic caching control (i.e. the above defined
  1066. * values). bits16-31 are reserved for platform-specific variations
  1067. * (e.g. l3$ caching on gen7). */
  1068. __u32 caching;
  1069. };
  1070. #define I915_TILING_NONE 0
  1071. #define I915_TILING_X 1
  1072. #define I915_TILING_Y 2
  1073. #define I915_TILING_LAST I915_TILING_Y
  1074. #define I915_BIT_6_SWIZZLE_NONE 0
  1075. #define I915_BIT_6_SWIZZLE_9 1
  1076. #define I915_BIT_6_SWIZZLE_9_10 2
  1077. #define I915_BIT_6_SWIZZLE_9_11 3
  1078. #define I915_BIT_6_SWIZZLE_9_10_11 4
  1079. /* Not seen by userland */
  1080. #define I915_BIT_6_SWIZZLE_UNKNOWN 5
  1081. /* Seen by userland. */
  1082. #define I915_BIT_6_SWIZZLE_9_17 6
  1083. #define I915_BIT_6_SWIZZLE_9_10_17 7
  1084. struct drm_i915_gem_set_tiling {
  1085. /** Handle of the buffer to have its tiling state updated */
  1086. __u32 handle;
  1087. /**
  1088. * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  1089. * I915_TILING_Y).
  1090. *
  1091. * This value is to be set on request, and will be updated by the
  1092. * kernel on successful return with the actual chosen tiling layout.
  1093. *
  1094. * The tiling mode may be demoted to I915_TILING_NONE when the system
  1095. * has bit 6 swizzling that can't be managed correctly by GEM.
  1096. *
  1097. * Buffer contents become undefined when changing tiling_mode.
  1098. */
  1099. __u32 tiling_mode;
  1100. /**
  1101. * Stride in bytes for the object when in I915_TILING_X or
  1102. * I915_TILING_Y.
  1103. */
  1104. __u32 stride;
  1105. /**
  1106. * Returned address bit 6 swizzling required for CPU access through
  1107. * mmap mapping.
  1108. */
  1109. __u32 swizzle_mode;
  1110. };
  1111. struct drm_i915_gem_get_tiling {
  1112. /** Handle of the buffer to get tiling state for. */
  1113. __u32 handle;
  1114. /**
  1115. * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  1116. * I915_TILING_Y).
  1117. */
  1118. __u32 tiling_mode;
  1119. /**
  1120. * Returned address bit 6 swizzling required for CPU access through
  1121. * mmap mapping.
  1122. */
  1123. __u32 swizzle_mode;
  1124. /**
  1125. * Returned address bit 6 swizzling required for CPU access through
  1126. * mmap mapping whilst bound.
  1127. */
  1128. __u32 phys_swizzle_mode;
  1129. };
  1130. struct drm_i915_gem_get_aperture {
  1131. /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
  1132. __u64 aper_size;
  1133. /**
  1134. * Available space in the aperture used by i915_gem_execbuffer, in
  1135. * bytes
  1136. */
  1137. __u64 aper_available_size;
  1138. };
  1139. struct drm_i915_get_pipe_from_crtc_id {
  1140. /** ID of CRTC being requested **/
  1141. __u32 crtc_id;
  1142. /** pipe of requested CRTC **/
  1143. __u32 pipe;
  1144. };
  1145. #define I915_MADV_WILLNEED 0
  1146. #define I915_MADV_DONTNEED 1
  1147. #define __I915_MADV_PURGED 2 /* internal state */
  1148. struct drm_i915_gem_madvise {
  1149. /** Handle of the buffer to change the backing store advice */
  1150. __u32 handle;
  1151. /* Advice: either the buffer will be needed again in the near future,
  1152. * or wont be and could be discarded under memory pressure.
  1153. */
  1154. __u32 madv;
  1155. /** Whether the backing store still exists. */
  1156. __u32 retained;
  1157. };
  1158. /* flags */
  1159. #define I915_OVERLAY_TYPE_MASK 0xff
  1160. #define I915_OVERLAY_YUV_PLANAR 0x01
  1161. #define I915_OVERLAY_YUV_PACKED 0x02
  1162. #define I915_OVERLAY_RGB 0x03
  1163. #define I915_OVERLAY_DEPTH_MASK 0xff00
  1164. #define I915_OVERLAY_RGB24 0x1000
  1165. #define I915_OVERLAY_RGB16 0x2000
  1166. #define I915_OVERLAY_RGB15 0x3000
  1167. #define I915_OVERLAY_YUV422 0x0100
  1168. #define I915_OVERLAY_YUV411 0x0200
  1169. #define I915_OVERLAY_YUV420 0x0300
  1170. #define I915_OVERLAY_YUV410 0x0400
  1171. #define I915_OVERLAY_SWAP_MASK 0xff0000
  1172. #define I915_OVERLAY_NO_SWAP 0x000000
  1173. #define I915_OVERLAY_UV_SWAP 0x010000
  1174. #define I915_OVERLAY_Y_SWAP 0x020000
  1175. #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
  1176. #define I915_OVERLAY_FLAGS_MASK 0xff000000
  1177. #define I915_OVERLAY_ENABLE 0x01000000
  1178. struct drm_intel_overlay_put_image {
  1179. /* various flags and src format description */
  1180. __u32 flags;
  1181. /* source picture description */
  1182. __u32 bo_handle;
  1183. /* stride values and offsets are in bytes, buffer relative */
  1184. __u16 stride_Y; /* stride for packed formats */
  1185. __u16 stride_UV;
  1186. __u32 offset_Y; /* offset for packet formats */
  1187. __u32 offset_U;
  1188. __u32 offset_V;
  1189. /* in pixels */
  1190. __u16 src_width;
  1191. __u16 src_height;
  1192. /* to compensate the scaling factors for partially covered surfaces */
  1193. __u16 src_scan_width;
  1194. __u16 src_scan_height;
  1195. /* output crtc description */
  1196. __u32 crtc_id;
  1197. __u16 dst_x;
  1198. __u16 dst_y;
  1199. __u16 dst_width;
  1200. __u16 dst_height;
  1201. };
  1202. /* flags */
  1203. #define I915_OVERLAY_UPDATE_ATTRS (1<<0)
  1204. #define I915_OVERLAY_UPDATE_GAMMA (1<<1)
  1205. #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
  1206. struct drm_intel_overlay_attrs {
  1207. __u32 flags;
  1208. __u32 color_key;
  1209. __s32 brightness;
  1210. __u32 contrast;
  1211. __u32 saturation;
  1212. __u32 gamma0;
  1213. __u32 gamma1;
  1214. __u32 gamma2;
  1215. __u32 gamma3;
  1216. __u32 gamma4;
  1217. __u32 gamma5;
  1218. };
  1219. /*
  1220. * Intel sprite handling
  1221. *
  1222. * Color keying works with a min/mask/max tuple. Both source and destination
  1223. * color keying is allowed.
  1224. *
  1225. * Source keying:
  1226. * Sprite pixels within the min & max values, masked against the color channels
  1227. * specified in the mask field, will be transparent. All other pixels will
  1228. * be displayed on top of the primary plane. For RGB surfaces, only the min
  1229. * and mask fields will be used; ranged compares are not allowed.
  1230. *
  1231. * Destination keying:
  1232. * Primary plane pixels that match the min value, masked against the color
  1233. * channels specified in the mask field, will be replaced by corresponding
  1234. * pixels from the sprite plane.
  1235. *
  1236. * Note that source & destination keying are exclusive; only one can be
  1237. * active on a given plane.
  1238. */
  1239. #define I915_SET_COLORKEY_NONE (1<<0) /* Deprecated. Instead set
  1240. * flags==0 to disable colorkeying.
  1241. */
  1242. #define I915_SET_COLORKEY_DESTINATION (1<<1)
  1243. #define I915_SET_COLORKEY_SOURCE (1<<2)
  1244. struct drm_intel_sprite_colorkey {
  1245. __u32 plane_id;
  1246. __u32 min_value;
  1247. __u32 channel_mask;
  1248. __u32 max_value;
  1249. __u32 flags;
  1250. };
  1251. struct drm_i915_gem_wait {
  1252. /** Handle of BO we shall wait on */
  1253. __u32 bo_handle;
  1254. __u32 flags;
  1255. /** Number of nanoseconds to wait, Returns time remaining. */
  1256. __s64 timeout_ns;
  1257. };
  1258. struct drm_i915_gem_context_create {
  1259. /* output: id of new context*/
  1260. __u32 ctx_id;
  1261. __u32 pad;
  1262. };
  1263. struct drm_i915_gem_context_destroy {
  1264. __u32 ctx_id;
  1265. __u32 pad;
  1266. };
  1267. struct drm_i915_reg_read {
  1268. /*
  1269. * Register offset.
  1270. * For 64bit wide registers where the upper 32bits don't immediately
  1271. * follow the lower 32bits, the offset of the lower 32bits must
  1272. * be specified
  1273. */
  1274. __u64 offset;
  1275. #define I915_REG_READ_8B_WA (1ul << 0)
  1276. __u64 val; /* Return value */
  1277. };
  1278. /* Known registers:
  1279. *
  1280. * Render engine timestamp - 0x2358 + 64bit - gen7+
  1281. * - Note this register returns an invalid value if using the default
  1282. * single instruction 8byte read, in order to workaround that pass
  1283. * flag I915_REG_READ_8B_WA in offset field.
  1284. *
  1285. */
  1286. struct drm_i915_reset_stats {
  1287. __u32 ctx_id;
  1288. __u32 flags;
  1289. /* All resets since boot/module reload, for all contexts */
  1290. __u32 reset_count;
  1291. /* Number of batches lost when active in GPU, for this context */
  1292. __u32 batch_active;
  1293. /* Number of batches lost pending for execution, for this context */
  1294. __u32 batch_pending;
  1295. __u32 pad;
  1296. };
  1297. struct drm_i915_gem_userptr {
  1298. __u64 user_ptr;
  1299. __u64 user_size;
  1300. __u32 flags;
  1301. #define I915_USERPTR_READ_ONLY 0x1
  1302. #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
  1303. /**
  1304. * Returned handle for the object.
  1305. *
  1306. * Object handles are nonzero.
  1307. */
  1308. __u32 handle;
  1309. };
  1310. struct drm_i915_gem_context_param {
  1311. __u32 ctx_id;
  1312. __u32 size;
  1313. __u64 param;
  1314. #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
  1315. #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
  1316. #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
  1317. #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
  1318. #define I915_CONTEXT_PARAM_BANNABLE 0x5
  1319. #define I915_CONTEXT_PARAM_PRIORITY 0x6
  1320. #define I915_CONTEXT_MAX_USER_PRIORITY 1023 /* inclusive */
  1321. #define I915_CONTEXT_DEFAULT_PRIORITY 0
  1322. #define I915_CONTEXT_MIN_USER_PRIORITY -1023 /* inclusive */
  1323. __u64 value;
  1324. };
  1325. enum drm_i915_oa_format {
  1326. I915_OA_FORMAT_A13 = 1, /* HSW only */
  1327. I915_OA_FORMAT_A29, /* HSW only */
  1328. I915_OA_FORMAT_A13_B8_C8, /* HSW only */
  1329. I915_OA_FORMAT_B4_C8, /* HSW only */
  1330. I915_OA_FORMAT_A45_B8_C8, /* HSW only */
  1331. I915_OA_FORMAT_B4_C8_A16, /* HSW only */
  1332. I915_OA_FORMAT_C4_B8, /* HSW+ */
  1333. /* Gen8+ */
  1334. I915_OA_FORMAT_A12,
  1335. I915_OA_FORMAT_A12_B8_C8,
  1336. I915_OA_FORMAT_A32u40_A4u32_B8_C8,
  1337. I915_OA_FORMAT_MAX /* non-ABI */
  1338. };
  1339. enum drm_i915_perf_property_id {
  1340. /**
  1341. * Open the stream for a specific context handle (as used with
  1342. * execbuffer2). A stream opened for a specific context this way
  1343. * won't typically require root privileges.
  1344. */
  1345. DRM_I915_PERF_PROP_CTX_HANDLE = 1,
  1346. /**
  1347. * A value of 1 requests the inclusion of raw OA unit reports as
  1348. * part of stream samples.
  1349. */
  1350. DRM_I915_PERF_PROP_SAMPLE_OA,
  1351. /**
  1352. * The value specifies which set of OA unit metrics should be
  1353. * be configured, defining the contents of any OA unit reports.
  1354. */
  1355. DRM_I915_PERF_PROP_OA_METRICS_SET,
  1356. /**
  1357. * The value specifies the size and layout of OA unit reports.
  1358. */
  1359. DRM_I915_PERF_PROP_OA_FORMAT,
  1360. /**
  1361. * Specifying this property implicitly requests periodic OA unit
  1362. * sampling and (at least on Haswell) the sampling frequency is derived
  1363. * from this exponent as follows:
  1364. *
  1365. * 80ns * 2^(period_exponent + 1)
  1366. */
  1367. DRM_I915_PERF_PROP_OA_EXPONENT,
  1368. DRM_I915_PERF_PROP_MAX /* non-ABI */
  1369. };
  1370. struct drm_i915_perf_open_param {
  1371. __u32 flags;
  1372. #define I915_PERF_FLAG_FD_CLOEXEC (1<<0)
  1373. #define I915_PERF_FLAG_FD_NONBLOCK (1<<1)
  1374. #define I915_PERF_FLAG_DISABLED (1<<2)
  1375. /** The number of u64 (id, value) pairs */
  1376. __u32 num_properties;
  1377. /**
  1378. * Pointer to array of u64 (id, value) pairs configuring the stream
  1379. * to open.
  1380. */
  1381. __u64 properties_ptr;
  1382. };
  1383. /**
  1384. * Enable data capture for a stream that was either opened in a disabled state
  1385. * via I915_PERF_FLAG_DISABLED or was later disabled via
  1386. * I915_PERF_IOCTL_DISABLE.
  1387. *
  1388. * It is intended to be cheaper to disable and enable a stream than it may be
  1389. * to close and re-open a stream with the same configuration.
  1390. *
  1391. * It's undefined whether any pending data for the stream will be lost.
  1392. */
  1393. #define I915_PERF_IOCTL_ENABLE _IO('i', 0x0)
  1394. /**
  1395. * Disable data capture for a stream.
  1396. *
  1397. * It is an error to try and read a stream that is disabled.
  1398. */
  1399. #define I915_PERF_IOCTL_DISABLE _IO('i', 0x1)
  1400. /**
  1401. * Common to all i915 perf records
  1402. */
  1403. struct drm_i915_perf_record_header {
  1404. __u32 type;
  1405. __u16 pad;
  1406. __u16 size;
  1407. };
  1408. enum drm_i915_perf_record_type {
  1409. /**
  1410. * Samples are the work horse record type whose contents are extensible
  1411. * and defined when opening an i915 perf stream based on the given
  1412. * properties.
  1413. *
  1414. * Boolean properties following the naming convention
  1415. * DRM_I915_PERF_SAMPLE_xyz_PROP request the inclusion of 'xyz' data in
  1416. * every sample.
  1417. *
  1418. * The order of these sample properties given by userspace has no
  1419. * affect on the ordering of data within a sample. The order is
  1420. * documented here.
  1421. *
  1422. * struct {
  1423. * struct drm_i915_perf_record_header header;
  1424. *
  1425. * { u32 oa_report[]; } && DRM_I915_PERF_PROP_SAMPLE_OA
  1426. * };
  1427. */
  1428. DRM_I915_PERF_RECORD_SAMPLE = 1,
  1429. /*
  1430. * Indicates that one or more OA reports were not written by the
  1431. * hardware. This can happen for example if an MI_REPORT_PERF_COUNT
  1432. * command collides with periodic sampling - which would be more likely
  1433. * at higher sampling frequencies.
  1434. */
  1435. DRM_I915_PERF_RECORD_OA_REPORT_LOST = 2,
  1436. /**
  1437. * An error occurred that resulted in all pending OA reports being lost.
  1438. */
  1439. DRM_I915_PERF_RECORD_OA_BUFFER_LOST = 3,
  1440. DRM_I915_PERF_RECORD_MAX /* non-ABI */
  1441. };
  1442. /**
  1443. * Structure to upload perf dynamic configuration into the kernel.
  1444. */
  1445. struct drm_i915_perf_oa_config {
  1446. /** String formatted like "%08x-%04x-%04x-%04x-%012x" */
  1447. char uuid[36];
  1448. __u32 n_mux_regs;
  1449. __u32 n_boolean_regs;
  1450. __u32 n_flex_regs;
  1451. /*
  1452. * These fields are pointers to tuples of u32 values (register address,
  1453. * value). For example the expected length of the buffer pointed by
  1454. * mux_regs_ptr is (2 * sizeof(u32) * n_mux_regs).
  1455. */
  1456. __u64 mux_regs_ptr;
  1457. __u64 boolean_regs_ptr;
  1458. __u64 flex_regs_ptr;
  1459. };
  1460. struct drm_i915_query_item {
  1461. __u64 query_id;
  1462. #define DRM_I915_QUERY_TOPOLOGY_INFO 1
  1463. /*
  1464. * When set to zero by userspace, this is filled with the size of the
  1465. * data to be written at the data_ptr pointer. The kernel sets this
  1466. * value to a negative value to signal an error on a particular query
  1467. * item.
  1468. */
  1469. __s32 length;
  1470. /*
  1471. * Unused for now. Must be cleared to zero.
  1472. */
  1473. __u32 flags;
  1474. /*
  1475. * Data will be written at the location pointed by data_ptr when the
  1476. * value of length matches the length of the data to be written by the
  1477. * kernel.
  1478. */
  1479. __u64 data_ptr;
  1480. };
  1481. struct drm_i915_query {
  1482. __u32 num_items;
  1483. /*
  1484. * Unused for now. Must be cleared to zero.
  1485. */
  1486. __u32 flags;
  1487. /*
  1488. * This points to an array of num_items drm_i915_query_item structures.
  1489. */
  1490. __u64 items_ptr;
  1491. };
  1492. /*
  1493. * Data written by the kernel with query DRM_I915_QUERY_TOPOLOGY_INFO :
  1494. *
  1495. * data: contains the 3 pieces of information :
  1496. *
  1497. * - the slice mask with one bit per slice telling whether a slice is
  1498. * available. The availability of slice X can be queried with the following
  1499. * formula :
  1500. *
  1501. * (data[X / 8] >> (X % 8)) & 1
  1502. *
  1503. * - the subslice mask for each slice with one bit per subslice telling
  1504. * whether a subslice is available. The availability of subslice Y in slice
  1505. * X can be queried with the following formula :
  1506. *
  1507. * (data[subslice_offset +
  1508. * X * subslice_stride +
  1509. * Y / 8] >> (Y % 8)) & 1
  1510. *
  1511. * - the EU mask for each subslice in each slice with one bit per EU telling
  1512. * whether an EU is available. The availability of EU Z in subslice Y in
  1513. * slice X can be queried with the following formula :
  1514. *
  1515. * (data[eu_offset +
  1516. * (X * max_subslices + Y) * eu_stride +
  1517. * Z / 8] >> (Z % 8)) & 1
  1518. */
  1519. struct drm_i915_query_topology_info {
  1520. /*
  1521. * Unused for now. Must be cleared to zero.
  1522. */
  1523. __u16 flags;
  1524. __u16 max_slices;
  1525. __u16 max_subslices;
  1526. __u16 max_eus_per_subslice;
  1527. /*
  1528. * Offset in data[] at which the subslice masks are stored.
  1529. */
  1530. __u16 subslice_offset;
  1531. /*
  1532. * Stride at which each of the subslice masks for each slice are
  1533. * stored.
  1534. */
  1535. __u16 subslice_stride;
  1536. /*
  1537. * Offset in data[] at which the EU masks are stored.
  1538. */
  1539. __u16 eu_offset;
  1540. /*
  1541. * Stride at which each of the EU masks for each subslice are stored.
  1542. */
  1543. __u16 eu_stride;
  1544. __u8 data[];
  1545. };
  1546. #if defined(__cplusplus)
  1547. }
  1548. #endif
  1549. #endif /* _I915_DRM_H_ */