aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2013-10-26 10:11:01 -0400
committerVille Syrjälä <ville.syrjala@linux.intel.com>2014-01-20 04:06:01 -0500
commit0dae35a3886c883bf993c8776dafd8a3bb2fef44 (patch)
tree57c09a365ea2b583834c2415e1faadd1083ad440
parent21b21560e9f7be6c3f415dfd7a840f72a250255c (diff)
drm: Simplify the math in drm_calc_timestamping_constants()
drm_calc_timestamping_constants() makes the math more complex than necessary. - multipying the dotclock by 1000 is pointless, just makes all the numbers bigger - div64_u64() is also pointless, div_u64 is enough - pixeldur_ns doesn't need any 64bit math Reviewed-by: mario.kleiner.de@gmail.com Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
-rw-r--r--drivers/gpu/drm/drm_irq.c26
1 files changed, 11 insertions, 15 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index 03f6a149b887..3283669a9083 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -451,10 +451,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
451 const struct drm_display_mode *mode) 451 const struct drm_display_mode *mode)
452{ 452{
453 s64 linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0; 453 s64 linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0;
454 u64 dotclock; 454 int dotclock = mode->clock;
455
456 /* Dot clock in Hz: */
457 dotclock = (u64) mode->clock * 1000;
458 455
459 /* Fields of interlaced scanout modes are only half a frame duration. 456 /* Fields of interlaced scanout modes are only half a frame duration.
460 * Double the dotclock to get half the frame-/line-/pixelduration. 457 * Double the dotclock to get half the frame-/line-/pixelduration.
@@ -464,17 +461,16 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
464 461
465 /* Valid dotclock? */ 462 /* Valid dotclock? */
466 if (dotclock > 0) { 463 if (dotclock > 0) {
467 int frame_size; 464 int frame_size = mode->crtc_htotal * mode->crtc_vtotal;
468 /* Convert scanline length in pixels and video dot clock to 465
469 * line duration, frame duration and pixel duration in 466 /*
470 * nanoseconds: 467 * Convert scanline length in pixels and video
468 * dot clock to line duration, frame duration
469 * and pixel duration in nanoseconds:
471 */ 470 */
472 pixeldur_ns = (s64) div64_u64(1000000000, dotclock); 471 pixeldur_ns = 1000000 / dotclock;
473 linedur_ns = (s64) div64_u64(((u64) mode->crtc_htotal * 472 linedur_ns = div_u64((u64) mode->crtc_htotal * 1000000, dotclock);
474 1000000000), dotclock); 473 framedur_ns = div_u64((u64) frame_size * 1000000, dotclock);
475 frame_size = mode->crtc_htotal * mode->crtc_vtotal;
476 framedur_ns = (s64) div64_u64((u64) frame_size * 1000000000,
477 dotclock);
478 } else 474 } else
479 DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n", 475 DRM_ERROR("crtc %d: Can't calculate constants, dotclock = 0!\n",
480 crtc->base.id); 476 crtc->base.id);
@@ -487,7 +483,7 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc,
487 crtc->base.id, mode->crtc_htotal, 483 crtc->base.id, mode->crtc_htotal,
488 mode->crtc_vtotal, mode->crtc_vdisplay); 484 mode->crtc_vtotal, mode->crtc_vdisplay);
489 DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n", 485 DRM_DEBUG("crtc %d: clock %d kHz framedur %d linedur %d, pixeldur %d\n",
490 crtc->base.id, (int) dotclock/1000, (int) framedur_ns, 486 crtc->base.id, dotclock, (int) framedur_ns,
491 (int) linedur_ns, (int) pixeldur_ns); 487 (int) linedur_ns, (int) pixeldur_ns);
492} 488}
493EXPORT_SYMBOL(drm_calc_timestamping_constants); 489EXPORT_SYMBOL(drm_calc_timestamping_constants);