Skip to contentSkip to conversation

drm: bridge: dw_hdmi: Fix ELD is not updated issue

PATCH Superseded Sandor Yu 2 participants 3 messages Jul 26, 2023 – Aug 4, 2023

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Sandor Yu

author
#0 lore raw

PATCH 1/1 drm: bridge: dw_hdmi: Fix ELD is not updated issue

The ELD (EDID-Like Data) is not updated when the HDMI cable is plugged into different HDMI monitors.
This is because the EDID is not updated in the HDMI HPD function. As a result, the ELD data remains unchanged and may not reflect the capabilities of the newly connected HDMI sink device.

To address this issue, the handle_plugged_change function should move to the bridge_atomic_enable and bridge_atomic_disable functions. Make sure the EDID is properly updated before updating ELD.

---
 drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 ++++-----------------
 1 file changed, 4 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +4 -17
index 9a3db5234a0e0..6fa4848591226 100644
@@ -196,7 +196,6 @@ struct dw_hdmi {
 
 	hdmi_codec_plugged_cb plugged_cb;
 	struct device *codec_dev;
-	enum drm_connector_status last_connector_result;
 };
 
 #define HDMI_IH_PHY_STAT0_RX_SENSE \
@@ -235,7 +234,7 @@ int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn,
 	mutex_lock(&hdmi->mutex);
 	hdmi->plugged_cb = fn;
 	hdmi->codec_dev = codec_dev;
-	plugged = hdmi->last_connector_result == connector_status_connected;
+	plugged = hdmi->connector.status == connector_status_connected;
 	handle_plugged_change(hdmi, plugged);
 	mutex_unlock(&hdmi->mutex);
 
@@ -2446,20 +2445,7 @@ static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi)
 
 static enum drm_connector_status dw_hdmi_detect(struct dw_hdmi *hdmi)
 {
-	enum drm_connector_status result;
-
-	result = hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
-
-	mutex_lock(&hdmi->mutex);
-	if (result != hdmi->last_connector_result) {
-		dev_dbg(hdmi->dev, "read_hpd result: %d", result);
-		handle_plugged_change(hdmi,
-				      result == connector_status_connected);
-		hdmi->last_connector_result = result;
-	}
-	mutex_unlock(&hdmi->mutex);
-
-	return result;
+	return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
 }
 
 static struct edid *dw_hdmi_get_edid(struct dw_hdmi *hdmi,
@@ -2958,6 +2944,7 @@ static void dw_hdmi_bridge_atomic_disable(struct drm_bridge *bridge,
 	hdmi->curr_conn = NULL;
 	dw_hdmi_update_power(hdmi);
 	dw_hdmi_update_phy_mask(hdmi);
+	handle_plugged_change(hdmi, false);
 	mutex_unlock(&hdmi->mutex);
 }
 
@@ -2976,6 +2963,7 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,
 	hdmi->curr_conn = connector;
 	dw_hdmi_update_power(hdmi);
 	dw_hdmi_update_phy_mask(hdmi);
+	handle_plugged_change(hdmi, true);
 	mutex_unlock(&hdmi->mutex);
 }
 
@@ -3369,7 +3357,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
 	hdmi->rxsense = true;
 	hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE);
 	hdmi->mc_clkdis = 0x7f;
-	hdmi->last_connector_result = connector_status_disconnected;
 
 	mutex_init(&hdmi->mutex);
 	mutex_init(&hdmi->audio_mutex);
Signature · 1 line
2.34.1
#1 lore raw

Hi,

Quoted 28 lines · Sandor Yu

The ELD (EDID-Like Data) is not updated when the HDMI cable is plugged into different HDMI monitors.
This is because the EDID is not updated in the HDMI HPD function. As a result, the ELD data remains unchanged and may not reflect the capabilities of the newly connected HDMI sink device.

