aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorDaniel Kurtz <djkurtz@chromium.org>2012-12-26 20:01:46 -0500
committerDave Airlie <airlied@redhat.com>2013-02-07 23:00:48 -0500
commit85a7ce67f3ebfd5975ffd1febcabfe4999ca911d (patch)
treed98adc99ef6bbccb40bcebdcdbc317bbceca1640 /drivers
parentdd66cc2e1f4765d0e6f39eb1e7d8d64d3f1cc522 (diff)
drm: make frame duration time calculation more precise
It is a bit more precise to compute the total number of pixels first and then divide, rather than multiplying the line pixel count by the already-rounded line duration. Signed-off-by: Daniel Kurtz <djkurtz@chromium.org> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/drm_irq.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 71f820565637..38e79927b2d7 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
505 505
506 /* Valid dotclock? */ 506 /* Valid dotclock? */
507 if (dotclock > 0) { 507 if (dotclock > 0) {
508 int frame_size;
508 /* Convert scanline length in pixels and video dot clock to 509 /* Convert scanline length in pixels and video dot clock to
509 * line duration, frame duration and pixel duration in 510 * line duration, frame duration and pixel duration in
510 * nanoseconds: 511 * nanoseconds:
@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
512 pixeldur_ns = (s64) div64_u64(1000000000, dotclock); 513 pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
513 linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal * 514 linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
514 1000000000), dotclock); 515 1000000000), dotclock);
515 framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns; 516 frame_size = crtc->hwmode.crtc_htotal *
517 crtc->hwmode.crtc_vtotal;
518 framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000,
519 dotclock);
516 } else 520 } else
517 DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n", 521 DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
518 crtc->base.id); 522 crtc->base.id);