diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-07-05 16:51:56 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-09-06 02:03:10 -0400 |
commit | 94352cf9a5328bb1a44288e6c2c1276695f8a356 (patch) | |
tree | b35aebdf6bf472532d5223b0731b5f6daad49850 /drivers/gpu/drm/i915/intel_display.c | |
parent | 9a935856992d68b9194f825ce6e115df7ecc5bca (diff) |
drm/i915: push crtc->fb update into pipe_set_base
Passing in the old fb, having overwritten the current fb, leads to
some neatly convoluted code. It's much simpler if we defer the
crtc->fb update to the place that updates the hw, in pipe_set_base.
This way we also don't need to restore anything in case something
fails - we only update crtc->fb once things have succeeded.
The real reason for this change is that now we keep the old fb
assigned to crtc->fb, which allows us to finally move the crtc disable
case into the common low-level set_mode function in the next patch.
Also don't clobber crtc->x and crtc->y, we neatly pass these down the
callchain already. Unfortunately we can't do the same with crtc->mode,
because that one is being used in the mode_set callbacks.
v2: Don't restore the drm_crtc object any more on failed modesets,
since we've lose an fb reference otherwise. Also (and this is the
reason this has been found), this totally confused the modeset state
tracking, since it clobbers crtc->enabled. Issue reported by Paulo
Zanoni.
v3: Rip out the entire crtc saving into struct intel_set_config, not
just the restoring part.
Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 104 |
1 files changed, 34 insertions, 70 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 5031e0c4a02e..9ce8c59c6b55 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -2201,16 +2201,17 @@ intel_finish_fb(struct drm_framebuffer *old_fb) | |||
2201 | 2201 | ||
2202 | static int | 2202 | static int |
2203 | intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | 2203 | intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, |
2204 | struct drm_framebuffer *old_fb) | 2204 | struct drm_framebuffer *fb) |
2205 | { | 2205 | { |
2206 | struct drm_device *dev = crtc->dev; | 2206 | struct drm_device *dev = crtc->dev; |
2207 | struct drm_i915_private *dev_priv = dev->dev_private; | 2207 | struct drm_i915_private *dev_priv = dev->dev_private; |
2208 | struct drm_i915_master_private *master_priv; | 2208 | struct drm_i915_master_private *master_priv; |
2209 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 2209 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2210 | struct drm_framebuffer *old_fb; | ||
2210 | int ret; | 2211 | int ret; |
2211 | 2212 | ||
2212 | /* no fb bound */ | 2213 | /* no fb bound */ |
2213 | if (!crtc->fb) { | 2214 | if (!fb) { |
2214 | DRM_ERROR("No FB bound\n"); | 2215 | DRM_ERROR("No FB bound\n"); |
2215 | return 0; | 2216 | return 0; |
2216 | } | 2217 | } |
@@ -2224,7 +2225,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
2224 | 2225 | ||
2225 | mutex_lock(&dev->struct_mutex); | 2226 | mutex_lock(&dev->struct_mutex); |
2226 | ret = intel_pin_and_fence_fb_obj(dev, | 2227 | ret = intel_pin_and_fence_fb_obj(dev, |
2227 | to_intel_framebuffer(crtc->fb)->obj, | 2228 | to_intel_framebuffer(fb)->obj, |
2228 | NULL); | 2229 | NULL); |
2229 | if (ret != 0) { | 2230 | if (ret != 0) { |
2230 | mutex_unlock(&dev->struct_mutex); | 2231 | mutex_unlock(&dev->struct_mutex); |
@@ -2232,17 +2233,20 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
2232 | return ret; | 2233 | return ret; |
2233 | } | 2234 | } |
2234 | 2235 | ||
2235 | if (old_fb) | 2236 | if (crtc->fb) |
2236 | intel_finish_fb(old_fb); | 2237 | intel_finish_fb(crtc->fb); |
2237 | 2238 | ||
2238 | ret = dev_priv->display.update_plane(crtc, crtc->fb, x, y); | 2239 | ret = dev_priv->display.update_plane(crtc, fb, x, y); |
2239 | if (ret) { | 2240 | if (ret) { |
2240 | intel_unpin_fb_obj(to_intel_framebuffer(crtc->fb)->obj); | 2241 | intel_unpin_fb_obj(to_intel_framebuffer(fb)->obj); |
2241 | mutex_unlock(&dev->struct_mutex); | 2242 | mutex_unlock(&dev->struct_mutex); |
2242 | DRM_ERROR("failed to update base address\n"); | 2243 | DRM_ERROR("failed to update base address\n"); |
2243 | return ret; | 2244 | return ret; |
2244 | } | 2245 | } |
2245 | 2246 | ||
2247 | old_fb = crtc->fb; | ||
2248 | crtc->fb = fb; | ||
2249 | |||
2246 | if (old_fb) { | 2250 | if (old_fb) { |
2247 | intel_wait_for_vblank(dev, intel_crtc->pipe); | 2251 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
2248 | intel_unpin_fb_obj(to_intel_framebuffer(old_fb)->obj); | 2252 | intel_unpin_fb_obj(to_intel_framebuffer(old_fb)->obj); |
@@ -3777,6 +3781,7 @@ static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) | |||
3777 | * true if they don't match). | 3781 | * true if they don't match). |
3778 | */ | 3782 | */ |
3779 | static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, | 3783 | static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, |
3784 | struct drm_framebuffer *fb, | ||
3780 | unsigned int *pipe_bpp, | 3785 | unsigned int *pipe_bpp, |
3781 | struct drm_display_mode *mode) | 3786 | struct drm_display_mode *mode) |
3782 | { | 3787 | { |
@@ -3846,7 +3851,7 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, | |||
3846 | * also stays within the max display bpc discovered above. | 3851 | * also stays within the max display bpc discovered above. |
3847 | */ | 3852 | */ |
3848 | 3853 | ||
3849 | switch (crtc->fb->depth) { | 3854 | switch (fb->depth) { |
3850 | case 8: | 3855 | case 8: |
3851 | bpc = 8; /* since we go through a colormap */ | 3856 | bpc = 8; /* since we go through a colormap */ |
3852 | break; | 3857 | break; |
@@ -4265,7 +4270,7 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4265 | struct drm_display_mode *mode, | 4270 | struct drm_display_mode *mode, |
4266 | struct drm_display_mode *adjusted_mode, | 4271 | struct drm_display_mode *adjusted_mode, |
4267 | int x, int y, | 4272 | int x, int y, |
4268 | struct drm_framebuffer *old_fb) | 4273 | struct drm_framebuffer *fb) |
4269 | { | 4274 | { |
4270 | struct drm_device *dev = crtc->dev; | 4275 | struct drm_device *dev = crtc->dev; |
4271 | struct drm_i915_private *dev_priv = dev->dev_private; | 4276 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -4455,7 +4460,7 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4455 | I915_WRITE(DSPCNTR(plane), dspcntr); | 4460 | I915_WRITE(DSPCNTR(plane), dspcntr); |
4456 | POSTING_READ(DSPCNTR(plane)); | 4461 | POSTING_READ(DSPCNTR(plane)); |
4457 | 4462 | ||
4458 | ret = intel_pipe_set_base(crtc, x, y, old_fb); | 4463 | ret = intel_pipe_set_base(crtc, x, y, fb); |
4459 | 4464 | ||
4460 | intel_update_watermarks(dev); | 4465 | intel_update_watermarks(dev); |
4461 | 4466 | ||
@@ -4613,7 +4618,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4613 | struct drm_display_mode *mode, | 4618 | struct drm_display_mode *mode, |
4614 | struct drm_display_mode *adjusted_mode, | 4619 | struct drm_display_mode *adjusted_mode, |
4615 | int x, int y, | 4620 | int x, int y, |
4616 | struct drm_framebuffer *old_fb) | 4621 | struct drm_framebuffer *fb) |
4617 | { | 4622 | { |
4618 | struct drm_device *dev = crtc->dev; | 4623 | struct drm_device *dev = crtc->dev; |
4619 | struct drm_i915_private *dev_priv = dev->dev_private; | 4624 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -4733,7 +4738,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4733 | /* determine panel color depth */ | 4738 | /* determine panel color depth */ |
4734 | temp = I915_READ(PIPECONF(pipe)); | 4739 | temp = I915_READ(PIPECONF(pipe)); |
4735 | temp &= ~PIPE_BPC_MASK; | 4740 | temp &= ~PIPE_BPC_MASK; |
4736 | dither = intel_choose_pipe_bpp_dither(crtc, &pipe_bpp, mode); | 4741 | dither = intel_choose_pipe_bpp_dither(crtc, fb, &pipe_bpp, mode); |
4737 | switch (pipe_bpp) { | 4742 | switch (pipe_bpp) { |
4738 | case 18: | 4743 | case 18: |
4739 | temp |= PIPE_6BPC; | 4744 | temp |= PIPE_6BPC; |
@@ -5002,7 +5007,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
5002 | I915_WRITE(DSPCNTR(plane), dspcntr); | 5007 | I915_WRITE(DSPCNTR(plane), dspcntr); |
5003 | POSTING_READ(DSPCNTR(plane)); | 5008 | POSTING_READ(DSPCNTR(plane)); |
5004 | 5009 | ||
5005 | ret = intel_pipe_set_base(crtc, x, y, old_fb); | 5010 | ret = intel_pipe_set_base(crtc, x, y, fb); |
5006 | 5011 | ||
5007 | intel_update_watermarks(dev); | 5012 | intel_update_watermarks(dev); |
5008 | 5013 | ||
@@ -5015,7 +5020,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5015 | struct drm_display_mode *mode, | 5020 | struct drm_display_mode *mode, |
5016 | struct drm_display_mode *adjusted_mode, | 5021 | struct drm_display_mode *adjusted_mode, |
5017 | int x, int y, | 5022 | int x, int y, |
5018 | struct drm_framebuffer *old_fb) | 5023 | struct drm_framebuffer *fb) |
5019 | { | 5024 | { |
5020 | struct drm_device *dev = crtc->dev; | 5025 | struct drm_device *dev = crtc->dev; |
5021 | struct drm_i915_private *dev_priv = dev->dev_private; | 5026 | struct drm_i915_private *dev_priv = dev->dev_private; |
@@ -5026,7 +5031,7 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
5026 | drm_vblank_pre_modeset(dev, pipe); | 5031 | drm_vblank_pre_modeset(dev, pipe); |
5027 | 5032 | ||
5028 | ret = dev_priv->display.crtc_mode_set(crtc, mode, adjusted_mode, | 5033 | ret = dev_priv->display.crtc_mode_set(crtc, mode, adjusted_mode, |
5029 | x, y, old_fb); | 5034 | x, y, fb); |
5030 | drm_vblank_post_modeset(dev, pipe); | 5035 | drm_vblank_post_modeset(dev, pipe); |
5031 | 5036 | ||
5032 | return ret; | 5037 | return ret; |
@@ -5718,7 +5723,7 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, | |||
5718 | struct drm_encoder *encoder = &intel_encoder->base; | 5723 | struct drm_encoder *encoder = &intel_encoder->base; |
5719 | struct drm_crtc *crtc = NULL; | 5724 | struct drm_crtc *crtc = NULL; |
5720 | struct drm_device *dev = encoder->dev; | 5725 | struct drm_device *dev = encoder->dev; |
5721 | struct drm_framebuffer *old_fb; | 5726 | struct drm_framebuffer *fb; |
5722 | int i = -1; | 5727 | int i = -1; |
5723 | 5728 | ||
5724 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", | 5729 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", |
@@ -5779,8 +5784,6 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, | |||
5779 | if (!mode) | 5784 | if (!mode) |
5780 | mode = &load_detect_mode; | 5785 | mode = &load_detect_mode; |
5781 | 5786 | ||
5782 | old_fb = crtc->fb; | ||
5783 | |||
5784 | /* We need a framebuffer large enough to accommodate all accesses | 5787 | /* We need a framebuffer large enough to accommodate all accesses |
5785 | * that the plane may generate whilst we perform load detection. | 5788 | * that the plane may generate whilst we perform load detection. |
5786 | * We can not rely on the fbcon either being present (we get called | 5789 | * We can not rely on the fbcon either being present (we get called |
@@ -5788,19 +5791,19 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, | |||
5788 | * not even exist) or that it is large enough to satisfy the | 5791 | * not even exist) or that it is large enough to satisfy the |
5789 | * requested mode. | 5792 | * requested mode. |
5790 | */ | 5793 | */ |
5791 | crtc->fb = mode_fits_in_fbdev(dev, mode); | 5794 | fb = mode_fits_in_fbdev(dev, mode); |
5792 | if (crtc->fb == NULL) { | 5795 | if (fb == NULL) { |
5793 | DRM_DEBUG_KMS("creating tmp fb for load-detection\n"); | 5796 | DRM_DEBUG_KMS("creating tmp fb for load-detection\n"); |
5794 | crtc->fb = intel_framebuffer_create_for_mode(dev, mode, 24, 32); | 5797 | fb = intel_framebuffer_create_for_mode(dev, mode, 24, 32); |
5795 | old->release_fb = crtc->fb; | 5798 | old->release_fb = fb; |
5796 | } else | 5799 | } else |
5797 | DRM_DEBUG_KMS("reusing fbdev for load-detection framebuffer\n"); | 5800 | DRM_DEBUG_KMS("reusing fbdev for load-detection framebuffer\n"); |
5798 | if (IS_ERR(crtc->fb)) { | 5801 | if (IS_ERR(fb)) { |
5799 | DRM_DEBUG_KMS("failed to allocate framebuffer for load-detection\n"); | 5802 | DRM_DEBUG_KMS("failed to allocate framebuffer for load-detection\n"); |
5800 | goto fail; | 5803 | goto fail; |
5801 | } | 5804 | } |
5802 | 5805 | ||
5803 | if (!intel_set_mode(crtc, mode, 0, 0, old_fb)) { | 5806 | if (!intel_set_mode(crtc, mode, 0, 0, fb)) { |
5804 | DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n"); | 5807 | DRM_DEBUG_KMS("failed to set mode on load-detect pipe\n"); |
5805 | if (old->release_fb) | 5808 | if (old->release_fb) |
5806 | old->release_fb->funcs->destroy(old->release_fb); | 5809 | old->release_fb->funcs->destroy(old->release_fb); |
@@ -5814,7 +5817,6 @@ bool intel_get_load_detect_pipe(struct drm_connector *connector, | |||
5814 | fail: | 5817 | fail: |
5815 | connector->encoder = NULL; | 5818 | connector->encoder = NULL; |
5816 | encoder->crtc = NULL; | 5819 | encoder->crtc = NULL; |
5817 | crtc->fb = old_fb; | ||
5818 | return false; | 5820 | return false; |
5819 | } | 5821 | } |
5820 | 5822 | ||
@@ -6666,13 +6668,12 @@ static void intel_modeset_commit_output_state(struct drm_device *dev) | |||
6666 | 6668 | ||
6667 | bool intel_set_mode(struct drm_crtc *crtc, | 6669 | bool intel_set_mode(struct drm_crtc *crtc, |
6668 | struct drm_display_mode *mode, | 6670 | struct drm_display_mode *mode, |
6669 | int x, int y, struct drm_framebuffer *old_fb) | 6671 | int x, int y, struct drm_framebuffer *fb) |
6670 | { | 6672 | { |
6671 | struct drm_device *dev = crtc->dev; | 6673 | struct drm_device *dev = crtc->dev; |
6672 | drm_i915_private_t *dev_priv = dev->dev_private; | 6674 | drm_i915_private_t *dev_priv = dev->dev_private; |
6673 | struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode; | 6675 | struct drm_display_mode *adjusted_mode, saved_mode, saved_hwmode; |
6674 | struct drm_encoder_helper_funcs *encoder_funcs; | 6676 | struct drm_encoder_helper_funcs *encoder_funcs; |
6675 | int saved_x, saved_y; | ||
6676 | struct drm_encoder *encoder; | 6677 | struct drm_encoder *encoder; |
6677 | bool ret = true; | 6678 | bool ret = true; |
6678 | 6679 | ||
@@ -6686,15 +6687,11 @@ bool intel_set_mode(struct drm_crtc *crtc, | |||
6686 | 6687 | ||
6687 | saved_hwmode = crtc->hwmode; | 6688 | saved_hwmode = crtc->hwmode; |
6688 | saved_mode = crtc->mode; | 6689 | saved_mode = crtc->mode; |
6689 | saved_x = crtc->x; | ||
6690 | saved_y = crtc->y; | ||
6691 | 6690 | ||
6692 | /* Update crtc values up front so the driver can rely on them for mode | 6691 | /* Update crtc values up front so the driver can rely on them for mode |
6693 | * setting. | 6692 | * setting. |
6694 | */ | 6693 | */ |
6695 | crtc->mode = *mode; | 6694 | crtc->mode = *mode; |
6696 | crtc->x = x; | ||
6697 | crtc->y = y; | ||
6698 | 6695 | ||
6699 | /* Pass our mode to the connectors and the CRTC to give them a chance to | 6696 | /* Pass our mode to the connectors and the CRTC to give them a chance to |
6700 | * adjust it according to limitations or connector properties, and also | 6697 | * adjust it according to limitations or connector properties, and also |
@@ -6725,7 +6722,7 @@ bool intel_set_mode(struct drm_crtc *crtc, | |||
6725 | /* Set up the DPLL and any encoders state that needs to adjust or depend | 6722 | /* Set up the DPLL and any encoders state that needs to adjust or depend |
6726 | * on the DPLL. | 6723 | * on the DPLL. |
6727 | */ | 6724 | */ |
6728 | ret = !intel_crtc_mode_set(crtc, mode, adjusted_mode, x, y, old_fb); | 6725 | ret = !intel_crtc_mode_set(crtc, mode, adjusted_mode, x, y, fb); |
6729 | if (!ret) | 6726 | if (!ret) |
6730 | goto done; | 6727 | goto done; |
6731 | 6728 | ||
@@ -6741,6 +6738,9 @@ bool intel_set_mode(struct drm_crtc *crtc, | |||
6741 | encoder_funcs->mode_set(encoder, mode, adjusted_mode); | 6738 | encoder_funcs->mode_set(encoder, mode, adjusted_mode); |
6742 | } | 6739 | } |
6743 | 6740 | ||
6741 | crtc->x = x; | ||
6742 | crtc->y = y; | ||
6743 | |||
6744 | /* Now enable the clocks, plane, pipe, and connectors that we set up. */ | 6744 | /* Now enable the clocks, plane, pipe, and connectors that we set up. */ |
6745 | dev_priv->display.crtc_enable(crtc); | 6745 | dev_priv->display.crtc_enable(crtc); |
6746 | 6746 | ||
@@ -6759,8 +6759,6 @@ done: | |||
6759 | if (!ret) { | 6759 | if (!ret) { |
6760 | crtc->hwmode = saved_hwmode; | 6760 | crtc->hwmode = saved_hwmode; |
6761 | crtc->mode = saved_mode; | 6761 | crtc->mode = saved_mode; |
6762 | crtc->x = saved_x; | ||
6763 | crtc->y = saved_y; | ||
6764 | } | 6762 | } |
6765 | 6763 | ||
6766 | return ret; | 6764 | return ret; |
@@ -6773,25 +6771,16 @@ static void intel_set_config_free(struct intel_set_config *config) | |||
6773 | 6771 | ||
6774 | kfree(config->save_connector_encoders); | 6772 | kfree(config->save_connector_encoders); |
6775 | kfree(config->save_encoder_crtcs); | 6773 | kfree(config->save_encoder_crtcs); |
6776 | kfree(config->save_crtcs); | ||
6777 | kfree(config); | 6774 | kfree(config); |
6778 | } | 6775 | } |
6779 | 6776 | ||
6780 | static int intel_set_config_save_state(struct drm_device *dev, | 6777 | static int intel_set_config_save_state(struct drm_device *dev, |
6781 | struct intel_set_config *config) | 6778 | struct intel_set_config *config) |
6782 | { | 6779 | { |
6783 | struct drm_crtc *crtc; | ||
6784 | struct drm_encoder *encoder; | 6780 | struct drm_encoder *encoder; |
6785 | struct drm_connector *connector; | 6781 | struct drm_connector *connector; |
6786 | int count; | 6782 | int count; |
6787 | 6783 | ||
6788 | /* Allocate space for the backup of all (non-pointer) crtc, encoder and | ||
6789 | * connector data. */ | ||
6790 | config->save_crtcs = kcalloc(dev->mode_config.num_crtc, | ||
6791 | sizeof(struct drm_crtc), GFP_KERNEL); | ||
6792 | if (!config->save_crtcs) | ||
6793 | return -ENOMEM; | ||
6794 | |||
6795 | config->save_encoder_crtcs = | 6784 | config->save_encoder_crtcs = |
6796 | kcalloc(dev->mode_config.num_encoder, | 6785 | kcalloc(dev->mode_config.num_encoder, |
6797 | sizeof(struct drm_crtc *), GFP_KERNEL); | 6786 | sizeof(struct drm_crtc *), GFP_KERNEL); |
@@ -6809,11 +6798,6 @@ static int intel_set_config_save_state(struct drm_device *dev, | |||
6809 | * restored, not the drivers personal bookkeeping. | 6798 | * restored, not the drivers personal bookkeeping. |
6810 | */ | 6799 | */ |
6811 | count = 0; | 6800 | count = 0; |
6812 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
6813 | config->save_crtcs[count++] = *crtc; | ||
6814 | } | ||
6815 | |||
6816 | count = 0; | ||
6817 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { | 6801 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) { |
6818 | config->save_encoder_crtcs[count++] = encoder->crtc; | 6802 | config->save_encoder_crtcs[count++] = encoder->crtc; |
6819 | } | 6803 | } |
@@ -6829,17 +6813,11 @@ static int intel_set_config_save_state(struct drm_device *dev, | |||
6829 | static void intel_set_config_restore_state(struct drm_device *dev, | 6813 | static void intel_set_config_restore_state(struct drm_device *dev, |
6830 | struct intel_set_config *config) | 6814 | struct intel_set_config *config) |
6831 | { | 6815 | { |
6832 | struct drm_crtc *crtc; | ||
6833 | struct intel_encoder *encoder; | 6816 | struct intel_encoder *encoder; |
6834 | struct intel_connector *connector; | 6817 | struct intel_connector *connector; |
6835 | int count; | 6818 | int count; |
6836 | 6819 | ||
6837 | count = 0; | 6820 | count = 0; |
6838 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | ||
6839 | *crtc = config->save_crtcs[count++]; | ||
6840 | } | ||
6841 | |||
6842 | count = 0; | ||
6843 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { | 6821 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { |
6844 | encoder->new_crtc = | 6822 | encoder->new_crtc = |
6845 | to_intel_crtc(config->save_encoder_crtcs[count++]); | 6823 | to_intel_crtc(config->save_encoder_crtcs[count++]); |
@@ -6994,7 +6972,6 @@ next_encoder: | |||
6994 | static int intel_crtc_set_config(struct drm_mode_set *set) | 6972 | static int intel_crtc_set_config(struct drm_mode_set *set) |
6995 | { | 6973 | { |
6996 | struct drm_device *dev; | 6974 | struct drm_device *dev; |
6997 | struct drm_framebuffer *old_fb = NULL; | ||
6998 | struct drm_mode_set save_set; | 6975 | struct drm_mode_set save_set; |
6999 | struct intel_set_config *config; | 6976 | struct intel_set_config *config; |
7000 | int ret; | 6977 | int ret; |
@@ -7057,13 +7034,10 @@ static int intel_crtc_set_config(struct drm_mode_set *set) | |||
7057 | DRM_DEBUG_KMS("attempting to set mode from" | 7034 | DRM_DEBUG_KMS("attempting to set mode from" |
7058 | " userspace\n"); | 7035 | " userspace\n"); |
7059 | drm_mode_debug_printmodeline(set->mode); | 7036 | drm_mode_debug_printmodeline(set->mode); |
7060 | old_fb = set->crtc->fb; | ||
7061 | set->crtc->fb = set->fb; | ||
7062 | if (!intel_set_mode(set->crtc, set->mode, | 7037 | if (!intel_set_mode(set->crtc, set->mode, |
7063 | set->x, set->y, old_fb)) { | 7038 | set->x, set->y, set->fb)) { |
7064 | DRM_ERROR("failed to set mode on [CRTC:%d]\n", | 7039 | DRM_ERROR("failed to set mode on [CRTC:%d]\n", |
7065 | set->crtc->base.id); | 7040 | set->crtc->base.id); |
7066 | set->crtc->fb = old_fb; | ||
7067 | ret = -EINVAL; | 7041 | ret = -EINVAL; |
7068 | goto fail; | 7042 | goto fail; |
7069 | } | 7043 | } |
@@ -7076,18 +7050,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set) | |||
7076 | } | 7050 | } |
7077 | drm_helper_disable_unused_functions(dev); | 7051 | drm_helper_disable_unused_functions(dev); |
7078 | } else if (config->fb_changed) { | 7052 | } else if (config->fb_changed) { |
7079 | set->crtc->x = set->x; | ||
7080 | set->crtc->y = set->y; | ||
7081 | |||
7082 | old_fb = set->crtc->fb; | ||
7083 | if (set->crtc->fb != set->fb) | ||
7084 | set->crtc->fb = set->fb; | ||
7085 | ret = intel_pipe_set_base(set->crtc, | 7053 | ret = intel_pipe_set_base(set->crtc, |
7086 | set->x, set->y, old_fb); | 7054 | set->x, set->y, set->fb); |
7087 | if (ret != 0) { | ||
7088 | set->crtc->fb = old_fb; | ||
7089 | goto fail; | ||
7090 | } | ||
7091 | } | 7055 | } |
7092 | 7056 | ||
7093 | intel_set_config_free(config); | 7057 | intel_set_config_free(config); |