vmwgfx_drm.h 31 KB

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