Commit d880fa66 authored by Russell King's avatar Russell King

drm/armada: use mode_valid to validate the adjusted mode

Validate the adjusted mode in the CRTC mode_fixup() call to ensure that
any encoder or bridge doesn't supply us with a mode we can't support.
Signed-off-by: default avatarRussell King <rmk+kernel@armlinux.org.uk>
parent 1ba246f2
...@@ -171,6 +171,8 @@ static void armada_drm_update_gamma(struct drm_crtc *crtc) ...@@ -171,6 +171,8 @@ static void armada_drm_update_gamma(struct drm_crtc *crtc)
static enum drm_mode_status armada_drm_crtc_mode_valid(struct drm_crtc *crtc, static enum drm_mode_status armada_drm_crtc_mode_valid(struct drm_crtc *crtc,
const struct drm_display_mode *mode) const struct drm_display_mode *mode)
{ {
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
if (mode->vscan > 1) if (mode->vscan > 1)
return MODE_NO_VSCAN; return MODE_NO_VSCAN;
...@@ -180,6 +182,11 @@ static enum drm_mode_status armada_drm_crtc_mode_valid(struct drm_crtc *crtc, ...@@ -180,6 +182,11 @@ static enum drm_mode_status armada_drm_crtc_mode_valid(struct drm_crtc *crtc,
if (mode->flags & DRM_MODE_FLAG_HSKEW) if (mode->flags & DRM_MODE_FLAG_HSKEW)
return MODE_H_ILLEGAL; return MODE_H_ILLEGAL;
/* We can't do interlaced modes if we don't have the SPU_ADV_REG */
if (!dcrtc->variant->has_spu_adv_reg &&
mode->flags & DRM_MODE_FLAG_INTERLACE)
return MODE_NO_INTERLACE;
if (mode->flags & (DRM_MODE_FLAG_BCAST | DRM_MODE_FLAG_PIXMUX | if (mode->flags & (DRM_MODE_FLAG_BCAST | DRM_MODE_FLAG_PIXMUX |
DRM_MODE_FLAG_CLKDIV2)) DRM_MODE_FLAG_CLKDIV2))
return MODE_BAD; return MODE_BAD;
...@@ -194,11 +201,6 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc, ...@@ -194,11 +201,6 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc,
struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc);
int ret; int ret;
/* We can't do interlaced modes if we don't have the SPU_ADV_REG */
if (!dcrtc->variant->has_spu_adv_reg &&
adj->flags & DRM_MODE_FLAG_INTERLACE)
return false;
/* /*
* Set CRTC modesetting parameters for the adjusted mode. This is * Set CRTC modesetting parameters for the adjusted mode. This is
* applied after the connectors, bridges, and encoders have fixed up * applied after the connectors, bridges, and encoders have fixed up
...@@ -206,6 +208,13 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc, ...@@ -206,6 +208,13 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc,
*/ */
drm_mode_set_crtcinfo(adj, CRTC_INTERLACE_HALVE_V); drm_mode_set_crtcinfo(adj, CRTC_INTERLACE_HALVE_V);
/*
* Validate the adjusted mode in case an encoder/bridge has set
* something we don't support.
*/
if (armada_drm_crtc_mode_valid(crtc, adj) != MODE_OK)
return false;
/* Check whether the display mode is possible */ /* Check whether the display mode is possible */
ret = dcrtc->variant->compute_clock(dcrtc, adj, NULL); ret = dcrtc->variant->compute_clock(dcrtc, adj, NULL);
if (ret) if (ret)
......
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