KMS

KMS — Kernel modesetting support library

Functions

const char * kmstest_pipe_name ()
int kmstest_pipe_to_index ()
const char * kmstest_plane_type_name ()
#define kmstest_port_name()
const char * kmstest_encoder_type_str ()
const char * kmstest_connector_status_str ()
const char * kmstest_connector_type_str ()
void kmstest_dump_mode ()
int kmstest_get_pipe_from_crtc_id ()
void kmstest_set_vt_graphics_mode ()
void kmstest_restore_vt_mode ()
bool kmstest_force_connector ()
void kmstest_edid_add_3d ()
void kmstest_edid_add_4k ()
void kmstest_edid_add_audio ()
void kmstest_force_edid ()
bool kmstest_get_connector_default_mode ()
bool kmstest_get_connector_config ()
bool kmstest_probe_connector_config ()
void kmstest_free_connector_config ()
void kmstest_set_connector_dpms ()
bool kmstest_get_property ()
void kmstest_unset_all_crtcs ()
int kmstest_get_crtc_idx ()
uint32_t kmstest_find_crtc_for_connector ()
uint32_t kmstest_dumb_create ()
void * kmstest_dumb_map_buffer ()
void kmstest_dumb_destroy ()
void kmstest_wait_for_pageflip ()
unsigned int kmstest_get_vblank ()
void igt_assert_plane_visible ()
bool igt_display_init ()
void igt_display_require ()
void igt_display_fini ()
void igt_display_reset ()
int igt_display_commit2 ()
int igt_display_commit ()
int igt_display_try_commit_atomic ()
void igt_display_commit_atomic ()
int igt_display_try_commit2 ()
int igt_display_drop_events ()
int igt_display_get_n_pipes ()
void igt_display_require_output ()
void igt_display_require_output_on_pipe ()
const char * igt_output_name ()
drmModeModeInfo * igt_output_get_mode ()
void igt_output_override_mode ()
void igt_output_set_pipe ()
igt_plane_t * igt_output_get_plane ()
igt_plane_t * igt_output_get_plane_type ()
igt_output_t * igt_output_from_connector ()
igt_plane_t * igt_pipe_get_plane_type ()
igt_output_t * igt_get_single_output_for_pipe ()
void igt_pipe_request_out_fence ()
void igt_plane_set_fb ()
void igt_plane_set_fence_fd ()
void igt_plane_set_position ()
void igt_plane_set_size ()
void igt_plane_set_rotation ()
void igt_fb_set_position ()
void igt_fb_set_size ()
void igt_wait_for_vblank ()
void igt_wait_for_vblank_count ()
#define igt_pipe_connector_valid()
#define for_each_if()
#define for_each_connected_output()
#define for_each_pipe_static()
#define for_each_pipe()
#define for_each_pipe_with_valid_output()
#define for_each_pipe_with_single_output()
#define for_each_valid_output_on_pipe()
#define for_each_plane_on_pipe()
#define IGT_FIXED()
bool igt_plane_has_prop ()
uint64_t igt_plane_get_prop ()
#define igt_plane_is_prop_changed()
#define igt_plane_set_prop_changed()
#define igt_plane_clear_prop_changed()
#define igt_plane_set_prop_value()
bool igt_plane_try_prop_enum ()
void igt_plane_set_prop_enum ()
void igt_plane_replace_prop_blob ()
bool igt_output_has_prop ()
uint64_t igt_output_get_prop ()
#define igt_output_is_prop_changed()
#define igt_output_set_prop_changed()
#define igt_output_clear_prop_changed()
#define igt_output_set_prop_value()
bool igt_output_try_prop_enum ()
void igt_output_set_prop_enum ()
void igt_output_replace_prop_blob ()
bool igt_pipe_obj_has_prop ()
uint64_t igt_pipe_obj_get_prop ()
uint64_t igt_pipe_get_prop ()
bool igt_pipe_has_prop ()
#define igt_pipe_obj_is_prop_changed()
#define igt_pipe_is_prop_changed()
#define igt_pipe_obj_set_prop_changed()
#define igt_pipe_set_prop_changed()
#define igt_pipe_obj_clear_prop_changed()
#define igt_pipe_clear_prop_changed()
#define igt_pipe_obj_set_prop_value()
#define igt_pipe_set_prop_value()
bool igt_pipe_obj_try_prop_enum ()
void igt_pipe_obj_set_prop_enum ()
#define igt_pipe_try_prop_enum()
#define igt_pipe_set_prop_enum()
void igt_pipe_obj_replace_prop_blob ()
#define igt_pipe_replace_prop_blob()
void igt_pipe_refresh ()
void igt_enable_connectors ()
void igt_reset_connectors ()
uint32_t kmstest_get_vbl_flag ()
const unsigned char * igt_kms_get_base_edid ()
const unsigned char * igt_kms_get_alt_edid ()
struct udev_monitor * igt_watch_hotplug ()
bool igt_hotplug_detected ()
void igt_flush_hotplugs ()
void igt_cleanup_hotplug ()
bool igt_display_has_format_mod ()
bool igt_plane_has_format_mod ()

Types and Values

Includes

#include <igt.h>

Description

This library provides support to enumerate and set modeset configurations.

There are two parts in this library: First the low level helper function which directly build on top of raw ioctls or the interfaces provided by libdrm. Those functions all have a kmstest_ prefix.

The second part is a high-level library to manage modeset configurations which abstracts away some of the low-level details like the difference between legacy and universal plane support for setting cursors or in the future the difference between legacy and atomic commit. These high-level functions have all igt_ prefixes. This part is still very much work in progress and so also lacks a bit documentation for the individual functions.

Note that this library's header pulls in the i-g-t framebuffer library as a dependency.

Functions

kmstest_pipe_name ()

