vmwgfx_drm.h 17 KB

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