From patchwork Wed Nov 29 15:12:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10082495 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 B633860311 for ; Wed, 29 Nov 2017 15:13:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A0DB429993 for ; Wed, 29 Nov 2017 15:13:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 954A7299E6; Wed, 29 Nov 2017 15:13:07 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 3A56D29993 for ; Wed, 29 Nov 2017 15:13:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E6336E945; Wed, 29 Nov 2017 15:13:06 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout2.w1.samsung.com (mailout2.w1.samsung.com [210.118.77.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id A74B26E942 for ; Wed, 29 Nov 2017 15:13:04 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20171129151302euoutp02b5cb0670d38a1e30e50fee9b9a6773ac~7lzutEGtK3047930479euoutp02V; Wed, 29 Nov 2017 15:13:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20171129151302euoutp02b5cb0670d38a1e30e50fee9b9a6773ac~7lzutEGtK3047930479euoutp02V DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1511968382; bh=0fsHZlhR0PCopZvINOtawhwW/jm5QkC3LcUyIpwC+sM=; h=From:To:Cc:Subject:Date:In-reply-to:References:From; b=KJlDsyOvE1bLIYqSaEajW60g9QjXovF/7sCE7mQ0yZlHcvNtMnI/TLwCx/bcnBjlh rRLqlxIuxVw3b/JT3BD+gUACxjJa+38qpNisSxmWhYBx6oWHItRdLo9aNG81zb07Fe 24quSYhtMQr7Sjpw5MnVO77HvPjbX/nNCvMOqD8A= Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20171129151301eucas1p1227832b5a0642d13039d57bfdba8e0e6~7lzt-d5ZU2993829938eucas1p14; Wed, 29 Nov 2017 15:13:01 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 7F.2D.12743.D7ECE1A5; Wed, 29 Nov 2017 15:13:01 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20171129151300eucas1p21e7b88b86dda95248be010f189c29dba~7lztSoP3P2617926179eucas1p2U; Wed, 29 Nov 2017 15:13:00 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d0000031c7-8e-5a1ece7d0d1f Received: from eusync3.samsung.com ( [203.254.199.213]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id CD.A4.18832.C7ECE1A5; Wed, 29 Nov 2017 15:13:00 +0000 (GMT) Received: from AMDC2075.DIGITAL.local ([106.120.51.25]) by eusync3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P060009VQ9EI060@eusync3.samsung.com>; Wed, 29 Nov 2017 15:13:00 +0000 (GMT) From: Maciej Purski To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] drm/bridge/sii8620: fix HDMI cable connection to dongle Date: Wed, 29 Nov 2017 16:12:48 +0100 Message-id: <1511968368-30884-2-git-send-email-m.purski@samsung.com> X-Mailer: git-send-email 2.7.4 In-reply-to: <1511968368-30884-1-git-send-email-m.purski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrDIsWRmVeSWpSXmKPExsWy7djP87q15+SiDFY/kbK4te4cq0XvuZNM Fk0db1ktNs5Yz2px5et7NovOiUvYLS7vmsNmseDlLRaLtUfusjtwelzu62XymN0xk9Vj+7cH rB73u48zefRtWcXo8XmTXABbFJdNSmpOZllqkb5dAlfG/pVKBRNVKl7sOsTewPhMtouRk0NC wERixYJ/TBC2mMSFe+vZuhi5OIQEljJKfFl1nhHC+cwosaT1ChNMR/P/RnaIxDJGidtbr0A5 /xklZk8/x9LFyMHBJqAlsaY9HqRBREBZ4u/EVWCTmAWuMkmcvLwdbJKwgI/Enq+HwWwWAVWJ S382soLYvAIuEo9vrmaE2CYncfNcJzOIzSngKtF8azMryCAJgTVsEr27FzFDFLlIzG75DGUL S7w6voUdwpaR6Ow4CHV2tcTFr7vYIOwaicbbG6BqrCU+T9oC1ssswCcxadt0ZpAHJAR4JTra hCBKPCT61q9lgbAdJS58+QINoxmMEhPeb2KcwCi9gJFhFaNIamlxbnpqsalecWJucWleul5y fu4mRmAcn/53/OsOxqXHrA4xCnAwKvHwaqyWjRJiTSwrrsw9xCjBwawkwquwWy5KiDclsbIq tSg/vqg0J7X4EKM0B4uSOK9tVFukkEB6YklqdmpqQWoRTJaJg1OqgXGt9o7MR3YGkw23mDf9 ly/98NC1yEU9616PsVFxtqbQ9U5rhV0bO28vidiTmLfX0/d/oXHvztNXOX/sfSlvcCh69YvX b7ieLo41Of9CaSfXMpePt/18N6Q/z1gUUurI37dxO+dfRctzCxcsFrxh8HVP5/zNbw+8kT2Y cvnPhpUxZ7MDdltWXbmjxFKckWioxVxUnAgATCTjWt8CAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrALMWRmVeSWpSXmKPExsVy+t/xq7o15+SiDOZ+sbC4te4cq0XvuZNM Fk0db1ktNs5Yz2px5et7NovOiUvYLS7vmsNmseDlLRaLtUfusjtwelzu62XymN0xk9Vj+7cH rB73u48zefRtWcXo8XmTXABbFJdNSmpOZllqkb5dAlfG/pVKBRNVKl7sOsTewPhMtouRk0NC wESi+X8jO4QtJnHh3nq2LkYuDiGBJYwS/+ecYwZJCAk0Mkm07GDsYuTgYBPQkljTHg8SFhFQ lvg7cRUjSD2zwE0mib9n97KCJIQFfCT2fD3MBGKzCKhKXPqzESzOK+Ai8fjmakaIZXISN891 gs3nFHCVaL61mRVil4vE3IkfWCcw8i5gZFjFKJJaWpybnltsqFecmFtcmpeul5yfu4kRGG7b jv3cvIPx0sbgQ4wCHIxKPLwaq2WjhFgTy4orcw8xSnAwK4nwKuyWixLiTUmsrEotyo8vKs1J LT7EKM3BoiTO27tndaSQQHpiSWp2ampBahFMlomDU6qBcVHI9s+Cvd/ubvjsfiWVbWbxgc2R T444Oj5YPjv5tK2ugZ3zMbcPHFf+xZ/dvbpGw3Idu8Br67X/P+2xu1tX908s7ANr6+lDdjEB jJK9amcLJz5bcTFpz8MszRfhL7bOfaU333RB7fxosel5xst+Xjt/brNJx8RazbbFng+W73Cb Ubh6kZPjpQNKLMUZiYZazEXFiQCX/2ZVMwIAAA== X-CMS-MailID: 20171129151300eucas1p21e7b88b86dda95248be010f189c29dba X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20171129151300eucas1p21e7b88b86dda95248be010f189c29dba X-RootMTR: 20171129151300eucas1p21e7b88b86dda95248be010f189c29dba References: <1511968368-30884-1-git-send-email-m.purski@samsung.com> Cc: Bartlomiej Zolnierkiewicz , David Airlie , linux-kernel@vger.kernel.org, Maciej Purski , Laurent Pinchart , Marek Szyprowski 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 MHL bridge is usually connected to TV via MHL dongle. Currently plugging HDMI cable to dongle is handled improperly. This patch fixes it. Signed-off-by: Maciej Purski --- drivers/gpu/drm/bridge/sil-sii8620.c | 49 ++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c index 35ccc90..857d2cb5 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -78,6 +78,7 @@ struct sii8620 { u8 devcap[MHL_DCAP_SIZE]; u8 xdevcap[MHL_XDC_SIZE]; u8 avif[HDMI_INFOFRAME_SIZE(AVI)]; + bool feature_complete; struct edid *edid; unsigned int gen2_write_burst:1; enum sii8620_mt_state mt_state; @@ -470,7 +471,7 @@ static void sii8620_update_array(u8 *dst, u8 *src, int count) } } -static void sii8620_sink_detected(struct sii8620 *ctx, int ret) +static void sii8620_hpd_plugged(struct sii8620 *ctx) { static const char * const sink_str[] = { [SINK_NONE] = "NONE", @@ -481,15 +482,13 @@ static void sii8620_sink_detected(struct sii8620 *ctx, int ret) char sink_name[20]; struct device *dev = ctx->dev; - if (ret < 0) - return; - sii8620_fetch_edid(ctx); if (!ctx->edid) { dev_err(ctx->dev, "Cannot fetch EDID\n"); sii8620_mhl_disconnected(ctx); return; } + sii8620_set_upstream_edid(ctx); if (drm_detect_hdmi_monitor(ctx->edid)) ctx->sink_type = SINK_HDMI; @@ -502,15 +501,6 @@ static void sii8620_sink_detected(struct sii8620 *ctx, int ret) sink_str[ctx->sink_type], sink_name); } -static void sii8620_edid_read(struct sii8620 *ctx, int ret) -{ - if (ret < 0) - return; - - sii8620_set_upstream_edid(ctx); - sii8620_enable_hpd(ctx); -} - static void sii8620_mr_devcap(struct sii8620 *ctx) { u8 dcap[MHL_DCAP_SIZE]; @@ -1490,6 +1480,15 @@ static void sii8620_set_mode(struct sii8620 *ctx, enum sii8620_mode mode) ); } +static void sii8620_hpd_unplugged(struct sii8620 *ctx) +{ + sii8620_disable_hpd(ctx); + ctx->sink_type = SINK_NONE; + ctx->feature_complete = false; + kfree(ctx->edid); + ctx->edid = NULL; +} + static void sii8620_disconnect(struct sii8620 *ctx) { sii8620_disable_gen2_write_burst(ctx); @@ -1517,7 +1516,7 @@ static void sii8620_disconnect(struct sii8620 *ctx) REG_MHL_DP_CTL6, 0x2A, REG_MHL_DP_CTL7, 0x03 ); - sii8620_disable_hpd(ctx); + sii8620_hpd_unplugged(ctx); sii8620_write_seq_static(ctx, REG_M3_CTRL, VAL_M3_CTRL_MHL3_VALUE, REG_MHL_COC_CTL1, 0x07, @@ -1566,9 +1565,6 @@ static void sii8620_disconnect(struct sii8620 *ctx) memset(ctx->devcap, 0, sizeof(ctx->devcap)); memset(ctx->xdevcap, 0, sizeof(ctx->xdevcap)); ctx->cbus_status = 0; - ctx->sink_type = SINK_NONE; - kfree(ctx->edid); - ctx->edid = NULL; sii8620_mt_cleanup(ctx); } @@ -1661,7 +1657,6 @@ static void sii8620_status_changed_path(struct sii8620 *ctx) | MHL_DST_LM_PATH_ENABLED); if (!sii8620_is_mhl3(ctx)) sii8620_mt_read_devcap(ctx, false); - sii8620_mt_set_cont(ctx, sii8620_sink_detected); } else { sii8620_mt_write_stat(ctx, MHL_DST_REG(LINK_MODE), MHL_DST_LM_CLK_MODE_NORMAL); @@ -1764,8 +1759,11 @@ static void sii8620_msc_mr_set_int(struct sii8620 *ctx) } if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_REQ) sii8620_send_features(ctx); - if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_COMPLETE) - sii8620_edid_read(ctx, 0); + if (ints[MHL_INT_RCHANGE] & MHL_INT_RC_FEAT_COMPLETE) { + ctx->feature_complete = true; + if (ctx->edid) + sii8620_enable_hpd(ctx); + } } static struct sii8620_mt_msg *sii8620_msc_msg_first(struct sii8620 *ctx) @@ -1840,6 +1838,13 @@ static void sii8620_irq_msc(struct sii8620 *ctx) if (stat & BIT_CBUS_MSC_MR_WRITE_STAT) sii8620_msc_mr_write_stat(ctx); + if (stat & BIT_CBUS_HPD_CHG) { + if (ctx->cbus_status & BIT_CBUS_STATUS_CBUS_HPD) + sii8620_hpd_plugged(ctx); + else + sii8620_hpd_unplugged(ctx); + } + if (stat & BIT_CBUS_MSC_MR_SET_INT) sii8620_msc_mr_set_int(ctx); @@ -1951,11 +1956,11 @@ static void sii8620_irq_ddc(struct sii8620 *ctx) if (stat & BIT_DDC_CMD_DONE) { sii8620_write(ctx, REG_INTR3_MASK, 0); - if (sii8620_is_mhl3(ctx)) + if (sii8620_is_mhl3(ctx) && !ctx->feature_complete) sii8620_mt_set_int(ctx, MHL_INT_REG(RCHANGE), MHL_INT_RC_FEAT_REQ); else - sii8620_edid_read(ctx, 0); + sii8620_enable_hpd(ctx); } sii8620_write(ctx, REG_INTR3, stat); }