From patchwork Tue Jan 9 02:03:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Liu X-Patchwork-Id: 10151175 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 3E5A760223 for ; Tue, 9 Jan 2018 08:35:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3020F284F6 for ; Tue, 9 Jan 2018 08:35:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2503C28571; Tue, 9 Jan 2018 08:35:51 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 E2D26284F6 for ; Tue, 9 Jan 2018 08:35:50 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 06B586E6A8; Tue, 9 Jan 2018 08:35:45 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 04FF86E06B for ; Tue, 9 Jan 2018 02:03:43 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id m26so7415718pfj.11 for ; Mon, 08 Jan 2018 18:03:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wehpzekEmdS+w+XwvE65sTVMqxFWmmKT/xYvSW+zEf0=; b=SoybwBOfB7/Xq8kYY648OXpOr0rZXAOKSYJz2NzCFNWvjIrvq/EoiZzm1f6cNn+Bvg jS6F46WIvXM54kbh+Db6937gA49gPc/Cb9bbu9i8f9El8k6xyFbqMBgoPx2vt36OD6iC m4p5q6BhE9i1FaGooaDXN+z28zutzUa+LW0+rAgV/bNaCRxZpb99h5PK4Qhp4eKTV4c2 raVBkOyChHLhytrMI7zrLPz/JIbVWwFqnLmFKDnQwTl2Rv9O/lVMeSBafLnOvHDI71/v uctcFmO8Jag0/QUzOKxPfIZ31HiMjm3uvb1vn3n7oy9sDwQdjgGgWnJnQf8qiZcxt3z/ X2Rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wehpzekEmdS+w+XwvE65sTVMqxFWmmKT/xYvSW+zEf0=; b=BDLvT3crJFFiAFCUogyyZBywOQVbSIqPCDG8izY3Fc2NrYrc7CBTvAXArl+ykIh66Z LyYnNH0X1y/Xw9Jr4hQCLbpPX8dvl1m+cYfQr/zjPT09WKMWRcCSrF9VVUt/SMxEk+j+ ltl8DcxtvSSMalkw+P8j9Swh7tDyOVoGcurM8B2xyabDcGSmBsI0KVkQGC5m0G3Exw2x p5X43bMnb/3l5LFyCUe/xPCYDOlkCyUbBdnZPEOmPN1ivVD0gD59Hde+R1aYmDebzF4n 0IaVTDQ4hK37RrHaTsi8jv6dj+UzGfnikDjxMZfame6rxCnqV5wX/Zy+nrCF0NoUYVcr Wjcw== X-Gm-Message-State: AKGB3mJVw0ooCRe0DgMzP+Ar1onmzgvRzio46M7VMXHV4NaiXjAu1oc0 cS9T7MtrE1OgNl2q6ddbeiI= X-Google-Smtp-Source: ACJfBouoZMBT4SkbRuloHk8mfSZH+xxRgUBRrOsDhmz245ckYnW/yA5sVcJuoM55zmx+AGoCT8Bjiw== X-Received: by 10.159.208.2 with SMTP id a2mr13846285plp.371.1515463422405; Mon, 08 Jan 2018 18:03:42 -0800 (PST) Received: from 60-242-179-244.static.tpgi.com.au (60-242-179-244.static.tpgi.com.au. [60.242.179.244]) by smtp.gmail.com with ESMTPSA id t75sm24022750pgc.30.2018.01.08.18.03.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jan 2018 18:03:41 -0800 (PST) From: Jonathan Liu To: Maxime Ripard , David Airlie , Chen-Yu Tsai Subject: [PATCH v3 3/3] drm/sun4i: hdmi: Add missing rate halving check in sun4i_tmds_determine_rate Date: Tue, 9 Jan 2018 13:03:23 +1100 Message-Id: <20180109020323.11852-4-net147@gmail.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180109020323.11852-1-net147@gmail.com> References: <20180109020323.11852-1-net147@gmail.com> X-Mailman-Approved-At: Tue, 09 Jan 2018 08:35:43 +0000 Cc: linux-arm-kernel@lists.infradead.org, linux-sunxi@googlegroups.com, Jonathan Liu , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org 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 It was only checking the divider when determing the closest match if it could not match the requested rate exactly. For a projector connected to an Olimex A20-OLinuXino-LIME using HDMI with a native resolution of 1280x800 and pixel clock of 83.5 MHz, this resulted in 1280x800 mode not being available and the following in dmesg when the kernel is booted with drm.debug=0x3e: [drm:drm_mode_debug_printmodeline] Modeline 37:"1280x800" 60 83500 1280 1352 1480 1680 800 810 816 831 0x48 0x5 [drm:drm_mode_prune_invalid] Not using 1280x800 mode: NOCLOCK Fixes: 9c5681011a0c ("drm/sun4i: Add HDMI support") Signed-off-by: Jonathan Liu --- drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c index 88eeeaf34638..3ecffa52c814 100644 --- a/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c +++ b/drivers/gpu/drm/sun4i/sun4i_hdmi_tmds_clk.c @@ -102,9 +102,12 @@ static int sun4i_tmds_determine_rate(struct clk_hw *hw, goto out; } - if (!best_parent || abs(rate - rounded / i) < - abs(rate - best_parent / best_div)) { + if (!best_parent || + abs(rate - rounded / i / j) < + abs(rate - best_parent / best_half / + best_div)) { best_parent = rounded; + best_half = i; best_div = j; } }