From patchwork Thu Oct 6 16:06:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 9365545 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 D94BA6077E for ; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB4782926A for ; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFE372927F; Fri, 7 Oct 2016 00:12:21 +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.2 required=2.0 tests=BAYES_00, 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 70D122926A for ; Fri, 7 Oct 2016 00:12:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 444E66EABB; Fri, 7 Oct 2016 00:12:05 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from wens.csie.org (mirror2.csie.ntu.edu.tw [140.112.30.76]) by gabe.freedesktop.org (Postfix) with ESMTPS id C9DB66EA0D for ; Thu, 6 Oct 2016 16:06:34 +0000 (UTC) Received: by wens.csie.org (Postfix, from userid 1000) id A5F955F99F; Fri, 7 Oct 2016 00:06:30 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , David Airlie , Rob Herring , Mark Rutland Subject: [PATCH 3/9] drm/sun4i: Put dotclock range into tcon quirks and check against them Date: Fri, 7 Oct 2016 00:06:23 +0800 Message-Id: <20161006160629.11198-4-wens@csie.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161006160629.11198-1-wens@csie.org> References: <20161006160629.11198-1-wens@csie.org> X-Mailman-Approved-At: Fri, 07 Oct 2016 00:11:52 +0000 Cc: devicetree@vger.kernel.org, linux-sunxi@googlegroups.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Chen-Yu Tsai , linux-arm-kernel@lists.infradead.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 In commit bb43d40d7c83 ("drm/sun4i: rgb: Validate the clock rate") the driver was rounding the requested clock rate and then checking the result against the original requested rate. This does not work well for a number of reasons: - The pixel clock does not have enough resolution to be able to provide all sub-MHz clock rates. This makes it filter out most modes found in simple-panel. - When first introduced, the main limiting factors were the video PLL clock range (27 ~ 381 MHz) and the lowest divider (6). On sun6i and later, the valid PLL clock range is extended to 30 ~ 600 MHz. The PLL's multiplier and divider can make it go much higher out of range, but the clock driver currently has no checks for it. Since the limits are well known, we can hard code the range into the tcon driver, and check against them. And we really only care about the upper limit, which affects the highest resolutions we can support. Fixes: bb43d40d7c83 ("drm/sun4i: rgb: Validate the clock rate") Signed-off-by: Chen-Yu Tsai --- drivers/gpu/drm/sun4i/sun4i_rgb.c | 8 +------- drivers/gpu/drm/sun4i/sun4i_tcon.c | 2 ++ drivers/gpu/drm/sun4i/sun4i_tcon.h | 1 + 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c index 8b520d9f5bd9..edbb42ead1f1 100644 --- a/drivers/gpu/drm/sun4i/sun4i_rgb.c +++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c @@ -60,8 +60,6 @@ static int sun4i_rgb_mode_valid(struct drm_connector *connector, struct sun4i_tcon *tcon = drv->tcon; u32 hsync = mode->hsync_end - mode->hsync_start; u32 vsync = mode->vsync_end - mode->vsync_start; - unsigned long rate = mode->clock * 1000; - long rounded_rate; DRM_DEBUG_DRIVER("Validating modes...\n"); @@ -93,11 +91,7 @@ static int sun4i_rgb_mode_valid(struct drm_connector *connector, DRM_DEBUG_DRIVER("Vertical parameters OK\n"); - rounded_rate = clk_round_rate(tcon->dclk, rate); - if (rounded_rate < rate) - return MODE_CLOCK_LOW; - - if (rounded_rate > rate) + if (mode->clock > tcon->quirks->max_clock) return MODE_CLOCK_HIGH; DRM_DEBUG_DRIVER("Clock rate OK\n"); diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index c6c1c7ce94a1..5a5407193753 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c @@ -583,6 +583,7 @@ static int sun4i_tcon_remove(struct platform_device *pdev) } const struct sun4i_tcon_quirks sun5i_a13_quirks = { + .max_clock = 63500, .is_sun5i = true, .has_channel_1 = true, .has_bypass_src = true, @@ -590,6 +591,7 @@ const struct sun4i_tcon_quirks sun5i_a13_quirks = { }; const struct sun4i_tcon_quirks sun8i_a33_quirks = { + .max_clock = 200000, /* nothing is supported */ }; diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h index 96c4f15c6922..972ca2b7c8c2 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.h +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h @@ -143,6 +143,7 @@ #define SUN4I_TCON_MAX_CHANNELS 2 struct sun4i_tcon_quirks { + int max_clock; /* Highest possible dotclock in kHz */ bool is_sun5i; /* sun5i has undocumented mux */ bool has_channel_1; /* a33 does not have channel 1 */ bool has_bypass_src; /* has separate input bypassing CEU */