To address this issue, the handle_plugged_change function should move to the bridge_atomic_enable and bridge_atomic_disable functions. Make sure the EDID is properly updated before updating ELD.

---
  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 ++++-----------------
  1 file changed, 4 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
index 9a3db5234a0e0..6fa4848591226 100644
@@ -196,7 +196,6 @@ struct dw_hdmi {
 
  	hdmi_codec_plugged_cb plugged_cb;
  	struct device *codec_dev;
-	enum drm_connector_status last_connector_result;
  };
 
  #define HDMI_IH_PHY_STAT0_RX_SENSE \

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn, · line 237

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -1
@@ -235,7 +234,7 @@ int dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb fn,
  	mutex_lock(&hdmi->mutex);
  	hdmi->plugged_cb = fn;
  	hdmi->codec_dev = codec_dev;
-	plugged = hdmi->last_connector_result == connector_status_connected;
+	plugged = hdmi->connector.status == connector_status_connected;

Please use curr_conn instead, connector is not always valid.

Quoted 42 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +3 -14
  	handle_plugged_change(hdmi, plugged);
  	mutex_unlock(&hdmi->mutex);
 
@@ -2446,20 +2445,7 @@ static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi)
 
  static enum drm_connector_status dw_hdmi_detect(struct dw_hdmi *hdmi)
  {
-	enum drm_connector_status result;
-
-	result = hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
-
-	mutex_lock(&hdmi->mutex);
-	if (result != hdmi->last_connector_result) {
-		dev_dbg(hdmi->dev, "read_hpd result: %d", result);
-		handle_plugged_change(hdmi,
-				      result == connector_status_connected);
-		hdmi->last_connector_result = result;
-	}
-	mutex_unlock(&hdmi->mutex);
-
-	return result;
+	return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
  }
 
  static struct edid *dw_hdmi_get_edid(struct dw_hdmi *hdmi,
@@ -2958,6 +2944,7 @@ static void dw_hdmi_bridge_atomic_disable(struct drm_bridge *bridge,
  	hdmi->curr_conn = NULL;
  	dw_hdmi_update_power(hdmi);
  	dw_hdmi_update_phy_mask(hdmi);
+	handle_plugged_change(hdmi, false);
  	mutex_unlock(&hdmi->mutex);
  }
 
@@ -2976,6 +2963,7 @@ static void dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,
  	hdmi->curr_conn = connector;
  	dw_hdmi_update_power(hdmi);
  	dw_hdmi_update_phy_mask(hdmi);
+	handle_plugged_change(hdmi, true);
  	mutex_unlock(&hdmi->mutex);
  }
 

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, · line 3362

Quoted 7 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
@@ -3369,7 +3357,6 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
  	hdmi->rxsense = true;
  	hdmi->phy_mask = (u8)~(HDMI_PHY_HPD | HDMI_PHY_RX_SENSE);
  	hdmi->mc_clkdis = 0x7f;
-	hdmi->last_connector_result = connector_status_disconnected;
 
  	mutex_init(&hdmi->mutex);
  	mutex_init(&hdmi->audio_mutex);

Thanks,
Neil

author
#2 lore raw

Hi Neil,

Thanks for your comments,

Quoted 34 lines

Hi,

Quoted 28 lines · Sandor Yu

The ELD (EDID-Like Data) is not updated when the HDMI cable is plugged into different HDMI monitors.
This is because the EDID is not updated in the HDMI HPD function. As a result, the ELD data remains unchanged and may not reflect the capabilities of the newly connected HDMI sink device.

To address this issue, the handle_plugged_change function should move to the bridge_atomic_enable and bridge_atomic_disable functions. Make sure the EDID is properly updated before updating ELD.

---
  drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 21 ++++-----------------
  1 file changed, 4 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
