[Intel-gfx] [PATCH] tests/pm_rpm: add cursor subtests
Paulo Zanoni
przanoni at gmail.com
Wed Jul 23 23:31:00 CEST 2014
From: Paulo Zanoni <paulo.r.zanoni at intel.com>
These tests currently trigger WARNs on our Kernel. Let's make sure we
fix the bugs and they never come back.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni at intel.com>
---
tests/pm_rpm.c | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++------
1 file changed, 101 insertions(+), 10 deletions(-)
diff --git a/tests/pm_rpm.c b/tests/pm_rpm.c
index 869e6f3..10ac6cc 100644
--- a/tests/pm_rpm.c
+++ b/tests/pm_rpm.c
@@ -277,13 +277,15 @@ static uint32_t get_fb(struct mode_set_data *data, int width, int height)
igt_assert(false);
}
-static bool enable_one_screen_with_type(struct mode_set_data *data,
- enum screen_type type)
+static bool find_connector_for_modeset(struct mode_set_data *data,
+ enum screen_type type,
+ uint32_t *connector_id,
+ drmModeModeInfoPtr *mode)
{
- uint32_t crtc_id = 0, buffer_id = 0, connector_id = 0;
- drmModeModeInfoPtr mode = NULL;
- int i, rc;
+ int i;
+ *connector_id = 0;
+ *mode = NULL;
for (i = 0; i < data->res->count_connectors; i++) {
drmModeConnectorPtr c = data->connectors[i];
@@ -296,13 +298,23 @@ static bool enable_one_screen_with_type(struct mode_set_data *data,
continue;
if (c->connection == DRM_MODE_CONNECTED && c->count_modes) {
- connector_id = c->connector_id;
- mode = &c->modes[0];
+ *connector_id = c->connector_id;
+ *mode = &c->modes[0];
break;
}
}
- if (connector_id == 0)
+ return (*connector_id != 0);
+}
+
+static bool enable_one_screen_with_type(struct mode_set_data *data,
+ enum screen_type type)
+{
+ uint32_t crtc_id = 0, buffer_id = 0, connector_id;
+ drmModeModeInfoPtr mode;
+ int rc;
+
+ if (!find_connector_for_modeset(data, type, &connector_id, &mode))
return false;
crtc_id = data->res->crtcs[0];
@@ -310,8 +322,6 @@ static bool enable_one_screen_with_type(struct mode_set_data *data,
igt_assert(crtc_id);
igt_assert(buffer_id);
- igt_assert(connector_id);
- igt_assert(mode);
rc = drmModeSetCrtc(drm_fd, crtc_id, buffer_id, 0, 0, &connector_id,
1, mode);
@@ -1407,6 +1417,81 @@ static void dpms_mode_unset_subtest(enum screen_type type)
igt_assert(wait_for_suspended());
}
+static void fill_igt_fb(struct igt_fb *fb, uint32_t color)
+{
+ int i;
+ uint32_t *ptr;
+
+ ptr = gem_mmap__cpu(drm_fd, fb->gem_handle, fb->size, 0);
+ for (i = 0; i < fb->size/sizeof(uint32_t); i++)
+ ptr[i] = color;
+ igt_assert(munmap(ptr, fb->size) == 0);
+}
+
+/* At some point, this test triggered WARNs in the Kernel. */
+static void cursor_subtest(bool dpms)
+{
+ uint32_t crtc_id = 0, connector_id;
+ drmModeModeInfoPtr mode;
+ int rc;
+ struct igt_fb scanout_fb, cursor_fb1, cursor_fb2;
+
+ disable_all_screens(&ms_data);
+ igt_assert(wait_for_suspended());
+
+ igt_require(find_connector_for_modeset(&ms_data, SCREEN_TYPE_ANY,
+ &connector_id, &mode));
+
+ crtc_id = ms_data.res->crtcs[0];
+ igt_assert(crtc_id);
+
+ igt_create_fb(drm_fd, mode->hdisplay, mode->vdisplay,
+ DRM_FORMAT_XRGB8888, false, &scanout_fb);
+ igt_create_fb(drm_fd, 64, 64, DRM_FORMAT_ARGB8888, false, &cursor_fb1);
+ igt_create_fb(drm_fd, 64, 64, DRM_FORMAT_ARGB8888, false, &cursor_fb2);
+
+ fill_igt_fb(&scanout_fb, 0xFF);
+ fill_igt_fb(&cursor_fb1, 0xFF00FFFF);
+ fill_igt_fb(&cursor_fb2, 0xFF00FF00);
+
+ rc = drmModeSetCrtc(drm_fd, crtc_id, scanout_fb.fb_id, 0, 0,
+ &connector_id, 1, mode);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_active());
+
+ rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb1.gem_handle, 64, 64);
+ igt_assert(rc == 0);
+ rc = drmModeMoveCursor(drm_fd, crtc_id, 0, 0);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_active());
+
+ if (dpms)
+ disable_all_screens_dpms(&ms_data);
+ else
+ disable_all_screens(&ms_data);
+ igt_assert(wait_for_suspended());
+
+ rc = drmModeMoveCursor(drm_fd, crtc_id, 1, 1);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_suspended());
+
+ rc = drmModeSetCursor(drm_fd, crtc_id, 0, 0, 0);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_suspended());
+
+ rc = drmModeSetCursor(drm_fd, crtc_id, cursor_fb2.gem_handle, 64, 64);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_suspended());
+
+ rc = drmModeMoveCursor(drm_fd, crtc_id, 2, 2);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_suspended());
+
+ rc = drmModeSetCursor(drm_fd, crtc_id, 0, 0, 0);
+ igt_assert(rc == 0);
+ igt_assert(wait_for_suspended());
+}
+
int rounds = 50;
bool stay = false;
@@ -1480,6 +1565,12 @@ int main(int argc, char *argv[])
igt_subtest("gem-idle")
gem_idle_subtest();
+ /* Planes and cursors */
+ igt_subtest("cursor")
+ cursor_subtest(false);
+ igt_subtest("cursor-dpms")
+ cursor_subtest(true);
+
/* Misc */
igt_subtest("reg-read-ioctl")
reg_read_ioctl_subtest();
--
2.0.1
More information about the Intel-gfx
mailing list