summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.sources2
-rw-r--r--lib/igt_psr.c40
-rw-r--r--lib/igt_psr.h34
-rw-r--r--lib/meson.build1
-rw-r--r--tests/kms_psr.c37
5 files changed, 90 insertions, 24 deletions
diff --git a/lib/Makefile.sources b/lib/Makefile.sources
index 042c1d3b..14356c94 100644
--- a/lib/Makefile.sources
+++ b/lib/Makefile.sources
@@ -103,6 +103,8 @@ lib_source_list = \
igt_kmod.h \
igt_syncobj.c \
igt_syncobj.h \
+ igt_psr.c \
+ igt_psr.h \
$(NULL)
.PHONY: version.h.tmp
diff --git a/lib/igt_psr.c b/lib/igt_psr.c
new file mode 100644
index 00000000..c979b0b5
--- /dev/null
+++ b/lib/igt_psr.c
@@ -0,0 +1,40 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include "igt_psr.h"
+
+bool psr_active(int fd, bool check_active)
+{
+ bool active;
+ char buf[512];
+
+ igt_debugfs_read(fd, "i915_edp_psr_status", buf);
+ active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
+ (strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
+ return check_active ? active : !active;
+}
+
+bool psr_wait_entry(int fd)
+{
+ return igt_wait(psr_active(fd, true), 500, 1);
+}
diff --git a/lib/igt_psr.h b/lib/igt_psr.h
new file mode 100644
index 00000000..980f85e0
--- /dev/null
+++ b/lib/igt_psr.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright © 2018 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef IGT_PSR_H
+#define IGT_PSR_H
+
+#include "igt_debugfs.h"
+#include "igt_core.h"
+#include "igt_aux.h"
+
+bool psr_wait_entry(int fd);
+bool psr_active(int fd, bool check_active);
+
+#endif
diff --git a/lib/meson.build b/lib/meson.build
index 939167f9..74a5f61e 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -48,6 +48,7 @@ lib_sources = [
'uwildmat/uwildmat.c',
'igt_kmod.c',
'igt_vc4.c',
+ 'igt_psr.c',
]
lib_deps = [
diff --git a/tests/kms_psr.c b/tests/kms_psr.c
index 9e893ed8..218b3960 100644
--- a/tests/kms_psr.c
+++ b/tests/kms_psr.c
@@ -24,6 +24,7 @@
#include "igt.h"
#include "igt_sysfs.h"
+#include "igt_psr.h"
#include <errno.h>
#include <stdbool.h>
#include <stdio.h>
@@ -197,24 +198,12 @@ static bool sink_support(data_t *data)
strstr(buf, "Sink_Support: yes\n");
}
-static bool psr_active(int fd, bool check_active)
-{
- bool active;
- char buf[512];
-
- igt_debugfs_read(fd, "i915_edp_psr_status", buf);
-
- active = strstr(buf, "HW Enabled & Active bit: yes\n") &&
- (strstr(buf, "SRDENT") || strstr(buf, "SLEEP"));
- return check_active ? active : !active;
-}
-
-static bool wait_psr_entry(data_t *data)
+static bool psr_wait_entry_if_enabled(data_t *data)
{
if (data->with_psr_disabled)
return true;
- return igt_wait((psr_active(data->drm_fd, true)), 500, 1);
+ return psr_wait_entry(data->drm_fd);
}
static inline void manual(const char *expected)
@@ -242,7 +231,7 @@ static void run_test(data_t *data)
manual("screen GREEN");
/* Confirm screen stays Green after PSR got active */
- igt_assert(wait_psr_entry(data));
+ igt_assert(psr_wait_entry_if_enabled(data));
manual("screen GREEN");
/* Setting a secondary fb/plane */
@@ -255,7 +244,7 @@ static void run_test(data_t *data)
else
manual("GREEN background with WHITE box");
- igt_assert(wait_psr_entry(data));
+ igt_assert(psr_wait_entry_if_enabled(data));
switch (data->op) {
case PAGE_FLIP:
/* Only in use when testing primary plane */
@@ -437,13 +426,13 @@ int main(int argc, char *argv[])
igt_subtest("basic") {
setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
test_cleanup(&data);
}
igt_subtest("no_drrs") {
setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
igt_assert(drrs_disabled(&data));
test_cleanup(&data);
}
@@ -452,7 +441,7 @@ int main(int argc, char *argv[])
igt_subtest_f("primary_%s", op_str(op)) {
data.op = op;
setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
run_test(&data);
test_cleanup(&data);
}
@@ -462,7 +451,7 @@ int main(int argc, char *argv[])
igt_subtest_f("sprite_%s", op_str(op)) {
data.op = op;
setup_test_plane(&data, DRM_PLANE_TYPE_OVERLAY);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
run_test(&data);
test_cleanup(&data);
}
@@ -472,7 +461,7 @@ int main(int argc, char *argv[])
igt_subtest_f("cursor_%s", op_str(op)) {
data.op = op;
setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
run_test(&data);
test_cleanup(&data);
}
@@ -481,7 +470,7 @@ int main(int argc, char *argv[])
igt_subtest_f("dpms") {
data.op = RENDER;
setup_test_plane(&data, DRM_PLANE_TYPE_PRIMARY);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
dpms_off_on(&data);
run_test(&data);
test_cleanup(&data);
@@ -490,10 +479,10 @@ int main(int argc, char *argv[])
igt_subtest_f("suspend") {
data.op = PLANE_ONOFF;
setup_test_plane(&data, DRM_PLANE_TYPE_CURSOR);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
igt_system_suspend_autoresume(SUSPEND_STATE_MEM,
SUSPEND_TEST_NONE);
- igt_assert(wait_psr_entry(&data));
+ igt_assert(psr_wait_entry_if_enabled(&data));
run_test(&data);
test_cleanup(&data);
}