1 /* SPDX-License-Identifier: (GPL-2.0 WITH Linux-syscall-note) OR MIT */
2 /**************************************************************************
4 * Copyright © 2009-2023 VMware, Inc., Palo Alto, CA., USA
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
22 * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
23 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
25 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #ifndef __VMWGFX_DRM_H__
30 #define __VMWGFX_DRM_H__
34 #if defined(__cplusplus)
38 #define DRM_VMW_MAX_SURFACE_FACES 6
39 #define DRM_VMW_MAX_MIP_LEVELS 24
42 #define DRM_VMW_GET_PARAM 0
43 #define DRM_VMW_ALLOC_DMABUF 1
44 #define DRM_VMW_ALLOC_BO 1
45 #define DRM_VMW_UNREF_DMABUF 2
46 #define DRM_VMW_HANDLE_CLOSE 2
47 #define DRM_VMW_CURSOR_BYPASS 3
48 /* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
49 #define DRM_VMW_CONTROL_STREAM 4
50 #define DRM_VMW_CLAIM_STREAM 5
51 #define DRM_VMW_UNREF_STREAM 6
52 /* guarded by DRM_VMW_PARAM_3D == 1 */
53 #define DRM_VMW_CREATE_CONTEXT 7
54 #define DRM_VMW_UNREF_CONTEXT 8
55 #define DRM_VMW_CREATE_SURFACE 9
56 #define DRM_VMW_UNREF_SURFACE 10
57 #define DRM_VMW_REF_SURFACE 11
58 #define DRM_VMW_EXECBUF 12
59 #define DRM_VMW_GET_3D_CAP 13
60 #define DRM_VMW_FENCE_WAIT 14
61 #define DRM_VMW_FENCE_SIGNALED 15
62 #define DRM_VMW_FENCE_UNREF 16
63 #define DRM_VMW_FENCE_EVENT 17
64 #define DRM_VMW_PRESENT 18
65 #define DRM_VMW_PRESENT_READBACK 19
66 #define DRM_VMW_UPDATE_LAYOUT 20
67 #define DRM_VMW_CREATE_SHADER 21
68 #define DRM_VMW_UNREF_SHADER 22
69 #define DRM_VMW_GB_SURFACE_CREATE 23
70 #define DRM_VMW_GB_SURFACE_REF 24
71 #define DRM_VMW_SYNCCPU 25
72 #define DRM_VMW_CREATE_EXTENDED_CONTEXT 26
73 #define DRM_VMW_GB_SURFACE_CREATE_EXT 27
74 #define DRM_VMW_GB_SURFACE_REF_EXT 28
75 #define DRM_VMW_MSG 29
76 #define DRM_VMW_MKSSTAT_RESET 30
77 #define DRM_VMW_MKSSTAT_ADD 31
78 #define DRM_VMW_MKSSTAT_REMOVE 32
80 /*************************************************************************/
82 * DRM_VMW_GET_PARAM - get device information.
84 * DRM_VMW_PARAM_FIFO_OFFSET:
85 * Offset to use to map the first page of the FIFO read-only.
86 * The fifo is mapped using the mmap() system call on the drm device.
88 * DRM_VMW_PARAM_OVERLAY_IOCTL:
89 * Does the driver support the overlay ioctl.
92 * SM4_1 support is enabled.
95 * SM5 support is enabled.
98 * SM5.1+GL4.3 support is enabled.
100 * DRM_VMW_PARAM_DEVICE_ID
101 * PCI ID of the underlying SVGA device.
104 #define DRM_VMW_PARAM_NUM_STREAMS 0
105 #define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
106 #define DRM_VMW_PARAM_3D 2
107 #define DRM_VMW_PARAM_HW_CAPS 3
108 #define DRM_VMW_PARAM_FIFO_CAPS 4
109 #define DRM_VMW_PARAM_MAX_FB_SIZE 5
110 #define DRM_VMW_PARAM_FIFO_HW_VERSION 6
111 #define DRM_VMW_PARAM_MAX_SURF_MEMORY 7
112 #define DRM_VMW_PARAM_3D_CAPS_SIZE 8
113 #define DRM_VMW_PARAM_MAX_MOB_MEMORY 9
114 #define DRM_VMW_PARAM_MAX_MOB_SIZE 10
115 #define DRM_VMW_PARAM_SCREEN_TARGET 11
116 #define DRM_VMW_PARAM_DX 12
117 #define DRM_VMW_PARAM_HW_CAPS2 13
118 #define DRM_VMW_PARAM_SM4_1 14
119 #define DRM_VMW_PARAM_SM5 15
120 #define DRM_VMW_PARAM_GL43 16
121 #define DRM_VMW_PARAM_DEVICE_ID 17
124 * enum drm_vmw_handle_type - handle type for ref ioctls
127 enum drm_vmw_handle_type {
128 DRM_VMW_HANDLE_LEGACY = 0,
129 DRM_VMW_HANDLE_PRIME = 1
133 * struct drm_vmw_getparam_arg
135 * @value: Returned value. //Out
136 * @param: Parameter to query. //In.
138 * Argument to the DRM_VMW_GET_PARAM Ioctl.
141 struct drm_vmw_getparam_arg {
147 /*************************************************************************/
149 * DRM_VMW_CREATE_CONTEXT - Create a host context.
151 * Allocates a device unique context id, and queues a create context command
152 * for the host. Does not wait for host completion.
156 * struct drm_vmw_context_arg
158 * @cid: Device unique context ID.
160 * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
161 * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
164 struct drm_vmw_context_arg {
169 /*************************************************************************/
171 * DRM_VMW_UNREF_CONTEXT - Create a host context.
173 * Frees a global context id, and queues a destroy host command for the host.
174 * Does not wait for host completion. The context ID can be used directly
175 * in the command stream and shows up as the same context ID on the host.
178 /*************************************************************************/
180 * DRM_VMW_CREATE_SURFACE - Create a host suface.
182 * Allocates a device unique surface id, and queues a create surface command
183 * for the host. Does not wait for host completion. The surface ID can be
184 * used directly in the command stream and shows up as the same surface
189 * struct drm_wmv_surface_create_req
191 * @flags: Surface flags as understood by the host.
192 * @format: Surface format as understood by the host.
193 * @mip_levels: Number of mip levels for each face.
194 * An unused face should have 0 encoded.
195 * @size_addr: Address of a user-space array of sruct drm_vmw_size
196 * cast to an __u64 for 32-64 bit compatibility.
197 * The size of the array should equal the total number of mipmap levels.
198 * @shareable: Boolean whether other clients (as identified by file descriptors)
199 * may reference this surface.
200 * @scanout: Boolean whether the surface is intended to be used as a
203 * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
204 * Output data from the DRM_VMW_REF_SURFACE Ioctl.
207 struct drm_vmw_surface_create_req {
210 __u32 mip_levels[DRM_VMW_MAX_SURFACE_FACES];
217 * struct drm_wmv_surface_arg
219 * @sid: Surface id of created surface or surface to destroy or reference.
220 * @handle_type: Handle type for DRM_VMW_REF_SURFACE Ioctl.
222 * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
223 * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
224 * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
227 struct drm_vmw_surface_arg {
229 enum drm_vmw_handle_type handle_type;
233 * struct drm_vmw_size ioctl.
235 * @width - mip level width
236 * @height - mip level height
237 * @depth - mip level depth
239 * Description of a mip level.
240 * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
243 struct drm_vmw_size {
251 * union drm_vmw_surface_create_arg
253 * @rep: Output data as described above.
254 * @req: Input data as described above.
256 * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
259 union drm_vmw_surface_create_arg {
260 struct drm_vmw_surface_arg rep;
261 struct drm_vmw_surface_create_req req;
264 /*************************************************************************/
266 * DRM_VMW_REF_SURFACE - Reference a host surface.
268 * Puts a reference on a host surface with a give sid, as previously
269 * returned by the DRM_VMW_CREATE_SURFACE ioctl.
270 * A reference will make sure the surface isn't destroyed while we hold
271 * it and will allow the calling client to use the surface ID in the command
274 * On successful return, the Ioctl returns the surface information given
275 * in the DRM_VMW_CREATE_SURFACE ioctl.
279 * union drm_vmw_surface_reference_arg
281 * @rep: Output data as described above.
282 * @req: Input data as described above.
284 * Argument to the DRM_VMW_REF_SURFACE Ioctl.
287 union drm_vmw_surface_reference_arg {
288 struct drm_vmw_surface_create_req rep;
289 struct drm_vmw_surface_arg req;
292 /*************************************************************************/
294 * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
296 * Clear a reference previously put on a host surface.
297 * When all references are gone, including the one implicitly placed
299 * a destroy surface command will be queued for the host.
300 * Does not wait for completion.
303 /*************************************************************************/
307 * Submit a command buffer for execution on the host, and return a
308 * fence seqno that when signaled, indicates that the command buffer has
313 * struct drm_vmw_execbuf_arg
315 * @commands: User-space address of a command buffer cast to an __u64.
316 * @command-size: Size in bytes of the command buffer.
317 * @throttle-us: Sleep until software is less than @throttle_us
318 * microseconds ahead of hardware. The driver may round this value
319 * to the nearest kernel tick.
320 * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
322 * @version: Allows expanding the execbuf ioctl parameters without breaking
323 * backwards compatibility, since user-space will always tell the kernel
324 * which version it uses.
325 * @flags: Execbuf flags.
326 * @imported_fence_fd: FD for a fence imported from another device
328 * Argument to the DRM_VMW_EXECBUF Ioctl.
331 #define DRM_VMW_EXECBUF_VERSION 2
333 #define DRM_VMW_EXECBUF_FLAG_IMPORT_FENCE_FD (1 << 0)
334 #define DRM_VMW_EXECBUF_FLAG_EXPORT_FENCE_FD (1 << 1)
336 struct drm_vmw_execbuf_arg {
343 __u32 context_handle;
344 __s32 imported_fence_fd;
348 * struct drm_vmw_fence_rep
350 * @handle: Fence object handle for fence associated with a command submission.
351 * @mask: Fence flags relevant for this fence object.
352 * @seqno: Fence sequence number in fifo. A fence object with a lower
353 * seqno will signal the EXEC flag before a fence object with a higher
354 * seqno. This can be used by user-space to avoid kernel calls to determine
355 * whether a fence has signaled the EXEC flag. Note that @seqno will
357 * @passed_seqno: The highest seqno number processed by the hardware
358 * so far. This can be used to mark user-space fence objects as signaled, and
359 * to determine whether a fence seqno might be stale.
360 * @fd: FD associated with the fence, -1 if not exported
361 * @error: This member should've been set to -EFAULT on submission.
362 * The following actions should be take on completion:
363 * error == -EFAULT: Fence communication failed. The host is synchronized.
364 * Use the last fence id read from the FIFO fence register.
365 * error != 0 && error != -EFAULT:
366 * Fence submission failed. The host is synchronized. Use the fence_seq member.
367 * error == 0: All is OK, The host may not be synchronized.
368 * Use the fence_seq member.
370 * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
373 struct drm_vmw_fence_rep {
382 /*************************************************************************/
386 * Allocate a buffer object that is visible also to the host.
387 * NOTE: The buffer is
388 * identified by a handle and an offset, which are private to the guest, but
389 * useable in the command stream. The guest kernel may translate these
390 * and patch up the command stream accordingly. In the future, the offset may
391 * be zero at all times, or it may disappear from the interface before it is
394 * The buffer object may stay user-space mapped in the guest at all times,
395 * and is thus suitable for sub-allocation.
397 * Buffer objects are mapped using the mmap() syscall on the drm device.
401 * struct drm_vmw_alloc_bo_req
403 * @size: Required minimum size of the buffer.
405 * Input data to the DRM_VMW_ALLOC_BO Ioctl.
408 struct drm_vmw_alloc_bo_req {
412 #define drm_vmw_alloc_dmabuf_req drm_vmw_alloc_bo_req
415 * struct drm_vmw_bo_rep
417 * @map_handle: Offset to use in the mmap() call used to map the buffer.
418 * @handle: Handle unique to this buffer. Used for unreferencing.
419 * @cur_gmr_id: GMR id to use in the command stream when this buffer is
420 * referenced. See not above.
421 * @cur_gmr_offset: Offset to use in the command stream when this buffer is
422 * referenced. See note above.
424 * Output data from the DRM_VMW_ALLOC_BO Ioctl.
427 struct drm_vmw_bo_rep {
431 __u32 cur_gmr_offset;
434 #define drm_vmw_dmabuf_rep drm_vmw_bo_rep
437 * union drm_vmw_alloc_bo_arg
439 * @req: Input data as described above.
440 * @rep: Output data as described above.
442 * Argument to the DRM_VMW_ALLOC_BO Ioctl.
445 union drm_vmw_alloc_bo_arg {
446 struct drm_vmw_alloc_bo_req req;
447 struct drm_vmw_bo_rep rep;
449 #define drm_vmw_alloc_dmabuf_arg drm_vmw_alloc_bo_arg
451 /*************************************************************************/
453 * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
455 * This IOCTL controls the overlay units of the svga device.
456 * The SVGA overlay units does not work like regular hardware units in
457 * that they do not automaticaly read back the contents of the given dma
458 * buffer. But instead only read back for each call to this ioctl, and
459 * at any point between this call being made and a following call that
460 * either changes the buffer or disables the stream.
464 * struct drm_vmw_rect
466 * Defines a rectangle. Used in the overlay ioctl to define
467 * source and destination rectangle.
470 struct drm_vmw_rect {
478 * struct drm_vmw_control_stream_arg
480 * @stream_id: Stearm to control
481 * @enabled: If false all following arguments are ignored.
482 * @handle: Handle to buffer for getting data from.
483 * @format: Format of the overlay as understood by the host.
484 * @width: Width of the overlay.
485 * @height: Height of the overlay.
486 * @size: Size of the overlay in bytes.
487 * @pitch: Array of pitches, the two last are only used for YUV12 formats.
488 * @offset: Offset from start of dma buffer to overlay.
489 * @src: Source rect, must be within the defined area above.
490 * @dst: Destination rect, x and y may be negative.
492 * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
495 struct drm_vmw_control_stream_arg {
511 struct drm_vmw_rect src;
512 struct drm_vmw_rect dst;
515 /*************************************************************************/
517 * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
521 #define DRM_VMW_CURSOR_BYPASS_ALL (1 << 0)
522 #define DRM_VMW_CURSOR_BYPASS_FLAGS (1)
525 * struct drm_vmw_cursor_bypass_arg
528 * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
529 * @xpos: X position of cursor.
530 * @ypos: Y position of cursor.
534 * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
537 struct drm_vmw_cursor_bypass_arg {
546 /*************************************************************************/
548 * DRM_VMW_CLAIM_STREAM - Claim a single stream.
552 * struct drm_vmw_context_arg
554 * @stream_id: Device unique context ID.
556 * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
557 * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
560 struct drm_vmw_stream_arg {
565 /*************************************************************************/
567 * DRM_VMW_UNREF_STREAM - Unclaim a stream.
569 * Return a single stream that was claimed by this process. Also makes
570 * sure that the stream has been stopped.
573 /*************************************************************************/
577 * Read 3D capabilities from the FIFO
582 * struct drm_vmw_get_3d_cap_arg
584 * @buffer: Pointer to a buffer for capability data, cast to an __u64
585 * @size: Max size to copy
587 * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
591 struct drm_vmw_get_3d_cap_arg {
597 /*************************************************************************/
601 * Waits for a fence object to signal. The wait is interruptible, so that
602 * signals may be delivered during the interrupt. The wait may timeout,
603 * in which case the calls returns -EBUSY. If the wait is restarted,
604 * that is restarting without resetting @cookie_valid to zero,
605 * the timeout is computed from the first call.
607 * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
609 * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
612 * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
614 * in the buffer given to the EXECBUF ioctl returning the fence object handle
615 * are available to user-space.
617 * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
618 * fenc wait ioctl returns 0, the fence object has been unreferenced after
622 #define DRM_VMW_FENCE_FLAG_EXEC (1 << 0)
623 #define DRM_VMW_FENCE_FLAG_QUERY (1 << 1)
625 #define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
628 * struct drm_vmw_fence_wait_arg
630 * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
631 * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
632 * @kernel_cookie: Set to 0 on first call. Left alone on restart.
633 * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
634 * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
636 * @flags: Fence flags to wait on.
637 * @wait_options: Options that control the behaviour of the wait ioctl.
639 * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
642 struct drm_vmw_fence_wait_arg {
653 /*************************************************************************/
655 * DRM_VMW_FENCE_SIGNALED
657 * Checks if a fence object is signaled..
661 * struct drm_vmw_fence_signaled_arg
663 * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
664 * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
665 * @signaled: Out: Flags signaled.
666 * @sequence: Out: Highest sequence passed so far. Can be used to signal the
667 * EXEC flag of user-space fence objects.
669 * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
673 struct drm_vmw_fence_signaled_arg {
678 __u32 signaled_flags;
682 /*************************************************************************/
684 * DRM_VMW_FENCE_UNREF
686 * Unreferences a fence object, and causes it to be destroyed if there are no
687 * other references to it.
692 * struct drm_vmw_fence_arg
694 * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
696 * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
699 struct drm_vmw_fence_arg {
705 /*************************************************************************/
707 * DRM_VMW_FENCE_EVENT
709 * Queues an event on a fence to be delivered on the drm character device
710 * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
711 * Optionally the approximate time when the fence signaled is
712 * given by the event.
718 #define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
720 struct drm_vmw_event_fence {
721 struct drm_event base;
728 * Flags that may be given to the command.
730 /* Request fence signaled time on the event. */
731 #define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
734 * struct drm_vmw_fence_event_arg
736 * @fence_rep: Pointer to fence_rep structure cast to __u64 or 0 if
737 * the fence is not supposed to be referenced by user-space.
738 * @user_info: Info to be delivered with the event.
739 * @handle: Attach the event to this fence only.
740 * @flags: A set of flags as defined above.
742 struct drm_vmw_fence_event_arg {
750 /*************************************************************************/
754 * Executes an SVGA present on a given fb for a given surface. The surface
755 * is placed on the framebuffer. Cliprects are given relative to the given
756 * point (the point disignated by dest_{x|y}).
761 * struct drm_vmw_present_arg
762 * @fb_id: framebuffer id to present / read back from.
763 * @sid: Surface id to present from.
764 * @dest_x: X placement coordinate for surface.
765 * @dest_y: Y placement coordinate for surface.
766 * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
767 * @num_clips: Number of cliprects given relative to the framebuffer origin,
768 * in the same coordinate space as the frame buffer.
769 * @pad64: Unused 64-bit padding.
771 * Input argument to the DRM_VMW_PRESENT ioctl.
774 struct drm_vmw_present_arg {
785 /*************************************************************************/
787 * DRM_VMW_PRESENT_READBACK
789 * Executes an SVGA present readback from a given fb to the dma buffer
790 * currently bound as the fb. If there is no dma buffer bound to the fb,
791 * an error will be returned.
796 * struct drm_vmw_present_arg
797 * @fb_id: fb_id to present / read back from.
798 * @num_clips: Number of cliprects.
799 * @clips_ptr: Pointer to an array of clip rects cast to an __u64.
800 * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an __u64.
801 * If this member is NULL, then the ioctl should not return a fence.
804 struct drm_vmw_present_readback_arg {
811 /*************************************************************************/
813 * DRM_VMW_UPDATE_LAYOUT - Update layout
815 * Updates the preferred modes and connection status for connectors. The
816 * command consists of one drm_vmw_update_layout_arg pointing to an array
817 * of num_outputs drm_vmw_rect's.
821 * struct drm_vmw_update_layout_arg
823 * @num_outputs: number of active connectors
824 * @rects: pointer to array of drm_vmw_rect cast to an __u64
826 * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
828 struct drm_vmw_update_layout_arg {
835 /*************************************************************************/
837 * DRM_VMW_CREATE_SHADER - Create shader
839 * Creates a shader and optionally binds it to a dma buffer containing
840 * the shader byte-code.
844 * enum drm_vmw_shader_type - Shader types
846 enum drm_vmw_shader_type {
847 drm_vmw_shader_type_vs = 0,
848 drm_vmw_shader_type_ps,
853 * struct drm_vmw_shader_create_arg
855 * @shader_type: Shader type of the shader to create.
856 * @size: Size of the byte-code in bytes.
857 * where the shader byte-code starts
858 * @buffer_handle: Buffer handle identifying the buffer containing the
860 * @shader_handle: On successful completion contains a handle that
861 * can be used to subsequently identify the shader.
862 * @offset: Offset in bytes into the buffer given by @buffer_handle,
864 * Input / Output argument to the DRM_VMW_CREATE_SHADER Ioctl.
866 struct drm_vmw_shader_create_arg {
867 enum drm_vmw_shader_type shader_type;
874 /*************************************************************************/
876 * DRM_VMW_UNREF_SHADER - Unreferences a shader
878 * Destroys a user-space reference to a shader, optionally destroying
883 * struct drm_vmw_shader_arg
885 * @handle: Handle identifying the shader to destroy.
887 * Input argument to the DRM_VMW_UNREF_SHADER ioctl.
889 struct drm_vmw_shader_arg {
894 /*************************************************************************/
896 * DRM_VMW_GB_SURFACE_CREATE - Create a host guest-backed surface.
898 * Allocates a surface handle and queues a create surface command
899 * for the host on the first use of the surface. The surface ID can
900 * be used as the surface ID in commands referencing the surface.
904 * enum drm_vmw_surface_flags
906 * @drm_vmw_surface_flag_shareable: Deprecated - all userspace surfaces are
908 * @drm_vmw_surface_flag_scanout: Whether the surface is a scanout
910 * @drm_vmw_surface_flag_create_buffer: Create a backup buffer if none is
912 * @drm_vmw_surface_flag_coherent: Back surface with coherent memory.
914 enum drm_vmw_surface_flags {
915 drm_vmw_surface_flag_shareable = (1 << 0),
916 drm_vmw_surface_flag_scanout = (1 << 1),
917 drm_vmw_surface_flag_create_buffer = (1 << 2),
918 drm_vmw_surface_flag_coherent = (1 << 3),
922 * struct drm_vmw_gb_surface_create_req
924 * @svga3d_flags: SVGA3d surface flags for the device.
925 * @format: SVGA3d format.
926 * @mip_level: Number of mip levels for all faces.
927 * @drm_surface_flags Flags as described above.
928 * @multisample_count Future use. Set to 0.
929 * @autogen_filter Future use. Set to 0.
930 * @buffer_handle Buffer handle of backup buffer. SVGA3D_INVALID_ID
932 * @base_size Size of the base mip level for all faces.
933 * @array_size Must be zero for non-DX hardware, and if non-zero
934 * svga3d_flags must have proper bind flags setup.
936 * Input argument to the DRM_VMW_GB_SURFACE_CREATE Ioctl.
937 * Part of output argument for the DRM_VMW_GB_SURFACE_REF Ioctl.
939 struct drm_vmw_gb_surface_create_req {
943 enum drm_vmw_surface_flags drm_surface_flags;
944 __u32 multisample_count;
945 __u32 autogen_filter;
948 struct drm_vmw_size base_size;
952 * struct drm_vmw_gb_surface_create_rep
954 * @handle: Surface handle.
955 * @backup_size: Size of backup buffers for this surface.
956 * @buffer_handle: Handle of backup buffer. SVGA3D_INVALID_ID if none.
957 * @buffer_size: Actual size of the buffer identified by
959 * @buffer_map_handle: Offset into device address space for the buffer
960 * identified by @buffer_handle.
962 * Part of output argument for the DRM_VMW_GB_SURFACE_REF ioctl.
963 * Output argument for the DRM_VMW_GB_SURFACE_CREATE ioctl.
965 struct drm_vmw_gb_surface_create_rep {
970 __u64 buffer_map_handle;
974 * union drm_vmw_gb_surface_create_arg
976 * @req: Input argument as described above.
977 * @rep: Output argument as described above.
979 * Argument to the DRM_VMW_GB_SURFACE_CREATE ioctl.
981 union drm_vmw_gb_surface_create_arg {
982 struct drm_vmw_gb_surface_create_rep rep;
983 struct drm_vmw_gb_surface_create_req req;
986 /*************************************************************************/
988 * DRM_VMW_GB_SURFACE_REF - Reference a host surface.
990 * Puts a reference on a host surface with a given handle, as previously
991 * returned by the DRM_VMW_GB_SURFACE_CREATE ioctl.
992 * A reference will make sure the surface isn't destroyed while we hold
993 * it and will allow the calling client to use the surface handle in
994 * the command stream.
996 * On successful return, the Ioctl returns the surface information given
997 * to and returned from the DRM_VMW_GB_SURFACE_CREATE ioctl.
1001 * struct drm_vmw_gb_surface_reference_arg
1003 * @creq: The data used as input when the surface was created, as described
1004 * above at "struct drm_vmw_gb_surface_create_req"
1005 * @crep: Additional data output when the surface was created, as described
1006 * above at "struct drm_vmw_gb_surface_create_rep"
1008 * Output Argument to the DRM_VMW_GB_SURFACE_REF ioctl.
1010 struct drm_vmw_gb_surface_ref_rep {
1011 struct drm_vmw_gb_surface_create_req creq;
1012 struct drm_vmw_gb_surface_create_rep crep;
1016 * union drm_vmw_gb_surface_reference_arg
1018 * @req: Input data as described above at "struct drm_vmw_surface_arg"
1019 * @rep: Output data as described above at "struct drm_vmw_gb_surface_ref_rep"
1021 * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
1023 union drm_vmw_gb_surface_reference_arg {
1024 struct drm_vmw_gb_surface_ref_rep rep;
1025 struct drm_vmw_surface_arg req;
1029 /*************************************************************************/
1031 * DRM_VMW_SYNCCPU - Sync a DMA buffer / MOB for CPU access.
1033 * Idles any previously submitted GPU operations on the buffer and
1034 * by default blocks command submissions that reference the buffer.
1035 * If the file descriptor used to grab a blocking CPU sync is closed, the
1036 * cpu sync is released.
1037 * The flags argument indicates how the grab / release operation should be
1042 * enum drm_vmw_synccpu_flags - Synccpu flags:
1044 * @drm_vmw_synccpu_read: Sync for read. If sync is done for read only, it's a
1045 * hint to the kernel to allow command submissions that references the buffer
1047 * @drm_vmw_synccpu_write: Sync for write. Block all command submissions
1048 * referencing this buffer.
1049 * @drm_vmw_synccpu_dontblock: Dont wait for GPU idle, but rather return
1050 * -EBUSY should the buffer be busy.
1051 * @drm_vmw_synccpu_allow_cs: Allow command submission that touches the buffer
1052 * while the buffer is synced for CPU. This is similar to the GEM bo idle
1055 enum drm_vmw_synccpu_flags {
1056 drm_vmw_synccpu_read = (1 << 0),
1057 drm_vmw_synccpu_write = (1 << 1),
1058 drm_vmw_synccpu_dontblock = (1 << 2),
1059 drm_vmw_synccpu_allow_cs = (1 << 3)
1063 * enum drm_vmw_synccpu_op - Synccpu operations:
1065 * @drm_vmw_synccpu_grab: Grab the buffer for CPU operations
1066 * @drm_vmw_synccpu_release: Release a previous grab.
1068 enum drm_vmw_synccpu_op {
1069 drm_vmw_synccpu_grab,
1070 drm_vmw_synccpu_release
1074 * struct drm_vmw_synccpu_arg
1076 * @op: The synccpu operation as described above.
1077 * @handle: Handle identifying the buffer object.
1078 * @flags: Flags as described above.
1080 struct drm_vmw_synccpu_arg {
1081 enum drm_vmw_synccpu_op op;
1082 enum drm_vmw_synccpu_flags flags;
1087 /*************************************************************************/
1089 * DRM_VMW_CREATE_EXTENDED_CONTEXT - Create a host context.
1091 * Allocates a device unique context id, and queues a create context command
1092 * for the host. Does not wait for host completion.
1094 enum drm_vmw_extended_context {
1095 drm_vmw_context_legacy,
1100 * union drm_vmw_extended_context_arg
1102 * @req: Context type.
1103 * @rep: Context identifier.
1105 * Argument to the DRM_VMW_CREATE_EXTENDED_CONTEXT Ioctl.
1107 union drm_vmw_extended_context_arg {
1108 enum drm_vmw_extended_context req;
1109 struct drm_vmw_context_arg rep;
1112 /*************************************************************************/
1114 * DRM_VMW_HANDLE_CLOSE - Close a user-space handle and release its
1115 * underlying resource.
1117 * Note that this ioctl is overlaid on the deprecated DRM_VMW_UNREF_DMABUF
1122 * struct drm_vmw_handle_close_arg
1124 * @handle: Handle to close.
1126 * Argument to the DRM_VMW_HANDLE_CLOSE Ioctl.
1128 struct drm_vmw_handle_close_arg {
1132 #define drm_vmw_unref_dmabuf_arg drm_vmw_handle_close_arg
1134 /*************************************************************************/
1136 * DRM_VMW_GB_SURFACE_CREATE_EXT - Create a host guest-backed surface.
1138 * Allocates a surface handle and queues a create surface command
1139 * for the host on the first use of the surface. The surface ID can
1140 * be used as the surface ID in commands referencing the surface.
1142 * This new command extends DRM_VMW_GB_SURFACE_CREATE by adding version
1143 * parameter and 64 bit svga flag.
1147 * enum drm_vmw_surface_version
1149 * @drm_vmw_surface_gb_v1: Corresponds to current gb surface format with
1150 * svga3d surface flags split into 2, upper half and lower half.
1152 enum drm_vmw_surface_version {
1153 drm_vmw_gb_surface_v1,
1157 * struct drm_vmw_gb_surface_create_ext_req
1159 * @base: Surface create parameters.
1160 * @version: Version of surface create ioctl.
1161 * @svga3d_flags_upper_32_bits: Upper 32 bits of svga3d flags.
1162 * @multisample_pattern: Multisampling pattern when msaa is supported.
1163 * @quality_level: Precision settings for each sample.
1164 * @buffer_byte_stride: Buffer byte stride.
1165 * @must_be_zero: Reserved for future usage.
1167 * Input argument to the DRM_VMW_GB_SURFACE_CREATE_EXT Ioctl.
1168 * Part of output argument for the DRM_VMW_GB_SURFACE_REF_EXT Ioctl.
1170 struct drm_vmw_gb_surface_create_ext_req {
1171 struct drm_vmw_gb_surface_create_req base;
1172 enum drm_vmw_surface_version version;
1173 __u32 svga3d_flags_upper_32_bits;
1174 __u32 multisample_pattern;
1175 __u32 quality_level;
1176 __u32 buffer_byte_stride;
1181 * union drm_vmw_gb_surface_create_ext_arg
1183 * @req: Input argument as described above.
1184 * @rep: Output argument as described above.
1186 * Argument to the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1188 union drm_vmw_gb_surface_create_ext_arg {
1189 struct drm_vmw_gb_surface_create_rep rep;
1190 struct drm_vmw_gb_surface_create_ext_req req;
1193 /*************************************************************************/
1195 * DRM_VMW_GB_SURFACE_REF_EXT - Reference a host surface.
1197 * Puts a reference on a host surface with a given handle, as previously
1198 * returned by the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1199 * A reference will make sure the surface isn't destroyed while we hold
1200 * it and will allow the calling client to use the surface handle in
1201 * the command stream.
1203 * On successful return, the Ioctl returns the surface information given
1204 * to and returned from the DRM_VMW_GB_SURFACE_CREATE_EXT ioctl.
1208 * struct drm_vmw_gb_surface_ref_ext_rep
1210 * @creq: The data used as input when the surface was created, as described
1211 * above at "struct drm_vmw_gb_surface_create_ext_req"
1212 * @crep: Additional data output when the surface was created, as described
1213 * above at "struct drm_vmw_gb_surface_create_rep"
1215 * Output Argument to the DRM_VMW_GB_SURFACE_REF_EXT ioctl.
1217 struct drm_vmw_gb_surface_ref_ext_rep {
1218 struct drm_vmw_gb_surface_create_ext_req creq;
1219 struct drm_vmw_gb_surface_create_rep crep;
1223 * union drm_vmw_gb_surface_reference_ext_arg
1225 * @req: Input data as described above at "struct drm_vmw_surface_arg"
1226 * @rep: Output data as described above at
1227 * "struct drm_vmw_gb_surface_ref_ext_rep"
1229 * Argument to the DRM_VMW_GB_SURFACE_REF Ioctl.
1231 union drm_vmw_gb_surface_reference_ext_arg {
1232 struct drm_vmw_gb_surface_ref_ext_rep rep;
1233 struct drm_vmw_surface_arg req;
1237 * struct drm_vmw_msg_arg
1239 * @send: Pointer to user-space msg string (null terminated).
1240 * @receive: Pointer to user-space receive buffer.
1241 * @send_only: Boolean whether this is only sending or receiving too.
1243 * Argument to the DRM_VMW_MSG ioctl.
1245 struct drm_vmw_msg_arg {
1253 * struct drm_vmw_mksstat_add_arg
1255 * @stat: Pointer to user-space stat-counters array, page-aligned.
1256 * @info: Pointer to user-space counter-infos array, page-aligned.
1257 * @strs: Pointer to user-space stat strings, page-aligned.
1258 * @stat_len: Length in bytes of stat-counters array.
1259 * @info_len: Length in bytes of counter-infos array.
1260 * @strs_len: Length in bytes of the stat strings, terminators included.
1261 * @description: Pointer to instance descriptor string; will be truncated
1262 * to MKS_GUEST_STAT_INSTANCE_DESC_LENGTH chars.
1263 * @id: Output identifier of the produced record; -1 if error.
1265 * Argument to the DRM_VMW_MKSSTAT_ADD ioctl.
1267 struct drm_vmw_mksstat_add_arg {
1279 * struct drm_vmw_mksstat_remove_arg
1281 * @id: Identifier of the record being disposed, originally obtained through
1282 * DRM_VMW_MKSSTAT_ADD ioctl.
1284 * Argument to the DRM_VMW_MKSSTAT_REMOVE ioctl.
1286 struct drm_vmw_mksstat_remove_arg {
1290 #if defined(__cplusplus)