aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c170
1 files changed, 110 insertions, 60 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index b7005640144c..6e423e04c35e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -892,7 +892,7 @@ enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv,
892 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe]; 892 struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
893 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 893 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
894 894
895 return intel_crtc->cpu_transcoder; 895 return intel_crtc->config.cpu_transcoder;
896} 896}
897 897
898static void ironlake_wait_for_vblank(struct drm_device *dev, int pipe) 898static void ironlake_wait_for_vblank(struct drm_device *dev, int pipe)
@@ -1227,8 +1227,8 @@ void assert_pipe(struct drm_i915_private *dev_priv,
1227 if (pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) 1227 if (pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE)
1228 state = true; 1228 state = true;
1229 1229
1230 if (IS_HASWELL(dev_priv->dev) && cpu_transcoder != TRANSCODER_EDP && 1230 if (!intel_using_power_well(dev_priv->dev) &&
1231 !(I915_READ(HSW_PWR_WELL_DRIVER) & HSW_PWR_WELL_ENABLE)) { 1231 cpu_transcoder != TRANSCODER_EDP) {
1232 cur_state = false; 1232 cur_state = false;
1233 } else { 1233 } else {
1234 reg = PIPECONF(cpu_transcoder); 1234 reg = PIPECONF(cpu_transcoder);
@@ -2002,8 +2002,10 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev,
2002 alignment = 0; 2002 alignment = 0;
2003 break; 2003 break;
2004 case I915_TILING_Y: 2004 case I915_TILING_Y:
2005 /* FIXME: Is this true? */ 2005 /* Despite that we check this in framebuffer_init userspace can
2006 DRM_ERROR("Y tiled not allowed for scan out buffers\n"); 2006 * screw us over and change the tiling after the fact. Only
2007 * pinned buffers can't change their tiling. */
2008 DRM_DEBUG_DRIVER("Y tiled not allowed for scan out buffers\n");
2007 return -EINVAL; 2009 return -EINVAL;
2008 default: 2010 default:
2009 BUG(); 2011 BUG();
@@ -3201,7 +3203,7 @@ static void lpt_pch_enable(struct drm_crtc *crtc)
3201 struct drm_device *dev = crtc->dev; 3203 struct drm_device *dev = crtc->dev;
3202 struct drm_i915_private *dev_priv = dev->dev_private; 3204 struct drm_i915_private *dev_priv = dev->dev_private;
3203 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 3205 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3204 enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; 3206 enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
3205 3207
3206 assert_transcoder_disabled(dev_priv, TRANSCODER_A); 3208 assert_transcoder_disabled(dev_priv, TRANSCODER_A);
3207 3209
@@ -3576,7 +3578,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
3576 struct intel_encoder *encoder; 3578 struct intel_encoder *encoder;
3577 int pipe = intel_crtc->pipe; 3579 int pipe = intel_crtc->pipe;
3578 int plane = intel_crtc->plane; 3580 int plane = intel_crtc->plane;
3579 enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; 3581 enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
3580 3582
3581 if (!intel_crtc->active) 3583 if (!intel_crtc->active)
3582 return; 3584 return;
@@ -3597,9 +3599,13 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
3597 3599
3598 intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder); 3600 intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
3599 3601
3600 /* Disable PF */ 3602 /* XXX: Once we have proper panel fitter state tracking implemented with
3601 I915_WRITE(PF_CTL(pipe), 0); 3603 * hardware state read/check support we should switch to only disable
3602 I915_WRITE(PF_WIN_SZ(pipe), 0); 3604 * the panel fitter when we know it's used. */
3605 if (intel_using_power_well(dev)) {
3606 I915_WRITE(PF_CTL(pipe), 0);
3607 I915_WRITE(PF_WIN_SZ(pipe), 0);
3608 }
3603 3609
3604 intel_ddi_disable_pipe_clock(intel_crtc); 3610 intel_ddi_disable_pipe_clock(intel_crtc);
3605 3611
@@ -3632,7 +3638,7 @@ static void haswell_crtc_off(struct drm_crtc *crtc)
3632 3638
3633 /* Stop saying we're using TRANSCODER_EDP because some other CRTC might 3639 /* Stop saying we're using TRANSCODER_EDP because some other CRTC might
3634 * start using it. */ 3640 * start using it. */
3635 intel_crtc->cpu_transcoder = (enum transcoder) intel_crtc->pipe; 3641 intel_crtc->config.cpu_transcoder = (enum transcoder) intel_crtc->pipe;
3636 3642
3637 intel_ddi_put_crtc_pll(crtc); 3643 intel_ddi_put_crtc_pll(crtc);
3638} 3644}
@@ -3718,6 +3724,26 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
3718 encoder->enable(encoder); 3724 encoder->enable(encoder);
3719} 3725}
3720 3726
3727static void i9xx_pfit_disable(struct intel_crtc *crtc)
3728{
3729 struct drm_device *dev = crtc->base.dev;
3730 struct drm_i915_private *dev_priv = dev->dev_private;
3731 enum pipe pipe;
3732 uint32_t pctl = I915_READ(PFIT_CONTROL);
3733
3734 assert_pipe_disabled(dev_priv, crtc->pipe);
3735
3736 if (INTEL_INFO(dev)->gen >= 4)
3737 pipe = (pctl & PFIT_PIPE_MASK) >> PFIT_PIPE_SHIFT;
3738 else
3739 pipe = PIPE_B;
3740
3741 if (pipe == crtc->pipe) {
3742 DRM_DEBUG_DRIVER("disabling pfit, current: 0x%08x\n", pctl);
3743 I915_WRITE(PFIT_CONTROL, 0);
3744 }
3745}
3746
3721static void i9xx_crtc_disable(struct drm_crtc *crtc) 3747static void i9xx_crtc_disable(struct drm_crtc *crtc)
3722{ 3748{
3723 struct drm_device *dev = crtc->dev; 3749 struct drm_device *dev = crtc->dev;
@@ -3726,8 +3752,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
3726 struct intel_encoder *encoder; 3752 struct intel_encoder *encoder;
3727 int pipe = intel_crtc->pipe; 3753 int pipe = intel_crtc->pipe;
3728 int plane = intel_crtc->plane; 3754 int plane = intel_crtc->plane;
3729 u32 pctl;
3730
3731 3755
3732 if (!intel_crtc->active) 3756 if (!intel_crtc->active)
3733 return; 3757 return;
@@ -3747,11 +3771,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
3747 intel_disable_plane(dev_priv, plane, pipe); 3771 intel_disable_plane(dev_priv, plane, pipe);
3748 intel_disable_pipe(dev_priv, pipe); 3772 intel_disable_pipe(dev_priv, pipe);
3749 3773
3750 /* Disable pannel fitter if it is on this pipe. */ 3774 i9xx_pfit_disable(intel_crtc);
3751 pctl = I915_READ(PFIT_CONTROL);
3752 if ((pctl & PFIT_ENABLE) &&
3753 ((pctl & PFIT_PIPE_MASK) >> PFIT_PIPE_SHIFT) == pipe)
3754 I915_WRITE(PFIT_CONTROL, 0);
3755 3775
3756 intel_disable_pll(dev_priv, pipe); 3776 intel_disable_pll(dev_priv, pipe);
3757 3777
@@ -3983,9 +4003,9 @@ static bool intel_crtc_compute_config(struct drm_crtc *crtc,
3983 adjusted_mode->hsync_start == adjusted_mode->hdisplay) 4003 adjusted_mode->hsync_start == adjusted_mode->hdisplay)
3984 return false; 4004 return false;
3985 4005
3986 if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)) && pipe_config->pipe_bpp > 10) { 4006 if ((IS_G4X(dev) || IS_VALLEYVIEW(dev)) && pipe_config->pipe_bpp > 10*3) {
3987 pipe_config->pipe_bpp = 10*3; /* 12bpc is gen5+ */ 4007 pipe_config->pipe_bpp = 10*3; /* 12bpc is gen5+ */
3988 } else if (INTEL_INFO(dev)->gen <= 4 && pipe_config->pipe_bpp > 8) { 4008 } else if (INTEL_INFO(dev)->gen <= 4 && pipe_config->pipe_bpp > 8*3) {
3989 /* only a 8bpc pipe, with 6bpc dither through the panel fitter 4009 /* only a 8bpc pipe, with 6bpc dither through the panel fitter
3990 * for lvds. */ 4010 * for lvds. */
3991 pipe_config->pipe_bpp = 8*3; 4011 pipe_config->pipe_bpp = 8*3;
@@ -4474,7 +4494,7 @@ static void intel_set_pipe_timings(struct intel_crtc *intel_crtc,
4474 struct drm_device *dev = intel_crtc->base.dev; 4494 struct drm_device *dev = intel_crtc->base.dev;
4475 struct drm_i915_private *dev_priv = dev->dev_private; 4495 struct drm_i915_private *dev_priv = dev->dev_private;
4476 enum pipe pipe = intel_crtc->pipe; 4496 enum pipe pipe = intel_crtc->pipe;
4477 enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; 4497 enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
4478 uint32_t vsyncshift; 4498 uint32_t vsyncshift;
4479 4499
4480 if (!IS_GEN2(dev) && adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) { 4500 if (!IS_GEN2(dev) && adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) {
@@ -4956,13 +4976,6 @@ static void lpt_init_pch_refclk(struct drm_device *dev)
4956 tmp |= (0x12 << 24); 4976 tmp |= (0x12 << 24);
4957 intel_sbi_write(dev_priv, 0x8008, tmp, SBI_MPHY); 4977 intel_sbi_write(dev_priv, 0x8008, tmp, SBI_MPHY);
4958 4978
4959 if (!is_sdv) {
4960 tmp = intel_sbi_read(dev_priv, 0x808C, SBI_MPHY);
4961 tmp &= ~(0x3 << 6);
4962 tmp |= (1 << 6) | (1 << 0);
4963 intel_sbi_write(dev_priv, 0x808C, tmp, SBI_MPHY);
4964 }
4965
4966 if (is_sdv) { 4979 if (is_sdv) {
4967 tmp = intel_sbi_read(dev_priv, 0x800C, SBI_MPHY); 4980 tmp = intel_sbi_read(dev_priv, 0x800C, SBI_MPHY);
4968 tmp |= 0x7FFF; 4981 tmp |= 0x7FFF;
@@ -5223,7 +5236,7 @@ static void haswell_set_pipeconf(struct drm_crtc *crtc,
5223{ 5236{
5224 struct drm_i915_private *dev_priv = crtc->dev->dev_private; 5237 struct drm_i915_private *dev_priv = crtc->dev->dev_private;
5225 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 5238 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5226 enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; 5239 enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
5227 uint32_t val; 5240 uint32_t val;
5228 5241
5229 val = I915_READ(PIPECONF(cpu_transcoder)); 5242 val = I915_READ(PIPECONF(cpu_transcoder));
@@ -5417,7 +5430,7 @@ void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc,
5417 struct drm_device *dev = crtc->base.dev; 5430 struct drm_device *dev = crtc->base.dev;
5418 struct drm_i915_private *dev_priv = dev->dev_private; 5431 struct drm_i915_private *dev_priv = dev->dev_private;
5419 int pipe = crtc->pipe; 5432 int pipe = crtc->pipe;
5420 enum transcoder transcoder = crtc->cpu_transcoder; 5433 enum transcoder transcoder = crtc->config.cpu_transcoder;
5421 5434
5422 if (INTEL_INFO(dev)->gen >= 5) { 5435 if (INTEL_INFO(dev)->gen >= 5) {
5423 I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m); 5436 I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m);
@@ -5469,7 +5482,8 @@ static void ironlake_fdi_set_m_n(struct drm_crtc *crtc)
5469} 5482}
5470 5483
5471static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, 5484static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
5472 intel_clock_t *clock, u32 fp) 5485 intel_clock_t *clock, u32 *fp,
5486 intel_clock_t *reduced_clock, u32 *fp2)
5473{ 5487{
5474 struct drm_crtc *crtc = &intel_crtc->base; 5488 struct drm_crtc *crtc = &intel_crtc->base;
5475 struct drm_device *dev = crtc->dev; 5489 struct drm_device *dev = crtc->dev;
@@ -5503,13 +5517,16 @@ static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc,
5503 if (is_lvds) { 5517 if (is_lvds) {
5504 if ((intel_panel_use_ssc(dev_priv) && 5518 if ((intel_panel_use_ssc(dev_priv) &&
5505 dev_priv->lvds_ssc_freq == 100) || 5519 dev_priv->lvds_ssc_freq == 100) ||
5506 intel_is_dual_link_lvds(dev)) 5520 (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev)))
5507 factor = 25; 5521 factor = 25;
5508 } else if (is_sdvo && is_tv) 5522 } else if (is_sdvo && is_tv)
5509 factor = 20; 5523 factor = 20;
5510 5524
5511 if (clock->m < factor * clock->n) 5525 if (clock->m < factor * clock->n)
5512 fp |= FP_CB_TUNE; 5526 *fp |= FP_CB_TUNE;
5527
5528 if (fp2 && (reduced_clock->m < factor * reduced_clock->n))
5529 *fp2 |= FP_CB_TUNE;
5513 5530
5514 dpll = 0; 5531 dpll = 0;
5515 5532
@@ -5596,7 +5613,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5596 WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)), 5613 WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)),
5597 "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev)); 5614 "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev));
5598 5615
5599 intel_crtc->cpu_transcoder = pipe; 5616 intel_crtc->config.cpu_transcoder = pipe;
5600 5617
5601 ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock, 5618 ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock,
5602 &has_reduced_clock, &reduced_clock); 5619 &has_reduced_clock, &reduced_clock);
@@ -5626,7 +5643,8 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5626 fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 | 5643 fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 |
5627 reduced_clock.m2; 5644 reduced_clock.m2;
5628 5645
5629 dpll = ironlake_compute_dpll(intel_crtc, &clock, fp); 5646 dpll = ironlake_compute_dpll(intel_crtc, &clock, &fp, &reduced_clock,
5647 has_reduced_clock ? &fp2 : NULL);
5630 5648
5631 DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe); 5649 DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe);
5632 drm_mode_debug_printmodeline(mode); 5650 drm_mode_debug_printmodeline(mode);
@@ -5779,9 +5797,9 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
5779 } 5797 }
5780 5798
5781 if (is_cpu_edp) 5799 if (is_cpu_edp)
5782 intel_crtc->cpu_transcoder = TRANSCODER_EDP; 5800 intel_crtc->config.cpu_transcoder = TRANSCODER_EDP;
5783 else 5801 else
5784 intel_crtc->cpu_transcoder = pipe; 5802 intel_crtc->config.cpu_transcoder = pipe;
5785 5803
5786 /* We are not sure yet this won't happen. */ 5804 /* We are not sure yet this won't happen. */
5787 WARN(!HAS_PCH_LPT(dev), "Unexpected PCH type %d\n", 5805 WARN(!HAS_PCH_LPT(dev), "Unexpected PCH type %d\n",
@@ -5790,7 +5808,7 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
5790 WARN(num_connectors != 1, "%d connectors attached to pipe %c\n", 5808 WARN(num_connectors != 1, "%d connectors attached to pipe %c\n",
5791 num_connectors, pipe_name(pipe)); 5809 num_connectors, pipe_name(pipe));
5792 5810
5793 WARN_ON(I915_READ(PIPECONF(intel_crtc->cpu_transcoder)) & 5811 WARN_ON(I915_READ(PIPECONF(intel_crtc->config.cpu_transcoder)) &
5794 (PIPECONF_ENABLE | I965_PIPECONF_ACTIVE)); 5812 (PIPECONF_ENABLE | I965_PIPECONF_ACTIVE));
5795 5813
5796 WARN_ON(I915_READ(DSPCNTR(plane)) & DISPLAY_PLANE_ENABLE); 5814 WARN_ON(I915_READ(DSPCNTR(plane)) & DISPLAY_PLANE_ENABLE);
@@ -5841,7 +5859,7 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
5841 struct drm_i915_private *dev_priv = dev->dev_private; 5859 struct drm_i915_private *dev_priv = dev->dev_private;
5842 uint32_t tmp; 5860 uint32_t tmp;
5843 5861
5844 tmp = I915_READ(PIPECONF(crtc->cpu_transcoder)); 5862 tmp = I915_READ(PIPECONF(crtc->config.cpu_transcoder));
5845 if (!(tmp & PIPECONF_ENABLE)) 5863 if (!(tmp & PIPECONF_ENABLE))
5846 return false; 5864 return false;
5847 5865
@@ -6809,7 +6827,7 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev,
6809{ 6827{
6810 struct drm_i915_private *dev_priv = dev->dev_private; 6828 struct drm_i915_private *dev_priv = dev->dev_private;
6811 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 6829 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
6812 enum transcoder cpu_transcoder = intel_crtc->cpu_transcoder; 6830 enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder;
6813 struct drm_display_mode *mode; 6831 struct drm_display_mode *mode;
6814 int htot = I915_READ(HTOTAL(cpu_transcoder)); 6832 int htot = I915_READ(HTOTAL(cpu_transcoder));
6815 int hsync = I915_READ(HSYNC(cpu_transcoder)); 6833 int hsync = I915_READ(HSYNC(cpu_transcoder));
@@ -7708,22 +7726,25 @@ intel_modeset_affected_pipes(struct drm_crtc *crtc, unsigned *modeset_pipes,
7708 if (crtc->enabled) 7726 if (crtc->enabled)
7709 *prepare_pipes |= 1 << intel_crtc->pipe; 7727 *prepare_pipes |= 1 << intel_crtc->pipe;
7710 7728
7711 /* We only support modeset on one single crtc, hence we need to do that 7729 /*
7712 * only for the passed in crtc iff we change anything else than just 7730 * For simplicity do a full modeset on any pipe where the output routing
7713 * disable crtcs. 7731 * changed. We could be more clever, but that would require us to be
7714 * 7732 * more careful with calling the relevant encoder->mode_set functions.
7715 * This is actually not true, to be fully compatible with the old crtc 7733 */
7716 * helper we automatically disable _any_ output (i.e. doesn't need to be
7717 * connected to the crtc we're modesetting on) if it's disconnected.
7718 * Which is a rather nutty api (since changed the output configuration
7719 * without userspace's explicit request can lead to confusion), but
7720 * alas. Hence we currently need to modeset on all pipes we prepare. */
7721 if (*prepare_pipes) 7734 if (*prepare_pipes)
7722 *modeset_pipes = *prepare_pipes; 7735 *modeset_pipes = *prepare_pipes;
7723 7736
7724 /* ... and mask these out. */ 7737 /* ... and mask these out. */
7725 *modeset_pipes &= ~(*disable_pipes); 7738 *modeset_pipes &= ~(*disable_pipes);
7726 *prepare_pipes &= ~(*disable_pipes); 7739 *prepare_pipes &= ~(*disable_pipes);
7740
7741 /*
7742 * HACK: We don't (yet) fully support global modesets. intel_set_config
7743 * obies this rule, but the modeset restore mode of
7744 * intel_modeset_setup_hw_state does not.
7745 */
7746 *modeset_pipes &= 1 << intel_crtc->pipe;
7747 *prepare_pipes &= 1 << intel_crtc->pipe;
7727} 7748}
7728 7749
7729static bool intel_crtc_in_use(struct drm_crtc *crtc) 7750static bool intel_crtc_in_use(struct drm_crtc *crtc)
@@ -7916,9 +7937,9 @@ intel_modeset_check_state(struct drm_device *dev)
7916 } 7937 }
7917} 7938}
7918 7939
7919int intel_set_mode(struct drm_crtc *crtc, 7940static int __intel_set_mode(struct drm_crtc *crtc,
7920 struct drm_display_mode *mode, 7941 struct drm_display_mode *mode,
7921 int x, int y, struct drm_framebuffer *fb) 7942 int x, int y, struct drm_framebuffer *fb)
7922{ 7943{
7923 struct drm_device *dev = crtc->dev; 7944 struct drm_device *dev = crtc->dev;
7924 drm_i915_private_t *dev_priv = dev->dev_private; 7945 drm_i915_private_t *dev_priv = dev->dev_private;
@@ -7969,10 +7990,12 @@ int intel_set_mode(struct drm_crtc *crtc,
7969 * to set it here already despite that we pass it down the callchain. 7990 * to set it here already despite that we pass it down the callchain.
7970 */ 7991 */
7971 if (modeset_pipes) { 7992 if (modeset_pipes) {
7993 enum transcoder tmp = to_intel_crtc(crtc)->config.cpu_transcoder;
7972 crtc->mode = *mode; 7994 crtc->mode = *mode;
7973 /* mode_set/enable/disable functions rely on a correct pipe 7995 /* mode_set/enable/disable functions rely on a correct pipe
7974 * config. */ 7996 * config. */
7975 to_intel_crtc(crtc)->config = *pipe_config; 7997 to_intel_crtc(crtc)->config = *pipe_config;
7998 to_intel_crtc(crtc)->config.cpu_transcoder = tmp;
7976 } 7999 }
7977 8000
7978 /* Only after disabling all output pipelines that will be changed can we 8001 /* Only after disabling all output pipelines that will be changed can we
@@ -8012,8 +8035,6 @@ done:
8012 if (ret && crtc->enabled) { 8035 if (ret && crtc->enabled) {
8013 crtc->hwmode = *saved_hwmode; 8036 crtc->hwmode = *saved_hwmode;
8014 crtc->mode = *saved_mode; 8037 crtc->mode = *saved_mode;
8015 } else {
8016 intel_modeset_check_state(dev);
8017 } 8038 }
8018 8039
8019out: 8040out:
@@ -8022,6 +8043,20 @@ out:
8022 return ret; 8043 return ret;
8023} 8044}
8024 8045
8046int intel_set_mode(struct drm_crtc *crtc,
8047 struct drm_display_mode *mode,
8048 int x, int y, struct drm_framebuffer *fb)
8049{
8050 int ret;
8051
8052 ret = __intel_set_mode(crtc, mode, x, y, fb);
8053
8054 if (ret == 0)
8055 intel_modeset_check_state(crtc->dev);
8056
8057 return ret;
8058}
8059
8025void intel_crtc_restore_mode(struct drm_crtc *crtc) 8060void intel_crtc_restore_mode(struct drm_crtc *crtc)
8026{ 8061{
8027 intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->fb); 8062 intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->fb);
@@ -8371,7 +8406,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
8371 /* Swap pipes & planes for FBC on pre-965 */ 8406 /* Swap pipes & planes for FBC on pre-965 */
8372 intel_crtc->pipe = pipe; 8407 intel_crtc->pipe = pipe;
8373 intel_crtc->plane = pipe; 8408 intel_crtc->plane = pipe;
8374 intel_crtc->cpu_transcoder = pipe; 8409 intel_crtc->config.cpu_transcoder = pipe;
8375 if (IS_MOBILE(dev) && IS_GEN3(dev)) { 8410 if (IS_MOBILE(dev) && IS_GEN3(dev)) {
8376 DRM_DEBUG_KMS("swapping pipes & planes for FBC\n"); 8411 DRM_DEBUG_KMS("swapping pipes & planes for FBC\n");
8377 intel_crtc->plane = !pipe; 8412 intel_crtc->plane = !pipe;
@@ -8462,7 +8497,7 @@ static void intel_setup_outputs(struct drm_device *dev)
8462 I915_WRITE(PFIT_CONTROL, 0); 8497 I915_WRITE(PFIT_CONTROL, 0);
8463 } 8498 }
8464 8499
8465 if (!(HAS_DDI(dev) && (I915_READ(DDI_BUF_CTL(PORT_A)) & DDI_A_4_LANES))) 8500 if (!IS_ULT(dev))
8466 intel_crt_init(dev); 8501 intel_crt_init(dev);
8467 8502
8468 if (HAS_DDI(dev)) { 8503 if (HAS_DDI(dev)) {
@@ -8991,6 +9026,9 @@ void intel_modeset_init(struct drm_device *dev)
8991 9026
8992 intel_init_pm(dev); 9027 intel_init_pm(dev);
8993 9028
9029 if (INTEL_INFO(dev)->num_pipes == 0)
9030 return;
9031
8994 intel_init_display(dev); 9032 intel_init_display(dev);
8995 9033
8996 if (IS_GEN2(dev)) { 9034 if (IS_GEN2(dev)) {
@@ -9093,7 +9131,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc)
9093 u32 reg; 9131 u32 reg;
9094 9132
9095 /* Clear any frame start delays used for debugging left by the BIOS */ 9133 /* Clear any frame start delays used for debugging left by the BIOS */
9096 reg = PIPECONF(crtc->cpu_transcoder); 9134 reg = PIPECONF(crtc->config.cpu_transcoder);
9097 I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK); 9135 I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK);
9098 9136
9099 /* We need to sanitize the plane -> pipe mapping first because this will 9137 /* We need to sanitize the plane -> pipe mapping first because this will
@@ -9259,7 +9297,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
9259 } 9297 }
9260 9298
9261 crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); 9299 crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]);
9262 crtc->cpu_transcoder = TRANSCODER_EDP; 9300 crtc->config.cpu_transcoder = TRANSCODER_EDP;
9263 9301
9264 DRM_DEBUG_KMS("Pipe %c using transcoder EDP\n", 9302 DRM_DEBUG_KMS("Pipe %c using transcoder EDP\n",
9265 pipe_name(pipe)); 9303 pipe_name(pipe));
@@ -9269,7 +9307,10 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
9269setup_pipes: 9307setup_pipes:
9270 list_for_each_entry(crtc, &dev->mode_config.crtc_list, 9308 list_for_each_entry(crtc, &dev->mode_config.crtc_list,
9271 base.head) { 9309 base.head) {
9310 enum transcoder tmp = crtc->config.cpu_transcoder;
9272 memset(&crtc->config, 0, sizeof(crtc->config)); 9311 memset(&crtc->config, 0, sizeof(crtc->config));
9312 crtc->config.cpu_transcoder = tmp;
9313
9273 crtc->active = dev_priv->display.get_pipe_config(crtc, 9314 crtc->active = dev_priv->display.get_pipe_config(crtc,
9274 &crtc->config); 9315 &crtc->config);
9275 9316
@@ -9330,10 +9371,16 @@ setup_pipes:
9330 } 9371 }
9331 9372
9332 if (force_restore) { 9373 if (force_restore) {
9374 /*
9375 * We need to use raw interfaces for restoring state to avoid
9376 * checking (bogus) intermediate states.
9377 */
9333 for_each_pipe(pipe) { 9378 for_each_pipe(pipe) {
9334 struct drm_crtc *crtc = 9379 struct drm_crtc *crtc =
9335 dev_priv->pipe_to_crtc_mapping[pipe]; 9380 dev_priv->pipe_to_crtc_mapping[pipe];
9336 intel_crtc_restore_mode(crtc); 9381
9382 __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y,
9383 crtc->fb);
9337 } 9384 }
9338 list_for_each_entry(plane, &dev->mode_config.plane_list, head) 9385 list_for_each_entry(plane, &dev->mode_config.plane_list, head)
9339 intel_plane_restore(plane); 9386 intel_plane_restore(plane);
@@ -9398,6 +9445,9 @@ void intel_modeset_cleanup(struct drm_device *dev)
9398 /* flush any delayed tasks or pending work */ 9445 /* flush any delayed tasks or pending work */
9399 flush_scheduled_work(); 9446 flush_scheduled_work();
9400 9447
9448 /* destroy backlight, if any, before the connectors */
9449 intel_panel_destroy_backlight(dev);
9450
9401 drm_mode_config_cleanup(dev); 9451 drm_mode_config_cleanup(dev);
9402 9452
9403 intel_cleanup_overlay(dev); 9453 intel_cleanup_overlay(dev);