vmwgfx_drm.h 35 KB

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