Userland interfaces

The DRM core exports several interfaces to applications, generally intended to be used through corresponding libdrm wrapper functions. In addition, drivers export device-specific interfaces for use by userspace drivers & device-aware applications through ioctls and sysfs files.

External interfaces include: memory mapping, context management, DMA operations, AGP management, vblank control, fence management, memory management, and output management.

Cover generic ioctls and sysfs layout here. We only need high-level info, since man pages should cover the rest.

libdrm Device Lookup


In an attempt to warn anyone else who's trying to figure out what's going on here, I'll try to summarize the story. First things first, let's clear up the names, because the kernel internals, libdrm and the ioctls are all named differently:

  • GET_UNIQUE ioctl, implemented by drm_getunique is wrapped up in libdrm through the drmGetBusid function.

  • The libdrm drmSetBusid function is backed by the SET_UNIQUE ioctl. All that code is nerved in the kernel with drm_invalid_op().

  • The internal set_busid kernel functions and driver callbacks are exclusively use by the SET_VERSION ioctl, because only drm 1.0 (which is nerved) allowed userspace to set the busid through the above ioctl.

  • Other ioctls and functions involved are named consistently.

For anyone wondering what's the difference between drm 1.1 and 1.4: Correctly handling pci domains in the busid on ppc. Doing this correctly was only implemented in libdrm in 2010, hence can't be nerved yet. No one knows what's special with drm 1.2 and 1.3.

Now the actual horror story of how device lookup in drm works. At large, there's 2 different ways, either by busid, or by device driver name.

Opening by busid is fairly simple:

  1. First call SET_VERSION to make sure pci domains are handled properly. As a side-effect this fills out the unique name in the master structure.

  2. Call GET_UNIQUE to read out the unique name from the master structure, which matches the busid thanks to step 1. If it doesn't, proceed to try the next device node.

Opening by name is slightly different:

  1. Directly call VERSION to get the version and to match against the driver name returned by that ioctl. Note that SET_VERSION is not called, which means the unique name for the master node just opening is _not_ filled out. This despite that with current drm device nodes are always bound to one device, and can't be runtime assigned like with drm 1.0.

  2. Match driver name. If it mismatches, proceed to the next device node.

  3. Call GET_UNIQUE, and check whether the unique name has length zero (by checking that the first byte in the string is 0). If that's not the case libdrm skips and proceeds to the next device node. Probably this is just copypasta from drm 1.0 times where a set unique name meant that the driver was in use already, but that's just conjecture.

Long story short: To keep the open by name logic working, GET_UNIQUE must _not_ return a unique string when SET_VERSION hasn't been called yet, otherwise libdrm breaks. Even when that unique string can't ever change, and is totally irrelevant for actually opening the device because runtime assignable device instances were only support in drm 1.0, which is long dead. But the libdrm code in drmOpenByName somehow survived, hence this can't be broken.

Primary Nodes, DRM Master and Authentication

struct drm_master is used to track groups of clients with open primary/legacy device nodes. For every struct drm_file which has had at least once successfully became the device master (either through the SET_MASTER IOCTL, or implicitly through opening the primary device node when no one else is the current master that time) there exists one drm_master. This is noted in drm_file.is_master. All other clients have just a pointer to the drm_master they are associated with.

In addition only one drm_master can be the current master for a drm_device. It can be switched through the DROP_MASTER and SET_MASTER IOCTL, or implicitly through closing/opening the primary device node. See also drm_is_current_master().

Clients can authenticate against the current master (if it matches their own) using the GETMAGIC and AUTHMAGIC IOCTLs. Together with exchanging masters, this allows controlled access to the device for an entire group of mutually trusted clients.

bool drm_is_current_master(struct drm_file *fpriv)

checks whether priv is the current master


struct drm_file *fpriv

DRM file private


Checks whether fpriv is current master on its device. This decides whether a client is allowed to run DRM_MASTER IOCTLs.

Most of the modern IOCTL which require DRM_MASTER are for kernel modesetting - the current master is assumed to own the non-shareable display hardware.

struct drm_master *drm_master_get(struct drm_master *master)

reference a master pointer


struct drm_master *master

struct drm_master


Increments the reference count of master and returns a pointer to master.

struct drm_master *drm_file_get_master(struct drm_file *file_priv)

reference drm_file.master of file_priv


struct drm_file *file_priv

DRM file private


Increments the reference count of file_priv's drm_file.master and returns the drm_file.master. If file_priv has no drm_file.master, returns NULL.

Master pointers returned from this function should be unreferenced using drm_master_put().

void drm_master_put(struct drm_master **master)

unreference and clear a master pointer


struct drm_master **master

pointer to a pointer of struct drm_master


This decrements the drm_master behind master and sets it to NULL.

struct drm_master

drm master structure


struct drm_master {
    struct kref refcount;
    struct drm_device *dev;
    char *unique;
    int unique_len;
    struct idr magic_map;
    void *driver_priv;
    struct drm_master *lessor;
    int lessee_id;
    struct list_head lessee_list;
    struct list_head lessees;
    struct idr leases;
    struct idr lessee_idr;



Refcount for this master object.


Link back to the DRM device


Unique identifier: e.g. busid. Protected by drm_device.master_mutex.


Length of unique field. Protected by drm_device.master_mutex.


Map of used authentication tokens. Protected by drm_device.master_mutex.


Pointer to driver-private information.


Lease grantor, only set if this struct drm_master represents a lessee holding a lease of objects from lessor. Full owners of the device have this set to NULL.

The lessor does not change once it's set in drm_lease_create(), and each lessee holds a reference to its lessor that it releases upon being destroyed in drm_lease_destroy().

See also the section on display resource leasing.


ID for lessees. Owners (i.e. lessor is NULL) always have ID 0. Protected by drm_device.mode_config's drm_mode_config.idr_mutex.


List entry of lessees of lessor, where they are linked to lessees. Not used for owners. Protected by drm_device.mode_config's drm_mode_config.idr_mutex.


List of drm_masters leasing from this one. Protected by drm_device.mode_config's drm_mode_config.idr_mutex.

This list is empty if no leases have been granted, or if all lessees have been destroyed. Since lessors are referenced by all their lessees, this master cannot be destroyed unless the list is empty.


Objects leased to this drm_master. Protected by drm_device.mode_config's drm_mode_config.idr_mutex.

Objects are leased all together in drm_lease_create(), and are removed all together when the lease is revoked.


All lessees under this owner (only used where lessor is NULL). Protected by drm_device.mode_config's drm_mode_config.idr_mutex.


Note that master structures are only relevant for the legacy/primary device nodes, hence there can only be one per device, not one per drm_minor.

DRM Display Resource Leasing

DRM leases provide information about whether a DRM master may control a DRM mode setting object. This enables the creation of multiple DRM masters that manage subsets of display resources.

The original DRM master of a device 'owns' the available drm resources. It may create additional DRM masters and 'lease' resources which it controls to the new DRM master. This gives the new DRM master control over the leased resources until the owner revokes the lease, or the new DRM master is closed. Some helpful terminology:

