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.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_rgb.c b/drivers/gpu/drm/sun4i/sun4i_rgb.c
index ab6494818050..f5bbac6efb4c 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,22 +92,21 @@ 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
90 return MODE_OK; 95 rounded_rate = clk_round_rate(tcon->dclk, rate);
91} 96 if (rounded_rate < rate)
97 return MODE_CLOCK_LOW;
92 98
93static struct drm_encoder * 99 if (rounded_rate > rate)
94sun4i_rgb_best_encoder(struct drm_connector *connector) 100 return MODE_CLOCK_HIGH;
95{
96 struct sun4i_rgb *rgb =
97 drm_connector_to_sun4i_rgb(connector);
98 101
99 return &rgb->encoder; 102 DRM_DEBUG_DRIVER("Clock rate OK\n");
103
104 return MODE_OK;
100} 105}
101 106
102static struct drm_connector_helper_funcs sun4i_rgb_con_helper_funcs = { 107static struct drm_connector_helper_funcs sun4i_rgb_con_helper_funcs = {
103 .get_modes = sun4i_rgb_get_modes, 108 .get_modes = sun4i_rgb_get_modes,
104 .mode_valid = sun4i_rgb_mode_valid, 109 .mode_valid = sun4i_rgb_mode_valid,
105 .best_encoder = sun4i_rgb_best_encoder,
106}; 110};
107 111
108static enum drm_connector_status 112static enum drm_connector_status
@@ -203,7 +207,7 @@ int sun4i_rgb_init(struct drm_device *drm)
203 int ret; 207 int ret;
204 208
205 /* If we don't have a panel, there's no point in going on */ 209 /* If we don't have a panel, there's no point in going on */
206 if (!tcon->panel) 210 if (IS_ERR(tcon->panel))
207 return -ENODEV; 211 return -ENODEV;
208 212
209 rgb = devm_kzalloc(drm->dev, sizeof(*rgb), GFP_KERNEL); 213 rgb = devm_kzalloc(drm->dev, sizeof(*rgb), GFP_KERNEL);