## ioctl wrappers ioctl wrappers — ioctl wrappers and related functions |

## Functions

int | (*igt_ioctl) ()
drm_intel_bo * | gem_handle_to_libdrm_bo ()
bool | gem_get_tiling ()
void | gem_set_tiling ()
void | gem_set_caching ()
uint32_t | gem_get_caching ()
uint32_t | gem_flink ()
uint32_t | gem_open ()
void | gem_close ()
void | gem_write ()
void | gem_read ()
void | gem_set_domain ()
int | gem_wait ()
void | gem_sync ()
bool | gem_create__has_stolen_support ()
uint32_t | gem_create_stolen ()
uint32_t | gem_create ()
void | gem_execbuf_wr ()
void | gem_execbuf ()
void * | gem_mmap__gtt ()
void * | gem_mmap__cpu ()
bool | gem_mmap__has_wc ()
void * | gem_mmap__wc ()
int | gem_munmap ()
#define | gem_require_stolen_support()
#define | gem_require_mmap_wc()
int | gem_madvise ()
void | gem_userptr ()
void | gem_sw_finish ()
bool | gem_bo_busy ()
void | igt_require_gem ()
bool | gem_has_llc ()
bool | gem_has_bsd ()
bool | gem_has_blt ()
bool | gem_has_vebox ()
bool | gem_has_bsd2 ()
int | gem_gtt_type ()
bool | gem_uses_ppgtt ()
bool | gem_uses_full_ppgtt ()
int | gem_gpu_reset_type ()
bool | gem_gpu_reset_enabled ()
bool | gem_engine_reset_enabled ()
int | gem_available_fences ()
uint64_t | gem_total_mappable_size ()
uint64_t | gem_total_stolen_size ()
uint64_t | gem_available_aperture_size ()
uint64_t | gem_aperture_size ()
uint64_t | gem_global_aperture_size ()
uint64_t | gem_mappable_aperture_size ()
bool | gem_has_softpin ()
bool | gem_has_exec_fence ()
void | gem_require_caching ()
bool | gem_has_ring ()
void | gem_require_ring ()
bool | gem_has_mocs_registers ()
void | gem_require_mocs_registers ()
int | prime_handle_to_fd ()
int | prime_handle_to_fd_for_mmap ()
uint32_t | prime_fd_to_handle ()
off_t | prime_get_size ()
void | prime_sync_start ()
void | prime_sync_end ()
#define | local_fourcc_mod_code()
void | igt_require_fb_modifiers ()

## Types and Values

#define | I915_GEM_DOMAIN_WC
#define | LOCAL_I915_GEM_USERPTR
#define | LOCAL_IOCTL_I915_GEM_USERPTR
struct | local_i915_gem_userptr
struct | local_dma_buf_sync
#define | LOCAL_DMA_BUF_SYNC_READ
#define | LOCAL_DMA_BUF_SYNC_WRITE
#define | LOCAL_DMA_BUF_SYNC_RW
#define | LOCAL_DMA_BUF_SYNC_START
#define | LOCAL_DMA_BUF_SYNC_END
#define | LOCAL_DMA_BUF_SYNC_VALID_FLAGS_MASK
#define | LOCAL_DMA_BUF_BASE
#define | LOCAL_DMA_BUF_IOCTL_SYNC
#define | DRM_RDWR
struct | local_drm_mode_fb_cmd2
#define | LOCAL_DRM_MODE_FB_MODIFIERS
#define | LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL
#define | LOCAL_DRM_FORMAT_MOD_NONE
#define | LOCAL_I915_FORMAT_MOD_X_TILED
#define | LOCAL_I915_FORMAT_MOD_Y_TILED
#define | LOCAL_I915_FORMAT_MOD_Yf_TILED
#define | LOCAL_I915_FORMAT_MOD_Y_TILED_CCS
#define | LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS
#define | LOCAL_DRM_IOCTL_MODE_ADDFB2
#define | LOCAL_DRM_CAP_ADDFB2_MODIFIERS

## Includes

    #include <igt.h>

## Description

This helper library contains simple functions to wrap the raw drm/i915 kernel ioctls. The normal versions never pass any error codes to the caller and use `igt_assert()` to check for error conditions instead. For some ioctls raw wrappers which do pass on error codes are available. These raw wrappers have a __ prefix.

For wrappers which check for feature bits there can also be two versions: The normal one simply returns a boolean to the caller. But when skipping the testcase entirely is the right action then it's better to use `igt_skip()` directly in the wrapper. Such functions have _require_ in their name to distinguish them.

