diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c index 704db2443b5e..6ef4d1a1e3a9 100644 --- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c +++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c | |||
@@ -24,6 +24,7 @@ | |||
24 | #include <linux/completion.h> | 24 | #include <linux/completion.h> |
25 | #include <linux/dma-mapping.h> | 25 | #include <linux/dma-mapping.h> |
26 | #include <linux/of_graph.h> | 26 | #include <linux/of_graph.h> |
27 | #include <linux/math64.h> | ||
27 | 28 | ||
28 | #include "tilcdc_drv.h" | 29 | #include "tilcdc_drv.h" |
29 | #include "tilcdc_regs.h" | 30 | #include "tilcdc_regs.h" |
@@ -48,6 +49,7 @@ struct tilcdc_crtc { | |||
48 | unsigned int lcd_fck_rate; | 49 | unsigned int lcd_fck_rate; |
49 | 50 | ||
50 | ktime_t last_vblank; | 51 | ktime_t last_vblank; |
52 | unsigned int hvtotal_us; | ||
51 | 53 | ||
52 | struct drm_framebuffer *curr_fb; | 54 | struct drm_framebuffer *curr_fb; |
53 | struct drm_framebuffer *next_fb; | 55 | struct drm_framebuffer *next_fb; |
@@ -292,6 +294,12 @@ static void tilcdc_crtc_set_clk(struct drm_crtc *crtc) | |||
292 | LCDC_V2_CORE_CLK_EN); | 294 | LCDC_V2_CORE_CLK_EN); |
293 | } | 295 | } |
294 | 296 | ||
297 | uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode) | ||
298 | { | ||
299 | return (uint) div_u64(1000llu * mode->htotal * mode->vtotal, | ||
300 | mode->clock); | ||
301 | } | ||
302 | |||
295 | static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) | 303 | static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) |
296 | { | 304 | { |
297 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); | 305 | struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc); |
@@ -459,6 +467,9 @@ static void tilcdc_crtc_set_mode(struct drm_crtc *crtc) | |||
459 | drm_framebuffer_get(fb); | 467 | drm_framebuffer_get(fb); |
460 | 468 | ||
461 | crtc->hwmode = crtc->state->adjusted_mode; | 469 | crtc->hwmode = crtc->state->adjusted_mode; |
470 | |||
471 | tilcdc_crtc->hvtotal_us = | ||
472 | tilcdc_mode_hvtotal(&crtc->hwmode); | ||
462 | } | 473 | } |
463 | 474 | ||
464 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) | 475 | static void tilcdc_crtc_enable(struct drm_crtc *crtc) |
@@ -642,7 +653,7 @@ int tilcdc_crtc_update_fb(struct drm_crtc *crtc, | |||
642 | spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags); | 653 | spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags); |
643 | 654 | ||
644 | next_vblank = ktime_add_us(tilcdc_crtc->last_vblank, | 655 | next_vblank = ktime_add_us(tilcdc_crtc->last_vblank, |
645 | 1000000 / crtc->hwmode.vrefresh); | 656 | tilcdc_crtc->hvtotal_us); |
646 | tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get())); | 657 | tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get())); |
647 | 658 | ||
648 | if (tdiff < TILCDC_VBLANK_SAFETY_THRESHOLD_US) | 659 | if (tdiff < TILCDC_VBLANK_SAFETY_THRESHOLD_US) |