diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2013-10-26 10:38:52 -0400 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2014-01-20 04:06:26 -0500 |
commit | 3c184f69917d16e295934fcbe0803355b544df64 (patch) | |
tree | 8858d539118e451ab576b08459d8a4d69ed822f9 | |
parent | 77666b72260da3a5290471de77e2d2261244db83 (diff) |
drm: Change {pixel,line,frame}dur_ns from s64 to int
Using s64 for the timestamping constants is wasteful. Signed 32bit
integers get us a range of over +-2 seconds. Presuming that no-one
wants to a vrefresh rate less than 0.5, we can switch to using int
for the timestamping constants. We save a few bytes in drm_crtc and
avoid a bunch of 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.c | 18 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 2 |
2 files changed, 10 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c index 52a234c4160e..91e8b4c55ea0 100644 --- a/drivers/gpu/drm/drm_irq.c +++ b/drivers/gpu/drm/drm_irq.c | |||
@@ -450,7 +450,7 @@ int drm_control(struct drm_device *dev, void *data, | |||
450 | void drm_calc_timestamping_constants(struct drm_crtc *crtc, | 450 | 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 | int linedur_ns = 0, pixeldur_ns = 0, framedur_ns = 0; |
454 | int dotclock = mode->crtc_clock; | 454 | int dotclock = mode->crtc_clock; |
455 | 455 | ||
456 | /* Fields of interlaced scanout modes are only half a frame duration. | 456 | /* Fields of interlaced scanout modes are only half a frame duration. |
@@ -483,8 +483,8 @@ void drm_calc_timestamping_constants(struct drm_crtc *crtc, | |||
483 | crtc->base.id, mode->crtc_htotal, | 483 | crtc->base.id, mode->crtc_htotal, |
484 | mode->crtc_vtotal, mode->crtc_vdisplay); | 484 | mode->crtc_vtotal, mode->crtc_vdisplay); |
485 | 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", |
486 | crtc->base.id, dotclock, (int) framedur_ns, | 486 | crtc->base.id, dotclock, framedur_ns, |
487 | (int) linedur_ns, (int) pixeldur_ns); | 487 | linedur_ns, pixeldur_ns); |
488 | } | 488 | } |
489 | EXPORT_SYMBOL(drm_calc_timestamping_constants); | 489 | EXPORT_SYMBOL(drm_calc_timestamping_constants); |
490 | 490 | ||
@@ -544,7 +544,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc, | |||
544 | struct timeval tv_etime; | 544 | struct timeval tv_etime; |
545 | int vbl_status, vtotal, vdisplay; | 545 | int vbl_status, vtotal, vdisplay; |
546 | int vpos, hpos, i; | 546 | int vpos, hpos, i; |
547 | s64 framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns; | 547 | int framedur_ns, linedur_ns, pixeldur_ns, delta_ns, duration_ns; |
548 | bool invbl; | 548 | bool invbl; |
549 | 549 | ||
550 | if (crtc < 0 || crtc >= dev->num_crtcs) { | 550 | if (crtc < 0 || crtc >= dev->num_crtcs) { |
@@ -607,18 +607,18 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc, | |||
607 | duration_ns = ktime_to_ns(etime) - ktime_to_ns(stime); | 607 | duration_ns = ktime_to_ns(etime) - ktime_to_ns(stime); |
608 | 608 | ||
609 | /* Accept result with < max_error nsecs timing uncertainty. */ | 609 | /* Accept result with < max_error nsecs timing uncertainty. */ |
610 | if (duration_ns <= (s64) *max_error) | 610 | if (duration_ns <= *max_error) |
611 | break; | 611 | break; |
612 | } | 612 | } |
613 | 613 | ||
614 | /* Noisy system timing? */ | 614 | /* Noisy system timing? */ |
615 | if (i == DRM_TIMESTAMP_MAXRETRIES) { | 615 | if (i == DRM_TIMESTAMP_MAXRETRIES) { |
616 | DRM_DEBUG("crtc %d: Noisy timestamp %d us > %d us [%d reps].\n", | 616 | DRM_DEBUG("crtc %d: Noisy timestamp %d us > %d us [%d reps].\n", |
617 | crtc, (int) duration_ns/1000, *max_error/1000, i); | 617 | crtc, duration_ns/1000, *max_error/1000, i); |
618 | } | 618 | } |
619 | 619 | ||
620 | /* Return upper bound of timestamp precision error. */ | 620 | /* Return upper bound of timestamp precision error. */ |
621 | *max_error = (int) duration_ns; | 621 | *max_error = duration_ns; |
622 | 622 | ||
623 | /* Check if in vblank area: | 623 | /* Check if in vblank area: |
624 | * vpos is >=0 in video scanout area, but negative | 624 | * vpos is >=0 in video scanout area, but negative |
@@ -631,7 +631,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc, | |||
631 | * since start of scanout at first display scanline. delta_ns | 631 | * since start of scanout at first display scanline. delta_ns |
632 | * can be negative if start of scanout hasn't happened yet. | 632 | * can be negative if start of scanout hasn't happened yet. |
633 | */ | 633 | */ |
634 | delta_ns = (s64) vpos * linedur_ns + (s64) hpos * pixeldur_ns; | 634 | delta_ns = vpos * linedur_ns + hpos * pixeldur_ns; |
635 | 635 | ||
636 | /* Is vpos outside nominal vblank area, but less than | 636 | /* Is vpos outside nominal vblank area, but less than |
637 | * 1/100 of a frame height away from start of vblank? | 637 | * 1/100 of a frame height away from start of vblank? |
@@ -669,7 +669,7 @@ int drm_calc_vbltimestamp_from_scanoutpos(struct drm_device *dev, int crtc, | |||
669 | crtc, (int)vbl_status, hpos, vpos, | 669 | crtc, (int)vbl_status, hpos, vpos, |
670 | (long)tv_etime.tv_sec, (long)tv_etime.tv_usec, | 670 | (long)tv_etime.tv_sec, (long)tv_etime.tv_usec, |
671 | (long)vblank_time->tv_sec, (long)vblank_time->tv_usec, | 671 | (long)vblank_time->tv_sec, (long)vblank_time->tv_usec, |
672 | (int)duration_ns/1000, i); | 672 | duration_ns/1000, i); |
673 | 673 | ||
674 | vbl_status = DRM_VBLANKTIME_SCANOUTPOS_METHOD; | 674 | vbl_status = DRM_VBLANKTIME_SCANOUTPOS_METHOD; |
675 | if (invbl) | 675 | if (invbl) |
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index f32c5cd51f41..a158ec0f97ab 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -447,7 +447,7 @@ struct drm_crtc { | |||
447 | uint16_t *gamma_store; | 447 | uint16_t *gamma_store; |
448 | 448 | ||
449 | /* Constants needed for precise vblank and swap timestamping. */ | 449 | /* Constants needed for precise vblank and swap timestamping. */ |
450 | s64 framedur_ns, linedur_ns, pixeldur_ns; | 450 | int framedur_ns, linedur_ns, pixeldur_ns; |
451 | 451 | ||
452 | /* if you are using the helper */ | 452 | /* if you are using the helper */ |
453 | void *helper_private; | 453 | void *helper_private; |