/*1* Header for the Direct Rendering Manager2*3* Author: Rickard E. (Rik) Faith <[email protected]>4*5* Acknowledgments:6* Dec 1999, Richard Henderson <[email protected]>, move to generic cmpxchg.7*/89/*10* Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.11* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.12* All rights reserved.13*14* Permission is hereby granted, free of charge, to any person obtaining a15* copy of this software and associated documentation files (the "Software"),16* to deal in the Software without restriction, including without limitation17* the rights to use, copy, modify, merge, publish, distribute, sublicense,18* and/or sell copies of the Software, and to permit persons to whom the19* Software is furnished to do so, subject to the following conditions:20*21* The above copyright notice and this permission notice (including the next22* paragraph) shall be included in all copies or substantial portions of the23* Software.24*25* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR26* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,27* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL28* VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR29* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,30* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR31* OTHER DEALINGS IN THE SOFTWARE.32*/3334#ifndef _DRM_H_35#define _DRM_H_3637#if defined(__linux__)3839#include <linux/types.h>40#include <asm/ioctl.h>41typedef unsigned int drm_handle_t;4243#else /* One of the BSDs */4445#include <stdint.h>46#include <sys/ioccom.h>47#include <sys/types.h>48typedef int8_t __s8;49typedef uint8_t __u8;50typedef int16_t __s16;51typedef uint16_t __u16;52typedef int32_t __s32;53typedef uint32_t __u32;54typedef int64_t __s64;55typedef uint64_t __u64;56typedef size_t __kernel_size_t;57typedef unsigned long drm_handle_t;5859#endif6061#if defined(__cplusplus)62extern "C" {63#endif6465#define DRM_NAME "drm" /**< Name in kernel, /dev, and /proc */66#define DRM_MIN_ORDER 5 /**< At least 2^5 bytes = 32 bytes */67#define DRM_MAX_ORDER 22 /**< Up to 2^22 bytes = 4MB */68#define DRM_RAM_PERCENT 10 /**< How much system ram can we lock? */6970#define _DRM_LOCK_HELD 0x80000000U /**< Hardware lock is held */71#define _DRM_LOCK_CONT 0x40000000U /**< Hardware lock is contended */72#define _DRM_LOCK_IS_HELD(lock) ((lock) & _DRM_LOCK_HELD)73#define _DRM_LOCK_IS_CONT(lock) ((lock) & _DRM_LOCK_CONT)74#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))7576typedef unsigned int drm_context_t;77typedef unsigned int drm_drawable_t;78typedef unsigned int drm_magic_t;7980/*81* Cliprect.82*83* \warning: If you change this structure, make sure you change84* XF86DRIClipRectRec in the server as well85*86* \note KW: Actually it's illegal to change either for87* backwards-compatibility reasons.88*/89struct drm_clip_rect {90unsigned short x1;91unsigned short y1;92unsigned short x2;93unsigned short y2;94};9596/*97* Drawable information.98*/99struct drm_drawable_info {100unsigned int num_rects;101struct drm_clip_rect *rects;102};103104/*105* Texture region,106*/107struct drm_tex_region {108unsigned char next;109unsigned char prev;110unsigned char in_use;111unsigned char padding;112unsigned int age;113};114115/*116* Hardware lock.117*118* The lock structure is a simple cache-line aligned integer. To avoid119* processor bus contention on a multiprocessor system, there should not be any120* other data stored in the same cache line.121*/122struct drm_hw_lock {123__volatile__ unsigned int lock; /**< lock variable */124char padding[60]; /**< Pad to cache line */125};126127/*128* DRM_IOCTL_VERSION ioctl argument type.129*130* \sa drmGetVersion().131*/132struct drm_version {133int version_major; /**< Major version */134int version_minor; /**< Minor version */135int version_patchlevel; /**< Patch level */136__kernel_size_t name_len; /**< Length of name buffer */137char *name; /**< Name of driver */138__kernel_size_t date_len; /**< Length of date buffer */139char *date; /**< User-space buffer to hold date */140__kernel_size_t desc_len; /**< Length of desc buffer */141char *desc; /**< User-space buffer to hold desc */142};143144/*145* DRM_IOCTL_GET_UNIQUE ioctl argument type.146*147* \sa drmGetBusid() and drmSetBusId().148*/149struct drm_unique {150__kernel_size_t unique_len; /**< Length of unique */151char *unique; /**< Unique name for driver instantiation */152};153154struct drm_list {155int count; /**< Length of user-space structures */156struct drm_version *version;157};158159struct drm_block {160int unused;161};162163/*164* DRM_IOCTL_CONTROL ioctl argument type.165*166* \sa drmCtlInstHandler() and drmCtlUninstHandler().167*/168struct drm_control {169enum {170DRM_ADD_COMMAND,171DRM_RM_COMMAND,172DRM_INST_HANDLER,173DRM_UNINST_HANDLER174} func;175int irq;176};177178/*179* Type of memory to map.180*/181enum drm_map_type {182_DRM_FRAME_BUFFER = 0, /**< WC (no caching), no core dump */183_DRM_REGISTERS = 1, /**< no caching, no core dump */184_DRM_SHM = 2, /**< shared, cached */185_DRM_AGP = 3, /**< AGP/GART */186_DRM_SCATTER_GATHER = 4, /**< Scatter/gather memory for PCI DMA */187_DRM_CONSISTENT = 5 /**< Consistent memory for PCI DMA */188};189190/*191* Memory mapping flags.192*/193enum drm_map_flags {194_DRM_RESTRICTED = 0x01, /**< Cannot be mapped to user-virtual */195_DRM_READ_ONLY = 0x02,196_DRM_LOCKED = 0x04, /**< shared, cached, locked */197_DRM_KERNEL = 0x08, /**< kernel requires access */198_DRM_WRITE_COMBINING = 0x10, /**< use write-combining if available */199_DRM_CONTAINS_LOCK = 0x20, /**< SHM page that contains lock */200_DRM_REMOVABLE = 0x40, /**< Removable mapping */201_DRM_DRIVER = 0x80 /**< Managed by driver */202};203204struct drm_ctx_priv_map {205unsigned int ctx_id; /**< Context requesting private mapping */206void *handle; /**< Handle of map */207};208209/*210* DRM_IOCTL_GET_MAP, DRM_IOCTL_ADD_MAP and DRM_IOCTL_RM_MAP ioctls211* argument type.212*213* \sa drmAddMap().214*/215struct drm_map {216unsigned long offset; /**< Requested physical address (0 for SAREA)*/217unsigned long size; /**< Requested physical size (bytes) */218enum drm_map_type type; /**< Type of memory to map */219enum drm_map_flags flags; /**< Flags */220void *handle; /**< User-space: "Handle" to pass to mmap() */221/**< Kernel-space: kernel-virtual address */222int mtrr; /**< MTRR slot used */223/* Private data */224};225226/*227* DRM_IOCTL_GET_CLIENT ioctl argument type.228*/229struct drm_client {230int idx; /**< Which client desired? */231int auth; /**< Is client authenticated? */232unsigned long pid; /**< Process ID */233unsigned long uid; /**< User ID */234unsigned long magic; /**< Magic */235unsigned long iocs; /**< Ioctl count */236};237238enum drm_stat_type {239_DRM_STAT_LOCK,240_DRM_STAT_OPENS,241_DRM_STAT_CLOSES,242_DRM_STAT_IOCTLS,243_DRM_STAT_LOCKS,244_DRM_STAT_UNLOCKS,245_DRM_STAT_VALUE, /**< Generic value */246_DRM_STAT_BYTE, /**< Generic byte counter (1024bytes/K) */247_DRM_STAT_COUNT, /**< Generic non-byte counter (1000/k) */248249_DRM_STAT_IRQ, /**< IRQ */250_DRM_STAT_PRIMARY, /**< Primary DMA bytes */251_DRM_STAT_SECONDARY, /**< Secondary DMA bytes */252_DRM_STAT_DMA, /**< DMA */253_DRM_STAT_SPECIAL, /**< Special DMA (e.g., priority or polled) */254_DRM_STAT_MISSED /**< Missed DMA opportunity */255/* Add to the *END* of the list */256};257258/*259* DRM_IOCTL_GET_STATS ioctl argument type.260*/261struct drm_stats {262unsigned long count;263struct {264unsigned long value;265enum drm_stat_type type;266} data[15];267};268269/*270* Hardware locking flags.271*/272enum drm_lock_flags {273_DRM_LOCK_READY = 0x01, /**< Wait until hardware is ready for DMA */274_DRM_LOCK_QUIESCENT = 0x02, /**< Wait until hardware quiescent */275_DRM_LOCK_FLUSH = 0x04, /**< Flush this context's DMA queue first */276_DRM_LOCK_FLUSH_ALL = 0x08, /**< Flush all DMA queues first */277/* These *HALT* flags aren't supported yet278-- they will be used to support the279full-screen DGA-like mode. */280_DRM_HALT_ALL_QUEUES = 0x10, /**< Halt all current and future queues */281_DRM_HALT_CUR_QUEUES = 0x20 /**< Halt all current queues */282};283284/*285* DRM_IOCTL_LOCK, DRM_IOCTL_UNLOCK and DRM_IOCTL_FINISH ioctl argument type.286*287* \sa drmGetLock() and drmUnlock().288*/289struct drm_lock {290int context;291enum drm_lock_flags flags;292};293294/*295* DMA flags296*297* \warning298* These values \e must match xf86drm.h.299*300* \sa drm_dma.301*/302enum drm_dma_flags {303/* Flags for DMA buffer dispatch */304_DRM_DMA_BLOCK = 0x01, /**<305* Block until buffer dispatched.306*307* \note The buffer may not yet have308* been processed by the hardware --309* getting a hardware lock with the310* hardware quiescent will ensure311* that the buffer has been312* processed.313*/314_DRM_DMA_WHILE_LOCKED = 0x02, /**< Dispatch while lock held */315_DRM_DMA_PRIORITY = 0x04, /**< High priority dispatch */316317/* Flags for DMA buffer request */318_DRM_DMA_WAIT = 0x10, /**< Wait for free buffers */319_DRM_DMA_SMALLER_OK = 0x20, /**< Smaller-than-requested buffers OK */320_DRM_DMA_LARGER_OK = 0x40 /**< Larger-than-requested buffers OK */321};322323/*324* DRM_IOCTL_ADD_BUFS and DRM_IOCTL_MARK_BUFS ioctl argument type.325*326* \sa drmAddBufs().327*/328struct drm_buf_desc {329int count; /**< Number of buffers of this size */330int size; /**< Size in bytes */331int low_mark; /**< Low water mark */332int high_mark; /**< High water mark */333enum {334_DRM_PAGE_ALIGN = 0x01, /**< Align on page boundaries for DMA */335_DRM_AGP_BUFFER = 0x02, /**< Buffer is in AGP space */336_DRM_SG_BUFFER = 0x04, /**< Scatter/gather memory buffer */337_DRM_FB_BUFFER = 0x08, /**< Buffer is in frame buffer */338_DRM_PCI_BUFFER_RO = 0x10 /**< Map PCI DMA buffer read-only */339} flags;340unsigned long agp_start; /**<341* Start address of where the AGP buffers are342* in the AGP aperture343*/344};345346/*347* DRM_IOCTL_INFO_BUFS ioctl argument type.348*/349struct drm_buf_info {350int count; /**< Entries in list */351struct drm_buf_desc *list;352};353354/*355* DRM_IOCTL_FREE_BUFS ioctl argument type.356*/357struct drm_buf_free {358int count;359int *list;360};361362/*363* Buffer information364*365* \sa drm_buf_map.366*/367struct drm_buf_pub {368int idx; /**< Index into the master buffer list */369int total; /**< Buffer size */370int used; /**< Amount of buffer in use (for DMA) */371void *address; /**< Address of buffer */372};373374/*375* DRM_IOCTL_MAP_BUFS ioctl argument type.376*/377struct drm_buf_map {378int count; /**< Length of the buffer list */379#ifdef __cplusplus380void *virt;381#else382void *virtual; /**< Mmap'd area in user-virtual */383#endif384struct drm_buf_pub *list; /**< Buffer information */385};386387/*388* DRM_IOCTL_DMA ioctl argument type.389*390* Indices here refer to the offset into the buffer list in drm_buf_get.391*392* \sa drmDMA().393*/394struct drm_dma {395int context; /**< Context handle */396int send_count; /**< Number of buffers to send */397int *send_indices; /**< List of handles to buffers */398int *send_sizes; /**< Lengths of data to send */399enum drm_dma_flags flags; /**< Flags */400int request_count; /**< Number of buffers requested */401int request_size; /**< Desired size for buffers */402int *request_indices; /**< Buffer information */403int *request_sizes;404int granted_count; /**< Number of buffers granted */405};406407enum drm_ctx_flags {408_DRM_CONTEXT_PRESERVED = 0x01,409_DRM_CONTEXT_2DONLY = 0x02410};411412/*413* DRM_IOCTL_ADD_CTX ioctl argument type.414*415* \sa drmCreateContext() and drmDestroyContext().416*/417struct drm_ctx {418drm_context_t handle;419enum drm_ctx_flags flags;420};421422/*423* DRM_IOCTL_RES_CTX ioctl argument type.424*/425struct drm_ctx_res {426int count;427struct drm_ctx *contexts;428};429430/*431* DRM_IOCTL_ADD_DRAW and DRM_IOCTL_RM_DRAW ioctl argument type.432*/433struct drm_draw {434drm_drawable_t handle;435};436437/*438* DRM_IOCTL_UPDATE_DRAW ioctl argument type.439*/440typedef enum {441DRM_DRAWABLE_CLIPRECTS442} drm_drawable_info_type_t;443444struct drm_update_draw {445drm_drawable_t handle;446unsigned int type;447unsigned int num;448unsigned long long data;449};450451/*452* DRM_IOCTL_GET_MAGIC and DRM_IOCTL_AUTH_MAGIC ioctl argument type.453*/454struct drm_auth {455drm_magic_t magic;456};457458/*459* DRM_IOCTL_IRQ_BUSID ioctl argument type.460*461* \sa drmGetInterruptFromBusID().462*/463struct drm_irq_busid {464int irq; /**< IRQ number */465int busnum; /**< bus number */466int devnum; /**< device number */467int funcnum; /**< function number */468};469470enum drm_vblank_seq_type {471_DRM_VBLANK_ABSOLUTE = 0x0, /**< Wait for specific vblank sequence number */472_DRM_VBLANK_RELATIVE = 0x1, /**< Wait for given number of vblanks */473/* bits 1-6 are reserved for high crtcs */474_DRM_VBLANK_HIGH_CRTC_MASK = 0x0000003e,475_DRM_VBLANK_EVENT = 0x4000000, /**< Send event instead of blocking */476_DRM_VBLANK_FLIP = 0x8000000, /**< Scheduled buffer swap should flip */477_DRM_VBLANK_NEXTONMISS = 0x10000000, /**< If missed, wait for next vblank */478_DRM_VBLANK_SECONDARY = 0x20000000, /**< Secondary display controller */479_DRM_VBLANK_SIGNAL = 0x40000000 /**< Send signal instead of blocking, unsupported */480};481#define _DRM_VBLANK_HIGH_CRTC_SHIFT 1482483#define _DRM_VBLANK_TYPES_MASK (_DRM_VBLANK_ABSOLUTE | _DRM_VBLANK_RELATIVE)484#define _DRM_VBLANK_FLAGS_MASK (_DRM_VBLANK_EVENT | _DRM_VBLANK_SIGNAL | \485_DRM_VBLANK_SECONDARY | _DRM_VBLANK_NEXTONMISS)486487struct drm_wait_vblank_request {488enum drm_vblank_seq_type type;489unsigned int sequence;490unsigned long signal;491};492493struct drm_wait_vblank_reply {494enum drm_vblank_seq_type type;495unsigned int sequence;496long tval_sec;497long tval_usec;498};499500/*501* DRM_IOCTL_WAIT_VBLANK ioctl argument type.502*503* \sa drmWaitVBlank().504*/505union drm_wait_vblank {506struct drm_wait_vblank_request request;507struct drm_wait_vblank_reply reply;508};509510#define _DRM_PRE_MODESET 1511#define _DRM_POST_MODESET 2512513/*514* DRM_IOCTL_MODESET_CTL ioctl argument type515*516* \sa drmModesetCtl().517*/518struct drm_modeset_ctl {519__u32 crtc;520__u32 cmd;521};522523/*524* DRM_IOCTL_AGP_ENABLE ioctl argument type.525*526* \sa drmAgpEnable().527*/528struct drm_agp_mode {529unsigned long mode; /**< AGP mode */530};531532/*533* DRM_IOCTL_AGP_ALLOC and DRM_IOCTL_AGP_FREE ioctls argument type.534*535* \sa drmAgpAlloc() and drmAgpFree().536*/537struct drm_agp_buffer {538unsigned long size; /**< In bytes -- will round to page boundary */539unsigned long handle; /**< Used for binding / unbinding */540unsigned long type; /**< Type of memory to allocate */541unsigned long physical; /**< Physical used by i810 */542};543544/*545* DRM_IOCTL_AGP_BIND and DRM_IOCTL_AGP_UNBIND ioctls argument type.546*547* \sa drmAgpBind() and drmAgpUnbind().548*/549struct drm_agp_binding {550unsigned long handle; /**< From drm_agp_buffer */551unsigned long offset; /**< In bytes -- will round to page boundary */552};553554/*555* DRM_IOCTL_AGP_INFO ioctl argument type.556*557* \sa drmAgpVersionMajor(), drmAgpVersionMinor(), drmAgpGetMode(),558* drmAgpBase(), drmAgpSize(), drmAgpMemoryUsed(), drmAgpMemoryAvail(),559* drmAgpVendorId() and drmAgpDeviceId().560*/561struct drm_agp_info {562int agp_version_major;563int agp_version_minor;564unsigned long mode;565unsigned long aperture_base; /* physical address */566unsigned long aperture_size; /* bytes */567unsigned long memory_allowed; /* bytes */568unsigned long memory_used;569570/* PCI information */571unsigned short id_vendor;572unsigned short id_device;573};574575/*576* DRM_IOCTL_SG_ALLOC ioctl argument type.577*/578struct drm_scatter_gather {579unsigned long size; /**< In bytes -- will round to page boundary */580unsigned long handle; /**< Used for mapping / unmapping */581};582583/*584* DRM_IOCTL_SET_VERSION ioctl argument type.585*/586struct drm_set_version {587int drm_di_major;588int drm_di_minor;589int drm_dd_major;590int drm_dd_minor;591};592593/* DRM_IOCTL_GEM_CLOSE ioctl argument type */594struct drm_gem_close {595/** Handle of the object to be closed. */596__u32 handle;597__u32 pad;598};599600/* DRM_IOCTL_GEM_FLINK ioctl argument type */601struct drm_gem_flink {602/** Handle for the object being named */603__u32 handle;604605/** Returned global name */606__u32 name;607};608609/* DRM_IOCTL_GEM_OPEN ioctl argument type */610struct drm_gem_open {611/** Name of object being opened */612__u32 name;613614/** Returned handle for the object */615__u32 handle;616617/** Returned size of the object */618__u64 size;619};620621/**622* DRM_CAP_DUMB_BUFFER623*624* If set to 1, the driver supports creating dumb buffers via the625* &DRM_IOCTL_MODE_CREATE_DUMB ioctl.626*/627#define DRM_CAP_DUMB_BUFFER 0x1628/**629* DRM_CAP_VBLANK_HIGH_CRTC630*631* If set to 1, the kernel supports specifying a CRTC index in the high bits of632* &drm_wait_vblank_request.type.633*634* Starting kernel version 2.6.39, this capability is always set to 1.635*/636#define DRM_CAP_VBLANK_HIGH_CRTC 0x2637/**638* DRM_CAP_DUMB_PREFERRED_DEPTH639*640* The preferred bit depth for dumb buffers.641*642* The bit depth is the number of bits used to indicate the color of a single643* pixel excluding any padding. This is different from the number of bits per644* pixel. For instance, XRGB8888 has a bit depth of 24 but has 32 bits per645* pixel.646*647* Note that this preference only applies to dumb buffers, it's irrelevant for648* other types of buffers.649*/650#define DRM_CAP_DUMB_PREFERRED_DEPTH 0x3651/**652* DRM_CAP_DUMB_PREFER_SHADOW653*654* If set to 1, the driver prefers userspace to render to a shadow buffer655* instead of directly rendering to a dumb buffer. For best speed, userspace656* should do streaming ordered memory copies into the dumb buffer and never657* read from it.658*659* Note that this preference only applies to dumb buffers, it's irrelevant for660* other types of buffers.661*/662#define DRM_CAP_DUMB_PREFER_SHADOW 0x4663/**664* DRM_CAP_PRIME665*666* Bitfield of supported PRIME sharing capabilities. See &DRM_PRIME_CAP_IMPORT667* and &DRM_PRIME_CAP_EXPORT.668*669* PRIME buffers are exposed as dma-buf file descriptors. See670* Documentation/gpu/drm-mm.rst, section "PRIME Buffer Sharing".671*/672#define DRM_CAP_PRIME 0x5673/**674* DRM_PRIME_CAP_IMPORT675*676* If this bit is set in &DRM_CAP_PRIME, the driver supports importing PRIME677* buffers via the &DRM_IOCTL_PRIME_FD_TO_HANDLE ioctl.678*/679#define DRM_PRIME_CAP_IMPORT 0x1680/**681* DRM_PRIME_CAP_EXPORT682*683* If this bit is set in &DRM_CAP_PRIME, the driver supports exporting PRIME684* buffers via the &DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl.685*/686#define DRM_PRIME_CAP_EXPORT 0x2687/**688* DRM_CAP_TIMESTAMP_MONOTONIC689*690* If set to 0, the kernel will report timestamps with ``CLOCK_REALTIME`` in691* struct drm_event_vblank. If set to 1, the kernel will report timestamps with692* ``CLOCK_MONOTONIC``. See ``clock_gettime(2)`` for the definition of these693* clocks.694*695* Starting from kernel version 2.6.39, the default value for this capability696* is 1. Starting kernel version 4.15, this capability is always set to 1.697*/698#define DRM_CAP_TIMESTAMP_MONOTONIC 0x6699/**700* DRM_CAP_ASYNC_PAGE_FLIP701*702* If set to 1, the driver supports &DRM_MODE_PAGE_FLIP_ASYNC.703*/704#define DRM_CAP_ASYNC_PAGE_FLIP 0x7705/**706* DRM_CAP_CURSOR_WIDTH707*708* The ``CURSOR_WIDTH`` and ``CURSOR_HEIGHT`` capabilities return a valid709* width x height combination for the hardware cursor. The intention is that a710* hardware agnostic userspace can query a cursor plane size to use.711*712* Note that the cross-driver contract is to merely return a valid size;713* drivers are free to attach another meaning on top, eg. i915 returns the714* maximum plane size.715*/716#define DRM_CAP_CURSOR_WIDTH 0x8717/**718* DRM_CAP_CURSOR_HEIGHT719*720* See &DRM_CAP_CURSOR_WIDTH.721*/722#define DRM_CAP_CURSOR_HEIGHT 0x9723/**724* DRM_CAP_ADDFB2_MODIFIERS725*726* If set to 1, the driver supports supplying modifiers in the727* &DRM_IOCTL_MODE_ADDFB2 ioctl.728*/729#define DRM_CAP_ADDFB2_MODIFIERS 0x10730/**731* DRM_CAP_PAGE_FLIP_TARGET732*733* If set to 1, the driver supports the &DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and734* &DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in735* &drm_mode_crtc_page_flip_target.flags for the &DRM_IOCTL_MODE_PAGE_FLIP736* ioctl.737*/738#define DRM_CAP_PAGE_FLIP_TARGET 0x11739/**740* DRM_CAP_CRTC_IN_VBLANK_EVENT741*742* If set to 1, the kernel supports reporting the CRTC ID in743* &drm_event_vblank.crtc_id for the &DRM_EVENT_VBLANK and744* &DRM_EVENT_FLIP_COMPLETE events.745*746* Starting kernel version 4.12, this capability is always set to 1.747*/748#define DRM_CAP_CRTC_IN_VBLANK_EVENT 0x12749/**750* DRM_CAP_SYNCOBJ751*752* If set to 1, the driver supports sync objects. See753* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".754*/755#define DRM_CAP_SYNCOBJ 0x13756/**757* DRM_CAP_SYNCOBJ_TIMELINE758*759* If set to 1, the driver supports timeline operations on sync objects. See760* Documentation/gpu/drm-mm.rst, section "DRM Sync Objects".761*/762#define DRM_CAP_SYNCOBJ_TIMELINE 0x14763764/* DRM_IOCTL_GET_CAP ioctl argument type */765struct drm_get_cap {766__u64 capability;767__u64 value;768};769770/**771* DRM_CLIENT_CAP_STEREO_3D772*773* If set to 1, the DRM core will expose the stereo 3D capabilities of the774* monitor by advertising the supported 3D layouts in the flags of struct775* drm_mode_modeinfo. See ``DRM_MODE_FLAG_3D_*``.776*777* This capability is always supported for all drivers starting from kernel778* version 3.13.779*/780#define DRM_CLIENT_CAP_STEREO_3D 1781782/**783* DRM_CLIENT_CAP_UNIVERSAL_PLANES784*785* If set to 1, the DRM core will expose all planes (overlay, primary, and786* cursor) to userspace.787*788* This capability has been introduced in kernel version 3.15. Starting from789* kernel version 3.17, this capability is always supported for all drivers.790*/791#define DRM_CLIENT_CAP_UNIVERSAL_PLANES 2792793/**794* DRM_CLIENT_CAP_ATOMIC795*796* If set to 1, the DRM core will expose atomic properties to userspace. This797* implicitly enables &DRM_CLIENT_CAP_UNIVERSAL_PLANES and798* &DRM_CLIENT_CAP_ASPECT_RATIO.799*800* If the driver doesn't support atomic mode-setting, enabling this capability801* will fail with -EOPNOTSUPP.802*803* This capability has been introduced in kernel version 4.0. Starting from804* kernel version 4.2, this capability is always supported for atomic-capable805* drivers.806*/807#define DRM_CLIENT_CAP_ATOMIC 3808809/**810* DRM_CLIENT_CAP_ASPECT_RATIO811*812* If set to 1, the DRM core will provide aspect ratio information in modes.813* See ``DRM_MODE_FLAG_PIC_AR_*``.814*815* This capability is always supported for all drivers starting from kernel816* version 4.18.817*/818#define DRM_CLIENT_CAP_ASPECT_RATIO 4819820/**821* DRM_CLIENT_CAP_WRITEBACK_CONNECTORS822*823* If set to 1, the DRM core will expose special connectors to be used for824* writing back to memory the scene setup in the commit. The client must enable825* &DRM_CLIENT_CAP_ATOMIC first.826*827* This capability is always supported for atomic-capable drivers starting from828* kernel version 4.19.829*/830#define DRM_CLIENT_CAP_WRITEBACK_CONNECTORS 5831832/* DRM_IOCTL_SET_CLIENT_CAP ioctl argument type */833struct drm_set_client_cap {834__u64 capability;835__u64 value;836};837838#define DRM_RDWR O_RDWR839#define DRM_CLOEXEC O_CLOEXEC840struct drm_prime_handle {841__u32 handle;842843/** Flags.. only applicable for handle->fd */844__u32 flags;845846/** Returned dmabuf file descriptor */847__s32 fd;848};849850struct drm_syncobj_create {851__u32 handle;852#define DRM_SYNCOBJ_CREATE_SIGNALED (1 << 0)853__u32 flags;854};855856struct drm_syncobj_destroy {857__u32 handle;858__u32 pad;859};860861#define DRM_SYNCOBJ_FD_TO_HANDLE_FLAGS_IMPORT_SYNC_FILE (1 << 0)862#define DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE (1 << 0)863struct drm_syncobj_handle {864__u32 handle;865__u32 flags;866867__s32 fd;868__u32 pad;869};870871struct drm_syncobj_transfer {872__u32 src_handle;873__u32 dst_handle;874__u64 src_point;875__u64 dst_point;876__u32 flags;877__u32 pad;878};879880#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_ALL (1 << 0)881#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_FOR_SUBMIT (1 << 1)882#define DRM_SYNCOBJ_WAIT_FLAGS_WAIT_AVAILABLE (1 << 2) /* wait for time point to become available */883struct drm_syncobj_wait {884__u64 handles;885/* absolute timeout */886__s64 timeout_nsec;887__u32 count_handles;888__u32 flags;889__u32 first_signaled; /* only valid when not waiting all */890__u32 pad;891};892893struct drm_syncobj_timeline_wait {894__u64 handles;895/* wait on specific timeline point for every handles*/896__u64 points;897/* absolute timeout */898__s64 timeout_nsec;899__u32 count_handles;900__u32 flags;901__u32 first_signaled; /* only valid when not waiting all */902__u32 pad;903};904905906struct drm_syncobj_array {907__u64 handles;908__u32 count_handles;909__u32 pad;910};911912#define DRM_SYNCOBJ_QUERY_FLAGS_LAST_SUBMITTED (1 << 0) /* last available point on timeline syncobj */913struct drm_syncobj_timeline_array {914__u64 handles;915__u64 points;916__u32 count_handles;917__u32 flags;918};919920921/* Query current scanout sequence number */922struct drm_crtc_get_sequence {923__u32 crtc_id; /* requested crtc_id */924__u32 active; /* return: crtc output is active */925__u64 sequence; /* return: most recent vblank sequence */926__s64 sequence_ns; /* return: most recent time of first pixel out */927};928929/* Queue event to be delivered at specified sequence. Time stamp marks930* when the first pixel of the refresh cycle leaves the display engine931* for the display932*/933#define DRM_CRTC_SEQUENCE_RELATIVE 0x00000001 /* sequence is relative to current */934#define DRM_CRTC_SEQUENCE_NEXT_ON_MISS 0x00000002 /* Use next sequence if we've missed */935936struct drm_crtc_queue_sequence {937__u32 crtc_id;938__u32 flags;939__u64 sequence; /* on input, target sequence. on output, actual sequence */940__u64 user_data; /* user data passed to event */941};942943#if defined(__cplusplus)944}945#endif946947#include "drm_mode.h"948949#if defined(__cplusplus)950extern "C" {951#endif952953#define DRM_IOCTL_BASE 'd'954#define DRM_IO(nr) _IO(DRM_IOCTL_BASE,nr)955#define DRM_IOR(nr,type) _IOR(DRM_IOCTL_BASE,nr,type)956#define DRM_IOW(nr,type) _IOW(DRM_IOCTL_BASE,nr,type)957#define DRM_IOWR(nr,type) _IOWR(DRM_IOCTL_BASE,nr,type)958959#define DRM_IOCTL_VERSION DRM_IOWR(0x00, struct drm_version)960#define DRM_IOCTL_GET_UNIQUE DRM_IOWR(0x01, struct drm_unique)961#define DRM_IOCTL_GET_MAGIC DRM_IOR( 0x02, struct drm_auth)962#define DRM_IOCTL_IRQ_BUSID DRM_IOWR(0x03, struct drm_irq_busid)963#define DRM_IOCTL_GET_MAP DRM_IOWR(0x04, struct drm_map)964#define DRM_IOCTL_GET_CLIENT DRM_IOWR(0x05, struct drm_client)965#define DRM_IOCTL_GET_STATS DRM_IOR( 0x06, struct drm_stats)966#define DRM_IOCTL_SET_VERSION DRM_IOWR(0x07, struct drm_set_version)967#define DRM_IOCTL_MODESET_CTL DRM_IOW(0x08, struct drm_modeset_ctl)968#define DRM_IOCTL_GEM_CLOSE DRM_IOW (0x09, struct drm_gem_close)969#define DRM_IOCTL_GEM_FLINK DRM_IOWR(0x0a, struct drm_gem_flink)970#define DRM_IOCTL_GEM_OPEN DRM_IOWR(0x0b, struct drm_gem_open)971#define DRM_IOCTL_GET_CAP DRM_IOWR(0x0c, struct drm_get_cap)972#define DRM_IOCTL_SET_CLIENT_CAP DRM_IOW( 0x0d, struct drm_set_client_cap)973974#define DRM_IOCTL_SET_UNIQUE DRM_IOW( 0x10, struct drm_unique)975#define DRM_IOCTL_AUTH_MAGIC DRM_IOW( 0x11, struct drm_auth)976#define DRM_IOCTL_BLOCK DRM_IOWR(0x12, struct drm_block)977#define DRM_IOCTL_UNBLOCK DRM_IOWR(0x13, struct drm_block)978#define DRM_IOCTL_CONTROL DRM_IOW( 0x14, struct drm_control)979#define DRM_IOCTL_ADD_MAP DRM_IOWR(0x15, struct drm_map)980#define DRM_IOCTL_ADD_BUFS DRM_IOWR(0x16, struct drm_buf_desc)981#define DRM_IOCTL_MARK_BUFS DRM_IOW( 0x17, struct drm_buf_desc)982#define DRM_IOCTL_INFO_BUFS DRM_IOWR(0x18, struct drm_buf_info)983#define DRM_IOCTL_MAP_BUFS DRM_IOWR(0x19, struct drm_buf_map)984#define DRM_IOCTL_FREE_BUFS DRM_IOW( 0x1a, struct drm_buf_free)985986#define DRM_IOCTL_RM_MAP DRM_IOW( 0x1b, struct drm_map)987988#define DRM_IOCTL_SET_SAREA_CTX DRM_IOW( 0x1c, struct drm_ctx_priv_map)989#define DRM_IOCTL_GET_SAREA_CTX DRM_IOWR(0x1d, struct drm_ctx_priv_map)990991#define DRM_IOCTL_SET_MASTER DRM_IO(0x1e)992#define DRM_IOCTL_DROP_MASTER DRM_IO(0x1f)993994#define DRM_IOCTL_ADD_CTX DRM_IOWR(0x20, struct drm_ctx)995#define DRM_IOCTL_RM_CTX DRM_IOWR(0x21, struct drm_ctx)996#define DRM_IOCTL_MOD_CTX DRM_IOW( 0x22, struct drm_ctx)997#define DRM_IOCTL_GET_CTX DRM_IOWR(0x23, struct drm_ctx)998#define DRM_IOCTL_SWITCH_CTX DRM_IOW( 0x24, struct drm_ctx)999#define DRM_IOCTL_NEW_CTX DRM_IOW( 0x25, struct drm_ctx)1000#define DRM_IOCTL_RES_CTX DRM_IOWR(0x26, struct drm_ctx_res)1001#define DRM_IOCTL_ADD_DRAW DRM_IOWR(0x27, struct drm_draw)1002#define DRM_IOCTL_RM_DRAW DRM_IOWR(0x28, struct drm_draw)1003#define DRM_IOCTL_DMA DRM_IOWR(0x29, struct drm_dma)1004#define DRM_IOCTL_LOCK DRM_IOW( 0x2a, struct drm_lock)1005#define DRM_IOCTL_UNLOCK DRM_IOW( 0x2b, struct drm_lock)1006#define DRM_IOCTL_FINISH DRM_IOW( 0x2c, struct drm_lock)10071008#define DRM_IOCTL_PRIME_HANDLE_TO_FD DRM_IOWR(0x2d, struct drm_prime_handle)1009#define DRM_IOCTL_PRIME_FD_TO_HANDLE DRM_IOWR(0x2e, struct drm_prime_handle)10101011#define DRM_IOCTL_AGP_ACQUIRE DRM_IO( 0x30)1012#define DRM_IOCTL_AGP_RELEASE DRM_IO( 0x31)1013#define DRM_IOCTL_AGP_ENABLE DRM_IOW( 0x32, struct drm_agp_mode)1014#define DRM_IOCTL_AGP_INFO DRM_IOR( 0x33, struct drm_agp_info)1015#define DRM_IOCTL_AGP_ALLOC DRM_IOWR(0x34, struct drm_agp_buffer)1016#define DRM_IOCTL_AGP_FREE DRM_IOW( 0x35, struct drm_agp_buffer)1017#define DRM_IOCTL_AGP_BIND DRM_IOW( 0x36, struct drm_agp_binding)1018#define DRM_IOCTL_AGP_UNBIND DRM_IOW( 0x37, struct drm_agp_binding)10191020#define DRM_IOCTL_SG_ALLOC DRM_IOWR(0x38, struct drm_scatter_gather)1021#define DRM_IOCTL_SG_FREE DRM_IOW( 0x39, struct drm_scatter_gather)10221023#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, union drm_wait_vblank)10241025#define DRM_IOCTL_CRTC_GET_SEQUENCE DRM_IOWR(0x3b, struct drm_crtc_get_sequence)1026#define DRM_IOCTL_CRTC_QUEUE_SEQUENCE DRM_IOWR(0x3c, struct drm_crtc_queue_sequence)10271028#define DRM_IOCTL_UPDATE_DRAW DRM_IOW(0x3f, struct drm_update_draw)10291030#define DRM_IOCTL_MODE_GETRESOURCES DRM_IOWR(0xA0, struct drm_mode_card_res)1031#define DRM_IOCTL_MODE_GETCRTC DRM_IOWR(0xA1, struct drm_mode_crtc)1032#define DRM_IOCTL_MODE_SETCRTC DRM_IOWR(0xA2, struct drm_mode_crtc)1033#define DRM_IOCTL_MODE_CURSOR DRM_IOWR(0xA3, struct drm_mode_cursor)1034#define DRM_IOCTL_MODE_GETGAMMA DRM_IOWR(0xA4, struct drm_mode_crtc_lut)1035#define DRM_IOCTL_MODE_SETGAMMA DRM_IOWR(0xA5, struct drm_mode_crtc_lut)1036#define DRM_IOCTL_MODE_GETENCODER DRM_IOWR(0xA6, struct drm_mode_get_encoder)1037#define DRM_IOCTL_MODE_GETCONNECTOR DRM_IOWR(0xA7, struct drm_mode_get_connector)1038#define DRM_IOCTL_MODE_ATTACHMODE DRM_IOWR(0xA8, struct drm_mode_mode_cmd) /* deprecated (never worked) */1039#define DRM_IOCTL_MODE_DETACHMODE DRM_IOWR(0xA9, struct drm_mode_mode_cmd) /* deprecated (never worked) */10401041#define DRM_IOCTL_MODE_GETPROPERTY DRM_IOWR(0xAA, struct drm_mode_get_property)1042#define DRM_IOCTL_MODE_SETPROPERTY DRM_IOWR(0xAB, struct drm_mode_connector_set_property)1043#define DRM_IOCTL_MODE_GETPROPBLOB DRM_IOWR(0xAC, struct drm_mode_get_blob)1044#define DRM_IOCTL_MODE_GETFB DRM_IOWR(0xAD, struct drm_mode_fb_cmd)1045#define DRM_IOCTL_MODE_ADDFB DRM_IOWR(0xAE, struct drm_mode_fb_cmd)1046#define DRM_IOCTL_MODE_RMFB DRM_IOWR(0xAF, unsigned int)1047#define DRM_IOCTL_MODE_PAGE_FLIP DRM_IOWR(0xB0, struct drm_mode_crtc_page_flip)1048#define DRM_IOCTL_MODE_DIRTYFB DRM_IOWR(0xB1, struct drm_mode_fb_dirty_cmd)10491050#define DRM_IOCTL_MODE_CREATE_DUMB DRM_IOWR(0xB2, struct drm_mode_create_dumb)1051#define DRM_IOCTL_MODE_MAP_DUMB DRM_IOWR(0xB3, struct drm_mode_map_dumb)1052#define DRM_IOCTL_MODE_DESTROY_DUMB DRM_IOWR(0xB4, struct drm_mode_destroy_dumb)1053#define DRM_IOCTL_MODE_GETPLANERESOURCES DRM_IOWR(0xB5, struct drm_mode_get_plane_res)1054#define DRM_IOCTL_MODE_GETPLANE DRM_IOWR(0xB6, struct drm_mode_get_plane)1055#define DRM_IOCTL_MODE_SETPLANE DRM_IOWR(0xB7, struct drm_mode_set_plane)1056#define DRM_IOCTL_MODE_ADDFB2 DRM_IOWR(0xB8, struct drm_mode_fb_cmd2)1057#define DRM_IOCTL_MODE_OBJ_GETPROPERTIES DRM_IOWR(0xB9, struct drm_mode_obj_get_properties)1058#define DRM_IOCTL_MODE_OBJ_SETPROPERTY DRM_IOWR(0xBA, struct drm_mode_obj_set_property)1059#define DRM_IOCTL_MODE_CURSOR2 DRM_IOWR(0xBB, struct drm_mode_cursor2)1060#define DRM_IOCTL_MODE_ATOMIC DRM_IOWR(0xBC, struct drm_mode_atomic)1061#define DRM_IOCTL_MODE_CREATEPROPBLOB DRM_IOWR(0xBD, struct drm_mode_create_blob)1062#define DRM_IOCTL_MODE_DESTROYPROPBLOB DRM_IOWR(0xBE, struct drm_mode_destroy_blob)10631064#define DRM_IOCTL_SYNCOBJ_CREATE DRM_IOWR(0xBF, struct drm_syncobj_create)1065#define DRM_IOCTL_SYNCOBJ_DESTROY DRM_IOWR(0xC0, struct drm_syncobj_destroy)1066#define DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD DRM_IOWR(0xC1, struct drm_syncobj_handle)1067#define DRM_IOCTL_SYNCOBJ_FD_TO_HANDLE DRM_IOWR(0xC2, struct drm_syncobj_handle)1068#define DRM_IOCTL_SYNCOBJ_WAIT DRM_IOWR(0xC3, struct drm_syncobj_wait)1069#define DRM_IOCTL_SYNCOBJ_RESET DRM_IOWR(0xC4, struct drm_syncobj_array)1070#define DRM_IOCTL_SYNCOBJ_SIGNAL DRM_IOWR(0xC5, struct drm_syncobj_array)10711072#define DRM_IOCTL_MODE_CREATE_LEASE DRM_IOWR(0xC6, struct drm_mode_create_lease)1073#define DRM_IOCTL_MODE_LIST_LESSEES DRM_IOWR(0xC7, struct drm_mode_list_lessees)1074#define DRM_IOCTL_MODE_GET_LEASE DRM_IOWR(0xC8, struct drm_mode_get_lease)1075#define DRM_IOCTL_MODE_REVOKE_LEASE DRM_IOWR(0xC9, struct drm_mode_revoke_lease)10761077#define DRM_IOCTL_SYNCOBJ_TIMELINE_WAIT DRM_IOWR(0xCA, struct drm_syncobj_timeline_wait)1078#define DRM_IOCTL_SYNCOBJ_QUERY DRM_IOWR(0xCB, struct drm_syncobj_timeline_array)1079#define DRM_IOCTL_SYNCOBJ_TRANSFER DRM_IOWR(0xCC, struct drm_syncobj_transfer)1080#define DRM_IOCTL_SYNCOBJ_TIMELINE_SIGNAL DRM_IOWR(0xCD, struct drm_syncobj_timeline_array)10811082#define DRM_IOCTL_MODE_GETFB2 DRM_IOWR(0xCE, struct drm_mode_fb_cmd2)10831084/*1085* Device specific ioctls should only be in their respective headers1086* The device specific ioctl range is from 0x40 to 0x9f.1087* Generic IOCTLS restart at 0xA0.1088*1089* \sa drmCommandNone(), drmCommandRead(), drmCommandWrite(), and1090* drmCommandReadWrite().1091*/1092#define DRM_COMMAND_BASE 0x401093#define DRM_COMMAND_END 0xA010941095/*1096* Header for events written back to userspace on the drm fd. The1097* type defines the type of event, the length specifies the total1098* length of the event (including the header), and user_data is1099* typically a 64 bit value passed with the ioctl that triggered the1100* event. A read on the drm fd will always only return complete1101* events, that is, if for example the read buffer is 100 bytes, and1102* there are two 64 byte events pending, only one will be returned.1103*1104* Event types 0 - 0x7fffffff are generic drm events, 0x80000000 and1105* up are chipset specific.1106*/1107struct drm_event {1108__u32 type;1109__u32 length;1110};11111112#define DRM_EVENT_VBLANK 0x011113#define DRM_EVENT_FLIP_COMPLETE 0x021114#define DRM_EVENT_CRTC_SEQUENCE 0x0311151116struct drm_event_vblank {1117struct drm_event base;1118__u64 user_data;1119__u32 tv_sec;1120__u32 tv_usec;1121__u32 sequence;1122__u32 crtc_id; /* 0 on older kernels that do not support this */1123};11241125/* Event delivered at sequence. Time stamp marks when the first pixel1126* of the refresh cycle leaves the display engine for the display1127*/1128struct drm_event_crtc_sequence {1129struct drm_event base;1130__u64 user_data;1131__s64 time_ns;1132__u64 sequence;1133};11341135/* typedef area */1136typedef struct drm_clip_rect drm_clip_rect_t;1137typedef struct drm_drawable_info drm_drawable_info_t;1138typedef struct drm_tex_region drm_tex_region_t;1139typedef struct drm_hw_lock drm_hw_lock_t;1140typedef struct drm_version drm_version_t;1141typedef struct drm_unique drm_unique_t;1142typedef struct drm_list drm_list_t;1143typedef struct drm_block drm_block_t;1144typedef struct drm_control drm_control_t;1145typedef enum drm_map_type drm_map_type_t;1146typedef enum drm_map_flags drm_map_flags_t;1147typedef struct drm_ctx_priv_map drm_ctx_priv_map_t;1148typedef struct drm_map drm_map_t;1149typedef struct drm_client drm_client_t;1150typedef enum drm_stat_type drm_stat_type_t;1151typedef struct drm_stats drm_stats_t;1152typedef enum drm_lock_flags drm_lock_flags_t;1153typedef struct drm_lock drm_lock_t;1154typedef enum drm_dma_flags drm_dma_flags_t;1155typedef struct drm_buf_desc drm_buf_desc_t;1156typedef struct drm_buf_info drm_buf_info_t;1157typedef struct drm_buf_free drm_buf_free_t;1158typedef struct drm_buf_pub drm_buf_pub_t;1159typedef struct drm_buf_map drm_buf_map_t;1160typedef struct drm_dma drm_dma_t;1161typedef union drm_wait_vblank drm_wait_vblank_t;1162typedef struct drm_agp_mode drm_agp_mode_t;1163typedef enum drm_ctx_flags drm_ctx_flags_t;1164typedef struct drm_ctx drm_ctx_t;1165typedef struct drm_ctx_res drm_ctx_res_t;1166typedef struct drm_draw drm_draw_t;1167typedef struct drm_update_draw drm_update_draw_t;1168typedef struct drm_auth drm_auth_t;1169typedef struct drm_irq_busid drm_irq_busid_t;1170typedef enum drm_vblank_seq_type drm_vblank_seq_type_t;11711172typedef struct drm_agp_buffer drm_agp_buffer_t;1173typedef struct drm_agp_binding drm_agp_binding_t;1174typedef struct drm_agp_info drm_agp_info_t;1175typedef struct drm_scatter_gather drm_scatter_gather_t;1176typedef struct drm_set_version drm_set_version_t;11771178#if defined(__cplusplus)1179}1180#endif11811182#endif118311841185