Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753934AbbHGN7s (ORCPT ); Fri, 7 Aug 2015 09:59:48 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:42804 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753556AbbHGN7q (ORCPT ); Fri, 7 Aug 2015 09:59:46 -0400 From: Sascha Hauer To: Thierry Reding Cc: Philipp Zabel , Russell King , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Sascha Hauer Subject: [PATCH 1/2] drm: bridge/dw_hdmi: Cache edid data Date: Fri, 7 Aug 2015 15:59:20 +0200 Message-Id: <1438955961-27232-2-git-send-email-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1438955961-27232-1-git-send-email-s.hauer@pengutronix.de> References: <1438955961-27232-1-git-send-email-s.hauer@pengutronix.de> X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2540 Lines: 84 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. This makes the code a little bit more efficient. Signed-off-by: Sascha Hauer --- drivers/gpu/drm/bridge/dw_hdmi.c | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c index 816d104..8d9b53c 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; @@ -1386,28 +1386,39 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, connector); - 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_disconnected; + + if (hdmi->ddc) { + if (hdmi->edid) { + drm_mode_connector_update_edid_property(connector, + NULL); + kfree(hdmi->edid); + } + + hdmi->edid = drm_get_edid(connector, hdmi->ddc); + if (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); + } + } + + return connector_status_connected; } 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); - - drm_mode_connector_update_edid_property(connector, edid); - ret = drm_add_edid_modes(connector, edid); - kfree(edid); + if (hdmi->edid) { + ret = drm_add_edid_modes(connector, hdmi->edid); + drm_edid_to_eld(connector, hdmi->edid); } else { dev_dbg(hdmi->dev, "failed to get edid\n"); } -- 2.4.6 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/