const char *
kmstest_pipe_name (enum pipe pipe);

Parameters

pipe

display pipe

 

Returns

String representing pipe , e.g. "A".


kmstest_pipe_to_index ()

int
kmstest_pipe_to_index (char pipe);

Parameters

pipe

display pipe in string format

 

Returns

index to corresponding pipe


kmstest_plane_type_name ()

const char *
kmstest_plane_type_name (int plane_type);

Parameters

plane_type

display plane type

 

Returns

String representing plane_type , e.g. "overlay".


kmstest_port_name()

#define kmstest_port_name(port) ((port) + 'A')

Parameters

port

display plane

 

Returns

String representing port , e.g. "A".


kmstest_encoder_type_str ()

const char *
kmstest_encoder_type_str (int type);

Parameters

type

DRM_MODE_ENCODER_* enumeration value

 

Returns

A string representing the drm encoder type .


kmstest_connector_status_str ()

const char *
kmstest_connector_status_str (int status);

Parameters

status

DRM_MODE_* connector status value

 

Returns

A string representing the drm connector status status .


kmstest_connector_type_str ()

const char *
kmstest_connector_type_str (int type);

Parameters

type

DRM_MODE_CONNECTOR_* enumeration value

 

Returns

A string representing the drm connector type .


kmstest_dump_mode ()

void
kmstest_dump_mode (drmModeModeInfo *mode);

Prints mode to stdout in a human-readable form.

Parameters

mode

libdrm mode structure

 

kmstest_get_pipe_from_crtc_id ()

int
kmstest_get_pipe_from_crtc_id (int fd,
                               int crtc_id);

Parameters

fd

DRM fd

 

crtc_id

DRM CRTC id

 

Returns

The crtc index for the given DRM CRTC ID crtc_id . The crtc index is the equivalent of the pipe id. This value maps directly to an enum pipe value used in other helper functions. Returns 0 if the index could not be determined.


kmstest_set_vt_graphics_mode ()

void
kmstest_set_vt_graphics_mode (void);

Sets the controlling VT (if available) into graphics/raw mode and installs an igt exit handler to set the VT back to text mode on exit. Use kmstest_restore_vt_mode to restore the previous VT mode manually.

All kms tests must call this function to make sure that the fbcon doesn't interfere by e.g. blanking the screen.


kmstest_restore_vt_mode ()

void
kmstest_restore_vt_mode (void);

Restore the VT mode in use before kmstest_set_vt_graphics_mode was called.


kmstest_force_connector ()

bool
kmstest_force_connector (int fd,
                         drmModeConnector *connector,
                         enum kmstest_force_connector_state state);

Force the specified state on the specified connector.

Parameters

fd

drm file descriptor

 

connector

connector

 

state

state to force on connector

 

Returns

true on success


kmstest_edid_add_3d ()

void
kmstest_edid_add_3d (const unsigned char *edid,
                     size_t length,
                     unsigned char *new_edid_ptr[],
                     size_t *new_length);

Makes a copy of an existing edid block and adds an extension indicating stereo 3D capabilities.

Parameters

edid

an existing valid edid block

 

length

length of edid

 

new_edid_ptr

pointer to where the new edid will be placed

 

new_length

pointer to the size of the new edid

 

kmstest_edid_add_4k ()

void
kmstest_edid_add_4k (const unsigned char *edid,
                     size_t length,
                     unsigned char *new_edid_ptr[],
                     size_t *new_length);

Makes a copy of an existing edid block and adds an extension indicating a HDMI 4K mode in vsdb.

Parameters

edid

an existing valid edid block

 

length

length of edid

 

new_edid_ptr

pointer to where the new edid will be placed

 

new_length

pointer to the size of the new edid

 

kmstest_edid_add_audio ()

void
kmstest_edid_add_audio (const unsigned char *edid,
                        size_t length,
                        unsigned char *new_edid_ptr[],
                        size_t *new_length);

Makes a copy of an existing edid block and adds an extension indicating basic audio support and speaker data block.

Parameters

edid

an existing valid edid block

 

length

length of edid

 

new_edid_ptr

pointer to where the new edid will be placed

 

new_length

pointer to the size of the new edid

 

kmstest_force_edid ()

void
kmstest_force_edid (int drm_fd,
                    drmModeConnector *connector,
                    const unsigned char *edid,
                    size_t length);

Set the EDID data on connector to edid . See also igt_kms_get_base_edid.

If length is zero, the forced EDID will be removed.

Parameters

drm_fd

drm file descriptor

 

connector

connector to set edid on

 

edid

An EDID data block

 

length

length of the EDID data. EDID_LENGTH defines the standard EDID length

 

kmstest_get_connector_default_mode ()

bool
kmstest_get_connector_default_mode (int drm_fd,
                                    drmModeConnector *connector,
                                    drmModeModeInfo *mode);

Retrieves the default mode for connector and stores it in mode .

Parameters

drm_fd

DRM fd

 

connector

libdrm connector

 

mode

libdrm mode

 

Returns

true on success, false on failure


kmstest_get_connector_config ()

bool
kmstest_get_connector_config (int drm_fd,
                              uint32_t connector_id,
                              unsigned long  crtc_idx_mask,
                              struct kmstest_connector_config *config);

This tries to find a suitable configuration for the given connector and CRTC constraint and fills it into config .

Parameters

drm_fd

DRM fd

 

connector_id

DRM connector id

 

crtc_idx_mask

mask of allowed DRM CRTC indices

 

config

structure filled with the possible configuration

 

kmstest_probe_connector_config ()

bool
kmstest_probe_connector_config (int drm_fd,
                                uint32_t connector_id,
                                unsigned long  crtc_idx_mask,
                                struct kmstest_connector_config *config);

This tries to find a suitable configuration for the given connector and CRTC constraint and fills it into config , fully probing the connector in the process.

