aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/sun4i/sun4i_rgb.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/sun4i/sun4i_rgb.c')
-rw-r--r--drivers/gpu/drm/sun4i/sun4i_rgb.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c
index ab6494818050..aaffe9e64ffb 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)
54static int sun4i_rgb_mode_valid(struct drm_connector *connector, 54static 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
@@ -203,7 +217,7 @@ int sun4i_rgb_init(struct drm_device *drm)
203 int ret; 217 int ret;
204 218
205 /* If we don't have a panel, there's no point in going on */ 219 /* If we don't have a panel, there's no point in going on */
206 if (!tcon->panel) 220 if (IS_ERR(tcon->panel))
207 return -ENODEV; 221 return -ENODEV;
208 222
209 rgb = devm_kzalloc(drm->dev, sizeof(*rgb), GFP_KERNEL); 223 rgb = devm_kzalloc(drm->dev, sizeof(*rgb), GFP_KERNEL);