All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] drm: bridge/dw-hdmi: cache edid data
@ 2016-01-08  9:02 Philipp Zabel
  2016-01-08  9:02 ` [PATCH 2/4] drm: bridge/dw-hdmi: remove unused code Philipp Zabel
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Philipp Zabel @ 2016-01-08  9:02 UTC (permalink / raw)
  To: Thierry Reding; +Cc: Russell King, kernel, dri-devel

From: Sascha Hauer <s.hauer@pengutronix.de>

Instead of rereading the edid data each time userspace asks for them,
read them once and cache them in the previously unused edid field in
struct dw_hdmi. When the connector is disconnected, drop the cached
edid data.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 drivers/gpu/drm/bridge/dw-hdmi.c | 43 ++++++++++++++++++++++++----------------
 1 file changed, 26 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index 6fbec99..b0ebf92 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -117,7 +117,7 @@ struct dw_hdmi {
 
 	int vic;
 
-	u8 edid[HDMI_EDID_LEN];
+	struct edid *edid;
 	bool cable_plugin;
 
 	bool phy_enabled;
@@ -1437,32 +1437,41 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force)
 	dw_hdmi_update_phy_mask(hdmi);
 	mutex_unlock(&hdmi->mutex);
 
-	return hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD ?
-		connector_status_connected : connector_status_disconnected;
+	if (hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD)
+		return connector_status_connected;
+
+	/* free previous EDID block */
+	if (hdmi->edid) {
+		drm_mode_connector_update_edid_property(connector, NULL);
+		kfree(hdmi->edid);
+		hdmi->edid = NULL;
+	}
+
+	return connector_status_disconnected;
 }
 
 static int dw_hdmi_connector_get_modes(struct drm_connector *connector)
 {
 	struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi,
 					     connector);
-	struct edid *edid;
 	int ret = 0;
 
-	if (!hdmi->ddc)
-		return 0;
-
-	edid = drm_get_edid(connector, hdmi->ddc);
-	if (edid) {
-		dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
-			edid->width_cm, edid->height_cm);
+	if (hdmi->ddc && !hdmi->edid) {
+		hdmi->edid = drm_get_edid(connector, hdmi->ddc);
+		if (hdmi->edid) {
+			hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(hdmi->edid);
+			hdmi->sink_has_audio = drm_detect_monitor_audio(hdmi->edid);
+			drm_mode_connector_update_edid_property(connector,
+								hdmi->edid);
+			dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n",
+				hdmi->edid->width_cm, hdmi->edid->height_cm);
+		}
+	}
 
-		hdmi->sink_is_hdmi = drm_detect_hdmi_monitor(edid);
-		hdmi->sink_has_audio = drm_detect_monitor_audio(edid);
-		drm_mode_connector_update_edid_property(connector, edid);
-		ret = drm_add_edid_modes(connector, edid);
+	if (hdmi->edid) {
+		ret = drm_add_edid_modes(connector, hdmi->edid);
 		/* Store the ELD */
-		drm_edid_to_eld(connector, edid);
-		kfree(edid);
+		drm_edid_to_eld(connector, hdmi->edid);
 	} else {
 		dev_dbg(hdmi->dev, "failed to get edid\n");
 	}
-- 
2.6.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2016-03-02 16:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-08  9:02 [PATCH 1/4] drm: bridge/dw-hdmi: cache edid data Philipp Zabel
2016-01-08  9:02 ` [PATCH 2/4] drm: bridge/dw-hdmi: remove unused code Philipp Zabel
2016-01-08  9:02 ` [PATCH 3/4] drm: bridge/dw-hdmi: detect initial connector state Philipp Zabel
2016-01-08 11:24   ` Russell King - ARM Linux
2016-01-08 11:40     ` Philipp Zabel
2016-03-02 16:35   ` Thierry Reding
2016-01-08  9:02 ` [PATCH 4/4] drm: bridge/dw-hdmi: use rx sense for plug detection if hpd is unreliable Philipp Zabel
2016-01-08 11:34   ` Russell King - ARM Linux

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.