vmwgfx_drm.h 30 KB

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