Parameters

drm_fd

DRM fd

 

connector_id

DRM connector id

 

crtc_idx_mask

mask of allowed DRM CRTC indices

 

config

structure filled with the possible configuration

 

kmstest_free_connector_config ()

void
kmstest_free_connector_config (struct kmstest_connector_config *config);

Free any resources in config allocated in kmstest_get_connector_config().

Parameters

config

connector configuration structure

 

kmstest_set_connector_dpms ()

void
kmstest_set_connector_dpms (int fd,
                            drmModeConnector *connector,
                            int mode);

This function sets the DPMS setting of connector to mode .

Parameters

fd

DRM fd

 

connector

libdrm connector

 

mode

DRM DPMS value

 

kmstest_get_property ()

bool
kmstest_get_property (int drm_fd,
                      uint32_t object_id,
                      uint32_t object_type,
                      const char *name,
                      uint32_t *prop_id,
                      uint64_t *value,
                      drmModePropertyPtr *prop);

Finds a property with the given name on the given object.

Parameters

drm_fd

drm file descriptor

 

object_id

object whose properties we're going to get

 

object_type

type of obj_id (DRM_MODE_OBJECT_*)

 

name

name of the property we're going to get

 

prop_id

if not NULL, returns the property id

 

value

if not NULL, returns the property value

 

prop

if not NULL, returns the property, and the caller will have to free it manually.

 

Returns

true in case we found something.


kmstest_unset_all_crtcs ()

void
kmstest_unset_all_crtcs (int drm_fd,
                         drmModeResPtr resources);

Disables all the screens.

Parameters

drm_fd

the DRM fd

 

resources

libdrm resources pointer

 

kmstest_get_crtc_idx ()

int
kmstest_get_crtc_idx (drmModeRes *res,
                      uint32_t crtc_id);

Get the CRTC index based on its ID. This is useful since a few places of libdrm deal with CRTC masks.

Parameters

res

the libdrm resources

 

crtc_id

the CRTC id

 

kmstest_find_crtc_for_connector ()

uint32_t
kmstest_find_crtc_for_connector (int fd,
                                 drmModeRes *res,
                                 drmModeConnector *connector,
                                 uint32_t crtc_blacklist_idx_mask);

Parameters

fd

DRM fd

 

res

libdrm resources pointer

 

connector

libdrm connector pointer

 

crtc_blacklist_idx_mask

a mask of CRTC indexes that we can't return

 

Returns

the CRTC ID for a CRTC that fits the connector, otherwise it asserts false and never returns. The blacklist mask can be used in case you have CRTCs that are already in use by other connectors.


kmstest_dumb_create ()

uint32_t
kmstest_dumb_create (int fd,
                     int width,
                     int height,
                     int bpp,
                     unsigned *stride,
                     uint64_t *size);

This wraps the CREATE_DUMB ioctl, which allocates a new dumb buffer object for the specified dimensions.

Parameters

fd

open drm file descriptor

 

width

width of the buffer in pixels

 

height

height of the buffer in pixels

 

bpp

bytes per pixel of the buffer

 

stride

Pointer which receives the dumb bo's stride, can be NULL.

 

size

Pointer which receives the dumb bo's size, can be NULL.

 

Returns

The file-private handle of the created buffer object


kmstest_dumb_map_buffer ()

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

Parameters

fd

Opened drm file descriptor

 

handle

Offset in the file referred to by fd

 

size

Length of the mapping, must be greater than 0

 

prot

Describes the memory protection of the mapping

 

Returns

A pointer representing the start of the virtual mapping


kmstest_dumb_destroy ()

void
kmstest_dumb_destroy (int fd,
                      uint32_t handle);

Parameters

fd

Opened drm file descriptor

 

handle

Offset in the file referred to by fd

 

kmstest_wait_for_pageflip ()

void
kmstest_wait_for_pageflip (int fd);

Blocks until pageflip is completed

Parameters

fd

Opened drm file descriptor

 

kmstest_get_vblank ()

unsigned int
kmstest_get_vblank (int fd,
                    int pipe,
                    unsigned int flags);

Blocks or request a signal when a specified vblank event occurs

Returns 0 on success or non-zero unsigned integer otherwise

Parameters

fd

Opened drm file descriptor

 

pipe

Display pipe

 

flags

Flags passed to drm_ioctl_wait_vblank

 

igt_assert_plane_visible ()

void
igt_assert_plane_visible (int fd,
                          enum pipe pipe,
                          bool visibility);

Asserts only if the plane's visibility state matches the status being passed by visibility

Parameters

fd

Opened file descriptor

 

pipe

Display pipe

 

visibility

Boolean parameter to test against the plane's current visibility state

 

igt_display_init ()

bool
igt_display_init (igt_display_t *display,
                  int drm_fd);

Initialize display and allocate the various resources required. Use igt_display_fini to release the resources when they are no longer required.

Parameters

display

a pointer to an igt_display_t structure

 

drm_fd

a drm file descriptor

 

Returns

true if the display has outputs and pipes available, false otherwise


igt_display_require ()

void
igt_display_require (igt_display_t *display,
                     int drm_fd);

igt_display_fini ()

void
igt_display_fini (igt_display_t *display);

Release any resources associated with display . This does not free display itself.

Parameters

display

a pointer to an igt_display_t structure

 

igt_display_reset ()

void
igt_display_reset (igt_display_t *display);

Reset basic pipes, connectors and planes on display back to default values. In particular, the following properties will be reset:

For outputs:

For pipes:

For planes:

Parameters

display

a pointer to an igt_display_t structure

 

igt_display_commit2 ()

int
igt_display_commit2 (igt_display_t *display,
                     enum igt_commit_style s);

