From patchwork Thu Aug 4 10:44:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jose Abreu X-Patchwork-Id: 9264673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ED3176048B for ; Fri, 5 Aug 2016 00:39:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFC2B27FAC for ; Fri, 5 Aug 2016 00:39:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D49F228415; Fri, 5 Aug 2016 00:39:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3262A27FAC for ; Fri, 5 Aug 2016 00:39:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4A2B96EACE; Fri, 5 Aug 2016 00:38:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtprelay.synopsys.com (smtprelay2.synopsys.com [198.182.60.111]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4D9A76E933 for ; Thu, 4 Aug 2016 10:45:28 +0000 (UTC) Received: from us02secmta1.synopsys.com (us02secmta1.synopsys.com [10.12.235.96]) by smtprelay.synopsys.com (Postfix) with ESMTP id 0436C10C0DAA; Thu, 4 Aug 2016 03:45:28 -0700 (PDT) Received: from us02secmta1.internal.synopsys.com (us02secmta1.internal.synopsys.com [127.0.0.1]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id EABCC4E213; Thu, 4 Aug 2016 03:45:27 -0700 (PDT) Received: from mailhost.synopsys.com (mailhost1.synopsys.com [10.12.238.239]) by us02secmta1.internal.synopsys.com (Service) with ESMTP id 8FDCF4E202; Thu, 4 Aug 2016 03:45:27 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id 6E90B24F; Thu, 4 Aug 2016 03:45:27 -0700 (PDT) Received: from synopsys-Macmini.mshome.net (joabreu-e7440.internal.synopsys.com [10.107.19.32]) by mailhost.synopsys.com (Postfix) with ESMTP id 1232F23A; Thu, 4 Aug 2016 03:45:24 -0700 (PDT) From: Jose Abreu To: dri-devel@lists.freedesktop.org Subject: [PATCH 3/3 v3] drm: bridge/dw-hdmi: Move edid reading to .detect() callback Date: Thu, 4 Aug 2016 11:44:51 +0100 Message-Id: <1bbffb944fb9ce0363f5544db31baf2a911c1c55.1470306826.git.joabreu@synopsys.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: X-Mailman-Approved-At: Fri, 05 Aug 2016 00:36:43 +0000 Cc: Jose Abreu , Fabio Estevam , Daniel Vetter , Carlos Palminha , linux-kernel@vger.kernel.org, Russell King , Thierry Reding , Vladimir Zapolskiy X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP When running HDMI compliance tests we noticed that sometimes the edid changes but the get_modes() function is not called so the edid is not updated. Moving the edid reading to the detect() callback ensures that the edid is correctly updated after an hotplug. Signed-off-by: Jose Abreu Cc: Carlos Palminha Cc: Archit Taneja Cc: David Airlie Cc: Russell King Cc: Fabio Estevam Cc: Daniel Vetter Cc: Takashi Iwai Cc: Vladimir Zapolskiy Cc: Thierry Reding Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- This patch was only introduced in v3. drivers/gpu/drm/bridge/dw-hdmi.c | 67 +++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c index 9122a20..c795888 100644 --- a/drivers/gpu/drm/bridge/dw-hdmi.c +++ b/drivers/gpu/drm/bridge/dw-hdmi.c @@ -31,8 +31,6 @@ #include "dw-hdmi.h" #include "dw-hdmi-audio.h" -#define HDMI_EDID_LEN 512 - #define RGB 0 #define YCBCR444 1 #define YCBCR422_16BITS 2 @@ -117,7 +115,7 @@ struct dw_hdmi { int vic; - u8 edid[HDMI_EDID_LEN]; + struct edid *edid; bool cable_plugin; bool phy_enabled; @@ -1457,6 +1455,7 @@ dw_hdmi_connector_detect(struct drm_connector *connector, bool force) { struct dw_hdmi *hdmi = container_of(connector, struct dw_hdmi, connector); + bool connected; mutex_lock(&hdmi->mutex); hdmi->force = DRM_FORCE_UNSPECIFIED; @@ -1464,7 +1463,40 @@ 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 ? + connected = hdmi_readb(hdmi, HDMI_PHY_STAT0) & HDMI_PHY_HPD; + + if (connected && hdmi->ddc) { + if (hdmi->edid) { + drm_mode_connector_update_edid_property(connector, + NULL); + kfree(hdmi->edid); + hdmi->edid = NULL; + } + + hdmi->edid = drm_get_edid(connector, hdmi->ddc); + if (hdmi->edid) { + dev_dbg(hdmi->dev, "got edid: width[%d] x height[%d]\n", + hdmi->edid->width_cm, + hdmi->edid->height_cm); + drm_mode_connector_update_edid_property(connector, + hdmi->edid); + drm_edid_to_eld(connector, hdmi->edid); + + hdmi->sink_is_hdmi = + drm_detect_hdmi_monitor(hdmi->edid); + hdmi->sink_has_audio = + drm_detect_monitor_audio(hdmi->edid); + hdmi->sink_supports_ai = + connector->eld[5] & (0x1 << 1); + } else { + dev_dbg(hdmi->dev, "failed to get edid\n"); + hdmi->sink_is_hdmi = false; + hdmi->sink_has_audio = false; + hdmi->sink_supports_ai = false; + } + } + + return connected ? connector_status_connected : connector_status_disconnected; } @@ -1472,33 +1504,10 @@ 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); - - 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); - /* Store the ELD */ - drm_edid_to_eld(connector, edid); - kfree(edid); - - hdmi->sink_supports_ai = connector->eld[5] & (0x1 << 1); - } else { - dev_dbg(hdmi->dev, "failed to get edid\n"); - hdmi->sink_is_hdmi = false; - hdmi->sink_has_audio = false; - hdmi->sink_supports_ai = false; - } - + if (hdmi->edid) + ret = drm_add_edid_modes(connector, hdmi->edid); return ret; }