From mboxrd@z Thu Jan 1 00:00:00 1970 From: Russell King Subject: [PATCH 14/18] drm/armada: use mode_valid to validate the adjusted mode Date: Thu, 13 Jun 2019 16:02:54 +0100 Message-ID: References: <20190613150114.xqkyb7j7w4ve4yvr@shell.armlinux.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20190613150114.xqkyb7j7w4ve4yvr@shell.armlinux.org.uk> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=m.gmane.org@lists.infradead.org To: dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org Cc: David Airlie , Daniel Vetter List-Id: dri-devel@lists.freedesktop.org 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: Russell King --- drivers/gpu/drm/armada/armada_crtc.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/armada/armada_crtc.c b/drivers/gpu/drm/armada/armada_crtc.c index 949acc82406b..ecce7efb271d 100644 --- a/drivers/gpu/drm/armada/armada_crtc.c +++ b/drivers/gpu/drm/armada/armada_crtc.c @@ -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, const struct drm_display_mode *mode) { + struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); + if (mode->vscan > 1) return MODE_NO_VSCAN; @@ -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) 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 | DRM_MODE_FLAG_CLKDIV2)) return MODE_BAD; @@ -194,11 +201,6 @@ static bool armada_drm_crtc_mode_fixup(struct drm_crtc *crtc, struct armada_crtc *dcrtc = drm_to_armada_crtc(crtc); 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 * 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, */ 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 */ ret = dcrtc->variant->compute_clock(dcrtc, adj, NULL); if (ret) -- 2.7.4