From: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Subject: [i-g-t V2 2/5] lib/drrs: Add support to force drrs to default on exit
Date: Tue, 24 Sep 2024 19:56:35 +0530 [thread overview]
Message-ID: <20240924142638.238291-3-bhanuprakash.modem@intel.com> (raw)
In-Reply-To: <20240924142638.238291-1-bhanuprakash.modem@intel.com>
Use existing exit handler helpers to reset the drrs status
to default on exit.
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
---
lib/i915/intel_drrs.c | 41 ++++++++++++++++++++++-------------------
lib/igt_kms.c | 20 ++++++++++++++++++++
lib/igt_kms.h | 3 +++
3 files changed, 45 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();
}
/**
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index c22cdb602..d7f6e475e 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1912,6 +1912,26 @@ static bool crtc_attr_set_debugfs(int drm_fd, enum pipe pipe,
return true;
}
+/**
+ * igt_set_crtc_attrs:
+ * @drm_fd: drm file descriptor
+ * @pipe: pipe
+ * @attr: attribute to set
+ * @value: value to set
+ * @reset_value: value to reset to
+ *
+ * Set the attribute @attr to @value on the crtc-@pipe.
+ *
+ * @return: true on success
+ */
+bool igt_set_crtc_attrs(int drm_fd, enum pipe pipe,
+ const char *attr, const char *value,
+ const char *reset_value)
+{
+ return crtc_attr_set_debugfs(drm_fd, pipe, attr, value, reset_value);
+
+}
+
/**
* kmstest_set_connector_dpms:
*
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 97efbefa5..67635d89a 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -1085,6 +1085,9 @@ void igt_pipe_refresh(igt_display_t *display, enum pipe pipe, bool force);
void igt_enable_connectors(int drm_fd);
void igt_reset_connectors(void);
+bool igt_set_crtc_attrs(int drm_fd, enum pipe pipe,
+ const char *attr, const char *value,
+ const char *reset_value);
void igt_reset_crtcs(void);
void dump_crtc_attrs(void);
--
2.43.0
next prev parent reply other threads:[~2024-09-24 14:36 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-24 14:26 [i-g-t V2 0/5] Force connector/crtc attrs to default Bhanuprakash Modem
2024-09-24 14:26 ` [i-g-t V2 1/5] lib/igt_kms: Add infra to handle crtc arbitrary attributes Bhanuprakash Modem
2024-11-15 17:20 ` Kamil Konieczny
2024-11-18 9:48 ` Modem, Bhanuprakash
2024-09-24 14:26 ` Bhanuprakash Modem [this message]
2024-09-24 14:26 ` [i-g-t V2 3/5] lib/dsc: Reset DSC bpc to default on exit Bhanuprakash Modem
2024-09-24 14:26 ` [i-g-t V2 4/5] lib/igt_kms: Force "edid_override" to NULL " Bhanuprakash Modem
2024-09-24 14:26 ` [i-g-t V2 5/5] lib/igt_kms: Reset spurious hpd to default " Bhanuprakash Modem
2024-09-26 3:53 ` ✗ Fi.CI.BAT: failure for Force connector/crtc attrs to default (rev2) Patchwork
2024-09-26 4:06 ` ✗ CI.xeBAT: " Patchwork
2024-09-26 13:35 ` ✗ CI.xeFULL: " Patchwork
2024-11-14 9:38 ` ✓ CI.xeBAT: success for Force connector/crtc attrs to default (rev3) Patchwork
2024-11-14 9:47 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-11-14 18:50 ` ✗ CI.xeFULL: " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240924142638.238291-3-bhanuprakash.modem@intel.com \
--to=bhanuprakash.modem@intel.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox