From patchwork Mon Mar 4 13:06:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Priit Laes X-Patchwork-Id: 10837793 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1B591390 for ; Mon, 4 Mar 2019 13:07:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9B4682A1BC for ; Mon, 4 Mar 2019 13:07:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D1F02A1CC; Mon, 4 Mar 2019 13:07:14 +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.4 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ECF732A1AD for ; Mon, 4 Mar 2019 13:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=lkmengyYiGYzTn9LMoX6/B9cmQPrg+lBTJbNP3yGYbY=; b=k2M ZKlgJWcJny+FXil9PHPg7uxIP/tyofDYBgqIjmGFjt4sil+VAxJazeM4Qa8VtsBRok94Qs63aU/Sy yMER+Lg8zWb1rPc62VI0WlYD3Mr0gnIyRcDqKU7rpNos5bRWlxZIcjB3bbEYhvFJ90ZYDEGdtVkAw eJF3S8l+iH8vOxQz/6f5afb9XzGv41174dAXMxCLr37al2TWvE5qUPn1osX5JIoeMVhyJHW5FFClG vaajkS1bHoJebk/qRl9efrSbDEqzWOueqaMKI7fIzdl02D/eV/clmscYZTnrkdRr2119GSf4Trd5A SxJ+fj9/SE8bBYf5Jlqku4YGx22h7Tg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0nJE-0005cc-U8; Mon, 04 Mar 2019 13:07:08 +0000 Received: from plaes.org ([188.166.43.21]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h0nJC-0005c2-3R for linux-arm-kernel@lists.infradead.org; Mon, 04 Mar 2019 13:07:07 +0000 Received: from localhost (unknown [193.40.103.250]) by plaes.org (Postfix) with ESMTPSA id EDBC840960; Mon, 4 Mar 2019 13:06:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=plaes.org; s=mail; t=1551704792; bh=F4Cj8QjZPj4Qdf1avfLjzBR1P6PcKWxJtjJWPwy7J5k=; h=From:To:Cc:Subject:Date:From; b=ZrYFiFHaepmU/we/IfrDK4OqYLCwm8X+GIBaoZ+S98j3ixqagi0dNxwUg4AepEA5G LqRTmBtdnwchPUaXD8s+KpVrEcdgtb66zUBa4a1sOUZ4INXgzet4K3CVUxXPKZroXr NwnSmIO9w5y7xqwv6MHOHO55d1ykjcNADUQe3Zg2D6OG0yW300u3GHNa1fo4cMhClb bfSVBhgk3aqrBzXankYIZCTRP4EV8GRbJzLva8eeY4CTgmWYXpmzh3VnSkdXkpW5ZC v9gurgJRoiY3LRe0r1cStaZxxFWnYY2UzyTve3c/zp2sHKhTsbYhy4JcGDm5Q9/K5n TtVRD0kFYLeyA== From: Priit Laes To: Maxime Ripard , David Airlie , Daniel Vetter , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RESEND PATCH] drm/sun4i: hdmi: Improve compatibility with hpd-less HDMI displays Date: Mon, 4 Mar 2019 15:06:16 +0200 Message-Id: <20190304130616.27525-1-plaes@plaes.org> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190304_050706_424423_FB3D287E X-CRM114-Status: GOOD ( 12.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-sunxi@googlegroups.com, Priit Laes , Russell King MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Priit Laes Even though HDMI connector features hotplug detect pin (HPD), there are older devices which do not support it. For these devices fall back to additional check on I2C bus to probe for EDID data. One known example is HDMI/DVI display with following edid: $ xxd -p display.edid 00ffffffffffff0005a1e00301000000150f0103800f05780a0f6ea05748 9a2610474f200000010101010101010101010101010101012a08804520e0 0b1020004000953600000018000000fd0034441a2403000a202020202020 0000001000310a20202020202020202020200000001000002a4030701300 782d1100001e006b $ edid-decode display.edid EDID version: 1.3 Manufacturer: AMA Model 3e0 Serial Number 1 Digital display Maximum image size: 15 cm x 5 cm Gamma: 2.20 RGB color display First detailed timing is preferred timing Display x,y Chromaticity: Red: 0.6250, 0.3398 Green: 0.2841, 0.6044 Blue: 0.1494, 0.0644 White: 0.2802, 0.3105 Established timings supported: 640x480@60Hz 4:3 HorFreq: 31469 Hz Clock: 25.175 MHz Standard timings supported: Detailed mode: Clock 20.900 MHz, 149 mm x 54 mm 640 672 672 709 hborder 0 480 484 484 491 vborder 0 -hsync -vsync VertFreq: 60 Hz, HorFreq: 29478 Hz Monitor ranges (GTF): 52-68Hz V, 26-36kHz H, max dotclock 30MHz Dummy block Dummy block Checksum: 0x6b (valid) Now, current implementation is still flawed, as HDMI uses the HPD signal to indicate that the source should re-read the EDID due to change in device capabilities. With current HPD polling implementation we would most certainly miss those notifications as one can try just swapping two HDMI monitors really fast. Proper fix would be skipping the HPD pin detection and relying on just EDID fetching and acting on its changes. CC: Russell King Signed-off-by: Priit Laes --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 416da5376701..44d5d50b7ada 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -242,14 +242,18 @@ sun4i_hdmi_connector_detect(struct drm_connector *connector, bool force) struct sun4i_hdmi *hdmi = drm_connector_to_sun4i_hdmi(connector); unsigned long reg; - if (readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg, - reg & SUN4I_HDMI_HPD_HIGH, - 0, 500000)) { - cec_phys_addr_invalidate(hdmi->cec_adap); - return connector_status_disconnected; - } - - return connector_status_connected; + /* TODO: Drop HPD polling and instead keep track of EDID changes */ + if (!readl_poll_timeout(hdmi->base + SUN4I_HDMI_HPD_REG, reg, + reg & SUN4I_HDMI_HPD_HIGH, + 0, 500000)) + return connector_status_connected; + + /* Fall back to EDID in case display does not support HPD */ + if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c)) + return connector_status_connected; + + cec_phys_addr_invalidate(hdmi->cec_adap); + return connector_status_disconnected; } static const struct drm_connector_funcs sun4i_hdmi_connector_funcs = {