Commit d7e1dfbf authored by Dhinakaran Pandiyan's avatar Dhinakaran Pandiyan

tests/psr: Move PSR state test functions to lib

kms_frontbuffer_tracking and kms_psr test PSR in different ways, let'
fix that by creating common library functions.

v2: Include the new file in meson.build
v3: Leave --no-psr intact (Rodrigo)

Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Dhinakaran Pandiyan's avatarDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Reviewed-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
parent 1a020469
......@@ -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
......
/*
* 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);
}
/*
* 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
......@@ -48,6 +48,7 @@ lib_sources = [
'uwildmat/uwildmat.c',
'igt_kmod.c',
'igt_vc4.c',
'igt_psr.c',
]
lib_deps = [
......
......@@ -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);
}
......
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