drm.h revision 01e04c3f
101e04c3fSmrg/**
201e04c3fSmrg * \file drm.h
301e04c3fSmrg * Header for the Direct Rendering Manager
401e04c3fSmrg *
501e04c3fSmrg * \author Rickard E. (Rik) Faith <faith@valinux.com>
601e04c3fSmrg *
701e04c3fSmrg * \par Acknowledgments:
801e04c3fSmrg * Dec 1999, Richard Henderson <rth@twiddle.net>, move to generic \c cmpxchg.
901e04c3fSmrg */
1001e04c3fSmrg
1101e04c3fSmrg/*
1201e04c3fSmrg * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
1301e04c3fSmrg * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
1401e04c3fSmrg * All rights reserved.
1501e04c3fSmrg *
1601e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
1701e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
1801e04c3fSmrg * to deal in the Software without restriction, including without limitation
1901e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
2001e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
2101e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
2201e04c3fSmrg *
2301e04c3fSmrg * The above copyright notice and this permission notice (including the next
2401e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
2501e04c3fSmrg * Software.
2601e04c3fSmrg *
2701e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2801e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2901e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
3001e04c3fSmrg * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
3101e04c3fSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
3201e04c3fSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
3301e04c3fSmrg * OTHER DEALINGS IN THE SOFTWARE.
3401e04c3fSmrg */
3501e04c3fSmrg
3601e04c3fSmrg#ifndef _DRM_H_
3701e04c3fSmrg#define _DRM_H_
3801e04c3fSmrg
3901e04c3fSmrg#if   defined(__linux__)
4001e04c3fSmrg
4101e04c3fSmrg#include <linux/types.h>
4201e04c3fSmrg#include <asm/ioctl.h>
4301e04c3fSmrgtypedef unsigned int drm_handle_t;
4401e04c3fSmrg
4501e04c3fSmrg#else /* One of the BSDs */
4601e04c3fSmrg
4701e04c3fSmrg#include <sys/ioccom.h>
4801e04c3fSmrg#include <sys/types.h>
4901e04c3fSmrgtypedef int8_t   __s8;
5001e04c3fSmrgtypedef uint8_t  __u8;
5101e04c3fSmrgtypedef int16_t  __s16;
5201e04c3fSmrgtypedef uint16_t __u16;
5301e04c3fSmrgtypedef int32_t  __s32;
5401e04c3fSmrgtypedef uint32_t __u32;
5501e04c3fSmrgtypedef int64_t  __s64;
5601e04c3fSmrgtypedef uint64_t __u64;
5701e04c3fSmrgtypedef size_t   __kernel_size_t;
5801e04c3fSmrgtypedef unsigned long drm_handle_t;
5901e04c3fSmrg
6001e04c3fSmrg#endif
6101e04c3fSmrg
6201e04c3fSmrg#if defined(__cplusplus)
6301e04c3fSmrgextern "C" {
6401e04c3fSmrg#endif
6501e04c3fSmrg
6601e04c3fSmrg#define DRM_NAME	"drm"	  /**< Name in kernel, /dev, and /proc */
6701e04c3fSmrg#define DRM_MIN_ORDER	5	  /**< At least 2^5 bytes = 32 bytes */
6801e04c3fSmrg#define DRM_MAX_ORDER	22	  /**< Up to 2^22 bytes = 4MB */
6901e04c3fSmrg#define DRM_RAM_PERCENT 10	  /**< How much system ram can we lock? */
7001e04c3fSmrg
7101e04c3fSmrg#define _DRM_LOCK_HELD	0x80000000U /**< Hardware lock is held */
7201e04c3fSmrg#define _DRM_LOCK_CONT	0x40000000U /**< Hardware lock is contended */
7301e04c3fSmrg#define _DRM_LOCK_IS_HELD(lock)	   ((lock) & _DRM_LOCK_HELD)
7401e04c3fSmrg#define _DRM_LOCK_IS_CONT(lock)	   ((lock) & _DRM_LOCK_CONT)
7501e04c3fSmrg#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
7601e04c3fSmrg
7701e04c3fSmrgtypedef unsigned int drm_context_t;
7801e04c3fSmrgtypedef unsigned int drm_drawable_t;
7901e04c3fSmrgtypedef unsigned int drm_magic_t;
8001e04c3fSmrg
8101e04c3fSmrg/**
8201e04c3fSmrg * Cliprect.
8301e04c3fSmrg *
8401e04c3fSmrg * \warning: If you change this structure, make sure you change
8501e04c3fSmrg * XF86DRIClipRectRec in the server as well
8601e04c3fSmrg *
8701e04c3fSmrg * \note KW: Actually it's illegal to change either for
8801e04c3fSmrg * backwards-compatibility reasons.
8901e04c3fSmrg */
9001e04c3fSmrgstruct drm_clip_rect {
9101e04c3fSmrg	unsigned short x1;
9201e04c3fSmrg	unsigned short y1;
9301e04c3fSmrg	unsigned short x2;
9401e04c3fSmrg	unsigned short y2;
9501e04c3fSmrg};
9601e04c3fSmrg
9701e04c3fSmrg/**
9801e04c3fSmrg * Drawable information.
9901e04c3fSmrg */
10001e04c3fSmrgstruct drm_drawable_info {
10101e04c3fSmrg	unsigned int num_rects;
10201e04c3fSmrg	struct drm_clip_rect *rects;
10301e04c3fSmrg};
10401e04c3fSmrg
10501e04c3fSmrg/**
10601e04c3fSmrg * Texture region,
10701e04c3fSmrg */
10801e04c3fSmrgstruct drm_tex_region {
10901e04c3fSmrg	unsigned char next;
11001e04c3fSmrg	unsigned char prev;
11101e04c3fSmrg	unsigned char in_use;
11201e04c3fSmrg	unsigned char padding;
11301e04c3fSmrg	unsigned int age;
11401e04c3fSmrg};
11501e04c3fSmrg
11601e04c3fSmrg/**
11701e04c3fSmrg * Hardware lock.
11801e04c3fSmrg *
11901e04c3fSmrg * The lock structure is a simple cache-line aligned integer.  To avoid
12001e04c3fSmrg * processor bus contention on a multiprocessor system, there should not be any
12101e04c3fSmrg * other data stored in the same cache line.
12201e04c3fSmrg */
12301e04c3fSmrgstruct drm_hw_lock {
12401e04c3fSmrg	__volatile__ unsigned int lock;		/**< lock variable */
12501e04c3fSmrg	char padding[60];			/**< Pad to cache line */
12601e04c3fSmrg};
12701e04c3fSmrg
12801e04c3fSmrg/**
12901e04c3fSmrg * DRM_IOCTL_VERSION ioctl argument type.
13001e04c3fSmrg *
13101e04c3fSmrg * \sa drmGetVersion().
13201e04c3fSmrg */
13301e04c3fSmrgstruct drm_version {
13401e04c3fSmrg	int version_major;	  /**< Major version */
13501e04c3fSmrg	int version_minor;	  /**< Minor version */
13601e04c3fSmrg	int version_patchlevel;	  /**< Patch level */
13701e04c3fSmrg	__kernel_size_t name_len;	  /**< Length of name buffer */
13801e04c3fSmrg	char *name;	  /**< Name of driver */
13901e04c3fSmrg	__kernel_size_t date_len;	  /**< Length of date buffer */
14001e04c3fSmrg	char *date;	  /**< User-space buffer to hold date */
14101e04c3fSmrg	__kernel_size_t desc_len;	  /**< Length of desc buffer */
14201e04c3fSmrg	char *desc;	  /**< User-space buffer to hold desc */
14301e04c3fSmrg};
14401e04c3fSmrg
14501e04c3fSmrg/**
14601e04c3fSmrg * DRM_IOCTL_GET_UNIQUE ioctl argument type.
14701e04c3fSmrg *
14801e04c3fSmrg * \sa drmGetBusid() and drmSetBusId().
14901e04c3fSmrg */
15001e04c3fSmrgstruct drm_unique {
15101e04c3fSmrg	__kernel_size_t unique_len;	  /**< Length of unique */
15201e04c3fSmrg	char *unique;	  /**< Unique name for driver instantiation */
15301e04c3fSmrg};
15401e04c3fSmrg
15501e04c3fSmrgstruct drm_list {
15601e04c3fSmrg	int count;		  /**< Length of user-space structures */
15701e04c3fSmrg	struct drm_version *version;
15801e04c3fSmrg};
15901e04c3fSmrg
16001e04c3fSmrgstruct drm_block {
16101e04c3fSmrg	int unused;
16201e04c3fSmrg};
16301e04c3fSmrg
16401e04c3fSmrg/**
16501e04c3fSmrg * DRM_IOCTL_CONTROL ioctl argument type.
16601e04c3fSmrg *
16701e04c3fSmrg * \sa drmCtlInstHandler() and drmCtlUninstHandler().
16801e04c3fSmrg */
16901e04c3fSmrgstruct drm_control {
17001e04c3fSmrg	enum {
17101e04c3fSmrg		DRM_ADD_COMMAND,
17201e04c3fSmrg		DRM_RM_COMMAND,
17301e04c3fSmrg		DRM_INST_HANDLER,
17401e04c3fSmrg		DRM_UNINST_HANDLER
17501e04c3fSmrg	} func;
17601e04c3fSmrg	int irq;
17701e04c3fSmrg};
17801e04c3fSmrg
17901e04c3fSmrg/**
18001e04c3fSmrg * Type of memory to map.
18101e04c3fSmrg */
18201e04c3fSmrgenum drm_map_type {
18301e04c3fSmrg	_DRM_FRAME_BUFFER = 0,	  /**< WC (no caching), no core dump */
18401e04c3fSmrg	_DRM_REGISTERS = 1,	  /**< no caching, no core dump */
18501e04c3fSmrg	_DRM_SHM = 2,		  /**< shared, cached */
18601e04c3fSmrg	_DRM_AGP = 3,		  /**< AGP/GART */
18701e04c3fSmrg	_DRM_SCATTER_GATHER = 4,  /**< Scatter/gather memory for PCI DMA */
18801e04c3fSmrg	_DRM_CONSISTENT = 5	  /**< Consistent memory for PCI DMA */
18901e04c3fSmrg};
19001e04c3fSmrg
19101e04c3fSmrg/**
19201e04c3fSmrg * Memory mapping flags.
19301e04c3fSmrg */
19401e04c3fSmrgenum drm_map_flags {
19501e04c3fSmrg	_DRM_RESTRICTED = 0x01,	     /**< Cannot be mapped to user-virtual */
19601e04c3fSmrg	_DRM_READ_ONLY = 0x02,
19701e04c3fSmrg	_DRM_LOCKED = 0x04,	     /**< shared, cached, locked */
19801e04c3fSmrg	_DRM_KERNEL = 0x08,	     /**< kernel requires access */
19901e04c3fSmrg	_DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */
20001e04c3fSmrg	_DRM_CONTAINS_LOCK = 0x20,   /**< SHM page that contains lock */
20101e04c3fSmrg	_DRM_REMOVABLE = 0x40,	     /**< Removable mapping */
20201e04c3fSmrg	_DRM_DRIVER = 0x80	     /**< Managed by driver */
20301e04c3fSmrg};
20401e04c3fSmrg
20501e04c3fSmrgstruct drm_ctx_priv_map {
20601e04c3fSmrg	unsigned int ctx_id;	 /**< Context requesting private mapping */
20701e04c3fSmrg	void *handle;		 /**< Handle of map */
20801e04c3fSmrg};
20901e04c3fSmrg
21001e04c3fSmrg/**
21101e04c3fSmrg * DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls
21201e04c3fSmrg * argument type.
21301e04c3fSmrg *
21401e04c3fSmrg * \sa drmAddMap().
21501e04c3fSmrg */
21601e04c3fSmrgstruct drm_map {
21701e04c3fSmrg	unsigned long offset;	 /**< Requested physical address (0 for SAREA)*/
21801e04c3fSmrg	unsigned long size;	 /**< Requested physical size (bytes) */
21901e04c3fSmrg	enum drm_map_type type;	 /**< Type of memory to map */
22001e04c3fSmrg	enum drm_map_flags flags;	 /**< Flags */
22101e04c3fSmrg	void *handle;		 /**< User-space: "Handle" to pass to mmap() */
22201e04c3fSmrg				 /**< Kernel-space: kernel-virtual address */
22301e04c3fSmrg	int mtrr;		 /**< MTRR slot used */
22401e04c3fSmrg	/*   Private data */
22501e04c3fSmrg};
22601e04c3fSmrg
22701e04c3fSmrg/**
22801e04c3fSmrg * DRM_IOCTL_GET_CLIENT ioctl argument type.
22901e04c3fSmrg */
23001e04c3fSmrgstruct drm_client {
23101e04c3fSmrg	int idx;		/**< Which client desired? */
23201e04c3fSmrg	int auth;		/**< Is client authenticated? */
23301e04c3fSmrg	unsigned long pid;	/**< Process ID */
23401e04c3fSmrg	unsigned long uid;	/**< User ID */
23501e04c3fSmrg	unsigned long magic;	/**< Magic */
23601e04c3fSmrg	unsigned long iocs;	/**< Ioctl count */
23701e04c3fSmrg};
23801e04c3fSmrg
23901e04c3fSmrgenum drm_stat_type {
24001e04c3fSmrg	_DRM_STAT_LOCK,
24101e04c3fSmrg	_DRM_STAT_OPENS,
24201e04c3fSmrg	_DRM_STAT_CLOSES,
24301e04c3fSmrg	_DRM_STAT_IOCTLS,
24401e04c3fSmrg	_DRM_STAT_LOCKS,
24501e04c3fSmrg	_DRM_STAT_UNLOCKS,
24601e04c3fSmrg	_DRM_STAT_VALUE,	/**< Generic value */
24701e04c3fSmrg	_DRM_STAT_BYTE,		/**< Generic byte counter (1024bytes/K) */
24801e04c3fSmrg	_DRM_STAT_COUNT,	/**< Generic non-byte counter (1000/k) */
24901e04c3fSmrg
25001e04c3fSmrg	_DRM_STAT_IRQ,		/**< IRQ */
25101e04c3fSmrg	_DRM_STAT_PRIMARY,	/**< Primary DMA bytes */
25201e04c3fSmrg	_DRM_STAT_SECONDARY,	/**< Secondary DMA bytes */
25301e04c3fSmrg	_DRM_STAT_DMA,		/**< DMA */
25401e04c3fSmrg	_DRM_STAT_SPECIAL,	/**< Special DMA (e.g., priority or polled) */
25501e04c3fSmrg	_DRM_STAT_MISSED	/**< Missed DMA opportunity */
25601e04c3fSmrg	    /* Add to the *END* of the list */
25701e04c3fSmrg};
25801e04c3fSmrg
25901e04c3fSmrg/**
26001e04c3fSmrg * DRM_IOCTL_GET_STATS ioctl argument type.
26101e04c3fSmrg */
26201e04c3fSmrgstruct drm_stats {
26301e04c3fSmrg	unsigned long count;
26401e04c3fSmrg	struct {
26501e04c3fSmrg		unsigned long value;
26601e04c3fSmrg		enum drm_stat_type type;
26701e04c3fSmrg	} data[15];
26801e04c3fSmrg};
26901e04c3fSmrg
27001e04c3fSmrg/**
27101e04c3fSmrg * Hardware locking flags.
27201e04c3fSmrg */
27301e04c3fSmrgenum drm_lock_flags {
27401e04c3fSmrg	_DRM_LOCK_READY = 0x01,	     /**< Wait until hardware is ready for DMA */
27501e04c3fSmrg	_DRM_LOCK_QUIESCENT = 0x02,  /**< Wait until hardware quiescent */
27601e04c3fSmrg	_DRM_LOCK_FLUSH = 0x04,	     /**< Flush this context's DMA queue first */
27701e04c3fSmrg	_DRM_LOCK_FLUSH_ALL = 0x08,  /**< Flush all DMA queues first */
27801e04c3fSmrg	/* These *HALT* flags aren't supported yet
27901e04c3fSmrg	   -- they will be used to support the
28001e04c3fSmrg	   full-screen DGA-like mode. */
28101e04c3fSmrg	_DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */
28201e04c3fSmrg	_DRM_HALT_CUR_QUEUES = 0x20  /**< Halt all current queues */
28301e04c3fSmrg};
28401e04c3fSmrg
28501e04c3fSmrg/**
28601e04c3fSmrg * DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.
28701e04c3fSmrg *
28801e04c3fSmrg * \sa drmGetLock() and drmUnlock().
28901e04c3fSmrg */
29001e04c3fSmrgstruct drm_lock {
29101e04c3fSmrg	int context;
29201e04c3fSmrg	enum drm_lock_flags flags;
29301e04c3fSmrg};
29401e04c3fSmrg
29501e04c3fSmrg/**
29601e04c3fSmrg * DMA flags
29701e04c3fSmrg *
29801e04c3fSmrg * \warning
29901e04c3fSmrg * These values \e must match xf86drm.h.
30001e04c3fSmrg *
30101e04c3fSmrg * \sa drm_dma.
30201e04c3fSmrg */
30301e04c3fSmrgenum drm_dma_flags {
30401e04c3fSmrg	/* Flags for DMA buffer dispatch */
30501e04c3fSmrg	_DRM_DMA_BLOCK = 0x01,	      /**<
30601e04c3fSmrg				       * Block until buffer dispatched.
30701e04c3fSmrg				       *
30801e04c3fSmrg				       * \note The buffer may not yet have
30901e04c3fSmrg				       * been processed by the hardware --
31001e04c3fSmrg				       * getting a hardware lock with the
31101e04c3fSmrg				       * hardware quiescent will ensure
31201e04c3fSmrg				       * that the buffer has been
31301e04c3fSmrg				       * processed.
31401e04c3fSmrg				       */
31501e04c3fSmrg	_DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */
31601e04c3fSmrg	_DRM_DMA_PRIORITY = 0x04,     /**< High priority dispatch */
31701e04c3fSmrg
31801e04c3fSmrg	/* Flags for DMA buffer request */
31901e04c3fSmrg	_DRM_DMA_WAIT = 0x10,	      /**< Wait for free buffers */
32001e04c3fSmrg	_DRM_DMA_SMALLER_OK = 0x20,   /**< Smaller-than-requested buffers OK */
32101e04c3fSmrg	_DRM_DMA_LARGER_OK = 0x40     /**< Larger-than-requested buffers OK */
32201e04c3fSmrg};
32301e04c3fSmrg
32401e04c3fSmrg/**
32501e04c3fSmrg * DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.
32601e04c3fSmrg *
32701e04c3fSmrg * \sa drmAddBufs().
32801e04c3fSmrg */
32901e04c3fSmrgstruct drm_buf_desc {
33001e04c3fSmrg	int count;		 /**< Number of buffers of this size */
33101e04c3fSmrg	int size;		 /**< Size in bytes */
33201e04c3fSmrg	int low_mark;		 /**< Low water mark */
33301e04c3fSmrg	int high_mark;		 /**< High water mark */
33401e04c3fSmrg	enum {
33501e04c3fSmrg		_DRM_PAGE_ALIGN = 0x01,	/**< Align on page boundaries for DMA */
33601e04c3fSmrg		_DRM_AGP_BUFFER = 0x02,	/**< Buffer is in AGP space */
33701e04c3fSmrg		_DRM_SG_BUFFER = 0x04,	/**< Scatter/gather memory buffer */
33801e04c3fSmrg		_DRM_FB_BUFFER = 0x08,	/**< Buffer is in frame buffer */
33901e04c3fSmrg		_DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */
34001e04c3fSmrg	} flags;
34101e04c3fSmrg	unsigned long agp_start; /**<
34201e04c3fSmrg				  * Start address of where the AGP buffers are
34301e04c3fSmrg				  * in the AGP aperture
34401e04c3fSmrg				  */
34501e04c3fSmrg};
34601e04c3fSmrg
34701e04c3fSmrg/**
34801e04c3fSmrg * DRM_IOCTL_INFO_BUFS ioctl argument type.
34901e04c3fSmrg */
35001e04c3fSmrgstruct drm_buf_info {
35101e04c3fSmrg	int count;		/**< Entries in list */
35201e04c3fSmrg	struct drm_buf_desc *list;
35301e04c3fSmrg};
35401e04c3fSmrg
35501e04c3fSmrg/**
35601e04c3fSmrg * DRM_IOCTL_FREE_BUFS ioctl argument type.
35701e04c3fSmrg */
35801e04c3fSmrgstruct drm_buf_free {
35901e04c3fSmrg	int count;
36001e04c3fSmrg	int *list;
36101e04c3fSmrg};
36201e04c3fSmrg
36301e04c3fSmrg/**
36401e04c3fSmrg * Buffer information
36501e04c3fSmrg *
36601e04c3fSmrg * \sa drm_buf_map.
36701e04c3fSmrg */
36801e04c3fSmrgstruct drm_buf_pub {
36901e04c3fSmrg	int idx;		       /**< Index into the master buffer list */
37001e04c3fSmrg	int total;		       /**< Buffer size */
37101e04c3fSmrg	int used;		       /**< Amount of buffer in use (for DMA) */
37201e04c3fSmrg	void *address;	       /**< Address of buffer */
37301e04c3fSmrg};
37401e04c3fSmrg
37501e04c3fSmrg/**
37601e04c3fSmrg * DRM_IOCTL_MAP_BUFS ioctl argument type.
37701e04c3fSmrg */
37801e04c3fSmrgstruct drm_buf_map {
37901e04c3fSmrg	int count;		/**< Length of the buffer list */
38001e04c3fSmrg#ifdef __cplusplus
38101e04c3fSmrg	void *virt;
38201e04c3fSmrg#else
38301e04c3fSmrg	void *virtual;		/**< Mmap'd area in user-virtual */
38401e04c3fSmrg#endif
38501e04c3fSmrg	struct drm_buf_pub *list;	/**< Buffer information */
38601e04c3fSmrg};
38701e04c3fSmrg
38801e04c3fSmrg/**
38901e04c3fSmrg * DRM_IOCTL_DMA ioctl argument type.
39001e04c3fSmrg *
39101e04c3fSmrg * Indices here refer to the offset into the buffer list in drm_buf_get.
39201e04c3fSmrg *
39301e04c3fSmrg * \sa drmDMA().
39401e04c3fSmrg */
39501e04c3fSmrgstruct drm_dma {
39601e04c3fSmrg	int context;			  /**< Context handle */
39701e04c3fSmrg	int send_count;			  /**< Number of buffers to send */
39801e04c3fSmrg	int *send_indices;	  /**< List of handles to buffers */
39901e04c3fSmrg	int *send_sizes;		  /**< Lengths of data to send */
40001e04c3fSmrg	enum drm_dma_flags flags;	  /**< Flags */
40101e04c3fSmrg	int request_count;		  /**< Number of buffers requested */
40201e04c3fSmrg	int request_size;		  /**< Desired size for buffers */
40301e04c3fSmrg	int *request_indices;	  /**< Buffer information */
40401e04c3fSmrg	int *request_sizes;
40501e04c3fSmrg	int granted_count;		  /**< Number of buffers granted */
40601e04c3fSmrg};
40701e04c3fSmrg
40801e04c3fSmrgenum drm_ctx_flags {
40901e04c3fSmrg	_DRM_CONTEXT_PRESERVED = 0x01,
41001e04c3fSmrg	_DRM_CONTEXT_2DONLY = 0x02
41101e04c3fSmrg};
41201e04c3fSmrg
41301e04c3fSmrg/**
41401e04c3fSmrg * DRM_IOCTL_ADD_CTX ioctl argument type.
41501e04c3fSmrg *
41601e04c3fSmrg * \sa drmCreateContext() and drmDestroyContext().
41701e04c3fSmrg */
41801e04c3fSmrgstruct drm_ctx {
41901e04c3fSmrg	drm_context_t handle;
42001e04c3fSmrg	enum drm_ctx_flags flags;
42101e04c3fSmrg};
42201e04c3fSmrg
42301e04c3fSmrg/**
42401e04c3fSmrg * DRM_IOCTL_RES_CTX ioctl argument type.
42501e04c3fSmrg */
42601e04c3fSmrgstruct drm_ctx_res {
42701e04c3fSmrg	int count;
42801e04c3fSmrg	struct drm_ctx *contexts;
42901e04c3fSmrg};
43001e04c3fSmrg
43101e04c3fSmrg/**
43201e04c3fSmrg * DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.
43301e04c3fSmrg */
43401e04c3fSmrgstruct drm_draw {
43501e04c3fSmrg	drm_drawable_t handle;
43601e04c3fSmrg};
43701e04c3fSmrg
43801e04c3fSmrg/**
43901e04c3fSmrg * DRM_IOCTL_UPDATE_DRAW ioctl argument type.
44001e04c3fSmrg */
44101e04c3fSmrgtypedef enum {
44201e04c3fSmrg	DRM_DRAWABLE_CLIPRECTS
44301e04c3fSmrg} drm_drawable_info_type_t;
44401e04c3fSmrg
44501e04c3fSmrgstruct drm_update_draw {
44601e04c3fSmrg	drm_drawable_t handle;
44701e04c3fSmrg	unsigned int type;
44801e04c3fSmrg	unsigned int num;
44901e04c3fSmrg	unsigned long long data;
45001e04c3fSmrg};
45101e04c3fSmrg
45201e04c3fSmrg/**
45301e04c3fSmrg * DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.
45401e04c3fSmrg */
45501e04c3fSmrgstruct drm_auth {
45601e04c3fSmrg	drm_magic_t magic;
45701e04c3fSmrg};
45801e04c3fSmrg
45901e04c3fSmrg/**
46001e04c3fSmrg * DRM_IOCTL_IRQ_BUSID ioctl argument type.
46101e04c3fSmrg *
46201e04c3fSmrg * \sa drmGetInterruptFromBusID().
46301e04c3fSmrg */
46401e04c3fSmrgstruct drm_irq_busid {
46501e04c3fSmrg	int irq;	/**< IRQ number */
46601e04c3fSmrg	int busnum;	/**< bus number */
46701e04c3fSmrg	int devnum;	/**< device number */
46801e04c3fSmrg	int funcnum;	/**< function number */
46901e04c3fSmrg};
47001e04c3fSmrg
47101e04c3fSmrgenum drm_vblank_seq_type {
47201e04c3fSmrg	_DRM_VBLANK_ABSOLUTE = 0x0,	/**< Wait for specific vblank sequence number */
47301e04c3fSmrg	_DRM_VBLANK_RELATIVE = 0x1,	/**< Wait for given number of vblanks */
47401e04c3fSmrg	/* bits 1-6 are reserved for high crtcs */
47501e04c3fSmrg	_DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,
47601e04c3fSmrg	_DRM_VBLANK_EVENT = 0x4000000,   /**< Send event instead of blocking */
47701e04c3fSmrg	_DRM_VBLANK_FLIP = 0x8000000,   /**< Scheduled buffer swap should flip */
47801e04c3fSmrg	_DRM_VBLANK_NEXTONMISS = 0x10000000,	/**< If missed, wait for next vblank */
47901e04c3fSmrg	_DRM_VBLANK_SECONDARY = 0x20000000,	/**< Secondary display controller */
48001e04c3fSmrg	_DRM_VBLANK_SIGNAL = 0x40000000	/**< Send signal instead of blocking, unsupported */
48101e04c3fSmrg};
48201e04c3fSmrg#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1
48301e04c3fSmrg
48401e04c3fSmrg#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)
48501e04c3fSmrg#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \
48601e04c3fSmrg				_DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)
48701e04c3fSmrg
48801e04c3fSmrgstruct drm_wait_vblank_request {
48901e04c3fSmrg	enum drm_vblank_seq_type type;
49001e04c3fSmrg	unsigned int sequence;
49101e04c3fSmrg	unsigned long signal;
49201e04c3fSmrg};
49301e04c3fSmrg
49401e04c3fSmrgstruct drm_wait_vblank_reply {
49501e04c3fSmrg	enum drm_vblank_seq_type type;
49601e04c3fSmrg	unsigned int sequence;
49701e04c3fSmrg	long tval_sec;
49801e04c3fSmrg	long tval_usec;
49901e04c3fSmrg};
50001e04c3fSmrg
50101e04c3fSmrg/**
50201e04c3fSmrg * DRM_IOCTL_WAIT_VBLANK ioctl argument type.
50301e04c3fSmrg *
50401e04c3fSmrg * \sa drmWaitVBlank().
50501e04c3fSmrg */
50601e04c3fSmrgunion drm_wait_vblank {
50701e04c3fSmrg	struct drm_wait_vblank_request request;
50801e04c3fSmrg	struct drm_wait_vblank_reply reply;
50901e04c3fSmrg};
51001e04c3fSmrg
51101e04c3fSmrg#define _DRM_PRE_MODESET 1
51201e04c3fSmrg#define _DRM_POST_MODESET 2
51301e04c3fSmrg
51401e04c3fSmrg/**
51501e04c3fSmrg * DRM_IOCTL_MODESET_CTL ioctl argument type
51601e04c3fSmrg *
51701e04c3fSmrg * \sa drmModesetCtl().
51801e04c3fSmrg */
51901e04c3fSmrgstruct drm_modeset_ctl {
52001e04c3fSmrg	__u32 crtc;
52101e04c3fSmrg	__u32 cmd;
52201e04c3fSmrg};
52301e04c3fSmrg
52401e04c3fSmrg/**
52501e04c3fSmrg * DRM_IOCTL_AGP_ENABLE ioctl argument type.
52601e04c3fSmrg *
52701e04c3fSmrg * \sa drmAgpEnable().
52801e04c3fSmrg */
52901e04c3fSmrgstruct drm_agp_mode {
53001e04c3fSmrg	unsigned long mode;	/**< AGP mode */
53101e04c3fSmrg};
53201e04c3fSmrg
53301e04c3fSmrg/**
53401e04c3fSmrg * DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.
53501e04c3fSmrg *
53601e04c3fSmrg * \sa drmAgpAlloc() and drmAgpFree().
53701e04c3fSmrg */
53801e04c3fSmrgstruct drm_agp_buffer {
53901e04c3fSmrg	unsigned long size;	/**< In bytes -- will round to page boundary */
54001e04c3fSmrg	unsigned long handle;	/**< Used for binding / unbinding */
54101e04c3fSmrg	unsigned long type;	/**< Type of memory to allocate */
54201e04c3fSmrg	unsigned long physical;	/**< Physical used by i810 */
54301e04c3fSmrg};
54401e04c3fSmrg
54501e04c3fSmrg/**
54601e04c3fSmrg * DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.
54701e04c3fSmrg *
54801e04c3fSmrg * \sa drmAgpBind() and drmAgpUnbind().
54901e04c3fSmrg */
55001e04c3fSmrgstruct drm_agp_binding {
55101e04c3fSmrg	unsigned long handle;	/**< From drm_agp_buffer */
55201e04c3fSmrg	unsigned long offset;	/**< In bytes -- will round to page boundary */
55301e04c3fSmrg};
55401e04c3fSmrg
55501e04c3fSmrg/**
55601e04c3fSmrg * DRM_IOCTL_AGP_INFO ioctl argument type.
55701e04c3fSmrg *
55801e04c3fSmrg * \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),
55901e04c3fSmrg * drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(),
56001e04c3fSmrg * drmAgpVendorId() and drmAgpDeviceId().
56101e04c3fSmrg */
56201e04c3fSmrgstruct drm_agp_info {
56301e04c3fSmrg	int agp_version_major;
56401e04c3fSmrg	int agp_version_minor;
56501e04c3fSmrg	unsigned long mode;
56601e04c3fSmrg	unsigned long aperture_base;	/* physical address */
56701e04c3fSmrg	unsigned long aperture_size;	/* bytes */
56801e04c3fSmrg	unsigned long memory_allowed;	/* bytes */
56901e04c3fSmrg	unsigned long memory_used;
57001e04c3fSmrg
57101e04c3fSmrg	/* PCI information */
57201e04c3fSmrg	unsigned short id_vendor;
57301e04c3fSmrg	unsigned short id_device;
57401e04c3fSmrg};
57501e04c3fSmrg
57601e04c3fSmrg/**
57701e04c3fSmrg * DRM_IOCTL_SG_ALLOC ioctl argument type.
57801e04c3fSmrg */
57901e04c3fSmrgstruct drm_scatter_gather {
58001e04c3fSmrg	unsigned long size;	/**< In bytes -- will round to page boundary */
58101e04c3fSmrg	unsigned long handle;	/**< Used for mapping / unmapping */
58201e04c3fSmrg};
58301e04c3fSmrg
58401e04c3fSmrg/**
58501e04c3fSmrg * DRM_IOCTL_SET_VERSION ioctl argument type.
58601e04c3fSmrg */
58701e04c3fSmrgstruct drm_set_version {
58801e04c3fSmrg	int drm_di_major;
58901e04c3fSmrg	int drm_di_minor;
59001e04c3fSmrg	int drm_dd_major;
59101e04c3fSmrg	int drm_dd_minor;
59201e04c3fSmrg};
59301e04c3fSmrg
59401e04c3fSmrg/** DRM_IOCTL_GEM_CLOSE ioctl argument type */
59501e04c3fSmrgstruct drm_gem_close {
59601e04c3fSmrg	/** Handle of the object to be closed. */
59701e04c3fSmrg	__u32 handle;
59801e04c3fSmrg	__u32 pad;
59901e04c3fSmrg};
60001e04c3fSmrg
60101e04c3fSmrg/** DRM_IOCTL_GEM_FLINK ioctl argument type */
60201e04c3fSmrgstruct drm_gem_flink {
60301e04c3fSmrg	/** Handle for the object being named */
60401e04c3fSmrg	__u32 handle;
60501e04c3fSmrg
60601e04c3fSmrg	/** Returned global name */
60701e04c3fSmrg	__u32 name;
60801e04c3fSmrg};
60901e04c3fSmrg
61001e04c3fSmrg/** DRM_IOCTL_GEM_OPEN ioctl argument type */
61101e04c3fSmrgstruct drm_gem_open {
61201e04c3fSmrg	/** Name of object being opened */
61301e04c3fSmrg	__u32 name;
61401e04c3fSmrg
61501e04c3fSmrg	/** Returned handle for the object */
61601e04c3fSmrg	__u32 handle;
61701e04c3fSmrg
61801e04c3fSmrg	/** Returned size of the object */
61901e04c3fSmrg	__u64 size;
62001e04c3fSmrg};
62101e04c3fSmrg
62201e04c3fSmrg#define DRM_CAP_DUMB_BUFFER		0x1
62301e04c3fSmrg#define DRM_CAP_VBLANK_HIGH_CRTC	0x2
62401e04c3fSmrg#define DRM_CAP_DUMB_PREFERRED_DEPTH	0x3
62501e04c3fSmrg#define DRM_CAP_DUMB_PREFER_SHADOW	0x4
62601e04c3fSmrg#define DRM_CAP_PRIME			0x5
62701e04c3fSmrg#define  DRM_PRIME_CAP_IMPORT		0x1
62801e04c3fSmrg#define  DRM_PRIME_CAP_EXPORT		0x2
62901e04c3fSmrg#define DRM_CAP_TIMESTAMP_MONOTONIC	0x6
63001e04c3fSmrg#define DRM_CAP_ASYNC_PAGE_FLIP		0x7
63101e04c3fSmrg/*
63201e04c3fSmrg * The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid widthxheight
63301e04c3fSmrg * combination for the hardware cursor. The intention is that a hardware
63401e04c3fSmrg * agnostic userspace can query a cursor plane size to use.
63501e04c3fSmrg *
63601e04c3fSmrg * Note that the cross-driver contract is to merely return a valid size;
63701e04c3fSmrg * drivers are free to attach another meaning on top, eg. i915 returns the
63801e04c3fSmrg * maximum plane size.
63901e04c3fSmrg */
64001e04c3fSmrg#define DRM_CAP_CURSOR_WIDTH		0x8
64101e04c3fSmrg#define DRM_CAP_CURSOR_HEIGHT		0x9
64201e04c3fSmrg#define DRM_CAP_ADDFB2_MODIFIERS	0x10
64301e04c3fSmrg#define DRM_CAP_PAGE_FLIP_TARGET	0x11
64401e04c3fSmrg#define DRM_CAP_CRTC_IN_VBLANK_EVENT	0x12
64501e04c3fSmrg#define DRM_CAP_SYNCOBJ		0x13
64601e04c3fSmrg
64701e04c3fSmrg/** DRM_IOCTL_GET_CAP ioctl argument type */
64801e04c3fSmrgstruct drm_get_cap {
64901e04c3fSmrg	__u64 capability;
65001e04c3fSmrg	__u64 value;
65101e04c3fSmrg};
65201e04c3fSmrg
65301e04c3fSmrg/**
65401e04c3fSmrg * DRM_CLIENT_CAP_STEREO_3D
65501e04c3fSmrg *
65601e04c3fSmrg * if set to 1, the DRM core will expose the stereo 3D capabilities of the
65701e04c3fSmrg * monitor by advertising the supported 3D layouts in the flags of struct
65801e04c3fSmrg * drm_mode_modeinfo.
65901e04c3fSmrg */
66001e04c3fSmrg#define DRM_CLIENT_CAP_STEREO_3D	1
66101e04c3fSmrg
66201e04c3fSmrg/**
66301e04c3fSmrg * DRM_CLIENT_CAP_UNIVERSAL_PLANES
66401e04c3fSmrg *
66501e04c3fSmrg * If set to 1, the DRM core will expose all planes (overlay, primary, and
66601e04c3fSmrg * cursor) to userspace.
66701e04c3fSmrg */
66801e04c3fSmrg#define DRM_CLIENT_CAP_UNIVERSAL_PLANES  2
66901e04c3fSmrg
67001e04c3fSmrg/**
67101e04c3fSmrg * DRM_CLIENT_CAP_ATOMIC
67201e04c3fSmrg *
67301e04c3fSmrg * If set to 1, the DRM core will expose atomic properties to userspace
67401e04c3fSmrg */
67501e04c3fSmrg#define DRM_CLIENT_CAP_ATOMIC	3
67601e04c3fSmrg
67701e04c3fSmrg/** DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */
67801e04c3fSmrgstruct drm_set_client_cap {
67901e04c3fSmrg	__u64 capability;
68001e04c3fSmrg	__u64 value;
68101e04c3fSmrg};
68201e04c3fSmrg
68301e04c3fSmrg#define DRM_RDWR O_RDWR
68401e04c3fSmrg#define DRM_CLOEXEC O_CLOEXEC
68501e04c3fSmrgstruct drm_prime_handle {
68601e04c3fSmrg	__u32 handle;
68701e04c3fSmrg
68801e04c3fSmrg	/** Flags.. only applicable for handle->fd */
68901e04c3fSmrg	__u32 flags;
69001e04c3fSmrg
69101e04c3fSmrg	/** Returned dmabuf file descriptor */
69201e04c3fSmrg	__s32 fd;
69301e04c3fSmrg};
69401e04c3fSmrg
69501e04c3fSmrgstruct drm_syncobj_create {
69601e04c3fSmrg	__u32 handle;
69701e04c3fSmrg#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0)
69801e04c3fSmrg	__u32 flags;
69901e04c3fSmrg};
70001e04c3fSmrg
70101e04c3fSmrgstruct drm_syncobj_destroy {
70201e04c3fSmrg	__u32 handle;
70301e04c3fSmrg	__u32 pad;
70401e04c3fSmrg};
70501e04c3fSmrg
70601e04c3fSmrg#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)
70701e04c3fSmrg#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)
70801e04c3fSmrgstruct drm_syncobj_handle {
70901e04c3fSmrg	__u32 handle;
71001e04c3fSmrg	__u32 flags;
71101e04c3fSmrg
71201e04c3fSmrg	__s32 fd;
71301e04c3fSmrg	__u32 pad;
71401e04c3fSmrg};
71501e04c3fSmrg
71601e04c3fSmrg#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)
71701e04c3fSmrg#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)
71801e04c3fSmrgstruct drm_syncobj_wait {
71901e04c3fSmrg	__u64 handles;
72001e04c3fSmrg	/* absolute timeout */
72101e04c3fSmrg	__s64 timeout_nsec;
72201e04c3fSmrg	__u32 count_handles;
72301e04c3fSmrg	__u32 flags;
72401e04c3fSmrg	__u32 first_signaled; /* only valid when not waiting all */
72501e04c3fSmrg	__u32 pad;
72601e04c3fSmrg};
72701e04c3fSmrg
72801e04c3fSmrgstruct drm_syncobj_array {
72901e04c3fSmrg	__u64 handles;
73001e04c3fSmrg	__u32 count_handles;
73101e04c3fSmrg	__u32 pad;
73201e04c3fSmrg};
73301e04c3fSmrg
73401e04c3fSmrg/* Query current scanout sequence number */
73501e04c3fSmrgstruct drm_crtc_get_sequence {
73601e04c3fSmrg	__u32 crtc_id;		/* requested crtc_id */
73701e04c3fSmrg	__u32 active;		/* return: crtc output is active */
73801e04c3fSmrg	__u64 sequence;		/* return: most recent vblank sequence */
73901e04c3fSmrg	__s64 sequence_ns;	/* return: most recent time of first pixel out */
74001e04c3fSmrg};
74101e04c3fSmrg
74201e04c3fSmrg/* Queue event to be delivered at specified sequence. Time stamp marks
74301e04c3fSmrg * when the first pixel of the refresh cycle leaves the display engine
74401e04c3fSmrg * for the display
74501e04c3fSmrg */
74601e04c3fSmrg#define DRM_CRTC_SEQUENCE_RELATIVE		0x00000001	/* sequence is relative to current */
74701e04c3fSmrg#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS		0x00000002	/* Use next sequence if we've missed */
74801e04c3fSmrg
74901e04c3fSmrgstruct drm_crtc_queue_sequence {
75001e04c3fSmrg	__u32 crtc_id;
75101e04c3fSmrg	__u32 flags;
75201e04c3fSmrg	__u64 sequence;		/* on input, target sequence. on output, actual sequence */
75301e04c3fSmrg	__u64 user_data;	/* user data passed to event */
75401e04c3fSmrg};
75501e04c3fSmrg
75601e04c3fSmrg#if defined(__cplusplus)
75701e04c3fSmrg}
75801e04c3fSmrg#endif
75901e04c3fSmrg
76001e04c3fSmrg#include "drm_mode.h"
76101e04c3fSmrg
76201e04c3fSmrg#if defined(__cplusplus)
76301e04c3fSmrgextern "C" {
76401e04c3fSmrg#endif
76501e04c3fSmrg
76601e04c3fSmrg#define DRM_IOCTL_BASE			'd'
76701e04c3fSmrg#define DRM_IO(nr)			_IO(DRM_IOCTL_BASE,nr)
76801e04c3fSmrg#define DRM_IOR(nr,type)		_IOR(DRM_IOCTL_BASE,nr,type)
76901e04c3fSmrg#define DRM_IOW(nr,type)		_IOW(DRM_IOCTL_BASE,nr,type)
77001e04c3fSmrg#define DRM_IOWR(nr,type)		_IOWR(DRM_IOCTL_BASE,nr,type)
77101e04c3fSmrg
77201e04c3fSmrg#define DRM_IOCTL_VERSION		DRM_IOWR(0x00, struct drm_version)
77301e04c3fSmrg#define DRM_IOCTL_GET_UNIQUE		DRM_IOWR(0x01, struct drm_unique)
77401e04c3fSmrg#define DRM_IOCTL_GET_MAGIC		DRM_IOR( 0x02, struct drm_auth)
77501e04c3fSmrg#define DRM_IOCTL_IRQ_BUSID		DRM_IOWR(0x03, struct drm_irq_busid)
77601e04c3fSmrg#define DRM_IOCTL_GET_MAP               DRM_IOWR(0x04, struct drm_map)
77701e04c3fSmrg#define DRM_IOCTL_GET_CLIENT            DRM_IOWR(0x05, struct drm_client)
77801e04c3fSmrg#define DRM_IOCTL_GET_STATS             DRM_IOR( 0x06, struct drm_stats)
77901e04c3fSmrg#define DRM_IOCTL_SET_VERSION		DRM_IOWR(0x07, struct drm_set_version)
78001e04c3fSmrg#define DRM_IOCTL_MODESET_CTL           DRM_IOW(0x08, struct drm_modeset_ctl)
78101e04c3fSmrg#define DRM_IOCTL_GEM_CLOSE		DRM_IOW (0x09, struct drm_gem_close)
78201e04c3fSmrg#define DRM_IOCTL_GEM_FLINK		DRM_IOWR(0x0a, struct drm_gem_flink)
78301e04c3fSmrg#define DRM_IOCTL_GEM_OPEN		DRM_IOWR(0x0b, struct drm_gem_open)
78401e04c3fSmrg#define DRM_IOCTL_GET_CAP		DRM_IOWR(0x0c, struct drm_get_cap)
78501e04c3fSmrg#define DRM_IOCTL_SET_CLIENT_CAP	DRM_IOW( 0x0d, struct drm_set_client_cap)
78601e04c3fSmrg
78701e04c3fSmrg#define DRM_IOCTL_SET_UNIQUE		DRM_IOW( 0x10, struct drm_unique)
78801e04c3fSmrg#define DRM_IOCTL_AUTH_MAGIC		DRM_IOW( 0x11, struct drm_auth)
78901e04c3fSmrg#define DRM_IOCTL_BLOCK			DRM_IOWR(0x12, struct drm_block)
79001e04c3fSmrg#define DRM_IOCTL_UNBLOCK		DRM_IOWR(0x13, struct drm_block)
79101e04c3fSmrg#define DRM_IOCTL_CONTROL		DRM_IOW( 0x14, struct drm_control)
79201e04c3fSmrg#define DRM_IOCTL_ADD_MAP		DRM_IOWR(0x15, struct drm_map)
79301e04c3fSmrg#define DRM_IOCTL_ADD_BUFS		DRM_IOWR(0x16, struct drm_buf_desc)
79401e04c3fSmrg#define DRM_IOCTL_MARK_BUFS		DRM_IOW( 0x17, struct drm_buf_desc)
79501e04c3fSmrg#define DRM_IOCTL_INFO_BUFS		DRM_IOWR(0x18, struct drm_buf_info)
79601e04c3fSmrg#define DRM_IOCTL_MAP_BUFS		DRM_IOWR(0x19, struct drm_buf_map)
79701e04c3fSmrg#define DRM_IOCTL_FREE_BUFS		DRM_IOW( 0x1a, struct drm_buf_free)
79801e04c3fSmrg
79901e04c3fSmrg#define DRM_IOCTL_RM_MAP		DRM_IOW( 0x1b, struct drm_map)
80001e04c3fSmrg
80101e04c3fSmrg#define DRM_IOCTL_SET_SAREA_CTX		DRM_IOW( 0x1c, struct drm_ctx_priv_map)
80201e04c3fSmrg#define DRM_IOCTL_GET_SAREA_CTX 	DRM_IOWR(0x1d, struct drm_ctx_priv_map)
80301e04c3fSmrg
80401e04c3fSmrg#define DRM_IOCTL_SET_MASTER            DRM_IO(0x1e)
80501e04c3fSmrg#define DRM_IOCTL_DROP_MASTER           DRM_IO(0x1f)
80601e04c3fSmrg
80701e04c3fSmrg#define DRM_IOCTL_ADD_CTX		DRM_IOWR(0x20, struct drm_ctx)
80801e04c3fSmrg#define DRM_IOCTL_RM_CTX		DRM_IOWR(0x21, struct drm_ctx)
80901e04c3fSmrg#define DRM_IOCTL_MOD_CTX		DRM_IOW( 0x22, struct drm_ctx)
81001e04c3fSmrg#define DRM_IOCTL_GET_CTX		DRM_IOWR(0x23, struct drm_ctx)
81101e04c3fSmrg#define DRM_IOCTL_SWITCH_CTX		DRM_IOW( 0x24, struct drm_ctx)
81201e04c3fSmrg#define DRM_IOCTL_NEW_CTX		DRM_IOW( 0x25, struct drm_ctx)
81301e04c3fSmrg#define DRM_IOCTL_RES_CTX		DRM_IOWR(0x26, struct drm_ctx_res)
81401e04c3fSmrg#define DRM_IOCTL_ADD_DRAW		DRM_IOWR(0x27, struct drm_draw)
81501e04c3fSmrg#define DRM_IOCTL_RM_DRAW		DRM_IOWR(0x28, struct drm_draw)
81601e04c3fSmrg#define DRM_IOCTL_DMA			DRM_IOWR(0x29, struct drm_dma)
81701e04c3fSmrg#define DRM_IOCTL_LOCK			DRM_IOW( 0x2a, struct drm_lock)
81801e04c3fSmrg#define DRM_IOCTL_UNLOCK		DRM_IOW( 0x2b, struct drm_lock)
81901e04c3fSmrg#define DRM_IOCTL_FINISH		DRM_IOW( 0x2c, struct drm_lock)
82001e04c3fSmrg
82101e04c3fSmrg#define DRM_IOCTL_PRIME_HANDLE_TO_FD    DRM_IOWR(0x2d, struct drm_prime_handle)
82201e04c3fSmrg#define DRM_IOCTL_PRIME_FD_TO_HANDLE    DRM_IOWR(0x2e, struct drm_prime_handle)
82301e04c3fSmrg
82401e04c3fSmrg#define DRM_IOCTL_AGP_ACQUIRE		DRM_IO(  0x30)
82501e04c3fSmrg#define DRM_IOCTL_AGP_RELEASE		DRM_IO(  0x31)
82601e04c3fSmrg#define DRM_IOCTL_AGP_ENABLE		DRM_IOW( 0x32, struct drm_agp_mode)
82701e04c3fSmrg#define DRM_IOCTL_AGP_INFO		DRM_IOR( 0x33, struct drm_agp_info)
82801e04c3fSmrg#define DRM_IOCTL_AGP_ALLOC		DRM_IOWR(0x34, struct drm_agp_buffer)
82901e04c3fSmrg#define DRM_IOCTL_AGP_FREE		DRM_IOW( 0x35, struct drm_agp_buffer)
83001e04c3fSmrg#define DRM_IOCTL_AGP_BIND		DRM_IOW( 0x36, struct drm_agp_binding)
83101e04c3fSmrg#define DRM_IOCTL_AGP_UNBIND		DRM_IOW( 0x37, struct drm_agp_binding)
83201e04c3fSmrg
83301e04c3fSmrg#define DRM_IOCTL_SG_ALLOC		DRM_IOWR(0x38, struct drm_scatter_gather)
83401e04c3fSmrg#define DRM_IOCTL_SG_FREE		DRM_IOW( 0x39, struct drm_scatter_gather)
83501e04c3fSmrg
83601e04c3fSmrg#define DRM_IOCTL_WAIT_VBLANK		DRM_IOWR(0x3a, union drm_wait_vblank)
83701e04c3fSmrg
83801e04c3fSmrg#define DRM_IOCTL_CRTC_GET_SEQUENCE	DRM_IOWR(0x3b, struct drm_crtc_get_sequence)
83901e04c3fSmrg#define DRM_IOCTL_CRTC_QUEUE_SEQUENCE	DRM_IOWR(0x3c, struct drm_crtc_queue_sequence)
84001e04c3fSmrg
84101e04c3fSmrg#define DRM_IOCTL_UPDATE_DRAW		DRM_IOW(0x3f, struct drm_update_draw)
84201e04c3fSmrg
84301e04c3fSmrg#define DRM_IOCTL_MODE_GETRESOURCES	DRM_IOWR(0xA0, struct drm_mode_card_res)
84401e04c3fSmrg#define DRM_IOCTL_MODE_GETCRTC		DRM_IOWR(0xA1, struct drm_mode_crtc)
84501e04c3fSmrg#define DRM_IOCTL_MODE_SETCRTC		DRM_IOWR(0xA2, struct drm_mode_crtc)
84601e04c3fSmrg#define DRM_IOCTL_MODE_CURSOR		DRM_IOWR(0xA3, struct drm_mode_cursor)
84701e04c3fSmrg#define DRM_IOCTL_MODE_GETGAMMA		DRM_IOWR(0xA4, struct drm_mode_crtc_lut)
84801e04c3fSmrg#define DRM_IOCTL_MODE_SETGAMMA		DRM_IOWR(0xA5, struct drm_mode_crtc_lut)
84901e04c3fSmrg#define DRM_IOCTL_MODE_GETENCODER	DRM_IOWR(0xA6, struct drm_mode_get_encoder)
85001e04c3fSmrg#define DRM_IOCTL_MODE_GETCONNECTOR	DRM_IOWR(0xA7, struct drm_mode_get_connector)
85101e04c3fSmrg#define DRM_IOCTL_MODE_ATTACHMODE	DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */
85201e04c3fSmrg#define DRM_IOCTL_MODE_DETACHMODE	DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */
85301e04c3fSmrg
85401e04c3fSmrg#define DRM_IOCTL_MODE_GETPROPERTY	DRM_IOWR(0xAA, struct drm_mode_get_property)
85501e04c3fSmrg#define DRM_IOCTL_MODE_SETPROPERTY	DRM_IOWR(0xAB, struct drm_mode_connector_set_property)
85601e04c3fSmrg#define DRM_IOCTL_MODE_GETPROPBLOB	DRM_IOWR(0xAC, struct drm_mode_get_blob)
85701e04c3fSmrg#define DRM_IOCTL_MODE_GETFB		DRM_IOWR(0xAD, struct drm_mode_fb_cmd)
85801e04c3fSmrg#define DRM_IOCTL_MODE_ADDFB		DRM_IOWR(0xAE, struct drm_mode_fb_cmd)
85901e04c3fSmrg#define DRM_IOCTL_MODE_RMFB		DRM_IOWR(0xAF, unsigned int)
86001e04c3fSmrg#define DRM_IOCTL_MODE_PAGE_FLIP	DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)
86101e04c3fSmrg#define DRM_IOCTL_MODE_DIRTYFB		DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)
86201e04c3fSmrg
86301e04c3fSmrg#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)
86401e04c3fSmrg#define DRM_IOCTL_MODE_MAP_DUMB    DRM_IOWR(0xB3, struct drm_mode_map_dumb)
86501e04c3fSmrg#define DRM_IOCTL_MODE_DESTROY_DUMB    DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)
86601e04c3fSmrg#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)
86701e04c3fSmrg#define DRM_IOCTL_MODE_GETPLANE	DRM_IOWR(0xB6, struct drm_mode_get_plane)
86801e04c3fSmrg#define DRM_IOCTL_MODE_SETPLANE	DRM_IOWR(0xB7, struct drm_mode_set_plane)
86901e04c3fSmrg#define DRM_IOCTL_MODE_ADDFB2		DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)
87001e04c3fSmrg#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES	DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)
87101e04c3fSmrg#define DRM_IOCTL_MODE_OBJ_SETPROPERTY	DRM_IOWR(0xBA, struct drm_mode_obj_set_property)
87201e04c3fSmrg#define DRM_IOCTL_MODE_CURSOR2		DRM_IOWR(0xBB, struct drm_mode_cursor2)
87301e04c3fSmrg#define DRM_IOCTL_MODE_ATOMIC		DRM_IOWR(0xBC, struct drm_mode_atomic)
87401e04c3fSmrg#define DRM_IOCTL_MODE_CREATEPROPBLOB	DRM_IOWR(0xBD, struct drm_mode_create_blob)
87501e04c3fSmrg#define DRM_IOCTL_MODE_DESTROYPROPBLOB	DRM_IOWR(0xBE, struct drm_mode_destroy_blob)
87601e04c3fSmrg
87701e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_CREATE	DRM_IOWR(0xBF, struct drm_syncobj_create)
87801e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_DESTROY	DRM_IOWR(0xC0, struct drm_syncobj_destroy)
87901e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD	DRM_IOWR(0xC1, struct drm_syncobj_handle)
88001e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE	DRM_IOWR(0xC2, struct drm_syncobj_handle)
88101e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_WAIT		DRM_IOWR(0xC3, struct drm_syncobj_wait)
88201e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_RESET		DRM_IOWR(0xC4, struct drm_syncobj_array)
88301e04c3fSmrg#define DRM_IOCTL_SYNCOBJ_SIGNAL	DRM_IOWR(0xC5, struct drm_syncobj_array)
88401e04c3fSmrg
88501e04c3fSmrg#define DRM_IOCTL_MODE_CREATE_LEASE	DRM_IOWR(0xC6, struct drm_mode_create_lease)
88601e04c3fSmrg#define DRM_IOCTL_MODE_LIST_LESSEES	DRM_IOWR(0xC7, struct drm_mode_list_lessees)
88701e04c3fSmrg#define DRM_IOCTL_MODE_GET_LEASE	DRM_IOWR(0xC8, struct drm_mode_get_lease)
88801e04c3fSmrg#define DRM_IOCTL_MODE_REVOKE_LEASE	DRM_IOWR(0xC9, struct drm_mode_revoke_lease)
88901e04c3fSmrg
89001e04c3fSmrg/**
89101e04c3fSmrg * Device specific ioctls should only be in their respective headers
89201e04c3fSmrg * The device specific ioctl range is from 0x40 to 0x9f.
89301e04c3fSmrg * Generic IOCTLS restart at 0xA0.
89401e04c3fSmrg *
89501e04c3fSmrg * \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and
89601e04c3fSmrg * drmCommandReadWrite().
89701e04c3fSmrg */
89801e04c3fSmrg#define DRM_COMMAND_BASE                0x40
89901e04c3fSmrg#define DRM_COMMAND_END			0xA0
90001e04c3fSmrg
90101e04c3fSmrg/**
90201e04c3fSmrg * Header for events written back to userspace on the drm fd.  The
90301e04c3fSmrg * type defines the type of event, the length specifies the total
90401e04c3fSmrg * length of the event (including the header), and user_data is
90501e04c3fSmrg * typically a 64 bit value passed with the ioctl that triggered the
90601e04c3fSmrg * event.  A read on the drm fd will always only return complete
90701e04c3fSmrg * events, that is, if for example the read buffer is 100 bytes, and
90801e04c3fSmrg * there are two 64 byte events pending, only one will be returned.
90901e04c3fSmrg *
91001e04c3fSmrg * Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and
91101e04c3fSmrg * up are chipset specific.
91201e04c3fSmrg */
91301e04c3fSmrgstruct drm_event {
91401e04c3fSmrg	__u32 type;
91501e04c3fSmrg	__u32 length;
91601e04c3fSmrg};
91701e04c3fSmrg
91801e04c3fSmrg#define DRM_EVENT_VBLANK 0x01
91901e04c3fSmrg#define DRM_EVENT_FLIP_COMPLETE 0x02
92001e04c3fSmrg#define DRM_EVENT_CRTC_SEQUENCE	0x03
92101e04c3fSmrg
92201e04c3fSmrgstruct drm_event_vblank {
92301e04c3fSmrg	struct drm_event base;
92401e04c3fSmrg	__u64 user_data;
92501e04c3fSmrg	__u32 tv_sec;
92601e04c3fSmrg	__u32 tv_usec;
92701e04c3fSmrg	__u32 sequence;
92801e04c3fSmrg	__u32 crtc_id; /* 0 on older kernels that do not support this */
92901e04c3fSmrg};
93001e04c3fSmrg
93101e04c3fSmrg/* Event delivered at sequence. Time stamp marks when the first pixel
93201e04c3fSmrg * of the refresh cycle leaves the display engine for the display
93301e04c3fSmrg */
93401e04c3fSmrgstruct drm_event_crtc_sequence {
93501e04c3fSmrg	struct drm_event	base;
93601e04c3fSmrg	__u64			user_data;
93701e04c3fSmrg	__s64			time_ns;
93801e04c3fSmrg	__u64			sequence;
93901e04c3fSmrg};
94001e04c3fSmrg
94101e04c3fSmrg/* typedef area */
94201e04c3fSmrgtypedef struct drm_clip_rect drm_clip_rect_t;
94301e04c3fSmrgtypedef struct drm_drawable_info drm_drawable_info_t;
94401e04c3fSmrgtypedef struct drm_tex_region drm_tex_region_t;
94501e04c3fSmrgtypedef struct drm_hw_lock drm_hw_lock_t;
94601e04c3fSmrgtypedef struct drm_version drm_version_t;
94701e04c3fSmrgtypedef struct drm_unique drm_unique_t;
94801e04c3fSmrgtypedef struct drm_list drm_list_t;
94901e04c3fSmrgtypedef struct drm_block drm_block_t;
95001e04c3fSmrgtypedef struct drm_control drm_control_t;
95101e04c3fSmrgtypedef enum drm_map_type drm_map_type_t;
95201e04c3fSmrgtypedef enum drm_map_flags drm_map_flags_t;
95301e04c3fSmrgtypedef struct drm_ctx_priv_map drm_ctx_priv_map_t;
95401e04c3fSmrgtypedef struct drm_map drm_map_t;
95501e04c3fSmrgtypedef struct drm_client drm_client_t;
95601e04c3fSmrgtypedef enum drm_stat_type drm_stat_type_t;
95701e04c3fSmrgtypedef struct drm_stats drm_stats_t;
95801e04c3fSmrgtypedef enum drm_lock_flags drm_lock_flags_t;
95901e04c3fSmrgtypedef struct drm_lock drm_lock_t;
96001e04c3fSmrgtypedef enum drm_dma_flags drm_dma_flags_t;
96101e04c3fSmrgtypedef struct drm_buf_desc drm_buf_desc_t;
96201e04c3fSmrgtypedef struct drm_buf_info drm_buf_info_t;
96301e04c3fSmrgtypedef struct drm_buf_free drm_buf_free_t;
96401e04c3fSmrgtypedef struct drm_buf_pub drm_buf_pub_t;
96501e04c3fSmrgtypedef struct drm_buf_map drm_buf_map_t;
96601e04c3fSmrgtypedef struct drm_dma drm_dma_t;
96701e04c3fSmrgtypedef union drm_wait_vblank drm_wait_vblank_t;
96801e04c3fSmrgtypedef struct drm_agp_mode drm_agp_mode_t;
96901e04c3fSmrgtypedef enum drm_ctx_flags drm_ctx_flags_t;
97001e04c3fSmrgtypedef struct drm_ctx drm_ctx_t;
97101e04c3fSmrgtypedef struct drm_ctx_res drm_ctx_res_t;
97201e04c3fSmrgtypedef struct drm_draw drm_draw_t;
97301e04c3fSmrgtypedef struct drm_update_draw drm_update_draw_t;
97401e04c3fSmrgtypedef struct drm_auth drm_auth_t;
97501e04c3fSmrgtypedef struct drm_irq_busid drm_irq_busid_t;
97601e04c3fSmrgtypedef enum drm_vblank_seq_type drm_vblank_seq_type_t;
97701e04c3fSmrg
97801e04c3fSmrgtypedef struct drm_agp_buffer drm_agp_buffer_t;
97901e04c3fSmrgtypedef struct drm_agp_binding drm_agp_binding_t;
98001e04c3fSmrgtypedef struct drm_agp_info drm_agp_info_t;
98101e04c3fSmrgtypedef struct drm_scatter_gather drm_scatter_gather_t;
98201e04c3fSmrgtypedef struct drm_set_version drm_set_version_t;
98301e04c3fSmrg
98401e04c3fSmrg#if defined(__cplusplus)
98501e04c3fSmrg}
98601e04c3fSmrg#endif
98701e04c3fSmrg
98801e04c3fSmrg#endif
989