public inbox for igt-dev@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Ramalingam C <ramalingam.c@intel.com>
To: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [Patch][i-g-t 1/2] lib/igt_kms: Add support for detecting connector events
Date: Tue, 16 Jun 2020 19:42:10 +0530	[thread overview]
Message-ID: <20200616141210.GB26166@intel.com> (raw)
In-Reply-To: <20200616105812.21558-2-ankit.k.nautiyal@intel.com>

On 2020-06-16 at 16:28:11 +0530, Ankit Nautiyal wrote:
> Currently, the event_detect function checks the property val for
> "HOTPLUG" and "LEASE" both of which are set to '1' when these events
> are sent.
> 
> This cannot be used for detecting connector events such as HDCP event
> as connector events are sent along with property to signify which
> property of which connector has changed. Connector ID and property id
> are provided along with "CONNECTOR" and "PROPERTY" as udev
> property-value pairs. Eg. for HDCP, the connector id of the connector
> whose hdcp status changed, and the property id of the
> ‘CONTENT_PROTECTION’ property are sent with uevent.
> 
> This patch modifies the event_detect function to check multiple
> properties with different expected values. It also adds support to
> detect connector event for a given pair of connector and property ids.
> 
> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
> ---
>  lib/igt_kms.c | 61 ++++++++++++++++++++++++++++++++++++++-------------
>  lib/igt_kms.h |  2 ++
>  2 files changed, 48 insertions(+), 15 deletions(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index 54de45e5..7177231e 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -4164,32 +4164,57 @@ struct udev_monitor *igt_watch_hotplug(void)
>  }
>  
>  static bool event_detected(struct udev_monitor *mon, int timeout_secs,
> -			   const char *property)
> +			   const char **property, int *expected_val, int num_props)
>  {
>  	struct udev_device *dev;
> -	const char *hotplug_val;
> +	const char *prop_val_str;
>  	struct pollfd fd = {
>  		.fd = udev_monitor_get_fd(mon),
>  		.events = POLLIN
>  	};
> -	bool hotplug_received = false;
> +	bool event_received = false;
> +	int i;
>  
> -	/* Go through all of the events pending on the udev monitor. Once we
> -	 * receive a hotplug, we continue going through the rest of the events
> -	 * so that redundant hotplug events don't change the results of future
> -	 * checks
> +	/* Go through all of the events pending on the udev monitor.
> +	 * Match the given set of properties and their values to
> +	 * the expected values.
>  	 */
> -	while (!hotplug_received && poll(&fd, 1, timeout_secs * 1000)) {
> +	while (!event_received && poll(&fd, 1, timeout_secs * 1000)) {
>  		dev = udev_monitor_receive_device(mon);
> -
> -		hotplug_val = udev_device_get_property_value(dev, property);
> -		if (hotplug_val && atoi(hotplug_val) == 1)
> -			hotplug_received = true;
> +		for (i = 0; i < num_props; i++) {
> +			event_received = true;
Not needed.
> +			prop_val_str = udev_device_get_property_value(dev, property[i]);
> +			if (!prop_val_str || atoi(prop_val_str) != expected_val[i]) {
> +				event_received = false;
Not needed.
> +				break;
> +			}
> +		}
		if (i == num_props)
			event_received = true;
>  
>  		udev_device_unref(dev);
>  	}
>  
> -	return hotplug_received;
> +	return event_received;
> +}
> +
> +/**
> + * igt_conn_event_detected:
> + * @mon: A udev monitor initialized with #igt_watch_hotplug
> + * @conn_id: Connector id of the Connector for which the property change is
> + * expected.
> + * @prop_id: Property id for which the change is expected.
> + * @timeout_secs: How long to wait for a connector event to occur.
> + *
> + * Assert that a connector event is received for a given connector and property.
> + *
> + * Returns: true if the connector event was received, false if we timed out
> + */
> +bool igt_conn_event_detected(struct udev_monitor *mon, uint32_t conn_id,
> +			     uint32_t prop_id, int timeout_secs)
> +{
> +	const char *props[2] = {"CONNECTOR", "PROPERTY"};
> +	int expected_val[2] = {conn_id, prop_id};
> +
> +	return event_detected(mon, timeout_secs, props, expected_val, 2);
>  }
>  
>  /**
> @@ -4203,7 +4228,10 @@ static bool event_detected(struct udev_monitor *mon, int timeout_secs,
>   */
>  bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
>  {
> -	return event_detected(mon, timeout_secs, "HOTPLUG");
> +	const char *props[1] = {"HOTPLUG"};
> +	int expected_val = 1;
> +
> +	return event_detected(mon, timeout_secs, props, &expected_val, 1);
>  }
>  
>  /**
> @@ -4217,7 +4245,10 @@ bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
>   */
>  bool igt_lease_change_detected(struct udev_monitor *mon, int timeout_secs)
>  {
> -	return event_detected(mon, timeout_secs, "LEASE");
> +	const char *props[1] = {"LEASE"};
> +	int expected_val = 1;
> +
> +	return event_detected(mon, timeout_secs, props, &expected_val, 1);
>  }
>  
>  /**
> diff --git a/lib/igt_kms.h b/lib/igt_kms.h
> index cd3fdbc0..27f1f729 100644
> --- a/lib/igt_kms.h
> +++ b/lib/igt_kms.h
> @@ -777,6 +777,8 @@ bool igt_hotplug_detected(struct udev_monitor *mon,
>  			  int timeout_secs);
>  bool igt_lease_change_detected(struct udev_monitor *mon,
>  			       int timeout_secs);
> +bool igt_conn_event_detected(struct udev_monitor *mon, uint32_t conn_id,
> +			     uint32_t prop_id, int timeout_msecs);
>  void igt_flush_hotplugs(struct udev_monitor *mon);
We need to have generich flush too like igt_(watch/flush/cleanup)_udev_event()

-Ram
>  void igt_cleanup_hotplug(struct udev_monitor *mon);
>  
> -- 
> 2.17.1
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-06-16 14:12 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-16 10:58 [igt-dev] [Patch][i-g-t 0/2] Add support to detect HDCP events Ankit Nautiyal
2020-06-16 10:58 ` [igt-dev] [Patch][i-g-t 1/2] lib/igt_kms: Add support for detecting connector events Ankit Nautiyal
2020-06-16 14:12   ` Ramalingam C [this message]
2020-06-17  6:23     ` Nautiyal, Ankit K
2020-06-16 10:58 ` [igt-dev] [Patch][i-g-t 2/2] tests/kms_content_protection: Use library functions for handling uevents Ankit Nautiyal
2020-06-16 14:03   ` Ramalingam C
2020-06-16 14:10     ` Arkadiusz Hiler
2020-06-16 14:17       ` Ramalingam C
2020-06-17  4:18     ` Anshuman Gupta
2020-06-17  6:24       ` Nautiyal, Ankit K
2020-06-16 16:45 ` [igt-dev] ✓ Fi.CI.BAT: success for Add support to detect HDCP events Patchwork
2020-06-16 17:44 ` [igt-dev] ✓ Fi.CI.IGT: " 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=20200616141210.GB26166@intel.com \
    --to=ramalingam.c@intel.com \
    --cc=ankit.k.nautiyal@intel.com \
    --cc=igt-dev@lists.freedesktop.org \
    /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