diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2016-04-21 05:25:26 -0400 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2016-05-30 02:28:33 -0400 |
commit | bb43d40d7c830da5f623e3938fef908b003b7523 (patch) | |
tree | 8260d627de2bdf2b7d5c24f92aae6eb1ffa993bc | |
parent | 4731a72df273bdbd225445424057c15dbb8d3495 (diff) |
drm/sun4i: rgb: Validate the clock rate
Our pixel clock cannot reach a high enough rate for some rather high while
common resolutions (like 1080p60).
Make sure we filter the resolutions we cannot reach in our mode_valid
function.
Fixes: 29e57fab97fc ("drm: sun4i: Add RGB output")
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r-- | drivers/gpu/drm/sun4i/sun4i_rgb.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c index ab6494818050..fe7ef52a9346 100644 --- a/drivers/gpu/drm/sun4i/sun4i_rgb.c +++ b/drivers/gpu/drm/sun4i/sun4i_rgb.c | |||
@@ -54,8 +54,13 @@ static int sun4i_rgb_get_modes(struct drm_connector *connector) | |||
54 | static int sun4i_rgb_mode_valid(struct drm_connector *connector, | 54 | static int sun4i_rgb_mode_valid(struct drm_connector *connector, |
55 | struct drm_display_mode *mode) | 55 | struct drm_display_mode *mode) |
56 | { | 56 | { |
57 | struct sun4i_rgb *rgb = drm_connector_to_sun4i_rgb(connector); | ||
58 | struct sun4i_drv *drv = rgb->drv; | ||
59 | struct sun4i_tcon *tcon = drv->tcon; | ||
57 | u32 hsync = mode->hsync_end - mode->hsync_start; | 60 | u32 hsync = mode->hsync_end - mode->hsync_start; |
58 | u32 vsync = mode->vsync_end - mode->vsync_start; | 61 | u32 vsync = mode->vsync_end - mode->vsync_start; |
62 | unsigned long rate = mode->clock * 1000; | ||
63 | long rounded_rate; | ||
59 | 64 | ||
60 | DRM_DEBUG_DRIVER("Validating modes...\n"); | 65 | DRM_DEBUG_DRIVER("Validating modes...\n"); |
61 | 66 | ||
@@ -87,6 +92,15 @@ static int sun4i_rgb_mode_valid(struct drm_connector *connector, | |||
87 | 92 | ||
88 | DRM_DEBUG_DRIVER("Vertical parameters OK\n"); | 93 | DRM_DEBUG_DRIVER("Vertical parameters OK\n"); |
89 | 94 | ||
95 | rounded_rate = clk_round_rate(tcon->dclk, rate); | ||
96 | if (rounded_rate < rate) | ||
97 | return MODE_CLOCK_LOW; | ||
98 | |||
99 | if (rounded_rate > rate) | ||
100 | return MODE_CLOCK_HIGH; | ||
101 | |||
102 | DRM_DEBUG_DRIVER("Clock rate OK\n"); | ||
103 | |||
90 | return MODE_OK; | 104 | return MODE_OK; |
91 | } | 105 | } |
92 | 106 | ||