index 9a3db5234a0e0..6fa4848591226 100644
@@ -196,7 +196,6 @@ struct dw_hdmi {
 
      hdmi_codec_plugged_cb plugged_cb;
      struct device *codec_dev;
-     enum drm_connector_status last_connector_result;
  };
 
  #define HDMI_IH_PHY_STAT0_RX_SENSE \ @@ -235,7 +234,7 @@ int
Quoted 1 line

dw_hdmi_set_plugged_cb(struct dw_hdmi *hdmi, hdmi_codec_plugged_cb

fn,

Quoted 8 lines
Quoted 4 lines
      mutex_lock(&hdmi->mutex);
      hdmi->plugged_cb = fn;
      hdmi->codec_dev = codec_dev;

- plugged = hdmi->last_connector_result ==

connector_status_connected;

Quoted 1 line

+ plugged = hdmi->connector.status == connector_status_connected;

Please use curr_conn instead, connector is not always valid.

curr_conn is NULL when dw_hdmi_set_plugged_cb is called by dw_hdmi_bridge_atomic_disable. I will add the variable of last_connector_resul back to driver later.

B.R
Sandor

Quoted 60 lines

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_update_phy_mask(struct · line 2447

Quoted 8 lines
      handle_plugged_change(hdmi, plugged);
      mutex_unlock(&hdmi->mutex);
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
@@ -2446,20 +2445,7 @@ static void dw_hdmi_update_phy_mask(struct
 dw_hdmi *hdmi)
 
  static enum drm_connector_status dw_hdmi_detect(struct dw_hdmi

*hdmi)

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void dw_hdmi_update_phy_mask(struct dw_hdmi *hdmi)

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -9
  {
-     enum drm_connector_status result;
-
-     result = hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
-
-     mutex_lock(&hdmi->mutex);
-     if (result != hdmi->last_connector_result) {
-             dev_dbg(hdmi->dev, "read_hpd result: %d", result);
-             handle_plugged_change(hdmi,
-                                   result ==

connector_status_connected);

Quoted 10 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -5
-             hdmi->last_connector_result = result;
-     }
-     mutex_unlock(&hdmi->mutex);
-
-     return result;
+     return hdmi->phy.ops->read_hpd(hdmi, hdmi->phy.data);
  }
 

static struct edid *dw_hdmi_get_edid(struct dw_hdmi *hdmi, @@
-2958,6 +2944,7 @@ static void dw_hdmi_bridge_atomic_disable(struct

drm_bridge *bridge,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c static void

Quoted 8 lines
      hdmi->curr_conn = NULL;
      dw_hdmi_update_power(hdmi);
      dw_hdmi_update_phy_mask(hdmi);
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -0
+     handle_plugged_change(hdmi, false);
      mutex_unlock(&hdmi->mutex);
  }
@@ -2976,6 +2963,7 @@ static void

dw_hdmi_bridge_atomic_enable(struct drm_bridge *bridge,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c struct dw_hdmi *dw_hdmi_probe(struct

Quoted 8 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +1 -0
      hdmi->curr_conn = connector;
      dw_hdmi_update_power(hdmi);
      dw_hdmi_update_phy_mask(hdmi);
+     handle_plugged_change(hdmi, true);
      mutex_unlock(&hdmi->mutex);
  }
 
@@ -3369,7 +3357,6 @@ struct dw_hdmi *dw_hdmi_probe(struct

platform_device *pdev,

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c struct dw_hdmi *dw_hdmi_probe(struct · line 3358

Quoted 2 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -0
      hdmi->rxsense = true;
      hdmi->phy_mask = (u8)~(HDMI_PHY_HPD |

HDMI_PHY_RX_SENSE);

drivers/gpu/drm/bridge/synopsys/dw-hdmi.c struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev, · line 3362

Quoted 5 lines
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c +0 -1
      hdmi->mc_clkdis = 0x7f;
-     hdmi->last_connector_result = connector_status_disconnected;
 
      mutex_init(&hdmi->mutex);
      mutex_init(&hdmi->audio_mutex);

Thanks,
Neil