Skip to contentSkip to conversation

drm/sun4i: hdmi: Improve compatibility with non-hotplug capable connectors

PATCH In review Priit Laes 3 participants 6 messages Nov 16, 2018 – Dec 5, 2018

Subsystems (4)
lore
Share & tools
lore

Priit Laes

author
#0 lore raw

PATCH 1/1 drm/sun4i: hdmi: Improve compatibility with non-hotplug capable connectors

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it. For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +8 -4
index 061d2e0d9011..bded09af1340 100644
@@ -238,14 +238,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
 	unsigned long reg;
 
-	if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
+	if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
 			       reg & SUN4I_HDMI_HPD_HIGH,
 			       0, 500000)) {
-		cec_phys_addr_invalidate(hdmi->cec_adap);
-		return connector_status_disconnected;
+		return connector_status_connected;
 	}
 
-	return connector_status_connected;
+	if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c))
+		return connector_status_connected;
+
+	cec_phys_addr_invalidate(hdmi->cec_adap);
+
+	return connector_status_unknown;
 }
 
 static const struct drm_connector_funcs sun4i_hdmi_connector_funcs = {
Signature · 1 line
2.19.1
#1 lore raw

Hi,

Quoted 4 lines · Priit Laes

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it.

Which devices?

Quoted 3 lines

For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

Again, which devices?

Quoted 3 lines

You only need one :)

Quoted 18 lines
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +1 -3
index 061d2e0d9011..bded09af1340 100644
@@ -238,14 +238,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
 	unsigned long reg;
 
-	if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
+	if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
 			       reg & SUN4I_HDMI_HPD_HIGH,
 			       0, 500000)) {
-		cec_phys_addr_invalidate(hdmi->cec_adap);
-		return connector_status_disconnected;

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 252

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +7 -1
+		return connector_status_connected;
 	}
 
-	return connector_status_connected;
+	if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c))
+		return connector_status_connected;
+
+	cec_phys_addr_invalidate(hdmi->cec_adap);
+
+	return connector_status_unknown;

You're doing basically two things in that patch, first adding the fallback to the DDC probe if the hotplug mechanism couldn't detect the display, and then returning a status unknown if both fail.

While I don't really have an opinion on the first one, it's mandatory for every HDMI device to be able to retrieve the EDID through the DDC. If a device was to disallow that, it would violate the HDMI, and I'm not sure we want to start supporting those devices.

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181119/83ff0540/attachment.sig>
author
#2 lore raw
Quoted 9 lines · Maxime Ripard

Hi,

Quoted 4 lines · Priit Laes

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it.

Which devices?

Device I have here is labelled "AMATIC INDUSTRIES PT-MULTI-1" and based on the TFP401APZP chip.

Quoted 6 lines
Quoted 4 lines

For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

Again, which devices?

OK, let's skip the part without DDC. I was probably thinking about VGA cables when I was writing that..

Quoted 27 lines
Quoted 3 lines

You only need one :)

Quoted 21 lines
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +2 -3
index 061d2e0d9011..bded09af1340 100644
@@ -238,14 +238,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
 	unsigned long reg;
 
-	if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
+	if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
 			       reg & SUN4I_HDMI_HPD_HIGH,
 			       0, 500000)) {
-		cec_phys_addr_invalidate(hdmi->cec_adap);
-		return connector_status_disconnected;
+		return connector_status_connected;
 	}
 
Quoted 11 lines

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 252

Quoted 7 lines
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +6 -1
-	return connector_status_connected;
+	if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c))
+		return connector_status_connected;
+
+	cec_phys_addr_invalidate(hdmi->cec_adap);
+
+	return connector_status_unknown;

You're doing basically two things in that patch, first adding the fallback to the DDC probe if the hotplug mechanism couldn't detect the display, and then returning a status unknown if both fail.

Agreed. 'connector_status_disconnected' is the way to go.

Quoted 4 lines

While I don't really have an opinion on the first one, it's mandatory for every HDMI device to be able to retrieve the EDID through the DDC. If a device was to disallow that, it would violate the HDMI, and I'm not sure we want to start supporting those devices.

Yes, Even if someone runs into those non-spec devices, then there's also possibility to use the force argument.

Thanks for review!

Quoted 7 lines

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
#3 lore raw
In reply to Maxime Ripard
Quoted 55 lines · Maxime Ripard

Hi,

Quoted 4 lines · Priit Laes

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it.

Which devices?

Quoted 3 lines

For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

Again, which devices?

Quoted 3 lines

You only need one :)

Quoted 18 lines
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +1 -3
index 061d2e0d9011..bded09af1340 100644
@@ -238,14 +238,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
 	unsigned long reg;
 
-	if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
+	if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
 			       reg & SUN4I_HDMI_HPD_HIGH,
 			       0, 500000)) {
-		cec_phys_addr_invalidate(hdmi->cec_adap);
-		return connector_status_disconnected;

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 252

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +7 -1
+		return connector_status_connected;
 	}
 
-	return connector_status_connected;
+	if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c))
+		return connector_status_connected;
+
+	cec_phys_addr_invalidate(hdmi->cec_adap);
+
+	return connector_status_unknown;

