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.c384
1 files changed, 301 insertions, 83 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e9a0df8a437b..853697fc4d4b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2931,8 +2931,6 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2931 return ret; 2931 return ret;
2932 } 2932 }
2933 2933
2934 intel_update_pipe_size(intel_crtc);
2935
2936 dev_priv->display.update_primary_plane(crtc, fb, x, y); 2934 dev_priv->display.update_primary_plane(crtc, fb, x, y);
2937 2935
2938 if (intel_crtc->active) 2936 if (intel_crtc->active)
@@ -4005,6 +4003,19 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
4005 } 4003 }
4006} 4004}
4007 4005
4006static void skylake_pfit_enable(struct intel_crtc *crtc)
4007{
4008 struct drm_device *dev = crtc->base.dev;
4009 struct drm_i915_private *dev_priv = dev->dev_private;
4010 int pipe = crtc->pipe;
4011
4012 if (crtc->config.pch_pfit.enabled) {
4013 I915_WRITE(PS_CTL(pipe), PS_ENABLE);
4014 I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos);
4015 I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size);
4016 }
4017}
4018
4008static void ironlake_pfit_enable(struct intel_crtc *crtc) 4019static void ironlake_pfit_enable(struct intel_crtc *crtc)
4009{ 4020{
4010 struct drm_device *dev = crtc->base.dev; 4021 struct drm_device *dev = crtc->base.dev;
@@ -4388,7 +4399,10 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
4388 4399
4389 intel_ddi_enable_pipe_clock(intel_crtc); 4400 intel_ddi_enable_pipe_clock(intel_crtc);
4390 4401
4391 ironlake_pfit_enable(intel_crtc); 4402 if (IS_SKYLAKE(dev))
4403 skylake_pfit_enable(intel_crtc);
4404 else
4405 ironlake_pfit_enable(intel_crtc);
4392 4406
4393 /* 4407 /*
4394 * On ILK+ LUT must be loaded before the pipe is running but with 4408 * On ILK+ LUT must be loaded before the pipe is running but with
@@ -4422,6 +4436,21 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
4422 intel_crtc_enable_planes(crtc); 4436 intel_crtc_enable_planes(crtc);
4423} 4437}
4424 4438
4439static void skylake_pfit_disable(struct intel_crtc *crtc)
4440{
4441 struct drm_device *dev = crtc->base.dev;
4442 struct drm_i915_private *dev_priv = dev->dev_private;
4443 int pipe = crtc->pipe;
4444
4445 /* To avoid upsetting the power well on haswell only disable the pfit if
4446 * it's in use. The hw state code will make sure we get this right. */
4447 if (crtc->config.pch_pfit.enabled) {
4448 I915_WRITE(PS_CTL(pipe), 0);
4449 I915_WRITE(PS_WIN_POS(pipe), 0);
4450 I915_WRITE(PS_WIN_SZ(pipe), 0);
4451 }
4452}
4453
4425static void ironlake_pfit_disable(struct intel_crtc *crtc) 4454static void ironlake_pfit_disable(struct intel_crtc *crtc)
4426{ 4455{
4427 struct drm_device *dev = crtc->base.dev; 4456 struct drm_device *dev = crtc->base.dev;
@@ -4534,7 +4563,10 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
4534 4563
4535 intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder); 4564 intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder);
4536 4565
4537 ironlake_pfit_disable(intel_crtc); 4566 if (IS_SKYLAKE(dev))
4567 skylake_pfit_disable(intel_crtc);
4568 else
4569 ironlake_pfit_disable(intel_crtc);
4538 4570
4539 intel_ddi_disable_pipe_clock(intel_crtc); 4571 intel_ddi_disable_pipe_clock(intel_crtc);
4540 4572
@@ -4907,10 +4939,23 @@ static void valleyview_modeset_global_resources(struct drm_device *dev)
4907 int req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk); 4939 int req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk);
4908 4940
4909 if (req_cdclk != dev_priv->vlv_cdclk_freq) { 4941 if (req_cdclk != dev_priv->vlv_cdclk_freq) {
4942 /*
4943 * FIXME: We can end up here with all power domains off, yet
4944 * with a CDCLK frequency other than the minimum. To account
4945 * for this take the PIPE-A power domain, which covers the HW
4946 * blocks needed for the following programming. This can be
4947 * removed once it's guaranteed that we get here either with
4948 * the minimum CDCLK set, or the required power domains
4949 * enabled.
4950 */
4951 intel_display_power_get(dev_priv, POWER_DOMAIN_PIPE_A);
4952
4910 if (IS_CHERRYVIEW(dev)) 4953 if (IS_CHERRYVIEW(dev))
4911 cherryview_set_cdclk(dev, req_cdclk); 4954 cherryview_set_cdclk(dev, req_cdclk);
4912 else 4955 else
4913 valleyview_set_cdclk(dev, req_cdclk); 4956 valleyview_set_cdclk(dev, req_cdclk);
4957
4958 intel_display_power_put(dev_priv, POWER_DOMAIN_PIPE_A);
4914 } 4959 }
4915} 4960}
4916 4961
@@ -5153,36 +5198,6 @@ static void i9xx_crtc_off(struct drm_crtc *crtc)
5153{ 5198{
5154} 5199}
5155 5200
5156static void intel_crtc_update_sarea(struct drm_crtc *crtc,
5157 bool enabled)
5158{
5159 struct drm_device *dev = crtc->dev;
5160 struct drm_i915_master_private *master_priv;
5161 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
5162 int pipe = intel_crtc->pipe;
5163
5164 if (!dev->primary->master)
5165 return;
5166
5167 master_priv = dev->primary->master->driver_priv;
5168 if (!master_priv->sarea_priv)
5169 return;
5170
5171 switch (pipe) {
5172 case 0:
5173 master_priv->sarea_priv->pipeA_w = enabled ? crtc->mode.hdisplay : 0;
5174 master_priv->sarea_priv->pipeA_h = enabled ? crtc->mode.vdisplay : 0;
5175 break;
5176 case 1:
5177 master_priv->sarea_priv->pipeB_w = enabled ? crtc->mode.hdisplay : 0;
5178 master_priv->sarea_priv->pipeB_h = enabled ? crtc->mode.vdisplay : 0;
5179 break;
5180 default:
5181 DRM_ERROR("Can't update pipe %c in SAREA\n", pipe_name(pipe));
5182 break;
5183 }
5184}
5185
5186/* Master function to enable/disable CRTC and corresponding power wells */ 5201/* Master function to enable/disable CRTC and corresponding power wells */
5187void intel_crtc_control(struct drm_crtc *crtc, bool enable) 5202void intel_crtc_control(struct drm_crtc *crtc, bool enable)
5188{ 5203{
@@ -5226,8 +5241,6 @@ void intel_crtc_update_dpms(struct drm_crtc *crtc)
5226 enable |= intel_encoder->connectors_active; 5241 enable |= intel_encoder->connectors_active;
5227 5242
5228 intel_crtc_control(crtc, enable); 5243 intel_crtc_control(crtc, enable);
5229
5230 intel_crtc_update_sarea(crtc, enable);
5231} 5244}
5232 5245
5233static void intel_crtc_disable(struct drm_crtc *crtc) 5246static void intel_crtc_disable(struct drm_crtc *crtc)
@@ -5242,7 +5255,6 @@ static void intel_crtc_disable(struct drm_crtc *crtc)
5242 WARN_ON(!crtc->enabled); 5255 WARN_ON(!crtc->enabled);
5243 5256
5244 dev_priv->display.crtc_disable(crtc); 5257 dev_priv->display.crtc_disable(crtc);
5245 intel_crtc_update_sarea(crtc, false);
5246 dev_priv->display.off(crtc); 5258 dev_priv->display.off(crtc);
5247 5259
5248 if (crtc->primary->fb) { 5260 if (crtc->primary->fb) {
@@ -7549,6 +7561,22 @@ static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc,
7549 &pipe_config->fdi_m_n, NULL); 7561 &pipe_config->fdi_m_n, NULL);
7550} 7562}
7551 7563
7564static void skylake_get_pfit_config(struct intel_crtc *crtc,
7565 struct intel_crtc_config *pipe_config)
7566{
7567 struct drm_device *dev = crtc->base.dev;
7568 struct drm_i915_private *dev_priv = dev->dev_private;
7569 uint32_t tmp;
7570
7571 tmp = I915_READ(PS_CTL(crtc->pipe));
7572
7573 if (tmp & PS_ENABLE) {
7574 pipe_config->pch_pfit.enabled = true;
7575 pipe_config->pch_pfit.pos = I915_READ(PS_WIN_POS(crtc->pipe));
7576 pipe_config->pch_pfit.size = I915_READ(PS_WIN_SZ(crtc->pipe));
7577 }
7578}
7579
7552static void ironlake_get_pfit_config(struct intel_crtc *crtc, 7580static void ironlake_get_pfit_config(struct intel_crtc *crtc,
7553 struct intel_crtc_config *pipe_config) 7581 struct intel_crtc_config *pipe_config)
7554{ 7582{
@@ -7962,6 +7990,28 @@ static int haswell_crtc_compute_clock(struct intel_crtc *crtc)
7962 return 0; 7990 return 0;
7963} 7991}
7964 7992
7993static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv,
7994 enum port port,
7995 struct intel_crtc_config *pipe_config)
7996{
7997 u32 temp;
7998
7999 temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port);
8000 pipe_config->ddi_pll_sel = temp >> (port * 3 + 1);
8001
8002 switch (pipe_config->ddi_pll_sel) {
8003 case SKL_DPLL1:
8004 pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1;
8005 break;
8006 case SKL_DPLL2:
8007 pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2;
8008 break;
8009 case SKL_DPLL3:
8010 pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3;
8011 break;
8012 }
8013}
8014
7965static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv, 8015static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv,
7966 enum port port, 8016 enum port port,
7967 struct intel_crtc_config *pipe_config) 8017 struct intel_crtc_config *pipe_config)
@@ -7991,7 +8041,10 @@ static void haswell_get_ddi_port_state(struct intel_crtc *crtc,
7991 8041
7992 port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT; 8042 port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT;
7993 8043
7994 haswell_get_ddi_pll(dev_priv, port, pipe_config); 8044 if (IS_SKYLAKE(dev))
8045 skylake_get_ddi_pll(dev_priv, port, pipe_config);
8046 else
8047 haswell_get_ddi_pll(dev_priv, port, pipe_config);
7995 8048
7996 if (pipe_config->shared_dpll >= 0) { 8049 if (pipe_config->shared_dpll >= 0) {
7997 pll = &dev_priv->shared_dplls[pipe_config->shared_dpll]; 8050 pll = &dev_priv->shared_dplls[pipe_config->shared_dpll];
@@ -8067,8 +8120,12 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
8067 intel_get_pipe_timings(crtc, pipe_config); 8120 intel_get_pipe_timings(crtc, pipe_config);
8068 8121
8069 pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe); 8122 pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe);
8070 if (intel_display_power_is_enabled(dev_priv, pfit_domain)) 8123 if (intel_display_power_is_enabled(dev_priv, pfit_domain)) {
8071 ironlake_get_pfit_config(crtc, pipe_config); 8124 if (IS_SKYLAKE(dev))
8125 skylake_get_pfit_config(crtc, pipe_config);
8126 else
8127 ironlake_get_pfit_config(crtc, pipe_config);
8128 }
8072 8129
8073 if (IS_HASWELL(dev)) 8130 if (IS_HASWELL(dev))
8074 pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) && 8131 pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) &&
@@ -8292,7 +8349,7 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
8292 uint32_t width, uint32_t height) 8349 uint32_t width, uint32_t height)
8293{ 8350{
8294 struct drm_device *dev = crtc->dev; 8351 struct drm_device *dev = crtc->dev;
8295 struct drm_i915_private *dev_priv = dev->dev_private; 8352 struct drm_i915_private *dev_priv = to_i915(dev);
8296 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 8353 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
8297 enum pipe pipe = intel_crtc->pipe; 8354 enum pipe pipe = intel_crtc->pipe;
8298 unsigned old_width; 8355 unsigned old_width;
@@ -8421,7 +8478,7 @@ __intel_framebuffer_create(struct drm_device *dev,
8421 8478
8422 intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); 8479 intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL);
8423 if (!intel_fb) { 8480 if (!intel_fb) {
8424 drm_gem_object_unreference_unlocked(&obj->base); 8481 drm_gem_object_unreference(&obj->base);
8425 return ERR_PTR(-ENOMEM); 8482 return ERR_PTR(-ENOMEM);
8426 } 8483 }
8427 8484
@@ -8431,7 +8488,7 @@ __intel_framebuffer_create(struct drm_device *dev,
8431 8488
8432 return &intel_fb->base; 8489 return &intel_fb->base;
8433err: 8490err:
8434 drm_gem_object_unreference_unlocked(&obj->base); 8491 drm_gem_object_unreference(&obj->base);
8435 kfree(intel_fb); 8492 kfree(intel_fb);
8436 8493
8437 return ERR_PTR(ret); 8494 return ERR_PTR(ret);
@@ -9465,6 +9522,69 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
9465 return 0; 9522 return 0;
9466} 9523}
9467 9524
9525static int intel_gen9_queue_flip(struct drm_device *dev,
9526 struct drm_crtc *crtc,
9527 struct drm_framebuffer *fb,
9528 struct drm_i915_gem_object *obj,
9529 struct intel_engine_cs *ring,
9530 uint32_t flags)
9531{
9532 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
9533 uint32_t plane = 0, stride;
9534 int ret;
9535
9536 switch(intel_crtc->pipe) {
9537 case PIPE_A:
9538 plane = MI_DISPLAY_FLIP_SKL_PLANE_1_A;
9539 break;
9540 case PIPE_B:
9541 plane = MI_DISPLAY_FLIP_SKL_PLANE_1_B;
9542 break;
9543 case PIPE_C:
9544 plane = MI_DISPLAY_FLIP_SKL_PLANE_1_C;
9545 break;
9546 default:
9547 WARN_ONCE(1, "unknown plane in flip command\n");
9548 return -ENODEV;
9549 }
9550
9551 switch (obj->tiling_mode) {
9552 case I915_TILING_NONE:
9553 stride = fb->pitches[0] >> 6;
9554 break;
9555 case I915_TILING_X:
9556 stride = fb->pitches[0] >> 9;
9557 break;
9558 default:
9559 WARN_ONCE(1, "unknown tiling in flip command\n");
9560 return -ENODEV;
9561 }
9562
9563 ret = intel_ring_begin(ring, 10);
9564 if (ret)
9565 return ret;
9566
9567 intel_ring_emit(ring, MI_LOAD_REGISTER_IMM(1));
9568 intel_ring_emit(ring, DERRMR);
9569 intel_ring_emit(ring, ~(DERRMR_PIPEA_PRI_FLIP_DONE |
9570 DERRMR_PIPEB_PRI_FLIP_DONE |
9571 DERRMR_PIPEC_PRI_FLIP_DONE));
9572 intel_ring_emit(ring, MI_STORE_REGISTER_MEM_GEN8(1) |
9573 MI_SRM_LRM_GLOBAL_GTT);
9574 intel_ring_emit(ring, DERRMR);
9575 intel_ring_emit(ring, ring->scratch.gtt_offset + 256);
9576 intel_ring_emit(ring, 0);
9577
9578 intel_ring_emit(ring, MI_DISPLAY_FLIP_I915 | plane);
9579 intel_ring_emit(ring, stride << 6 | obj->tiling_mode);
9580 intel_ring_emit(ring, intel_crtc->unpin_work->gtt_offset);
9581
9582 intel_mark_page_flip_active(intel_crtc);
9583 __intel_ring_advance(ring);
9584
9585 return 0;
9586}
9587
9468static int intel_default_queue_flip(struct drm_device *dev, 9588static int intel_default_queue_flip(struct drm_device *dev,
9469 struct drm_crtc *crtc, 9589 struct drm_crtc *crtc,
9470 struct drm_framebuffer *fb, 9590 struct drm_framebuffer *fb,
@@ -9904,6 +10024,10 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
9904 pipe_config->dp_m2_n2.link_n, 10024 pipe_config->dp_m2_n2.link_n,
9905 pipe_config->dp_m2_n2.tu); 10025 pipe_config->dp_m2_n2.tu);
9906 10026
10027 DRM_DEBUG_KMS("audio: %i, infoframes: %i\n",
10028 pipe_config->has_audio,
10029 pipe_config->has_infoframe);
10030
9907 DRM_DEBUG_KMS("requested mode:\n"); 10031 DRM_DEBUG_KMS("requested mode:\n");
9908 drm_mode_debug_printmodeline(&pipe_config->requested_mode); 10032 drm_mode_debug_printmodeline(&pipe_config->requested_mode);
9909 DRM_DEBUG_KMS("adjusted mode:\n"); 10033 DRM_DEBUG_KMS("adjusted mode:\n");
@@ -10372,6 +10496,7 @@ intel_pipe_config_compare(struct drm_device *dev,
10372 if ((INTEL_INFO(dev)->gen < 8 && !IS_HASWELL(dev)) || 10496 if ((INTEL_INFO(dev)->gen < 8 && !IS_HASWELL(dev)) ||
10373 IS_VALLEYVIEW(dev)) 10497 IS_VALLEYVIEW(dev))
10374 PIPE_CONF_CHECK_I(limited_color_range); 10498 PIPE_CONF_CHECK_I(limited_color_range);
10499 PIPE_CONF_CHECK_I(has_infoframe);
10375 10500
10376 PIPE_CONF_CHECK_I(has_audio); 10501 PIPE_CONF_CHECK_I(has_audio);
10377 10502
@@ -10428,6 +10553,9 @@ intel_pipe_config_compare(struct drm_device *dev,
10428 PIPE_CONF_CHECK_X(dpll_hw_state.fp0); 10553 PIPE_CONF_CHECK_X(dpll_hw_state.fp0);
10429 PIPE_CONF_CHECK_X(dpll_hw_state.fp1); 10554 PIPE_CONF_CHECK_X(dpll_hw_state.fp1);
10430 PIPE_CONF_CHECK_X(dpll_hw_state.wrpll); 10555 PIPE_CONF_CHECK_X(dpll_hw_state.wrpll);
10556 PIPE_CONF_CHECK_X(dpll_hw_state.ctrl1);
10557 PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr1);
10558 PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr2);
10431 10559
10432 if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) 10560 if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5)
10433 PIPE_CONF_CHECK_I(pipe_bpp); 10561 PIPE_CONF_CHECK_I(pipe_bpp);
@@ -10751,45 +10879,60 @@ static void update_scanline_offset(struct intel_crtc *crtc)
10751 crtc->scanline_offset = 1; 10879 crtc->scanline_offset = 1;
10752} 10880}
10753 10881
10882static struct intel_crtc_config *
10883intel_modeset_compute_config(struct drm_crtc *crtc,
10884 struct drm_display_mode *mode,
10885 struct drm_framebuffer *fb,
10886 unsigned *modeset_pipes,
10887 unsigned *prepare_pipes,
10888 unsigned *disable_pipes)
10889{
10890 struct intel_crtc_config *pipe_config = NULL;
10891
10892 intel_modeset_affected_pipes(crtc, modeset_pipes,
10893 prepare_pipes, disable_pipes);
10894
10895 if ((*modeset_pipes) == 0)
10896 goto out;
10897
10898 /*
10899 * Note this needs changes when we start tracking multiple modes
10900 * and crtcs. At that point we'll need to compute the whole config
10901 * (i.e. one pipe_config for each crtc) rather than just the one
10902 * for this crtc.
10903 */
10904 pipe_config = intel_modeset_pipe_config(crtc, fb, mode);
10905 if (IS_ERR(pipe_config)) {
10906 goto out;
10907 }
10908 intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config,
10909 "[modeset]");
10910 to_intel_crtc(crtc)->new_config = pipe_config;
10911
10912out:
10913 return pipe_config;
10914}
10915
10754static int __intel_set_mode(struct drm_crtc *crtc, 10916static int __intel_set_mode(struct drm_crtc *crtc,
10755 struct drm_display_mode *mode, 10917 struct drm_display_mode *mode,
10756 int x, int y, struct drm_framebuffer *fb) 10918 int x, int y, struct drm_framebuffer *fb,
10919 struct intel_crtc_config *pipe_config,
10920 unsigned modeset_pipes,
10921 unsigned prepare_pipes,
10922 unsigned disable_pipes)
10757{ 10923{
10758 struct drm_device *dev = crtc->dev; 10924 struct drm_device *dev = crtc->dev;
10759 struct drm_i915_private *dev_priv = dev->dev_private; 10925 struct drm_i915_private *dev_priv = dev->dev_private;
10760 struct drm_display_mode *saved_mode; 10926 struct drm_display_mode *saved_mode;
10761 struct intel_crtc_config *pipe_config = NULL;
10762 struct intel_crtc *intel_crtc; 10927 struct intel_crtc *intel_crtc;
10763 unsigned disable_pipes, prepare_pipes, modeset_pipes;
10764 int ret = 0; 10928 int ret = 0;
10765 10929
10766 saved_mode = kmalloc(sizeof(*saved_mode), GFP_KERNEL); 10930 saved_mode = kmalloc(sizeof(*saved_mode), GFP_KERNEL);
10767 if (!saved_mode) 10931 if (!saved_mode)
10768 return -ENOMEM; 10932 return -ENOMEM;
10769 10933
10770 intel_modeset_affected_pipes(crtc, &modeset_pipes,
10771 &prepare_pipes, &disable_pipes);
10772
10773 *saved_mode = crtc->mode; 10934 *saved_mode = crtc->mode;
10774 10935
10775 /* Hack: Because we don't (yet) support global modeset on multiple
10776 * crtcs, we don't keep track of the new mode for more than one crtc.
10777 * Hence simply check whether any bit is set in modeset_pipes in all the
10778 * pieces of code that are not yet converted to deal with mutliple crtcs
10779 * changing their mode at the same time. */
10780 if (modeset_pipes) {
10781 pipe_config = intel_modeset_pipe_config(crtc, fb, mode);
10782 if (IS_ERR(pipe_config)) {
10783 ret = PTR_ERR(pipe_config);
10784 pipe_config = NULL;
10785
10786 goto out;
10787 }
10788 intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config,
10789 "[modeset]");
10790 to_intel_crtc(crtc)->new_config = pipe_config;
10791 }
10792
10793 /* 10936 /*
10794 * See if the config requires any additional preparation, e.g. 10937 * See if the config requires any additional preparation, e.g.
10795 * to adjust global state with pipes off. We need to do this 10938 * to adjust global state with pipes off. We need to do this
@@ -10830,6 +10973,10 @@ static int __intel_set_mode(struct drm_crtc *crtc,
10830 10973
10831 /* crtc->mode is already used by the ->mode_set callbacks, hence we need 10974 /* crtc->mode is already used by the ->mode_set callbacks, hence we need
10832 * to set it here already despite that we pass it down the callchain. 10975 * to set it here already despite that we pass it down the callchain.
10976 *
10977 * Note we'll need to fix this up when we start tracking multiple
10978 * pipes; here we assume a single modeset_pipe and only track the
10979 * single crtc and mode.
10833 */ 10980 */
10834 if (modeset_pipes) { 10981 if (modeset_pipes) {
10835 crtc->mode = *mode; 10982 crtc->mode = *mode;
@@ -10891,19 +11038,23 @@ done:
10891 if (ret && crtc->enabled) 11038 if (ret && crtc->enabled)
10892 crtc->mode = *saved_mode; 11039 crtc->mode = *saved_mode;
10893 11040
10894out:
10895 kfree(pipe_config); 11041 kfree(pipe_config);
10896 kfree(saved_mode); 11042 kfree(saved_mode);
10897 return ret; 11043 return ret;
10898} 11044}
10899 11045
10900static int intel_set_mode(struct drm_crtc *crtc, 11046static int intel_set_mode_pipes(struct drm_crtc *crtc,
10901 struct drm_display_mode *mode, 11047 struct drm_display_mode *mode,
10902 int x, int y, struct drm_framebuffer *fb) 11048 int x, int y, struct drm_framebuffer *fb,
11049 struct intel_crtc_config *pipe_config,
11050 unsigned modeset_pipes,
11051 unsigned prepare_pipes,
11052 unsigned disable_pipes)
10903{ 11053{
10904 int ret; 11054 int ret;
10905 11055
10906 ret = __intel_set_mode(crtc, mode, x, y, fb); 11056 ret = __intel_set_mode(crtc, mode, x, y, fb, pipe_config, modeset_pipes,
11057 prepare_pipes, disable_pipes);
10907 11058
10908 if (ret == 0) 11059 if (ret == 0)
10909 intel_modeset_check_state(crtc->dev); 11060 intel_modeset_check_state(crtc->dev);
@@ -10911,6 +11062,26 @@ static int intel_set_mode(struct drm_crtc *crtc,
10911 return ret; 11062 return ret;
10912} 11063}
10913 11064
11065static int intel_set_mode(struct drm_crtc *crtc,
11066 struct drm_display_mode *mode,
11067 int x, int y, struct drm_framebuffer *fb)
11068{
11069 struct intel_crtc_config *pipe_config;
11070 unsigned modeset_pipes, prepare_pipes, disable_pipes;
11071
11072 pipe_config = intel_modeset_compute_config(crtc, mode, fb,
11073 &modeset_pipes,
11074 &prepare_pipes,
11075 &disable_pipes);
11076
11077 if (IS_ERR(pipe_config))
11078 return PTR_ERR(pipe_config);
11079
11080 return intel_set_mode_pipes(crtc, mode, x, y, fb, pipe_config,
11081 modeset_pipes, prepare_pipes,
11082 disable_pipes);
11083}
11084
10914void intel_crtc_restore_mode(struct drm_crtc *crtc) 11085void intel_crtc_restore_mode(struct drm_crtc *crtc)
10915{ 11086{
10916 intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->primary->fb); 11087 intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, crtc->primary->fb);
@@ -11239,6 +11410,8 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
11239 struct drm_device *dev; 11410 struct drm_device *dev;
11240 struct drm_mode_set save_set; 11411 struct drm_mode_set save_set;
11241 struct intel_set_config *config; 11412 struct intel_set_config *config;
11413 struct intel_crtc_config *pipe_config;
11414 unsigned modeset_pipes, prepare_pipes, disable_pipes;
11242 int ret; 11415 int ret;
11243 11416
11244 BUG_ON(!set); 11417 BUG_ON(!set);
@@ -11284,9 +11457,36 @@ static int intel_crtc_set_config(struct drm_mode_set *set)
11284 if (ret) 11457 if (ret)
11285 goto fail; 11458 goto fail;
11286 11459
11460 pipe_config = intel_modeset_compute_config(set->crtc, set->mode,
11461 set->fb,
11462 &modeset_pipes,
11463 &prepare_pipes,
11464 &disable_pipes);
11465 if (IS_ERR(pipe_config)) {
11466 ret = PTR_ERR(pipe_config);
11467 goto fail;
11468 } else if (pipe_config) {
11469 if (to_intel_crtc(set->crtc)->new_config->has_audio !=
11470 to_intel_crtc(set->crtc)->config.has_audio)
11471 config->mode_changed = true;
11472
11473 /* Force mode sets for any infoframe stuff */
11474 if (to_intel_crtc(set->crtc)->new_config->has_infoframe ||
11475 to_intel_crtc(set->crtc)->config.has_infoframe)
11476 config->mode_changed = true;
11477 }
11478
11479 /* set_mode will free it in the mode_changed case */
11480 if (!config->mode_changed)
11481 kfree(pipe_config);
11482
11483 intel_update_pipe_size(to_intel_crtc(set->crtc));
11484
11287 if (config->mode_changed) { 11485 if (config->mode_changed) {
11288 ret = intel_set_mode(set->crtc, set->mode, 11486 ret = intel_set_mode_pipes(set->crtc, set->mode,
11289 set->x, set->y, set->fb); 11487 set->x, set->y, set->fb, pipe_config,
11488 modeset_pipes, prepare_pipes,
11489 disable_pipes);
11290 } else if (config->fb_changed) { 11490 } else if (config->fb_changed) {
11291 struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc); 11491 struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc);
11292 11492
@@ -11559,8 +11759,8 @@ intel_commit_primary_plane(struct drm_plane *plane,
11559 struct drm_rect *src = &state->src; 11759 struct drm_rect *src = &state->src;
11560 11760
11561 crtc->primary->fb = fb; 11761 crtc->primary->fb = fb;
11562 crtc->x = src->x1; 11762 crtc->x = src->x1 >> 16;
11563 crtc->y = src->y1; 11763 crtc->y = src->y1 >> 16;
11564 11764
11565 intel_plane->crtc_x = state->orig_dst.x1; 11765 intel_plane->crtc_x = state->orig_dst.x1;
11566 intel_plane->crtc_y = state->orig_dst.y1; 11766 intel_plane->crtc_y = state->orig_dst.y1;
@@ -12009,7 +12209,7 @@ enum pipe intel_get_pipe_from_connector(struct intel_connector *connector)
12009 12209
12010 WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); 12210 WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
12011 12211
12012 if (!encoder) 12212 if (!encoder || WARN_ON(!encoder->crtc))
12013 return INVALID_PIPE; 12213 return INVALID_PIPE;
12014 12214
12015 return to_intel_crtc(encoder->crtc)->pipe; 12215 return to_intel_crtc(encoder->crtc)->pipe;
@@ -12244,7 +12444,7 @@ static void intel_setup_outputs(struct drm_device *dev)
12244 if (SUPPORTS_TV(dev)) 12444 if (SUPPORTS_TV(dev))
12245 intel_tv_init(dev); 12445 intel_tv_init(dev);
12246 12446
12247 intel_edp_psr_init(dev); 12447 intel_psr_init(dev);
12248 12448
12249 for_each_intel_encoder(dev, encoder) { 12449 for_each_intel_encoder(dev, encoder) {
12250 encoder->base.possible_crtcs = encoder->crtc_mask; 12450 encoder->base.possible_crtcs = encoder->crtc_mask;
@@ -12558,6 +12758,9 @@ static void intel_init_display(struct drm_device *dev)
12558 case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */ 12758 case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */
12559 dev_priv->display.queue_flip = intel_gen7_queue_flip; 12759 dev_priv->display.queue_flip = intel_gen7_queue_flip;
12560 break; 12760 break;
12761 case 9:
12762 dev_priv->display.queue_flip = intel_gen9_queue_flip;
12763 break;
12561 } 12764 }
12562 12765
12563 intel_panel_init_backlight_funcs(dev); 12766 intel_panel_init_backlight_funcs(dev);
@@ -13262,8 +13465,8 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
13262 struct drm_crtc *crtc = 13465 struct drm_crtc *crtc =
13263 dev_priv->pipe_to_crtc_mapping[pipe]; 13466 dev_priv->pipe_to_crtc_mapping[pipe];
13264 13467
13265 __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, 13468 intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y,
13266 crtc->primary->fb); 13469 crtc->primary->fb);
13267 } 13470 }
13268 } else { 13471 } else {
13269 intel_modeset_update_staged_output_state(dev); 13472 intel_modeset_update_staged_output_state(dev);
@@ -13274,6 +13477,7 @@ void intel_modeset_setup_hw_state(struct drm_device *dev,
13274 13477
13275void intel_modeset_gem_init(struct drm_device *dev) 13478void intel_modeset_gem_init(struct drm_device *dev)
13276{ 13479{
13480 struct drm_i915_private *dev_priv = dev->dev_private;
13277 struct drm_crtc *c; 13481 struct drm_crtc *c;
13278 struct drm_i915_gem_object *obj; 13482 struct drm_i915_gem_object *obj;
13279 13483
@@ -13281,6 +13485,16 @@ void intel_modeset_gem_init(struct drm_device *dev)
13281 intel_init_gt_powersave(dev); 13485 intel_init_gt_powersave(dev);
13282 mutex_unlock(&dev->struct_mutex); 13486 mutex_unlock(&dev->struct_mutex);
13283 13487
13488 /*
13489 * There may be no VBT; and if the BIOS enabled SSC we can
13490 * just keep using it to avoid unnecessary flicker. Whereas if the
13491 * BIOS isn't using it, don't assume it will work even if the VBT
13492 * indicates as much.
13493 */
13494 if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev))
13495 dev_priv->vbt.lvds_use_ssc = !!(I915_READ(PCH_DREF_CONTROL) &
13496 DREF_SSC1_ENABLE);
13497
13284 intel_modeset_init_hw(dev); 13498 intel_modeset_init_hw(dev);
13285 13499
13286 intel_setup_overlay(dev); 13500 intel_setup_overlay(dev);
@@ -13306,6 +13520,8 @@ void intel_modeset_gem_init(struct drm_device *dev)
13306 } 13520 }
13307 } 13521 }
13308 mutex_unlock(&dev->struct_mutex); 13522 mutex_unlock(&dev->struct_mutex);
13523
13524 intel_backlight_register(dev);
13309} 13525}
13310 13526
13311void intel_connector_unregister(struct intel_connector *intel_connector) 13527void intel_connector_unregister(struct intel_connector *intel_connector)
@@ -13321,9 +13537,13 @@ void intel_modeset_cleanup(struct drm_device *dev)
13321 struct drm_i915_private *dev_priv = dev->dev_private; 13537 struct drm_i915_private *dev_priv = dev->dev_private;
13322 struct drm_connector *connector; 13538 struct drm_connector *connector;
13323 13539
13540 intel_disable_gt_powersave(dev);
13541
13542 intel_backlight_unregister(dev);
13543
13324 /* 13544 /*
13325 * Interrupts and polling as the first thing to avoid creating havoc. 13545 * Interrupts and polling as the first thing to avoid creating havoc.
13326 * Too much stuff here (turning of rps, connectors, ...) would 13546 * Too much stuff here (turning of connectors, ...) would
13327 * experience fancy races otherwise. 13547 * experience fancy races otherwise.
13328 */ 13548 */
13329 intel_irq_uninstall(dev_priv); 13549 intel_irq_uninstall(dev_priv);
@@ -13340,8 +13560,6 @@ void intel_modeset_cleanup(struct drm_device *dev)
13340 13560
13341 intel_disable_fbc(dev); 13561 intel_disable_fbc(dev);
13342 13562
13343 intel_disable_gt_powersave(dev);
13344
13345 ironlake_teardown_rc6(dev); 13563 ironlake_teardown_rc6(dev);
13346 13564
13347 mutex_unlock(&dev->struct_mutex); 13565 mutex_unlock(&dev->struct_mutex);