[i-g-t V3 2/4] lib/drrs: Add support to force drrs to default on exit
Bhanuprakash Modem
bhanuprakash.modem at intel.com
Mon Nov 18 09:59:46 UTC 2024
Use existing exit handler helpers to reset the drrs status
to default on exit.
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
lib/i915/intel_drrs.c | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/lib/i915/intel_drrs.c b/lib/i915/intel_drrs.c
index ac8dd5e61..0d1f9cbad 100644
--- a/lib/i915/intel_drrs.c
+++ b/lib/i915/intel_drrs.c
@@ -56,26 +56,18 @@ bool intel_output_has_drrs(int device, igt_output_t *output)
return strstr(buf, "seamless");
}
-static void drrs_set(int device, enum pipe pipe, unsigned int val)
+static void reset_crtc_drrs_at_exit(int sig)
{
- char buf[2];
- int dir, ret;
-
- igt_debug("Manually %sabling DRRS. %u\n", val ? "en" : "dis", val);
- snprintf(buf, sizeof(buf), "%d", val);
+ igt_reset_crtcs();
+}
- dir = igt_debugfs_pipe_dir(device, pipe, O_DIRECTORY);
- igt_require_fd(dir);
- ret = igt_sysfs_write(dir, "i915_drrs_ctl", buf, sizeof(buf) - 1);
- close(dir);
+static bool drrs_set(int device, enum pipe pipe, const char *val)
+{
+ igt_debug("Manually %sabling DRRS.\n", !strcmp(val, "1") ? "en" : "dis");
- /*
- * 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().
- */
- if (val)
- igt_assert_f(ret == (sizeof(buf) - 1), "debugfs_write failed");
+ return igt_set_crtc_attrs(device, pipe,
+ "i915_drrs_ctl",
+ val, "0");
}
/**
@@ -90,7 +82,17 @@ static void drrs_set(int device, enum pipe pipe, unsigned int val)
*/
void intel_drrs_enable(int device, enum pipe pipe)
{
- drrs_set(device, pipe, 1);
+ bool ret = drrs_set(device, pipe, "1");
+
+ /*
+ * 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().
+ */
+ igt_assert_f(ret == 1, "debugfs_write failed");
+
+ dump_crtc_attrs();
+ igt_install_exit_handler(reset_crtc_drrs_at_exit);
}
/**
@@ -105,7 +107,8 @@ void intel_drrs_enable(int device, enum pipe pipe)
*/
void intel_drrs_disable(int device, enum pipe pipe)
{
- drrs_set(device, pipe, 0);
+ drrs_set(device, pipe, "0");
+ dump_crtc_attrs();
}
/**
--
2.43.0
More information about the igt-dev
mailing list