vmwgfx_drm.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092
  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. #ifndef __KERNEL__
  30. #include <drm/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. #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
  63. /*************************************************************************/
  64. /**
  65. * DRM_VMW_GET_PARAM - get device information.
  66. *
  67. * DRM_VMW_PARAM_FIFO_OFFSET:
  68. * Offset to use to map the first page of the FIFO read-only.
  69. * The fifo is mapped using the mmap() system call on the drm device.
  70. *
  71. * DRM_VMW_PARAM_OVERLAY_IOCTL:
  72. * Does the driver support the overlay ioctl.
  73. */
  74. #define DRM_VMW_PARAM_NUM_STREAMS 0
  75. #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
  76. #define DRM_VMW_PARAM_3D 2
  77. #define DRM_VMW_PARAM_HW_CAPS 3
  78. #define DRM_VMW_PARAM_FIFO_CAPS 4
  79. #define DRM_VMW_PARAM_MAX_FB_SIZE 5
  80. #define DRM_VMW_PARAM_FIFO_HW_VERSION 6
  81. #define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
  82. #define DRM_VMW_PARAM_3D_CAPS_SIZE 8
  83. #define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
  84. #define DRM_VMW_PARAM_MAX_MOB_SIZE 10
  85. #define DRM_VMW_PARAM_SCREEN_TARGET 11
  86. #define DRM_VMW_PARAM_DX 12
  87. /**
  88. * enum drm_vmw_handle_type - handle type for ref ioctls
  89. *
  90. */
  91. enum drm_vmw_handle_type {
  92. DRM_VMW_HANDLE_LEGACY = 0,
  93. DRM_VMW_HANDLE_PRIME = 1
  94. };
  95. /**
  96. * struct drm_vmw_getparam_arg
  97. *
  98. * @value: Returned value. //Out
  99. * @param: Parameter to query. //In.
  100. *
  101. * Argument to the DRM_VMW_GET_PARAM Ioctl.
  102. */
  103. struct drm_vmw_getparam_arg {
  104. uint64_t value;
  105. uint32_t param;
  106. uint32_t pad64;
  107. };
  108. /*************************************************************************/
  109. /**
  110. * DRM_VMW_CREATE_CONTEXT - Create a host context.
  111. *
  112. * Allocates a device unique context id, and queues a create context command
  113. * for the host. Does not wait for host completion.
  114. */
  115. /**
  116. * struct drm_vmw_context_arg
  117. *
  118. * @cid: Device unique context ID.
  119. *
  120. * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
  121. * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
  122. */
  123. struct drm_vmw_context_arg {
  124. int32_t cid;
  125. uint32_t pad64;
  126. };
  127. /*************************************************************************/
  128. /**
  129. * DRM_VMW_UNREF_CONTEXT - Create a host context.
  130. *
  131. * Frees a global context id, and queues a destroy host command for the host.
  132. * Does not wait for host completion. The context ID can be used directly
  133. * in the command stream and shows up as the same context ID on the host.
  134. */
  135. /*************************************************************************/
  136. /**
  137. * DRM_VMW_CREATE_SURFACE - Create a host suface.
  138. *
  139. * Allocates a device unique surface id, and queues a create surface command
  140. * for the host. Does not wait for host completion. The surface ID can be
  141. * used directly in the command stream and shows up as the same surface
  142. * ID on the host.
  143. */
  144. /**
  145. * struct drm_wmv_surface_create_req
  146. *
  147. * @flags: Surface flags as understood by the host.
  148. * @format: Surface format as understood by the host.
  149. * @mip_levels: Number of mip levels for each face.
  150. * An unused face should have 0 encoded.
  151. * @size_addr: Address of a user-space array of sruct drm_vmw_size
  152. * cast to an uint64_t for 32-64 bit compatibility.
  153. * The size of the array should equal the total number of mipmap levels.
  154. * @shareable: Boolean whether other clients (as identified by file descriptors)
  155. * may reference this surface.
  156. * @scanout: Boolean whether the surface is intended to be used as a
  157. * scanout.
  158. *
  159. * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
  160. * Output data from the DRM_VMW_REF_SURFACE Ioctl.
  161. */
  162. struct drm_vmw_surface_create_req {
  163. uint32_t flags;
  164. uint32_t format;
  165. uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
  166. uint64_t size_addr;
  167. int32_t shareable;
  168. int32_t scanout;
  169. };
  170. /**
  171. * struct drm_wmv_surface_arg
  172. *
  173. * @sid: Surface id of created surface or surface to destroy or reference.
  174. * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
  175. *
  176. * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
  177. * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
  178. * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
  179. */
  180. struct drm_vmw_surface_arg {
  181. int32_t sid;
  182. enum drm_vmw_handle_type handle_type;
  183. };
  184. /**
  185. * struct drm_vmw_size ioctl.
  186. *
  187. * @width - mip level width
  188. * @height - mip level height
  189. * @depth - mip level depth
  190. *
  191. * Description of a mip level.
  192. * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
  193. */
  194. struct drm_vmw_size {
  195. uint32_t width;
  196. uint32_t height;
  197. uint32_t depth;
  198. uint32_t pad64;
  199. };
  200. /**
  201. * union drm_vmw_surface_create_arg
  202. *
  203. * @rep: Output data as described above.
  204. * @req: Input data as described above.
  205. *
  206. * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
  207. */
  208. union drm_vmw_surface_create_arg {
  209. struct drm_vmw_surface_arg rep;
  210. struct drm_vmw_surface_create_req req;
  211. };
  212. /*************************************************************************/
  213. /**
  214. * DRM_VMW_REF_SURFACE - Reference a host surface.
  215. *
  216. * Puts a reference on a host surface with a give sid, as previously
  217. * returned by the DRM_VMW_CREATE_SURFACE ioctl.
  218. * A reference will make sure the surface isn't destroyed while we hold
  219. * it and will allow the calling client to use the surface ID in the command
  220. * stream.
  221. *
  222. * On successful return, the Ioctl returns the surface information given
  223. * in the DRM_VMW_CREATE_SURFACE ioctl.
  224. */
  225. /**
  226. * union drm_vmw_surface_reference_arg
  227. *
  228. * @rep: Output data as described above.
  229. * @req: Input data as described above.
  230. *
  231. * Argument to the DRM_VMW_REF_SURFACE Ioctl.
  232. */
  233. union drm_vmw_surface_reference_arg {
  234. struct drm_vmw_surface_create_req rep;
  235. struct drm_vmw_surface_arg req;
  236. };
  237. /*************************************************************************/
  238. /**
  239. * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
  240. *
  241. * Clear a reference previously put on a host surface.
  242. * When all references are gone, including the one implicitly placed
  243. * on creation,
  244. * a destroy surface command will be queued for the host.
  245. * Does not wait for completion.
  246. */
  247. /*************************************************************************/
  248. /**
  249. * DRM_VMW_EXECBUF
  250. *
  251. * Submit a command buffer for execution on the host, and return a
  252. * fence seqno that when signaled, indicates that the command buffer has
  253. * executed.
  254. */
  255. /**
  256. * struct drm_vmw_execbuf_arg
  257. *
  258. * @commands: User-space address of a command buffer cast to an uint64_t.
  259. * @command-size: Size in bytes of the command buffer.
  260. * @throttle-us: Sleep until software is less than @throttle_us
  261. * microseconds ahead of hardware. The driver may round this value
  262. * to the nearest kernel tick.
  263. * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
  264. * uint64_t.
  265. * @version: Allows expanding the execbuf ioctl parameters without breaking
  266. * backwards compatibility, since user-space will always tell the kernel
  267. * which version it uses.
  268. * @flags: Execbuf flags. None currently.
  269. *
  270. * Argument to the DRM_VMW_EXECBUF Ioctl.
  271. */
  272. #define DRM_VMW_EXECBUF_VERSION 2
  273. struct drm_vmw_execbuf_arg {
  274. uint64_t commands;
  275. uint32_t command_size;
  276. uint32_t throttle_us;
  277. uint64_t fence_rep;
  278. uint32_t version;
  279. uint32_t flags;
  280. uint32_t context_handle;
  281. uint32_t pad64;
  282. };
  283. /**
  284. * struct drm_vmw_fence_rep
  285. *
  286. * @handle: Fence object handle for fence associated with a command submission.
  287. * @mask: Fence flags relevant for this fence object.
  288. * @seqno: Fence sequence number in fifo. A fence object with a lower
  289. * seqno will signal the EXEC flag before a fence object with a higher
  290. * seqno. This can be used by user-space to avoid kernel calls to determine
  291. * whether a fence has signaled the EXEC flag. Note that @seqno will
  292. * wrap at 32-bit.
  293. * @passed_seqno: The highest seqno number processed by the hardware
  294. * so far. This can be used to mark user-space fence objects as signaled, and
  295. * to determine whether a fence seqno might be stale.
  296. * @error: This member should've been set to -EFAULT on submission.
  297. * The following actions should be take on completion:
  298. * error == -EFAULT: Fence communication failed. The host is synchronized.
  299. * Use the last fence id read from the FIFO fence register.
  300. * error != 0 && error != -EFAULT:
  301. * Fence submission failed. The host is synchronized. Use the fence_seq member.
  302. * error == 0: All is OK, The host may not be synchronized.
  303. * Use the fence_seq member.
  304. *
  305. * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
  306. */
  307. struct drm_vmw_fence_rep {
  308. uint32_t handle;
  309. uint32_t mask;
  310. uint32_t seqno;
  311. uint32_t passed_seqno;
  312. uint32_t pad64;
  313. int32_t error;
  314. };
  315. /*************************************************************************/
  316. /**
  317. * DRM_VMW_ALLOC_DMABUF
  318. *
  319. * Allocate a DMA buffer that is visible also to the host.
  320. * NOTE: The buffer is
  321. * identified by a handle and an offset, which are private to the guest, but
  322. * useable in the command stream. The guest kernel may translate these
  323. * and patch up the command stream accordingly. In the future, the offset may
  324. * be zero at all times, or it may disappear from the interface before it is
  325. * fixed.
  326. *
  327. * The DMA buffer may stay user-space mapped in the guest at all times,
  328. * and is thus suitable for sub-allocation.
  329. *
  330. * DMA buffers are mapped using the mmap() syscall on the drm device.
  331. */
  332. /**
  333. * struct drm_vmw_alloc_dmabuf_req
  334. *
  335. * @size: Required minimum size of the buffer.
  336. *
  337. * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
  338. */
  339. struct drm_vmw_alloc_dmabuf_req {
  340. uint32_t size;
  341. uint32_t pad64;
  342. };
  343. /**
  344. * struct drm_vmw_dmabuf_rep
  345. *
  346. * @map_handle: Offset to use in the mmap() call used to map the buffer.
  347. * @handle: Handle unique to this buffer. Used for unreferencing.
  348. * @cur_gmr_id: GMR id to use in the command stream when this buffer is
  349. * referenced. See not above.
  350. * @cur_gmr_offset: Offset to use in the command stream when this buffer is
  351. * referenced. See note above.
  352. *
  353. * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
  354. */
  355. struct drm_vmw_dmabuf_rep {
  356. uint64_t map_handle;
  357. uint32_t handle;
  358. uint32_t cur_gmr_id;
  359. uint32_t cur_gmr_offset;
  360. uint32_t pad64;
  361. };
  362. /**
  363. * union drm_vmw_dmabuf_arg
  364. *
  365. * @req: Input data as described above.
  366. * @rep: Output data as described above.
  367. *
  368. * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
  369. */
  370. union drm_vmw_alloc_dmabuf_arg {
  371. struct drm_vmw_alloc_dmabuf_req req;
  372. struct drm_vmw_dmabuf_rep rep;
  373. };
  374. /*************************************************************************/
  375. /**
  376. * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
  377. *
  378. */
  379. /**
  380. * struct drm_vmw_unref_dmabuf_arg
  381. *
  382. * @handle: Handle indicating what buffer to free. Obtained from the
  383. * DRM_VMW_ALLOC_DMABUF Ioctl.
  384. *
  385. * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
  386. */
  387. struct drm_vmw_unref_dmabuf_arg {
  388. uint32_t handle;
  389. uint32_t pad64;
  390. };
  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. int32_t x;
  410. int32_t y;
  411. uint32_t w;
  412. uint32_t 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. uint32_t stream_id;
  433. uint32_t enabled;
  434. uint32_t flags;
  435. uint32_t color_key;
  436. uint32_t handle;
  437. uint32_t offset;
  438. int32_t format;
  439. uint32_t size;
  440. uint32_t width;
  441. uint32_t height;
  442. uint32_t pitch[3];
  443. uint32_t 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. uint32_t flags;
  468. uint32_t crtc_id;
  469. int32_t xpos;
  470. int32_t ypos;
  471. int32_t xhot;
  472. int32_t 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. uint32_t stream_id;
  488. uint32_t 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 uint64_t
  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. uint64_t buffer;
  515. uint32_t max_size;
  516. uint32_t 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. uint32_t handle;
  561. int32_t cookie_valid;
  562. uint64_t kernel_cookie;
  563. uint64_t timeout_us;
  564. int32_t lazy;
  565. int32_t flags;
  566. int32_t wait_options;
  567. int32_t 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. uint32_t handle;
  589. uint32_t flags;
  590. int32_t signaled;
  591. uint32_t passed_seqno;
  592. uint32_t signaled_flags;
  593. uint32_t 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. uint32_t handle;
  612. uint32_t 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. uint64_t user_data;
  630. uint32_t tv_sec;
  631. uint32_t 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 uint64_t 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. uint64_t fence_rep;
  649. uint64_t user_data;
  650. uint32_t handle;
  651. uint32_t 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 uint64_t.
  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. uint32_t fb_id;
  677. uint32_t sid;
  678. int32_t dest_x;
  679. int32_t dest_y;
  680. uint64_t clips_ptr;
  681. uint32_t num_clips;
  682. uint32_t 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 uint64_t.
  698. * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an uint64_t.
  699. * If this member is NULL, then the ioctl should not return a fence.
  700. */
  701. struct drm_vmw_present_readback_arg {
  702. uint32_t fb_id;
  703. uint32_t num_clips;
  704. uint64_t clips_ptr;
  705. uint64_t 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 uint64_t
  720. *
  721. * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
  722. */
  723. struct drm_vmw_update_layout_arg {
  724. uint32_t num_outputs;
  725. uint32_t pad64;
  726. uint64_t 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. uint32_t size;
  759. uint32_t buffer_handle;
  760. uint32_t shader_handle;
  761. uint64_t 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. uint32_t handle;
  779. uint32_t 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. uint32_t svga3d_flags;
  823. uint32_t format;
  824. uint32_t mip_levels;
  825. enum drm_vmw_surface_flags drm_surface_flags;
  826. uint32_t multisample_count;
  827. uint32_t autogen_filter;
  828. uint32_t buffer_handle;
  829. uint32_t 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. uint32_t handle;
  848. uint32_t backup_size;
  849. uint32_t buffer_handle;
  850. uint32_t buffer_size;
  851. uint64_t 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. uint32_t handle;
  956. uint32_t 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. #endif