From: Kunal Joshi <kunal1.joshi@intel.com>
To: igt-dev@lists.freedesktop.org
Cc: "Kunal Joshi" <kunal1.joshi@intel.com>,
"Ville Syrjälä" <ville.syrjala@linux.intel.com>,
"Ankit Nautiyal" <ankit.k.nautiyal@intel.com>,
"Bhanuprakash Modem" <bhanuprakash.modem@intel.com>,
"Karthik B S" <karthik.b.s@intel.com>
Subject: [PATCH i-g-t 7/9] lib/igt_kms: add kmstest_force_connector_debugfs
Date: Wed, 10 Apr 2024 12:14:24 +0530 [thread overview]
Message-ID: <20240410064426.1968399-8-kunal1.joshi@intel.com> (raw)
In-Reply-To: <20240410064426.1968399-1-kunal1.joshi@intel.com>
allow to set debugfs for a connector with particular value and install
exit handler for cleanup.
This is same kmstest_force_connector just that one uses sysfs and
limited to only status sysfs.
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Cc: Bhanuprakash Modem <bhanuprakash.modem@intel.com>
Cc: Karthik B S <karthik.b.s@intel.com>
Signed-off-by: Kunal Joshi <kunal1.joshi@intel.com>
---
lib/igt_kms.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 2 ++
2 files changed, 82 insertions(+)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 80070d935..56c9dae9b 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -1600,6 +1600,52 @@ static bool force_connector(int drm_fd,
return true;
}
+static bool force_connector_debugfs(int drm_fd,
+ drmModeConnector *connector,
+ const char *attr, const char *value)
+{
+ char name[80];
+ int i, idx, dir;
+
+ if (!connector)
+ return false;
+
+ snprintf(name, sizeof(name), "%s-%d",
+ kmstest_connector_type_str(connector->connector_type),
+ connector->connector_type_id);
+
+ dir = igt_debugfs_connector_dir(drm_fd, name, O_DIRECTORY);
+ if (dir < 0)
+ return false;
+
+ if (!igt_sysfs_set(dir, attr, value)) {
+ close(dir);
+ return false;
+ }
+
+ igt_debug("Debugfs %s of Connector %s is now forced %s\n", attr, name, value);
+
+ /* already tracked? */
+ if (connector_is_forced(idx, connector, FORCED_CONNECTOR_DEBUGFS)) {
+ close(dir);
+ return true;
+ }
+
+ i = forced_connector_free_index(FORCED_CONNECTOR_DEBUGFS);
+ if (i < 0) {
+ igt_warn("Connector limit reached, %s will not be reset\n", name);
+ close(dir);
+ return true;
+ }
+
+ forced_connectors_debugfs[i].idx = idx;
+ forced_connectors_debugfs[i].connector_type = connector->connector_type;
+ forced_connectors_debugfs[i].connector_type_id = connector->connector_type_id;
+ forced_connectors_debugfs[i].dir = dir;
+
+ return true;
+}
+
static void dump_forced_connectors(enum kmstest_force_type type)
{
char name[80];
@@ -1674,6 +1720,40 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
return true;
}
+/**
+ * kmstest_force_connector_debugfs:
+ * @fd: drm file descriptor
+ * @connector: connector
+ * @attr: debugfs of the connector
+ * @value: value to set
+ *
+ * Force the specified state on the specified connector.
+ *
+ * Returns: True on success
+ */
+bool kmstest_force_connector_debugfs(int drm_fd, drmModeConnector *connector,
+ enum kmstest_force_debugfs debugfs, const char *value)
+{
+ drmModeConnector *temp;
+ const char *attr = get_debugfs_default_attr(debugfs);
+
+ if (!force_connector_debugfs(drm_fd, connector, attr, value))
+ return false;
+
+ dump_forced_connectors(FORCED_CONNECTOR_DEBUGFS);
+
+ igt_install_exit_handler(reset_connectors_debugfs_at_exit);
+
+ /*
+ * To allow callers to always use GetConnectorCurrent we need to force a
+ * redetection here.
+ */
+ temp = drmModeGetConnector(drm_fd, connector->connector_id);
+ drmModeFreeConnector(temp);
+
+ return true;
+}
+
/**
* kmstest_force_edid:
* @drm_fd: drm file descriptor
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index f676de737..4980d4791 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -283,6 +283,8 @@ struct edid;
bool kmstest_force_connector(int fd, drmModeConnector *connector,
enum kmstest_force_connector_state state);
+bool kmstest_force_connector_debugfs(int drm_fd, drmModeConnector *connector,
+ enum kmstest_force_debugfs debugfs, const char *value);
void kmstest_force_edid(int drm_fd, drmModeConnector *connector,
const struct edid *edid);
--
2.34.1
next prev parent reply other threads:[~2024-04-10 6:34 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 6:44 [PATCH i-g-t 0/9] enhancements for forcing debugfs of connector Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 1/9] lib/igt_kms: Refacror forced_connector struct Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 2/9] lib/igt_kms: add forced_connectors_debugfs array Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 3/9] lib/igt_kms: add enum kmstest_force_type Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 4/9] lib/igt_kms: refactor helpers forced_connectors helpers Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 5/9] lib/igt_kms: add igt_reset_connectors_debugfs Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 6/9] lib/igt_kms: add exit handler function to clear force debugfs state Kunal Joshi
2024-04-10 6:44 ` Kunal Joshi [this message]
2024-04-10 6:44 ` [PATCH i-g-t 8/9] tests/intel/km_big_joiner: use kmstest_force_connector_debugfs for better cleanup functionality Kunal Joshi
2024-04-10 6:44 ` [PATCH i-g-t 9/9] lib/igt_kms: remove unused igt_force_and_check_bigjoiner_status Kunal Joshi
2024-04-10 6:54 ` ✗ GitLab.Pipeline: warning for enhancements for forcing debugfs of connector Patchwork
2024-04-10 7:20 ` ✓ CI.xeBAT: success " Patchwork
2024-04-10 7:26 ` ✗ Fi.CI.BAT: failure " Patchwork
2024-04-10 15:03 ` [PATCH i-g-t 0/9] " Ville Syrjälä
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=20240410064426.1968399-8-kunal1.joshi@intel.com \
--to=kunal1.joshi@intel.com \
--cc=ankit.k.nautiyal@intel.com \
--cc=bhanuprakash.modem@intel.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=karthik.b.s@intel.com \
--cc=ville.syrjala@linux.intel.com \
/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