  • An 'owner' is a struct drm_master that is not leasing objects from another struct drm_master, and hence 'owns' the objects. The owner can be identified as the struct drm_master for which drm_master.lessor is NULL.

  • A 'lessor' is a struct drm_master which is leasing objects to one or more other struct drm_master. Currently, lessees are not allowed to create sub-leases, hence the lessor is the same as the owner.

  • A 'lessee' is a struct drm_master which is leasing objects from some other struct drm_master. Each lessee only leases resources from a single lessor recorded in drm_master.lessor, and holds the set of objects that it is leasing in drm_master.leases.

  • A 'lease' is a contract between the lessor and lessee that identifies which resources may be controlled by the lessee. All of the resources that are leased must be owned by or leased to the lessor, and lessors are not permitted to lease the same object to multiple lessees.

The set of objects any struct drm_master 'controls' is limited to the set of objects it leases (for lessees) or all objects (for owners).

Objects not controlled by a struct drm_master cannot be modified through the various state manipulating ioctls, and any state reported back to user space will be edited to make them appear idle and/or unusable. For instance, connectors always report 'disconnected', while encoders report no possible crtcs or clones.

Since each lessee may lease objects from a single lessor, display resource leases form a tree of struct drm_master. As lessees are currently not allowed to create sub-leases, the tree depth is limited to 1. All of these get activated simultaneously when the top level device owner changes through the SETMASTER or DROPMASTER IOCTL, so drm_device.master points to the owner at the top of the lease tree (i.e. the struct drm_master for which drm_master.lessor is NULL). The full list of lessees that are leasing objects from the owner can be searched via the owner's drm_master.lessee_idr.

Open-Source Userspace Requirements

The DRM subsystem has stricter requirements than most other kernel subsystems on what the userspace side for new uAPI needs to look like. This section here explains what exactly those requirements are, and why they exist.

The short summary is that any addition of DRM uAPI requires corresponding open-sourced userspace patches, and those patches must be reviewed and ready for merging into a suitable and canonical upstream project.

GFX devices (both display and render/GPU side) are really complex bits of hardware, with userspace and kernel by necessity having to work together really closely. The interfaces, for rendering and modesetting, must be extremely wide and flexible, and therefore it is almost always impossible to precisely define them for every possible corner case. This in turn makes it really practically infeasible to differentiate between behaviour that's required by userspace, and which must not be changed to avoid regressions, and behaviour which is only an accidental artifact of the current implementation.

Without access to the full source code of all userspace users that means it becomes impossible to change the implementation details, since userspace could depend upon the accidental behaviour of the current implementation in minute details. And debugging such regressions without access to source code is pretty much impossible. As a consequence this means:

  • The Linux kernel's "no regression" policy holds in practice only for open-source userspace of the DRM subsystem. DRM developers are perfectly fine if closed-source blob drivers in userspace use the same uAPI as the open drivers, but they must do so in the exact same way as the open drivers. Creative (ab)use of the interfaces will, and in the past routinely has, lead to breakage.

  • Any new userspace interface must have an open-source implementation as demonstration vehicle.

The other reason for requiring open-source userspace is uAPI review. Since the kernel and userspace parts of a GFX stack must work together so closely, code review can only assess whether a new interface achieves its goals by looking at both sides. Making sure that the interface indeed covers the use-case fully leads to a few additional requirements:

  • The open-source userspace must not be a toy/test application, but the real thing. Specifically it needs to handle all the usual error and corner cases. These are often the places where new uAPI falls apart and hence essential to assess the fitness of a proposed interface.

  • The userspace side must be fully reviewed and tested to the standards of that userspace project. For e.g. mesa this means piglit testcases and review on the mailing list. This is again to ensure that the new interface actually gets the job done. The userspace-side reviewer should also provide an Acked-by on the kernel uAPI patch indicating that they believe the proposed uAPI is sound and sufficiently documented and validated for userspace's consumption.

  • The userspace patches must be against the canonical upstream, not some vendor fork. This is to make sure that no one cheats on the review and testing requirements by doing a quick fork.