## Functions

### igt_ioctl ()

    int
    (*igt_ioctl) (int fd,
                  unsigned long  request,
                  void *arg);

This is a wrapper around `drmIoctl()`, which can be augmented with special code blocks like igt_while_interruptible.

#### Parameters

fd | file descriptor |
request | IOCTL request number |
arg | argument pointer |

### gem_handle_to_libdrm_bo ()

    drm_intel_bo *
    gem_handle_to_libdrm_bo (drm_intel_bufmgr *bufmgr,
                             int fd,
                             const char *name,
                             uint32_t handle);

This helper function imports a raw gem buffer handle into the libdrm buffer manager.

#### Parameters

bufmgr | libdrm buffer manager instance |
fd | open i915 drm file descriptor |
name | buffer name in libdrm |
handle | gem buffer object handle |

#### Returns

The imported libdrm buffer manager object.

### gem_get_tiling ()

    bool
    gem_get_tiling (int fd,
                    uint32_t handle,
                    uint32_t *tiling,
                    uint32_t *swizzle);

This wraps the GET_TILING ioctl.

Returns whether the actual physical tiling matches the reported tiling.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
tiling | (out) tiling mode of the gem buffer |
swizzle | (out) bit 6 swizzle mode |

### gem_set_tiling ()

    void
    gem_set_tiling (int fd,
                    uint32_t handle,
                    uint32_t tiling,
                    uint32_t stride);

This wraps the SET_TILING ioctl.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
tiling | tiling mode bits |
stride | stride of the buffer when using a tiled mode, otherwise must be 0 |

### gem_set_caching ()

    void
    gem_set_caching (int fd,
                     uint32_t handle,
                     uint32_t caching);

This wraps the SET_CACHING ioctl. Note that this function internally calls `igt_require()` when SET_CACHING isn't available, hence automatically skips the test. Therefore always extract test logic which uses this into its own subtest.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
caching | caching mode bits |

### gem_get_caching ()

    uint32_t
    gem_get_caching (int fd,
                     uint32_t handle);

This wraps the GET_CACHING ioctl.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |

#### Returns

The current caching mode bits.

### gem_flink ()

    uint32_t
    gem_flink (int fd,
               uint32_t handle);

This wraps the GEM_FLINK ioctl, which is used to export a gem buffer object into the device-global flink namespace. See `gem_open()` for opening such a buffer name on a different i915 drm file descriptor.

#### Parameters

fd | open i915 drm file descriptor |
handle | file-private gem buffer object handle |

#### Returns

The created flink buffer name.

### gem_open ()

    uint32_t
    gem_open (int fd,
              uint32_t name);

This wraps the GEM_OPEN ioctl, which is used to import an flink name.

#### Parameters

fd | open i915 drm file descriptor |
name | flink buffer name |

#### Returns

gem file-private buffer handle of the open object.

### gem_close ()

    void
    gem_close (int fd,
               uint32_t handle);

This wraps the GEM_CLOSE ioctl, which to release a file-private gem buffer handle.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |

### gem_write ()

    void
    gem_write (int fd,
               uint32_t handle,
               uint64_t offset,
               const void *buf,
               uint64_t length);

This wraps the PWRITE ioctl, which is to upload a linear data to a subrange of a gem buffer object.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
offset | offset within the buffer of the subrange |
buf | pointer to the data to write into the buffer |
length | size of the subrange |

### gem_read ()

    void
    gem_read (int fd,
              uint32_t handle,
              uint64_t offset,
              void *buf,
              uint64_t length);

This wraps the PREAD ioctl, which is to download a linear data to a subrange of a gem buffer object.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
offset | offset within the buffer of the subrange |
buf | pointer to the data to read into |
length | size of the subrange |

### gem_set_domain ()

    void
    gem_set_domain (int fd,
                    uint32_t handle,
                    uint32_t read,
                    uint32_t write);

This wraps the SET_DOMAIN ioctl, which is used to control the coherency of the gem buffer object between the cpu and gtt mappings. It is also use to synchronize with outstanding rendering in general, but for that use-case please have a look at `gem_sync()`.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
read | gem domain bits for read access |
write | gem domain bit for write access |

### gem_wait ()

    int
    gem_wait (int fd,
              uint32_t handle,
              int64_t *timeout_ns);

### gem_sync ()

    void
    gem_sync (int fd,
              uint32_t handle);

