[igt-dev] [Patch][i-g-t v2 1/3] lib/igt_kms: Add support for detecting connector events

Nautiyal, Ankit K ankit.k.nautiyal at intel.com
Tue Jun 23 13:37:15 UTC 2020


Hi Ram,

Thanks for the suggestions.

I agree with the comments and will be addressing them in next patch set.

Regards,

Ankit


On 6/23/2020 5:20 PM, C, Ramalingam wrote:
> On 2020-06-23 at 16:02:52 +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.
>>
>> 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.
>>
>> Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal at 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..a9c444e6 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;
>>   	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.
>> + *
>> + * Assert that a connector event is received for a given connector and property.
> You mean detect the connector event? Assert in IGT perspective might be
> different?
>> + *
>> + * 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, 3);
> ARRAY_SIZE could be used instead of constant..
>
> -Ram.
>>   }
>>   
>>   /**
>> @@ -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..0b4d7c94 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_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
>>



More information about the igt-dev mailing list