i915_drm.h 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  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_IOCTL_I915_INIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT, drm_i915_init_t)
  241. #define DRM_IOCTL_I915_FLUSH DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLUSH)
  242. #define DRM_IOCTL_I915_FLIP DRM_IO ( DRM_COMMAND_BASE + DRM_I915_FLIP)
  243. #define DRM_IOCTL_I915_BATCHBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_BATCHBUFFER, drm_i915_batchbuffer_t)
  244. #define DRM_IOCTL_I915_IRQ_EMIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_IRQ_EMIT, drm_i915_irq_emit_t)
  245. #define DRM_IOCTL_I915_IRQ_WAIT DRM_IOW( DRM_COMMAND_BASE + DRM_I915_IRQ_WAIT, drm_i915_irq_wait_t)
  246. #define DRM_IOCTL_I915_GETPARAM DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GETPARAM, drm_i915_getparam_t)
  247. #define DRM_IOCTL_I915_SETPARAM DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SETPARAM, drm_i915_setparam_t)
  248. #define DRM_IOCTL_I915_ALLOC DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_ALLOC, drm_i915_mem_alloc_t)
  249. #define DRM_IOCTL_I915_FREE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_FREE, drm_i915_mem_free_t)
  250. #define DRM_IOCTL_I915_INIT_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_INIT_HEAP, drm_i915_mem_init_heap_t)
  251. #define DRM_IOCTL_I915_CMDBUFFER DRM_IOW( DRM_COMMAND_BASE + DRM_I915_CMDBUFFER, drm_i915_cmdbuffer_t)
  252. #define DRM_IOCTL_I915_DESTROY_HEAP DRM_IOW( DRM_COMMAND_BASE + DRM_I915_DESTROY_HEAP, drm_i915_mem_destroy_heap_t)
  253. #define DRM_IOCTL_I915_SET_VBLANK_PIPE DRM_IOW( DRM_COMMAND_BASE + DRM_I915_SET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  254. #define DRM_IOCTL_I915_GET_VBLANK_PIPE DRM_IOR( DRM_COMMAND_BASE + DRM_I915_GET_VBLANK_PIPE, drm_i915_vblank_pipe_t)
  255. #define DRM_IOCTL_I915_VBLANK_SWAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_VBLANK_SWAP, drm_i915_vblank_swap_t)
  256. #define DRM_IOCTL_I915_HWS_ADDR DRM_IOW(DRM_COMMAND_BASE + DRM_I915_HWS_ADDR, struct drm_i915_gem_init)
  257. #define DRM_IOCTL_I915_GEM_INIT DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_INIT, struct drm_i915_gem_init)
  258. #define DRM_IOCTL_I915_GEM_EXECBUFFER DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER, struct drm_i915_gem_execbuffer)
  259. #define DRM_IOCTL_I915_GEM_EXECBUFFER2 DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_EXECBUFFER2, struct drm_i915_gem_execbuffer2)
  260. #define DRM_IOCTL_I915_GEM_PIN DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_PIN, struct drm_i915_gem_pin)
  261. #define DRM_IOCTL_I915_GEM_UNPIN DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_UNPIN, struct drm_i915_gem_unpin)
  262. #define DRM_IOCTL_I915_GEM_BUSY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_BUSY, struct drm_i915_gem_busy)
  263. #define DRM_IOCTL_I915_GEM_SET_CACHING DRM_IOW(DRM_COMMAND_BASE + DRM_I915_GEM_SET_CACHING, struct drm_i915_gem_caching)
  264. #define DRM_IOCTL_I915_GEM_GET_CACHING DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_GET_CACHING, struct drm_i915_gem_caching)
  265. #define DRM_IOCTL_I915_GEM_THROTTLE DRM_IO ( DRM_COMMAND_BASE + DRM_I915_GEM_THROTTLE)
  266. #define DRM_IOCTL_I915_GEM_ENTERVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_ENTERVT)
  267. #define DRM_IOCTL_I915_GEM_LEAVEVT DRM_IO(DRM_COMMAND_BASE + DRM_I915_GEM_LEAVEVT)
  268. #define DRM_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct drm_i915_gem_create)
  269. #define DRM_IOCTL_I915_GEM_PREAD DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PREAD, struct drm_i915_gem_pread)
  270. #define DRM_IOCTL_I915_GEM_PWRITE DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_PWRITE, struct drm_i915_gem_pwrite)
  271. #define DRM_IOCTL_I915_GEM_MMAP DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct drm_i915_gem_mmap)
  272. #define DRM_IOCTL_I915_GEM_MMAP_GTT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP_GTT, struct drm_i915_gem_mmap_gtt)
  273. #define DRM_IOCTL_I915_GEM_SET_DOMAIN DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SET_DOMAIN, struct drm_i915_gem_set_domain)
  274. #define DRM_IOCTL_I915_GEM_SW_FINISH DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_SW_FINISH, struct drm_i915_gem_sw_finish)
  275. #define DRM_IOCTL_I915_GEM_SET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_SET_TILING, struct drm_i915_gem_set_tiling)
  276. #define DRM_IOCTL_I915_GEM_GET_TILING DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_TILING, struct drm_i915_gem_get_tiling)
  277. #define DRM_IOCTL_I915_GEM_GET_APERTURE DRM_IOR (DRM_COMMAND_BASE + DRM_I915_GEM_GET_APERTURE, struct drm_i915_gem_get_aperture)
  278. #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)
  279. #define DRM_IOCTL_I915_GEM_MADVISE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MADVISE, struct drm_i915_gem_madvise)
  280. #define DRM_IOCTL_I915_OVERLAY_PUT_IMAGE DRM_IOW(DRM_COMMAND_BASE + DRM_I915_OVERLAY_PUT_IMAGE, struct drm_intel_overlay_put_image)
  281. #define DRM_IOCTL_I915_OVERLAY_ATTRS DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_OVERLAY_ATTRS, struct drm_intel_overlay_attrs)
  282. #define DRM_IOCTL_I915_SET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_SET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  283. #define DRM_IOCTL_I915_GET_SPRITE_COLORKEY DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GET_SPRITE_COLORKEY, struct drm_intel_sprite_colorkey)
  284. #define DRM_IOCTL_I915_GEM_WAIT DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_WAIT, struct drm_i915_gem_wait)
  285. #define DRM_IOCTL_I915_GEM_CONTEXT_CREATE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_CREATE, struct drm_i915_gem_context_create)
  286. #define DRM_IOCTL_I915_GEM_CONTEXT_DESTROY DRM_IOW (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_DESTROY, struct drm_i915_gem_context_destroy)
  287. #define DRM_IOCTL_I915_REG_READ DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_REG_READ, struct drm_i915_reg_read)
  288. #define DRM_IOCTL_I915_GET_RESET_STATS DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GET_RESET_STATS, struct drm_i915_reset_stats)
  289. #define DRM_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_USERPTR, struct drm_i915_gem_userptr)
  290. #define DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_GETPARAM, struct drm_i915_gem_context_param)
  291. #define DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_CONTEXT_SETPARAM, struct drm_i915_gem_context_param)
  292. /* Allow drivers to submit batchbuffers directly to hardware, relying
  293. * on the security mechanisms provided by hardware.
  294. */
  295. typedef struct drm_i915_batchbuffer {
  296. int start; /* agp offset */
  297. int used; /* nr bytes in use */
  298. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  299. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  300. int num_cliprects; /* mulitpass with multiple cliprects? */
  301. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  302. } drm_i915_batchbuffer_t;
  303. /* As above, but pass a pointer to userspace buffer which can be
  304. * validated by the kernel prior to sending to hardware.
  305. */
  306. typedef struct _drm_i915_cmdbuffer {
  307. char __user *buf; /* pointer to userspace command buffer */
  308. int sz; /* nr bytes in buf */
  309. int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
  310. int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
  311. int num_cliprects; /* mulitpass with multiple cliprects? */
  312. struct drm_clip_rect __user *cliprects; /* pointer to userspace cliprects */
  313. } drm_i915_cmdbuffer_t;
  314. /* Userspace can request & wait on irq's:
  315. */
  316. typedef struct drm_i915_irq_emit {
  317. int __user *irq_seq;
  318. } drm_i915_irq_emit_t;
  319. typedef struct drm_i915_irq_wait {
  320. int irq_seq;
  321. } drm_i915_irq_wait_t;
  322. /* Ioctl to query kernel params:
  323. */
  324. #define I915_PARAM_IRQ_ACTIVE 1
  325. #define I915_PARAM_ALLOW_BATCHBUFFER 2
  326. #define I915_PARAM_LAST_DISPATCH 3
  327. #define I915_PARAM_CHIPSET_ID 4
  328. #define I915_PARAM_HAS_GEM 5
  329. #define I915_PARAM_NUM_FENCES_AVAIL 6
  330. #define I915_PARAM_HAS_OVERLAY 7
  331. #define I915_PARAM_HAS_PAGEFLIPPING 8
  332. #define I915_PARAM_HAS_EXECBUF2 9
  333. #define I915_PARAM_HAS_BSD 10
  334. #define I915_PARAM_HAS_BLT 11
  335. #define I915_PARAM_HAS_RELAXED_FENCING 12
  336. #define I915_PARAM_HAS_COHERENT_RINGS 13
  337. #define I915_PARAM_HAS_EXEC_CONSTANTS 14
  338. #define I915_PARAM_HAS_RELAXED_DELTA 15
  339. #define I915_PARAM_HAS_GEN7_SOL_RESET 16
  340. #define I915_PARAM_HAS_LLC 17
  341. #define I915_PARAM_HAS_ALIASING_PPGTT 18
  342. #define I915_PARAM_HAS_WAIT_TIMEOUT 19
  343. #define I915_PARAM_HAS_SEMAPHORES 20
  344. #define I915_PARAM_HAS_PRIME_VMAP_FLUSH 21
  345. #define I915_PARAM_HAS_VEBOX 22
  346. #define I915_PARAM_HAS_SECURE_BATCHES 23
  347. #define I915_PARAM_HAS_PINNED_BATCHES 24
  348. #define I915_PARAM_HAS_EXEC_NO_RELOC 25
  349. #define I915_PARAM_HAS_EXEC_HANDLE_LUT 26
  350. #define I915_PARAM_HAS_WT 27
  351. #define I915_PARAM_CMD_PARSER_VERSION 28
  352. #define I915_PARAM_HAS_COHERENT_PHYS_GTT 29
  353. #define I915_PARAM_MMAP_VERSION 30
  354. #define I915_PARAM_HAS_BSD2 31
  355. #define I915_PARAM_REVISION 32
  356. #define I915_PARAM_SUBSLICE_TOTAL 33
  357. #define I915_PARAM_EU_TOTAL 34
  358. #define I915_PARAM_HAS_GPU_RESET 35
  359. #define I915_PARAM_HAS_RESOURCE_STREAMER 36
  360. #define I915_PARAM_HAS_EXEC_SOFTPIN 37
  361. #define I915_PARAM_HAS_POOLED_EU 38
  362. #define I915_PARAM_MIN_EU_IN_POOL 39
  363. #define I915_PARAM_MMAP_GTT_VERSION 40
  364. typedef struct drm_i915_getparam {
  365. __s32 param;
  366. /*
  367. * WARNING: Using pointers instead of fixed-size u64 means we need to write
  368. * compat32 code. Don't repeat this mistake.
  369. */
  370. int __user *value;
  371. } drm_i915_getparam_t;
  372. /* Ioctl to set kernel params:
  373. */
  374. #define I915_SETPARAM_USE_MI_BATCHBUFFER_START 1
  375. #define I915_SETPARAM_TEX_LRU_LOG_GRANULARITY 2
  376. #define I915_SETPARAM_ALLOW_BATCHBUFFER 3
  377. #define I915_SETPARAM_NUM_USED_FENCES 4
  378. typedef struct drm_i915_setparam {
  379. int param;
  380. int value;
  381. } drm_i915_setparam_t;
  382. /* A memory manager for regions of shared memory:
  383. */
  384. #define I915_MEM_REGION_AGP 1
  385. typedef struct drm_i915_mem_alloc {
  386. int region;
  387. int alignment;
  388. int size;
  389. int __user *region_offset; /* offset from start of fb or agp */
  390. } drm_i915_mem_alloc_t;
  391. typedef struct drm_i915_mem_free {
  392. int region;
  393. int region_offset;
  394. } drm_i915_mem_free_t;
  395. typedef struct drm_i915_mem_init_heap {
  396. int region;
  397. int size;
  398. int start;
  399. } drm_i915_mem_init_heap_t;
  400. /* Allow memory manager to be torn down and re-initialized (eg on
  401. * rotate):
  402. */
  403. typedef struct drm_i915_mem_destroy_heap {
  404. int region;
  405. } drm_i915_mem_destroy_heap_t;
  406. /* Allow X server to configure which pipes to monitor for vblank signals
  407. */
  408. #define DRM_I915_VBLANK_PIPE_A 1
  409. #define DRM_I915_VBLANK_PIPE_B 2
  410. typedef struct drm_i915_vblank_pipe {
  411. int pipe;
  412. } drm_i915_vblank_pipe_t;
  413. /* Schedule buffer swap at given vertical blank:
  414. */
  415. typedef struct drm_i915_vblank_swap {
  416. drm_drawable_t drawable;
  417. enum drm_vblank_seq_type seqtype;
  418. unsigned int sequence;
  419. } drm_i915_vblank_swap_t;
  420. typedef struct drm_i915_hws_addr {
  421. __u64 addr;
  422. } drm_i915_hws_addr_t;
  423. struct drm_i915_gem_init {
  424. /**
  425. * Beginning offset in the GTT to be managed by the DRM memory
  426. * manager.
  427. */
  428. __u64 gtt_start;
  429. /**
  430. * Ending offset in the GTT to be managed by the DRM memory
  431. * manager.
  432. */
  433. __u64 gtt_end;
  434. };
  435. struct drm_i915_gem_create {
  436. /**
  437. * Requested size for the object.
  438. *
  439. * The (page-aligned) allocated size for the object will be returned.
  440. */
  441. __u64 size;
  442. /**
  443. * Returned handle for the object.
  444. *
  445. * Object handles are nonzero.
  446. */
  447. __u32 handle;
  448. __u32 pad;
  449. };
  450. struct drm_i915_gem_pread {
  451. /** Handle for the object being read. */
  452. __u32 handle;
  453. __u32 pad;
  454. /** Offset into the object to read from */
  455. __u64 offset;
  456. /** Length of data to read */
  457. __u64 size;
  458. /**
  459. * Pointer to write the data into.
  460. *
  461. * This is a fixed-size type for 32/64 compatibility.
  462. */
  463. __u64 data_ptr;
  464. };
  465. struct drm_i915_gem_pwrite {
  466. /** Handle for the object being written to. */
  467. __u32 handle;
  468. __u32 pad;
  469. /** Offset into the object to write to */
  470. __u64 offset;
  471. /** Length of data to write */
  472. __u64 size;
  473. /**
  474. * Pointer to read the data from.
  475. *
  476. * This is a fixed-size type for 32/64 compatibility.
  477. */
  478. __u64 data_ptr;
  479. };
  480. struct drm_i915_gem_mmap {
  481. /** Handle for the object being mapped. */
  482. __u32 handle;
  483. __u32 pad;
  484. /** Offset in the object to map. */
  485. __u64 offset;
  486. /**
  487. * Length of data to map.
  488. *
  489. * The value will be page-aligned.
  490. */
  491. __u64 size;
  492. /**
  493. * Returned pointer the data was mapped at.
  494. *
  495. * This is a fixed-size type for 32/64 compatibility.
  496. */
  497. __u64 addr_ptr;
  498. /**
  499. * Flags for extended behaviour.
  500. *
  501. * Added in version 2.
  502. */
  503. __u64 flags;
  504. #define I915_MMAP_WC 0x1
  505. };
  506. struct drm_i915_gem_mmap_gtt {
  507. /** Handle for the object being mapped. */
  508. __u32 handle;
  509. __u32 pad;
  510. /**
  511. * Fake offset to use for subsequent mmap call
  512. *
  513. * This is a fixed-size type for 32/64 compatibility.
  514. */
  515. __u64 offset;
  516. };
  517. struct drm_i915_gem_set_domain {
  518. /** Handle for the object */
  519. __u32 handle;
  520. /** New read domains */
  521. __u32 read_domains;
  522. /** New write domain */
  523. __u32 write_domain;
  524. };
  525. struct drm_i915_gem_sw_finish {
  526. /** Handle for the object */
  527. __u32 handle;
  528. };
  529. struct drm_i915_gem_relocation_entry {
  530. /**
  531. * Handle of the buffer being pointed to by this relocation entry.
  532. *
  533. * It's appealing to make this be an index into the mm_validate_entry
  534. * list to refer to the buffer, but this allows the driver to create
  535. * a relocation list for state buffers and not re-write it per
  536. * exec using the buffer.
  537. */
  538. __u32 target_handle;
  539. /**
  540. * Value to be added to the offset of the target buffer to make up
  541. * the relocation entry.
  542. */
  543. __u32 delta;
  544. /** Offset in the buffer the relocation entry will be written into */
  545. __u64 offset;
  546. /**
  547. * Offset value of the target buffer that the relocation entry was last
  548. * written as.
  549. *
  550. * If the buffer has the same offset as last time, we can skip syncing
  551. * and writing the relocation. This value is written back out by
  552. * the execbuffer ioctl when the relocation is written.
  553. */
  554. __u64 presumed_offset;
  555. /**
  556. * Target memory domains read by this operation.
  557. */
  558. __u32 read_domains;
  559. /**
  560. * Target memory domains written by this operation.
  561. *
  562. * Note that only one domain may be written by the whole
  563. * execbuffer operation, so that where there are conflicts,
  564. * the application will get -EINVAL back.
  565. */
  566. __u32 write_domain;
  567. };
  568. /** @{
  569. * Intel memory domains
  570. *
  571. * Most of these just align with the various caches in
  572. * the system and are used to flush and invalidate as
  573. * objects end up cached in different domains.
  574. */
  575. /** CPU cache */
  576. #define I915_GEM_DOMAIN_CPU 0x00000001
  577. /** Render cache, used by 2D and 3D drawing */
  578. #define I915_GEM_DOMAIN_RENDER 0x00000002
  579. /** Sampler cache, used by texture engine */
  580. #define I915_GEM_DOMAIN_SAMPLER 0x00000004
  581. /** Command queue, used to load batch buffers */
  582. #define I915_GEM_DOMAIN_COMMAND 0x00000008
  583. /** Instruction cache, used by shader programs */
  584. #define I915_GEM_DOMAIN_INSTRUCTION 0x00000010
  585. /** Vertex address cache */
  586. #define I915_GEM_DOMAIN_VERTEX 0x00000020
  587. /** GTT domain - aperture and scanout */
  588. #define I915_GEM_DOMAIN_GTT 0x00000040
  589. /** @} */
  590. struct drm_i915_gem_exec_object {
  591. /**
  592. * User's handle for a buffer to be bound into the GTT for this
  593. * operation.
  594. */
  595. __u32 handle;
  596. /** Number of relocations to be performed on this buffer */
  597. __u32 relocation_count;
  598. /**
  599. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  600. * the relocations to be performed in this buffer.
  601. */
  602. __u64 relocs_ptr;
  603. /** Required alignment in graphics aperture */
  604. __u64 alignment;
  605. /**
  606. * Returned value of the updated offset of the object, for future
  607. * presumed_offset writes.
  608. */
  609. __u64 offset;
  610. };
  611. struct drm_i915_gem_execbuffer {
  612. /**
  613. * List of buffers to be validated with their relocations to be
  614. * performend on them.
  615. *
  616. * This is a pointer to an array of struct drm_i915_gem_validate_entry.
  617. *
  618. * These buffers must be listed in an order such that all relocations
  619. * a buffer is performing refer to buffers that have already appeared
  620. * in the validate list.
  621. */
  622. __u64 buffers_ptr;
  623. __u32 buffer_count;
  624. /** Offset in the batchbuffer to start execution from. */
  625. __u32 batch_start_offset;
  626. /** Bytes used in batchbuffer from batch_start_offset */
  627. __u32 batch_len;
  628. __u32 DR1;
  629. __u32 DR4;
  630. __u32 num_cliprects;
  631. /** This is a struct drm_clip_rect *cliprects */
  632. __u64 cliprects_ptr;
  633. };
  634. struct drm_i915_gem_exec_object2 {
  635. /**
  636. * User's handle for a buffer to be bound into the GTT for this
  637. * operation.
  638. */
  639. __u32 handle;
  640. /** Number of relocations to be performed on this buffer */
  641. __u32 relocation_count;
  642. /**
  643. * Pointer to array of struct drm_i915_gem_relocation_entry containing
  644. * the relocations to be performed in this buffer.
  645. */
  646. __u64 relocs_ptr;
  647. /** Required alignment in graphics aperture */
  648. __u64 alignment;
  649. /**
  650. * When the EXEC_OBJECT_PINNED flag is specified this is populated by
  651. * the user with the GTT offset at which this object will be pinned.
  652. * When the I915_EXEC_NO_RELOC flag is specified this must contain the
  653. * presumed_offset of the object.
  654. * During execbuffer2 the kernel populates it with the value of the
  655. * current GTT offset of the object, for future presumed_offset writes.
  656. */
  657. __u64 offset;
  658. #define EXEC_OBJECT_NEEDS_FENCE (1<<0)
  659. #define EXEC_OBJECT_NEEDS_GTT (1<<1)
  660. #define EXEC_OBJECT_WRITE (1<<2)
  661. #define EXEC_OBJECT_SUPPORTS_48B_ADDRESS (1<<3)
  662. #define EXEC_OBJECT_PINNED (1<<4)
  663. #define EXEC_OBJECT_PAD_TO_SIZE (1<<5)
  664. /* All remaining bits are MBZ and RESERVED FOR FUTURE USE */
  665. #define __EXEC_OBJECT_UNKNOWN_FLAGS -(EXEC_OBJECT_PAD_TO_SIZE<<1)
  666. __u64 flags;
  667. union {
  668. __u64 rsvd1;
  669. __u64 pad_to_size;
  670. };
  671. __u64 rsvd2;
  672. };
  673. struct drm_i915_gem_execbuffer2 {
  674. /**
  675. * List of gem_exec_object2 structs
  676. */
  677. __u64 buffers_ptr;
  678. __u32 buffer_count;
  679. /** Offset in the batchbuffer to start execution from. */
  680. __u32 batch_start_offset;
  681. /** Bytes used in batchbuffer from batch_start_offset */
  682. __u32 batch_len;
  683. __u32 DR1;
  684. __u32 DR4;
  685. __u32 num_cliprects;
  686. /** This is a struct drm_clip_rect *cliprects */
  687. __u64 cliprects_ptr;
  688. #define I915_EXEC_RING_MASK (0x3f)
  689. #define I915_EXEC_DEFAULT (0<<0)
  690. #define I915_EXEC_RENDER (1<<0)
  691. #define I915_EXEC_BSD (2<<0)
  692. #define I915_EXEC_BLT (3<<0)
  693. #define I915_EXEC_VEBOX (4<<0)
  694. /* Used for switching the constants addressing mode on gen4+ RENDER ring.
  695. * Gen6+ only supports relative addressing to dynamic state (default) and
  696. * absolute addressing.
  697. *
  698. * These flags are ignored for the BSD and BLT rings.
  699. */
  700. #define I915_EXEC_CONSTANTS_MASK (3<<6)
  701. #define I915_EXEC_CONSTANTS_REL_GENERAL (0<<6) /* default */
  702. #define I915_EXEC_CONSTANTS_ABSOLUTE (1<<6)
  703. #define I915_EXEC_CONSTANTS_REL_SURFACE (2<<6) /* gen4/5 only */
  704. __u64 flags;
  705. __u64 rsvd1; /* now used for context info */
  706. __u64 rsvd2;
  707. };
  708. /** Resets the SO write offset registers for transform feedback on gen7. */
  709. #define I915_EXEC_GEN7_SOL_RESET (1<<8)
  710. /** Request a privileged ("secure") batch buffer. Note only available for
  711. * DRM_ROOT_ONLY | DRM_MASTER processes.
  712. */
  713. #define I915_EXEC_SECURE (1<<9)
  714. /** Inform the kernel that the batch is and will always be pinned. This
  715. * negates the requirement for a workaround to be performed to avoid
  716. * an incoherent CS (such as can be found on 830/845). If this flag is
  717. * not passed, the kernel will endeavour to make sure the batch is
  718. * coherent with the CS before execution. If this flag is passed,
  719. * userspace assumes the responsibility for ensuring the same.
  720. */
  721. #define I915_EXEC_IS_PINNED (1<<10)
  722. /** Provide a hint to the kernel that the command stream and auxiliary
  723. * state buffers already holds the correct presumed addresses and so the
  724. * relocation process may be skipped if no buffers need to be moved in
  725. * preparation for the execbuffer.
  726. */
  727. #define I915_EXEC_NO_RELOC (1<<11)
  728. /** Use the reloc.handle as an index into the exec object array rather
  729. * than as the per-file handle.
  730. */
  731. #define I915_EXEC_HANDLE_LUT (1<<12)
  732. /** Used for switching BSD rings on the platforms with two BSD rings */
  733. #define I915_EXEC_BSD_SHIFT (13)
  734. #define I915_EXEC_BSD_MASK (3 << I915_EXEC_BSD_SHIFT)
  735. /* default ping-pong mode */
  736. #define I915_EXEC_BSD_DEFAULT (0 << I915_EXEC_BSD_SHIFT)
  737. #define I915_EXEC_BSD_RING1 (1 << I915_EXEC_BSD_SHIFT)
  738. #define I915_EXEC_BSD_RING2 (2 << I915_EXEC_BSD_SHIFT)
  739. /** Tell the kernel that the batchbuffer is processed by
  740. * the resource streamer.
  741. */
  742. #define I915_EXEC_RESOURCE_STREAMER (1<<15)
  743. #define __I915_EXEC_UNKNOWN_FLAGS -(I915_EXEC_RESOURCE_STREAMER<<1)
  744. #define I915_EXEC_CONTEXT_ID_MASK (0xffffffff)
  745. #define i915_execbuffer2_set_context_id(eb2, context) \
  746. (eb2).rsvd1 = context & I915_EXEC_CONTEXT_ID_MASK
  747. #define i915_execbuffer2_get_context_id(eb2) \
  748. ((eb2).rsvd1 & I915_EXEC_CONTEXT_ID_MASK)
  749. struct drm_i915_gem_pin {
  750. /** Handle of the buffer to be pinned. */
  751. __u32 handle;
  752. __u32 pad;
  753. /** alignment required within the aperture */
  754. __u64 alignment;
  755. /** Returned GTT offset of the buffer. */
  756. __u64 offset;
  757. };
  758. struct drm_i915_gem_unpin {
  759. /** Handle of the buffer to be unpinned. */
  760. __u32 handle;
  761. __u32 pad;
  762. };
  763. struct drm_i915_gem_busy {
  764. /** Handle of the buffer to check for busy */
  765. __u32 handle;
  766. /** Return busy status
  767. *
  768. * A return of 0 implies that the object is idle (after
  769. * having flushed any pending activity), and a non-zero return that
  770. * the object is still in-flight on the GPU. (The GPU has not yet
  771. * signaled completion for all pending requests that reference the
  772. * object.) An object is guaranteed to become idle eventually (so
  773. * long as no new GPU commands are executed upon it). Due to the
  774. * asynchronous nature of the hardware, an object reported
  775. * as busy may become idle before the ioctl is completed.
  776. *
  777. * Furthermore, if the object is busy, which engine is busy is only
  778. * provided as a guide. There are race conditions which prevent the
  779. * report of which engines are busy from being always accurate.
  780. * However, the converse is not true. If the object is idle, the
  781. * result of the ioctl, that all engines are idle, is accurate.
  782. *
  783. * The returned dword is split into two fields to indicate both
  784. * the engines on which the object is being read, and the
  785. * engine on which it is currently being written (if any).
  786. *
  787. * The low word (bits 0:15) indicate if the object is being written
  788. * to by any engine (there can only be one, as the GEM implicit
  789. * synchronisation rules force writes to be serialised). Only the
  790. * engine for the last write is reported.
  791. *
  792. * The high word (bits 16:31) are a bitmask of which engines are
  793. * currently reading from the object. Multiple engines may be
  794. * reading from the object simultaneously.
  795. *
  796. * The value of each engine is the same as specified in the
  797. * EXECBUFFER2 ioctl, i.e. I915_EXEC_RENDER, I915_EXEC_BSD etc.
  798. * Note I915_EXEC_DEFAULT is a symbolic value and is mapped to
  799. * the I915_EXEC_RENDER engine for execution, and so it is never
  800. * reported as active itself. Some hardware may have parallel
  801. * execution engines, e.g. multiple media engines, which are
  802. * mapped to the same identifier in the EXECBUFFER2 ioctl and
  803. * so are not separately reported for busyness.
  804. *
  805. * Caveat emptor:
  806. * Only the boolean result of this query is reliable; that is whether
  807. * the object is idle or busy. The report of which engines are busy
  808. * should be only used as a heuristic.
  809. */
  810. __u32 busy;
  811. };
  812. /**
  813. * I915_CACHING_NONE
  814. *
  815. * GPU access is not coherent with cpu caches. Default for machines without an
  816. * LLC.
  817. */
  818. #define I915_CACHING_NONE 0
  819. /**
  820. * I915_CACHING_CACHED
  821. *
  822. * GPU access is coherent with cpu caches and furthermore the data is cached in
  823. * last-level caches shared between cpu cores and the gpu GT. Default on
  824. * machines with HAS_LLC.
  825. */
  826. #define I915_CACHING_CACHED 1
  827. /**
  828. * I915_CACHING_DISPLAY
  829. *
  830. * Special GPU caching mode which is coherent with the scanout engines.
  831. * Transparently falls back to I915_CACHING_NONE on platforms where no special
  832. * cache mode (like write-through or gfdt flushing) is available. The kernel
  833. * automatically sets this mode when using a buffer as a scanout target.
  834. * Userspace can manually set this mode to avoid a costly stall and clflush in
  835. * the hotpath of drawing the first frame.
  836. */
  837. #define I915_CACHING_DISPLAY 2
  838. struct drm_i915_gem_caching {
  839. /**
  840. * Handle of the buffer to set/get the caching level of. */
  841. __u32 handle;
  842. /**
  843. * Cacheing level to apply or return value
  844. *
  845. * bits0-15 are for generic caching control (i.e. the above defined
  846. * values). bits16-31 are reserved for platform-specific variations
  847. * (e.g. l3$ caching on gen7). */
  848. __u32 caching;
  849. };
  850. #define I915_TILING_NONE 0
  851. #define I915_TILING_X 1
  852. #define I915_TILING_Y 2
  853. #define I915_TILING_LAST I915_TILING_Y
  854. #define I915_BIT_6_SWIZZLE_NONE 0
  855. #define I915_BIT_6_SWIZZLE_9 1
  856. #define I915_BIT_6_SWIZZLE_9_10 2
  857. #define I915_BIT_6_SWIZZLE_9_11 3
  858. #define I915_BIT_6_SWIZZLE_9_10_11 4
  859. /* Not seen by userland */
  860. #define I915_BIT_6_SWIZZLE_UNKNOWN 5
  861. /* Seen by userland. */
  862. #define I915_BIT_6_SWIZZLE_9_17 6
  863. #define I915_BIT_6_SWIZZLE_9_10_17 7
  864. struct drm_i915_gem_set_tiling {
  865. /** Handle of the buffer to have its tiling state updated */
  866. __u32 handle;
  867. /**
  868. * Tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  869. * I915_TILING_Y).
  870. *
  871. * This value is to be set on request, and will be updated by the
  872. * kernel on successful return with the actual chosen tiling layout.
  873. *
  874. * The tiling mode may be demoted to I915_TILING_NONE when the system
  875. * has bit 6 swizzling that can't be managed correctly by GEM.
  876. *
  877. * Buffer contents become undefined when changing tiling_mode.
  878. */
  879. __u32 tiling_mode;
  880. /**
  881. * Stride in bytes for the object when in I915_TILING_X or
  882. * I915_TILING_Y.
  883. */
  884. __u32 stride;
  885. /**
  886. * Returned address bit 6 swizzling required for CPU access through
  887. * mmap mapping.
  888. */
  889. __u32 swizzle_mode;
  890. };
  891. struct drm_i915_gem_get_tiling {
  892. /** Handle of the buffer to get tiling state for. */
  893. __u32 handle;
  894. /**
  895. * Current tiling mode for the object (I915_TILING_NONE, I915_TILING_X,
  896. * I915_TILING_Y).
  897. */
  898. __u32 tiling_mode;
  899. /**
  900. * Returned address bit 6 swizzling required for CPU access through
  901. * mmap mapping.
  902. */
  903. __u32 swizzle_mode;
  904. /**
  905. * Returned address bit 6 swizzling required for CPU access through
  906. * mmap mapping whilst bound.
  907. */
  908. __u32 phys_swizzle_mode;
  909. };
  910. struct drm_i915_gem_get_aperture {
  911. /** Total size of the aperture used by i915_gem_execbuffer, in bytes */
  912. __u64 aper_size;
  913. /**
  914. * Available space in the aperture used by i915_gem_execbuffer, in
  915. * bytes
  916. */
  917. __u64 aper_available_size;
  918. };
  919. struct drm_i915_get_pipe_from_crtc_id {
  920. /** ID of CRTC being requested **/
  921. __u32 crtc_id;
  922. /** pipe of requested CRTC **/
  923. __u32 pipe;
  924. };
  925. #define I915_MADV_WILLNEED 0
  926. #define I915_MADV_DONTNEED 1
  927. #define __I915_MADV_PURGED 2 /* internal state */
  928. struct drm_i915_gem_madvise {
  929. /** Handle of the buffer to change the backing store advice */
  930. __u32 handle;
  931. /* Advice: either the buffer will be needed again in the near future,
  932. * or wont be and could be discarded under memory pressure.
  933. */
  934. __u32 madv;
  935. /** Whether the backing store still exists. */
  936. __u32 retained;
  937. };
  938. /* flags */
  939. #define I915_OVERLAY_TYPE_MASK 0xff
  940. #define I915_OVERLAY_YUV_PLANAR 0x01
  941. #define I915_OVERLAY_YUV_PACKED 0x02
  942. #define I915_OVERLAY_RGB 0x03
  943. #define I915_OVERLAY_DEPTH_MASK 0xff00
  944. #define I915_OVERLAY_RGB24 0x1000
  945. #define I915_OVERLAY_RGB16 0x2000
  946. #define I915_OVERLAY_RGB15 0x3000
  947. #define I915_OVERLAY_YUV422 0x0100
  948. #define I915_OVERLAY_YUV411 0x0200
  949. #define I915_OVERLAY_YUV420 0x0300
  950. #define I915_OVERLAY_YUV410 0x0400
  951. #define I915_OVERLAY_SWAP_MASK 0xff0000
  952. #define I915_OVERLAY_NO_SWAP 0x000000
  953. #define I915_OVERLAY_UV_SWAP 0x010000
  954. #define I915_OVERLAY_Y_SWAP 0x020000
  955. #define I915_OVERLAY_Y_AND_UV_SWAP 0x030000
  956. #define I915_OVERLAY_FLAGS_MASK 0xff000000
  957. #define I915_OVERLAY_ENABLE 0x01000000
  958. struct drm_intel_overlay_put_image {
  959. /* various flags and src format description */
  960. __u32 flags;
  961. /* source picture description */
  962. __u32 bo_handle;
  963. /* stride values and offsets are in bytes, buffer relative */
  964. __u16 stride_Y; /* stride for packed formats */
  965. __u16 stride_UV;
  966. __u32 offset_Y; /* offset for packet formats */
  967. __u32 offset_U;
  968. __u32 offset_V;
  969. /* in pixels */
  970. __u16 src_width;
  971. __u16 src_height;
  972. /* to compensate the scaling factors for partially covered surfaces */
  973. __u16 src_scan_width;
  974. __u16 src_scan_height;
  975. /* output crtc description */
  976. __u32 crtc_id;
  977. __u16 dst_x;
  978. __u16 dst_y;
  979. __u16 dst_width;
  980. __u16 dst_height;
  981. };
  982. /* flags */
  983. #define I915_OVERLAY_UPDATE_ATTRS (1<<0)
  984. #define I915_OVERLAY_UPDATE_GAMMA (1<<1)
  985. #define I915_OVERLAY_DISABLE_DEST_COLORKEY (1<<2)
  986. struct drm_intel_overlay_attrs {
  987. __u32 flags;
  988. __u32 color_key;
  989. __s32 brightness;
  990. __u32 contrast;
  991. __u32 saturation;
  992. __u32 gamma0;
  993. __u32 gamma1;
  994. __u32 gamma2;
  995. __u32 gamma3;
  996. __u32 gamma4;
  997. __u32 gamma5;
  998. };
  999. /*
  1000. * Intel sprite handling
  1001. *
  1002. * Color keying works with a min/mask/max tuple. Both source and destination
  1003. * color keying is allowed.
  1004. *
  1005. * Source keying:
  1006. * Sprite pixels within the min & max values, masked against the color channels
  1007. * specified in the mask field, will be transparent. All other pixels will
  1008. * be displayed on top of the primary plane. For RGB surfaces, only the min
  1009. * and mask fields will be used; ranged compares are not allowed.
  1010. *
  1011. * Destination keying:
  1012. * Primary plane pixels that match the min value, masked against the color
  1013. * channels specified in the mask field, will be replaced by corresponding
  1014. * pixels from the sprite plane.
  1015. *
  1016. * Note that source & destination keying are exclusive; only one can be
  1017. * active on a given plane.
  1018. */
  1019. #define I915_SET_COLORKEY_NONE (1<<0) /* disable color key matching */
  1020. #define I915_SET_COLORKEY_DESTINATION (1<<1)
  1021. #define I915_SET_COLORKEY_SOURCE (1<<2)
  1022. struct drm_intel_sprite_colorkey {
  1023. __u32 plane_id;
  1024. __u32 min_value;
  1025. __u32 channel_mask;
  1026. __u32 max_value;
  1027. __u32 flags;
  1028. };
  1029. struct drm_i915_gem_wait {
  1030. /** Handle of BO we shall wait on */
  1031. __u32 bo_handle;
  1032. __u32 flags;
  1033. /** Number of nanoseconds to wait, Returns time remaining. */
  1034. __s64 timeout_ns;
  1035. };
  1036. struct drm_i915_gem_context_create {
  1037. /* output: id of new context*/
  1038. __u32 ctx_id;
  1039. __u32 pad;
  1040. };
  1041. struct drm_i915_gem_context_destroy {
  1042. __u32 ctx_id;
  1043. __u32 pad;
  1044. };
  1045. struct drm_i915_reg_read {
  1046. /*
  1047. * Register offset.
  1048. * For 64bit wide registers where the upper 32bits don't immediately
  1049. * follow the lower 32bits, the offset of the lower 32bits must
  1050. * be specified
  1051. */
  1052. __u64 offset;
  1053. __u64 val; /* Return value */
  1054. };
  1055. /* Known registers:
  1056. *
  1057. * Render engine timestamp - 0x2358 + 64bit - gen7+
  1058. * - Note this register returns an invalid value if using the default
  1059. * single instruction 8byte read, in order to workaround that use
  1060. * offset (0x2538 | 1) instead.
  1061. *
  1062. */
  1063. struct drm_i915_reset_stats {
  1064. __u32 ctx_id;
  1065. __u32 flags;
  1066. /* All resets since boot/module reload, for all contexts */
  1067. __u32 reset_count;
  1068. /* Number of batches lost when active in GPU, for this context */
  1069. __u32 batch_active;
  1070. /* Number of batches lost pending for execution, for this context */
  1071. __u32 batch_pending;
  1072. __u32 pad;
  1073. };
  1074. struct drm_i915_gem_userptr {
  1075. __u64 user_ptr;
  1076. __u64 user_size;
  1077. __u32 flags;
  1078. #define I915_USERPTR_READ_ONLY 0x1
  1079. #define I915_USERPTR_UNSYNCHRONIZED 0x80000000
  1080. /**
  1081. * Returned handle for the object.
  1082. *
  1083. * Object handles are nonzero.
  1084. */
  1085. __u32 handle;
  1086. };
  1087. struct drm_i915_gem_context_param {
  1088. __u32 ctx_id;
  1089. __u32 size;
  1090. __u64 param;
  1091. #define I915_CONTEXT_PARAM_BAN_PERIOD 0x1
  1092. #define I915_CONTEXT_PARAM_NO_ZEROMAP 0x2
  1093. #define I915_CONTEXT_PARAM_GTT_SIZE 0x3
  1094. #define I915_CONTEXT_PARAM_NO_ERROR_CAPTURE 0x4
  1095. __u64 value;
  1096. };
  1097. #if defined(__cplusplus)
  1098. }
  1099. #endif
  1100. #endif /* _UAPI_I915_DRM_H_ */