From patchwork Fri Nov 16 17:18:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Priit Laes X-Patchwork-Id: 10687481 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 8958A13B5 for ; Sat, 17 Nov 2018 14:56:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7117B2B902 for ; Sat, 17 Nov 2018 14:56:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63D282B905; Sat, 17 Nov 2018 14:56:31 +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, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C83AD2B902 for ; Sat, 17 Nov 2018 14:56:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A3C789F3C; Sat, 17 Nov 2018 14:56:24 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from plaes.org (plaes.org [188.166.43.21]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3A21D6E70F for ; Fri, 16 Nov 2018 17:18:39 +0000 (UTC) Received: from localhost (157-101-157-37.dyn.estpak.ee [37.157.101.157]) by plaes.org (Postfix) with ESMTPSA id 7648E404F6; Fri, 16 Nov 2018 17:18:37 +0000 (UTC) From: Priit Laes To: Maxime Ripard , Chen-Yu Tsai , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] drm/sun4i: hdmi: Improve compatibility with non-hotplug capable connectors Date: Fri, 16 Nov 2018 19:18:29 +0200 Message-Id: <20181116171830.23465-1-plaes@plaes.org> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-Mailman-Approved-At: Sat, 17 Nov 2018 14:56:23 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mats Lundberg , Priit Laes , Priit Laes Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Priit Laes Even though HDMI connector features hotplug detect pin (HPD), there are devices that which do not support it. For these devices fall back to additional check on I2C bus. Of course, there might be also devices that do not wire DDC pins too, so we don't really know whether cable has been connected. Signed-off-by: Priit Laes Signed-off-by: Priit Laes --- drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c index 061d2e0d9011..bded09af1340 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_enc.c @@ -238,14 +238,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, + 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; } - return connector_status_connected; + if (!IS_ERR(hdmi->i2c) && drm_probe_ddc(hdmi->i2c)) + return connector_status_connected; + + cec_phys_addr_invalidate(hdmi->cec_adap); + + return connector_status_unknown; } static const struct drm_connector_funcs sun4i_hdmi_connector_funcs = {