[PATCH i-g-t v2 1/5] lib/igt_kms: Add a detect timeout value

Louis Chauvet louis.chauvet at bootlin.com
Tue Oct 22 10:28:35 UTC 2024


Some tests need to wait for a specific connector status. In order to make
the timeout customisable for each target, add an option in the
configuration file.

Signed-off-by: Louis Chauvet <louis.chauvet at bootlin.com>
---
 lib/igt_core.c |  3 +++
 lib/igt_kms.c  | 24 ++++++++++++++++++++++++
 lib/igt_kms.h  |  9 +++++++++
 3 files changed, 36 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 407f7b55187c..5f75141cc42e 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -265,6 +265,9 @@
  *	# It is not mandatory and allows overriding default values.
  *	[DUT]
  *	SuspendResumeDelay=10
+ *	# The following option define the timeout for detection feature
+ *	# (waiting for a connector status)
+ *	DetectTimeout=10.0
  * ]|
  *
  * Some specific configuration options may be used by specific parts of IGT,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index bb35d4b82c5a..195868646a14 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -58,6 +58,7 @@
 #include "intel_chipset.h"
 #include "igt_debugfs.h"
 #include "igt_device.h"
+#include "igt_rc.h"
 #include "igt_sysfs.h"
 #include "sw_sync.h"
 #ifdef HAVE_CHAMELIUM
@@ -7119,3 +7120,26 @@ void igt_reset_link_params(int drm_fd, igt_output_t *output)
 	temp = drmModeGetConnector(drm_fd, output->config.connector->connector_id);
 	drmModeFreeConnector(temp);
 }
+
+/**
+ * igt_default_detect_timeout - Get the default timeout value for detection feature
+ *
+ * Some tests requires to wait for a specific connector status. This value will determine the
+ * timeout value for this waiting.
+ */
+float igt_default_detect_timeout(void)
+{
+	static double timeout = 0.0;
+	static bool first_call = true;
+
+	if (first_call) {
+		if (igt_key_file)
+			timeout = g_key_file_get_double(igt_key_file, "DUT", "DetectTimeout", NULL);
+		else
+			timeout = DEFAULT_DETECT_TIMEOUT;
+
+		first_call = false;
+	}
+
+	return timeout;
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 2b26d2bbfff1..4f0030264d9f 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -39,6 +39,13 @@
 #include "igt_fb.h"
 #include "ioctl_wrappers.h"
 
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout used for some detection functions
+ *
+ * It can be overiden by option DetectTimeout in the .igtrc file.
+ */
+#define DEFAULT_DETECT_TIMEOUT 10.0
+
 /* Low-level helpers with kmstest_ prefix */
 
 /**
@@ -1254,4 +1261,6 @@ int igt_get_dp_pending_lt_failures(int drm_fd, igt_output_t *output);
 int igt_get_dp_pending_retrain(int drm_fd, igt_output_t *output);
 void igt_reset_link_params(int drm_fd, igt_output_t *output);
 
+float igt_default_detect_timeout(void);
+
 #endif /* __IGT_KMS_H__ */

-- 
2.46.2



More information about the igt-dev mailing list