vmwgfx_drm.h 17 KB

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