drmtest

drmtest — Base library for drm tests and tools

Functions

#define ARRAY_SIZE()
#define ALIGN()
int drm_get_card ()
int drm_open_driver ()
int drm_open_driver_master ()
int drm_open_driver_render ()
void gem_quiescent_gpu ()
void igt_require_intel ()
bool is_i915_device ()
#define do_or_die()
#define do_ioctl()
#define do_ioctl_err()

Types and Values

#define DRIVER_INTEL
#define DRIVER_VC4
#define DRIVER_VGEM
#define DRIVER_VIRTIO
#define DRIVER_AMDGPU
#define DRIVER_V3D
#define DRIVER_ANY

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

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) (((v) + (a)-1) & ~((a)-1))

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

Parameters

v

value to be aligned

 

a

alignment unit in bytes

 

drm_get_card ()

int
drm_get_card (void);

Get an i915 drm card index number for use in /dev or /sys. The minor index of the legacy node is returned, not of the control or render node.

Returns

The i915 drm index or -1 on error


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


gem_quiescent_gpu ()

void
gem_quiescent_gpu (int fd);

Ensure the gpu is idle by launching a nop execbuf and stalling for it. This is automatically run when opening a drm device node and is also installed as an exit handler to have the best assurance that the test is run in a pristine and controlled environment.

This function simply allows tests to make additional calls in-between, if so desired.

Parameters

fd

open i915 drm file descriptor

 

igt_require_intel ()

void
igt_require_intel (int fd);

is_i915_device ()

bool
is_i915_device (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_VIRTIO

#define DRIVER_VIRTIO (1 << 3)

DRIVER_AMDGPU

#define DRIVER_AMDGPU (1 << 4)

DRIVER_V3D

#define DRIVER_V3D (1 << 5)

DRIVER_ANY

#define DRIVER_ANY 	~(DRIVER_VGEM)