You're doing basically two things in that patch, first adding the fallback to the DDC probe if the hotplug mechanism couldn't detect the display, and then returning a status unknown if both fail.

Quoted 4 lines

While I don't really have an opinion on the first one, it's mandatory for every HDMI device to be able to retrieve the EDID through the DDC. If a device was to disallow that, it would violate the HDMI, and I'm not sure we want to start supporting those devices.

There is also the problem that HDMI uses the HPD signal to indicate that the source should re-read the EDID due to the EDID changing. In HDMI, you don't necessarily have a fixed-for-all-time EDID, but one which can change depending on what devices are in the HDMI path.

Consider, for example, an AV amplifier which needs to subsitute the audio capabilities when it is turned on, but when in standby needs to pass through the TVs audio capabilities. It informs the source by momentarily deasserting the HDMI HPD signal, which is the HDMI way to inform the source that the EDID should be re-read.

If you're going to use "read EDID" as the hotplug method, I think you need to keep track of when it changes so that EDID updates are correctly handled.

Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up
#4 lore raw
Quoted 72 lines · Russell King - ARM Linux
Quoted 55 lines · Maxime Ripard

Hi,

Quoted 4 lines · Priit Laes

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it.

Which devices?

Quoted 3 lines

For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

Again, which devices?

Quoted 3 lines

You only need one :)

Quoted 18 lines
---
 drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +1 -3
index 061d2e0d9011..bded09af1340 100644
@@ -238,14 +238,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector);
 	unsigned long reg;
 
-	if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
+	if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg,
 			       reg & SUN4I_HDMI_HPD_HIGH,
 			       0, 500000)) {
-		cec_phys_addr_invalidate(hdmi->cec_adap);
-		return connector_status_disconnected;

drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force) · line 252

Quoted 10 lines
drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +7 -1
+		return connector_status_connected;
 	}
 
-	return connector_status_connected;
+	if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c))
+		return connector_status_connected;
+
+	cec_phys_addr_invalidate(hdmi->cec_adap);
+
+	return connector_status_unknown;

You're doing basically two things in that patch, first adding the fallback to the DDC probe if the hotplug mechanism couldn't detect the display, and then returning a status unknown if both fail.

Quoted 4 lines

While I don't really have an opinion on the first one, it's mandatory for every HDMI device to be able to retrieve the EDID through the DDC. If a device was to disallow that, it would violate the HDMI, and I'm not sure we want to start supporting those devices.

There is also the problem that HDMI uses the HPD signal to indicate that the source should re-read the EDID due to the EDID changing. In HDMI, you don't necessarily have a fixed-for-all-time EDID, but one which can change depending on what devices are in the HDMI path.

Consider, for example, an AV amplifier which needs to subsitute the audio capabilities when it is turned on, but when in standby needs to pass through the TVs audio capabilities. It informs the source by momentarily deasserting the HDMI HPD signal, which is the HDMI way to inform the source that the EDID should be re-read.

Quoted 3 lines

If you're going to use "read EDID" as the hotplug method, I think you need to keep track of when it changes so that EDID updates are correctly handled.

I didn't think about that, thanks for bringing it up!

Maxime

Signature · 10 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20181120/d0e8a592/attachment-0001.sig>
author
#5 lore raw
Quoted 46 lines · Maxime Ripard
Quoted 45 lines · Russell King - ARM Linux
Quoted 24 lines · Maxime Ripard

Hi,

Quoted 4 lines · Priit Laes

From: Priit Laes <[email protected]>

Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it.

Which devices?

Quoted 3 lines

For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected.

Again, which devices?

Quoted 3 lines

You only need one :)

Quoted 1 line

---

Quoted 8 lines

You're doing basically two things in that patch, first adding the fallback to the DDC probe if the hotplug mechanism couldn't detect the display, and then returning a status unknown if both fail.

While I don't really have an opinion on the first one, it's mandatory for every HDMI device to be able to retrieve the EDID through the DDC. If a device was to disallow that, it would violate the HDMI, and I'm not sure we want to start supporting those devices.

There is also the problem that HDMI uses the HPD signal to indicate that the source should re-read the EDID due to the EDID changing. In HDMI, you don't necessarily have a fixed-for-all-time EDID, but one which can change depending on what devices are in the HDMI path.

Consider, for example, an AV amplifier which needs to subsitute the audio capabilities when it is turned on, but when in standby needs to pass through the TVs audio capabilities. It informs the source by momentarily deasserting the HDMI HPD signal, which is the HDMI way to inform the source that the EDID should be re-read.

Quoted 5 lines
Quoted 3 lines

If you're going to use "read EDID" as the hotplug method, I think you need to keep track of when it changes so that EDID updates are correctly handled.

I didn't think about that, thanks for bringing it up!

Well, currently this is broken anyway, becuse we are doing the polling due to missing HPD interrupt. You can test by quickly switching between two different monitors that both have proper HPD pin.

Quoted 7 lines

Maxime

Signature · 3 lines
Maxime Ripard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com