Commits framebuffer and positioning changes to all planes of each display pipe, using a specific API to perform the programming. This function should be used to exercise a specific driver programming API; igt_display_commit should be used instead if the API used is unimportant to the test being run.

This function should only be used to commit changes that are expected to succeed, since any failure during the commit process will cause the IGT subtest to fail. To commit changes that are expected to fail, use igt_try_display_commit2 instead.

Parameters

display

DRM device handle

 

s

Commit style

 

Returns

0 upon success. This function will never return upon failure since igt_fail() at lower levels will longjmp out of it.


igt_display_commit ()

int
igt_display_commit (igt_display_t *display);

Commits framebuffer and positioning changes to all planes of each display pipe.

Parameters

display

DRM device handle

 

Returns

0 upon success. This function will never return upon failure since igt_fail() at lower levels will longjmp out of it.


igt_display_try_commit_atomic ()

int
igt_display_try_commit_atomic (igt_display_t *display,
                               uint32_t flags,
                               void *user_data);

This function is similar to igt_display_try_commit2, but is used when you want to pass different flags to the actual commit.

Useful flags can be DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT, or DRM_MODE_ATOMIC_TEST_ONLY.

user_data is returned in the event if you pass DRM_MODE_PAGE_FLIP_EVENT to flags .

This function will return an error if commit fails, instead of aborting the test.

Parameters

display

igt_display_t to commit.

 

flags

Flags passed to drmModeAtomicCommit.

 

user_data

User defined pointer passed to drmModeAtomicCommit.

 

igt_display_commit_atomic ()

void
igt_display_commit_atomic (igt_display_t *display,
                           uint32_t flags,
                           void *user_data);

This function is similar to igt_display_commit2, but is used when you want to pass different flags to the actual commit.

Useful flags can be DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT, or DRM_MODE_ATOMIC_TEST_ONLY.

user_data is returned in the event if you pass DRM_MODE_PAGE_FLIP_EVENT to flags .

This function will abort the test if commit fails.

Parameters

display

igt_display_t to commit.

 

flags

Flags passed to drmModeAtomicCommit.

 

user_data

User defined pointer passed to drmModeAtomicCommit.

 

igt_display_try_commit2 ()

int
igt_display_try_commit2 (igt_display_t *display,
                         enum igt_commit_style s);

Attempts to commit framebuffer and positioning changes to all planes of each display pipe. This function should be used to commit changes that are expected to fail, so that the error code can be checked for correctness. For changes that are expected to succeed, use igt_display_commit instead.

Note that in non-atomic commit styles, no display programming will be performed after the first failure is encountered, so only some of the operations requested by a test may have been completed. Tests that catch errors returned by this function should take care to restore the display to a sane state after a failure is detected.

Parameters

display

DRM device handle

 

s

Commit style

 

Returns

0 upon success, otherwise the error code of the first error encountered.


igt_display_drop_events ()

int
igt_display_drop_events (igt_display_t *display);

Nonblockingly reads all current events and drops them, for highest reliablility, call igt_display_commit2() first to flush all outstanding events.

This will be called on the first commit after igt_display_reset() too, to make sure any stale events are flushed.

Parameters

display

DRM device handle

 

Returns

Number of dropped events.


igt_display_get_n_pipes ()

int
igt_display_get_n_pipes (igt_display_t *display);

Returns total number of pipes for the given display

Parameters

display

A pointer to an igt_display_t structure

 

igt_display_require_output ()

void
igt_display_require_output (igt_display_t *display);

Checks whether there's a valid pipe /output combination for the given display Skips test if a valid combination of pipe and output is not found

Parameters

display

A pointer to an igt_display_t structure

 

igt_display_require_output_on_pipe ()

void
igt_display_require_output_on_pipe (igt_display_t *display,
                                    enum pipe pipe);

Checks whether there's a valid pipe /output combination for the given display and pipe Skips test if a valid pipe is not found

Parameters

display

A pointer to an igt_display_t structure

 

pipe

Display pipe

 

igt_output_name ()

const char *
igt_output_name (igt_output_t *output);

Parameters

output

Target output

 

Returns

String representing a connector's name, e.g. "DP-1".


igt_output_get_mode ()

drmModeModeInfo *
igt_output_get_mode (igt_output_t *output);

Get the current mode of the given connector

Parameters

output

Target output

 

Returns

A drmModeModeInfo struct representing the current mode


igt_output_override_mode ()

void
igt_output_override_mode (igt_output_t *output,
                          drmModeModeInfo *mode);

Overrides the output's mode with mode , so that it is used instead of the mode obtained with get connectors. Note that the mode is used without checking if the output supports it, so this might lead to unexpected results.

Parameters

output

Output of which the mode will be overridden

 

mode

New mode, or NULL to disable override.

 

igt_output_set_pipe ()

void
igt_output_set_pipe (igt_output_t *output,
                     enum pipe pipe);

igt_output_get_plane ()

igt_plane_t *
igt_output_get_plane (igt_output_t *output,
                      int plane_idx);

igt_output_get_plane_type ()

igt_plane_t *
igt_output_get_plane_type (igt_output_t *output,
                           int plane_type);

Finds a valid plane type for the given output otherwise the test is skipped if the right combination of output /plane_type is not found

Parameters

output

Target output

 

plane_type

Cursor, primary or an overlay plane

 

Returns

A igt_plane_t structure that matches the requested plane type


igt_output_from_connector ()

igt_output_t *
igt_output_from_connector (igt_display_t *display,
                           drmModeConnector *connector);

Finds the output corresponding to the given connector

Parameters

display

a pointer to an igt_display_t structure

 

connector

a pointer to a drmModeConnector

 

Returns

A igt_output_t structure configured to use the connector, or NULL if none was found


igt_pipe_get_plane_type ()

