Commit c5006cfe authored by Jesse Barnes's avatar Jesse Barnes Committed by Dave Airlie

drm: try to restore previous CRTC config if mode set fails

We restore the CRTC, encoder, and connector configurations, but if the
mode set failed, the attached display may have been turned off, so we
need to try set_config again to restore things to the way they were.
Signed-off-by: default avatarJesse Barnes <jbarnes@virtuousgeek.org>
Reviewed-by: default avatarAlex Deucher <alexdeucher@gmail.com>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent 091264f0
...@@ -484,6 +484,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -484,6 +484,7 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
struct drm_connector *save_connectors, *connector; struct drm_connector *save_connectors, *connector;
int count = 0, ro, fail = 0; int count = 0, ro, fail = 0;
struct drm_crtc_helper_funcs *crtc_funcs; struct drm_crtc_helper_funcs *crtc_funcs;
struct drm_mode_set save_set;
int ret = 0; int ret = 0;
int i; int i;
...@@ -556,6 +557,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -556,6 +557,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
save_connectors[count++] = *connector; save_connectors[count++] = *connector;
} }
save_set.crtc = set->crtc;
save_set.mode = &set->crtc->mode;
save_set.x = set->crtc->x;
save_set.y = set->crtc->y;
save_set.fb = set->crtc->fb;
/* We should be able to check here if the fb has the same properties /* We should be able to check here if the fb has the same properties
* and then just flip_or_move it */ * and then just flip_or_move it */
if (set->crtc->fb != set->fb) { if (set->crtc->fb != set->fb) {
...@@ -721,6 +728,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set) ...@@ -721,6 +728,12 @@ int drm_crtc_helper_set_config(struct drm_mode_set *set)
*connector = save_connectors[count++]; *connector = save_connectors[count++];
} }
/* Try to restore the config */
if (mode_changed &&
!drm_crtc_helper_set_mode(save_set.crtc, save_set.mode, save_set.x,
save_set.y, save_set.fb))
DRM_ERROR("failed to restore config after modeset failure\n");
kfree(save_connectors); kfree(save_connectors);
kfree(save_encoders); kfree(save_encoders);
kfree(save_crtcs); kfree(save_crtcs);
......
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