  • The kernel patch can only be merged after all the above requirements are met, but it must be merged to either drm-next or drm-misc-next before the userspace patches land. uAPI always flows from the kernel, doing things the other way round risks divergence of the uAPI definitions and header files.

These are fairly steep requirements, but have grown out from years of shared pain and experience with uAPI added hastily, and almost always regretted about just as fast. GFX devices change really fast, requiring a paradigm shift and entire new set of uAPI interfaces every few years at least. Together with the Linux kernel's guarantee to keep existing userspace running for 10+ years this is already rather painful for the DRM subsystem, with multiple different uAPIs for the same thing co-existing. If we add a few more complete mistakes into the mix every year it would be entirely unmanageable.

Render nodes

DRM core provides multiple character-devices for user-space to use. Depending on which device is opened, user-space can perform a different set of operations (mainly ioctls). The primary node is always created and called card<num>. Additionally, a currently unused control node, called controlD<num> is also created. The primary node provides all legacy operations and historically was the only interface used by userspace. With KMS, the control node was introduced. However, the planned KMS control interface has never been written and so the control node stays unused to date.

With the increased use of offscreen renderers and GPGPU applications, clients no longer require running compositors or graphics servers to make use of a GPU. But the DRM API required unprivileged clients to authenticate to a DRM-Master prior to getting GPU access. To avoid this step and to grant clients GPU access without authenticating, render nodes were introduced. Render nodes solely serve render clients, that is, no modesetting or privileged ioctls can be issued on render nodes. Only non-global rendering commands are allowed. If a driver supports render nodes, it must advertise it via the DRIVER_RENDER DRM driver capability. If not supported, the primary node must be used for render clients together with the legacy drmAuth authentication procedure.

If a driver advertises render node support, DRM core will create a separate render node called renderD<num>. There will be one render node per device. No ioctls except PRIME-related ioctls will be allowed on this node. Especially GEM_OPEN will be explicitly prohibited. For a complete list of driver-independent ioctls that can be used on render nodes, see the ioctls marked DRM_RENDER_ALLOW in drm_ioctl.c Render nodes are designed to avoid the buffer-leaks, which occur if clients guess the flink names or mmap offsets on the legacy interface. Additionally to this basic interface, drivers must mark their driver-dependent render-only ioctls as DRM_RENDER_ALLOW so render clients can use them. Driver authors must be careful not to allow any privileged ioctls on render nodes.

With render nodes, user-space can now control access to the render node via basic file-system access-modes. A running graphics server which authenticates clients on the privileged primary/legacy node is no longer required. Instead, a client can open the render node and is immediately granted GPU access. Communication between clients (or servers) is done via PRIME. FLINK from render node to legacy node is not supported. New clients must not use the insecure FLINK interface.

Besides dropping all modeset/global ioctls, render nodes also drop the DRM-Master concept. There is no reason to associate render clients with a DRM-Master as they are independent of any graphics server. Besides, they must work without any running master, anyway. Drivers must be able to run without a master object if they support render nodes. If, on the other hand, a driver requires shared state between clients which is visible to user-space and accessible beyond open-file boundaries, they cannot support render nodes.

Device Hot-Unplug


The following is the plan. Implementation is not there yet (2020 May).

Graphics devices (display and/or render) may be connected via USB (e.g. display adapters or docking stations) or Thunderbolt (e.g. eGPU). An end user is able to hot-unplug this kind of devices while they are being used, and expects that the very least the machine does not crash. Any damage from hot-unplugging a DRM device needs to be limited as much as possible and userspace must be given the chance to handle it if it wants to. Ideally, unplugging a DRM device still lets a desktop continue to run, but that is going to need explicit support throughout the whole graphics stack: from kernel and userspace drivers, through display servers, via window system protocols, and in applications and libraries.

Other scenarios that should lead to the same are: unrecoverable GPU crash, PCI device disappearing off the bus, or forced unbind of a driver from the physical device.

In other words, from userspace perspective everything needs to keep on working more or less, until userspace stops using the disappeared DRM device and closes it completely. Userspace will learn of the device disappearance from the device removed uevent, ioctls returning ENODEV (or driver-specific ioctls returning driver-specific things), or open() returning ENXIO.

Only after userspace has closed all relevant DRM device and dmabuf file descriptors and removed all mmaps, the DRM driver can tear down its instance for the device that no longer exists. If the same physical device somehow comes back in the mean time, it shall be a new DRM device.

Similar to PIDs, chardev minor numbers are not recycled immediately. A new DRM device always picks the next free minor number compared to the previous one allocated, and wraps around when minor numbers are exhausted.

The goal raises at least the following requirements for the kernel and drivers.

Requirements for KMS UAPI

  • KMS connectors must change their status to disconnected.

  • Legacy modesets and pageflips, and atomic commits, both real and TEST_ONLY, and any other ioctls either fail with ENODEV or fake success.

  • Pending non-blocking KMS operations deliver the DRM events userspace is expecting. This applies also to ioctls that faked success.

  • open() on a device node whose underlying device has disappeared will fail with ENXIO.

  • Attempting to create a DRM lease on a disappeared DRM device will fail with ENODEV. Existing DRM leases remain and work as listed above.

Requirements for Render and Cross-Device UAPI

  • All GPU jobs that can no longer run must have their fences force-signalled to avoid inflicting hangs on userspace. The associated error code is ENODEV.

  • Some userspace APIs already define what should happen when the device disappears (OpenGL, GL ES: GL_KHR_robustness; Vulkan: VK_ERROR_DEVICE_LOST; etc.). DRM drivers are free to implement this behaviour the way they see best, e.g. returning failures in driver-specific ioctls and handling those in userspace drivers, or rely on uevents, and so on.

  • dmabuf which point to memory that has disappeared will either fail to import with ENODEV or continue to be successfully imported if it would have succeeded before the disappearance. See also about memory maps below for already imported dmabufs.

  • Attempting to import a dmabuf to a disappeared device will either fail with ENODEV or succeed if it would have succeeded without the disappearance.

