Commit 9f6fbe22 authored by Ville Syrjälä's avatar Ville Syrjälä

drm/i915: Stop hand rolling drm_mode_match()

Utilize drm_mode_match() instead of hand rolling it when
looking for the DRRS downclock mode.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190321132446.22394-5-ville.syrjala@linux.intel.comReviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Acked-by: default avatarJani Nikula <jani.nikula@intel.com>
parent dee2370c
...@@ -46,6 +46,16 @@ intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode, ...@@ -46,6 +46,16 @@ intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode,
drm_mode_set_crtcinfo(adjusted_mode, 0); drm_mode_set_crtcinfo(adjusted_mode, 0);
} }
static bool is_downclock_mode(const struct drm_display_mode *downclock_mode,
const struct drm_display_mode *fixed_mode)
{
return drm_mode_match(downclock_mode, fixed_mode,
DRM_MODE_MATCH_TIMINGS |
DRM_MODE_MATCH_FLAGS |
DRM_MODE_MATCH_3D_FLAGS) &&
downclock_mode->clock < fixed_mode->clock;
}
/** /**
* intel_find_panel_downclock - find the reduced downclock for LVDS in EDID * intel_find_panel_downclock - find the reduced downclock for LVDS in EDID
* @dev_priv: i915 device instance * @dev_priv: i915 device instance
...@@ -60,11 +70,8 @@ intel_find_panel_downclock(struct drm_i915_private *dev_priv, ...@@ -60,11 +70,8 @@ intel_find_panel_downclock(struct drm_i915_private *dev_priv,
struct drm_display_mode *fixed_mode, struct drm_display_mode *fixed_mode,
struct drm_connector *connector) struct drm_connector *connector)
{ {
struct drm_display_mode *scan, *tmp_mode; const struct drm_display_mode *scan, *best_mode = NULL;
int temp_downclock; int best_clock = fixed_mode->clock;
temp_downclock = fixed_mode->clock;
tmp_mode = NULL;
list_for_each_entry(scan, &connector->probed_modes, head) { list_for_each_entry(scan, &connector->probed_modes, head) {
/* /*
...@@ -74,29 +81,21 @@ intel_find_panel_downclock(struct drm_i915_private *dev_priv, ...@@ -74,29 +81,21 @@ intel_find_panel_downclock(struct drm_i915_private *dev_priv,
* case we can set the different FPx0/1 to dynamically select * case we can set the different FPx0/1 to dynamically select
* between low and high frequency. * between low and high frequency.
*/ */
if (scan->hdisplay == fixed_mode->hdisplay && if (is_downclock_mode(scan, fixed_mode) &&
scan->hsync_start == fixed_mode->hsync_start && scan->clock < best_clock) {
scan->hsync_end == fixed_mode->hsync_end && /*
scan->htotal == fixed_mode->htotal && * The downclock is already found. But we
scan->vdisplay == fixed_mode->vdisplay && * expect to find the lower downclock.
scan->vsync_start == fixed_mode->vsync_start && */
scan->vsync_end == fixed_mode->vsync_end && best_clock = scan->clock;
scan->vtotal == fixed_mode->vtotal) { best_mode = scan;
if (scan->clock < temp_downclock) {
/*
* The downclock is already found. But we
* expect to find the lower downclock.
*/
temp_downclock = scan->clock;
tmp_mode = scan;
}
} }
} }
if (temp_downclock < fixed_mode->clock) if (best_mode)
return drm_mode_duplicate(&dev_priv->drm, tmp_mode); return drm_mode_duplicate(&dev_priv->drm, best_mode);
else
return NULL; return NULL;
} }
struct drm_display_mode * struct drm_display_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