vmwgfx_drm.h 16 KB

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