This functions waits for outstanding rendering to complete.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |

### gem_create__has_stolen_support ()

    bool
    gem_create__has_stolen_support (int fd);

### gem_create_stolen ()

    uint32_t
    gem_create_stolen (int fd,
                       uint64_t size);

This wraps the new GEM_CREATE ioctl, which allocates a new gem buffer object of `size` and placement in stolen memory region.

#### Parameters

fd | open i915 drm file descriptor |
size | desired size of the buffer |

#### Returns

The file-private handle of the created buffer object

### gem_create ()

    uint32_t
    gem_create (int fd,
                uint64_t size);

This wraps the GEM_CREATE ioctl, which allocates a new gem buffer object of `size` .

#### Parameters

fd | open i915 drm file descriptor |
size | desired size of the buffer |

#### Returns

The file-private handle of the created buffer object

### gem_execbuf_wr ()

    void
    gem_execbuf_wr (int fd,
                    struct drm_i915_gem_execbuffer2 *execbuf);

This wraps the EXECBUFFER2_WR ioctl, which submits a batchbuffer for the gpu to run.

#### Parameters

fd | open i915 drm file descriptor |
execbuf | execbuffer data structure |

### gem_execbuf ()

    void
    gem_execbuf (int fd,
                 struct drm_i915_gem_execbuffer2 *execbuf);

This wraps the EXECBUFFER2 ioctl, which submits a batchbuffer for the gpu to run.

#### Parameters

fd | open i915 drm file descriptor |
execbuf | execbuffer data structure |

### gem_mmap__gtt ()

    void *
    gem_mmap__gtt (int fd,
                   uint32_t handle,
                   uint64_t size,
                   unsigned  prot);

Like `__gem_mmap__gtt()` except we assert on failure.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
size | size of the gem buffer |
prot | memory protection bits as used by `mmap()` |

#### Returns

A pointer to the created memory mapping

### gem_mmap__cpu ()

    void *
    gem_mmap__cpu (int fd,
                   uint32_t handle,
                   uint64_t offset,
                   uint64_t size,
                   unsigned  prot);

Like `__gem_mmap__cpu()` except we assert on failure.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
offset | offset in the gem buffer of the mmap arena |
size | size of the mmap arena |
prot | memory protection bits as used by `mmap()` |

#### Returns

A pointer to the created memory mapping

### gem_mmap__has_wc ()

    bool
    gem_mmap__has_wc (int fd);

### gem_mmap__wc ()

    void *
    gem_mmap__wc (int fd,
                  uint32_t handle,
                  uint64_t offset,
                  uint64_t size,
                  unsigned  prot);

Like `__gem_mmap__wc()` except we assert on failure.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
offset | offset in the gem buffer of the mmap arena |
size | size of the mmap arena |
prot | memory protection bits as used by `mmap()` |

#### Returns

A pointer to the created memory mapping

### gem_munmap ()

    int
    gem_munmap (void *ptr,
                uint64_t size);

### gem_require_stolen_support()

    #define             gem_require_stolen_support(fd)

Test macro to query whether support for allocating objects from stolen memory is available. Automatically skips through `igt_require()` if not.

#### Parameters

fd | open i915 drm file descriptor |

### gem_require_mmap_wc()

    #define gem_require_mmap_wc(fd) igt_require(gem_mmap__has_wc(fd))

Feature test macro to query whether direct (i.e. cpu access path, bypassing the gtt) write-combine memory mappings are available. Automatically skips through `igt_require()` if not.

#### Parameters

fd | open i915 drm file descriptor |

### gem_madvise ()

    int
    gem_madvise (int fd,
                 uint32_t handle,
                 int state);

This wraps the MADVISE ioctl, which is used in libdrm to implement opportunistic buffer object caching. Objects in the cache are set to DONTNEED (internally in the kernel tracked as purgeable objects). When such a cached object is in need again it must be set back to WILLNEED before first use.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |
state | desired madvise state |

#### Returns

When setting the madvise state to WILLNEED this returns whether the backing storage was still available or not.

### gem_userptr ()

    void
    gem_userptr (int fd,
                 void *ptr,
                 int size,
                 int read_only,
                 uint32_t flags,
                 uint32_t *handle);

Returns userptr handle for the GEM object.

#### Parameters

fd | open i915 drm file descriptor |
ptr | userptr pointer to be passed |
size | desired size of the buffer |
read_only | specify whether userptr is opened read only |
flags | other userptr flags |
handle | returned handle for the object |