igt_plane_t *
igt_pipe_get_plane_type (igt_pipe_t *pipe,
                         int plane_type);

Finds a valid plane type for the given pipe otherwise it skips the test if the right combination of pipe /plane_type is not found

Parameters

pipe

Target pipe

 

plane_type

Cursor, primary or an overlay plane

 

Returns

A igt_plane_t structure that matches the requested plane type


igt_get_single_output_for_pipe ()

igt_output_t *
igt_get_single_output_for_pipe (igt_display_t *display,
                                enum pipe pipe);

Get a compatible output for a pipe.

Parameters

display

a pointer to an igt_display_t structure

 

pipe

The pipe for which an igt_output_t must be returned.

 

Returns

A compatible output for a given pipe, or NULL.


igt_pipe_request_out_fence ()

void
igt_pipe_request_out_fence (igt_pipe_t *pipe);

Marks this pipe for requesting an out fence at the next atomic commit will contain the fd number of the out fence created by KMS.

Parameters

pipe

pipe which out fence will be requested for

 

igt_plane_set_fb ()

void
igt_plane_set_fb (igt_plane_t *plane,
                  struct igt_fb *fb);

Pairs a given framebuffer to a plane

This function also sets a default size and position for the framebuffer to avoid crashes on applications that ignore to set these.

Parameters

plane

Plane

 

fb

Framebuffer pointer

 

igt_plane_set_fence_fd ()

void
igt_plane_set_fence_fd (igt_plane_t *plane,
                        int fence_fd);

This function sets a fence fd to enable a commit to wait for some event to occur before completing.

Parameters

plane

plane

 

fence_fd

fence fd, disable fence_fd by setting it to -1

 

igt_plane_set_position ()

void
igt_plane_set_position (igt_plane_t *plane,
                        int x,
                        int y);

This function sets a new (x,y) position for the given plane. New position will be committed at plane commit time via drmModeSetPlane().

Parameters

plane

Plane pointer for which position is to be set

 

x

X coordinate

 

y

Y coordinate

 

igt_plane_set_size ()

void
igt_plane_set_size (igt_plane_t *plane,
                    int w,
                    int h);

This function sets width and height for requested plane. New size will be committed at plane commit time via drmModeSetPlane().

Parameters

plane

plane pointer for which size to be set

 

w

width

 

h

height

 

igt_plane_set_rotation ()

void
igt_plane_set_rotation (igt_plane_t *plane,
                        igt_rotation_t rotation);

This function sets a new rotation for the requested plane . New rotation will be committed at plane commit time via drmModeSetPlane().

Parameters

plane

Plane pointer for which rotation is to be set

 

rotation

Plane rotation value (0, 90, 180, 270)

 

igt_fb_set_position ()

void
igt_fb_set_position (struct igt_fb *fb,
                     igt_plane_t *plane,
                     uint32_t x,
                     uint32_t y);

This function sets position for requested framebuffer as src to plane. New position will be committed at plane commit time via drmModeSetPlane().

Parameters

fb

framebuffer pointer

 

plane

plane

 

x

X position

 

y

Y position

 

igt_fb_set_size ()

void
igt_fb_set_size (struct igt_fb *fb,
                 igt_plane_t *plane,
                 uint32_t w,
                 uint32_t h);

This function sets fetch rect size from requested framebuffer as src to plane. New size will be committed at plane commit time via drmModeSetPlane().

Parameters

fb

framebuffer pointer

 

plane

plane

 

w

width

 

h

height

 

igt_wait_for_vblank ()

void
igt_wait_for_vblank (int drm_fd,
                     enum pipe pipe);

Waits for 1 vertical blank intervals

Parameters

drm_fd

A drm file descriptor

 

pipe

Pipe to wait_for_vblank on

 

igt_wait_for_vblank_count ()

void
igt_wait_for_vblank_count (int drm_fd,
                           enum pipe pipe,
                           int count);

Waits for a given number of vertical blank intervals

Parameters

drm_fd

A drm file descriptor

 

pipe

Pipe to wait_for_vblank on

 

count

Number of vblanks to wait on

 

igt_pipe_connector_valid()

#define             igt_pipe_connector_valid(pipe, output)

Checks whether the given pipe and output can be used together.

Parameters

pipe

pipe to check.

 

output

igt_output_t to check.

 

for_each_if()

#define for_each_if(condition) if (!(condition)) {} else

for_each_connected_output()

#define             for_each_connected_output(display, output)

This for loop iterates over all outputs.

Parameters

display

a pointer to an igt_display_t structure

 

output

The output to iterate.

 

for_each_pipe_static()

#define             for_each_pipe_static(pipe)

for_each_pipe()

#define             for_each_pipe(display, pipe)

This for loop iterates over all pipes.

Note that this cannot be used to enumerate per-pipe subtest names since it depends upon runtime probing of the actual kms driver that is being tested. Used for_each_pipe_static instead.

Parameters

display

a pointer to an igt_display_t structure

 

pipe

The pipe to iterate.

 

for_each_pipe_with_valid_output()

#define             for_each_pipe_with_valid_output(display, pipe, output)

This for loop is called over all connected outputs. This function will try every combination of pipe and output .

If you only need to test a single output for each pipe, use for_each_pipe_with_single_output(), if you only need an output for a single pipe, use igt_get_single_output_for_pipe().

Parameters

display

a pointer to an igt_display_t structure

 

pipe

The pipe for which this pipe / output combination is valid.

 

output

The output for which this pipe / output combination is valid.

 

for_each_pipe_with_single_output()

#define             for_each_pipe_with_single_output(display, pipe, output)

This loop is called over all pipes, and will try to find a compatible output for each pipe. Unlike for_each_pipe_with_valid_output(), this function will be called at most once for each pipe.

Parameters

display

a pointer to an igt_display_t structure

 

