xref: /openbmc/linux/include/uapi/drm/vmwgfx_drm.h (revision ed84ef1c)
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 
28 #ifndef __VMWGFX_DRM_H__
29 #define __VMWGFX_DRM_H__
30 
31 #include "drm.h"
32 
33 #if defined(__cplusplus)
34 extern "C" {
35 #endif
36 
37 #define DRM_VMW_MAX_SURFACE_FACES 6
38 #define DRM_VMW_MAX_MIP_LEVELS 24
39 
40 
41 #define DRM_VMW_GET_PARAM            0
42 #define DRM_VMW_ALLOC_DMABUF         1
43 #define DRM_VMW_ALLOC_BO             1
44 #define DRM_VMW_UNREF_DMABUF         2
45 #define DRM_VMW_HANDLE_CLOSE         2
46 #define DRM_VMW_CURSOR_BYPASS        3
47 /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
48 #define DRM_VMW_CONTROL_STREAM       4
49 #define DRM_VMW_CLAIM_STREAM         5
50 #define DRM_VMW_UNREF_STREAM         6
51 /* guarded by DRM_VMW_PARAM_3D == 1 */
52 #define DRM_VMW_CREATE_CONTEXT       7
53 #define DRM_VMW_UNREF_CONTEXT        8
54 #define DRM_VMW_CREATE_SURFACE       9
55 #define DRM_VMW_UNREF_SURFACE        10
56 #define DRM_VMW_REF_SURFACE          11
57 #define DRM_VMW_EXECBUF              12
58 #define DRM_VMW_GET_3D_CAP           13
59 #define DRM_VMW_FENCE_WAIT           14
60 #define DRM_VMW_FENCE_SIGNALED       15
61 #define DRM_VMW_FENCE_UNREF          16
62 #define DRM_VMW_FENCE_EVENT          17
63 #define DRM_VMW_PRESENT              18
64 #define DRM_VMW_PRESENT_READBACK     19
65 #define DRM_VMW_UPDATE_LAYOUT        20
66 #define DRM_VMW_CREATE_SHADER        21
67 #define DRM_VMW_UNREF_SHADER         22
68 #define DRM_VMW_GB_SURFACE_CREATE    23
69 #define DRM_VMW_GB_SURFACE_REF       24
70 #define DRM_VMW_SYNCCPU              25
71 #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
72 #define DRM_VMW_GB_SURFACE_CREATE_EXT   27
73 #define DRM_VMW_GB_SURFACE_REF_EXT      28
74 #define DRM_VMW_MSG                     29
75 #define DRM_VMW_MKSSTAT_RESET           30
76 #define DRM_VMW_MKSSTAT_ADD             31
77 #define DRM_VMW_MKSSTAT_REMOVE          32
78 
79 /*************************************************************************/
80 /**
81  * DRM_VMW_GET_PARAM - get device information.
82  *
83  * DRM_VMW_PARAM_FIFO_OFFSET:
84  * Offset to use to map the first page of the FIFO read-only.
85  * The fifo is mapped using the mmap() system call on the drm device.
86  *
87  * DRM_VMW_PARAM_OVERLAY_IOCTL:
88  * Does the driver support the overlay ioctl.
89  *
90  * DRM_VMW_PARAM_SM4_1
91  * SM4_1 support is enabled.
92  *
93  * DRM_VMW_PARAM_SM5
94  * SM5 support is enabled.
95  */
96 
97 #define DRM_VMW_PARAM_NUM_STREAMS      0
98 #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
99 #define DRM_VMW_PARAM_3D               2
100 #define DRM_VMW_PARAM_HW_CAPS          3
101 #define DRM_VMW_PARAM_FIFO_CAPS        4
102 #define DRM_VMW_PARAM_MAX_FB_SIZE      5
103 #define DRM_VMW_PARAM_FIFO_HW_VERSION  6
104 #define DRM_VMW_PARAM_MAX_SURF_MEMORY  7
105 #define DRM_VMW_PARAM_3D_CAPS_SIZE     8
106 #define DRM_VMW_PARAM_MAX_MOB_MEMORY   9
107 #define DRM_VMW_PARAM_MAX_MOB_SIZE     10
108 #define DRM_VMW_PARAM_SCREEN_TARGET    11
109 #define DRM_VMW_PARAM_DX               12
110 #define DRM_VMW_PARAM_HW_CAPS2         13
111 #define DRM_VMW_PARAM_SM4_1            14
112 #define DRM_VMW_PARAM_SM5              15
113 
114 /**
115  * enum drm_vmw_handle_type - handle type for ref ioctls
116  *
117  */
118 enum drm_vmw_handle_type {
119 	DRM_VMW_HANDLE_LEGACY = 0,
120 	DRM_VMW_HANDLE_PRIME = 1
121 };
122 
123 /**
124  * struct drm_vmw_getparam_arg
125  *
126  * @value: Returned value. //Out
127  * @param: Parameter to query. //In.
128  *
129  * Argument to the DRM_VMW_GET_PARAM Ioctl.
130  */
131 
132 struct drm_vmw_getparam_arg {
133 	__u64 value;
134 	__u32 param;
135 	__u32 pad64;
136 };
137 
138 /*************************************************************************/
139 /**
140  * DRM_VMW_CREATE_CONTEXT - Create a host context.
141  *
142  * Allocates a device unique context id, and queues a create context command
143  * for the host. Does not wait for host completion.
144  */
145 
146 /**
147  * struct drm_vmw_context_arg
148  *
149  * @cid: Device unique context ID.
150  *
151  * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
152  * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
153  */
154 
155 struct drm_vmw_context_arg {
156 	__s32 cid;
157 	__u32 pad64;
158 };
159 
160 /*************************************************************************/
161 /**
162  * DRM_VMW_UNREF_CONTEXT - Create a host context.
163  *
164  * Frees a global context id, and queues a destroy host command for the host.
165  * Does not wait for host completion. The context ID can be used directly
166  * in the command stream and shows up as the same context ID on the host.
167  */
168 
169 /*************************************************************************/
170 /**
171  * DRM_VMW_CREATE_SURFACE - Create a host suface.
172  *
173  * Allocates a device unique surface id, and queues a create surface command
174  * for the host. Does not wait for host completion. The surface ID can be
175  * used directly in the command stream and shows up as the same surface
176  * ID on the host.
177  */
178 
179 /**
180  * struct drm_wmv_surface_create_req
181  *
182  * @flags: Surface flags as understood by the host.
183  * @format: Surface format as understood by the host.
184  * @mip_levels: Number of mip levels for each face.
185  * An unused face should have 0 encoded.
186  * @size_addr: Address of a user-space array of sruct drm_vmw_size
187  * cast to an __u64 for 32-64 bit compatibility.
188  * The size of the array should equal the total number of mipmap levels.
189  * @shareable: Boolean whether other clients (as identified by file descriptors)
190  * may reference this surface.
191  * @scanout: Boolean whether the surface is intended to be used as a
192  * scanout.
193  *
194  * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
195  * Output data from the DRM_VMW_REF_SURFACE Ioctl.
196  */
197 
198 struct drm_vmw_surface_create_req {
199 	__u32 flags;
200 	__u32 format;
201 	__u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
202 	__u64 size_addr;
203 	__s32 shareable;
204 	__s32 scanout;
205 };
206 
207 /**
208  * struct drm_wmv_surface_arg
209  *
210  * @sid: Surface id of created surface or surface to destroy or reference.
211  * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
212  *
213  * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
214  * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
215  * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
216  */
217 
218 struct drm_vmw_surface_arg {
219 	__s32 sid;
220 	enum drm_vmw_handle_type handle_type;
221 };
222 
223 /**
224  * struct drm_vmw_size ioctl.
225  *
226  * @width - mip level width
227  * @height - mip level height
228  * @depth - mip level depth
229  *
230  * Description of a mip level.
231  * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
232  */
233 
234 struct drm_vmw_size {
235 	__u32 width;
236 	__u32 height;
237 	__u32 depth;
238 	__u32 pad64;
239 };
240 
241 /**
242  * union drm_vmw_surface_create_arg
243  *
244  * @rep: Output data as described above.
245  * @req: Input data as described above.
246  *
247  * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
248  */
249 
250 union drm_vmw_surface_create_arg {
251 	struct drm_vmw_surface_arg rep;
252 	struct drm_vmw_surface_create_req req;
253 };
254 
255 /*************************************************************************/
256 /**
257  * DRM_VMW_REF_SURFACE - Reference a host surface.
258  *
259  * Puts a reference on a host surface with a give sid, as previously
260  * returned by the DRM_VMW_CREATE_SURFACE ioctl.
261  * A reference will make sure the surface isn't destroyed while we hold
262  * it and will allow the calling client to use the surface ID in the command
263  * stream.
264  *
265  * On successful return, the Ioctl returns the surface information given
266  * in the DRM_VMW_CREATE_SURFACE ioctl.
267  */
268 
269 /**
270  * union drm_vmw_surface_reference_arg
271  *
272  * @rep: Output data as described above.
273  * @req: Input data as described above.
274  *
275  * Argument to the DRM_VMW_REF_SURFACE Ioctl.
276  */
277 
278 union drm_vmw_surface_reference_arg {
279 	struct drm_vmw_surface_create_req rep;
280 	struct drm_vmw_surface_arg req;
281 };
282 
283 /*************************************************************************/
284 /**
285  * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
286  *
287  * Clear a reference previously put on a host surface.
288  * When all references are gone, including the one implicitly placed
289  * on creation,
290  * a destroy surface command will be queued for the host.
291  * Does not wait for completion.
292  */
293 
294 /*************************************************************************/
295 /**
296  * DRM_VMW_EXECBUF
297  *
298  * Submit a command buffer for execution on the host, and return a
299  * fence seqno that when signaled, indicates that the command buffer has
300  * executed.
301  */
302 
303 /**
304  * struct drm_vmw_execbuf_arg
305  *
306  * @commands: User-space address of a command buffer cast to an __u64.
307  * @command-size: Size in bytes of the command buffer.
308  * @throttle-us: Sleep until software is less than @throttle_us
309  * microseconds ahead of hardware. The driver may round this value
310  * to the nearest kernel tick.
311  * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
312  * __u64.
313  * @version: Allows expanding the execbuf ioctl parameters without breaking
314  * backwards compatibility, since user-space will always tell the kernel
315  * which version it uses.
316  * @flags: Execbuf flags.
317  * @imported_fence_fd:  FD for a fence imported from another device
318  *
319  * Argument to the DRM_VMW_EXECBUF Ioctl.
320  */
321 
322 #define DRM_VMW_EXECBUF_VERSION 2
323 
324 #define DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD (1 << 0)
325 #define DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD (1 << 1)
326 
327 struct drm_vmw_execbuf_arg {
328 	__u64 commands;
329 	__u32 command_size;
330 	__u32 throttle_us;
331 	__u64 fence_rep;
332 	__u32 version;
333 	__u32 flags;
334 	__u32 context_handle;
335 	__s32 imported_fence_fd;
336 };
337 
338 /**
339  * struct drm_vmw_fence_rep
340  *
341  * @handle: Fence object handle for fence associated with a command submission.
342  * @mask: Fence flags relevant for this fence object.
343  * @seqno: Fence sequence number in fifo. A fence object with a lower
344  * seqno will signal the EXEC flag before a fence object with a higher
345  * seqno. This can be used by user-space to avoid kernel calls to determine
346  * whether a fence has signaled the EXEC flag. Note that @seqno will
347  * wrap at 32-bit.
348  * @passed_seqno: The highest seqno number processed by the hardware
349  * so far. This can be used to mark user-space fence objects as signaled, and
350  * to determine whether a fence seqno might be stale.
351  * @fd: FD associated with the fence, -1 if not exported
352  * @error: This member should've been set to -EFAULT on submission.
353  * The following actions should be take on completion:
354  * error == -EFAULT: Fence communication failed. The host is synchronized.
355  * Use the last fence id read from the FIFO fence register.
356  * error != 0 && error != -EFAULT:
357  * Fence submission failed. The host is synchronized. Use the fence_seq member.
358  * error == 0: All is OK, The host may not be synchronized.
359  * Use the fence_seq member.
360  *
361  * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
362  */
363 
364 struct drm_vmw_fence_rep {
365 	__u32 handle;
366 	__u32 mask;
367 	__u32 seqno;
368 	__u32 passed_seqno;
369 	__s32 fd;
370 	__s32 error;
371 };
372 
373 /*************************************************************************/
374 /**
375  * DRM_VMW_ALLOC_BO
376  *
377  * Allocate a buffer object that is visible also to the host.
378  * NOTE: The buffer is
379  * identified by a handle and an offset, which are private to the guest, but
380  * useable in the command stream. The guest kernel may translate these
381  * and patch up the command stream accordingly. In the future, the offset may
382  * be zero at all times, or it may disappear from the interface before it is
383  * fixed.
384  *
385  * The buffer object may stay user-space mapped in the guest at all times,
386  * and is thus suitable for sub-allocation.
387  *
388  * Buffer objects are mapped using the mmap() syscall on the drm device.
389  */
390 
391 /**
392  * struct drm_vmw_alloc_bo_req
393  *
394  * @size: Required minimum size of the buffer.
395  *
396  * Input data to the DRM_VMW_ALLOC_BO Ioctl.
397  */
398 
399 struct drm_vmw_alloc_bo_req {
400 	__u32 size;
401 	__u32 pad64;
402 };
403 #define drm_vmw_alloc_dmabuf_req drm_vmw_alloc_bo_req
404 
405 /**
406  * struct drm_vmw_bo_rep
407  *
408  * @map_handle: Offset to use in the mmap() call used to map the buffer.
409  * @handle: Handle unique to this buffer. Used for unreferencing.
410  * @cur_gmr_id: GMR id to use in the command stream when this buffer is
411  * referenced. See not above.
412  * @cur_gmr_offset: Offset to use in the command stream when this buffer is
413  * referenced. See note above.
414  *
415  * Output data from the DRM_VMW_ALLOC_BO Ioctl.
416  */
417 
418 struct drm_vmw_bo_rep {
419 	__u64 map_handle;
420 	__u32 handle;
421 	__u32 cur_gmr_id;
422 	__u32 cur_gmr_offset;
423 	__u32 pad64;
424 };
425 #define drm_vmw_dmabuf_rep drm_vmw_bo_rep
426 
427 /**
428  * union drm_vmw_alloc_bo_arg
429  *
430  * @req: Input data as described above.
431  * @rep: Output data as described above.
432  *
433  * Argument to the DRM_VMW_ALLOC_BO Ioctl.
434  */
435 
436 union drm_vmw_alloc_bo_arg {
437 	struct drm_vmw_alloc_bo_req req;
438 	struct drm_vmw_bo_rep rep;
439 };
440 #define drm_vmw_alloc_dmabuf_arg drm_vmw_alloc_bo_arg
441 
442 /*************************************************************************/
443 /**
444  * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
445  *
446  * This IOCTL controls the overlay units of the svga device.
447  * The SVGA overlay units does not work like regular hardware units in
448  * that they do not automaticaly read back the contents of the given dma
449  * buffer. But instead only read back for each call to this ioctl, and
450  * at any point between this call being made and a following call that
451  * either changes the buffer or disables the stream.
452  */
453 
454 /**
455  * struct drm_vmw_rect
456  *
457  * Defines a rectangle. Used in the overlay ioctl to define
458  * source and destination rectangle.
459  */
460 
461 struct drm_vmw_rect {
462 	__s32 x;
463 	__s32 y;
464 	__u32 w;
465 	__u32 h;
466 };
467 
468 /**
469  * struct drm_vmw_control_stream_arg
470  *
471  * @stream_id: Stearm to control
472  * @enabled: If false all following arguments are ignored.
473  * @handle: Handle to buffer for getting data from.
474  * @format: Format of the overlay as understood by the host.
475  * @width: Width of the overlay.
476  * @height: Height of the overlay.
477  * @size: Size of the overlay in bytes.
478  * @pitch: Array of pitches, the two last are only used for YUV12 formats.
479  * @offset: Offset from start of dma buffer to overlay.
480  * @src: Source rect, must be within the defined area above.
481  * @dst: Destination rect, x and y may be negative.
482  *
483  * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
484  */
485 
486 struct drm_vmw_control_stream_arg {
487 	__u32 stream_id;
488 	__u32 enabled;
489 
490 	__u32 flags;
491 	__u32 color_key;
492 
493 	__u32 handle;
494 	__u32 offset;
495 	__s32 format;
496 	__u32 size;
497 	__u32 width;
498 	__u32 height;
499 	__u32 pitch[3];
500 
501 	__u32 pad64;
502 	struct drm_vmw_rect src;
503 	struct drm_vmw_rect dst;
504 };
505 
506 /*************************************************************************/
507 /**
508  * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
509  *
510  */
511 
512 #define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
513 #define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
514 
515 /**
516  * struct drm_vmw_cursor_bypass_arg
517  *
518  * @flags: Flags.
519  * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
520  * @xpos: X position of cursor.
521  * @ypos: Y position of cursor.
522  * @xhot: X hotspot.
523  * @yhot: Y hotspot.
524  *
525  * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
526  */
527 
528 struct drm_vmw_cursor_bypass_arg {
529 	__u32 flags;
530 	__u32 crtc_id;
531 	__s32 xpos;
532 	__s32 ypos;
533 	__s32 xhot;
534 	__s32 yhot;
535 };
536 
537 /*************************************************************************/
538 /**
539  * DRM_VMW_CLAIM_STREAM - Claim a single stream.
540  */
541 
542 /**
543  * struct drm_vmw_context_arg
544  *
545  * @stream_id: Device unique context ID.
546  *
547  * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
548  * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
549  */
550 
551 struct drm_vmw_stream_arg {
552 	__u32 stream_id;
553 	__u32 pad64;
554 };
555 
556 /*************************************************************************/
557 /**
558  * DRM_VMW_UNREF_STREAM - Unclaim a stream.
559  *
560  * Return a single stream that was claimed by this process. Also makes
561  * sure that the stream has been stopped.
562  */
563 
564 /*************************************************************************/
565 /**
566  * DRM_VMW_GET_3D_CAP
567  *
568  * Read 3D capabilities from the FIFO
569  *
570  */
571 
572 /**
573  * struct drm_vmw_get_3d_cap_arg
574  *
575  * @buffer: Pointer to a buffer for capability data, cast to an __u64
576  * @size: Max size to copy
577  *
578  * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
579  * ioctls.
580  */
581 
582 struct drm_vmw_get_3d_cap_arg {
583 	__u64 buffer;
584 	__u32 max_size;
585 	__u32 pad64;
586 };
587 
588 /*************************************************************************/
589 /**
590  * DRM_VMW_FENCE_WAIT
591  *
592  * Waits for a fence object to signal. The wait is interruptible, so that
593  * signals may be delivered during the interrupt. The wait may timeout,
594  * in which case the calls returns -EBUSY. If the wait is restarted,
595  * that is restarting without resetting @cookie_valid to zero,
596  * the timeout is computed from the first call.
597  *
598  * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
599  * on:
600  * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
601  * stream
602  * have executed.
603  * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
604  * commands
605  * in the buffer given to the EXECBUF ioctl returning the fence object handle
606  * are available to user-space.
607  *
608  * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
609  * fenc wait ioctl returns 0, the fence object has been unreferenced after
610  * the wait.
611  */
612 
613 #define DRM_VMW_FENCE_FLAG_EXEC   (1 << 0)
614 #define DRM_VMW_FENCE_FLAG_QUERY  (1 << 1)
615 
616 #define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
617 
618 /**
619  * struct drm_vmw_fence_wait_arg
620  *
621  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
622  * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
623  * @kernel_cookie: Set to 0 on first call. Left alone on restart.
624  * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
625  * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
626  * before returning.
627  * @flags: Fence flags to wait on.
628  * @wait_options: Options that control the behaviour of the wait ioctl.
629  *
630  * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
631  */
632 
633 struct drm_vmw_fence_wait_arg {
634 	__u32 handle;
635 	__s32  cookie_valid;
636 	__u64 kernel_cookie;
637 	__u64 timeout_us;
638 	__s32 lazy;
639 	__s32 flags;
640 	__s32 wait_options;
641 	__s32 pad64;
642 };
643 
644 /*************************************************************************/
645 /**
646  * DRM_VMW_FENCE_SIGNALED
647  *
648  * Checks if a fence object is signaled..
649  */
650 
651 /**
652  * struct drm_vmw_fence_signaled_arg
653  *
654  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
655  * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
656  * @signaled: Out: Flags signaled.
657  * @sequence: Out: Highest sequence passed so far. Can be used to signal the
658  * EXEC flag of user-space fence objects.
659  *
660  * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
661  * ioctls.
662  */
663 
664 struct drm_vmw_fence_signaled_arg {
665 	 __u32 handle;
666 	 __u32 flags;
667 	 __s32 signaled;
668 	 __u32 passed_seqno;
669 	 __u32 signaled_flags;
670 	 __u32 pad64;
671 };
672 
673 /*************************************************************************/
674 /**
675  * DRM_VMW_FENCE_UNREF
676  *
677  * Unreferences a fence object, and causes it to be destroyed if there are no
678  * other references to it.
679  *
680  */
681 
682 /**
683  * struct drm_vmw_fence_arg
684  *
685  * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
686  *
687  * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
688  */
689 
690 struct drm_vmw_fence_arg {
691 	 __u32 handle;
692 	 __u32 pad64;
693 };
694 
695 
696 /*************************************************************************/
697 /**
698  * DRM_VMW_FENCE_EVENT
699  *
700  * Queues an event on a fence to be delivered on the drm character device
701  * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
702  * Optionally the approximate time when the fence signaled is
703  * given by the event.
704  */
705 
706 /*
707  * The event type
708  */
709 #define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
710 
711 struct drm_vmw_event_fence {
712 	struct drm_event base;
713 	__u64 user_data;
714 	__u32 tv_sec;
715 	__u32 tv_usec;
716 };
717 
718 /*
719  * Flags that may be given to the command.
720  */
721 /* Request fence signaled time on the event. */
722 #define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
723 
724 /**
725  * struct drm_vmw_fence_event_arg
726  *
727  * @fence_rep: Pointer to fence_rep structure cast to __u64 or 0 if
728  * the fence is not supposed to be referenced by user-space.
729  * @user_info: Info to be delivered with the event.
730  * @handle: Attach the event to this fence only.
731  * @flags: A set of flags as defined above.
732  */
733 struct drm_vmw_fence_event_arg {
734 	__u64 fence_rep;
735 	__u64 user_data;
736 	__u32 handle;
737 	__u32 flags;
738 };
739 
740 
741 /*************************************************************************/
742 /**
743  * DRM_VMW_PRESENT
744  *
745  * Executes an SVGA present on a given fb for a given surface. The surface
746  * is placed on the framebuffer. Cliprects are given relative to the given
747  * point (the point disignated by dest_{x|y}).
748  *
749  */
750 
751 /**
752  * struct drm_vmw_present_arg
753  * @fb_id: framebuffer id to present / read back from.
754  * @sid: Surface id to present from.
755  * @dest_x: X placement coordinate for surface.
756  * @dest_y: Y placement coordinate for surface.
757  * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
758  * @num_clips: Number of cliprects given relative to the framebuffer origin,
759  * in the same coordinate space as the frame buffer.
760  * @pad64: Unused 64-bit padding.
761  *
762  * Input argument to the DRM_VMW_PRESENT ioctl.
763  */
764 
765 struct drm_vmw_present_arg {
766 	__u32 fb_id;
767 	__u32 sid;
768 	__s32 dest_x;
769 	__s32 dest_y;
770 	__u64 clips_ptr;
771 	__u32 num_clips;
772 	__u32 pad64;
773 };
774 
775 
776 /*************************************************************************/
777 /**
778  * DRM_VMW_PRESENT_READBACK
779  *
780  * Executes an SVGA present readback from a given fb to the dma buffer
781  * currently bound as the fb. If there is no dma buffer bound to the fb,
782  * an error will be returned.
783  *
784  */
785 
786 /**
787  * struct drm_vmw_present_arg
788  * @fb_id: fb_id to present / read back from.
789  * @num_clips: Number of cliprects.
790  * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
791  * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an __u64.
792  * If this member is NULL, then the ioctl should not return a fence.
793  */
794 
795 struct drm_vmw_present_readback_arg {
796 	 __u32 fb_id;
797 	 __u32 num_clips;
798 	 __u64 clips_ptr;
799 	 __u64 fence_rep;
800 };
801 
802 /*************************************************************************/
803 /**
804  * DRM_VMW_UPDATE_LAYOUT - Update layout
805  *
806  * Updates the preferred modes and connection status for connectors. The
807  * command consists of one drm_vmw_update_layout_arg pointing to an array
808  * of num_outputs drm_vmw_rect's.
809  */
810 
811 /**
812  * struct drm_vmw_update_layout_arg
813  *
814  * @num_outputs: number of active connectors
815  * @rects: pointer to array of drm_vmw_rect cast to an __u64
816  *
817  * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
818  */
819 struct drm_vmw_update_layout_arg {
820 	__u32 num_outputs;
821 	__u32 pad64;
822 	__u64 rects;
823 };
824 
825 
826 /*************************************************************************/
827 /**
828  * DRM_VMW_CREATE_SHADER - Create shader
829  *
830  * Creates a shader and optionally binds it to a dma buffer containing
831  * the shader byte-code.
832  */
833 
834 /**
835  * enum drm_vmw_shader_type - Shader types
836  */
837 enum drm_vmw_shader_type {
838 	drm_vmw_shader_type_vs = 0,
839 	drm_vmw_shader_type_ps,
840 };
841 
842 
843 /**
844  * struct drm_vmw_shader_create_arg
845  *
846  * @shader_type: Shader type of the shader to create.
847  * @size: Size of the byte-code in bytes.
848  * where the shader byte-code starts
849  * @buffer_handle: Buffer handle identifying the buffer containing the
850  * shader byte-code
851  * @shader_handle: On successful completion contains a handle that
852  * can be used to subsequently identify the shader.
853  * @offset: Offset in bytes into the buffer given by @buffer_handle,
854  *
855  * Input / Output argument to the DRM_VMW_CREATE_SHADER Ioctl.
856  */
857 struct drm_vmw_shader_create_arg {
858 	enum drm_vmw_shader_type shader_type;
859 	__u32 size;
860 	__u32 buffer_handle;
861 	__u32 shader_handle;
862 	__u64 offset;
863 };
864 
865 /*************************************************************************/
866 /**
867  * DRM_VMW_UNREF_SHADER - Unreferences a shader
868  *
869  * Destroys a user-space reference to a shader, optionally destroying
870  * it.
871  */
872 
873 /**
874  * struct drm_vmw_shader_arg
875  *
876  * @handle: Handle identifying the shader to destroy.
877  *
878  * Input argument to the DRM_VMW_UNREF_SHADER ioctl.
879  */
880 struct drm_vmw_shader_arg {
881 	__u32 handle;
882 	__u32 pad64;
883 };
884 
885 /*************************************************************************/
886 /**
887  * DRM_VMW_GB_SURFACE_CREATE - Create a host guest-backed surface.
888  *
889  * Allocates a surface handle and queues a create surface command
890  * for the host on the first use of the surface. The surface ID can
891  * be used as the surface ID in commands referencing the surface.
892  */
893 
894 /**
895  * enum drm_vmw_surface_flags
896  *
897  * @drm_vmw_surface_flag_shareable:     Whether the surface is shareable
898  * @drm_vmw_surface_flag_scanout:       Whether the surface is a scanout
899  *                                      surface.
900  * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is
901  *                                      given.
902  * @drm_vmw_surface_flag_coherent:      Back surface with coherent memory.
903  */
904 enum drm_vmw_surface_flags {
905 	drm_vmw_surface_flag_shareable = (1 << 0),
906 	drm_vmw_surface_flag_scanout = (1 << 1),
907 	drm_vmw_surface_flag_create_buffer = (1 << 2),
908 	drm_vmw_surface_flag_coherent = (1 << 3),
909 };
910 
911 /**
912  * struct drm_vmw_gb_surface_create_req
913  *
914  * @svga3d_flags:     SVGA3d surface flags for the device.
915  * @format:           SVGA3d format.
916  * @mip_level:        Number of mip levels for all faces.
917  * @drm_surface_flags Flags as described above.
918  * @multisample_count Future use. Set to 0.
919  * @autogen_filter    Future use. Set to 0.
920  * @buffer_handle     Buffer handle of backup buffer. SVGA3D_INVALID_ID
921  *                    if none.
922  * @base_size         Size of the base mip level for all faces.
923  * @array_size        Must be zero for non-DX hardware, and if non-zero
924  *                    svga3d_flags must have proper bind flags setup.
925  *
926  * Input argument to the  DRM_VMW_GB_SURFACE_CREATE Ioctl.
927  * Part of output argument for the DRM_VMW_GB_SURFACE_REF Ioctl.
928  */
929 struct drm_vmw_gb_surface_create_req {
930 	__u32 svga3d_flags;
931 	__u32 format;
932 	__u32 mip_levels;
933 	enum drm_vmw_surface_flags drm_surface_flags;
934 	__u32 multisample_count;
935 	__u32 autogen_filter;
936 	__u32 buffer_handle;
937 	__u32 array_size;
938 	struct drm_vmw_size base_size;
939 };
940 
941 /**
942  * struct drm_vmw_gb_surface_create_rep
943  *
944  * @handle:            Surface handle.
945  * @backup_size:       Size of backup buffers for this surface.
946  * @buffer_handle:     Handle of backup buffer. SVGA3D_INVALID_ID if none.
947  * @buffer_size:       Actual size of the buffer identified by
948  *                     @buffer_handle
949  * @buffer_map_handle: Offset into device address space for the buffer
950  *                     identified by @buffer_handle.
951  *
952  * Part of output argument for the DRM_VMW_GB_SURFACE_REF ioctl.
953  * Output argument for the DRM_VMW_GB_SURFACE_CREATE ioctl.
954  */
955 struct drm_vmw_gb_surface_create_rep {
956 	__u32 handle;
957 	__u32 backup_size;
958 	__u32 buffer_handle;
959 	__u32 buffer_size;
960 	__u64 buffer_map_handle;
961 };
962 
963 /**
964  * union drm_vmw_gb_surface_create_arg
965  *
966  * @req: Input argument as described above.
967  * @rep: Output argument as described above.
968  *
969  * Argument to the DRM_VMW_GB_SURFACE_CREATE ioctl.
970  */
971 union drm_vmw_gb_surface_create_arg {
972 	struct drm_vmw_gb_surface_create_rep rep;
973 	struct drm_vmw_gb_surface_create_req req;
974 };
975 
976 /*************************************************************************/
977 /**
978  * DRM_VMW_GB_SURFACE_REF - Reference a host surface.
979  *
980  * Puts a reference on a host surface with a given handle, as previously
981  * returned by the DRM_VMW_GB_SURFACE_CREATE ioctl.
982  * A reference will make sure the surface isn't destroyed while we hold
983  * it and will allow the calling client to use the surface handle in
984  * the command stream.
985  *
986  * On successful return, the Ioctl returns the surface information given
987  * to and returned from the DRM_VMW_GB_SURFACE_CREATE ioctl.
988  */
989 
990 /**
991  * struct drm_vmw_gb_surface_reference_arg
992  *
993  * @creq: The data used as input when the surface was created, as described
994  *        above at "struct drm_vmw_gb_surface_create_req"
995  * @crep: Additional data output when the surface was created, as described
996  *        above at "struct drm_vmw_gb_surface_create_rep"
997  *
998  * Output Argument to the DRM_VMW_GB_SURFACE_REF ioctl.
999  */
1000 struct drm_vmw_gb_surface_ref_rep {
1001 	struct drm_vmw_gb_surface_create_req creq;
1002 	struct drm_vmw_gb_surface_create_rep crep;
1003 };
1004 
1005 /**
1006  * union drm_vmw_gb_surface_reference_arg
1007  *
1008  * @req: Input data as described above at "struct drm_vmw_surface_arg"
1009  * @rep: Output data as described above at "struct drm_vmw_gb_surface_ref_rep"
1010  *
1011  * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
1012  */
1013 union drm_vmw_gb_surface_reference_arg {
1014 	struct drm_vmw_gb_surface_ref_rep rep;
1015 	struct drm_vmw_surface_arg req;
1016 };
1017 
1018 
1019 /*************************************************************************/
1020 /**
1021  * DRM_VMW_SYNCCPU - Sync a DMA buffer / MOB for CPU access.
1022  *
1023  * Idles any previously submitted GPU operations on the buffer and
1024  * by default blocks command submissions that reference the buffer.
1025  * If the file descriptor used to grab a blocking CPU sync is closed, the
1026  * cpu sync is released.
1027  * The flags argument indicates how the grab / release operation should be
1028  * performed:
1029  */
1030 
1031 /**
1032  * enum drm_vmw_synccpu_flags - Synccpu flags:
1033  *
1034  * @drm_vmw_synccpu_read: Sync for read. If sync is done for read only, it's a
1035  * hint to the kernel to allow command submissions that references the buffer
1036  * for read-only.
1037  * @drm_vmw_synccpu_write: Sync for write. Block all command submissions
1038  * referencing this buffer.
1039  * @drm_vmw_synccpu_dontblock: Dont wait for GPU idle, but rather return
1040  * -EBUSY should the buffer be busy.
1041  * @drm_vmw_synccpu_allow_cs: Allow command submission that touches the buffer
1042  * while the buffer is synced for CPU. This is similar to the GEM bo idle
1043  * behavior.
1044  */
1045 enum drm_vmw_synccpu_flags {
1046 	drm_vmw_synccpu_read = (1 << 0),
1047 	drm_vmw_synccpu_write = (1 << 1),
1048 	drm_vmw_synccpu_dontblock = (1 << 2),
1049 	drm_vmw_synccpu_allow_cs = (1 << 3)
1050 };
1051 
1052 /**
1053  * enum drm_vmw_synccpu_op - Synccpu operations:
1054  *
1055  * @drm_vmw_synccpu_grab:    Grab the buffer for CPU operations
1056  * @drm_vmw_synccpu_release: Release a previous grab.
1057  */
1058 enum drm_vmw_synccpu_op {
1059 	drm_vmw_synccpu_grab,
1060 	drm_vmw_synccpu_release
1061 };
1062 
1063 /**
1064  * struct drm_vmw_synccpu_arg
1065  *
1066  * @op:			     The synccpu operation as described above.
1067  * @handle:		     Handle identifying the buffer object.
1068  * @flags:		     Flags as described above.
1069  */
1070 struct drm_vmw_synccpu_arg {
1071 	enum drm_vmw_synccpu_op op;
1072 	enum drm_vmw_synccpu_flags flags;
1073 	__u32 handle;
1074 	__u32 pad64;
1075 };
1076 
1077 /*************************************************************************/
1078 /**
1079  * DRM_VMW_CREATE_EXTENDED_CONTEXT - Create a host context.
1080  *
1081  * Allocates a device unique context id, and queues a create context command
1082  * for the host. Does not wait for host completion.
1083  */
1084 enum drm_vmw_extended_context {
1085 	drm_vmw_context_legacy,
1086 	drm_vmw_context_dx
1087 };
1088 
1089 /**
1090  * union drm_vmw_extended_context_arg
1091  *
1092  * @req: Context type.
1093  * @rep: Context identifier.
1094  *
1095  * Argument to the DRM_VMW_CREATE_EXTENDED_CONTEXT Ioctl.
1096  */
1097 union drm_vmw_extended_context_arg {
1098 	enum drm_vmw_extended_context req;
1099 	struct drm_vmw_context_arg rep;
1100 };
1101 
1102 /*************************************************************************/
1103 /*
1104  * DRM_VMW_HANDLE_CLOSE - Close a user-space handle and release its
1105  * underlying resource.
1106  *
1107  * Note that this ioctl is overlaid on the deprecated DRM_VMW_UNREF_DMABUF
1108  * Ioctl.
1109  */
1110 
1111 /**
1112  * struct drm_vmw_handle_close_arg
1113  *
1114  * @handle: Handle to close.
1115  *
1116  * Argument to the DRM_VMW_HANDLE_CLOSE Ioctl.
1117  */
1118 struct drm_vmw_handle_close_arg {
1119 	__u32 handle;
1120 	__u32 pad64;
1121 };
1122 #define drm_vmw_unref_dmabuf_arg drm_vmw_handle_close_arg
1123 
1124 /*************************************************************************/
1125 /**
1126  * DRM_VMW_GB_SURFACE_CREATE_EXT - Create a host guest-backed surface.
1127  *
1128  * Allocates a surface handle and queues a create surface command
1129  * for the host on the first use of the surface. The surface ID can
1130  * be used as the surface ID in commands referencing the surface.
1131  *
1132  * This new command extends DRM_VMW_GB_SURFACE_CREATE by adding version
1133  * parameter and 64 bit svga flag.
1134  */
1135 
1136 /**
1137  * enum drm_vmw_surface_version
1138  *
1139  * @drm_vmw_surface_gb_v1: Corresponds to current gb surface format with
1140  * svga3d surface flags split into 2, upper half and lower half.
1141  */
1142 enum drm_vmw_surface_version {
1143 	drm_vmw_gb_surface_v1,
1144 };
1145 
1146 /**
1147  * struct drm_vmw_gb_surface_create_ext_req
1148  *
1149  * @base: Surface create parameters.
1150  * @version: Version of surface create ioctl.
1151  * @svga3d_flags_upper_32_bits: Upper 32 bits of svga3d flags.
1152  * @multisample_pattern: Multisampling pattern when msaa is supported.
1153  * @quality_level: Precision settings for each sample.
1154  * @buffer_byte_stride: Buffer byte stride.
1155  * @must_be_zero: Reserved for future usage.
1156  *
1157  * Input argument to the  DRM_VMW_GB_SURFACE_CREATE_EXT Ioctl.
1158  * Part of output argument for the DRM_VMW_GB_SURFACE_REF_EXT Ioctl.
1159  */
1160 struct drm_vmw_gb_surface_create_ext_req {
1161 	struct drm_vmw_gb_surface_create_req base;
1162 	enum drm_vmw_surface_version version;
1163 	__u32 svga3d_flags_upper_32_bits;
1164 	__u32 multisample_pattern;
1165 	__u32 quality_level;
1166 	__u32 buffer_byte_stride;
1167 	__u32 must_be_zero;
1168 };
1169 
1170 /**
1171  * union drm_vmw_gb_surface_create_ext_arg
1172  *
1173  * @req: Input argument as described above.
1174  * @rep: Output argument as described above.
1175  *
1176  * Argument to the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1177  */
1178 union drm_vmw_gb_surface_create_ext_arg {
1179 	struct drm_vmw_gb_surface_create_rep rep;
1180 	struct drm_vmw_gb_surface_create_ext_req req;
1181 };
1182 
1183 /*************************************************************************/
1184 /**
1185  * DRM_VMW_GB_SURFACE_REF_EXT - Reference a host surface.
1186  *
1187  * Puts a reference on a host surface with a given handle, as previously
1188  * returned by the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1189  * A reference will make sure the surface isn't destroyed while we hold
1190  * it and will allow the calling client to use the surface handle in
1191  * the command stream.
1192  *
1193  * On successful return, the Ioctl returns the surface information given
1194  * to and returned from the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1195  */
1196 
1197 /**
1198  * struct drm_vmw_gb_surface_ref_ext_rep
1199  *
1200  * @creq: The data used as input when the surface was created, as described
1201  *        above at "struct drm_vmw_gb_surface_create_ext_req"
1202  * @crep: Additional data output when the surface was created, as described
1203  *        above at "struct drm_vmw_gb_surface_create_rep"
1204  *
1205  * Output Argument to the DRM_VMW_GB_SURFACE_REF_EXT ioctl.
1206  */
1207 struct drm_vmw_gb_surface_ref_ext_rep {
1208 	struct drm_vmw_gb_surface_create_ext_req creq;
1209 	struct drm_vmw_gb_surface_create_rep crep;
1210 };
1211 
1212 /**
1213  * union drm_vmw_gb_surface_reference_ext_arg
1214  *
1215  * @req: Input data as described above at "struct drm_vmw_surface_arg"
1216  * @rep: Output data as described above at
1217  *       "struct drm_vmw_gb_surface_ref_ext_rep"
1218  *
1219  * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
1220  */
1221 union drm_vmw_gb_surface_reference_ext_arg {
1222 	struct drm_vmw_gb_surface_ref_ext_rep rep;
1223 	struct drm_vmw_surface_arg req;
1224 };
1225 
1226 /**
1227  * struct drm_vmw_msg_arg
1228  *
1229  * @send: Pointer to user-space msg string (null terminated).
1230  * @receive: Pointer to user-space receive buffer.
1231  * @send_only: Boolean whether this is only sending or receiving too.
1232  *
1233  * Argument to the DRM_VMW_MSG ioctl.
1234  */
1235 struct drm_vmw_msg_arg {
1236 	__u64 send;
1237 	__u64 receive;
1238 	__s32 send_only;
1239 	__u32 receive_len;
1240 };
1241 
1242 /**
1243  * struct drm_vmw_mksstat_add_arg
1244  *
1245  * @stat: Pointer to user-space stat-counters array, page-aligned.
1246  * @info: Pointer to user-space counter-infos array, page-aligned.
1247  * @strs: Pointer to user-space stat strings, page-aligned.
1248  * @stat_len: Length in bytes of stat-counters array.
1249  * @info_len: Length in bytes of counter-infos array.
1250  * @strs_len: Length in bytes of the stat strings, terminators included.
1251  * @description: Pointer to instance descriptor string; will be truncated
1252  *               to MKS_GUEST_STAT_INSTANCE_DESC_LENGTH chars.
1253  * @id: Output identifier of the produced record; -1 if error.
1254  *
1255  * Argument to the DRM_VMW_MKSSTAT_ADD ioctl.
1256  */
1257 struct drm_vmw_mksstat_add_arg {
1258 	__u64 stat;
1259 	__u64 info;
1260 	__u64 strs;
1261 	__u64 stat_len;
1262 	__u64 info_len;
1263 	__u64 strs_len;
1264 	__u64 description;
1265 	__u64 id;
1266 };
1267 
1268 /**
1269  * struct drm_vmw_mksstat_remove_arg
1270  *
1271  * @id: Identifier of the record being disposed, originally obtained through
1272  *      DRM_VMW_MKSSTAT_ADD ioctl.
1273  *
1274  * Argument to the DRM_VMW_MKSSTAT_REMOVE ioctl.
1275  */
1276 struct drm_vmw_mksstat_remove_arg {
1277 	__u64 id;
1278 };
1279 
1280 #if defined(__cplusplus)
1281 }
1282 #endif
1283 
1284 #endif
1285