From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1735BFF886F for ; Tue, 28 Apr 2026 04:47:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BB51310E29C; Tue, 28 Apr 2026 04:47:49 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="RSFG2wLG"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by gabe.freedesktop.org (Postfix) with ESMTPS id 337E010E0EB for ; Tue, 28 Apr 2026 04:47:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1777351623; x=1808887623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=MyRLhQ3yjSDDE9LQNs09ruiNzX2p+q6mJaIbgMjuy8k=; b=RSFG2wLGQBhCYLNLM+BLIALbtmBGz9C22hUU3cYye43s0Jz+GytYp3EZ 9loQE+I1j64EGuphPnxAScRIZIQTcFx4U4FI3v8jOSSNDo8s+twI64jsS VL08yJvPGfbI8YUwlDKx6MLL7+I2KM2hWGt/TYdBBZsT7HjSQvMDaBwk/ Gioo5wWi6HPfGqSDzafEm6W/5m1yXxh5Kot3rJwjTxUYeKn9o00UDaDB+ /ztqjm7zN2C3QM8/poxmvQOAco/i+PuCtRVacPrLOkcRZnzCEq2drVlnH n40/4p3Z8yoYXpG2kmsQLQMP4+6M4+Spiy9yVP06jNCulobxGJkC0hAq7 g==; X-CSE-ConnectionGUID: G0z9WbVcSu+QEz5w0Hegwg== X-CSE-MsgGUID: Iour+kYDSVSjhjBQ6RY8sg== X-IronPort-AV: E=McAfee;i="6800,10657,11769"; a="78167789" X-IronPort-AV: E=Sophos;i="6.23,203,1770624000"; d="scan'208";a="78167789" Received: from orviesa008.jf.intel.com ([10.64.159.148]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2026 21:47:03 -0700 X-CSE-ConnectionGUID: +GVaNzM1TVKrzXkeT2wTiQ== X-CSE-MsgGUID: 6n7nh4mpRHukwFXz6Cy6vQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,203,1770624000"; d="scan'208";a="233706436" Received: from bilal-nuc7i7bnh.iind.intel.com ([10.190.239.45]) by orviesa008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Apr 2026 21:47:01 -0700 From: Mohammed Bilal To: igt-dev@lists.freedesktop.org Cc: kunal1.joshi@intel.com, Louis Chauvet , Kory Maincent , Luca Ceresoli Subject: [PATCH i-g-t v1 02/25] lib/igt_kms: Add helper to wait for a specific status on a connector Date: Tue, 28 Apr 2026 10:16:11 +0530 Message-ID: <20260428044644.257001-3-mohammed.bilal@intel.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20260428044644.257001-1-mohammed.bilal@intel.com> References: <20260428044644.257001-1-mohammed.bilal@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: igt-dev@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development mailing list for IGT GPU Tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: igt-dev-bounces@lists.freedesktop.org Sender: "igt-dev" From: Louis Chauvet During testing with chamelium, it is frequent to wait for a specific connector status. This new helper is polling the DRM API to wait for this status. This allows detecting it without notifier systems which can fail if hot plug detection is not working properly on the device under test. Reviewed-by: Kory Maincent Reviewed-by: Luca Ceresoli Signed-off-by: Louis Chauvet --- lib/igt_kms.c | 39 +++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 3 +++ 2 files changed, 42 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index ece888d1a..25184531b 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -8214,3 +8214,42 @@ double igt_default_display_detect_timeout(void) return timeout; } + +/** + * igt_wait_for_connector_status: + * @drm_fd: drm file descriptor + * @connector_id: connector to monitor + * @timeout: maximum duration to wait, in second. Use -1.0 to set the timeout + * to igt_default_detect_timeout(). + * @drm_mode: mode to wait for, see enum drmModeConnection + * + * Wait for at most @timeout that the connector @connector_id status + * become @drm_mode + * Returns: true when the status is reached, false if there is a timeout + */ +bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout, + int drm_mode) +{ + drmModeConnector *connector; + struct timespec start, end; + + if (timeout == -1.0) + timeout = igt_default_display_detect_timeout(); + + clock_gettime(CLOCK_MONOTONIC, &start); + end = start; + + while (igt_time_elapsed(&start, &end) <= timeout) { + connector = drmModeGetConnector(drm_fd, connector_id); + if (connector && connector->connection == drm_mode) { + free(connector); + return true; + } + free(connector); + clock_gettime(CLOCK_MONOTONIC, &end); + } + + igt_debug("Timeout waiting for connection status %d on connector %d\n", drm_mode, + connector_id); + return false; +} diff --git a/lib/igt_kms.h b/lib/igt_kms.h index b10df1d8d..60cfc1763 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -1299,4 +1299,7 @@ igt_colorop_t *igt_find_colorop(igt_display_t *display, uint32_t id); double igt_default_display_detect_timeout(void); +bool igt_wait_for_connector_status(int drm_fd, unsigned int connector_id, double timeout, + int drm_mode); + #endif /* __IGT_KMS_H__ */ -- 2.48.1