[PATCH i-g-t v7 01/48] lib/igt_kms: Add a detect timeout value

Louis Chauvet
2026-02-23T12:08:49Z

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@bootlin.com>
---
lib/igt_core.c | 33 +++++++++++++++++++++++++++++++++
lib/igt_core.h | 9 +++++++++
lib/igt_kms.c | 1 +
3 files changed, 43 insertions(+)

diff --git a/lib/igt_core.c b/lib/igt_core.c
index 3ee670a41a91..e8f31d573512 100644
--- a/lib/igt_core.c
+++ b/lib/igt_core.c
@@ -26,6 +26,7 @@
*
*/

+#include "igt_kms.h"
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
#endif
@@ -271,6 +272,10 @@
* &num; It is not mandatory and allows overriding default values.
* [DUT]
* SuspendResumeDelay=10
+ *
+ * &num; The following option define the timeout (in seconds) for detection feature
+ * &num; (waiting for a connector status)
+ * DisplayDetectTimeout=10.0
* ]|
*
* Some specific configuration options may be used by specific parts of IGT,
@@ -379,6 +384,21 @@ static bool stderr_needs_sentinel = false;

static int _igt_dynamic_tests_executed = -1;

+/**
+ * default_display_detect_timeout: Timeout for display detection, in seconds
+ */
+static double default_display_detect_timeout;
+
+static void igt_set_default_display_detect_timeout(double timeout)
+{
+ default_display_detect_timeout = timeout;
+}
+
+double igt_default_display_detect_timeout(void)
+{
+ return default_display_detect_timeout;
+}
+
static void print_backtrace(void)
{
#ifndef HAVE_LIBUNWIND
@@ -1003,6 +1023,7 @@ static void common_init_config(void)
{
GError *error = NULL;
int ret = 0;
+ static double timeout = 0.0;

igt_key_file = igt_load_igtrc();

@@ -1023,6 +1044,18 @@ static void common_init_config(void)
if (ret != 0)
igt_set_autoresume_delay(ret);

+ 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;
+ }
+ g_clear_error(&error);
+ igt_set_default_display_detect_timeout(timeout);
+
/* Adding filters, order .igtrc, IGT_DEVICE, --device filter */
if (igt_device_filter_count() > 0)
igt_debug("Notice: using --device filters:\n");
diff --git a/lib/igt_core.h b/lib/igt_core.h
index 6845f853c980..daf83cb5380d 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -143,6 +143,13 @@ struct _GKeyFile *igt_load_igtrc(void);
*/
#define IGT_EXIT_ABORT 112

+/**
+ * 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
void __igt_assert_in_outer_scope(void);

bool __igt_fixture(void);
@@ -446,6 +453,8 @@ void __igt_subtest_group_restore(int, int);
*/
#define igt_main() igt_main_args(NULL, NULL, NULL, NULL, NULL)

+double igt_default_display_detect_timeout(void);
+
const char *igt_test_name(void);
void igt_simple_init_parse_opts(int *argc, char **argv,
const char *extra_short_opts,
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 5c48796040a2..65e657cffda7 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -60,6 +60,7 @@
#include "igt_debugfs.h"
#include "igt_device.h"
#include "igt_pipe_crc.h"
+#include "igt_rc.h"
#include "igt_sysfs.h"
#include "sw_sync.h"
#ifdef HAVE_CHAMELIUM

--
2.52.0