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.c138
1 files changed, 108 insertions, 30 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 393a39922e53..35364e68a091 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -980,11 +980,29 @@ static void assert_transcoder_disabled(struct drm_i915_private *dev_priv,
980 pipe_name(pipe)); 980 pipe_name(pipe));
981} 981}
982 982
983static bool dp_pipe_enabled(struct drm_i915_private *dev_priv, enum pipe pipe,
984 int reg, u32 port_sel, u32 val)
985{
986 if ((val & DP_PORT_EN) == 0)
987 return false;
988
989 if (HAS_PCH_CPT(dev_priv->dev)) {
990 u32 trans_dp_ctl_reg = TRANS_DP_CTL(pipe);
991 u32 trans_dp_ctl = I915_READ(trans_dp_ctl_reg);
992 if ((trans_dp_ctl & TRANS_DP_PORT_SEL_MASK) != port_sel)
993 return false;
994 } else {
995 if ((val & DP_PIPE_MASK) != (pipe << 30))
996 return false;
997 }
998 return true;
999}
1000
983static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv, 1001static void assert_pch_dp_disabled(struct drm_i915_private *dev_priv,
984 enum pipe pipe, int reg) 1002 enum pipe pipe, int reg, u32 port_sel)
985{ 1003{
986 u32 val = I915_READ(reg); 1004 u32 val = I915_READ(reg);
987 WARN(DP_PIPE_ENABLED(val, pipe), 1005 WARN(dp_pipe_enabled(dev_priv, pipe, reg, port_sel, val),
988 "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n", 1006 "PCH DP (0x%08x) enabled on transcoder %c, should be disabled\n",
989 reg, pipe_name(pipe)); 1007 reg, pipe_name(pipe));
990} 1008}
@@ -1004,9 +1022,9 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv,
1004 int reg; 1022 int reg;
1005 u32 val; 1023 u32 val;
1006 1024
1007 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_B); 1025 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_B, TRANS_DP_PORT_SEL_B);
1008 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_C); 1026 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_C, TRANS_DP_PORT_SEL_C);
1009 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_D); 1027 assert_pch_dp_disabled(dev_priv, pipe, PCH_DP_D, TRANS_DP_PORT_SEL_D);
1010 1028
1011 reg = PCH_ADPA; 1029 reg = PCH_ADPA;
1012 val = I915_READ(reg); 1030 val = I915_READ(reg);
@@ -1276,6 +1294,17 @@ static void intel_disable_pipe(struct drm_i915_private *dev_priv,
1276 intel_wait_for_pipe_off(dev_priv->dev, pipe); 1294 intel_wait_for_pipe_off(dev_priv->dev, pipe);
1277} 1295}
1278 1296
1297/*
1298 * Plane regs are double buffered, going from enabled->disabled needs a
1299 * trigger in order to latch. The display address reg provides this.
1300 */
1301static void intel_flush_display_plane(struct drm_i915_private *dev_priv,
1302 enum plane plane)
1303{
1304 I915_WRITE(DSPADDR(plane), I915_READ(DSPADDR(plane)));
1305 I915_WRITE(DSPSURF(plane), I915_READ(DSPSURF(plane)));
1306}
1307
1279/** 1308/**
1280 * intel_enable_plane - enable a display plane on a given pipe 1309 * intel_enable_plane - enable a display plane on a given pipe
1281 * @dev_priv: i915 private structure 1310 * @dev_priv: i915 private structure
@@ -1299,20 +1328,10 @@ static void intel_enable_plane(struct drm_i915_private *dev_priv,
1299 return; 1328 return;
1300 1329
1301 I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE); 1330 I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE);
1331 intel_flush_display_plane(dev_priv, plane);
1302 intel_wait_for_vblank(dev_priv->dev, pipe); 1332 intel_wait_for_vblank(dev_priv->dev, pipe);
1303} 1333}
1304 1334
1305/*
1306 * Plane regs are double buffered, going from enabled->disabled needs a
1307 * trigger in order to latch. The display address reg provides this.
1308 */
1309static void intel_flush_display_plane(struct drm_i915_private *dev_priv,
1310 enum plane plane)
1311{
1312 u32 reg = DSPADDR(plane);
1313 I915_WRITE(reg, I915_READ(reg));
1314}
1315
1316/** 1335/**
1317 * intel_disable_plane - disable a display plane 1336 * intel_disable_plane - disable a display plane
1318 * @dev_priv: i915 private structure 1337 * @dev_priv: i915 private structure
@@ -1338,19 +1357,24 @@ static void intel_disable_plane(struct drm_i915_private *dev_priv,
1338} 1357}
1339 1358
1340static void disable_pch_dp(struct drm_i915_private *dev_priv, 1359static void disable_pch_dp(struct drm_i915_private *dev_priv,
1341 enum pipe pipe, int reg) 1360 enum pipe pipe, int reg, u32 port_sel)
1342{ 1361{
1343 u32 val = I915_READ(reg); 1362 u32 val = I915_READ(reg);
1344 if (DP_PIPE_ENABLED(val, pipe)) 1363 if (dp_pipe_enabled(dev_priv, pipe, reg, port_sel, val)) {
1364 DRM_DEBUG_KMS("Disabling pch dp %x on pipe %d\n", reg, pipe);
1345 I915_WRITE(reg, val & ~DP_PORT_EN); 1365 I915_WRITE(reg, val & ~DP_PORT_EN);
1366 }
1346} 1367}
1347 1368
1348static void disable_pch_hdmi(struct drm_i915_private *dev_priv, 1369static void disable_pch_hdmi(struct drm_i915_private *dev_priv,
1349 enum pipe pipe, int reg) 1370 enum pipe pipe, int reg)
1350{ 1371{
1351 u32 val = I915_READ(reg); 1372 u32 val = I915_READ(reg);
1352 if (HDMI_PIPE_ENABLED(val, pipe)) 1373 if (HDMI_PIPE_ENABLED(val, pipe)) {
1374 DRM_DEBUG_KMS("Disabling pch HDMI %x on pipe %d\n",
1375 reg, pipe);
1353 I915_WRITE(reg, val & ~PORT_ENABLE); 1376 I915_WRITE(reg, val & ~PORT_ENABLE);
1377 }
1354} 1378}
1355 1379
1356/* Disable any ports connected to this transcoder */ 1380/* Disable any ports connected to this transcoder */
@@ -1362,9 +1386,9 @@ static void intel_disable_pch_ports(struct drm_i915_private *dev_priv,
1362 val = I915_READ(PCH_PP_CONTROL); 1386 val = I915_READ(PCH_PP_CONTROL);
1363 I915_WRITE(PCH_PP_CONTROL, val | PANEL_UNLOCK_REGS); 1387 I915_WRITE(PCH_PP_CONTROL, val | PANEL_UNLOCK_REGS);
1364 1388
1365 disable_pch_dp(dev_priv, pipe, PCH_DP_B); 1389 disable_pch_dp(dev_priv, pipe, PCH_DP_B, TRANS_DP_PORT_SEL_B);
1366 disable_pch_dp(dev_priv, pipe, PCH_DP_C); 1390 disable_pch_dp(dev_priv, pipe, PCH_DP_C, TRANS_DP_PORT_SEL_C);
1367 disable_pch_dp(dev_priv, pipe, PCH_DP_D); 1391 disable_pch_dp(dev_priv, pipe, PCH_DP_D, TRANS_DP_PORT_SEL_D);
1368 1392
1369 reg = PCH_ADPA; 1393 reg = PCH_ADPA;
1370 val = I915_READ(reg); 1394 val = I915_READ(reg);
@@ -2096,7 +2120,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2096 2120
2097 /* no fb bound */ 2121 /* no fb bound */
2098 if (!crtc->fb) { 2122 if (!crtc->fb) {
2099 DRM_DEBUG_KMS("No FB bound\n"); 2123 DRM_ERROR("No FB bound\n");
2100 return 0; 2124 return 0;
2101 } 2125 }
2102 2126
@@ -2105,6 +2129,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2105 case 1: 2129 case 1:
2106 break; 2130 break;
2107 default: 2131 default:
2132 DRM_ERROR("no plane for crtc\n");
2108 return -EINVAL; 2133 return -EINVAL;
2109 } 2134 }
2110 2135
@@ -2114,6 +2139,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2114 NULL); 2139 NULL);
2115 if (ret != 0) { 2140 if (ret != 0) {
2116 mutex_unlock(&dev->struct_mutex); 2141 mutex_unlock(&dev->struct_mutex);
2142 DRM_ERROR("pin & fence failed\n");
2117 return ret; 2143 return ret;
2118 } 2144 }
2119 2145
@@ -2142,6 +2168,7 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y,
2142 if (ret) { 2168 if (ret) {
2143 i915_gem_object_unpin(to_intel_framebuffer(crtc->fb)->obj); 2169 i915_gem_object_unpin(to_intel_framebuffer(crtc->fb)->obj);
2144 mutex_unlock(&dev->struct_mutex); 2170 mutex_unlock(&dev->struct_mutex);
2171 DRM_ERROR("failed to update base address\n");
2145 return ret; 2172 return ret;
2146 } 2173 }
2147 2174
@@ -2248,6 +2275,18 @@ static void intel_fdi_normal_train(struct drm_crtc *crtc)
2248 FDI_FE_ERRC_ENABLE); 2275 FDI_FE_ERRC_ENABLE);
2249} 2276}
2250 2277
2278static void cpt_phase_pointer_enable(struct drm_device *dev, int pipe)
2279{
2280 struct drm_i915_private *dev_priv = dev->dev_private;
2281 u32 flags = I915_READ(SOUTH_CHICKEN1);
2282
2283 flags |= FDI_PHASE_SYNC_OVR(pipe);
2284 I915_WRITE(SOUTH_CHICKEN1, flags); /* once to unlock... */
2285 flags |= FDI_PHASE_SYNC_EN(pipe);
2286 I915_WRITE(SOUTH_CHICKEN1, flags); /* then again to enable */
2287 POSTING_READ(SOUTH_CHICKEN1);
2288}
2289
2251/* The FDI link training functions for ILK/Ibexpeak. */ 2290/* The FDI link training functions for ILK/Ibexpeak. */
2252static void ironlake_fdi_link_train(struct drm_crtc *crtc) 2291static void ironlake_fdi_link_train(struct drm_crtc *crtc)
2253{ 2292{
@@ -2398,6 +2437,9 @@ static void gen6_fdi_link_train(struct drm_crtc *crtc)
2398 POSTING_READ(reg); 2437 POSTING_READ(reg);
2399 udelay(150); 2438 udelay(150);
2400 2439
2440 if (HAS_PCH_CPT(dev))
2441 cpt_phase_pointer_enable(dev, pipe);
2442
2401 for (i = 0; i < 4; i++ ) { 2443 for (i = 0; i < 4; i++ ) {
2402 reg = FDI_TX_CTL(pipe); 2444 reg = FDI_TX_CTL(pipe);
2403 temp = I915_READ(reg); 2445 temp = I915_READ(reg);
@@ -2514,6 +2556,9 @@ static void ivb_manual_fdi_link_train(struct drm_crtc *crtc)
2514 POSTING_READ(reg); 2556 POSTING_READ(reg);
2515 udelay(150); 2557 udelay(150);
2516 2558
2559 if (HAS_PCH_CPT(dev))
2560 cpt_phase_pointer_enable(dev, pipe);
2561
2517 for (i = 0; i < 4; i++ ) { 2562 for (i = 0; i < 4; i++ ) {
2518 reg = FDI_TX_CTL(pipe); 2563 reg = FDI_TX_CTL(pipe);
2519 temp = I915_READ(reg); 2564 temp = I915_READ(reg);
@@ -2623,6 +2668,17 @@ static void ironlake_fdi_pll_enable(struct drm_crtc *crtc)
2623 } 2668 }
2624} 2669}
2625 2670
2671static void cpt_phase_pointer_disable(struct drm_device *dev, int pipe)
2672{
2673 struct drm_i915_private *dev_priv = dev->dev_private;
2674 u32 flags = I915_READ(SOUTH_CHICKEN1);
2675
2676 flags &= ~(FDI_PHASE_SYNC_EN(pipe));
2677 I915_WRITE(SOUTH_CHICKEN1, flags); /* once to disable... */
2678 flags &= ~(FDI_PHASE_SYNC_OVR(pipe));
2679 I915_WRITE(SOUTH_CHICKEN1, flags); /* then again to lock */
2680 POSTING_READ(SOUTH_CHICKEN1);
2681}
2626static void ironlake_fdi_disable(struct drm_crtc *crtc) 2682static void ironlake_fdi_disable(struct drm_crtc *crtc)
2627{ 2683{
2628 struct drm_device *dev = crtc->dev; 2684 struct drm_device *dev = crtc->dev;
@@ -2652,6 +2708,8 @@ static void ironlake_fdi_disable(struct drm_crtc *crtc)
2652 I915_WRITE(FDI_RX_CHICKEN(pipe), 2708 I915_WRITE(FDI_RX_CHICKEN(pipe),
2653 I915_READ(FDI_RX_CHICKEN(pipe) & 2709 I915_READ(FDI_RX_CHICKEN(pipe) &
2654 ~FDI_RX_PHASE_SYNC_POINTER_EN)); 2710 ~FDI_RX_PHASE_SYNC_POINTER_EN));
2711 } else if (HAS_PCH_CPT(dev)) {
2712 cpt_phase_pointer_disable(dev, pipe);
2655 } 2713 }
2656 2714
2657 /* still set train pattern 1 */ 2715 /* still set train pattern 1 */
@@ -2862,14 +2920,18 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
2862 I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size); 2920 I915_WRITE(PF_WIN_SZ(pipe), dev_priv->pch_pf_size);
2863 } 2921 }
2864 2922
2923 /*
2924 * On ILK+ LUT must be loaded before the pipe is running but with
2925 * clocks enabled
2926 */
2927 intel_crtc_load_lut(crtc);
2928
2865 intel_enable_pipe(dev_priv, pipe, is_pch_port); 2929 intel_enable_pipe(dev_priv, pipe, is_pch_port);
2866 intel_enable_plane(dev_priv, plane, pipe); 2930 intel_enable_plane(dev_priv, plane, pipe);
2867 2931
2868 if (is_pch_port) 2932 if (is_pch_port)
2869 ironlake_pch_enable(crtc); 2933 ironlake_pch_enable(crtc);
2870 2934
2871 intel_crtc_load_lut(crtc);
2872
2873 mutex_lock(&dev->struct_mutex); 2935 mutex_lock(&dev->struct_mutex);
2874 intel_update_fbc(dev); 2936 intel_update_fbc(dev);
2875 mutex_unlock(&dev->struct_mutex); 2937 mutex_unlock(&dev->struct_mutex);
@@ -4538,7 +4600,9 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
4538 if (connector->encoder != encoder) 4600 if (connector->encoder != encoder)
4539 continue; 4601 continue;
4540 4602
4541 if (connector->display_info.bpc < display_bpc) { 4603 /* Don't use an invalid EDID bpc value */
4604 if (connector->display_info.bpc &&
4605 connector->display_info.bpc < display_bpc) {
4542 DRM_DEBUG_DRIVER("clamping display bpc (was %d) to EDID reported max of %d\n", display_bpc, connector->display_info.bpc); 4606 DRM_DEBUG_DRIVER("clamping display bpc (was %d) to EDID reported max of %d\n", display_bpc, connector->display_info.bpc);
4543 display_bpc = connector->display_info.bpc; 4607 display_bpc = connector->display_info.bpc;
4544 } 4608 }
@@ -5153,7 +5217,8 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5153 temp |= PIPE_12BPC; 5217 temp |= PIPE_12BPC;
5154 break; 5218 break;
5155 default: 5219 default:
5156 WARN(1, "intel_choose_pipe_bpp returned invalid value\n"); 5220 WARN(1, "intel_choose_pipe_bpp returned invalid value %d\n",
5221 pipe_bpp);
5157 temp |= PIPE_8BPC; 5222 temp |= PIPE_8BPC;
5158 pipe_bpp = 24; 5223 pipe_bpp = 24;
5159 break; 5224 break;
@@ -5238,7 +5303,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5238 } else if (is_sdvo && is_tv) 5303 } else if (is_sdvo && is_tv)
5239 factor = 20; 5304 factor = 20;
5240 5305
5241 if (clock.m1 < factor * clock.n) 5306 if (clock.m < factor * clock.n)
5242 fp |= FP_CB_TUNE; 5307 fp |= FP_CB_TUNE;
5243 5308
5244 dpll = 0; 5309 dpll = 0;
@@ -5516,6 +5581,8 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc,
5516 5581
5517 drm_vblank_post_modeset(dev, pipe); 5582 drm_vblank_post_modeset(dev, pipe);
5518 5583
5584 intel_crtc->dpms_mode = DRM_MODE_DPMS_ON;
5585
5519 return ret; 5586 return ret;
5520} 5587}
5521 5588
@@ -7714,10 +7781,12 @@ static void gen6_init_clock_gating(struct drm_device *dev)
7714 ILK_DPARB_CLK_GATE | 7781 ILK_DPARB_CLK_GATE |
7715 ILK_DPFD_CLK_GATE); 7782 ILK_DPFD_CLK_GATE);
7716 7783
7717 for_each_pipe(pipe) 7784 for_each_pipe(pipe) {
7718 I915_WRITE(DSPCNTR(pipe), 7785 I915_WRITE(DSPCNTR(pipe),
7719 I915_READ(DSPCNTR(pipe)) | 7786 I915_READ(DSPCNTR(pipe)) |
7720 DISPPLANE_TRICKLE_FEED_DISABLE); 7787 DISPPLANE_TRICKLE_FEED_DISABLE);
7788 intel_flush_display_plane(dev_priv, pipe);
7789 }
7721} 7790}
7722 7791
7723static void ivybridge_init_clock_gating(struct drm_device *dev) 7792static void ivybridge_init_clock_gating(struct drm_device *dev)
@@ -7734,10 +7803,12 @@ static void ivybridge_init_clock_gating(struct drm_device *dev)
7734 7803
7735 I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE); 7804 I915_WRITE(ILK_DSPCLK_GATE, IVB_VRHUNIT_CLK_GATE);
7736 7805
7737 for_each_pipe(pipe) 7806 for_each_pipe(pipe) {
7738 I915_WRITE(DSPCNTR(pipe), 7807 I915_WRITE(DSPCNTR(pipe),
7739 I915_READ(DSPCNTR(pipe)) | 7808 I915_READ(DSPCNTR(pipe)) |
7740 DISPPLANE_TRICKLE_FEED_DISABLE); 7809 DISPPLANE_TRICKLE_FEED_DISABLE);
7810 intel_flush_display_plane(dev_priv, pipe);
7811 }
7741} 7812}
7742 7813
7743static void g4x_init_clock_gating(struct drm_device *dev) 7814static void g4x_init_clock_gating(struct drm_device *dev)
@@ -7820,6 +7891,7 @@ static void ibx_init_clock_gating(struct drm_device *dev)
7820static void cpt_init_clock_gating(struct drm_device *dev) 7891static void cpt_init_clock_gating(struct drm_device *dev)
7821{ 7892{
7822 struct drm_i915_private *dev_priv = dev->dev_private; 7893 struct drm_i915_private *dev_priv = dev->dev_private;
7894 int pipe;
7823 7895
7824 /* 7896 /*
7825 * On Ibex Peak and Cougar Point, we need to disable clock 7897 * On Ibex Peak and Cougar Point, we need to disable clock
@@ -7829,6 +7901,9 @@ static void cpt_init_clock_gating(struct drm_device *dev)
7829 I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE); 7901 I915_WRITE(SOUTH_DSPCLK_GATE_D, PCH_DPLSUNIT_CLOCK_GATE_DISABLE);
7830 I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) | 7902 I915_WRITE(SOUTH_CHICKEN2, I915_READ(SOUTH_CHICKEN2) |
7831 DPLS_EDP_PPS_FIX_DIS); 7903 DPLS_EDP_PPS_FIX_DIS);
7904 /* Without this, mode sets may fail silently on FDI */
7905 for_each_pipe(pipe)
7906 I915_WRITE(TRANS_CHICKEN2(pipe), TRANS_AUTOTRAIN_GEN_STALL_DIS);
7832} 7907}
7833 7908
7834static void ironlake_teardown_rc6(struct drm_device *dev) 7909static void ironlake_teardown_rc6(struct drm_device *dev)
@@ -8178,6 +8253,9 @@ struct intel_quirk intel_quirks[] = {
8178 8253
8179 /* Lenovo U160 cannot use SSC on LVDS */ 8254 /* Lenovo U160 cannot use SSC on LVDS */
8180 { 0x0046, 0x17aa, 0x3920, quirk_ssc_force_disable }, 8255 { 0x0046, 0x17aa, 0x3920, quirk_ssc_force_disable },
8256
8257 /* Sony Vaio Y cannot use SSC on LVDS */
8258 { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable },
8181}; 8259};
8182 8260
8183static void intel_init_quirks(struct drm_device *dev) 8261static void intel_init_quirks(struct drm_device *dev)