drmtest

drmtest — Base library for drm tests and tools

Functions

Types and Values

#define DRIVER_INTEL
#define DRIVER_VC4
#define DRIVER_VGEM
#define DRIVER_AMDGPU
#define DRIVER_V3D
#define DRIVER_PANFROST
#define DRIVER_MSM
#define DRIVER_XE
#define DRIVER_VMWGFX
#define DRIVER_ANY
enum intel_driver

Includes

#include <igt.h>

Description

This library contains the basic support for writing tests, with the most important part being the helper function to open drm device nodes.

But there's also a bit of other assorted stuff here.

Note that this library's header pulls in the i-g-t core and batchbuffer libraries as dependencies.

Functions

drm_get_chipset ()

unsigned int
drm_get_chipset (int fd);

Parameters

fd

a drm file descriptor

 

Returns

chipset if driver name found in modules[] array, for example: DRIVER_INTEL DRIVER_ANY if drm device name not known


ARRAY_SIZE()

#define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))

Macro to compute the size of the static array arr .

Parameters

arr

static array

 

ALIGN()

#define ALIGN(v, a) ALIGN_MASK(v, (typeof(v))(a) - 1)

Macro to align a value v to a specified unit a .

Parameters

v

value to be aligned

 

a

alignment unit in bytes

 

ALIGN_MASK()

#define ALIGN_MASK(v, mask) (((v) + (mask)) & ~(mask))

ALIGN_DOWN()

#define ALIGN_DOWN(x, a) ALIGN((x) - ((a) - 1), (a))

Macro to align down a value v to a specified unit a .

Parameters

v

value to be aligned down

 

a

alignment unit in bytes

 

IS_ALIGNED()

#define IS_ALIGNED(v, a) (((v) & ((typeof(v))(a) - 1)) == 0)

Macro to check if value v is aligned to a

Parameters

v

value to check

 

a

alignment unit in bytes

 

drm_load_module ()

void
drm_load_module (unsigned int chipset);

drm_open_driver_another ()

int
drm_open_driver_another (int idx,
                         int chipset);

A wrapper for __drm_open_driver with skip on fail.

Parameters

idx

index of the device you are opening

 

chipset

OR'd flags for each chipset to search, eg. DRIVER_INTEL

 

Returns

An open DRM fd or skips


drm_open_driver ()

int
drm_open_driver (int chipset);

Open a drm legacy device node. This function always returns a valid file descriptor.

Parameters

chipset

OR'd flags for each chipset to search, eg. DRIVER_INTEL

 

Returns

a drm file descriptor


drm_open_driver_master ()

int
drm_open_driver_master (int chipset);

Open a drm legacy device node and ensure that it is drm master.

Parameters

chipset

OR'd flags for each chipset to search, eg. DRIVER_INTEL

 

Returns

The drm file descriptor or -1 on error


drm_open_driver_render ()

int
drm_open_driver_render (int chipset);

Open a drm render device node.

Parameters

chipset

OR'd flags for each chipset to search, eg. DRIVER_INTEL

 

Returns

The drm file descriptor or -1 on error


drm_close_driver ()

int
drm_close_driver (int fd);

Check the given drm file descriptor fd is valid and if not issue warning. For valid fd close it and make cleanups.

Parameters

fd

a drm file descriptor

 

Returns

0 on success or -1 on error.


drm_reopen_driver ()

int
drm_reopen_driver (int fd);

Re-opens the drm fd which is useful in instances where a clean default context is needed.

Parameters

fd

re-open the drm file descriptor

 

drm_prepare_filtered_multigpu ()

int
drm_prepare_filtered_multigpu (int chipset);

drm_open_filtered_card ()

int
drm_open_filtered_card (int idx);

Open N-th GPU from filtered list

Parameters

idx

index for GPU to open

 

Returns

Opened device or -1 if error.


igt_require_amdgpu ()

void
igt_require_amdgpu (int fd);

igt_require_intel ()

void
igt_require_intel (int fd);

igt_require_i915 ()

void
igt_require_i915 (int fd);

igt_require_nouveau ()

void
igt_require_nouveau (int fd);

igt_require_vc4 ()

void
igt_require_vc4 (int fd);

igt_require_xe ()

void
igt_require_xe (int fd);

is_amdgpu_device ()

bool
is_amdgpu_device (int fd);

is_i915_device ()

bool
is_i915_device (int fd);

is_mtk_device ()

bool
is_mtk_device (int fd);

is_msm_device ()

bool
is_msm_device (int fd);

is_nouveau_device ()

bool
is_nouveau_device (int fd);

is_vc4_device ()

bool
is_vc4_device (int fd);

is_xe_device ()

bool
is_xe_device (int fd);

is_intel_device ()

bool
is_intel_device (int fd);

get_intel_driver ()

enum intel_driver
get_intel_driver (int fd);

do_or_die()

#define do_or_die(x) igt_assert((x) == 0)

Simple macro to execute x and check that it's return value is 0. Presumes that in any failure case the return value is non-zero and a precise error is logged into errno. Uses igt_assert() internally.

Parameters

x

command

 

do_ioctl()

#define             do_ioctl(fd, ioc, ioc_data)

This macro wraps drmIoctl() and uses igt_assert to check that it has been successfully executed.

Parameters

fd

open i915 drm file descriptor

 

ioc

ioctl op definition from drm headers

 

ioc_data

data pointer for the ioctl operation

 

do_ioctl_err()

#define             do_ioctl_err(fd, ioc, ioc_data, err)

This macro wraps drmIoctl() and uses igt_assert to check that it fails, returning a particular value in errno.

Parameters

fd

open i915 drm file descriptor

 

ioc

ioctl op definition from drm headers

 

ioc_data

data pointer for the ioctl operation

 

err

value to expect in errno

 

Types and Values

DRIVER_INTEL

#define DRIVER_INTEL (1 << 0)

DRIVER_VC4

#define DRIVER_VC4 (1 << 1)

DRIVER_VGEM

#define DRIVER_VGEM (1 << 2)

DRIVER_AMDGPU

#define DRIVER_AMDGPU (1 << 3)

DRIVER_V3D

#define DRIVER_V3D (1 << 4)

DRIVER_PANFROST

#define DRIVER_PANFROST (1 << 5)

DRIVER_MSM

#define DRIVER_MSM (1 << 6)

DRIVER_XE

#define DRIVER_XE (1 << 7)

DRIVER_VMWGFX

#define DRIVER_VMWGFX   (1 << 8)

DRIVER_ANY

#define DRIVER_ANY 	~(DRIVER_VGEM)

enum intel_driver

Members

INTEL_DRIVER_I915

   

INTEL_DRIVER_XE