vmwgfx_drm.h 31 KB

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