From: Chen-Yu Tsai <wens@csie.org>
To: Maxime Ripard <maxime.ripard@free-electrons.com>,
David Airlie <airlied@linux.ie>, Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Cc: Chen-Yu Tsai <wens@csie.org>,
dri-devel@lists.freedesktop.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, devicetree@vger.kernel.org,
linux-sunxi@googlegroups.com
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 [thread overview]
Message-ID: <20161006160629.11198-4-wens@csie.org> (raw)
In-Reply-To: <20161006160629.11198-1-wens@csie.org>
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 <wens@csie.org>
---
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 */
--
2.9.3
next prev parent reply other threads:[~2016-10-06 16:06 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-06 16:06 [PATCH 0/9] drm/sun4i: Support first display pipeline on sun6i Chen-Yu Tsai
2016-10-06 16:06 ` [PATCH 1/9] drm/sun4i: sun6i-drc: Support DRC on A31 and A31s Chen-Yu Tsai
2016-10-10 14:45 ` Rob Herring
2016-10-06 16:06 ` [PATCH 2/9] drm/sun4i: tcon: Move SoC specific quirks to a DT matched data structure Chen-Yu Tsai
2016-10-07 8:38 ` Maxime Ripard
2016-10-11 9:16 ` Chen-Yu Tsai
2016-10-11 9:36 ` Maxime Ripard
2016-10-06 16:06 ` Chen-Yu Tsai [this message]
2016-10-07 8:54 ` [PATCH 3/9] drm/sun4i: Put dotclock range into tcon quirks and check against them Maxime Ripard
2016-10-06 16:06 ` [PATCH 4/9] drm/sun4i: Add compatible string for A31/A31s TCON (timing controller) Chen-Yu Tsai
2016-10-07 8:55 ` Maxime Ripard
2016-10-06 16:06 ` [PATCH 5/9] drm/sun4i: Add compatible strings for A31/A31s display pipelines Chen-Yu Tsai
2016-10-10 14:49 ` Rob Herring
2016-10-06 16:06 ` [PATCH 6/9] ARM: dts: sun6i: Sort pinmux setting nodes Chen-Yu Tsai
2016-10-07 8:57 ` Maxime Ripard
2016-10-06 16:06 ` [PATCH 7/9] ARM: dts: sun6i: Add device nodes for first display pipeline Chen-Yu Tsai
2016-10-06 16:06 ` [PATCH 8/9] ARM: dts: sun6i: Add A31 LCD0 RGB888 pins Chen-Yu Tsai
2016-10-06 16:06 ` [PATCH 9/9] [DO NOT MERGE] ARM: dts: sun6i: Enable 7" LCD panel on Sinlinx SinA31s Chen-Yu Tsai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161006160629.11198-4-wens@csie.org \
--to=wens@csie.org \
--cc=airlied@linux.ie \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sunxi@googlegroups.com \
--cc=mark.rutland@arm.com \
--cc=maxime.ripard@free-electrons.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®