i915_drm.h 43 KB

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