[PATCH i-g-t 1/2] lib/igt_kms: New helper to check force joiner status

Bhanuprakash Modem bhanuprakash.modem at intel.com
Wed Apr 17 12:33:18 UTC 2024


Add a new static function to check the force joiner status
on selected connecter, so that it would be helpful to check
the force joiner status from other places too.

Cc: Kunal Joshi <kunal1.joshi at intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 lib/igt_kms.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 3216fe7e4..9ff80378d 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -6255,6 +6255,22 @@ bool igt_has_force_joiner_debugfs(int drmfd, igt_output_t *output)
 	return ret >= 0;
 }
 
+static bool check_force_bigjoiner_status(int drmfd, char *connector_name, bool enable)
+{
+	int debugfs_fd, ret;
+	char buf[512];
+
+	debugfs_fd = igt_debugfs_connector_dir(drmfd, connector_name, O_DIRECTORY);
+	igt_assert_f(debugfs_fd >= 0, "Could not open debugfs for connector %s\n", connector_name);
+
+	ret = igt_debugfs_simple_read(debugfs_fd, "i915_bigjoiner_force_enable", buf, sizeof(buf));
+	close(debugfs_fd);
+	igt_assert_f(ret > 0, "Could not read i915_bigjoiner_force_enable for connector %s\n", connector_name);
+
+	return enable ? strstr(buf, "Y") :
+			strstr(buf, "N");
+}
+
 /**
  * Forces the enable/disable state of big joiner for a specific connector.
  *
@@ -6268,19 +6284,15 @@ bool igt_has_force_joiner_debugfs(int drmfd, igt_output_t *output)
 bool igt_force_and_check_bigjoiner_status(int drmfd, char *connector_name, bool enable)
 {
 	int debugfs_fd, ret;
-	char buf[512];
 
 	igt_assert_f(connector_name, "Connector name cannot be NULL\n");
 	debugfs_fd = igt_debugfs_connector_dir(drmfd, connector_name, O_DIRECTORY);
 	igt_assert_f(debugfs_fd >= 0, "Could not open debugfs for connector %s\n", connector_name);
 	ret = igt_sysfs_write(debugfs_fd, "i915_bigjoiner_force_enable", enable ? "1" : "0", 1);
 	igt_assert_f(ret > 0, "Could not write i915_bigjoiner_force_enable for connector %s\n", connector_name);
-	ret = igt_debugfs_simple_read(debugfs_fd, "i915_bigjoiner_force_enable", buf, sizeof(buf));
 	close(debugfs_fd);
-	igt_assert_f(ret > 0, "Could not read i915_bigjoiner_force_enable for connector %s\n", connector_name);
 
-	return enable ? strstr(buf, "Y") :
-			strstr(buf, "N");
+	return check_force_bigjoiner_status(drmfd, connector_name, enable);
 }
 
 /**
-- 
2.43.2



More information about the igt-dev mailing list