From patchwork Tue Jan 23 11:15:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maciej Purski X-Patchwork-Id: 10180321 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 47DD2601D5 for ; Tue, 23 Jan 2018 13:32:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 36C0F28066 for ; Tue, 23 Jan 2018 13:32:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B26B286BE; Tue, 23 Jan 2018 13:32:17 +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 0825428066 for ; Tue, 23 Jan 2018 13:32:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7CAF6E3B2; Tue, 23 Jan 2018 13:31:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by gabe.freedesktop.org (Postfix) with ESMTPS id 61F9889B7D for ; Tue, 23 Jan 2018 11:15:28 +0000 (UTC) Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20180123111525euoutp018fee9a9c86b983e75b205bdf91c6fc58~MbC97MIER1617416174euoutp01H; Tue, 23 Jan 2018 11:15:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180123111525euoutp018fee9a9c86b983e75b205bdf91c6fc58~MbC97MIER1617416174euoutp01H DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1516706125; bh=nFhSaV383ino2fiHEB8J6rEiD14U0eGpa4KXPFmmjbs=; h=From:To:Cc:Subject:Date:References:From; b=GRSx6ChFHLiVYfdObJUikquYSqvA4OmzH8qSdFtR/gaQjUK3xytx5SCk29282WR9z RvBEhqA0HaFQldFlIlyT2VBB9zRuxcSc57h8JONQHEGHX4jZ5mI3mdcQWFgvliIYWJ bqeB+6JSCQhc66E3prTVyp8FUi3wERzq4rUs74AA= Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180123111524eucas1p22d35212777d488dcb36c77b9066bf683~MbC8-rwPD0662106621eucas1p2p; Tue, 23 Jan 2018 11:15:24 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2.samsung.com (EUCPMTA) with SMTP id DF.FB.12907.C49176A5; Tue, 23 Jan 2018 11:15:24 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20180123111523eucas1p2c4321e8ffc6425bec8725e2c60fec9e5~MbC8JVVUM0479304793eucas1p2g; Tue, 23 Jan 2018 11:15:23 +0000 (GMT) X-AuditID: cbfec7f1-f793a6d00000326b-9e-5a67194c01fe Received: from eusync4.samsung.com ( [203.254.199.214]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id F5.80.20118.B49176A5; Tue, 23 Jan 2018 11:15:23 +0000 (GMT) Received: from AMDC2075.DIGITAL.local ([106.120.51.25]) by eusync4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0P3000LEM9XIW2C0@eusync4.samsung.com>; Tue, 23 Jan 2018 11:15:23 +0000 (GMT) From: Maciej Purski To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/bridge/sii8620: fix display modes validation Date: Tue, 23 Jan 2018 12:15:13 +0100 Message-id: <1516706113-9016-1-git-send-email-m.purski@samsung.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrNIsWRmVeSWpSXmKPExsWy7djP87o+kulRBs9bxCxurTvHatF77iST RVPHW1aLjTPWs1pc+fqezaJz4hJ2i8u75rBZLHh5i8Vi7ZG77A6cHpf7epk8ZnfMZPXY/u0B q8f97uNMHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJXx7MtrxoJLshU3Hzxmb2C8J97FyMkh IWAiceXJAmYIW0ziwr31bF2MXBxCAksZJU5NnsIK4XxmlNi45wk7TMf5CZugqpYxSvw/3sgM 4fxnlHjWcIyli5GDg01AS2JNezxIg4iAssTfiasYQWqYBa4ySZy8vJ0JJCEs4CjRf/0JG0g9 i4CqROddFpAwr4CzxMdDP5kglslJ3DzXCXXeBDaJvT9luhjZgWwXiT0VEFFhiVfHt0CdJiNx eXI3C4RdLXHx6y42CLtGovH2Bqgaa4nPk7aATWQW4JOYtG06M8gBEgK8Eh1tQhAlHhKLJ75m hbAdJY7PW8YEUiIkECvx7HTwBEapBYwMqxhFUkuLc9NTi430ihNzi0vz0vWS83M3MQKj9PS/ 4x93ML4/YXWIUYCDUYmHV4ExLUqINbGsuDL3EKMEB7OSCG8ea3qUEG9KYmVValF+fFFpTmrx IUZpDhYlcV7bqLZIIYH0xJLU7NTUgtQimCwTB6dUA+Pec0eMcjfGiaumqHNWBgUyLP379NP/ xVcfOq6TuOc3S6lZ7sid3c0sCV1X404c3RaZXHyhfNaffWa3UjWT35zf/LQrvbXXNJIvwkdA uWnhzl1PTs89uqslLUspIqKi8OIa71kaof1zjzHxCE0+l/Cr8GBOheQGzeL8xlmr6wNElnR0 +Aisy1BiKc5INNRiLipOBABkV6n7zgIAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupkluLIzCtJLcpLzFFi42I5/e/4NV1vyfQog1lf9SxurTvHatF77iST RVPHW1aLjTPWs1pc+fqezaJz4hJ2i8u75rBZLHh5i8Vi7ZG77A6cHpf7epk8ZnfMZPXY/u0B q8f97uNMHn1bVjF6fN4kF8AWxWWTkpqTWZZapG+XwJXx7MtrxoJLshU3Hzxmb2C8J97FyMkh IWAicX7CJjYIW0ziwr31QDYXh5DAEkaJlsY77BBOI5PE7+u3mLsYOTjYBLQk1rTHgzSICChL /J24ihGkhlngJpPE37N7WUESwgKOEv3Xn7CB1LMIqEp03mUBCfMKOEt8PPSTCWKZnMTNc53M Exi5FzAyrGIUSS0tzk3PLTbSK07MLS7NS9dLzs/dxAgMoG3Hfm7Zwdj1LvgQowAHoxIPryJj WpQQa2JZcWXuIUYJDmYlEd481vQoId6UxMqq1KL8+KLSnNTiQ4zSHCxK4ry9e1ZHCgmkJ5ak ZqemFqQWwWSZODilGhjDggstXCYVXA81Wt3wbWWg/Jk3VjHTM8M8f719/oyv/+Qkf+E9u/4X V8oUNXF+WOp3pHsd/9rGjO07/jxfoVtbJP7qFR/HLOcL5ncYorx2bXE5deDKp4PZF07Ou127 ddq6mIqSo9K+RxnduD5lFJ0NmZ76VJlzd2FFlvRvto8ZU8u5jP9eS52rxFKckWioxVxUnAgA JydfQhwCAAA= X-CMS-MailID: 20180123111523eucas1p2c4321e8ffc6425bec8725e2c60fec9e5 X-Msg-Generator: CA CMS-TYPE: 201P X-CMS-RootMailID: 20180123111523eucas1p2c4321e8ffc6425bec8725e2c60fec9e5 X-RootMTR: 20180123111523eucas1p2c4321e8ffc6425bec8725e2c60fec9e5 References: 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 Current implementation of mode_valid() and mode_fixup() callbacks handle packed pixel modes improperly. Fix it by using proper maximum clock values from the documentation. Signed-off-by: Maciej Purski --- drivers/gpu/drm/bridge/sil-sii8620.c | 90 ++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c index 5168783..1718c2e 100644 --- a/drivers/gpu/drm/bridge/sil-sii8620.c +++ b/drivers/gpu/drm/bridge/sil-sii8620.c @@ -34,8 +34,11 @@ #define SII8620_BURST_BUF_LEN 288 #define VAL_RX_HDMI_CTRL2_DEFVAL VAL_RX_HDMI_CTRL2_IDLE_CNT(3) -#define MHL1_MAX_LCLK 225000 -#define MHL3_MAX_LCLK 600000 + +#define MHL1_MAX_PCLK 75000 +#define MHL1_MAX_PCLK_PP_MODE 150000 +#define MHL3_MAX_PCLK 200000 +#define MHL3_MAX_PCLK_PP_MODE 300000 enum sii8620_mode { CM_DISCONNECTED, @@ -2123,61 +2126,70 @@ static void sii8620_detach(struct drm_bridge *bridge) rc_unregister_device(ctx->rc_dev); } +static int sii8620_is_packing_required(struct sii8620 *ctx, + const struct drm_display_mode *mode) +{ + int ret; + + if (sii8620_is_mhl3(ctx)) { + if (mode->clock < MHL3_MAX_PCLK) + ret = 0; + else if (mode->clock < MHL3_MAX_PCLK_PP_MODE) + ret = 1; + else + ret = -1; + } else { + if (mode->clock < MHL1_MAX_PCLK) + ret = 0; + else if (mode->clock < MHL1_MAX_PCLK_PP_MODE) + ret = 1; + else + ret = -1; + } + + return ret; +} + static enum drm_mode_status sii8620_mode_valid(struct drm_bridge *bridge, const struct drm_display_mode *mode) { + enum drm_mode_status ret; struct sii8620 *ctx = bridge_to_sii8620(bridge); + int pack_required = sii8620_is_packing_required(ctx, mode); bool can_pack = ctx->devcap[MHL_DCAP_VID_LINK_MODE] & MHL_DCAP_VID_LINK_PPIXEL; - unsigned int max_pclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK : - MHL1_MAX_LCLK; - max_pclk /= can_pack ? 2 : 3; - return (mode->clock > max_pclk) ? MODE_CLOCK_HIGH : MODE_OK; + switch (pack_required) { + case -1: + ret = MODE_CLOCK_HIGH; + break; + case 1: + ret = (can_pack) ? MODE_OK : MODE_CLOCK_HIGH; + break; + case 0: + ret = MODE_OK; + break; + } + + return ret; } + static bool sii8620_mode_fixup(struct drm_bridge *bridge, const struct drm_display_mode *mode, struct drm_display_mode *adjusted_mode) { struct sii8620 *ctx = bridge_to_sii8620(bridge); - int max_lclk; - bool ret = true; mutex_lock(&ctx->lock); - max_lclk = sii8620_is_mhl3(ctx) ? MHL3_MAX_LCLK : MHL1_MAX_LCLK; - if (max_lclk > 3 * adjusted_mode->clock) { - ctx->use_packed_pixel = 0; - goto end; - } - if ((ctx->devcap[MHL_DCAP_VID_LINK_MODE] & MHL_DCAP_VID_LINK_PPIXEL) && - max_lclk > 2 * adjusted_mode->clock) { - ctx->use_packed_pixel = 1; - goto end; - } - ret = false; -end: - if (ret) { - u8 vic = drm_match_cea_mode(adjusted_mode); - - if (!vic) { - union hdmi_infoframe frm; - u8 mhl_vic[] = { 0, 95, 94, 93, 98 }; - - /* FIXME: We need the connector here */ - drm_hdmi_vendor_infoframe_from_display_mode( - &frm.vendor.hdmi, NULL, adjusted_mode); - vic = frm.vendor.hdmi.vic; - if (vic >= ARRAY_SIZE(mhl_vic)) - vic = 0; - vic = mhl_vic[vic]; - } - ctx->video_code = vic; - ctx->pixel_clock = adjusted_mode->clock; - } + ctx->use_packed_pixel = sii8620_is_packing_required(ctx, adjusted_mode); + ctx->video_code = drm_match_cea_mode(adjusted_mode); + ctx->pixel_clock = adjusted_mode->clock; + mutex_unlock(&ctx->lock); - return ret; + + return true; } static const struct drm_bridge_funcs sii8620_bridge_funcs = {