linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1] usb: typec: altmodes/displayport: Add hpd sysfs attribute
@ 2022-12-11 19:37 Badhri Jagan Sridharan
  2022-12-13  9:21 ` Heikki Krogerus
  0 siblings, 1 reply; 2+ messages in thread
From: Badhri Jagan Sridharan @ 2022-12-11 19:37 UTC (permalink / raw)
  To: Heikki Krogerus, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, RD Babiera, Badhri Jagan Sridharan

Exporsing HotPlugDetect(HPD) helps userspace to infer HPD
state as defined by VESA DisplayPort Alt Mode on USB Type-C Standard.
This allows userspace to notify users for self help, for instance,
to hint user that the display port cable is probably detached (or)
the display port sink (viz., monitors ect.,) is un-powered.
Also helps to debug issues reported from field.

This change adds an additional attribute "hpd" to the existing
"displayport" attributes.

VESA DisplayPort Alt Mode on USB Type-C Standard defines how
HotPlugDetect(HPD) shall be supported on the USB-C connector
when operating in DisplayPort Alt Mode. This is a read only
node which reflects the current state of HPD.

Valid values:
 - 1 when HPD’s logical state is high (HPD_High)
 - 0 when HPD’s logical state is low (HPD_Low)

Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>
---
 .../ABI/testing/sysfs-driver-typec-displayport    | 15 +++++++++++++++
 drivers/usb/typec/altmodes/displayport.c          | 10 ++++++++++
 2 files changed, 25 insertions(+)

diff --git a/Documentation/ABI/testing/sysfs-driver-typec-displayport b/Documentation/ABI/testing/sysfs-driver-typec-displayport
index 231471ad0d4b..256c87c5219a 100644
--- a/Documentation/ABI/testing/sysfs-driver-typec-displayport
+++ b/Documentation/ABI/testing/sysfs-driver-typec-displayport
@@ -47,3 +47,18 @@ Description:
 		USB SuperSpeed protocol. From user perspective pin assignments C
 		and E are equal, where all channels on the connector are used
 		for carrying DisplayPort protocol (allowing higher resolutions).
+
+What:		/sys/bus/typec/devices/.../displayport/hpd
+Date:		Dec 2022
+Contact:	Badhri Jagan Sridharan <badhri@google.com>
+Description:
+		VESA DisplayPort Alt Mode on USB Type-C Standard defines how
+		HotPlugDetect(HPD) shall be supported on the USB-C connector when
+		operating in DisplayPort Alt Mode. This is a read only node which
+		reflects the current state of HPD.
+
+		Valid values:
+			- 1: when HPD’s logical state is high (HPD_High) as defined
+			     by VESA DisplayPort Alt Mode on USB Type-C Standard.
+			- 0 when HPD’s logical state is low (HPD_Low) as defined by
+			     VESA DisplayPort Alt Mode on USB Type-C Standard.
diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
index de66a2949e33..06fb4732f8cd 100644
--- a/drivers/usb/typec/altmodes/displayport.c
+++ b/drivers/usb/typec/altmodes/displayport.c
@@ -146,6 +146,7 @@ static int dp_altmode_status_update(struct dp_altmode *dp)
 		if (dp->hpd != hpd) {
 			drm_connector_oob_hotplug_event(dp->connector_fwnode);
 			dp->hpd = hpd;
+			sysfs_notify(&dp->alt->dev.kobj, "displayport", "hpd");
 		}
 	}
 
@@ -508,9 +509,18 @@ static ssize_t pin_assignment_show(struct device *dev,
 }
 static DEVICE_ATTR_RW(pin_assignment);
 
+static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct dp_altmode *dp = dev_get_drvdata(dev);
+
+	return sysfs_emit(buf, "%d\n", dp->hpd);
+}
+static DEVICE_ATTR_RO(hpd);
+
 static struct attribute *dp_altmode_attrs[] = {
 	&dev_attr_configuration.attr,
 	&dev_attr_pin_assignment.attr,
+	&dev_attr_hpd.attr,
 	NULL
 };
 

base-commit: 81c25247a2a03a0f97e4805d7aff7541ccff6baa
-- 
2.39.0.rc1.256.g54fd8350bd-goog


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v1] usb: typec: altmodes/displayport: Add hpd sysfs attribute
  2022-12-11 19:37 [PATCH v1] usb: typec: altmodes/displayport: Add hpd sysfs attribute Badhri Jagan Sridharan
@ 2022-12-13  9:21 ` Heikki Krogerus
  0 siblings, 0 replies; 2+ messages in thread
From: Heikki Krogerus @ 2022-12-13  9:21 UTC (permalink / raw)
  To: Badhri Jagan Sridharan
  Cc: Greg Kroah-Hartman, linux-usb, linux-kernel, RD Babiera

