vmwgfx_drm.h 31 KB

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