Commit bafb6863 authored by Chris Morgan's avatar Chris Morgan Committed by Heiko Stuebner
Browse files

drm/bridge: dw-hdmi-qp: Add support for missing HPD



Add support for the dw-hdmi-qp driver to handle devices with missing
HPD pins.

Since in this situation we are now polling for the EDID data via i2c
change the error message to a rate limited debug message when we are
unable to complete an i2c read, as a disconnected device would
otherwise fill dmesg with i2c read errors.

Reviewed-by: default avatarCristian Ciocaltea <cristian.ciocaltea@collabora.com>
Signed-off-by: default avatarChris Morgan <macromorgan@hotmail.com>
Signed-off-by: default avatarHeiko Stuebner <heiko@sntech.de>
Link: https://patch.msgid.link/20251119225526.70588-3-macroalpha82@gmail.com
parent db04f0d4
Loading
Loading
Loading
Loading
+30 −4
Original line number Diff line number Diff line
@@ -165,6 +165,7 @@ struct dw_hdmi_qp {
	struct regmap *regm;

	unsigned long tmds_char_rate;
	bool no_hpd;
};

static void dw_hdmi_qp_write(struct dw_hdmi_qp *hdmi, unsigned int val,
@@ -555,6 +556,10 @@ static int dw_hdmi_qp_i2c_read(struct dw_hdmi_qp *hdmi,

		stat = wait_for_completion_timeout(&i2c->cmp, HZ / 10);
		if (!stat) {
			if (hdmi->no_hpd)
				dev_dbg_ratelimited(hdmi->dev,
						    "i2c read timed out\n");
			else
				dev_err(hdmi->dev, "i2c read timed out\n");
			dw_hdmi_qp_write(hdmi, 0x01, I2CM_CONTROL0);
			return -EAGAIN;
@@ -562,6 +567,10 @@ static int dw_hdmi_qp_i2c_read(struct dw_hdmi_qp *hdmi,

		/* Check for error condition on the bus */
		if (i2c->stat & I2CM_NACK_RCVD_IRQ) {
			if (hdmi->no_hpd)
				dev_dbg_ratelimited(hdmi->dev,
						    "i2c read error\n");
			else
				dev_err(hdmi->dev, "i2c read error\n");
			dw_hdmi_qp_write(hdmi, 0x01, I2CM_CONTROL0);
			return -EIO;
@@ -900,6 +909,15 @@ static enum drm_connector_status
dw_hdmi_qp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *connector)
{
	struct dw_hdmi_qp *hdmi = bridge->driver_private;
	const struct drm_edid *drm_edid;

	if (hdmi->no_hpd) {
		drm_edid = drm_edid_read_ddc(connector, bridge->ddc);
		if (drm_edid)
			return connector_status_connected;
		else
			return connector_status_disconnected;
	}

	return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
}
@@ -925,6 +943,11 @@ dw_hdmi_qp_bridge_tmds_char_rate_valid(const struct drm_bridge *bridge,
{
	struct dw_hdmi_qp *hdmi = bridge->driver_private;

	/*
	 * TODO: when hdmi->no_hpd is 1 we must not support modes that
	 * require scrambling, including every mode with a clock above
	 * HDMI14_MAX_TMDSCLK.
	 */
	if (rate > HDMI14_MAX_TMDSCLK) {
		dev_dbg(hdmi->dev, "Unsupported TMDS char rate: %lld\n", rate);
		return MODE_CLOCK_HIGH;
@@ -1277,12 +1300,15 @@ struct dw_hdmi_qp *dw_hdmi_qp_bind(struct platform_device *pdev,
	if (ret)
		return ERR_PTR(ret);

	hdmi->no_hpd = device_property_read_bool(dev, "no-hpd");

	hdmi->bridge.driver_private = hdmi;
	hdmi->bridge.ops = DRM_BRIDGE_OP_DETECT |
			   DRM_BRIDGE_OP_EDID |
			   DRM_BRIDGE_OP_HDMI |
			   DRM_BRIDGE_OP_HDMI_AUDIO |
			   DRM_BRIDGE_OP_HPD;
			   DRM_BRIDGE_OP_HDMI_AUDIO;
	if (!hdmi->no_hpd)
		hdmi->bridge.ops |= DRM_BRIDGE_OP_HPD;
	hdmi->bridge.of_node = pdev->dev.of_node;
	hdmi->bridge.type = DRM_MODE_CONNECTOR_HDMIA;
	hdmi->bridge.vendor = "Synopsys";