On Sun, Dec 11, 2022 at 11:37:55AM -0800, Badhri Jagan Sridharan wrote:
> Exporsing HotPlugDetect(HPD) helps userspace to infer HPD
> state as defined by VESA DisplayPort Alt Mode on USB Type-C Standard.
> This allows userspace to notify users for self help, for instance,
> to hint user that the display port cable is probably detached (or)
> the display port sink (viz., monitors ect.,) is un-powered.
> Also helps to debug issues reported from field.
> 
> This change adds an additional attribute "hpd" to the existing
> "displayport" attributes.
> 
> VESA DisplayPort Alt Mode on USB Type-C Standard defines how
> HotPlugDetect(HPD) shall be supported on the USB-C connector
> when operating in DisplayPort Alt Mode. This is a read only
> node which reflects the current state of HPD.
> 
> Valid values:
>  - 1 when HPD’s logical state is high (HPD_High)
>  - 0 when HPD’s logical state is low (HPD_Low)
> 
> Signed-off-by: Badhri Jagan Sridharan <badhri@google.com>

Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>

> ---
>  .../ABI/testing/sysfs-driver-typec-displayport    | 15 +++++++++++++++
>  drivers/usb/typec/altmodes/displayport.c          | 10 ++++++++++
>  2 files changed, 25 insertions(+)
> 
> diff --git a/Documentation/ABI/testing/sysfs-driver-typec-displayport b/Documentation/ABI/testing/sysfs-driver-typec-displayport
> index 231471ad0d4b..256c87c5219a 100644
> --- a/Documentation/ABI/testing/sysfs-driver-typec-displayport
> +++ b/Documentation/ABI/testing/sysfs-driver-typec-displayport
> @@ -47,3 +47,18 @@ Description:
>  		USB SuperSpeed protocol. From user perspective pin assignments C
>  		and E are equal, where all channels on the connector are used
>  		for carrying DisplayPort protocol (allowing higher resolutions).
> +
> +What:		/sys/bus/typec/devices/.../displayport/hpd
> +Date:		Dec 2022
> +Contact:	Badhri Jagan Sridharan <badhri@google.com>
> +Description:
> +		VESA DisplayPort Alt Mode on USB Type-C Standard defines how
> +		HotPlugDetect(HPD) shall be supported on the USB-C connector when
> +		operating in DisplayPort Alt Mode. This is a read only node which
> +		reflects the current state of HPD.
> +
> +		Valid values:
> +			- 1: when HPD’s logical state is high (HPD_High) as defined
> +			     by VESA DisplayPort Alt Mode on USB Type-C Standard.
> +			- 0 when HPD’s logical state is low (HPD_Low) as defined by
> +			     VESA DisplayPort Alt Mode on USB Type-C Standard.
> diff --git a/drivers/usb/typec/altmodes/displayport.c b/drivers/usb/typec/altmodes/displayport.c
> index de66a2949e33..06fb4732f8cd 100644
> --- a/drivers/usb/typec/altmodes/displayport.c
> +++ b/drivers/usb/typec/altmodes/displayport.c
> @@ -146,6 +146,7 @@ static int dp_altmode_status_update(struct dp_altmode *dp)
>  		if (dp->hpd != hpd) {
>  			drm_connector_oob_hotplug_event(dp->connector_fwnode);
>  			dp->hpd = hpd;
> +			sysfs_notify(&dp->alt->dev.kobj, "displayport", "hpd");
>  		}
>  	}
>  
> @@ -508,9 +509,18 @@ static ssize_t pin_assignment_show(struct device *dev,
>  }
>  static DEVICE_ATTR_RW(pin_assignment);
>  
> +static ssize_t hpd_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	struct dp_altmode *dp = dev_get_drvdata(dev);
> +
> +	return sysfs_emit(buf, "%d\n", dp->hpd);
> +}
> +static DEVICE_ATTR_RO(hpd);
> +
>  static struct attribute *dp_altmode_attrs[] = {
>  	&dev_attr_configuration.attr,
>  	&dev_attr_pin_assignment.attr,
> +	&dev_attr_hpd.attr,
>  	NULL
>  };
>  
> 
> base-commit: 81c25247a2a03a0f97e4805d7aff7541ccff6baa
> -- 
> 2.39.0.rc1.256.g54fd8350bd-goog

thanks,

-- 
heikki

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-13  9:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-11 19:37 [PATCH v1] usb: typec: altmodes/displayport: Add hpd sysfs attribute Badhri Jagan Sridharan
2022-12-13  9:21 ` Heikki Krogerus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).