From 5134d8df071372b77783fcef9d2fb63b63edfadf Mon Sep 17 00:00:00 2001 From: Mark Yao Date: Sun, 22 Jan 2017 15:54:24 +0800 Subject: [PATCH] drm/rockchip: dw_hdmi: check display mode with crtc mode valid Change-Id: I23470e46b97169da0b59153dfc0835833f1aa549 Signed-off-by: Mark Yao --- drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 43 ++++++++++++++++++++- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c index fe023bc61ee0..4afa28fe0c2c 100644 --- a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c +++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c @@ -267,6 +267,11 @@ dw_hdmi_rockchip_mode_valid(struct drm_connector *connector, { int pclk = mode->clock * 1000; int num_rates = ARRAY_SIZE(dw_hdmi_rates); + struct drm_encoder *encoder = connector->encoder; + enum drm_mode_status status = MODE_OK; + struct drm_device *dev = connector->dev; + struct rockchip_drm_private *priv = dev->dev_private; + struct drm_crtc *crtc; int i; /* @@ -282,10 +287,44 @@ dw_hdmi_rockchip_mode_valid(struct drm_connector *connector, if ((pclk >= dw_hdmi_rates[i] - slop) && (pclk <= dw_hdmi_rates[i] + slop)) - return MODE_OK; + return MODE_BAD; } - return MODE_BAD; + if (!encoder) { + const struct drm_connector_helper_funcs *funcs; + + funcs = connector->helper_private; + if (funcs->atomic_best_encoder) + encoder = funcs->atomic_best_encoder(connector, + connector->state); + else + encoder = funcs->best_encoder(connector); + } + + if (!encoder || !encoder->possible_crtcs) + return MODE_BAD; + /* + * ensure all drm display mode can work, if someone want support more + * resolutions, please limit the possible_crtc, only connect to + * needed crtc. + */ + drm_for_each_crtc(crtc, connector->dev) { + int pipe = drm_crtc_index(crtc); + const struct rockchip_crtc_funcs *funcs = + priv->crtc_funcs[pipe]; + + if (!(encoder->possible_crtcs & drm_crtc_mask(crtc))) + continue; + if (!funcs || !funcs->mode_valid) + continue; + + status = funcs->mode_valid(crtc, mode, + DRM_MODE_CONNECTOR_HDMIA); + if (status != MODE_OK) + return status; + } + + return status; } static const struct drm_encoder_funcs dw_hdmi_rockchip_encoder_funcs = { -- 2.34.1