summaryrefslogtreecommitdiff
path: root/tests/kms_cursor_crc.c
diff options
context:
space:
mode:
authorMatt Roper <matthew.d.roper@intel.com>2015-10-15 16:54:32 -0700
committerThomas Wood <thomas.wood@intel.com>2015-10-16 15:35:28 +0100
commitcd99ddead3815aacaa483f27548a3f5e1a7d9353 (patch)
tree8b0c17866baf9cade125c67e78b19599745b9495 /tests/kms_cursor_crc.c
parente3ac13e16a4a1311e8e73f242e878d74c2063341 (diff)
kms_cursor_crc: Add test for unthrottled cursor movement
We've had bugs in the past that caused cursor updates to be synced to vblank, resulting in sluggish cursor movement. Add a test to try to make sure we don't regress and reintroduce these bugs. Cc: kalyan.kondapally@intel.com Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Diffstat (limited to 'tests/kms_cursor_crc.c')
-rw-r--r--tests/kms_cursor_crc.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/tests/kms_cursor_crc.c b/tests/kms_cursor_crc.c
index 3495b26d..d1de4501 100644
--- a/tests/kms_cursor_crc.c
+++ b/tests/kms_cursor_crc.c
@@ -55,6 +55,7 @@ typedef struct {
igt_crc_t ref_crc;
int left, right, top, bottom;
int screenw, screenh;
+ int refresh;
int curw, curh; /* cursor size */
int cursor_max_w, cursor_max_h;
igt_pipe_crc_t *pipe_crc;
@@ -327,6 +328,7 @@ static bool prepare_crtc(data_t *data, igt_output_t *output,
data->screenh = mode->vdisplay;
data->curw = cursor_w;
data->curh = cursor_h;
+ data->refresh = mode->vrefresh;
/* make sure cursor is disabled */
cursor_disable(data);
@@ -479,6 +481,42 @@ static void test_cursor_size(data_t *data)
}
}
+static void test_rapid_movement(data_t *data)
+{
+ struct timeval start, end, delta;
+ int x = 0, y = 0;
+ long usec;
+ int crtc_id = data->output->config.crtc->crtc_id;
+
+ igt_assert_eq(drmModeSetCursor(data->drm_fd, crtc_id,
+ data->fb.gem_handle, data->curw, data->curh), 0);
+
+ gettimeofday(&start, NULL);
+ for ( ; x < 100; x++)
+ igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
+ for ( ; y < 100; y++)
+ igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
+ for ( ; x > 0; x--)
+ igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
+ for ( ; y > 0; y--)
+ igt_assert_eq(drmModeMoveCursor(data->drm_fd, crtc_id, x, y), 0);
+ gettimeofday(&end, NULL);
+
+ /*
+ * We've done 400 cursor updates now. If we're being throttled to
+ * vblank, then that would take roughly 400/refresh seconds. If the
+ * elapsed time is greater than 90% of that value, we'll consider it
+ * a failure (since cursor updates shouldn't be throttled).
+ */
+ timersub(&end, &start, &delta);
+ usec = delta.tv_usec + 1000000 * delta.tv_sec;
+ igt_assert_lt(usec, 0.9 * 400 * 1000000 / data->refresh);
+
+ igt_assert_eq(drmModeSetCursor(data->drm_fd, crtc_id,
+ 0, data->curw, data->curh), 0);
+
+}
+
static void run_test_generic(data_t *data)
{
int cursor_size;
@@ -510,6 +548,10 @@ static void run_test_generic(data_t *data)
data->flags = 0;
}
+ igt_subtest_f("cursor-%dx%d-rapid-movement", w, h) {
+ run_test(data, test_rapid_movement, w, h);
+ }
+
igt_fixture
igt_remove_fb(data->drm_fd, &data->fb);