diff options
author | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-05-27 12:09:31 -0400 |
---|---|---|
committer | Maxime Ripard <maxime.ripard@free-electrons.com> | 2017-06-01 03:49:59 -0400 |
commit | b8317a3d50ceb3eae3a280c50c0de61ec302b806 (patch) | |
tree | 77b07dda3a12309d6bac7d15031f31aedf10acc8 | |
parent | a88cbbd469b05548f499e4320758f0364beada08 (diff) |
drm/sun4i: tcon: multiply the vtotal when not in interlace
It appears that the total vertical resolution needs to be doubled when
we're not in interlaced. Make sure that is the case.
Reviewed-by: Chen-Yu Tsai <wens@csie.org>
Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
-rw-r--r-- | drivers/gpu/drm/sun4i/sun4i_tcon.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c index 61e1de77831d..d9791292553e 100644 --- a/drivers/gpu/drm/sun4i/sun4i_tcon.c +++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c | |||
@@ -229,7 +229,7 @@ EXPORT_SYMBOL(sun4i_tcon0_mode_set); | |||
229 | void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, | 229 | void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, |
230 | struct drm_display_mode *mode) | 230 | struct drm_display_mode *mode) |
231 | { | 231 | { |
232 | unsigned int bp, hsync, vsync; | 232 | unsigned int bp, hsync, vsync, vtotal; |
233 | u8 clk_delay; | 233 | u8 clk_delay; |
234 | u32 val; | 234 | u32 val; |
235 | 235 | ||
@@ -276,12 +276,30 @@ void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, | |||
276 | SUN4I_TCON1_BASIC3_H_TOTAL(mode->crtc_htotal) | | 276 | SUN4I_TCON1_BASIC3_H_TOTAL(mode->crtc_htotal) | |
277 | SUN4I_TCON1_BASIC3_H_BACKPORCH(bp)); | 277 | SUN4I_TCON1_BASIC3_H_BACKPORCH(bp)); |
278 | 278 | ||
279 | /* Set vertical display timings */ | ||
280 | bp = mode->crtc_vtotal - mode->crtc_vsync_start; | 279 | bp = mode->crtc_vtotal - mode->crtc_vsync_start; |
281 | DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n", | 280 | DRM_DEBUG_DRIVER("Setting vertical total %d, backporch %d\n", |
282 | mode->vtotal, bp); | 281 | mode->crtc_vtotal, bp); |
282 | |||
283 | /* | ||
284 | * The vertical resolution needs to be doubled in all | ||
285 | * cases. We could use crtc_vtotal and always multiply by two, | ||
286 | * but that leads to a rounding error in interlace when vtotal | ||
287 | * is odd. | ||
288 | * | ||
289 | * This happens with TV's PAL for example, where vtotal will | ||
290 | * be 625, crtc_vtotal 312, and thus crtc_vtotal * 2 will be | ||
291 | * 624, which apparently confuses the hardware. | ||
292 | * | ||
293 | * To work around this, we will always use vtotal, and | ||
294 | * multiply by two only if we're not in interlace. | ||
295 | */ | ||
296 | vtotal = mode->vtotal; | ||
297 | if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) | ||
298 | vtotal = vtotal * 2; | ||
299 | |||
300 | /* Set vertical display timings */ | ||
283 | regmap_write(tcon->regs, SUN4I_TCON1_BASIC4_REG, | 301 | regmap_write(tcon->regs, SUN4I_TCON1_BASIC4_REG, |
284 | SUN4I_TCON1_BASIC4_V_TOTAL(mode->vtotal) | | 302 | SUN4I_TCON1_BASIC4_V_TOTAL(vtotal) | |
285 | SUN4I_TCON1_BASIC4_V_BACKPORCH(bp)); | 303 | SUN4I_TCON1_BASIC4_V_BACKPORCH(bp)); |
286 | 304 | ||
287 | /* Set Hsync and Vsync length */ | 305 | /* Set Hsync and Vsync length */ |