vmwgfx_drm.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. /**************************************************************************
  2. *
  3. * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
  4. * All Rights Reserved.
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a
  7. * copy of this software and associated documentation files (the
  8. * "Software"), to deal in the Software without restriction, including
  9. * without limitation the rights to use, copy, modify, merge, publish,
  10. * distribute, sub license, and/or sell copies of the Software, and to
  11. * permit persons to whom the Software is furnished to do so, subject to
  12. * the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the
  15. * next paragraph) shall be included in all copies or substantial portions
  16. * of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. *
  26. **************************************************************************/
  27. #ifndef __VMWGFX_DRM_H__
  28. #define __VMWGFX_DRM_H__
  29. #define DRM_VMW_MAX_SURFACE_FACES 6
  30. #define DRM_VMW_MAX_MIP_LEVELS 24
  31. #define DRM_VMW_EXT_NAME_LEN 128
  32. #define DRM_VMW_GET_PARAM 0
  33. #define DRM_VMW_ALLOC_DMABUF 1
  34. #define DRM_VMW_UNREF_DMABUF 2
  35. #define DRM_VMW_CURSOR_BYPASS 3
  36. /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
  37. #define DRM_VMW_CONTROL_STREAM 4
  38. #define DRM_VMW_CLAIM_STREAM 5
  39. #define DRM_VMW_UNREF_STREAM 6
  40. /* guarded by DRM_VMW_PARAM_3D == 1 */
  41. #define DRM_VMW_CREATE_CONTEXT 7
  42. #define DRM_VMW_UNREF_CONTEXT 8
  43. #define DRM_VMW_CREATE_SURFACE 9
  44. #define DRM_VMW_UNREF_SURFACE 10
  45. #define DRM_VMW_REF_SURFACE 11
  46. #define DRM_VMW_EXECBUF 12
  47. #define DRM_VMW_FIFO_DEBUG 13
  48. #define DRM_VMW_FENCE_WAIT 14
  49. /*************************************************************************/
  50. /**
  51. * DRM_VMW_GET_PARAM - get device information.
  52. *
  53. * DRM_VMW_PARAM_FIFO_OFFSET:
  54. * Offset to use to map the first page of the FIFO read-only.
  55. * The fifo is mapped using the mmap() system call on the drm device.
  56. *
  57. * DRM_VMW_PARAM_OVERLAY_IOCTL:
  58. * Does the driver support the overlay ioctl.
  59. */
  60. #define DRM_VMW_PARAM_NUM_STREAMS 0
  61. #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
  62. #define DRM_VMW_PARAM_3D 2
  63. #define DRM_VMW_PARAM_FIFO_OFFSET 3
  64. /**
  65. * struct drm_vmw_getparam_arg
  66. *
  67. * @value: Returned value. //Out
  68. * @param: Parameter to query. //In.
  69. *
  70. * Argument to the DRM_VMW_GET_PARAM Ioctl.
  71. */
  72. struct drm_vmw_getparam_arg {
  73. uint64_t value;
  74. uint32_t param;
  75. uint32_t pad64;
  76. };
  77. /*************************************************************************/
  78. /**
  79. * DRM_VMW_EXTENSION - Query device extensions.
  80. */
  81. /**
  82. * struct drm_vmw_extension_rep
  83. *
  84. * @exists: The queried extension exists.
  85. * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension.
  86. * @driver_sarea_offset: Offset to any space in the DRI SAREA
  87. * used by the extension.
  88. * @major: Major version number of the extension.
  89. * @minor: Minor version number of the extension.
  90. * @pl: Patch level version number of the extension.
  91. *
  92. * Output argument to the DRM_VMW_EXTENSION Ioctl.
  93. */
  94. struct drm_vmw_extension_rep {
  95. int32_t exists;
  96. uint32_t driver_ioctl_offset;
  97. uint32_t driver_sarea_offset;
  98. uint32_t major;
  99. uint32_t minor;
  100. uint32_t pl;
  101. uint32_t pad64;
  102. };
  103. /**
  104. * union drm_vmw_extension_arg
  105. *
  106. * @extension - Ascii name of the extension to be queried. //In
  107. * @rep - Reply as defined above. //Out
  108. *
  109. * Argument to the DRM_VMW_EXTENSION Ioctl.
  110. */
  111. union drm_vmw_extension_arg {
  112. char extension[DRM_VMW_EXT_NAME_LEN];
  113. struct drm_vmw_extension_rep rep;
  114. };
  115. /*************************************************************************/
  116. /**
  117. * DRM_VMW_CREATE_CONTEXT - Create a host context.
  118. *
  119. * Allocates a device unique context id, and queues a create context command
  120. * for the host. Does not wait for host completion.
  121. */
  122. /**
  123. * struct drm_vmw_context_arg
  124. *
  125. * @cid: Device unique context ID.
  126. *
  127. * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
  128. * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
  129. */
  130. struct drm_vmw_context_arg {
  131. int32_t cid;
  132. uint32_t pad64;
  133. };
  134. /*************************************************************************/
  135. /**
  136. * DRM_VMW_UNREF_CONTEXT - Create a host context.
  137. *
  138. * Frees a global context id, and queues a destroy host command for the host.
  139. * Does not wait for host completion. The context ID can be used directly
  140. * in the command stream and shows up as the same context ID on the host.
  141. */
  142. /*************************************************************************/
  143. /**
  144. * DRM_VMW_CREATE_SURFACE - Create a host suface.
  145. *
  146. * Allocates a device unique surface id, and queues a create surface command
  147. * for the host. Does not wait for host completion. The surface ID can be
  148. * used directly in the command stream and shows up as the same surface
  149. * ID on the host.
  150. */
  151. /**
  152. * struct drm_wmv_surface_create_req
  153. *
  154. * @flags: Surface flags as understood by the host.
  155. * @format: Surface format as understood by the host.
  156. * @mip_levels: Number of mip levels for each face.
  157. * An unused face should have 0 encoded.
  158. * @size_addr: Address of a user-space array of sruct drm_vmw_size
  159. * cast to an uint64_t for 32-64 bit compatibility.
  160. * The size of the array should equal the total number of mipmap levels.
  161. * @shareable: Boolean whether other clients (as identified by file descriptors)
  162. * may reference this surface.
  163. *
  164. * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
  165. * Output data from the DRM_VMW_REF_SURFACE Ioctl.
  166. */
  167. struct drm_vmw_surface_create_req {
  168. uint32_t flags;
  169. uint32_t format;
  170. uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
  171. uint64_t size_addr;
  172. int32_t shareable;
  173. uint32_t pad64;
  174. };
  175. /**
  176. * struct drm_wmv_surface_arg
  177. *
  178. * @sid: Surface id of created surface or surface to destroy or reference.
  179. *
  180. * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
  181. * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
  182. * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
  183. */
  184. struct drm_vmw_surface_arg {
  185. int32_t sid;
  186. uint32_t pad64;
  187. };
  188. /**
  189. * struct drm_vmw_size ioctl.
  190. *
  191. * @width - mip level width
  192. * @height - mip level height
  193. * @depth - mip level depth
  194. *
  195. * Description of a mip level.
  196. * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
  197. */
  198. struct drm_vmw_size {
  199. uint32_t width;
  200. uint32_t height;
  201. uint32_t depth;
  202. uint32_t pad64;
  203. };
  204. /**
  205. * union drm_vmw_surface_create_arg
  206. *
  207. * @rep: Output data as described above.
  208. * @req: Input data as described above.
  209. *
  210. * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
  211. */
  212. union drm_vmw_surface_create_arg {
  213. struct drm_vmw_surface_arg rep;
  214. struct drm_vmw_surface_create_req req;
  215. };
  216. /*************************************************************************/
  217. /**
  218. * DRM_VMW_REF_SURFACE - Reference a host surface.
  219. *
  220. * Puts a reference on a host surface with a give sid, as previously
  221. * returned by the DRM_VMW_CREATE_SURFACE ioctl.
  222. * A reference will make sure the surface isn't destroyed while we hold
  223. * it and will allow the calling client to use the surface ID in the command
  224. * stream.
  225. *
  226. * On successful return, the Ioctl returns the surface information given
  227. * in the DRM_VMW_CREATE_SURFACE ioctl.
  228. */
  229. /**
  230. * union drm_vmw_surface_reference_arg
  231. *
  232. * @rep: Output data as described above.
  233. * @req: Input data as described above.
  234. *
  235. * Argument to the DRM_VMW_REF_SURFACE Ioctl.
  236. */
  237. union drm_vmw_surface_reference_arg {
  238. struct drm_vmw_surface_create_req rep;
  239. struct drm_vmw_surface_arg req;
  240. };
  241. /*************************************************************************/
  242. /**
  243. * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
  244. *
  245. * Clear a reference previously put on a host surface.
  246. * When all references are gone, including the one implicitly placed
  247. * on creation,
  248. * a destroy surface command will be queued for the host.
  249. * Does not wait for completion.
  250. */
  251. /*************************************************************************/
  252. /**
  253. * DRM_VMW_EXECBUF
  254. *
  255. * Submit a command buffer for execution on the host, and return a
  256. * fence sequence that when signaled, indicates that the command buffer has
  257. * executed.
  258. */
  259. /**
  260. * struct drm_vmw_execbuf_arg
  261. *
  262. * @commands: User-space address of a command buffer cast to an uint64_t.
  263. * @command-size: Size in bytes of the command buffer.
  264. * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
  265. * uint64_t.
  266. *
  267. * Argument to the DRM_VMW_EXECBUF Ioctl.
  268. */
  269. struct drm_vmw_execbuf_arg {
  270. uint64_t commands;
  271. uint32_t command_size;
  272. uint32_t pad64;
  273. uint64_t fence_rep;
  274. };
  275. /**
  276. * struct drm_vmw_fence_rep
  277. *
  278. * @fence_seq: Fence sequence associated with a command submission.
  279. * @error: This member should've been set to -EFAULT on submission.
  280. * The following actions should be take on completion:
  281. * error == -EFAULT: Fence communication failed. The host is synchronized.
  282. * Use the last fence id read from the FIFO fence register.
  283. * error != 0 && error != -EFAULT:
  284. * Fence submission failed. The host is synchronized. Use the fence_seq member.
  285. * error == 0: All is OK, The host may not be synchronized.
  286. * Use the fence_seq member.
  287. *
  288. * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
  289. */
  290. struct drm_vmw_fence_rep {
  291. uint64_t fence_seq;
  292. int32_t error;
  293. uint32_t pad64;
  294. };
  295. /*************************************************************************/
  296. /**
  297. * DRM_VMW_ALLOC_DMABUF
  298. *
  299. * Allocate a DMA buffer that is visible also to the host.
  300. * NOTE: The buffer is
  301. * identified by a handle and an offset, which are private to the guest, but
  302. * useable in the command stream. The guest kernel may translate these
  303. * and patch up the command stream accordingly. In the future, the offset may
  304. * be zero at all times, or it may disappear from the interface before it is
  305. * fixed.
  306. *
  307. * The DMA buffer may stay user-space mapped in the guest at all times,
  308. * and is thus suitable for sub-allocation.
  309. *
  310. * DMA buffers are mapped using the mmap() syscall on the drm device.
  311. */
  312. /**
  313. * struct drm_vmw_alloc_dmabuf_req
  314. *
  315. * @size: Required minimum size of the buffer.
  316. *
  317. * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
  318. */
  319. struct drm_vmw_alloc_dmabuf_req {
  320. uint32_t size;
  321. uint32_t pad64;
  322. };
  323. /**
  324. * struct drm_vmw_dmabuf_rep
  325. *
  326. * @map_handle: Offset to use in the mmap() call used to map the buffer.
  327. * @handle: Handle unique to this buffer. Used for unreferencing.
  328. * @cur_gmr_id: GMR id to use in the command stream when this buffer is
  329. * referenced. See not above.
  330. * @cur_gmr_offset: Offset to use in the command stream when this buffer is
  331. * referenced. See note above.
  332. *
  333. * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
  334. */
  335. struct drm_vmw_dmabuf_rep {
  336. uint64_t map_handle;
  337. uint32_t handle;
  338. uint32_t cur_gmr_id;
  339. uint32_t cur_gmr_offset;
  340. uint32_t pad64;
  341. };
  342. /**
  343. * union drm_vmw_dmabuf_arg
  344. *
  345. * @req: Input data as described above.
  346. * @rep: Output data as described above.
  347. *
  348. * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
  349. */
  350. union drm_vmw_alloc_dmabuf_arg {
  351. struct drm_vmw_alloc_dmabuf_req req;
  352. struct drm_vmw_dmabuf_rep rep;
  353. };
  354. /*************************************************************************/
  355. /**
  356. * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
  357. *
  358. */
  359. /**
  360. * struct drm_vmw_unref_dmabuf_arg
  361. *
  362. * @handle: Handle indicating what buffer to free. Obtained from the
  363. * DRM_VMW_ALLOC_DMABUF Ioctl.
  364. *
  365. * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
  366. */
  367. struct drm_vmw_unref_dmabuf_arg {
  368. uint32_t handle;
  369. uint32_t pad64;
  370. };
  371. /*************************************************************************/
  372. /**
  373. * DRM_VMW_FIFO_DEBUG - Get last FIFO submission.
  374. *
  375. * This IOCTL copies the last FIFO submission directly out of the FIFO buffer.
  376. */
  377. /**
  378. * struct drm_vmw_fifo_debug_arg
  379. *
  380. * @debug_buffer: User space address of a debug_buffer cast to an uint64_t //In
  381. * @debug_buffer_size: Size in bytes of debug buffer //In
  382. * @used_size: Number of bytes copied to the buffer // Out
  383. * @did_not_fit: Boolean indicating that the fifo contents did not fit. //Out
  384. *
  385. * Argument to the DRM_VMW_FIFO_DEBUG Ioctl.
  386. */
  387. struct drm_vmw_fifo_debug_arg {
  388. uint64_t debug_buffer;
  389. uint32_t debug_buffer_size;
  390. uint32_t used_size;
  391. int32_t did_not_fit;
  392. uint32_t pad64;
  393. };
  394. struct drm_vmw_fence_wait_arg {
  395. uint64_t sequence;
  396. uint64_t kernel_cookie;
  397. int32_t cookie_valid;
  398. int32_t pad64;
  399. };
  400. /*************************************************************************/
  401. /**
  402. * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
  403. *
  404. * This IOCTL controls the overlay units of the svga device.
  405. * The SVGA overlay units does not work like regular hardware units in
  406. * that they do not automaticaly read back the contents of the given dma
  407. * buffer. But instead only read back for each call to this ioctl, and
  408. * at any point between this call being made and a following call that
  409. * either changes the buffer or disables the stream.
  410. */
  411. /**
  412. * struct drm_vmw_rect
  413. *
  414. * Defines a rectangle. Used in the overlay ioctl to define
  415. * source and destination rectangle.
  416. */
  417. struct drm_vmw_rect {
  418. int32_t x;
  419. int32_t y;
  420. uint32_t w;
  421. uint32_t h;
  422. };
  423. /**
  424. * struct drm_vmw_control_stream_arg
  425. *
  426. * @stream_id: Stearm to control
  427. * @enabled: If false all following arguments are ignored.
  428. * @handle: Handle to buffer for getting data from.
  429. * @format: Format of the overlay as understood by the host.
  430. * @width: Width of the overlay.
  431. * @height: Height of the overlay.
  432. * @size: Size of the overlay in bytes.
  433. * @pitch: Array of pitches, the two last are only used for YUV12 formats.
  434. * @offset: Offset from start of dma buffer to overlay.
  435. * @src: Source rect, must be within the defined area above.
  436. * @dst: Destination rect, x and y may be negative.
  437. *
  438. * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
  439. */
  440. struct drm_vmw_control_stream_arg {
  441. uint32_t stream_id;
  442. uint32_t enabled;
  443. uint32_t flags;
  444. uint32_t color_key;
  445. uint32_t handle;
  446. uint32_t offset;
  447. int32_t format;
  448. uint32_t size;
  449. uint32_t width;
  450. uint32_t height;
  451. uint32_t pitch[3];
  452. uint32_t pad64;
  453. struct drm_vmw_rect src;
  454. struct drm_vmw_rect dst;
  455. };
  456. /*************************************************************************/
  457. /**
  458. * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
  459. *
  460. */
  461. #define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
  462. #define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
  463. /**
  464. * struct drm_vmw_cursor_bypass_arg
  465. *
  466. * @flags: Flags.
  467. * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
  468. * @xpos: X position of cursor.
  469. * @ypos: Y position of cursor.
  470. * @xhot: X hotspot.
  471. * @yhot: Y hotspot.
  472. *
  473. * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
  474. */
  475. struct drm_vmw_cursor_bypass_arg {
  476. uint32_t flags;
  477. uint32_t crtc_id;
  478. int32_t xpos;
  479. int32_t ypos;
  480. int32_t xhot;
  481. int32_t yhot;
  482. };
  483. /*************************************************************************/
  484. /**
  485. * DRM_VMW_CLAIM_STREAM - Claim a single stream.
  486. */
  487. /**
  488. * struct drm_vmw_context_arg
  489. *
  490. * @stream_id: Device unique context ID.
  491. *
  492. * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
  493. * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
  494. */
  495. struct drm_vmw_stream_arg {
  496. uint32_t stream_id;
  497. uint32_t pad64;
  498. };
  499. /*************************************************************************/
  500. /**
  501. * DRM_VMW_UNREF_STREAM - Unclaim a stream.
  502. *
  503. * Return a single stream that was claimed by this process. Also makes
  504. * sure that the stream has been stopped.
  505. */
  506. #endif