drm: make frame duration time calculation more precise
authorDaniel Kurtz <djkurtz@chromium.org>
Thu, 27 Dec 2012 01:01:46 +0000 (01:01 +0000)
committerDave Airlie <airlied@redhat.com>
Fri, 8 Feb 2013 04:00:48 +0000 (14:00 +1000)
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>
drivers/gpu/drm/drm_irq.c

index 71f82056563745cf1fd79c662599dccbb81b39d8..38e79927b2d7e6ead32398eac6a04eb992bf0cb1 100644 (file)
@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
 
        /* Valid dotclock? */
        if (dotclock > 0) {
+               int frame_size;
                /* Convert scanline length in pixels and video dot clock to
                 * line duration, frame duration and pixel duration in
                 * nanoseconds:
@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
                pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
                linedur_ns  = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
                                              1000000000), dotclock);
-               framedur_ns = (s64) crtc->hwmode.crtc_vtotal * linedur_ns;
+               frame_size = crtc->hwmode.crtc_htotal *
+                               crtc->hwmode.crtc_vtotal;
+               framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000,
+                                             dotclock);
        } else
                DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
                          crtc->base.id);