Commit 339d202c authored by Alex Deucher's avatar Alex Deucher

drm/edid: compare actual vrefresh for all modes for quirks

The vrefresh field of the mode is 0 for most modes
fetched from the EDID (e.g., established timings).
When dealing with monitors that have a bogus preferred
mode, we may not always select the mode we want because
we compare the target refresh to the mode's vrefresh which
is 0 in a lot of cases.
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
parent cf0613d2
...@@ -1329,7 +1329,7 @@ static u32 edid_get_quirks(struct edid *edid) ...@@ -1329,7 +1329,7 @@ static u32 edid_get_quirks(struct edid *edid)
} }
#define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay) #define MODE_SIZE(m) ((m)->hdisplay * (m)->vdisplay)
#define MODE_REFRESH_DIFF(m,r) (abs((m)->vrefresh - target_refresh)) #define MODE_REFRESH_DIFF(c,t) (abs((c) - (t)))
/** /**
* edid_fixup_preferred - set preferred modes based on quirk list * edid_fixup_preferred - set preferred modes based on quirk list
...@@ -1344,6 +1344,7 @@ static void edid_fixup_preferred(struct drm_connector *connector, ...@@ -1344,6 +1344,7 @@ static void edid_fixup_preferred(struct drm_connector *connector,
{ {
struct drm_display_mode *t, *cur_mode, *preferred_mode; struct drm_display_mode *t, *cur_mode, *preferred_mode;
int target_refresh = 0; int target_refresh = 0;
int cur_vrefresh, preferred_vrefresh;
if (list_empty(&connector->probed_modes)) if (list_empty(&connector->probed_modes))
return; return;
...@@ -1366,10 +1367,14 @@ static void edid_fixup_preferred(struct drm_connector *connector, ...@@ -1366,10 +1367,14 @@ static void edid_fixup_preferred(struct drm_connector *connector,
if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode)) if (MODE_SIZE(cur_mode) > MODE_SIZE(preferred_mode))
preferred_mode = cur_mode; preferred_mode = cur_mode;
cur_vrefresh = cur_mode->vrefresh ?
cur_mode->vrefresh : drm_mode_vrefresh(cur_mode);
preferred_vrefresh = preferred_mode->vrefresh ?
preferred_mode->vrefresh : drm_mode_vrefresh(preferred_mode);
/* At a given size, try to get closest to target refresh */ /* At a given size, try to get closest to target refresh */
if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) && if ((MODE_SIZE(cur_mode) == MODE_SIZE(preferred_mode)) &&
MODE_REFRESH_DIFF(cur_mode, target_refresh) < MODE_REFRESH_DIFF(cur_vrefresh, target_refresh) <
MODE_REFRESH_DIFF(preferred_mode, target_refresh)) { MODE_REFRESH_DIFF(preferred_vrefresh, target_refresh)) {
preferred_mode = cur_mode; preferred_mode = cur_mode;
} }
} }
......
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