aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_modes.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_modes.c')
-rw-r--r--drivers/gpu/drm/drm_modes.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index 51f677215f1d..6d81a02463a3 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -553,6 +553,32 @@ int drm_mode_height(struct drm_display_mode *mode)
553} 553}
554EXPORT_SYMBOL(drm_mode_height); 554EXPORT_SYMBOL(drm_mode_height);
555 555
556/** drm_mode_hsync - get the hsync of a mode
557 * @mode: mode
558 *
559 * LOCKING:
560 * None.
561 *
562 * Return @modes's hsync rate in kHz, rounded to the nearest int.
563 */
564int drm_mode_hsync(struct drm_display_mode *mode)
565{
566 unsigned int calc_val;
567
568 if (mode->hsync)
569 return mode->hsync;
570
571 if (mode->htotal < 0)
572 return 0;
573
574 calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */
575 calc_val += 500; /* round to 1000Hz */
576 calc_val /= 1000; /* truncate to kHz */
577
578 return calc_val;
579}
580EXPORT_SYMBOL(drm_mode_hsync);
581
556/** 582/**
557 * drm_mode_vrefresh - get the vrefresh of a mode 583 * drm_mode_vrefresh - get the vrefresh of a mode
558 * @mode: mode 584 * @mode: mode
@@ -560,7 +586,7 @@ EXPORT_SYMBOL(drm_mode_height);
560 * LOCKING: 586 * LOCKING:
561 * None. 587 * None.
562 * 588 *
563 * Return @mode's vrefresh rate or calculate it if necessary. 589 * Return @mode's vrefresh rate in Hz or calculate it if necessary.
564 * 590 *
565 * FIXME: why is this needed? shouldn't vrefresh be set already? 591 * FIXME: why is this needed? shouldn't vrefresh be set already?
566 * 592 *