Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Joshi, Kunal1" <kunal1.joshi@intel.com>
To: Louis Chauvet <louis.chauvet@bootlin.com>, igt-dev@lists.freedesktop.org
Cc: Petri Latvala <adrinael@adrinael.net>,
	Arkadiusz Hiler <arek@hiler.eu>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>,
	Juha-Pekka Heikkila <juhapekka.heikkila@gmail.com>,
	Bhanuprakash Modem <bhanuprakash.modem@intel.com>,
	Ashutosh Dixit <ashutosh.dixit@intel.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	nicolejadeyee@google.com, seanpaul@google.com,
	jeremie.dautheribes@bootlin.com, markyacoub@google.com
Subject: Re: [i-g-t,v4,2/5] lib/igt_kms: Add helper to wait for a specific status on a connector
Date: Wed, 19 Mar 2025 14:16:32 +0530	[thread overview]
Message-ID: <48a41355-b190-42ce-a224-8e71a28613a1@intel.com> (raw)
In-Reply-To: <20250110-b4-cv3-01-igt-kms-v4-2-0b0474708f9f@bootlin.com>

Hello Louis,

Can we have all connector related at one place (kms_connector_helper or 
igt_connector),
igt_kms is already crowded and also will be easy to find all connector 
helpers at one place.

Thanks and Regards
Kunal Joshi

On 10-01-2025 23:12, Louis Chauvet wrote:
> 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.
>
> Signed-off-by: Louis Chauvet <louis.chauvet@bootlin.com>
> ---
>   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 b3373435b252c9f8c5d5854f738f7f4bbc468964..d0b6c70f135754d0a413f73a0f8e5b24a208a2b3 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -7245,3 +7245,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 91a26f2070efd26f9d107841ae3083b281d5e4c6..6d5582290f61d1a4151dd8e8448fc26c660a1536 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -1279,4 +1279,7 @@ int igt_backlight_write(int value, const char *fname, igt_backlight_context_t *c
>   
>   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__ */

  reply	other threads:[~2025-03-19  8:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-10 17:42 [PATCH i-g-t v4 0/5] lib/igt_kms: Helpers for connector managment Louis Chauvet
2025-01-10 17:42 ` [PATCH i-g-t v4 1/5] lib/igt_kms: Add a detect timeout value Louis Chauvet
2025-03-19  8:41   ` [i-g-t,v4,1/5] " Joshi, Kunal1
2025-01-10 17:42 ` [PATCH i-g-t v4 2/5] lib/igt_kms: Add helper to wait for a specific status on a connector Louis Chauvet
2025-03-19  8:46   ` Joshi, Kunal1 [this message]
2025-01-10 17:42 ` [PATCH i-g-t v4 3/5] lib/igt_kms: Add function to list connected connectors Louis Chauvet
2025-01-10 17:42 ` [PATCH i-g-t v4 4/5] lib/igt_kms: Add helper to obtain a connector by its name or MST path Louis Chauvet
2025-01-10 17:42 ` [PATCH i-g-t v4 5/5] lib/igt_kms: Add function to get valid pipe for specific output Louis Chauvet
2025-01-24  4:26   ` Karthik B S
2025-01-27 14:44     ` Louis Chauvet
2025-02-03  5:04       ` Karthik B S
2025-01-10 18:47 ` ✓ i915.CI.BAT: success for lib/igt_kms: Helpers for connector managment (rev4) Patchwork
2025-01-10 19:08 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-01-14 21:18 ` ✗ i915.CI.Full: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48a41355-b190-42ce-a224-8e71a28613a1@intel.com \
    --to=kunal1.joshi@intel.com \
    --cc=adrinael@adrinael.net \
    --cc=arek@hiler.eu \
    --cc=ashutosh.dixit@intel.com \
    --cc=bhanuprakash.modem@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeremie.dautheribes@bootlin.com \
    --cc=juhapekka.heikkila@gmail.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=louis.chauvet@bootlin.com \
    --cc=markyacoub@google.com \
    --cc=nicolejadeyee@google.com \
    --cc=seanpaul@google.com \
    --cc=thomas.petazzoni@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox