[igt-dev] [PATCH i-g-t 2/5] tests/kms_frontbuffer_tracking: Rework toggling drrs/fbc/psr.
Maarten Lankhorst
maarten.lankhorst at linux.intel.com
Mon Mar 12 17:30:10 UTC 2018
Add a helper <feature>_set for each function, and allow -1 to restore
the initial value. This is useful for the basic subtest, which is run
near the end.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
---
tests/kms_frontbuffer_tracking.c | 63 +++++++++++++++++++++++++++-------------
1 file changed, 43 insertions(+), 20 deletions(-)
diff --git a/tests/kms_frontbuffer_tracking.c b/tests/kms_frontbuffer_tracking.c
index 19a69cca5b37..746f8d1f8a75 100644
--- a/tests/kms_frontbuffer_tracking.c
+++ b/tests/kms_frontbuffer_tracking.c
@@ -747,7 +747,7 @@ static void __debugfs_read(const char *param, char *buf, int len)
buf[len] = '\0';
}
-static int __debugfs_write(const char *param, char *buf, int len)
+static int __debugfs_write(const char *param, const char *buf, int len)
{
return igt_sysfs_write(drm.debugfs, param, buf, len - 1);
}
@@ -781,24 +781,54 @@ static void psr_print_status(void)
igt_info("PSR status:\n%s\n", buf);
}
-static void drrs_set(unsigned int val)
+static void drrs_set(int val)
{
char buf[2];
int ret;
igt_debug("Manually %sabling DRRS. %u\n", val ? "en" : "dis", val);
- snprintf(buf, sizeof(buf), "%d", val);
+ snprintf(buf, sizeof(buf), "%d", !!val);
ret = debugfs_write("i915_drrs_ctl", buf);
/*
- * drrs_enable() is called on DRRS capable platform only,
- * whereas drrs_disable() is called on all platforms.
- * So handle the failure of debugfs_write only for drrs_enable().
+ * enabling psr is done on DRRS capable platform only,
+ * whereas disabling/default is called on all platforms.
+ * So handle the failure of debugfs_write only when explicitly enabling drrs.
*/
- if (val)
+ if (val > 0)
igt_assert_f(ret == (sizeof(buf) - 1), "debugfs_write failed");
}
+static bool psr_set(int val)
+{
+ int oldval;
+ static int default_psr = -1;
+
+ oldval = igt_get_module_param_int("enable_psr");
+ if (default_psr == -1)
+ default_psr = oldval;
+
+ if (val == -1)
+ val = default_psr;
+
+ igt_set_module_param_int("enable_psr", val);
+
+ return val != oldval;
+}
+
+static void fbc_set(int val)
+{
+ static int default_fbc = -1;
+
+ if (default_fbc == -1)
+ default_fbc = igt_get_module_param_int("enable_fbc");
+
+ if (val == -1)
+ val = default_fbc;
+
+ igt_set_module_param_int("enable_fbc", val);
+}
+
static bool is_drrs_high(void)
{
char buf[MAX_DRRS_STATUS_BUF_LEN];
@@ -963,13 +993,6 @@ static bool drrs_wait_until_rr_switch_to_low(void)
return igt_wait(is_drrs_low(), 5000, 1);
}
-#define fbc_enable() igt_set_module_param_int("enable_fbc", 1)
-#define fbc_disable() igt_set_module_param_int("enable_fbc", 0)
-#define psr_enable() igt_set_module_param_int("enable_psr", 1)
-#define psr_disable() igt_set_module_param_int("enable_psr", 0)
-#define drrs_enable() drrs_set(1)
-#define drrs_disable() drrs_set(0)
-
static void get_sink_crc(sink_crc_t *crc, bool mandatory)
{
int rc, errno_;
@@ -1198,9 +1221,9 @@ static void disable_features(const struct test_mode *t)
if (t->feature == FEATURE_DEFAULT)
return;
- fbc_disable();
- psr_disable();
- drrs_disable();
+ fbc_set(0);
+ psr_set(0);
+ drrs_set(0);
}
static void *busy_thread_func(void *data)
@@ -1830,11 +1853,11 @@ static void enable_features_for_test(const struct test_mode *t)
return;
if (t->feature & FEATURE_FBC)
- fbc_enable();
+ fbc_set(1);
if (t->feature & FEATURE_PSR)
- psr_enable();
+ psr_set(1);
if (t->feature & FEATURE_DRRS)
- drrs_enable();
+ drrs_set(1);
}
static void check_test_requirements(const struct test_mode *t)
--
2.16.2
More information about the igt-dev
mailing list