From: Mark Yao Date: Fri, 31 Mar 2017 07:20:07 +0000 (+0800) Subject: drm/rockchip: protect connector status with loader protect X-Git-Tag: firefly_0821_release~148 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e0881ef2dc3694b0cf2c5207dd92c4c8e7305214;p=firefly-linux-kernel-4.4.55.git drm/rockchip: protect connector status with loader protect In order to keep display not flash, we cheat all connectors status as power on, but actually the connector's driver think it's off. So when power off connector, we need correct connector's status first. Change-Id: I9fa09d184197c71220d33666564876fc3b1212a7 Signed-off-by: Mark Yao --- diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c index df3d47b176bb..6ac31a9f8260 100644 --- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c @@ -965,19 +965,11 @@ static int analogix_dp_loader_protect(struct drm_connector *connector, bool on) { struct analogix_dp_device *dp = to_dp(connector); - if (on == connector->loader_protect) - return 0; - - if (on) { + if (on) pm_runtime_get_sync(dp->dev); - - connector->loader_protect = true; - } else { + else pm_runtime_put(dp->dev); - connector->loader_protect = false; - } - return 0; } @@ -1113,10 +1105,6 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge) dp->plat_data->power_off(dp->plat_data); pm_runtime_put_sync(dp->dev); - if (dp->connector.loader_protect) { - pm_runtime_put_sync(dp->dev); - dp->connector.loader_protect = false; - } dp->dpms_mode = DRM_MODE_DPMS_OFF; } diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c index 40a67eb373fa..d5524917e7c4 100644 --- a/drivers/gpu/drm/drm_atomic_helper.c +++ b/drivers/gpu/drm/drm_atomic_helper.c @@ -579,6 +579,7 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) for_each_connector_in_state(old_state, connector, old_conn_state, i) { const struct drm_encoder_helper_funcs *funcs; + const struct drm_connector_helper_funcs *conn_funcs; struct drm_encoder *encoder; struct drm_crtc_state *old_crtc_state; @@ -606,6 +607,21 @@ disable_outputs(struct drm_device *dev, struct drm_atomic_state *old_state) DRM_DEBUG_ATOMIC("disabling [ENCODER:%d:%s]\n", encoder->base.id, encoder->name); + conn_funcs = connector->helper_private; + if (connector->loader_protect) { + drm_bridge_pre_enable(encoder->bridge); + + if (funcs->enable) + funcs->enable(encoder); + else + funcs->commit(encoder); + + drm_bridge_enable(encoder->bridge); + + if (conn_funcs->loader_protect) + conn_funcs->loader_protect(connector, false); + connector->loader_protect = false; + } /* * Each encoder has at most one connector (since we always steal * it away), so we won't call disable hooks twice. diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c index 59605f9056af..af4e8ea763be 100644 --- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c +++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c @@ -329,6 +329,7 @@ int setup_initial_state(struct drm_device *drm_dev, conn_state->best_encoder = funcs->best_encoder(connector); if (funcs->loader_protect) funcs->loader_protect(connector, true); + connector->loader_protect = true; num_modes = connector->funcs->fill_modes(connector, 4096, 4096); if (!num_modes) { dev_err(drm_dev->dev, "connector[%s] can't found any modes\n", @@ -437,6 +438,7 @@ int setup_initial_state(struct drm_device *drm_dev, error: if (funcs->loader_protect) funcs->loader_protect(connector, false); + connector->loader_protect = false; return ret; }