Commit 4d092021 authored by Mika Kahola's avatar Mika Kahola

tests: Move wait_for_pageflip as library function

Two tests uses the very same wait_for_pageflip() routine. These tests are
'kms_rotation_crc' and 'kms_flip_tiling'. In order to decrease code
repetition, let's move this function as part of kms function collection
in igt_kms.

No functional changes.
Signed-off-by: default avatarMika Kahola <mika.kahola@intel.com>
Reviewed-by: Ville Syrjälä's avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent 71c7a574
......@@ -1458,6 +1458,30 @@ unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags)
return vbl.reply.sequence;
}
/**
* kmstest_wait_for_pageflip:
* @fd: Opened drm file descriptor
*
* Blocks until pageflip is completed
*
*/
void kmstest_wait_for_pageflip(int fd)
{
drmEventContext evctx = { .version = 2 };
struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
fd_set fds;
int ret;
/* Wait for pageflip completion, then consume event on fd */
FD_ZERO(&fds);
FD_SET(fd, &fds);
do {
ret = select(fd + 1, &fds, NULL, NULL, &timeout);
} while (ret < 0 && errno == EINTR);
igt_assert_eq(ret, 1);
igt_assert(drmHandleEvent(fd, &evctx) == 0);
}
static void get_plane(char *str, int type, struct kmstest_plane *plane)
{
int ret;
......
......@@ -222,6 +222,7 @@ uint32_t kmstest_dumb_create(int fd, int width, int height, int bpp,
void *kmstest_dumb_map_buffer(int fd, uint32_t handle, uint64_t size,
unsigned prot);
void kmstest_wait_for_pageflip(int fd);
unsigned int kmstest_get_vblank(int fd, int pipe, unsigned int flags);
void igt_assert_plane_visible(int fd, enum pipe pipe, bool visibility);
......
......@@ -30,7 +30,6 @@
#include <stdio.h>
#include <string.h>
IGT_TEST_DESCRIPTION("Test page flips and tiling scenarios");
typedef struct {
......@@ -62,23 +61,6 @@ static void pipe_crc_free(void)
}
}
static void wait_for_pageflip(int fd)
{
drmEventContext evctx = { .version = 2 };
struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
fd_set fds;
int ret;
/* Wait for pageflip completion, then consume event on fd */
FD_ZERO(&fds);
FD_SET(fd, &fds);
do {
ret = select(fd + 1, &fds, NULL, NULL, &timeout);
} while (ret < 0 && errno == EINTR);
igt_assert_eq(ret, 1);
igt_assert(drmHandleEvent(fd, &evctx) == 0);
}
static void
test_flip_tiling(data_t *data, enum pipe pipe, igt_output_t *output, uint64_t tiling[2])
{
......@@ -139,7 +121,7 @@ test_flip_tiling(data_t *data, enum pipe pipe, igt_output_t *output, uint64_t ti
*/
igt_require(ret == 0);
wait_for_pageflip(data->drm_fd);
kmstest_wait_for_pageflip(data->drm_fd);
/* Get a crc and compare with the reference. */
igt_pipe_crc_collect_crc(pipe_crc, &crc);
......
......@@ -284,23 +284,6 @@ static void prepare_fbs(data_t *data, igt_output_t *output,
igt_plane_set_position(plane, data->pos_x, data->pos_y);
}
static void wait_for_pageflip(int fd)
{
drmEventContext evctx = { .version = 2 };
struct timeval timeout = { .tv_sec = 0, .tv_usec = 50000 };
fd_set fds;
int ret;
/* Wait for pageflip completion, then consume event on fd */
FD_ZERO(&fds);
FD_SET(fd, &fds);
do {
ret = select(fd + 1, &fds, NULL, NULL, &timeout);
} while (ret < 0 && errno == EINTR);
igt_assert_eq(ret, 1);
igt_assert(drmHandleEvent(fd, &evctx) == 0);
}
static void test_single_case(data_t *data, enum pipe pipe,
igt_output_t *output, igt_plane_t *plane,
enum rectangle_type rect,
......@@ -350,7 +333,7 @@ static void test_single_case(data_t *data, enum pipe pipe,
NULL);
igt_assert_eq(ret, 0);
}
wait_for_pageflip(data->gfx_fd);
kmstest_wait_for_pageflip(data->gfx_fd);
igt_pipe_crc_drain(data->pipe_crc);
igt_pipe_crc_get_single(data->pipe_crc, &crc_output);
igt_assert_crc_equal(&data->flip_crc,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment