From: Mark Yao Date: Sun, 22 Jan 2017 07:46:48 +0000 (+0800) Subject: drm/rockchip: cdn-dp: check display mode with crtc mode valid X-Git-Tag: firefly_0821_release~687 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5f675da2d51494da9efdf825bb2981b38495eb60;p=firefly-linux-kernel-4.4.55.git drm/rockchip: cdn-dp: check display mode with crtc mode valid Change-Id: I431ae8e56c18b827e1995ce0dec125c585d096f9 Signed-off-by: Mark Yao --- diff --git a/drivers/gpu/drm/rockchip/cdn-dp-core.c b/drivers/gpu/drm/rockchip/cdn-dp-core.c index 9815856c0462..a11292dfe544 100644 --- a/drivers/gpu/drm/rockchip/cdn-dp-core.c +++ b/drivers/gpu/drm/rockchip/cdn-dp-core.c @@ -265,6 +265,11 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, struct cdn_dp_device *dp = connector_to_dp(connector); struct drm_display_info *display_info = &dp->connector.display_info; u32 requested, actual, rate, sink_max, source_max = 0; + 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; u8 lanes, bpc; /* If DP is disconnected, every mode is invalid */ @@ -305,6 +310,40 @@ static int cdn_dp_connector_mode_valid(struct drm_connector *connector, return MODE_CLOCK_HIGH; } + 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 MODE_OK; }