vmwgfx_drm.h 31 KB

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