### gem_sw_finish ()

    void
    gem_sw_finish (int fd,
                   uint32_t handle);

This wraps the SW_FINISH ioctl, which is used to flush out frontbuffer rendering done through the direct cpu memory mappings. Shipping userspace does _not_ call this after frontbuffer rendering through gtt memory mappings.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |

### gem_bo_busy ()

    bool
    gem_bo_busy (int fd,
                 uint32_t handle);

This wraps the BUSY ioctl, which tells whether a buffer object is still actively used by the gpu in a execbuffer.

#### Parameters

fd | open i915 drm file descriptor |
handle | gem buffer object handle |

#### Returns

The busy state of the buffer object.

### igt_require_gem ()

    void
    igt_require_gem (int fd);

### gem_has_llc ()

    bool
    gem_has_llc (int fd);

### gem_has_bsd ()

    bool
    gem_has_bsd (int fd);

Feature test macro to query whether the BSD ring is available.

Note that recent Bspec calls this the VCS ring for Video Command Submission.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the BSD ring is available or not.

### gem_has_blt ()

    bool
    gem_has_blt (int fd);

Feature test macro to query whether the blitter ring is available.

Note that recent Bspec calls this the BCS ring for Blitter Command Submission.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the blitter ring is available or not.

### gem_has_vebox ()

    bool
    gem_has_vebox (int fd);

Feature test macro to query whether the vebox ring is available.

Note that recent Bspec calls this the VECS ring for Video Enhancement Command Submission.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the vebox ring is available or not.

### gem_has_bsd2 ()

    bool
    gem_has_bsd2 (int fd);

Feature test macro to query whether the BSD2 ring is available.

Note that recent Bspec calls this the VCS ring for Video Command Submission.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the BSD ring is avaible or not.

### gem_gtt_type ()

    int
    gem_gtt_type (int fd);

Feature test macro to check what type of gtt is being used by the kernel: 0 - global gtt 1 - aliasing ppgtt 2 - full ppgtt, limited to 32bit address space 3 - full ppgtt, 64bit address space

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Type of gtt being used.

### gem_uses_ppgtt ()

    bool
    gem_uses_ppgtt (int fd);

Feature test macro to check whether the kernel internally uses ppgtt to execute batches. Note that this is also true when we're using full ppgtt.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether batches are run through ppgtt.

### gem_uses_full_ppgtt ()

    bool
    gem_uses_full_ppgtt (int fd);

Feature test macro to check whether the kernel internally uses full per-process gtt to execute batches. Note that this is also true when we're using full 64b ppgtt.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether batches are run through full ppgtt.

### gem_gpu_reset_type ()

    int
    gem_gpu_reset_type (int fd);

Query whether reset-engine (2), global-reset (1) or reset-disable (0) is available.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

GPU reset type available

### gem_gpu_reset_enabled ()

    bool
    gem_gpu_reset_enabled (int fd);

Feature test macro to check whether the kernel internally uses hangchecks and can reset the GPU upon hang detection. Note that this is also true when reset-engine (the lightweight, single engine reset) is available.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the driver will detect hangs and perform a reset.

### gem_engine_reset_enabled ()

    bool
    gem_engine_reset_enabled (int fd);

Feature test macro to check whether the kernel internally uses hangchecks and can reset individual engines upon hang detection.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether the driver will detect hangs and perform an engine reset.

### gem_available_fences ()

    int
    gem_available_fences (int fd);

Feature test macro to query the kernel for the number of available fences usable in a batchbuffer. Only relevant for pre-gen4.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

The number of available fences.

### gem_total_mappable_size ()

    uint64_t
    gem_total_mappable_size (int fd);

Feature test macro to query the kernel for the total mappable size.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Total mappable address space size.

### gem_total_stolen_size ()

    uint64_t
    gem_total_stolen_size (int fd);

Feature test macro to query the kernel for the total stolen size.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Total stolen memory.

### gem_available_aperture_size ()

    uint64_t
    gem_available_aperture_size (int fd);

Feature test macro to query the kernel for the available gpu aperture size usable in a batchbuffer.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

The available gtt address space size.

### gem_aperture_size ()

    uint64_t
    gem_aperture_size (int fd);

Feature test macro to query the kernel for the total gpu aperture size.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

The total gtt address space size.

### gem_global_aperture_size ()

    uint64_t
    gem_global_aperture_size (int fd);

