13bfa90b6Smrg/**************************************************************************
23bfa90b6Smrg *
33bfa90b6Smrg * Copyright © 2009 VMware, Inc., Palo Alto, CA., USA
43bfa90b6Smrg * All Rights Reserved.
53bfa90b6Smrg *
63bfa90b6Smrg * Permission is hereby granted, free of charge, to any person obtaining a
73bfa90b6Smrg * copy of this software and associated documentation files (the
83bfa90b6Smrg * "Software"), to deal in the Software without restriction, including
93bfa90b6Smrg * without limitation the rights to use, copy, modify, merge, publish,
103bfa90b6Smrg * distribute, sub license, and/or sell copies of the Software, and to
113bfa90b6Smrg * permit persons to whom the Software is furnished to do so, subject to
123bfa90b6Smrg * the following conditions:
133bfa90b6Smrg *
143bfa90b6Smrg * The above copyright notice and this permission notice (including the
153bfa90b6Smrg * next paragraph) shall be included in all copies or substantial portions
163bfa90b6Smrg * of the Software.
173bfa90b6Smrg *
183bfa90b6Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
193bfa90b6Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
203bfa90b6Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
213bfa90b6Smrg * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM,
223bfa90b6Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
233bfa90b6Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
243bfa90b6Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
253bfa90b6Smrg *
263bfa90b6Smrg **************************************************************************/
273bfa90b6Smrg
283bfa90b6Smrg#ifndef __VMWGFX_DRM_H__
293bfa90b6Smrg#define __VMWGFX_DRM_H__
303bfa90b6Smrg#include <drm.h>
313bfa90b6Smrg
323bfa90b6Smrg#define DRM_VMW_MAX_SURFACE_FACES 6
333bfa90b6Smrg#define DRM_VMW_MAX_MIP_LEVELS 24
343bfa90b6Smrg
353bfa90b6Smrg
363bfa90b6Smrg#define DRM_VMW_GET_PARAM            0
373bfa90b6Smrg#define DRM_VMW_ALLOC_DMABUF         1
383bfa90b6Smrg#define DRM_VMW_UNREF_DMABUF         2
393bfa90b6Smrg#define DRM_VMW_CURSOR_BYPASS        3
403bfa90b6Smrg/* guarded by DRM_VMW_PARAM_NUM_STREAMS != 0*/
413bfa90b6Smrg#define DRM_VMW_CONTROL_STREAM       4
423bfa90b6Smrg#define DRM_VMW_CLAIM_STREAM         5
433bfa90b6Smrg#define DRM_VMW_UNREF_STREAM         6
443bfa90b6Smrg/* guarded by DRM_VMW_PARAM_3D == 1 */
453bfa90b6Smrg#define DRM_VMW_CREATE_CONTEXT       7
463bfa90b6Smrg#define DRM_VMW_UNREF_CONTEXT        8
473bfa90b6Smrg#define DRM_VMW_CREATE_SURFACE       9
483bfa90b6Smrg#define DRM_VMW_UNREF_SURFACE        10
493bfa90b6Smrg#define DRM_VMW_REF_SURFACE          11
503bfa90b6Smrg#define DRM_VMW_EXECBUF              12
513bfa90b6Smrg#define DRM_VMW_GET_3D_CAP           13
523bfa90b6Smrg#define DRM_VMW_FENCE_WAIT           14
533bfa90b6Smrg#define DRM_VMW_FENCE_SIGNALED       15
543bfa90b6Smrg#define DRM_VMW_FENCE_UNREF          16
553bfa90b6Smrg#define DRM_VMW_FENCE_EVENT          17
563bfa90b6Smrg#define DRM_VMW_PRESENT              18
573bfa90b6Smrg#define DRM_VMW_PRESENT_READBACK     19
583bfa90b6Smrg#define DRM_VMW_UPDATE_LAYOUT        20
593bfa90b6Smrg
603bfa90b6Smrg/*************************************************************************/
613bfa90b6Smrg/**
623bfa90b6Smrg * DRM_VMW_GET_PARAM - get device information.
633bfa90b6Smrg *
643bfa90b6Smrg * DRM_VMW_PARAM_FIFO_OFFSET:
653bfa90b6Smrg * Offset to use to map the first page of the FIFO read-only.
663bfa90b6Smrg * The fifo is mapped using the mmap() system call on the drm device.
673bfa90b6Smrg *
683bfa90b6Smrg * DRM_VMW_PARAM_OVERLAY_IOCTL:
693bfa90b6Smrg * Does the driver support the overlay ioctl.
703bfa90b6Smrg */
713bfa90b6Smrg
723bfa90b6Smrg#define DRM_VMW_PARAM_NUM_STREAMS      0
733bfa90b6Smrg#define DRM_VMW_PARAM_NUM_FREE_STREAMS 1
743bfa90b6Smrg#define DRM_VMW_PARAM_3D               2
753bfa90b6Smrg#define DRM_VMW_PARAM_HW_CAPS          3
763bfa90b6Smrg#define DRM_VMW_PARAM_FIFO_CAPS        4
773bfa90b6Smrg#define DRM_VMW_PARAM_MAX_FB_SIZE      5
783bfa90b6Smrg#define DRM_VMW_PARAM_FIFO_HW_VERSION  6
7934a0776dSmrg#define DRM_VMW_PARAM_SCREEN_TARGET    11
803bfa90b6Smrg
813bfa90b6Smrg/**
823bfa90b6Smrg * struct drm_vmw_getparam_arg
833bfa90b6Smrg *
843bfa90b6Smrg * @value: Returned value. //Out
853bfa90b6Smrg * @param: Parameter to query. //In.
863bfa90b6Smrg *
873bfa90b6Smrg * Argument to the DRM_VMW_GET_PARAM Ioctl.
883bfa90b6Smrg */
893bfa90b6Smrg
903bfa90b6Smrgstruct drm_vmw_getparam_arg {
913bfa90b6Smrg	uint64_t value;
923bfa90b6Smrg	uint32_t param;
933bfa90b6Smrg	uint32_t pad64;
943bfa90b6Smrg};
953bfa90b6Smrg
963bfa90b6Smrg/*************************************************************************/
973bfa90b6Smrg/**
983bfa90b6Smrg * DRM_VMW_CREATE_CONTEXT - Create a host context.
993bfa90b6Smrg *
1003bfa90b6Smrg * Allocates a device unique context id, and queues a create context command
1013bfa90b6Smrg * for the host. Does not wait for host completion.
1023bfa90b6Smrg */
1033bfa90b6Smrg
1043bfa90b6Smrg/**
1053bfa90b6Smrg * struct drm_vmw_context_arg
1063bfa90b6Smrg *
1073bfa90b6Smrg * @cid: Device unique context ID.
1083bfa90b6Smrg *
1093bfa90b6Smrg * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
1103bfa90b6Smrg * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
1113bfa90b6Smrg */
1123bfa90b6Smrg
1133bfa90b6Smrgstruct drm_vmw_context_arg {
1143bfa90b6Smrg	int32_t cid;
1153bfa90b6Smrg	uint32_t pad64;
1163bfa90b6Smrg};
1173bfa90b6Smrg
1183bfa90b6Smrg/*************************************************************************/
1193bfa90b6Smrg/**
1203bfa90b6Smrg * DRM_VMW_UNREF_CONTEXT - Create a host context.
1213bfa90b6Smrg *
1223bfa90b6Smrg * Frees a global context id, and queues a destroy host command for the host.
1233bfa90b6Smrg * Does not wait for host completion. The context ID can be used directly
1243bfa90b6Smrg * in the command stream and shows up as the same context ID on the host.
1253bfa90b6Smrg */
1263bfa90b6Smrg
1273bfa90b6Smrg/*************************************************************************/
1283bfa90b6Smrg/**
1293bfa90b6Smrg * DRM_VMW_CREATE_SURFACE - Create a host suface.
1303bfa90b6Smrg *
1313bfa90b6Smrg * Allocates a device unique surface id, and queues a create surface command
1323bfa90b6Smrg * for the host. Does not wait for host completion. The surface ID can be
1333bfa90b6Smrg * used directly in the command stream and shows up as the same surface
1343bfa90b6Smrg * ID on the host.
1353bfa90b6Smrg */
1363bfa90b6Smrg
1373bfa90b6Smrg/**
1383bfa90b6Smrg * struct drm_wmv_surface_create_req
1393bfa90b6Smrg *
1403bfa90b6Smrg * @flags: Surface flags as understood by the host.
1413bfa90b6Smrg * @format: Surface format as understood by the host.
1423bfa90b6Smrg * @mip_levels: Number of mip levels for each face.
1433bfa90b6Smrg * An unused face should have 0 encoded.
1443bfa90b6Smrg * @size_addr: Address of a user-space array of sruct drm_vmw_size
1453bfa90b6Smrg * cast to an uint64_t for 32-64 bit compatibility.
1463bfa90b6Smrg * The size of the array should equal the total number of mipmap levels.
1473bfa90b6Smrg * @shareable: Boolean whether other clients (as identified by file descriptors)
1483bfa90b6Smrg * may reference this surface.
1493bfa90b6Smrg * @scanout: Boolean whether the surface is intended to be used as a
1503bfa90b6Smrg * scanout.
1513bfa90b6Smrg *
1523bfa90b6Smrg * Input data to the DRM_VMW_CREATE_SURFACE Ioctl.
1533bfa90b6Smrg * Output data from the DRM_VMW_REF_SURFACE Ioctl.
1543bfa90b6Smrg */
1553bfa90b6Smrg
1563bfa90b6Smrgstruct drm_vmw_surface_create_req {
1573bfa90b6Smrg	uint32_t flags;
1583bfa90b6Smrg	uint32_t format;
1593bfa90b6Smrg	uint32_t mip_levels[DRM_VMW_MAX_SURFACE_FACES];
1603bfa90b6Smrg	uint64_t size_addr;
1613bfa90b6Smrg	int32_t shareable;
1623bfa90b6Smrg	int32_t scanout;
1633bfa90b6Smrg};
1643bfa90b6Smrg
1653bfa90b6Smrg/**
1663bfa90b6Smrg * struct drm_wmv_surface_arg
1673bfa90b6Smrg *
1683bfa90b6Smrg * @sid: Surface id of created surface or surface to destroy or reference.
1693bfa90b6Smrg *
1703bfa90b6Smrg * Output data from the DRM_VMW_CREATE_SURFACE Ioctl.
1713bfa90b6Smrg * Input argument to the DRM_VMW_UNREF_SURFACE Ioctl.
1723bfa90b6Smrg * Input argument to the DRM_VMW_REF_SURFACE Ioctl.
1733bfa90b6Smrg */
1743bfa90b6Smrg
1753bfa90b6Smrgstruct drm_vmw_surface_arg {
1763bfa90b6Smrg	int32_t sid;
1773bfa90b6Smrg	uint32_t pad64;
1783bfa90b6Smrg};
1793bfa90b6Smrg
1803bfa90b6Smrg/**
1813bfa90b6Smrg * struct drm_vmw_size ioctl.
1823bfa90b6Smrg *
1833bfa90b6Smrg * @width - mip level width
1843bfa90b6Smrg * @height - mip level height
1853bfa90b6Smrg * @depth - mip level depth
1863bfa90b6Smrg *
1873bfa90b6Smrg * Description of a mip level.
1883bfa90b6Smrg * Input data to the DRM_WMW_CREATE_SURFACE Ioctl.
1893bfa90b6Smrg */
1903bfa90b6Smrg
1913bfa90b6Smrgstruct drm_vmw_size {
1923bfa90b6Smrg	uint32_t width;
1933bfa90b6Smrg	uint32_t height;
1943bfa90b6Smrg	uint32_t depth;
1953bfa90b6Smrg	uint32_t pad64;
1963bfa90b6Smrg};
1973bfa90b6Smrg
1983bfa90b6Smrg/**
1993bfa90b6Smrg * union drm_vmw_surface_create_arg
2003bfa90b6Smrg *
2013bfa90b6Smrg * @rep: Output data as described above.
2023bfa90b6Smrg * @req: Input data as described above.
2033bfa90b6Smrg *
2043bfa90b6Smrg * Argument to the DRM_VMW_CREATE_SURFACE Ioctl.
2053bfa90b6Smrg */
2063bfa90b6Smrg
2073bfa90b6Smrgunion drm_vmw_surface_create_arg {
2083bfa90b6Smrg	struct drm_vmw_surface_arg rep;
2093bfa90b6Smrg	struct drm_vmw_surface_create_req req;
2103bfa90b6Smrg};
2113bfa90b6Smrg
2123bfa90b6Smrg/*************************************************************************/
2133bfa90b6Smrg/**
2143bfa90b6Smrg * DRM_VMW_REF_SURFACE - Reference a host surface.
2153bfa90b6Smrg *
2163bfa90b6Smrg * Puts a reference on a host surface with a give sid, as previously
2173bfa90b6Smrg * returned by the DRM_VMW_CREATE_SURFACE ioctl.
2183bfa90b6Smrg * A reference will make sure the surface isn't destroyed while we hold
2193bfa90b6Smrg * it and will allow the calling client to use the surface ID in the command
2203bfa90b6Smrg * stream.
2213bfa90b6Smrg *
2223bfa90b6Smrg * On successful return, the Ioctl returns the surface information given
2233bfa90b6Smrg * in the DRM_VMW_CREATE_SURFACE ioctl.
2243bfa90b6Smrg */
2253bfa90b6Smrg
2263bfa90b6Smrg/**
2273bfa90b6Smrg * union drm_vmw_surface_reference_arg
2283bfa90b6Smrg *
2293bfa90b6Smrg * @rep: Output data as described above.
2303bfa90b6Smrg * @req: Input data as described above.
2313bfa90b6Smrg *
2323bfa90b6Smrg * Argument to the DRM_VMW_REF_SURFACE Ioctl.
2333bfa90b6Smrg */
2343bfa90b6Smrg
2353bfa90b6Smrgunion drm_vmw_surface_reference_arg {
2363bfa90b6Smrg	struct drm_vmw_surface_create_req rep;
2373bfa90b6Smrg	struct drm_vmw_surface_arg req;
2383bfa90b6Smrg};
2393bfa90b6Smrg
2403bfa90b6Smrg/*************************************************************************/
2413bfa90b6Smrg/**
2423bfa90b6Smrg * DRM_VMW_UNREF_SURFACE - Unreference a host surface.
2433bfa90b6Smrg *
2443bfa90b6Smrg * Clear a reference previously put on a host surface.
2453bfa90b6Smrg * When all references are gone, including the one implicitly placed
2463bfa90b6Smrg * on creation,
2473bfa90b6Smrg * a destroy surface command will be queued for the host.
2483bfa90b6Smrg * Does not wait for completion.
2493bfa90b6Smrg */
2503bfa90b6Smrg
2513bfa90b6Smrg/*************************************************************************/
2523bfa90b6Smrg/**
2533bfa90b6Smrg * DRM_VMW_EXECBUF
2543bfa90b6Smrg *
2553bfa90b6Smrg * Submit a command buffer for execution on the host, and return a
2563bfa90b6Smrg * fence seqno that when signaled, indicates that the command buffer has
2573bfa90b6Smrg * executed.
2583bfa90b6Smrg */
2593bfa90b6Smrg
2603bfa90b6Smrg/**
2613bfa90b6Smrg * struct drm_vmw_execbuf_arg
2623bfa90b6Smrg *
2633bfa90b6Smrg * @commands: User-space address of a command buffer cast to an uint64_t.
2643bfa90b6Smrg * @command-size: Size in bytes of the command buffer.
2653bfa90b6Smrg * @throttle-us: Sleep until software is less than @throttle_us
2663bfa90b6Smrg * microseconds ahead of hardware. The driver may round this value
2673bfa90b6Smrg * to the nearest kernel tick.
2683bfa90b6Smrg * @fence_rep: User-space address of a struct drm_vmw_fence_rep cast to an
2693bfa90b6Smrg * uint64_t.
2703bfa90b6Smrg * @version: Allows expanding the execbuf ioctl parameters without breaking
2713bfa90b6Smrg * backwards compatibility, since user-space will always tell the kernel
2723bfa90b6Smrg * which version it uses.
2733bfa90b6Smrg * @flags: Execbuf flags. None currently.
2743bfa90b6Smrg *
2753bfa90b6Smrg * Argument to the DRM_VMW_EXECBUF Ioctl.
2763bfa90b6Smrg */
2773bfa90b6Smrg
2783bfa90b6Smrg#define DRM_VMW_EXECBUF_VERSION 1
2793bfa90b6Smrg
2803bfa90b6Smrgstruct drm_vmw_execbuf_arg {
2813bfa90b6Smrg	uint64_t commands;
2823bfa90b6Smrg	uint32_t command_size;
2833bfa90b6Smrg	uint32_t throttle_us;
2843bfa90b6Smrg	uint64_t fence_rep;
2853bfa90b6Smrg	uint32_t version;
2863bfa90b6Smrg	uint32_t flags;
2873bfa90b6Smrg};
2883bfa90b6Smrg
2893bfa90b6Smrg/**
2903bfa90b6Smrg * struct drm_vmw_fence_rep
2913bfa90b6Smrg *
2923bfa90b6Smrg * @handle: Fence object handle for fence associated with a command submission.
2933bfa90b6Smrg * @mask: Fence flags relevant for this fence object.
2943bfa90b6Smrg * @seqno: Fence sequence number in fifo. A fence object with a lower
2953bfa90b6Smrg * seqno will signal the EXEC flag before a fence object with a higher
2963bfa90b6Smrg * seqno. This can be used by user-space to avoid kernel calls to determine
2973bfa90b6Smrg * whether a fence has signaled the EXEC flag. Note that @seqno will
2983bfa90b6Smrg * wrap at 32-bit.
2993bfa90b6Smrg * @passed_seqno: The highest seqno number processed by the hardware
3003bfa90b6Smrg * so far. This can be used to mark user-space fence objects as signaled, and
3013bfa90b6Smrg * to determine whether a fence seqno might be stale.
3023bfa90b6Smrg * @error: This member should've been set to -EFAULT on submission.
3033bfa90b6Smrg * The following actions should be take on completion:
3043bfa90b6Smrg * error == -EFAULT: Fence communication failed. The host is synchronized.
3053bfa90b6Smrg * Use the last fence id read from the FIFO fence register.
3063bfa90b6Smrg * error != 0 && error != -EFAULT:
3073bfa90b6Smrg * Fence submission failed. The host is synchronized. Use the fence_seq member.
3083bfa90b6Smrg * error == 0: All is OK, The host may not be synchronized.
3093bfa90b6Smrg * Use the fence_seq member.
3103bfa90b6Smrg *
3113bfa90b6Smrg * Input / Output data to the DRM_VMW_EXECBUF Ioctl.
3123bfa90b6Smrg */
3133bfa90b6Smrg
3143bfa90b6Smrgstruct drm_vmw_fence_rep {
3153bfa90b6Smrg	uint32_t handle;
3163bfa90b6Smrg	uint32_t mask;
3173bfa90b6Smrg	uint32_t seqno;
3183bfa90b6Smrg	uint32_t passed_seqno;
3193bfa90b6Smrg	uint32_t pad64;
3203bfa90b6Smrg	int32_t error;
3213bfa90b6Smrg};
3223bfa90b6Smrg
3233bfa90b6Smrg/*************************************************************************/
3243bfa90b6Smrg/**
3253bfa90b6Smrg * DRM_VMW_ALLOC_DMABUF
3263bfa90b6Smrg *
3273bfa90b6Smrg * Allocate a DMA buffer that is visible also to the host.
3283bfa90b6Smrg * NOTE: The buffer is
3293bfa90b6Smrg * identified by a handle and an offset, which are private to the guest, but
3303bfa90b6Smrg * useable in the command stream. The guest kernel may translate these
3313bfa90b6Smrg * and patch up the command stream accordingly. In the future, the offset may
3323bfa90b6Smrg * be zero at all times, or it may disappear from the interface before it is
3333bfa90b6Smrg * fixed.
3343bfa90b6Smrg *
3353bfa90b6Smrg * The DMA buffer may stay user-space mapped in the guest at all times,
3363bfa90b6Smrg * and is thus suitable for sub-allocation.
3373bfa90b6Smrg *
3383bfa90b6Smrg * DMA buffers are mapped using the mmap() syscall on the drm device.
3393bfa90b6Smrg */
3403bfa90b6Smrg
3413bfa90b6Smrg/**
3423bfa90b6Smrg * struct drm_vmw_alloc_dmabuf_req
3433bfa90b6Smrg *
3443bfa90b6Smrg * @size: Required minimum size of the buffer.
3453bfa90b6Smrg *
3463bfa90b6Smrg * Input data to the DRM_VMW_ALLOC_DMABUF Ioctl.
3473bfa90b6Smrg */
3483bfa90b6Smrg
3493bfa90b6Smrgstruct drm_vmw_alloc_dmabuf_req {
3503bfa90b6Smrg	uint32_t size;
3513bfa90b6Smrg	uint32_t pad64;
3523bfa90b6Smrg};
3533bfa90b6Smrg
3543bfa90b6Smrg/**
3553bfa90b6Smrg * struct drm_vmw_dmabuf_rep
3563bfa90b6Smrg *
3573bfa90b6Smrg * @map_handle: Offset to use in the mmap() call used to map the buffer.
3583bfa90b6Smrg * @handle: Handle unique to this buffer. Used for unreferencing.
3593bfa90b6Smrg * @cur_gmr_id: GMR id to use in the command stream when this buffer is
3603bfa90b6Smrg * referenced. See not above.
3613bfa90b6Smrg * @cur_gmr_offset: Offset to use in the command stream when this buffer is
3623bfa90b6Smrg * referenced. See note above.
3633bfa90b6Smrg *
3643bfa90b6Smrg * Output data from the DRM_VMW_ALLOC_DMABUF Ioctl.
3653bfa90b6Smrg */
3663bfa90b6Smrg
3673bfa90b6Smrgstruct drm_vmw_dmabuf_rep {
3683bfa90b6Smrg	uint64_t map_handle;
3693bfa90b6Smrg	uint32_t handle;
3703bfa90b6Smrg	uint32_t cur_gmr_id;
3713bfa90b6Smrg	uint32_t cur_gmr_offset;
3723bfa90b6Smrg	uint32_t pad64;
3733bfa90b6Smrg};
3743bfa90b6Smrg
3753bfa90b6Smrg/**
3763bfa90b6Smrg * union drm_vmw_dmabuf_arg
3773bfa90b6Smrg *
3783bfa90b6Smrg * @req: Input data as described above.
3793bfa90b6Smrg * @rep: Output data as described above.
3803bfa90b6Smrg *
3813bfa90b6Smrg * Argument to the DRM_VMW_ALLOC_DMABUF Ioctl.
3823bfa90b6Smrg */
3833bfa90b6Smrg
3843bfa90b6Smrgunion drm_vmw_alloc_dmabuf_arg {
3853bfa90b6Smrg	struct drm_vmw_alloc_dmabuf_req req;
3863bfa90b6Smrg	struct drm_vmw_dmabuf_rep rep;
3873bfa90b6Smrg};
3883bfa90b6Smrg
3893bfa90b6Smrg/*************************************************************************/
3903bfa90b6Smrg/**
3913bfa90b6Smrg * DRM_VMW_UNREF_DMABUF - Free a DMA buffer.
3923bfa90b6Smrg *
3933bfa90b6Smrg */
3943bfa90b6Smrg
3953bfa90b6Smrg/**
3963bfa90b6Smrg * struct drm_vmw_unref_dmabuf_arg
3973bfa90b6Smrg *
3983bfa90b6Smrg * @handle: Handle indicating what buffer to free. Obtained from the
3993bfa90b6Smrg * DRM_VMW_ALLOC_DMABUF Ioctl.
4003bfa90b6Smrg *
4013bfa90b6Smrg * Argument to the DRM_VMW_UNREF_DMABUF Ioctl.
4023bfa90b6Smrg */
4033bfa90b6Smrg
4043bfa90b6Smrgstruct drm_vmw_unref_dmabuf_arg {
4053bfa90b6Smrg	uint32_t handle;
4063bfa90b6Smrg	uint32_t pad64;
4073bfa90b6Smrg};
4083bfa90b6Smrg
4093bfa90b6Smrg/*************************************************************************/
4103bfa90b6Smrg/**
4113bfa90b6Smrg * DRM_VMW_CONTROL_STREAM - Control overlays, aka streams.
4123bfa90b6Smrg *
4133bfa90b6Smrg * This IOCTL controls the overlay units of the svga device.
4143bfa90b6Smrg * The SVGA overlay units does not work like regular hardware units in
4153bfa90b6Smrg * that they do not automaticaly read back the contents of the given dma
4163bfa90b6Smrg * buffer. But instead only read back for each call to this ioctl, and
4173bfa90b6Smrg * at any point between this call being made and a following call that
4183bfa90b6Smrg * either changes the buffer or disables the stream.
4193bfa90b6Smrg */
4203bfa90b6Smrg
4213bfa90b6Smrg/**
4223bfa90b6Smrg * struct drm_vmw_rect
4233bfa90b6Smrg *
4243bfa90b6Smrg * Defines a rectangle. Used in the overlay ioctl to define
4253bfa90b6Smrg * source and destination rectangle.
4263bfa90b6Smrg */
4273bfa90b6Smrg
4283bfa90b6Smrgstruct drm_vmw_rect {
4293bfa90b6Smrg	int32_t x;
4303bfa90b6Smrg	int32_t y;
4313bfa90b6Smrg	uint32_t w;
4323bfa90b6Smrg	uint32_t h;
4333bfa90b6Smrg};
4343bfa90b6Smrg
4353bfa90b6Smrg/**
4363bfa90b6Smrg * struct drm_vmw_control_stream_arg
4373bfa90b6Smrg *
4383bfa90b6Smrg * @stream_id: Stearm to control
4393bfa90b6Smrg * @enabled: If false all following arguments are ignored.
4403bfa90b6Smrg * @handle: Handle to buffer for getting data from.
4413bfa90b6Smrg * @format: Format of the overlay as understood by the host.
4423bfa90b6Smrg * @width: Width of the overlay.
4433bfa90b6Smrg * @height: Height of the overlay.
4443bfa90b6Smrg * @size: Size of the overlay in bytes.
4453bfa90b6Smrg * @pitch: Array of pitches, the two last are only used for YUV12 formats.
4463bfa90b6Smrg * @offset: Offset from start of dma buffer to overlay.
4473bfa90b6Smrg * @src: Source rect, must be within the defined area above.
4483bfa90b6Smrg * @dst: Destination rect, x and y may be negative.
4493bfa90b6Smrg *
4503bfa90b6Smrg * Argument to the DRM_VMW_CONTROL_STREAM Ioctl.
4513bfa90b6Smrg */
4523bfa90b6Smrg
4533bfa90b6Smrgstruct drm_vmw_control_stream_arg {
4543bfa90b6Smrg	uint32_t stream_id;
4553bfa90b6Smrg	uint32_t enabled;
4563bfa90b6Smrg
4573bfa90b6Smrg	uint32_t flags;
4583bfa90b6Smrg	uint32_t color_key;
4593bfa90b6Smrg
4603bfa90b6Smrg	uint32_t handle;
4613bfa90b6Smrg	uint32_t offset;
4623bfa90b6Smrg	int32_t format;
4633bfa90b6Smrg	uint32_t size;
4643bfa90b6Smrg	uint32_t width;
4653bfa90b6Smrg	uint32_t height;
4663bfa90b6Smrg	uint32_t pitch[3];
4673bfa90b6Smrg
4683bfa90b6Smrg	uint32_t pad64;
4693bfa90b6Smrg	struct drm_vmw_rect src;
4703bfa90b6Smrg	struct drm_vmw_rect dst;
4713bfa90b6Smrg};
4723bfa90b6Smrg
4733bfa90b6Smrg/*************************************************************************/
4743bfa90b6Smrg/**
4753bfa90b6Smrg * DRM_VMW_CURSOR_BYPASS - Give extra information about cursor bypass.
4763bfa90b6Smrg *
4773bfa90b6Smrg */
4783bfa90b6Smrg
4793bfa90b6Smrg#define DRM_VMW_CURSOR_BYPASS_ALL    (1 << 0)
4803bfa90b6Smrg#define DRM_VMW_CURSOR_BYPASS_FLAGS       (1)
4813bfa90b6Smrg
4823bfa90b6Smrg/**
4833bfa90b6Smrg * struct drm_vmw_cursor_bypass_arg
4843bfa90b6Smrg *
4853bfa90b6Smrg * @flags: Flags.
4863bfa90b6Smrg * @crtc_id: Crtc id, only used if DMR_CURSOR_BYPASS_ALL isn't passed.
4873bfa90b6Smrg * @xpos: X position of cursor.
4883bfa90b6Smrg * @ypos: Y position of cursor.
4893bfa90b6Smrg * @xhot: X hotspot.
4903bfa90b6Smrg * @yhot: Y hotspot.
4913bfa90b6Smrg *
4923bfa90b6Smrg * Argument to the DRM_VMW_CURSOR_BYPASS Ioctl.
4933bfa90b6Smrg */
4943bfa90b6Smrg
4953bfa90b6Smrgstruct drm_vmw_cursor_bypass_arg {
4963bfa90b6Smrg	uint32_t flags;
4973bfa90b6Smrg	uint32_t crtc_id;
4983bfa90b6Smrg	int32_t xpos;
4993bfa90b6Smrg	int32_t ypos;
5003bfa90b6Smrg	int32_t xhot;
5013bfa90b6Smrg	int32_t yhot;
5023bfa90b6Smrg};
5033bfa90b6Smrg
5043bfa90b6Smrg/*************************************************************************/
5053bfa90b6Smrg/**
5063bfa90b6Smrg * DRM_VMW_CLAIM_STREAM - Claim a single stream.
5073bfa90b6Smrg */
5083bfa90b6Smrg
5093bfa90b6Smrg/**
5103bfa90b6Smrg * struct drm_vmw_context_arg
5113bfa90b6Smrg *
5123bfa90b6Smrg * @stream_id: Device unique context ID.
5133bfa90b6Smrg *
5143bfa90b6Smrg * Output argument to the DRM_VMW_CREATE_CONTEXT Ioctl.
5153bfa90b6Smrg * Input argument to the DRM_VMW_UNREF_CONTEXT Ioctl.
5163bfa90b6Smrg */
5173bfa90b6Smrg
5183bfa90b6Smrgstruct drm_vmw_stream_arg {
5193bfa90b6Smrg	uint32_t stream_id;
5203bfa90b6Smrg	uint32_t pad64;
5213bfa90b6Smrg};
5223bfa90b6Smrg
5233bfa90b6Smrg/*************************************************************************/
5243bfa90b6Smrg/**
5253bfa90b6Smrg * DRM_VMW_UNREF_STREAM - Unclaim a stream.
5263bfa90b6Smrg *
5273bfa90b6Smrg * Return a single stream that was claimed by this process. Also makes
5283bfa90b6Smrg * sure that the stream has been stopped.
5293bfa90b6Smrg */
5303bfa90b6Smrg
5313bfa90b6Smrg/*************************************************************************/
5323bfa90b6Smrg/**
5333bfa90b6Smrg * DRM_VMW_GET_3D_CAP
5343bfa90b6Smrg *
5353bfa90b6Smrg * Read 3D capabilities from the FIFO
5363bfa90b6Smrg *
5373bfa90b6Smrg */
5383bfa90b6Smrg
5393bfa90b6Smrg/**
5403bfa90b6Smrg * struct drm_vmw_get_3d_cap_arg
5413bfa90b6Smrg *
5423bfa90b6Smrg * @buffer: Pointer to a buffer for capability data, cast to an uint64_t
5433bfa90b6Smrg * @size: Max size to copy
5443bfa90b6Smrg *
5453bfa90b6Smrg * Input argument to the DRM_VMW_GET_3D_CAP_IOCTL
5463bfa90b6Smrg * ioctls.
5473bfa90b6Smrg */
5483bfa90b6Smrg
5493bfa90b6Smrgstruct drm_vmw_get_3d_cap_arg {
5503bfa90b6Smrg	uint64_t buffer;
5513bfa90b6Smrg	uint32_t max_size;
5523bfa90b6Smrg	uint32_t pad64;
5533bfa90b6Smrg};
5543bfa90b6Smrg
5553bfa90b6Smrg
5563bfa90b6Smrg/*************************************************************************/
5573bfa90b6Smrg/**
5583bfa90b6Smrg * DRM_VMW_FENCE_WAIT
5593bfa90b6Smrg *
5603bfa90b6Smrg * Waits for a fence object to signal. The wait is interruptible, so that
5613bfa90b6Smrg * signals may be delivered during the interrupt. The wait may timeout,
5623bfa90b6Smrg * in which case the calls returns -EBUSY. If the wait is restarted,
5633bfa90b6Smrg * that is restarting without resetting @cookie_valid to zero,
5643bfa90b6Smrg * the timeout is computed from the first call.
5653bfa90b6Smrg *
5663bfa90b6Smrg * The flags argument to the DRM_VMW_FENCE_WAIT ioctl indicates what to wait
5673bfa90b6Smrg * on:
5683bfa90b6Smrg * DRM_VMW_FENCE_FLAG_EXEC: All commands ahead of the fence in the command
5693bfa90b6Smrg * stream
5703bfa90b6Smrg * have executed.
5713bfa90b6Smrg * DRM_VMW_FENCE_FLAG_QUERY: All query results resulting from query finish
5723bfa90b6Smrg * commands
5733bfa90b6Smrg * in the buffer given to the EXECBUF ioctl returning the fence object handle
5743bfa90b6Smrg * are available to user-space.
5753bfa90b6Smrg *
5763bfa90b6Smrg * DRM_VMW_WAIT_OPTION_UNREF: If this wait option is given, and the
5773bfa90b6Smrg * fenc wait ioctl returns 0, the fence object has been unreferenced after
5783bfa90b6Smrg * the wait.
5793bfa90b6Smrg */
5803bfa90b6Smrg
5813bfa90b6Smrg#define DRM_VMW_FENCE_FLAG_EXEC   (1 << 0)
5823bfa90b6Smrg#define DRM_VMW_FENCE_FLAG_QUERY  (1 << 1)
5833bfa90b6Smrg
5843bfa90b6Smrg#define DRM_VMW_WAIT_OPTION_UNREF (1 << 0)
5853bfa90b6Smrg
5863bfa90b6Smrg/**
5873bfa90b6Smrg * struct drm_vmw_fence_wait_arg
5883bfa90b6Smrg *
5893bfa90b6Smrg * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
5903bfa90b6Smrg * @cookie_valid: Must be reset to 0 on first call. Left alone on restart.
5913bfa90b6Smrg * @kernel_cookie: Set to 0 on first call. Left alone on restart.
5923bfa90b6Smrg * @timeout_us: Wait timeout in microseconds. 0 for indefinite timeout.
5933bfa90b6Smrg * @lazy: Set to 1 if timing is not critical. Allow more than a kernel tick
5943bfa90b6Smrg * before returning.
5953bfa90b6Smrg * @flags: Fence flags to wait on.
5963bfa90b6Smrg * @wait_options: Options that control the behaviour of the wait ioctl.
5973bfa90b6Smrg *
5983bfa90b6Smrg * Input argument to the DRM_VMW_FENCE_WAIT ioctl.
5993bfa90b6Smrg */
6003bfa90b6Smrg
6013bfa90b6Smrgstruct drm_vmw_fence_wait_arg {
6023bfa90b6Smrg	uint32_t handle;
6033bfa90b6Smrg	int32_t  cookie_valid;
6043bfa90b6Smrg	uint64_t kernel_cookie;
6053bfa90b6Smrg	uint64_t timeout_us;
6063bfa90b6Smrg	int32_t lazy;
6073bfa90b6Smrg	int32_t flags;
6083bfa90b6Smrg	int32_t wait_options;
6093bfa90b6Smrg	int32_t pad64;
6103bfa90b6Smrg};
6113bfa90b6Smrg
6123bfa90b6Smrg/*************************************************************************/
6133bfa90b6Smrg/**
6143bfa90b6Smrg * DRM_VMW_FENCE_SIGNALED
6153bfa90b6Smrg *
6163bfa90b6Smrg * Checks if a fence object is signaled..
6173bfa90b6Smrg */
6183bfa90b6Smrg
6193bfa90b6Smrg/**
6203bfa90b6Smrg * struct drm_vmw_fence_signaled_arg
6213bfa90b6Smrg *
6223bfa90b6Smrg * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
6233bfa90b6Smrg * @flags: Fence object flags input to DRM_VMW_FENCE_SIGNALED ioctl
6243bfa90b6Smrg * @signaled: Out: Flags signaled.
6253bfa90b6Smrg * @sequence: Out: Highest sequence passed so far. Can be used to signal the
6263bfa90b6Smrg * EXEC flag of user-space fence objects.
6273bfa90b6Smrg *
6283bfa90b6Smrg * Input/Output argument to the DRM_VMW_FENCE_SIGNALED and DRM_VMW_FENCE_UNREF
6293bfa90b6Smrg * ioctls.
6303bfa90b6Smrg */
6313bfa90b6Smrg
6323bfa90b6Smrgstruct drm_vmw_fence_signaled_arg {
6333bfa90b6Smrg	 uint32_t handle;
6343bfa90b6Smrg	 uint32_t flags;
6353bfa90b6Smrg	 int32_t signaled;
6363bfa90b6Smrg	 uint32_t passed_seqno;
6373bfa90b6Smrg	 uint32_t signaled_flags;
6383bfa90b6Smrg	 uint32_t pad64;
6393bfa90b6Smrg};
6403bfa90b6Smrg
6413bfa90b6Smrg/*************************************************************************/
6423bfa90b6Smrg/**
6433bfa90b6Smrg * DRM_VMW_FENCE_UNREF
6443bfa90b6Smrg *
6453bfa90b6Smrg * Unreferences a fence object, and causes it to be destroyed if there are no
6463bfa90b6Smrg * other references to it.
6473bfa90b6Smrg *
6483bfa90b6Smrg */
6493bfa90b6Smrg
6503bfa90b6Smrg/**
6513bfa90b6Smrg * struct drm_vmw_fence_arg
6523bfa90b6Smrg *
6533bfa90b6Smrg * @handle: Fence object handle as returned by the DRM_VMW_EXECBUF ioctl.
6543bfa90b6Smrg *
6553bfa90b6Smrg * Input/Output argument to the DRM_VMW_FENCE_UNREF ioctl..
6563bfa90b6Smrg */
6573bfa90b6Smrg
6583bfa90b6Smrgstruct drm_vmw_fence_arg {
6593bfa90b6Smrg	 uint32_t handle;
6603bfa90b6Smrg	 uint32_t pad64;
6613bfa90b6Smrg};
6623bfa90b6Smrg
6633bfa90b6Smrg
6643bfa90b6Smrg/*************************************************************************/
6653bfa90b6Smrg/**
6663bfa90b6Smrg * DRM_VMW_FENCE_EVENT
6673bfa90b6Smrg *
6683bfa90b6Smrg * Queues an event on a fence to be delivered on the drm character device
6693bfa90b6Smrg * when the fence has signaled the DRM_VMW_FENCE_FLAG_EXEC flag.
6703bfa90b6Smrg * Optionally the approximate time when the fence signaled is
6713bfa90b6Smrg * given by the event.
6723bfa90b6Smrg */
6733bfa90b6Smrg
6743bfa90b6Smrg/*
6753bfa90b6Smrg * The event type
6763bfa90b6Smrg */
6773bfa90b6Smrg#define DRM_VMW_EVENT_FENCE_SIGNALED 0x80000000
6783bfa90b6Smrg
6793bfa90b6Smrgstruct drm_vmw_event_fence {
6803bfa90b6Smrg	struct drm_event base;
6813bfa90b6Smrg	uint64_t user_data;
6823bfa90b6Smrg	uint32_t tv_sec;
6833bfa90b6Smrg	uint32_t tv_usec;
6843bfa90b6Smrg};
6853bfa90b6Smrg
6863bfa90b6Smrg/*
6873bfa90b6Smrg * Flags that may be given to the command.
6883bfa90b6Smrg */
6893bfa90b6Smrg/* Request fence signaled time on the event. */
6903bfa90b6Smrg#define DRM_VMW_FE_FLAG_REQ_TIME (1 << 0)
6913bfa90b6Smrg
6923bfa90b6Smrg/**
6933bfa90b6Smrg * struct drm_vmw_fence_event_arg
6943bfa90b6Smrg *
6953bfa90b6Smrg * @fence_rep: Pointer to fence_rep structure cast to uint64_t or 0 if
6963bfa90b6Smrg * the fence is not supposed to be referenced by user-space.
6973bfa90b6Smrg * @user_info: Info to be delivered with the event.
6983bfa90b6Smrg * @handle: Attach the event to this fence only.
6993bfa90b6Smrg * @flags: A set of flags as defined above.
7003bfa90b6Smrg */
7013bfa90b6Smrgstruct drm_vmw_fence_event_arg {
7023bfa90b6Smrg	uint64_t fence_rep;
7033bfa90b6Smrg	uint64_t user_data;
7043bfa90b6Smrg	uint32_t handle;
7053bfa90b6Smrg	uint32_t flags;
7063bfa90b6Smrg};
7073bfa90b6Smrg
7083bfa90b6Smrg
7093bfa90b6Smrg/*************************************************************************/
7103bfa90b6Smrg/**
7113bfa90b6Smrg * DRM_VMW_PRESENT
7123bfa90b6Smrg *
7133bfa90b6Smrg * Executes an SVGA present on a given fb for a given surface. The surface
7143bfa90b6Smrg * is placed on the framebuffer. Cliprects are given relative to the given
7153bfa90b6Smrg * point (the point disignated by dest_{x|y}).
7163bfa90b6Smrg *
7173bfa90b6Smrg */
7183bfa90b6Smrg
7193bfa90b6Smrg/**
7203bfa90b6Smrg * struct drm_vmw_present_arg
7213bfa90b6Smrg * @fb_id: framebuffer id to present / read back from.
7223bfa90b6Smrg * @sid: Surface id to present from.
7233bfa90b6Smrg * @dest_x: X placement coordinate for surface.
7243bfa90b6Smrg * @dest_y: Y placement coordinate for surface.
7253bfa90b6Smrg * @clips_ptr: Pointer to an array of clip rects cast to an uint64_t.
7263bfa90b6Smrg * @num_clips: Number of cliprects given relative to the framebuffer origin,
7273bfa90b6Smrg * in the same coordinate space as the frame buffer.
7283bfa90b6Smrg * @pad64: Unused 64-bit padding.
7293bfa90b6Smrg *
7303bfa90b6Smrg * Input argument to the DRM_VMW_PRESENT ioctl.
7313bfa90b6Smrg */
7323bfa90b6Smrg
7333bfa90b6Smrgstruct drm_vmw_present_arg {
7343bfa90b6Smrg	uint32_t fb_id;
7353bfa90b6Smrg	uint32_t sid;
7363bfa90b6Smrg	int32_t dest_x;
7373bfa90b6Smrg	int32_t dest_y;
7383bfa90b6Smrg	uint64_t clips_ptr;
7393bfa90b6Smrg	uint32_t num_clips;
7403bfa90b6Smrg	uint32_t pad64;
7413bfa90b6Smrg};
7423bfa90b6Smrg
7433bfa90b6Smrg
7443bfa90b6Smrg/*************************************************************************/
7453bfa90b6Smrg/**
7463bfa90b6Smrg * DRM_VMW_PRESENT_READBACK
7473bfa90b6Smrg *
7483bfa90b6Smrg * Executes an SVGA present readback from a given fb to the dma buffer
7493bfa90b6Smrg * currently bound as the fb. If there is no dma buffer bound to the fb,
7503bfa90b6Smrg * an error will be returned.
7513bfa90b6Smrg *
7523bfa90b6Smrg */
7533bfa90b6Smrg
7543bfa90b6Smrg/**
7553bfa90b6Smrg * struct drm_vmw_present_arg
7563bfa90b6Smrg * @fb_id: fb_id to present / read back from.
7573bfa90b6Smrg * @num_clips: Number of cliprects.
7583bfa90b6Smrg * @clips_ptr: Pointer to an array of clip rects cast to an uint64_t.
7593bfa90b6Smrg * @fence_rep: Pointer to a struct drm_vmw_fence_rep, cast to an uint64_t.
7603bfa90b6Smrg * If this member is NULL, then the ioctl should not return a fence.
7613bfa90b6Smrg */
7623bfa90b6Smrg
7633bfa90b6Smrgstruct drm_vmw_present_readback_arg {
7643bfa90b6Smrg	 uint32_t fb_id;
7653bfa90b6Smrg	 uint32_t num_clips;
7663bfa90b6Smrg	 uint64_t clips_ptr;
7673bfa90b6Smrg	 uint64_t fence_rep;
7683bfa90b6Smrg};
7693bfa90b6Smrg
7703bfa90b6Smrg/*************************************************************************/
7713bfa90b6Smrg/**
7723bfa90b6Smrg * DRM_VMW_UPDATE_LAYOUT - Update layout
7733bfa90b6Smrg *
7743bfa90b6Smrg * Updates the preferred modes and connection status for connectors. The
7753bfa90b6Smrg * command consists of one drm_vmw_update_layout_arg pointing to an array
7763bfa90b6Smrg * of num_outputs drm_vmw_rect's.
7773bfa90b6Smrg */
7783bfa90b6Smrg
7793bfa90b6Smrg/**
7803bfa90b6Smrg * struct drm_vmw_update_layout_arg
7813bfa90b6Smrg *
7823bfa90b6Smrg * @num_outputs: number of active connectors
7833bfa90b6Smrg * @rects: pointer to array of drm_vmw_rect cast to an uint64_t
7843bfa90b6Smrg *
7853bfa90b6Smrg * Input argument to the DRM_VMW_UPDATE_LAYOUT Ioctl.
7863bfa90b6Smrg */
7873bfa90b6Smrgstruct drm_vmw_update_layout_arg {
7883bfa90b6Smrg	uint32_t num_outputs;
7893bfa90b6Smrg	uint32_t pad64;
7903bfa90b6Smrg	uint64_t rects;
7913bfa90b6Smrg};
7923bfa90b6Smrg
7933bfa90b6Smrg#endif
794