pipe

The pipe for which this pipe / output combination is valid.

 

output

The output for which this pipe / output combination is valid.

 

for_each_valid_output_on_pipe()

#define             for_each_valid_output_on_pipe(display, pipe, output)

This for loop is called over all connected output that can be used on this pipe . If there are no valid outputs for this pipe, nothing happens.

Parameters

display

a pointer to an igt_display_t structure

 

pipe

Pipe to enumerate valid outputs over

 

output

The enumerated output.

 

for_each_plane_on_pipe()

#define             for_each_plane_on_pipe(display, pipe, plane)

IGT_FIXED()

#define IGT_FIXED(i,f) ((i) << 16 | (f))

igt_plane_has_prop ()

bool
igt_plane_has_prop (igt_plane_t *plane,
                    enum igt_atomic_plane_properties prop);

Check whether plane supports a given property.

Parameters

plane

Plane to check.

 

prop

Property to check.

 

Returns

True if the property is supported, otherwise false.


igt_plane_get_prop ()

uint64_t
igt_plane_get_prop (igt_plane_t *plane,
                    enum igt_atomic_plane_properties prop);

Return current value on a plane for a given property.

Parameters

plane

Target plane.

 

prop

Property to check.

 

Returns

The value the property is set to, if this is a blob, the blob id is returned. This can be passed to drmModeGetPropertyBlob() to get the contents of the blob.


igt_plane_is_prop_changed()

#define             igt_plane_is_prop_changed(plane, prop)

igt_plane_set_prop_changed()

#define             igt_plane_set_prop_changed(plane, prop)

igt_plane_clear_prop_changed()

#define             igt_plane_clear_prop_changed(plane, prop)

igt_plane_set_prop_value()

#define             igt_plane_set_prop_value(plane, prop, value)

igt_plane_try_prop_enum ()

bool
igt_plane_try_prop_enum (igt_plane_t *plane,
                         enum igt_atomic_plane_properties prop,
                         const char *val);

igt_plane_set_prop_enum ()

void
igt_plane_set_prop_enum (igt_plane_t *plane,
                         enum igt_atomic_plane_properties prop,
                         const char *val);

igt_plane_replace_prop_blob ()

void
igt_plane_replace_prop_blob (igt_plane_t *plane,
                             enum igt_atomic_plane_properties prop,
                             const void *ptr,
                             size_t length);

This function will destroy the old property blob for the given property, and will create a new property blob with the values passed to this function.

The new property blob will be committed when you call igt_display_commit(), igt_display_commit2() or igt_display_commit_atomic().

Parameters

plane

plane to set property on.

 

prop

property for which the blob will be replaced.

 

ptr

Pointer to contents for the property.

 

length

Length of contents.

 

igt_output_has_prop ()

bool
igt_output_has_prop (igt_output_t *output,
                     enum igt_atomic_connector_properties prop);

Check whether output supports a given property.

Parameters

output

Output to check.

 

prop

Property to check.

 

Returns

True if the property is supported, otherwise false.


igt_output_get_prop ()

uint64_t
igt_output_get_prop (igt_output_t *output,
                     enum igt_atomic_connector_properties prop);

Return current value on an output for a given property.

Parameters

output

Target output.

 

prop

Property to return.

 

Returns

The value the property is set to, if this is a blob, the blob id is returned. This can be passed to drmModeGetPropertyBlob() to get the contents of the blob.


igt_output_is_prop_changed()

#define             igt_output_is_prop_changed(output, prop)

igt_output_set_prop_changed()

#define             igt_output_set_prop_changed(output, prop)

igt_output_clear_prop_changed()

#define             igt_output_clear_prop_changed(output, prop)

igt_output_set_prop_value()

#define             igt_output_set_prop_value(output, prop, value)

igt_output_try_prop_enum ()

bool
igt_output_try_prop_enum (igt_output_t *output,
                          enum igt_atomic_connector_properties prop,
                          const char *val);

igt_output_set_prop_enum ()

void
igt_output_set_prop_enum (igt_output_t *output,
                          enum igt_atomic_connector_properties prop,
                          const char *val);

igt_output_replace_prop_blob ()

void
igt_output_replace_prop_blob (igt_output_t *output,
                              enum igt_atomic_connector_properties prop,
                              const void *ptr,
                              size_t length);

This function will destroy the old property blob for the given property, and will create a new property blob with the values passed to this function.

The new property blob will be committed when you call igt_display_commit(), igt_display_commit2() or igt_display_commit_atomic().

Parameters

output

output to set property on.

 

prop

property for which the blob will be replaced.

 

ptr

Pointer to contents for the property.

 

length

Length of contents.

 

igt_pipe_obj_has_prop ()

bool
igt_pipe_obj_has_prop (igt_pipe_t *pipe,
                       enum igt_atomic_crtc_properties prop);

Check whether pipe supports a given property.

Parameters

pipe

Pipe to check.

 

prop

Property to check.

 

Returns

True if the property is supported, otherwise false.


igt_pipe_obj_get_prop ()

uint64_t
igt_pipe_obj_get_prop (igt_pipe_t *pipe,
                       enum igt_atomic_crtc_properties prop);

Return current value on a pipe for a given property.

Parameters

pipe

Target pipe.

 

prop

Property to return.

 

Returns

The value the property is set to, if this is a blob, the blob id is returned. This can be passed to drmModeGetPropertyBlob() to get the contents of the blob.


igt_pipe_get_prop ()

uint64_t
igt_pipe_get_prop (igt_display_t *display,
                   enum pipe pipe,
                   enum igt_atomic_crtc_properties prop);

Return current value on a pipe for a given property.

Parameters

display

Pointer to display.

 

pipe

Target pipe.

 

prop

Property to return.

 

Returns