Feature test macro to query the kernel for the global gpu aperture size. This is the area available for the kernel to perform address translations.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

The mappable gtt address space size.

### gem_mappable_aperture_size ()

    uint64_t
    gem_mappable_aperture_size (void);

Feature test macro to query the kernel for the mappable gpu aperture size. This is the area available for GTT memory mappings.

#### Returns

The mappable gtt address space size.

### gem_has_softpin ()

    bool
    gem_has_softpin (int fd);

Feature test macro to query whether the softpinning functionality is supported.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether softpin support is available

### gem_has_exec_fence ()

    bool
    gem_has_exec_fence (int fd);

Feature test macro to query whether in/out fence support in execbuffer is available.

#### Parameters

fd | open i915 drm file descriptor |

#### Returns

Whether fence support is available

### gem_require_caching ()

    void
    gem_require_caching (int fd);

Feature test macro to query whether buffer object caching control is available. Automatically skips through `igt_require()` if not.

#### Parameters

fd | open i915 drm file descriptor |

### gem_has_ring ()

    bool
    gem_has_ring (int fd,
                  unsigned  ring);

### gem_require_ring ()

    void
    gem_require_ring (int fd,
                      unsigned  ring);

Feature test macro to query whether a specific ring is available. This automagically skips if the ring isn't available by calling `igt_require()`.

#### Parameters

fd | open i915 drm file descriptor |
ring | ring flag bit as used in `gem_execbuf()` |

### gem_has_mocs_registers ()

    bool
    gem_has_mocs_registers (int fd);

Feature test macro to query whether the device has MOCS registers. These exist gen 9+.

#### Parameters

fd | open i915 drm file descriptor |

### gem_require_mocs_registers ()

    void
    gem_require_mocs_registers (int fd);

Feature test macro to query whether the device has MOCS registers. These exist gen 9+.

#### Parameters

fd | open i915 drm file descriptor |

### prime_handle_to_fd ()

    int
    prime_handle_to_fd (int fd,
                        uint32_t handle);

This wraps the PRIME_HANDLE_TO_FD ioctl, which is used to export a gem buffer object into a global (i.e. potentially cross-device) dma-buf file-descriptor handle.

#### Parameters

fd | open i915 drm file descriptor |
handle | file-private gem buffer object handle |

#### Returns

The created dma-buf fd handle.

### prime_handle_to_fd_for_mmap ()

    int
    prime_handle_to_fd_for_mmap (int fd,
                                 uint32_t handle);

Same as prime_handle_to_fd above but with DRM_RDWR capabilities, which can be useful for writing into the mmap'ed dma-buf file-descriptor.

#### Parameters

fd | open i915 drm file descriptor |
handle | file-private gem buffer object handle |

#### Returns

The created dma-buf fd handle or -1 if the ioctl fails.

### prime_fd_to_handle ()

    uint32_t
    prime_fd_to_handle (int fd,
                        int dma_buf_fd);

This wraps the PRIME_FD_TO_HANDLE ioctl, which is used to import a dma-buf file-descriptor into a gem buffer object.

#### Parameters

fd | open i915 drm file descriptor |
dma_buf_fd | dma-buf fd handle |

#### Returns

The created gem buffer object handle.

### prime_get_size ()

    off_t
    prime_get_size (int dma_buf_fd);

This wraps the `lseek()` protocol used to query the invariant size of a dma-buf. Not all kernels support this, which is check with `igt_require()` and so will result in automagic test skipping.

#### Parameters

dma_buf_fd | dma-buf fd handle |

#### Returns

The lifetime-invariant size of the dma-buf object.

### prime_sync_start ()

    void
    prime_sync_start (int dma_buf_fd,
                      bool write);

Must be called before starting CPU mmap access to a dma-buf.

#### Parameters

dma_buf_fd | dma-buf fd handle |
write | read/write or read-only access |

### prime_sync_end ()

    void
    prime_sync_end (int dma_buf_fd,
                    bool write);

Must be called after finishing CPU mmap access to a dma-buf.

#### Parameters

dma_buf_fd | dma-buf fd handle |
write | read/write or read-only access |

### local_fourcc_mod_code()

    #define             local_fourcc_mod_code(vendor, val)

### igt_require_fb_modifiers ()

    void
    igt_require_fb_modifiers (int fd);

Requires presence of DRM_CAP_ADDFB2_MODIFIERS.

#### Parameters

fd | Open DRM file descriptor. |

