From b87239e7d8081c90308e78898dbedb3ab9082cd1 Mon Sep 17 00:00:00 2001
From: Jakob Bornecrantz <jakob@collabora.com>
Date: Wed, 14 Dec 2022 12:20:03 +0000
Subject: [PATCH] d/wmr: Increase display init sleep and also add debug
 variable to control it

---
 src/xrt/drivers/wmr/wmr_hmd.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/xrt/drivers/wmr/wmr_hmd.c b/src/xrt/drivers/wmr/wmr_hmd.c
index aacf474d0..d668d0387 100644
--- a/src/xrt/drivers/wmr/wmr_hmd.c
+++ b/src/xrt/drivers/wmr/wmr_hmd.c
@@ -67,6 +67,9 @@
 //! Specifies whether the user wants to use a SLAM tracker.
 DEBUG_GET_ONCE_BOOL_OPTION(wmr_slam, "WMR_SLAM", true)
 
+//! Specifies whether the user wants to use a SLAM tracker.
+DEBUG_GET_ONCE_NUM_OPTION(sleep_seconds, "WMR_DISPLAY_INIT_SLEEP_SECONDS", 4)
+
 //! Specifies whether the user wants to use the hand tracker.
 DEBUG_GET_ONCE_BOOL_OPTION(wmr_handtracking, "WMR_HANDTRACKING", true)
 
@@ -680,8 +683,9 @@ wmr_hmd_activate_reverb(struct wmr_hmd *wh)
 	         "Sleep until the HMD display is powered up so, the available displays can be enumerated by the host "
 	         "system.");
 
-	// Two seconds seems to be needed, 1 was not enough.
-	os_nanosleep(U_TIME_1MS_IN_NS * 2000);
+	// Get the sleep amount, then sleep. One or two seconds was not enough.
+	uint64_t seconds = debug_get_num_option_sleep_seconds();
+	os_nanosleep(U_TIME_1S_IN_NS * seconds);
 
 	return 0;
 }