The value the property is set to, if this is a blob, the blob id is returned. This can be passed to drmModeGetPropertyBlob() to get the contents of the blob.


igt_pipe_has_prop ()

bool
igt_pipe_has_prop (igt_display_t *display,
                   enum pipe pipe,
                   enum igt_atomic_crtc_properties prop);

Check whether pipe supports a given property.

Parameters

display

Pointer to display.

 

pipe

Pipe to check.

 

prop

Property to check.

 

Returns

True if the property is supported, otherwise false.


igt_pipe_obj_is_prop_changed()

#define             igt_pipe_obj_is_prop_changed(pipe_obj, prop)

igt_pipe_is_prop_changed()

#define             igt_pipe_is_prop_changed(display, pipe, prop)

igt_pipe_obj_set_prop_changed()

#define             igt_pipe_obj_set_prop_changed(pipe_obj, prop)

igt_pipe_set_prop_changed()

#define             igt_pipe_set_prop_changed(display, pipe, prop)

igt_pipe_obj_clear_prop_changed()

#define             igt_pipe_obj_clear_prop_changed(pipe_obj, prop)

igt_pipe_clear_prop_changed()

#define             igt_pipe_clear_prop_changed(display, pipe, prop)

igt_pipe_obj_set_prop_value()

#define             igt_pipe_obj_set_prop_value(pipe_obj, prop, value)

igt_pipe_set_prop_value()

#define             igt_pipe_set_prop_value(display, pipe, prop, value)

igt_pipe_obj_try_prop_enum ()

bool
igt_pipe_obj_try_prop_enum (igt_pipe_t *pipe,
                            enum igt_atomic_crtc_properties prop,
                            const char *val);

igt_pipe_obj_set_prop_enum ()

void
igt_pipe_obj_set_prop_enum (igt_pipe_t *pipe,
                            enum igt_atomic_crtc_properties prop,
                            const char *val);

igt_pipe_try_prop_enum()

#define             igt_pipe_try_prop_enum(display, pipe, prop, val)

igt_pipe_set_prop_enum()

#define             igt_pipe_set_prop_enum(display, pipe, prop, val)

igt_pipe_obj_replace_prop_blob ()

void
igt_pipe_obj_replace_prop_blob (igt_pipe_t *pipe,
                                enum igt_atomic_crtc_properties prop,
                                const void *ptr,
                                size_t length);

This function will destroy the old property blob for the given property, and will create a new property blob with the values passed to this function.

The new property blob will be committed when you call igt_display_commit(), igt_display_commit2() or igt_display_commit_atomic().

Please use igt_output_override_mode() if you want to set IGT_CRTC_MODE_ID, it works better with legacy commit.

Parameters

pipe

pipe to set property on.

 

prop

property for which the blob will be replaced.

 

ptr

Pointer to contents for the property.

 

length

Length of contents.

 

igt_pipe_replace_prop_blob()

#define             igt_pipe_replace_prop_blob(display, pipe, prop, ptr, length)

igt_pipe_refresh ()

void
igt_pipe_refresh (igt_display_t *display,
                  enum pipe pipe,
                  bool force);

igt_enable_connectors ()

void
igt_enable_connectors (int drm_fd);

Force connectors to be enabled where this is known to work well. Use igt_reset_connectors to revert the changes.

An exit handler is installed to ensure connectors are reset when the test exits.


igt_reset_connectors ()

void
igt_reset_connectors (void);

Remove any forced state from the connectors.


kmstest_get_vbl_flag ()

uint32_t
kmstest_get_vbl_flag (uint32_t pipe_id);

Convert a pipe id into the flag representation expected in DRM while processing DRM_IOCTL_WAIT_VBLANK.

Parameters

pipe_id

Pipe to convert to flag representation.

 

igt_kms_get_base_edid ()

const unsigned char *
igt_kms_get_base_edid (void);

Get the base edid block, which includes the following modes:

  • 1920x1080 60Hz

  • 1280x720 60Hz

  • 1024x768 60Hz

  • 800x600 60Hz

  • 640x480 60Hz

This can be extended with further features using functions such as kmstest_edid_add_3d.

Returns

a basic edid block


igt_kms_get_alt_edid ()

const unsigned char *
igt_kms_get_alt_edid (void);

Get an alternate edid block, which includes the following modes:

  • 1400x1050 60Hz

  • 1920x1080 60Hz

  • 1280x720 60Hz

  • 1024x768 60Hz

  • 800x600 60Hz

  • 640x480 60Hz

This can be extended with further features using functions such as kmstest_edid_add_3d.

Returns

an alternate edid block


igt_watch_hotplug ()

struct udev_monitor *
igt_watch_hotplug (void);

Begin monitoring udev for sysfs hotplug events.

Returns

a udev monitor for detecting hotplugs on


igt_hotplug_detected ()

bool
igt_hotplug_detected (struct udev_monitor *mon,
                      int timeout_secs);

Assert that a hotplug event was received since we last checked the monitor.

Parameters

mon

A udev monitor initialized with igt_watch_hotplug

 

timeout_secs

How long to wait for a hotplug event to occur.

 

Returns

true if a sysfs hotplug event was received, false if we timed out


igt_flush_hotplugs ()

void
igt_flush_hotplugs (struct udev_monitor *mon);

Get rid of any pending hotplug events

Parameters

mon

A udev monitor initialized with igt_watch_hotplug

 

igt_cleanup_hotplug ()

void
igt_cleanup_hotplug (struct udev_monitor *mon);

Cleanup the resources allocated by igt_watch_hotplug

Parameters

mon

A udev monitor initialized with igt_watch_hotplug

 

igt_display_has_format_mod ()

bool
igt_display_has_format_mod (igt_display_t *display,
                            uint32_t format,
                            uint64_t modifier);