## Types and Values

### I915_GEM_DOMAIN_WC

    #define I915_GEM_DOMAIN_WC 0x80

### LOCAL_I915_GEM_USERPTR

    #define LOCAL_I915_GEM_USERPTR       0x33

### LOCAL_IOCTL_I915_GEM_USERPTR

    #define LOCAL_IOCTL_I915_GEM_USERPTR DRM_IOWR (DRM_COMMAND_BASE + LOCAL_I915_GEM_USERPTR, struct local_i915_gem_userptr)

### struct local_i915_gem_userptr

    struct local_i915_gem_userptr {
    	uint64_t user_ptr;
    	uint64_t user_size;
    	uint32_t flags;
    #define LOCAL_I915_USERPTR_READ_ONLY (1<<0)
    #define LOCAL_I915_USERPTR_UNSYNCHRONIZED (1<<31)
    	uint32_t handle;
    };

### struct local_dma_buf_sync

    struct local_dma_buf_sync {
    	uint64_t flags;
    };

### LOCAL_DMA_BUF_SYNC_READ

    #define LOCAL_DMA_BUF_SYNC_READ      (1 << 0)

### LOCAL_DMA_BUF_SYNC_WRITE

    #define LOCAL_DMA_BUF_SYNC_WRITE     (2 << 0)

### LOCAL_DMA_BUF_SYNC_RW

    #define LOCAL_DMA_BUF_SYNC_RW        (LOCAL_DMA_BUF_SYNC_READ | LOCAL_DMA_BUF_SYNC_WRITE)

### LOCAL_DMA_BUF_SYNC_START

    #define LOCAL_DMA_BUF_SYNC_START     (0 << 2)

### LOCAL_DMA_BUF_SYNC_END

    #define LOCAL_DMA_BUF_SYNC_END       (1 << 2)

### LOCAL_DMA_BUF_SYNC_VALID_FLAGS_MASK

    #define             LOCAL_DMA_BUF_SYNC_VALID_FLAGS_MASK

### LOCAL_DMA_BUF_BASE

    #define LOCAL_DMA_BUF_BASE 'b'

### LOCAL_DMA_BUF_IOCTL_SYNC

    #define LOCAL_DMA_BUF_IOCTL_SYNC _IOW(LOCAL_DMA_BUF_BASE, 0, struct local_dma_buf_sync)

### DRM_RDWR

    #define DRM_RDWR O_RDWR

### struct local_drm_mode_fb_cmd2

    struct local_drm_mode_fb_cmd2 {
    	uint32_t fb_id;
    	uint32_t width, height;
    	uint32_t pixel_format;
    	uint32_t flags;
    	uint32_t handles[4];
    	uint32_t pitches[4];
    	uint32_t offsets[4];
    	uint64_t modifier[4];
    };

### LOCAL_DRM_MODE_FB_MODIFIERS

    #define LOCAL_DRM_MODE_FB_MODIFIERS (1<<1)

### LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL

    #define LOCAL_DRM_FORMAT_MOD_VENDOR_INTEL 0x01

### LOCAL_DRM_FORMAT_MOD_NONE

    #define LOCAL_DRM_FORMAT_MOD_NONE (0)

### LOCAL_I915_FORMAT_MOD_X_TILED

    #define LOCAL_I915_FORMAT_MOD_X_TILED local_fourcc_mod_code(INTEL, 1)

### LOCAL_I915_FORMAT_MOD_Y_TILED

    #define LOCAL_I915_FORMAT_MOD_Y_TILED local_fourcc_mod_code(INTEL, 2)

### LOCAL_I915_FORMAT_MOD_Yf_TILED

    #define LOCAL_I915_FORMAT_MOD_Yf_TILED local_fourcc_mod_code(INTEL, 3)

### LOCAL_I915_FORMAT_MOD_Y_TILED_CCS

    #define LOCAL_I915_FORMAT_MOD_Y_TILED_CCS local_fourcc_mod_code(INTEL, 4)

### LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS

    #define LOCAL_I915_FORMAT_MOD_Yf_TILED_CCS local_fourcc_mod_code(INTEL, 5)

### LOCAL_DRM_IOCTL_MODE_ADDFB2

    #define             LOCAL_DRM_IOCTL_MODE_ADDFB2

### LOCAL_DRM_CAP_ADDFB2_MODIFIERS

    #define LOCAL_DRM_CAP_ADDFB2_MODIFIERS 0x10