  • open() on a device node whose underlying device has disappeared will fail with ENXIO.

Requirements for Memory Maps

Memory maps have further requirements that apply to both existing maps and maps created after the device has disappeared. If the underlying memory disappears, the map is created or modified such that reads and writes will still complete successfully but the result is undefined. This applies to both userspace mmap()'d memory and memory pointed to by dmabuf which might be mapped to other devices (cross-device dmabuf imports).

Raising SIGBUS is not an option, because userspace cannot realistically handle it. Signal handlers are global, which makes them extremely difficult to use correctly from libraries like those that Mesa produces. Signal handlers are not composable, you can't have different handlers for GPU1 and GPU2 from different vendors, and a third handler for mmapped regular files. Threads cause additional pain with signal handling as well.

IOCTL Support on Device Nodes

First things first, driver private IOCTLs should only be needed for drivers supporting rendering. Kernel modesetting is all standardized, and extended through properties. There are a few exceptions in some existing drivers, which define IOCTL for use by the display DRM master, but they all predate properties.

Now if you do have a render driver you always have to support it through driver private properties. There's a few steps needed to wire all the things up.

First you need to define the structure for your IOCTL in your driver private UAPI header in include/uapi/drm/my_driver_drm.h:

struct my_driver_operation {
        u32 some_thing;
        u32 another_thing;

Please make sure that you follow all the best practices from Documentation/process/botching-up-ioctls.rst. Note that drm_ioctl() automatically zero-extends structures, hence make sure you can add more stuff at the end, i.e. don't put a variable sized array there.

Then you need to define your IOCTL number, using one of DRM_IO(), DRM_IOR(), DRM_IOW() or DRM_IOWR(). It must start with the DRM_IOCTL_ prefix:

##define DRM_IOCTL_MY_DRIVER_OPERATION  *         DRM_IOW(DRM_COMMAND_BASE, struct my_driver_operation)

DRM driver private IOCTL must be in the range from DRM_COMMAND_BASE to DRM_COMMAND_END. Finally you need an array of struct drm_ioctl_desc to wire up the handlers and set the access rights:

static const struct drm_ioctl_desc my_driver_ioctls[] = {
    DRM_IOCTL_DEF_DRV(MY_DRIVER_OPERATION, my_driver_operation,

And then assign this to the drm_driver.ioctls field in your driver structure.

See the separate chapter on file operations for how the driver-specific IOCTLs are wired up.

Testing and validation

Testing Requirements for userspace API

New cross-driver userspace interface extensions, like new IOCTL, new KMS properties, new files in sysfs or anything else that constitutes an API change should have driver-agnostic testcases in IGT for that feature, if such a test can be reasonably made using IGT for the target hardware.

Validating changes with IGT

There's a collection of tests that aims to cover the whole functionality of DRM drivers and that can be used to check that changes to DRM drivers or the core don't regress existing functionality. This test suite is called IGT and its code and instructions to build and run can be found in

Using VKMS to test DRM API

VKMS is a software-only model of a KMS driver that is useful for testing and for running compositors. VKMS aims to enable a virtual display without the need for a hardware display capability. These characteristics made VKMS a perfect tool for validating the DRM core behavior and also support the compositor developer. VKMS makes it possible to test DRM functions in a virtual machine without display, simplifying the validation of some of the core changes.

To Validate changes in DRM API with VKMS, start setting the kernel: make sure to enable VKMS module; compile the kernel with the VKMS enabled and install it in the target machine. VKMS can be run in a Virtual Machine (QEMU, virtme or similar). It's recommended the use of KVM with the minimum of 1GB of RAM and four cores.

It's possible to run the IGT-tests in a VM in two ways:

  1. Use IGT inside a VM

  2. Use IGT from the host machine and write the results in a shared directory.

Following is an example of using a VM with a shared directory with the host machine to run igt-tests. This example uses virtme:

$ virtme-run --rwdir /path/for/shared_dir --kdir=path/for/kernel/directory --mods=auto

Run the igt-tests in the guest machine. This example runs the 'kms_flip' tests:

$ /path/for/igt-gpu-tools/scripts/ -p -s -t "kms_flip.*" -v

In this example, instead of building the igt_runner, Piglit is used (-p option). It creates an HTML summary of the test results and saves them in the folder "igt-gpu-tools/results". It executes only the igt-tests matching the -t option.

Display CRC Support

DRM device drivers can provide to userspace CRC information of each frame as it reached a given hardware component (a CRC sampling "source").

Userspace can control generation of CRCs in a given CRTC by writing to the file dri/0/crtc-N/crc/control in debugfs, with N being the index of the CRTC. Accepted values are source names (which are driver-specific) and the "auto" keyword, which will let the driver select a default source of frame CRCs for this CRTC.

Once frame CRC generation is enabled, userspace can capture them by reading the dri/0/crtc-N/crc/data file. Each line in that file contains the frame number in the first field and then a number of unsigned integer fields containing the CRC data. Fields are separated by a single space and the number of CRC fields is source-specific.

Note that though in some cases the CRC is computed in a specified way and on the frame contents as supplied by userspace (eDP 1.3), in general the CRC computation is performed in an unspecified way and on frame contents that have been already processed in also an unspecified way and thus userspace cannot rely on being able to generate matching CRC values for the frame contents that it submits. In this general case, the maximum userspace can do is to compare the reported CRCs of frames that should have the same contents.

On the driver side the implementation effort is minimal, drivers only need to implement drm_crtc_funcs.set_crc_source and drm_crtc_funcs.verify_crc_source. The debugfs files are automatically set up if those vfuncs are set. CRC samples need to be captured in the driver by calling drm_crtc_add_crc_entry(). Depending on the driver and HW requirements, drm_crtc_funcs.set_crc_source may result in a commit (even a full modeset).

CRC results must be reliable across non-full-modeset atomic commits, so if a commit via DRM_IOCTL_MODE_ATOMIC would disable or otherwise interfere with CRC generation, then the driver must mark that commit as a full modeset (drm_atomic_crtc_needs_modeset() should return true). As a result, to ensure consistent results, generic userspace must re-setup CRC generation after a legacy SETCRTC or an atomic commit with DRM_MODE_ATOMIC_ALLOW_MODESET.

int drm_crtc_add_crc_entry(struct drm_crtc *crtc, bool has_frame, uint32_t frame, uint32_t *crcs)

Add entry with CRC information for a frame


struct drm_crtc *crtc

CRTC to which the frame belongs

bool has_frame

whether this entry has a frame number to go with

uint32_t frame

number of the frame these CRCs are about

uint32_t *crcs

array of CRC values, with length matching #drm_crtc_crc.values_cnt


For each frame, the driver polls the source of CRCs for new data and calls this function to add them to the buffer from where userspace reads.

Debugfs Support

struct drm_info_list

debugfs info list entry


struct drm_info_list {
    const char *name;
    int (*show)(struct seq_file*, void*);
    u32 driver_features;
    void *data;



file name


Show callback. seq_file->private will be set to the struct drm_info_node corresponding to the instance of this info on a given struct drm_minor.


Required driver features for this entry


Driver-private data, should not be device-specific.


This structure represents a debugfs file to be created by the drm core.

struct drm_info_node

Per-minor debugfs node structure


struct drm_info_node {
    struct drm_minor *minor;
    const struct drm_info_list *info_ent;



struct drm_minor for this node.


template for this node.


This structure represents a debugfs file, as an instantiation of a struct drm_info_list on a struct drm_minor.


No it doesn't make a hole lot of sense that we duplicate debugfs entries for both the render and the primary nodes, but that's how this has organically grown. It should probably be fixed, with a compatibility link, if needed.

struct drm_debugfs_info

debugfs info list entry


struct drm_debugfs_info {
    const char *name;
    int (*show)(struct seq_file*, void*);
    u32 driver_features;
    void *data;



File name


Show callback. seq_file->private will be set to the struct drm_debugfs_entry corresponding to the instance of this info on a given struct drm_device.


Required driver features for this entry.


Driver-private data, should not be device-specific.


This structure represents a debugfs file to be created by the drm core.

struct drm_debugfs_entry

Per-device debugfs node structure


struct drm_debugfs_entry {
    struct drm_device *dev;
    struct drm_debugfs_info file;
    struct list_head list;



struct drm_device for this node.


Template for this node.


Linked list of all device nodes.


This structure represents a debugfs file, as an instantiation of a struct drm_debugfs_info on a struct drm_device.

void drm_debugfs_create_files(const struct drm_info_list *files, int count, struct dentry *root, struct drm_minor *minor)

Initialize a given set of debugfs files for DRM minor


const struct drm_info_list *files

The array of files to create

int count

The number of files given

struct dentry *root

DRI debugfs dir entry.

struct drm_minor *minor

device minor number


Create a given set of debugfs files represented by an array of struct drm_info_list in the given root directory. These files will be removed automatically on drm_debugfs_cleanup().

void drm_debugfs_add_file(struct drm_device *dev, const char *name, int (*show)(struct seq_file*, void*), void *data)

Add a given file to the DRM device debugfs file list


struct drm_device *dev

drm device for the ioctl

const char *name

debugfs file name

int (*show)(struct seq_file*, void*)

show callback

void *data

driver-private data, should not be device-specific


Add a given file entry to the DRM device debugfs file list to be created on drm_debugfs_init.

void drm_debugfs_add_files(struct drm_device *dev, const struct drm_debugfs_info *files, int count)

Add an array of files to the DRM device debugfs file list


struct drm_device *dev

drm device for the ioctl

const struct drm_debugfs_info *files

The array of files to create

int count

The number of files given


Add a given set of debugfs files represented by an array of struct drm_debugfs_info in the DRM device debugfs file list.

Sysfs Support

DRM provides very little additional support to drivers for sysfs interactions, beyond just all the standard stuff. Drivers who want to expose additional sysfs properties and property groups can attach them at either or drm_connector.kdev.

Registration is automatically handled when calling drm_dev_register(), or drm_connector_register() in case of hot-plugged connectors. Unregistration is also automatically handled by drm_dev_unregister() and drm_connector_unregister().

void drm_sysfs_hotplug_event(struct drm_device *dev)

generate a DRM uevent


struct drm_device *dev

DRM device


Send a uevent for the DRM device specified by dev. Currently we only set HOTPLUG=1 in the uevent environment, but this could be expanded to deal with other types of events.

Any new uapi should be using the drm_sysfs_connector_status_event() for uevents on connector status change.

void drm_sysfs_connector_hotplug_event(struct drm_connector *connector)

generate a DRM uevent for any connector change


struct drm_connector *connector

connector which has changed


Send a uevent for the DRM connector specified by connector. This will send a uevent with the properties HOTPLUG=1 and CONNECTOR.

void drm_sysfs_connector_status_event(struct drm_connector *connector, struct drm_property *property)

generate a DRM uevent for connector property status change


struct drm_connector *connector

connector on which property status changed

struct drm_property *property

connector property whose status changed.


Send a uevent for the DRM device specified by dev. Currently we set HOTPLUG=1 and connector id along with the attached property id related to the status change.

int drm_class_device_register(struct device *dev)

register new device with the DRM sysfs class


struct device *dev

device to register


Registers a new struct device within the DRM sysfs class. Essentially only used by ttm to have a place for its global settings. Drivers should never use this.

void drm_class_device_unregister(struct device *dev)

unregister device with the DRM sysfs class


struct device *dev

device to unregister


Unregisters a struct device from the DRM sysfs class. Essentially only used by ttm to have a place for its global settings. Drivers should never use this.

VBlank event handling

The DRM core exposes two vertical blank related ioctls:


This takes a struct drm_wait_vblank structure as its argument, and it is used to block or request a signal when a specified vblank event occurs.


This was only used for user-mode-settind drivers around modesetting changes to allow the kernel to update the vblank interrupt after mode setting, since on many devices the vertical blank counter is reset to 0 at some point during modeset. Modern drivers should not call this any more since with kernel mode setting it is a no-op.

Userspace API Structures

DRM exposes many UAPI and structure definition to have a consistent and standardized interface with user. Userspace can refer to these structure definitions and UAPI formats to communicate to driver

CRTC index

CRTC's have both an object ID and an index, and they are not the same thing. The index is used in cases where a densely packed identifier for a CRTC is needed, for instance a bitmask of CRTC's. The member possible_crtcs of struct drm_mode_get_plane is an example.

DRM_IOCTL_MODE_GETRESOURCES populates a structure with an array of CRTC ID's, and the CRTC index is its position in this array.





If set to 1, the driver supports creating dumb buffers via the DRM_IOCTL_MODE_CREATE_DUMB ioctl.





If set to 1, the kernel supports specifying a CRTC index in the high bits of drm_wait_vblank_request.type.

Starting kernel version 2.6.39, this capability is always set to 1.





The preferred bit depth for dumb buffers.

The bit depth is the number of bits used to indicate the color of a single pixel excluding any padding. This is different from the number of bits per pixel. For instance, XRGB8888 has a bit depth of 24 but has 32 bits per pixel.

Note that this preference only applies to dumb buffers, it's irrelevant for other types of buffers.





If set to 1, the driver prefers userspace to render to a shadow buffer instead of directly rendering to a dumb buffer. For best speed, userspace should do streaming ordered memory copies into the dumb buffer and never read from it.

Note that this preference only applies to dumb buffers, it's irrelevant for other types of buffers.





Bitfield of supported PRIME sharing capabilities. See DRM_PRIME_CAP_IMPORT and DRM_PRIME_CAP_EXPORT.

PRIME buffers are exposed as dma-buf file descriptors. See DRM Memory Management, section "PRIME Buffer Sharing".





If this bit is set in DRM_CAP_PRIME, the driver supports importing PRIME buffers via the DRM_IOCTL_PRIME_FD_TO_HANDLE ioctl.





If this bit is set in DRM_CAP_PRIME, the driver supports exporting PRIME buffers via the DRM_IOCTL_PRIME_HANDLE_TO_FD ioctl.





If set to 0, the kernel will report timestamps with CLOCK_REALTIME in struct drm_event_vblank. If set to 1, the kernel will report timestamps with CLOCK_MONOTONIC. See clock_gettime(2) for the definition of these clocks.

Starting from kernel version 2.6.39, the default value for this capability is 1. Starting kernel version 4.15, this capability is always set to 1.





If set to 1, the driver supports DRM_MODE_PAGE_FLIP_ASYNC.





The CURSOR_WIDTH and CURSOR_HEIGHT capabilities return a valid width x height combination for the hardware cursor. The intention is that a hardware agnostic userspace can query a cursor plane size to use.

Note that the cross-driver contract is to merely return a valid size; drivers are free to attach another meaning on top, eg. i915 returns the maximum plane size.










If set to 1, the driver supports supplying modifiers in the DRM_IOCTL_MODE_ADDFB2 ioctl.





If set to 1, the driver supports the DRM_MODE_PAGE_FLIP_TARGET_ABSOLUTE and DRM_MODE_PAGE_FLIP_TARGET_RELATIVE flags in drm_mode_crtc_page_flip_target.flags for the DRM_IOCTL_MODE_PAGE_FLIP ioctl.





If set to 1, the kernel supports reporting the CRTC ID in drm_event_vblank.crtc_id for the DRM_EVENT_VBLANK and DRM_EVENT_FLIP_COMPLETE events.

Starting kernel version 4.12, this capability is always set to 1.





If set to 1, the driver supports sync objects. See DRM Memory Management, section "DRM Sync Objects".





If set to 1, the driver supports timeline operations on sync objects. See DRM Memory Management, section "DRM Sync Objects".





If set to 1, the DRM core will expose the stereo 3D capabilities of the monitor by advertising the supported 3D layouts in the flags of struct drm_mode_modeinfo. See DRM_MODE_FLAG_3D_*.

This capability is always supported for all drivers starting from kernel version 3.13.





If set to 1, the DRM core will expose all planes (overlay, primary, and cursor) to userspace.

This capability has been introduced in kernel version 3.15. Starting from kernel version 3.17, this capability is always supported for all drivers.





If set to 1, the DRM core will expose atomic properties to userspace. This implicitly enables DRM_CLIENT_CAP_UNIVERSAL_PLANES and DRM_CLIENT_CAP_ASPECT_RATIO.

If the driver doesn't support atomic mode-setting, enabling this capability will fail with -EOPNOTSUPP.

This capability has been introduced in kernel version 4.0. Starting from kernel version 4.2, this capability is always supported for atomic-capable drivers.





If set to 1, the DRM core will provide aspect ratio information in modes. See DRM_MODE_FLAG_PIC_AR_*.

This capability is always supported for all drivers starting from kernel version 4.18.





If set to 1, the DRM core will expose special connectors to be used for writing back to memory the scene setup in the commit. The client must enable DRM_CLIENT_CAP_ATOMIC first.

This capability is always supported for atomic-capable drivers starting from kernel version 4.19.



Close a GEM handle.



GEM handles are not reference-counted by the kernel. User-space is responsible for managing their lifetime. For example, if user-space imports the same memory object twice on the same DRM file description, the same GEM handle is returned by both imports, and user-space needs to ensure DRM_IOCTL_GEM_CLOSE is performed once only. The same situation can happen when a memory object is allocated, then exported and imported again on the same DRM file description. The DRM_IOCTL_MODE_GETFB2 IOCTL is an exception and always returns fresh new GEM handles even if an existing GEM handle already refers to the same memory object before the IOCTL is performed.



Convert a GEM handle to a DMA-BUF FD.



User-space sets drm_prime_handle.handle with the GEM handle to export and drm_prime_handle.flags, and gets back a DMA-BUF file descriptor in drm_prime_handle.fd.

The export can fail for any driver-specific reason, e.g. because export is not supported for this specific GEM handle (but might be for others).

Support for exporting DMA-BUFs is advertised via DRM_PRIME_CAP_EXPORT.



Convert a DMA-BUF FD to a GEM handle.



User-space sets drm_prime_handle.fd with a DMA-BUF file descriptor to import, and gets back a GEM handle in drm_prime_handle.handle. drm_prime_handle.flags is unused.

If an existing GEM handle refers to the memory object backing the DMA-BUF, that GEM handle is returned. Therefore user-space which needs to handle arbitrary DMA-BUFs must have a user-space lookup data structure to manually reference-count duplicated GEM handles. For more information see DRM_IOCTL_GEM_CLOSE.

The import can fail for any driver-specific reason, e.g. because import is only supported for DMA-BUFs allocated on this DRM device.

Support for importing DMA-BUFs is advertised via DRM_PRIME_CAP_IMPORT.



Remove a framebuffer.



This removes a framebuffer previously added via ADDFB/ADDFB2. The IOCTL argument is a framebuffer object ID.

Warning: removing a framebuffer currently in-use on an enabled plane will disable that plane. The CRTC the plane is linked to may also be disabled (depending on driver capabilities).



Get framebuffer metadata.



This queries metadata about a framebuffer. User-space fills drm_mode_fb_cmd2.fb_id as the input, and the kernels fills the rest of the struct as the output.

If the client is DRM master or has CAP_SYS_ADMIN, drm_mode_fb_cmd2.handles will be filled with GEM buffer handles. Fresh new GEM handles are always returned, even if another GEM handle referring to the same memory object already exists on the DRM file description. The caller is responsible for removing the new handles, e.g. via the DRM_IOCTL_GEM_CLOSE IOCTL. The same new handle will be returned for multiple planes in case they use the same memory object. Planes are valid until one has a zero handle -- this can be used to compute the number of planes.

Otherwise, drm_mode_fb_cmd2.handles will be zeroed and planes are valid until one has a zero drm_mode_fb_cmd2.pitches.

If the framebuffer has a format modifier, DRM_MODE_FB_MODIFIERS will be set in drm_mode_fb_cmd2.flags and drm_mode_fb_cmd2.modifier will contain the modifier. Otherwise, user-space must ignore drm_mode_fb_cmd2.modifier.

To obtain DMA-BUF FDs for each plane without leaking GEM handles, user-space can export each handle via DRM_IOCTL_PRIME_HANDLE_TO_FD, then immediately close each unique handle via DRM_IOCTL_GEM_CLOSE, making sure to not double-close handles which are specified multiple times in the array.

struct drm_mode_modeinfo

Display mode information.


struct drm_mode_modeinfo {
    __u32 clock;
    __u16 hdisplay;
    __u16 hsync_start;
    __u16 hsync_end;
    __u16 htotal;
    __u16 hskew;
    __u16 vdisplay;
    __u16 vsync_start;
    __u16 vsync_end;
    __u16 vtotal;
    __u16 vscan;
    __u32 vrefresh;
    __u32 flags;
    __u32 type;
    char name[DRM_DISPLAY_MODE_LEN];



pixel clock in kHz


horizontal display size


horizontal sync start


horizontal sync end


horizontal total size


horizontal skew


vertical display size


vertical sync start


vertical sync end


vertical total size


vertical scan


approximate vertical refresh rate in Hz


bitmask of misc. flags, see DRM_MODE_FLAG_* defines


bitmask of type flags, see DRM_MODE_TYPE_* defines


string describing the mode resolution


This is the user-space API display mode information structure. For the kernel version see struct drm_display_mode.

struct drm_mode_get_plane

Get plane metadata.


struct drm_mode_get_plane {
    __u32 plane_id;
    __u32 crtc_id;
    __u32 fb_id;
    __u32 possible_crtcs;
    __u32 gamma_size;
    __u32 count_format_types;
    __u64 format_type_ptr;



Object ID of the plane whose information should be retrieved. Set by caller.


Object ID of the current CRTC.


Object ID of the current fb.


Bitmask of CRTC's compatible with the plane. CRTC's are created and they receive an index, which corresponds to their position in the bitmask. Bit N corresponds to CRTC index N.


Never used.


Number of formats.


Pointer to __u32 array of formats that are supported by the plane. These formats do not require modifiers.


Userspace can perform a GETPLANE ioctl to retrieve information about a plane.

To retrieve the number of formats supported, set count_format_types to zero and call the ioctl. count_format_types will be updated with the value.

To retrieve these formats, allocate an array with the memory needed to store count_format_types formats. Point format_type_ptr to this array and call the ioctl again (with count_format_types still set to the value returned in the first ioctl call).

struct drm_mode_get_connector

Get connector metadata.


struct drm_mode_get_connector {
    __u64 encoders_ptr;
    __u64 modes_ptr;
    __u64 props_ptr;
    __u64 prop_values_ptr;
    __u32 count_modes;
    __u32 count_props;
    __u32 count_encoders;
    __u32 encoder_id;
    __u32 connector_id;
    __u32 connector_type;
    __u32 connector_type_id;
    __u32 connection;
    __u32 mm_width;
    __u32 mm_height;
    __u32 subpixel;
    __u32 pad;



Pointer to __u32 array of object IDs.


Pointer to struct drm_mode_modeinfo array.


Pointer to __u32 array of property IDs.


Pointer to __u64 array of property values.


Number of modes.


Number of properties.


Number of encoders.


Object ID of the current encoder.


Object ID of the connector.


Type of the connector.



Type-specific connector number.

This is not an object ID. This is a per-type connector number. Each (type, type_id) combination is unique across all connectors of a DRM device.


Status of the connector.

See enum drm_connector_status.


Width of the connected sink in millimeters.


Height of the connected sink in millimeters.


Subpixel order of the connected sink.

See enum subpixel_order.


Padding, must be zero.


User-space can perform a GETCONNECTOR ioctl to retrieve information about a connector. User-space is expected to retrieve encoders, modes and properties by performing this ioctl at least twice: the first time to retrieve the number of elements, the second time to retrieve the elements themselves.

To retrieve the number of elements, set count_props and count_encoders to zero, set count_modes to 1, and set modes_ptr to a temporary struct drm_mode_modeinfo element.

To retrieve the elements, allocate arrays for encoders_ptr, modes_ptr, props_ptr and prop_values_ptr, then set count_modes, count_props and count_encoders to their capacity.

Performing the ioctl only twice may be racy: the number of elements may have changed with a hotplug event in-between the two ioctls. User-space is expected to retry the last ioctl until the number of elements stabilizes. The kernel won't fill any array which doesn't have the expected length.

Force-probing a connector

If the count_modes field is set to zero and the DRM client is the current DRM master, the kernel will perform a forced probe on the connector to refresh the connector status, modes and EDID. A forced-probe can be slow, might cause flickering and the ioctl will block.

User-space needs to force-probe connectors to ensure their metadata is up-to-date at startup and after receiving a hot-plug event. User-space may perform a forced-probe when the user explicitly requests it. User-space shouldn't perform a forced-probe in other situations.

struct drm_mode_property_enum

Description for an enum/bitfield entry.


struct drm_mode_property_enum {
    __u64 value;
    char name[DRM_PROP_NAME_LEN];



numeric value for this enum entry.


symbolic name for this enum entry.


See struct drm_property_enum for details.

struct drm_mode_get_property

Get property metadata.


struct drm_mode_get_property {
    __u64 values_ptr;
    __u64 enum_blob_ptr;
    __u32 prop_id;
    __u32 flags;
    char name[DRM_PROP_NAME_LEN];
    __u32 count_values;
    __u32 count_enum_blobs;



Pointer to a __u64 array.


Pointer to a struct drm_mode_property_enum array.


Object ID of the property which should be retrieved. Set by the caller.


DRM_MODE_PROP_* bitfield. See drm_property.flags for a definition of the flags.


Symbolic property name. User-space should use this field to recognize properties.


Number of elements in values_ptr.


Number of elements in enum_blob_ptr.


User-space can perform a GETPROPERTY ioctl to retrieve information about a property. The same property may be attached to multiple objects, see "Modeset Base Object Abstraction".

The meaning of the values_ptr field changes depending on the property type. See drm_property.flags for more details.

The enum_blob_ptr and count_enum_blobs fields are only meaningful when the property has the type DRM_MODE_PROP_ENUM or DRM_MODE_PROP_BITMASK. For backwards compatibility, the kernel will always set count_enum_blobs to zero when the property has the type DRM_MODE_PROP_BLOB. User-space must ignore these two fields if the property has a different type.

User-space is expected to retrieve values and enums by performing this ioctl at least twice: the first time to retrieve the number of elements, the second time to retrieve the elements themselves.

To retrieve the number of elements, set count_values and count_enum_blobs to zero, then call the ioctl. count_values will be updated with the number of elements. If the property has the type DRM_MODE_PROP_ENUM or DRM_MODE_PROP_BITMASK, count_enum_blobs will be updated as well.

To retrieve the elements themselves, allocate an array for values_ptr and set count_values to its capacity. If the property has the type DRM_MODE_PROP_ENUM or DRM_MODE_PROP_BITMASK, allocate an array for enum_blob_ptr and set count_enum_blobs to its capacity. Calling the ioctl again will fill the arrays.

struct drm_mode_fb_cmd2

Frame-buffer metadata.


struct drm_mode_fb_cmd2 {
    __u32 fb_id;
    __u32 width;
    __u32 height;
    __u32 pixel_format;
    __u32 flags;
    __u32 handles[4];
    __u32 pitches[4];
    __u32 offsets[4];
    __u64 modifier[4];



Object ID of the frame-buffer.


Width of the frame-buffer.


Height of the frame-buffer.


FourCC format code, see DRM_FORMAT_* constants in drm_fourcc.h.




GEM buffer handle, one per plane. Set to 0 if the plane is unused. The same handle can be used for multiple planes.


Pitch (aka. stride) in bytes, one per plane.


Offset into the buffer in bytes, one per plane.


Format modifier, one per plane. See DRM_FORMAT_MOD_* constants in drm_fourcc.h. All planes must use the same modifier. Ignored unless DRM_MODE_FB_MODIFIERS is set in flags.


This struct holds frame-buffer metadata. There are two ways to use it:

  • User-space can fill this struct and perform a DRM_IOCTL_MODE_ADDFB2 ioctl to register a new frame-buffer. The new frame-buffer object ID will be set by the kernel in fb_id.

  • User-space can set fb_id and perform a DRM_IOCTL_MODE_GETFB2 ioctl to fetch metadata about an existing frame-buffer.

In case of planar formats, this struct allows up to 4 buffer objects with offsets and pitches per plane. The pitch and offset order are dictated by the format FourCC as defined by drm_fourcc.h, e.g. NV12 is described as:

YUV 4:2:0 image with a plane of 8-bit Y samples followed by an interleaved U/V plane containing 8-bit 2x2 subsampled colour difference samples.

So it would consist of a Y plane at offsets[0] and a UV plane at offsets[1].

To accommodate tiled, compressed, etc formats, a modifier can be specified. For more information see the "Format Modifiers" section. Note that even though it looks like we have a modifier per-plane, we in fact do not. The modifier for each plane must be identical. Thus all combinations of different data layouts for multi-plane formats must be enumerated as separate modifiers.

All of the entries in handles, pitches, offsets and modifier must be zero when unused. Warning, for offsets and modifier zero can't be used to figure out whether the entry is used or not since it's a valid value (a zero offset is common, and a zero modifier is DRM_FORMAT_MOD_LINEAR).

struct hdr_metadata_infoframe

HDR Metadata Infoframe Data.


struct hdr_metadata_infoframe {
    __u8 eotf;
    __u8 metadata_type;
    struct {
        __u16 x, y;
    } display_primaries[3];
    struct {
        __u16 x, y;
    } white_point;
    __u16 max_display_mastering_luminance;
    __u16 min_display_mastering_luminance;
    __u16 max_cll;
    __u16 max_fall;



Electro-Optical Transfer Function (EOTF) used in the stream.




Color Primaries of the Data. These are coded as unsigned 16-bit values in units of 0.00002, where 0x0000 represents zero and 0xC350 represents 1.0000. display_primaries.x: X cordinate of color primary. display_primaries.y: Y cordinate of color primary.


White Point of Colorspace Data. These are coded as unsigned 16-bit values in units of 0.00002, where 0x0000 represents zero and 0xC350 represents 1.0000. white_point.x: X cordinate of whitepoint of color primary. white_point.y: Y cordinate of whitepoint of color primary.


Max Mastering Display Luminance. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.


Min Mastering Display Luminance. This value is coded as an unsigned 16-bit value in units of 0.0001 cd/m2, where 0x0001 represents 0.0001 cd/m2 and 0xFFFF represents 6.5535 cd/m2.


Max Content Light Level. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.


Max Frame Average Light Level. This value is coded as an unsigned 16-bit value in units of 1 cd/m2, where 0x0001 represents 1 cd/m2 and 0xFFFF represents 65535 cd/m2.


HDR Metadata Infoframe as per CTA 861.G spec. This is expected to match exactly with the spec.

Userspace is expected to pass the metadata information as per the format described in this structure.

struct hdr_output_metadata

HDR output metadata


struct hdr_output_metadata {
    __u32 metadata_type;
    union {
        struct hdr_metadata_infoframe hdmi_metadata_type1;







HDR Metadata Infoframe.


Metadata Information to be passed from userspace





Request that the kernel sends back a vblank event (see struct drm_event_vblank) with the DRM_EVENT_FLIP_COMPLETE type when the page-flip is done.





Request that the page-flip is performed as soon as possible, ie. with no delay due to waiting for vblank. This may cause tearing to be visible on the screen.





Bitmask of flags suitable for drm_mode_crtc_page_flip_target.flags.





Do not apply the atomic commit, instead check whether the hardware supports this configuration.

See drm_mode_config_funcs.atomic_check for more details on test-only commits.





Do not block while applying the atomic commit. The DRM_IOCTL_MODE_ATOMIC IOCTL returns immediately instead of waiting for the changes to be applied in hardware. Note, the driver will still check that the update can be applied before retuning.





Allow the update to result in temporary or transient visible artifacts while the update is being applied. Applying the update may also take significantly more time than a page flip. All visual artifacts will disappear by the time the update is completed, as signalled through the vblank event's timestamp (see struct drm_event_vblank).

This flag must be set when the KMS update might cause visible artifacts. Without this flag such KMS update will return a EINVAL error. What kind of update may cause visible artifacts depends on the driver and the hardware. User-space that needs to know beforehand if an update might cause visible artifacts can use DRM_MODE_ATOMIC_TEST_ONLY without DRM_MODE_ATOMIC_ALLOW_MODESET to see if it fails.

To the best of the driver's knowledge, visual artifacts are guaranteed to not appear when this flag is not set. Some sinks might display visual artifacts outside of the driver's control.





Bitfield of flags accepted by the DRM_IOCTL_MODE_ATOMIC IOCTL in drm_mode_atomic.flags.

struct drm_mode_create_blob

Create New blob property


struct drm_mode_create_blob {
    __u64 data;
    __u32 length;
    __u32 blob_id;



Pointer to data to copy.


Length of data to copy.


Return: new property ID.


Create a new 'blob' data property, copying length bytes from data pointer, and returning new blob ID.

struct drm_mode_destroy_blob

Destroy user blob


struct drm_mode_destroy_blob {
    __u32 blob_id;



blob_id to destroy


Destroy a user-created blob property.

User-space can release blobs as soon as they do not need to refer to them by their blob object ID. For instance, if you are using a MODE_ID blob in an atomic commit and you will not make another commit re-using the same ID, you can destroy the blob as soon as the commit has been issued, without waiting for it to complete.

struct drm_mode_create_lease

Create lease


struct drm_mode_create_lease {
    __u64 object_ids;
    __u32 object_count;
    __u32 flags;
    __u32 lessee_id;
    __u32 fd;



Pointer to array of object ids (__u32)


Number of object ids


flags for new FD (O_CLOEXEC, etc)


Return: unique identifier for lessee.


Return: file descriptor to new drm_master file


Lease mode resources, creating another drm_master.

The object_ids array must reference at least one CRTC, one connector and one plane if DRM_CLIENT_CAP_UNIVERSAL_PLANES is enabled. Alternatively, the lease can be completely empty.

struct drm_mode_list_lessees

List lessees


struct drm_mode_list_lessees {
    __u32 count_lessees;
    __u32 pad;
    __u64 lessees_ptr;



Number of lessees.

On input, provides length of the array. On output, provides total number. No more than the input number will be written back, so two calls can be used to get the size and then the data.




Pointer to lessees.

Pointer to __u64 array of lessee ids


List lesses from a drm_master.

struct drm_mode_get_lease

Get Lease


struct drm_mode_get_lease {
    __u32 count_objects;
    __u32 pad;
    __u64 objects_ptr;



Number of leased objects.

On input, provides length of the array. On output, provides total number. No more than the input number will be written back, so two calls can be used to get the size and then the data.




Pointer to objects.

Pointer to __u32 array of object ids.


Get leased objects.

struct drm_mode_revoke_lease

Revoke lease


struct drm_mode_revoke_lease {
    __u32 lessee_id;



Unique ID of lessee

struct drm_mode_rect

Two dimensional rectangle.


struct drm_mode_rect {
    __s32 x1;
    __s32 y1;
    __s32 x2;
    __s32 y2;



Horizontal starting coordinate (inclusive).


Vertical starting coordinate (inclusive).


Horizontal ending coordinate (exclusive).


Vertical ending coordinate (exclusive).


With drm subsystem using struct drm_rect to manage rectangular area this export it to user-space.

Currently used by drm_mode_atomic blob property FB_DAMAGE_CLIPS.