提交 85a7ce67 编写于 作者: D Daniel Kurtz 提交者: Dave Airlie

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: NDaniel Kurtz <djkurtz@chromium.org>
Signed-off-by: NDave Airlie <airlied@redhat.com>
上级 dd66cc2e
...@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc) ...@@ -505,6 +505,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
/* Valid dotclock? */ /* Valid dotclock? */
if (dotclock > 0) { if (dotclock > 0) {
int frame_size;
/* Convert scanline length in pixels and video dot clock to /* Convert scanline length in pixels and video dot clock to
* line duration, frame duration and pixel duration in * line duration, frame duration and pixel duration in
* nanoseconds: * nanoseconds:
...@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc) ...@@ -512,7 +513,10 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc)
pixeldur_ns = (s64) div64_u64(1000000000, dotclock); pixeldur_ns = (s64) div64_u64(1000000000, dotclock);
linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal * linedur_ns = (s64) div64_u64(((u64) crtc->hwmode.crtc_htotal *
1000000000), dotclock); 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 } else
DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n", DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
crtc->base.id); crtc->base.id);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册