Commit 7ac96a9c authored by Adam Jackson's avatar Adam Jackson Committed by Dave Airlie

drm/modes: Add drm_mode_hsync()

Signed-off-by: default avatarAdam Jackson <ajax@redhat.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 9cf00977
...@@ -553,6 +553,32 @@ int drm_mode_height(struct drm_display_mode *mode) ...@@ -553,6 +553,32 @@ int drm_mode_height(struct drm_display_mode *mode)
} }
EXPORT_SYMBOL(drm_mode_height); EXPORT_SYMBOL(drm_mode_height);
/** drm_mode_hsync - get the hsync of a mode
* @mode: mode
*
* LOCKING:
* None.
*
* Return @modes's hsync rate in kHz, rounded to the nearest int.
*/
int drm_mode_hsync(struct drm_display_mode *mode)
{
unsigned int calc_val;
if (mode->hsync)
return mode->hsync;
if (mode->htotal < 0)
return 0;
calc_val = (mode->clock * 1000) / mode->htotal; /* hsync in Hz */
calc_val += 500; /* round to 1000Hz */
calc_val /= 1000; /* truncate to kHz */
return calc_val;
}
EXPORT_SYMBOL(drm_mode_hsync);
/** /**
* drm_mode_vrefresh - get the vrefresh of a mode * drm_mode_vrefresh - get the vrefresh of a mode
* @mode: mode * @mode: mode
...@@ -560,7 +586,7 @@ EXPORT_SYMBOL(drm_mode_height); ...@@ -560,7 +586,7 @@ EXPORT_SYMBOL(drm_mode_height);
* LOCKING: * LOCKING:
* None. * None.
* *
* Return @mode's vrefresh rate or calculate it if necessary. * Return @mode's vrefresh rate in Hz or calculate it if necessary.
* *
* FIXME: why is this needed? shouldn't vrefresh be set already? * FIXME: why is this needed? shouldn't vrefresh be set already?
* *
......
...@@ -123,7 +123,7 @@ struct drm_display_mode { ...@@ -123,7 +123,7 @@ struct drm_display_mode {
int type; int type;
/* Proposed mode values */ /* Proposed mode values */
int clock; int clock; /* in kHz */
int hdisplay; int hdisplay;
int hsync_start; int hsync_start;
int hsync_end; int hsync_end;
...@@ -164,8 +164,8 @@ struct drm_display_mode { ...@@ -164,8 +164,8 @@ struct drm_display_mode {
int *private; int *private;
int private_flags; int private_flags;
int vrefresh; int vrefresh; /* in Hz */
float hsync; int hsync; /* in kHz */
}; };
enum drm_connector_status { enum drm_connector_status {
...@@ -681,6 +681,7 @@ extern void drm_mode_validate_size(struct drm_device *dev, ...@@ -681,6 +681,7 @@ extern void drm_mode_validate_size(struct drm_device *dev,
extern void drm_mode_prune_invalid(struct drm_device *dev, extern void drm_mode_prune_invalid(struct drm_device *dev,
struct list_head *mode_list, bool verbose); struct list_head *mode_list, bool verbose);
extern void drm_mode_sort(struct list_head *mode_list); extern void drm_mode_sort(struct list_head *mode_list);
extern int drm_mode_hsync(struct drm_display_mode *mode);
extern int drm_mode_vrefresh(struct drm_display_mode *mode); extern int drm_mode_vrefresh(struct drm_display_mode *mode);
extern void drm_mode_set_crtcinfo(struct drm_display_mode *p, extern void drm_mode_set_crtcinfo(struct drm_display_mode *p,
int adjust_flags); int adjust_flags);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment