aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/drm_modes.c28
-rw-r--r--include/drm/drm_crtc.h7
2 files changed, 31 insertions, 4 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 *
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index d84fba15c9d8..938f327a2a3b 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -123,7 +123,7 @@ struct drm_display_mode {
123 int type; 123 int type;
124 124
125 /* Proposed mode values */ 125 /* Proposed mode values */
126 int clock; 126 int clock; /* in kHz */
127 int hdisplay; 127 int hdisplay;
128 int hsync_start; 128 int hsync_start;
129 int hsync_end; 129 int hsync_end;
@@ -164,8 +164,8 @@ struct drm_display_mode {
164 int *private; 164 int *private;
165 int private_flags; 165 int private_flags;
166 166
167 int vrefresh; 167 int vrefresh; /* in Hz */
168 float hsync; 168 int hsync; /* in kHz */
169}; 169};
170 170
171enum drm_connector_status { 171enum drm_connector_status {
@@ -681,6 +681,7 @@ extern void drm_mode_validate_size(struct drm_device *dev,
681extern void drm_mode_prune_invalid(struct drm_device *dev, 681extern void drm_mode_prune_invalid(struct drm_device *dev,
682 struct list_head *mode_list, bool verbose); 682 struct list_head *mode_list, bool verbose);
683extern void drm_mode_sort(struct list_head *mode_list); 683extern void drm_mode_sort(struct list_head *mode_list);
684extern int drm_mode_hsync(struct drm_display_mode *mode);
684extern int drm_mode_vrefresh(struct drm_display_mode *mode); 685extern int drm_mode_vrefresh(struct drm_display_mode *mode);
685extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, 686extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
686 int adjust_flags); 687 int adjust_flags);