[PATCH i-g-t v4 1/5] lib/igt_kms: Add a detect timeout value
Louis Chauvet
louis.chauvet at bootlin.com
Fri Jan 10 17:42:50 UTC 2025
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 | 4 ++++
lib/igt_kms.c | 35 +++++++++++++++++++++++++++++++++++
lib/igt_kms.h | 10 ++++++++++
3 files changed, 49 insertions(+)
diff --git a/lib/igt_core.c b/lib/igt_core.c
index 407f7b55187ceac4cbc0645c629a7fbb17f89575..796c52b44341c1a40abc87540ca0f65d09ca554f 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -265,6 +265,10 @@
* # 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)
+ * DisplayDetectTimeout=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 76f32e1e0ffd60d9542b43881e73c9810e45327b..b3373435b252c9f8c5d5854f738f7f4bbc468964 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -59,6 +59,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
@@ -7210,3 +7211,37 @@ int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *c
return 0;
}
+
+/**
+ * igt_default_display_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.
+ */
+double igt_default_display_detect_timeout(void)
+{
+ static double timeout = 0.0;
+ static bool first_call = true;
+ GError *error = NULL;
+
+ if (first_call) {
+ if (igt_key_file) {
+ timeout = g_key_file_get_double(igt_key_file, "DUT", "DisplayDetectTimeout",
+ &error);
+ if (error) {
+ igt_debug("Failed to read DisplayDetectTimeout, defaulting to %f\n",
+ DEFAULT_DETECT_TIMEOUT);
+ g_clear_error(&error);
+ timeout = DEFAULT_DETECT_TIMEOUT;
+ }
+ } else {
+ timeout = DEFAULT_DETECT_TIMEOUT;
+ }
+
+ first_call = false;
+ }
+
+ return timeout;
+}
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 301f370dfeb34e90e6f88dfe0006667d7b6a7213..91a26f2070efd26f9d107841ae3083b281d5e4c6 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -40,6 +40,14 @@
#include "igt_fb.h"
#include "ioctl_wrappers.h"
+/**
+ * define DEFAULT_DETECT_TIMEOUT - Default timeout in second used for some screen 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 */
/**
@@ -1269,4 +1277,6 @@ void igt_reset_link_params(int drm_fd, igt_output_t *output);
int igt_backlight_read(int *result, const char *fname, igt_backlight_context_t *context);
int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *context);
+double igt_default_display_detect_timeout(void);
+
#endif /* __IGT_KMS_H__ */
--
2.47.1
More information about the igt-dev
mailing list