From: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
To: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [Patch][i-g-t v3 1/3] lib/igt_kms: Add support for detecting connector events
Date: Tue, 23 Jun 2020 19:04:14 +0530 [thread overview]
Message-ID: <20200623133416.4275-2-ankit.k.nautiyal@intel.com> (raw)
In-Reply-To: <20200623133416.4275-1-ankit.k.nautiyal@intel.com>
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.
v2: Simplified the event_detect conditional statements. (Ram)
Changed the api name for detecting connnector events. (Anshuman)
Added check for "HOTPLUG" property value for connector events.
v3: Used ARRAY_SIZE() instead of constants. (Ram)
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
---
lib/igt_kms.c | 71 ++++++++++++++++++++++++++++++++++++++-------------
lib/igt_kms.h | 2 ++
2 files changed, 55 insertions(+), 18 deletions(-)
diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index afef5939..1af74d08 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -4194,33 +4194,60 @@ struct udev_monitor *igt_watch_hotplug(void)
return mon;
}
-static bool event_detected(struct udev_monitor *mon, int timeout_secs,
- const char *property)
+static
+bool event_detected(struct udev_monitor *mon, int timeout_secs,
+ const char **property, int *expected_val, int num_props)
{
struct udev_device *dev;
- const char *hotplug_val;
+ const char *prop_val;
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++) {
+ prop_val = udev_device_get_property_value(dev,
+ property[i]);
+ if (!prop_val || atoi(prop_val) != expected_val[i])
+ break;
+ }
+ if (i == num_props)
+ event_received = true;
udev_device_unref(dev);
}
- return hotplug_received;
+ return event_received;
+}
+
+/**
+ * igt_connector_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.
+ *
+ * Detect if 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_connector_event_detected(struct udev_monitor *mon, uint32_t conn_id,
+ uint32_t prop_id, int timeout_secs)
+{
+ const char *props[3] = {"HOTPLUG", "CONNECTOR", "PROPERTY"};
+ int expected_val[3] = {1, conn_id, prop_id};
+
+ return event_detected(mon, timeout_secs, props, expected_val,
+ ARRAY_SIZE(props));
}
/**
@@ -4228,13 +4255,17 @@ static bool event_detected(struct udev_monitor *mon, int timeout_secs,
* @mon: A udev monitor initialized with #igt_watch_hotplug
* @timeout_secs: How long to wait for a hotplug event to occur.
*
- * Assert that a hotplug event was received since we last checked the monitor.
+ * Detect if a hotplug event was received since we last checked the monitor.
*
* Returns: true if a sysfs hotplug event was received, false if we timed out
*/
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,
+ ARRAY_SIZE(props));
}
/**
@@ -4242,13 +4273,17 @@ bool igt_hotplug_detected(struct udev_monitor *mon, int timeout_secs)
* @mon: A udev monitor initialized with #igt_watch_hotplug
* @timeout_secs: How long to wait for a lease change event to occur.
*
- * Assert that a lease change event was received since we last checked the monitor.
+ * Detect if a lease change event was received since we last checked the monitor.
*
* Returns: true if a sysfs lease change event was received, false if we timed out
*/
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,
+ ARRAY_SIZE(props));
}
/**
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index 32a0e4cc..539f6c5a 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -779,6 +779,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_connector_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);
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
next prev parent reply other threads:[~2020-06-23 13:39 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-23 13:34 [igt-dev] [Patch][i-g-t v3 0/3] Add support to detect HDCP events Ankit Nautiyal
2020-06-23 13:34 ` Ankit Nautiyal [this message]
2020-06-23 14:12 ` [igt-dev] [Patch][i-g-t v3 1/3] lib/igt_kms: Add support for detecting connector events Ramalingam C
2020-06-23 13:34 ` [igt-dev] [Patch][i-g-t v3 2/3] tests/kms_content_protection: Use library functions for handling uevents Ankit Nautiyal
2020-06-23 13:34 ` [igt-dev] [Patch][i-g-t v3 3/3] lib: Use generic names for APIs that handle uevents Ankit Nautiyal
2020-06-23 13:44 ` [igt-dev] ✗ Fi.CI.BUILD: failure for Add support to detect HDCP events (rev3) Patchwork
2020-06-23 14:13 ` [igt-dev] [Patch][i-g-t v3 0/3] Add support to detect HDCP events Arkadiusz Hiler
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=20200623133416.4275-2-ankit.k.nautiyal@intel.com \
--to=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