vmwgfx_drm.h 31 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. /**************************************************************************
  2. *
  3. * Copyright © 2009-2015 VMware, Inc., Palo Alto, CA., USA
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef __VMWGFX_DRM_H__
  28. #define __VMWGFX_DRM_H__
  29. #include "drm.h"
  30. #if defined(__cplusplus)
  31. extern "C" {
  32. #endif
  33. #define DRM_VMW_MAX_SURFACE_FACES 6
  34. #define DRM_VMW_MAX_MIP_LEVELS 24
  35. #define DRM_VMW_GET_PARAM 0
  36. #define DRM_VMW_ALLOC_DMABUF 1
  37. #define DRM_VMW_ALLOC_BO 1
  38. #define DRM_VMW_UNREF_DMABUF 2
  39. #define DRM_VMW_HANDLE_CLOSE 2
  40. #define DRM_VMW_CURSOR_BYPASS 3
  41. /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
  42. #define DRM_VMW_CONTROL_STREAM 4
  43. #define DRM_VMW_CLAIM_STREAM 5
  44. #define DRM_VMW_UNREF_STREAM 6
  45. /* guarded by DRM_VMW_PARAM_3D == 1 */
  46. #define DRM_VMW_CREATE_CONTEXT 7
  47. #define DRM_VMW_UNREF_CONTEXT 8
  48. #define DRM_VMW_CREATE_SURFACE 9
  49. #define DRM_VMW_UNREF_SURFACE 10
  50. #define DRM_VMW_REF_SURFACE 11
  51. #define DRM_VMW_EXECBUF 12
  52. #define DRM_VMW_GET_3D_CAP 13
  53. #define DRM_VMW_FENCE_WAIT 14
  54. #define DRM_VMW_FENCE_SIGNALED 15
  55. #define DRM_VMW_FENCE_UNREF 16
  56. #define DRM_VMW_FENCE_EVENT 17
  57. #define DRM_VMW_PRESENT 18
  58. #define DRM_VMW_PRESENT_READBACK 19
  59. #define DRM_VMW_UPDATE_LAYOUT 20
  60. #define DRM_VMW_CREATE_SHADER 21
  61. #define DRM_VMW_UNREF_SHADER 22
  62. #define DRM_VMW_GB_SURFACE_CREATE 23
  63. #define DRM_VMW_GB_SURFACE_REF 24
  64. #define DRM_VMW_SYNCCPU 25
  65. #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
  66. /*************************************************************************/
  67. /**
  68. * DRM_VMW_GET_PARAM - get device information.
  69. *
  70. * DRM_VMW_PARAM_FIFO_OFFSET:
  71. * Offset to use to map the first page of the FIFO read-only.
  72. * The fifo is mapped using the mmap() system call on the drm device.
  73. *
  74. * DRM_VMW_PARAM_OVERLAY_IOCTL:
  75. * Does the driver support the overlay ioctl.
  76. */
  77. #define DRM_VMW_PARAM_NUM_STREAMS 0
  78. #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
  79. #define DRM_VMW_PARAM_3D 2
  80. #define DRM_VMW_PARAM_HW_CAPS 3
  81. #define DRM_VMW_PARAM_FIFO_CAPS 4
  82. #define DRM_VMW_PARAM_MAX_FB_SIZE 5
  83. #define DRM_VMW_PARAM_FIFO_HW_VERSION 6
  84. #define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
  85. #define DRM_VMW_PARAM_3D_CAPS_SIZE 8
  86. #define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
  87. #define DRM_VMW_PARAM_MAX_MOB_SIZE 10
  88. #define DRM_VMW_PARAM_SCREEN_TARGET 11
  89. #define DRM_VMW_PARAM_DX 12
  90. /**
  91. * enum drm_vmw_handle_type - handle type for ref ioctls
  92. *
  93. */
  94. enum drm_vmw_handle_type {
  95. DRM_VMW_HANDLE_LEGACY = 0,
  96. DRM_VMW_HANDLE_PRIME = 1
  97. };
  98. /**
  99. * struct drm_vmw_getparam_arg
  100. *
  101. * @value: Returned value. //Out
  102. * @param: Parameter to query. //In.
  103. *
  104. * Argument to the DRM_VMW_GET_PARAM Ioctl.
  105. */
  106. struct drm_vmw_getparam_arg {
  107. __u64 value;
  108. __u32 param;
  109. __u32 pad64;
  110. };
  111. /*************************************************************************/
  112. /**
  113. * DRM_VMW_CREATE_CONTEXT - Create a host context.
  114. *
  115. * Allocates a device unique context id, and queues a create context command
  116. * for the host. Does not wait for host completion.
  117. */
  118. /**
  119. * struct drm_vmw_context_arg
  120. *
  121. * @cid: Device unique context ID.
  122. *
  123. * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
  124. * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
  125. */
  126. struct drm_vmw_context_arg {
  127. __s32 cid;
  128. __u32 pad64;
  129. };
  130. /*************************************************************************/
  131. /**
  132. * DRM_VMW_UNREF_CONTEXT - Create a host context.
  133. *
  134. * Frees a global context id, and queues a destroy host command for the host.
  135. * Does not wait for host completion. The context ID can be used directly
  136. * in the command stream and shows up as the same context ID on the host.
  137. */
  138. /*************************************************************************/
  139. /**
  140. * DRM_VMW_CREATE_SURFACE - Create a host suface.
  141. *
  142. * Allocates a device unique surface id, and queues a create surface command
  143. * for the host. Does not wait for host completion. The surface ID can be
  144. * used directly in the command stream and shows up as the same surface
  145. * ID on the host.
  146. */
  147. /**
  148. * struct drm_wmv_surface_create_req
  149. *
  150. * @flags: Surface flags as understood by the host.
  151. * @format: Surface format as understood by the host.
  152. * @mip_levels: Number of mip levels for each face.
  153. * An unused face should have 0 encoded.
  154. * @size_addr: Address of a user-space array of sruct drm_vmw_size
  155. * cast to an __u64 for 32-64 bit compatibility.
  156. * The size of the array should equal the total number of mipmap levels.
  157. * @shareable: Boolean whether other clients (as identified by file descriptors)
  158. * may reference this surface.
  159. * @scanout: Boolean whether the surface is intended to be used as a
  160. * scanout.
  161. *
  162. * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
  163. * Output data from the DRM_VMW_REF_SURFACE Ioctl.
  164. */
  165. struct drm_vmw_surface_create_req {
  166. __u32 flags;
  167. __u32 format;
  168. __u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
  169. __u64 size_addr;
  170. __s32 shareable;
  171. __s32 scanout;
  172. };
  173. /**
  174. * struct drm_wmv_surface_arg
  175. *
  176. * @sid: Surface id of created surface or surface to destroy or reference.
  177. * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
  178. *
  179. * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
  180. * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
  181. * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
  182. */
  183. struct drm_vmw_surface_arg {
  184. __s32 sid;
  185. enum drm_vmw_handle_type handle_type;
  186. };
  187. /**
  188. * struct drm_vmw_size ioctl.
  189. *
  190. * @width - mip level width
  191. * @height - mip level height
  192. * @depth - mip level depth
  193. *
  194. * Description of a mip level.
  195. * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
  196. */
  197. struct drm_vmw_size {
  198. __u32 width;
  199. __u32 height;
  200. __u32 depth;
  201. __u32 pad64;
  202. };
  203. /**
  204. * union drm_vmw_surface_create_arg
  205. *
  206. * @rep: Output data as described above.
  207. * @req: Input data as described above.
  208. *
  209. * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
  210. */
  211. union drm_vmw_surface_create_arg {
  212. struct drm_vmw_surface_arg rep;
  213. struct drm_vmw_surface_create_req req;
  214. };
  215. /*************************************************************************/
  216. /**
  217. * DRM_VMW_REF_SURFACE - Reference a host surface.
  218. *
  219. * Puts a reference on a host surface with a give sid, as previously
  220. * returned by the DRM_VMW_CREATE_SURFACE ioctl.
  221. * A reference will make sure the surface isn't destroyed while we hold
  222. * it and will allow the calling client to use the surface ID in the command
  223. * stream.
  224. *
  225. * On successful return, the Ioctl returns the surface information given
  226. * in the DRM_VMW_CREATE_SURFACE ioctl.
  227. */
  228. /**
  229. * union drm_vmw_surface_reference_arg
  230. *
  231. * @rep: Output data as described above.
  232. * @req: Input data as described above.
  233. *
  234. * Argument to the DRM_VMW_REF_SURFACE Ioctl.
  235. */
  236. union drm_vmw_surface_reference_arg {
  237. struct drm_vmw_surface_create_req rep;
  238. struct drm_vmw_surface_arg req;
  239. };
  240. /*************************************************************************/
  241. /**
  242. * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
  243. *
  244. * Clear a reference previously put on a host surface.
  245. * When all references are gone, including the one implicitly placed
  246. * on creation,
  247. * a destroy surface command will be queued for the host.
  248. * Does not wait for completion.
  249. */
  250. /*************************************************************************/
  251. /**
  252. * DRM_VMW_EXECBUF
  253. *
  254. * Submit a command buffer for execution on the host, and return a
  255. * fence seqno that when signaled, indicates that the command buffer has
  256. * executed.
  257. */
  258. /**
  259. * struct drm_vmw_execbuf_arg
  260. *
  261. * @commands: User-space address of a command buffer cast to an __u64.
  262. * @command-size: Size in bytes of the command buffer.
  263. * @throttle-us: Sleep until software is less than @throttle_us
  264. * microseconds ahead of hardware. The driver may round this value
  265. * to the nearest kernel tick.
  266. * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
  267. * __u64.
  268. * @version: Allows expanding the execbuf ioctl parameters without breaking
  269. * backwards compatibility, since user-space will always tell the kernel
  270. * which version it uses.
  271. * @flags: Execbuf flags.
  272. * @imported_fence_fd: FD for a fence imported from another device
  273. *
  274. * Argument to the DRM_VMW_EXECBUF Ioctl.
  275. */
  276. #define DRM_VMW_EXECBUF_VERSION 2
  277. #define DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD (1 << 0)
  278. #define DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD (1 << 1)
  279. struct drm_vmw_execbuf_arg {
  280. __u64 commands;
  281. __u32 command_size;
  282. __u32 throttle_us;
  283. __u64 fence_rep;
  284. __u32 version;
  285. __u32 flags;
  286. __u32 context_handle;
  287. __s32 imported_fence_fd;
  288. };
  289. /**
  290. * struct drm_vmw_fence_rep
  291. *
  292. * @handle: Fence object handle for fence associated with a command submission.
  293. * @mask: Fence flags relevant for this fence object.
  294. * @seqno: Fence sequence number in fifo. A fence object with a lower
  295. * seqno will signal the EXEC flag before a fence object with a higher
  296. * seqno. This can be used by user-space to avoid kernel calls to determine
  297. * whether a fence has signaled the EXEC flag. Note that @seqno will
  298. * wrap at 32-bit.
  299. * @passed_seqno: The highest seqno number processed by the hardware
  300. * so far. This can be used to mark user-space fence objects as signaled, and
  301. * to determine whether a fence seqno might be stale.
  302. * @fd: FD associated with the fence, -1 if not exported
  303. * @error: This member should've been set to -EFAULT on submission.
  304. * The following actions should be take on completion:
  305. * error == -EFAULT: Fence communication failed. The host is synchronized.
  306. * Use the last fence id read from the FIFO fence register.
  307. * error != 0 && error != -EFAULT:
  308. * Fence submission failed. The host is synchronized. Use the fence_seq member.
  309. * error == 0: All is OK, The host may not be synchronized.
  310. * Use the fence_seq member.
  311. *
  312. * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
  313. */
  314. struct drm_vmw_fence_rep {
  315. __u32 handle;
  316. __u32 mask;
  317. __u32 seqno;
  318. __u32 passed_seqno;
  319. __s32 fd;
  320. __s32 error;
  321. };
  322. /*************************************************************************/
  323. /**
  324. * DRM_VMW_ALLOC_BO
  325. *
  326. * Allocate a buffer object that is visible also to the host.
  327. * NOTE: The buffer is
  328. * identified by a handle and an offset, which are private to the guest, but
  329. * useable in the command stream. The guest kernel may translate these
  330. * and patch up the command stream accordingly. In the future, the offset may
  331. * be zero at all times, or it may disappear from the interface before it is
  332. * fixed.
  333. *
  334. * The buffer object may stay user-space mapped in the guest at all times,
  335. * and is thus suitable for sub-allocation.
  336. *
  337. * Buffer objects are mapped using the mmap() syscall on the drm device.
  338. */
  339. /**
  340. * struct drm_vmw_alloc_bo_req
  341. *
  342. * @size: Required minimum size of the buffer.
  343. *
  344. * Input data to the DRM_VMW_ALLOC_BO Ioctl.
  345. */
  346. struct drm_vmw_alloc_bo_req {
  347. __u32 size;
  348. __u32 pad64;
  349. };
  350. #define drm_vmw_alloc_dmabuf_req drm_vmw_alloc_bo_req
  351. /**
  352. * struct drm_vmw_bo_rep
  353. *
  354. * @map_handle: Offset to use in the mmap() call used to map the buffer.
  355. * @handle: Handle unique to this buffer. Used for unreferencing.
  356. * @cur_gmr_id: GMR id to use in the command stream when this buffer is
  357. * referenced. See not above.
  358. * @cur_gmr_offset: Offset to use in the command stream when this buffer is
  359. * referenced. See note above.
  360. *
  361. * Output data from the DRM_VMW_ALLOC_BO Ioctl.
  362. */
  363. struct drm_vmw_bo_rep {
  364. __u64 map_handle;
  365. __u32 handle;
  366. __u32 cur_gmr_id;
  367. __u32 cur_gmr_offset;
  368. __u32 pad64;
  369. };
  370. #define drm_vmw_dmabuf_rep drm_vmw_bo_rep
  371. /**
  372. * union drm_vmw_alloc_bo_arg
  373. *
  374. * @req: Input data as described above.
  375. * @rep: Output data as described above.
  376. *
  377. * Argument to the DRM_VMW_ALLOC_BO Ioctl.
  378. */
  379. union drm_vmw_alloc_bo_arg {
  380. struct drm_vmw_alloc_bo_req req;
  381. struct drm_vmw_bo_rep rep;
  382. };
  383. #define drm_vmw_alloc_dmabuf_arg drm_vmw_alloc_bo_arg
  384. /*************************************************************************/
  385. /**
  386. * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
  387. *
  388. * This IOCTL controls the overlay units of the svga device.
  389. * The SVGA overlay units does not work like regular hardware units in
  390. * that they do not automaticaly read back the contents of the given dma
  391. * buffer. But instead only read back for each call to this ioctl, and
  392. * at any point between this call being made and a following call that
  393. * either changes the buffer or disables the stream.
  394. */
  395. /**
  396. * struct drm_vmw_rect
  397. *
  398. * Defines a rectangle. Used in the overlay ioctl to define
  399. * source and destination rectangle.
  400. */
  401. struct drm_vmw_rect {
  402. __s32 x;
  403. __s32 y;
  404. __u32 w;
  405. __u32 h;
  406. };
  407. /**
  408. * struct drm_vmw_control_stream_arg
  409. *
  410. * @stream_id: Stearm to control
  411. * @enabled: If false all following arguments are ignored.
  412. * @handle: Handle to buffer for getting data from.
  413. * @format: Format of the overlay as understood by the host.
  414. * @width: Width of the overlay.
  415. * @height: Height of the overlay.
  416. * @size: Size of the overlay in bytes.
  417. * @pitch: Array of pitches, the two last are only used for YUV12 formats.
  418. * @offset: Offset from start of dma buffer to overlay.
  419. * @src: Source rect, must be within the defined area above.
  420. * @dst: Destination rect, x and y may be negative.
  421. *
  422. * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
  423. */
  424. struct drm_vmw_control_stream_arg {
  425. __u32 stream_id;
  426. __u32 enabled;
  427. __u32 flags;
  428. __u32 color_key;
  429. __u32 handle;
  430. __u32 offset;
  431. __s32 format;
  432. __u32 size;
  433. __u32 width;
  434. __u32 height;
  435. __u32 pitch[3];
  436. __u32 pad64;
  437. struct drm_vmw_rect src;
  438. struct drm_vmw_rect dst;
  439. };
  440. /*************************************************************************/
  441. /**
  442. * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
  443. *
  444. */
  445. #define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
  446. #define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
  447. /**
  448. * struct drm_vmw_cursor_bypass_arg
  449. *
  450. * @flags: Flags.
  451. * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
  452. * @xpos: X position of cursor.
  453. * @ypos: Y position of cursor.
  454. * @xhot: X hotspot.
  455. * @yhot: Y hotspot.
  456. *
  457. * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
  458. */
  459. struct drm_vmw_cursor_bypass_arg {
  460. __u32 flags;
  461. __u32 crtc_id;
  462. __s32 xpos;
  463. __s32 ypos;
  464. __s32 xhot;
  465. __s32 yhot;
  466. };
  467. /*************************************************************************/
  468. /**
  469. * DRM_VMW_CLAIM_STREAM - Claim a single stream.
  470. */
  471. /**
  472. * struct drm_vmw_context_arg
  473. *
  474. * @stream_id: Device unique context ID.
  475. *
  476. * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
  477. * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
  478. */
  479. struct drm_vmw_stream_arg {
  480. __u32 stream_id;
  481. __u32 pad64;
  482. };
  483. /*************************************************************************/
  484. /**
  485. * DRM_VMW_UNREF_STREAM - Unclaim a stream.
  486. *
  487. * Return a single stream that was claimed by this process. Also makes
  488. * sure that the stream has been stopped.
  489. */
  490. /*************************************************************************/
  491. /**
  492. * DRM_VMW_GET_3D_CAP
  493. *
  494. * Read 3D capabilities from the FIFO
  495. *
  496. */
  497. /**
  498. * struct drm_vmw_get_3d_cap_arg
  499. *
  500. * @buffer: Pointer to a buffer for capability data, cast to an __u64
  501. * @size: Max size to copy
  502. *
  503. * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
  504. * ioctls.
  505. */
  506. struct drm_vmw_get_3d_cap_arg {
  507. __u64 buffer;
  508. __u32 max_size;
  509. __u32 pad64;
  510. };
  511. /*************************************************************************/
  512. /**
  513. * DRM_VMW_FENCE_WAIT
  514. *
  515. * Waits for a fence object to signal. The wait is interruptible, so that
  516. * signals may be delivered during the interrupt. The wait may timeout,
  517. * in which case the calls returns -EBUSY. If the wait is restarted,
  518. * that is restarting without resetting @cookie_valid to zero,
  519. * the timeout is computed from the first call.
  520. *
  521. * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
  522. * on:
  523. * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
  524. * stream
  525. * have executed.
  526. * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
  527. * commands
  528. * in the buffer given to the EXECBUF ioctl returning the fence object handle
  529. * are available to user-space.
  530. *
  531. * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
  532. * fenc wait ioctl returns 0, the fence object has been unreferenced after
  533. * the wait.
  534. */
  535. #define DRM_VMW_FENCE_FLAG_EXEC (1 << 0)
  536. #define DRM_VMW_FENCE_FLAG_QUERY (1 << 1)
  537. #define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
  538. /**
  539. * struct drm_vmw_fence_wait_arg
  540. *
  541. * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
  542. * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
  543. * @kernel_cookie: Set to 0 on first call. Left alone on restart.
  544. * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
  545. * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
  546. * before returning.
  547. * @flags: Fence flags to wait on.
  548. * @wait_options: Options that control the behaviour of the wait ioctl.
  549. *
  550. * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
  551. */
  552. struct drm_vmw_fence_wait_arg {
  553. __u32 handle;
  554. __s32 cookie_valid;
  555. __u64 kernel_cookie;
  556. __u64 timeout_us;
  557. __s32 lazy;
  558. __s32 flags;
  559. __s32 wait_options;
  560. __s32 pad64;
  561. };
  562. /*************************************************************************/
  563. /**
  564. * DRM_VMW_FENCE_SIGNALED
  565. *
  566. * Checks if a fence object is signaled..
  567. */
  568. /**
  569. * struct drm_vmw_fence_signaled_arg
  570. *
  571. * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
  572. * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
  573. * @signaled: Out: Flags signaled.
  574. * @sequence: Out: Highest sequence passed so far. Can be used to signal the
  575. * EXEC flag of user-space fence objects.
  576. *
  577. * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
  578. * ioctls.
  579. */
  580. struct drm_vmw_fence_signaled_arg {
  581. __u32 handle;
  582. __u32 flags;
  583. __s32 signaled;
  584. __u32 passed_seqno;
  585. __u32 signaled_flags;
  586. __u32 pad64;
  587. };
  588. /*************************************************************************/
  589. /**
  590. * DRM_VMW_FENCE_UNREF
  591. *
  592. * Unreferences a fence object, and causes it to be destroyed if there are no
  593. * other references to it.
  594. *
  595. */
  596. /**
  597. * struct drm_vmw_fence_arg
  598. *
  599. * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
  600. *
  601. * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
  602. */
  603. struct drm_vmw_fence_arg {
  604. __u32 handle;
  605. __u32 pad64;
  606. };
  607. /*************************************************************************/
  608. /**
  609. * DRM_VMW_FENCE_EVENT
  610. *
  611. * Queues an event on a fence to be delivered on the drm character device
  612. * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
  613. * Optionally the approximate time when the fence signaled is
  614. * given by the event.
  615. */
  616. /*
  617. * The event type
  618. */
  619. #define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
  620. struct drm_vmw_event_fence {
  621. struct drm_event base;
  622. __u64 user_data;
  623. __u32 tv_sec;
  624. __u32 tv_usec;
  625. };
  626. /*
  627. * Flags that may be given to the command.
  628. */
  629. /* Request fence signaled time on the event. */
  630. #define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
  631. /**
  632. * struct drm_vmw_fence_event_arg
  633. *
  634. * @fence_rep: Pointer to fence_rep structure cast to __u64 or 0 if
  635. * the fence is not supposed to be referenced by user-space.
  636. * @user_info: Info to be delivered with the event.
  637. * @handle: Attach the event to this fence only.
  638. * @flags: A set of flags as defined above.
  639. */
  640. struct drm_vmw_fence_event_arg {
  641. __u64 fence_rep;
  642. __u64 user_data;
  643. __u32 handle;
  644. __u32 flags;
  645. };
  646. /*************************************************************************/
  647. /**
  648. * DRM_VMW_PRESENT
  649. *
  650. * Executes an SVGA present on a given fb for a given surface. The surface
  651. * is placed on the framebuffer. Cliprects are given relative to the given
  652. * point (the point disignated by dest_{x|y}).
  653. *
  654. */
  655. /**
  656. * struct drm_vmw_present_arg
  657. * @fb_id: framebuffer id to present / read back from.
  658. * @sid: Surface id to present from.
  659. * @dest_x: X placement coordinate for surface.
  660. * @dest_y: Y placement coordinate for surface.
  661. * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
  662. * @num_clips: Number of cliprects given relative to the framebuffer origin,
  663. * in the same coordinate space as the frame buffer.
  664. * @pad64: Unused 64-bit padding.
  665. *
  666. * Input argument to the DRM_VMW_PRESENT ioctl.
  667. */
  668. struct drm_vmw_present_arg {
  669. __u32 fb_id;
  670. __u32 sid;
  671. __s32 dest_x;
  672. __s32 dest_y;
  673. __u64 clips_ptr;
  674. __u32 num_clips;
  675. __u32 pad64;
  676. };
  677. /*************************************************************************/
  678. /**
  679. * DRM_VMW_PRESENT_READBACK
  680. *
  681. * Executes an SVGA present readback from a given fb to the dma buffer
  682. * currently bound as the fb. If there is no dma buffer bound to the fb,
  683. * an error will be returned.
  684. *
  685. */
  686. /**
  687. * struct drm_vmw_present_arg
  688. * @fb_id: fb_id to present / read back from.
  689. * @num_clips: Number of cliprects.
  690. * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
  691. * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an __u64.
  692. * If this member is NULL, then the ioctl should not return a fence.
  693. */
  694. struct drm_vmw_present_readback_arg {
  695. __u32 fb_id;
  696. __u32 num_clips;
  697. __u64 clips_ptr;
  698. __u64 fence_rep;
  699. };
  700. /*************************************************************************/
  701. /**
  702. * DRM_VMW_UPDATE_LAYOUT - Update layout
  703. *
  704. * Updates the preferred modes and connection status for connectors. The
  705. * command consists of one drm_vmw_update_layout_arg pointing to an array
  706. * of num_outputs drm_vmw_rect's.
  707. */
  708. /**
  709. * struct drm_vmw_update_layout_arg
  710. *
  711. * @num_outputs: number of active connectors
  712. * @rects: pointer to array of drm_vmw_rect cast to an __u64
  713. *
  714. * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
  715. */
  716. struct drm_vmw_update_layout_arg {
  717. __u32 num_outputs;
  718. __u32 pad64;
  719. __u64 rects;
  720. };
  721. /*************************************************************************/
  722. /**
  723. * DRM_VMW_CREATE_SHADER - Create shader
  724. *
  725. * Creates a shader and optionally binds it to a dma buffer containing
  726. * the shader byte-code.
  727. */
  728. /**
  729. * enum drm_vmw_shader_type - Shader types
  730. */
  731. enum drm_vmw_shader_type {
  732. drm_vmw_shader_type_vs = 0,
  733. drm_vmw_shader_type_ps,
  734. };
  735. /**
  736. * struct drm_vmw_shader_create_arg
  737. *
  738. * @shader_type: Shader type of the shader to create.
  739. * @size: Size of the byte-code in bytes.
  740. * where the shader byte-code starts
  741. * @buffer_handle: Buffer handle identifying the buffer containing the
  742. * shader byte-code
  743. * @shader_handle: On successful completion contains a handle that
  744. * can be used to subsequently identify the shader.
  745. * @offset: Offset in bytes into the buffer given by @buffer_handle,
  746. *
  747. * Input / Output argument to the DRM_VMW_CREATE_SHADER Ioctl.
  748. */
  749. struct drm_vmw_shader_create_arg {
  750. enum drm_vmw_shader_type shader_type;
  751. __u32 size;
  752. __u32 buffer_handle;
  753. __u32 shader_handle;
  754. __u64 offset;
  755. };
  756. /*************************************************************************/
  757. /**
  758. * DRM_VMW_UNREF_SHADER - Unreferences a shader
  759. *
  760. * Destroys a user-space reference to a shader, optionally destroying
  761. * it.
  762. */
  763. /**
  764. * struct drm_vmw_shader_arg
  765. *
  766. * @handle: Handle identifying the shader to destroy.
  767. *
  768. * Input argument to the DRM_VMW_UNREF_SHADER ioctl.
  769. */
  770. struct drm_vmw_shader_arg {
  771. __u32 handle;
  772. __u32 pad64;
  773. };
  774. /*************************************************************************/
  775. /**
  776. * DRM_VMW_GB_SURFACE_CREATE - Create a host guest-backed surface.
  777. *
  778. * Allocates a surface handle and queues a create surface command
  779. * for the host on the first use of the surface. The surface ID can
  780. * be used as the surface ID in commands referencing the surface.
  781. */
  782. /**
  783. * enum drm_vmw_surface_flags
  784. *
  785. * @drm_vmw_surface_flag_shareable: Whether the surface is shareable
  786. * @drm_vmw_surface_flag_scanout: Whether the surface is a scanout
  787. * surface.
  788. * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is
  789. * given.
  790. */
  791. enum drm_vmw_surface_flags {
  792. drm_vmw_surface_flag_shareable = (1 << 0),
  793. drm_vmw_surface_flag_scanout = (1 << 1),
  794. drm_vmw_surface_flag_create_buffer = (1 << 2)
  795. };
  796. /**
  797. * struct drm_vmw_gb_surface_create_req
  798. *
  799. * @svga3d_flags: SVGA3d surface flags for the device.
  800. * @format: SVGA3d format.
  801. * @mip_level: Number of mip levels for all faces.
  802. * @drm_surface_flags Flags as described above.
  803. * @multisample_count Future use. Set to 0.
  804. * @autogen_filter Future use. Set to 0.
  805. * @buffer_handle Buffer handle of backup buffer. SVGA3D_INVALID_ID
  806. * if none.
  807. * @base_size Size of the base mip level for all faces.
  808. * @array_size Must be zero for non-DX hardware, and if non-zero
  809. * svga3d_flags must have proper bind flags setup.
  810. *
  811. * Input argument to the DRM_VMW_GB_SURFACE_CREATE Ioctl.
  812. * Part of output argument for the DRM_VMW_GB_SURFACE_REF Ioctl.
  813. */
  814. struct drm_vmw_gb_surface_create_req {
  815. __u32 svga3d_flags;
  816. __u32 format;
  817. __u32 mip_levels;
  818. enum drm_vmw_surface_flags drm_surface_flags;
  819. __u32 multisample_count;
  820. __u32 autogen_filter;
  821. __u32 buffer_handle;
  822. __u32 array_size;
  823. struct drm_vmw_size base_size;
  824. };
  825. /**
  826. * struct drm_vmw_gb_surface_create_rep
  827. *
  828. * @handle: Surface handle.
  829. * @backup_size: Size of backup buffers for this surface.
  830. * @buffer_handle: Handle of backup buffer. SVGA3D_INVALID_ID if none.
  831. * @buffer_size: Actual size of the buffer identified by
  832. * @buffer_handle
  833. * @buffer_map_handle: Offset into device address space for the buffer
  834. * identified by @buffer_handle.
  835. *
  836. * Part of output argument for the DRM_VMW_GB_SURFACE_REF ioctl.
  837. * Output argument for the DRM_VMW_GB_SURFACE_CREATE ioctl.
  838. */
  839. struct drm_vmw_gb_surface_create_rep {
  840. __u32 handle;
  841. __u32 backup_size;
  842. __u32 buffer_handle;
  843. __u32 buffer_size;
  844. __u64 buffer_map_handle;
  845. };
  846. /**
  847. * union drm_vmw_gb_surface_create_arg
  848. *
  849. * @req: Input argument as described above.
  850. * @rep: Output argument as described above.
  851. *
  852. * Argument to the DRM_VMW_GB_SURFACE_CREATE ioctl.
  853. */
  854. union drm_vmw_gb_surface_create_arg {
  855. struct drm_vmw_gb_surface_create_rep rep;
  856. struct drm_vmw_gb_surface_create_req req;
  857. };
  858. /*************************************************************************/
  859. /**
  860. * DRM_VMW_GB_SURFACE_REF - Reference a host surface.
  861. *
  862. * Puts a reference on a host surface with a given handle, as previously
  863. * returned by the DRM_VMW_GB_SURFACE_CREATE ioctl.
  864. * A reference will make sure the surface isn't destroyed while we hold
  865. * it and will allow the calling client to use the surface handle in
  866. * the command stream.
  867. *
  868. * On successful return, the Ioctl returns the surface information given
  869. * to and returned from the DRM_VMW_GB_SURFACE_CREATE ioctl.
  870. */
  871. /**
  872. * struct drm_vmw_gb_surface_reference_arg
  873. *
  874. * @creq: The data used as input when the surface was created, as described
  875. * above at "struct drm_vmw_gb_surface_create_req"
  876. * @crep: Additional data output when the surface was created, as described
  877. * above at "struct drm_vmw_gb_surface_create_rep"
  878. *
  879. * Output Argument to the DRM_VMW_GB_SURFACE_REF ioctl.
  880. */
  881. struct drm_vmw_gb_surface_ref_rep {
  882. struct drm_vmw_gb_surface_create_req creq;
  883. struct drm_vmw_gb_surface_create_rep crep;
  884. };
  885. /**
  886. * union drm_vmw_gb_surface_reference_arg
  887. *
  888. * @req: Input data as described above at "struct drm_vmw_surface_arg"
  889. * @rep: Output data as described above at "struct drm_vmw_gb_surface_ref_rep"
  890. *
  891. * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
  892. */
  893. union drm_vmw_gb_surface_reference_arg {
  894. struct drm_vmw_gb_surface_ref_rep rep;
  895. struct drm_vmw_surface_arg req;
  896. };
  897. /*************************************************************************/
  898. /**
  899. * DRM_VMW_SYNCCPU - Sync a DMA buffer / MOB for CPU access.
  900. *
  901. * Idles any previously submitted GPU operations on the buffer and
  902. * by default blocks command submissions that reference the buffer.
  903. * If the file descriptor used to grab a blocking CPU sync is closed, the
  904. * cpu sync is released.
  905. * The flags argument indicates how the grab / release operation should be
  906. * performed:
  907. */
  908. /**
  909. * enum drm_vmw_synccpu_flags - Synccpu flags:
  910. *
  911. * @drm_vmw_synccpu_read: Sync for read. If sync is done for read only, it's a
  912. * hint to the kernel to allow command submissions that references the buffer
  913. * for read-only.
  914. * @drm_vmw_synccpu_write: Sync for write. Block all command submissions
  915. * referencing this buffer.
  916. * @drm_vmw_synccpu_dontblock: Dont wait for GPU idle, but rather return
  917. * -EBUSY should the buffer be busy.
  918. * @drm_vmw_synccpu_allow_cs: Allow command submission that touches the buffer
  919. * while the buffer is synced for CPU. This is similar to the GEM bo idle
  920. * behavior.
  921. */
  922. enum drm_vmw_synccpu_flags {
  923. drm_vmw_synccpu_read = (1 << 0),
  924. drm_vmw_synccpu_write = (1 << 1),
  925. drm_vmw_synccpu_dontblock = (1 << 2),
  926. drm_vmw_synccpu_allow_cs = (1 << 3)
  927. };
  928. /**
  929. * enum drm_vmw_synccpu_op - Synccpu operations:
  930. *
  931. * @drm_vmw_synccpu_grab: Grab the buffer for CPU operations
  932. * @drm_vmw_synccpu_release: Release a previous grab.
  933. */
  934. enum drm_vmw_synccpu_op {
  935. drm_vmw_synccpu_grab,
  936. drm_vmw_synccpu_release
  937. };
  938. /**
  939. * struct drm_vmw_synccpu_arg
  940. *
  941. * @op: The synccpu operation as described above.
  942. * @handle: Handle identifying the buffer object.
  943. * @flags: Flags as described above.
  944. */
  945. struct drm_vmw_synccpu_arg {
  946. enum drm_vmw_synccpu_op op;
  947. enum drm_vmw_synccpu_flags flags;
  948. __u32 handle;
  949. __u32 pad64;
  950. };
  951. /*************************************************************************/
  952. /**
  953. * DRM_VMW_CREATE_EXTENDED_CONTEXT - Create a host context.
  954. *
  955. * Allocates a device unique context id, and queues a create context command
  956. * for the host. Does not wait for host completion.
  957. */
  958. enum drm_vmw_extended_context {
  959. drm_vmw_context_legacy,
  960. drm_vmw_context_dx
  961. };
  962. /**
  963. * union drm_vmw_extended_context_arg
  964. *
  965. * @req: Context type.
  966. * @rep: Context identifier.
  967. *
  968. * Argument to the DRM_VMW_CREATE_EXTENDED_CONTEXT Ioctl.
  969. */
  970. union drm_vmw_extended_context_arg {
  971. enum drm_vmw_extended_context req;
  972. struct drm_vmw_context_arg rep;
  973. };
  974. /*************************************************************************/
  975. /*
  976. * DRM_VMW_HANDLE_CLOSE - Close a user-space handle and release its
  977. * underlying resource.
  978. *
  979. * Note that this ioctl is overlaid on the deprecated DRM_VMW_UNREF_DMABUF
  980. * Ioctl.
  981. */
  982. /**
  983. * struct drm_vmw_handle_close_arg
  984. *
  985. * @handle: Handle to close.
  986. *
  987. * Argument to the DRM_VMW_HANDLE_CLOSE Ioctl.
  988. */
  989. struct drm_vmw_handle_close_arg {
  990. __u32 handle;
  991. __u32 pad64;
  992. };
  993. #define drm_vmw_unref_dmabuf_arg drm_vmw_handle_close_arg
  994. #if defined(__cplusplus)
  995. }
  996. #endif
  997. #endif