igt_plane_has_format_mod ()

bool
igt_plane_has_format_mod (igt_plane_t *plane,
                          uint32_t format,
                          uint64_t modifier);

Types and Values

enum pipe

Members

PIPE_NONE

Invalid pipe, used for disconnecting a output from a pipe.

 

PIPE_ANY

Deprecated alias for PIPE_NONE .

 

PIPE_A

First crtc.

 

PIPE_B

Second crtc.

 

PIPE_C

Third crtc.

 

PIPE_D

Fourth crtc.

 

PIPE_E

Fifth crtc.

 

PIPE_F

Sixth crtc.

 

IGT_MAX_PIPES

Max number of pipes allowed.

 

enum port

Members

PORT_A

   

PORT_B

   

PORT_C

   

PORT_D

   

PORT_E

   

I915_MAX_PORTS

   

enum igt_atomic_crtc_properties

Members

IGT_CRTC_BACKGROUND

   

IGT_CRTC_CTM

   

IGT_CRTC_GAMMA_LUT

   

IGT_CRTC_GAMMA_LUT_SIZE

   

IGT_CRTC_DEGAMMA_LUT

   

IGT_CRTC_DEGAMMA_LUT_SIZE

   

IGT_CRTC_MODE_ID

   

IGT_CRTC_ACTIVE

   

IGT_CRTC_OUT_FENCE_PTR

   

IGT_NUM_CRTC_PROPS

   

enum igt_atomic_connector_properties

Members

IGT_CONNECTOR_SCALING_MODE

   

IGT_CONNECTOR_CRTC_ID

   

IGT_CONNECTOR_DPMS

   

IGT_CONNECTOR_BROADCAST_RGB

   

IGT_CONNECTOR_CONTENT_PROTECTION

   

IGT_NUM_CONNECTOR_PROPS

   

struct kmstest_connector_config

struct kmstest_connector_config {
	drmModeCrtc *crtc;
	drmModeConnector *connector;
	drmModeEncoder *encoder;
	drmModeModeInfo default_mode;

	int pipe;
	unsigned valid_crtc_idx_mask;
};

struct kmstest_plane

struct kmstest_plane {
	int id;
	int index;
	int type;
	int pos_x;
	int pos_y;
	int width;
	int height;
};

struct kmstest_crtc

struct kmstest_crtc {
	int id;
	int pipe;
	bool active;
	int width;
	int height;
	int n_planes;
	struct kmstest_plane *planes;
};

enum kmstest_force_connector_state

Members

FORCE_CONNECTOR_UNSPECIFIED

Unspecified

 

FORCE_CONNECTOR_ON

On

 

FORCE_CONNECTOR_DIGITAL

Digital

 

FORCE_CONNECTOR_OFF

Off

 

enum intel_broadcast_rgb_mode

Members

BROADCAST_RGB_AUTO

Choose the color range to use automatically

 

BROADCAST_RGB_FULL

Force the connector to use full color range

 

BROADCAST_RGB_16_235

Force the connector to use a limited 16:235 color range

 

enum igt_commit_style

Members

COMMIT_LEGACY

Changes will be committed using the legacy API.

 

COMMIT_UNIVERSAL

Changes will be committed with the universal plane API, no modesets are allowed.

 

COMMIT_ATOMIC

Changes will be committed using the atomic API.

 

enum igt_atomic_plane_properties

Members

IGT_PLANE_SRC_X

   

IGT_PLANE_SRC_Y

   

IGT_PLANE_SRC_W

   

IGT_PLANE_SRC_H

   

IGT_PLANE_CRTC_X

   

IGT_PLANE_CRTC_Y

   

IGT_PLANE_CRTC_W

   

IGT_PLANE_CRTC_H

   

IGT_PLANE_FB_ID

   

IGT_PLANE_CRTC_ID

   

IGT_PLANE_IN_FENCE_FD

   

IGT_PLANE_TYPE

   

IGT_PLANE_ROTATION

   

IGT_PLANE_IN_FORMATS

   

IGT_PLANE_COLOR_ENCODING

   

IGT_PLANE_COLOR_RANGE

   

IGT_PLANE_PIXEL_BLEND_MODE

   

IGT_PLANE_ALPHA

   

IGT_NUM_PLANE_PROPS

   

igt_display_t

typedef struct igt_display igt_display_t;

igt_pipe_t

typedef struct igt_pipe igt_pipe_t;

igt_fixed_t

typedef uint32_t igt_fixed_t;			/* 16.16 fixed point */

enum igt_rotation_t

Members

IGT_ROTATION_0

   

IGT_ROTATION_90

   

IGT_ROTATION_180

   

IGT_ROTATION_270

   

IGT_REFLECT_X

   

IGT_REFLECT_Y

   

IGT_ROTATION_MASK

#define             IGT_ROTATION_MASK

igt_plane_t

typedef struct {
} igt_plane_t;

struct igt_pipe

struct igt_pipe {
	igt_display_t *display;
	enum pipe pipe;

	int n_planes;
	int plane_cursor;
	int plane_primary;
	igt_plane_t *planes;

	uint64_t changed;
	uint32_t props[IGT_NUM_CRTC_PROPS];
	uint64_t values[IGT_NUM_CRTC_PROPS];

	uint32_t crtc_id;

	int32_t out_fence_fd;
};

igt_output_t

typedef struct {
} igt_output_t;

struct igt_display

struct igt_display {
	int drm_fd;
	int log_shift;
	int n_pipes;
	int n_outputs;
	igt_output_t *outputs;
	igt_pipe_t *pipes;
	bool has_cursor_plane;
	bool is_atomic;
	bool first_commit;

	uint64_t *modifiers;
	uint32_t *formats;
	int format_mod_count;
};

EDID_LENGTH

#define EDID_LENGTH 128