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.c89
1 files changed, 79 insertions, 10 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e77a863a3833..d809b038ca88 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -38,8 +38,8 @@
38#include "i915_drv.h" 38#include "i915_drv.h"
39#include "i915_trace.h" 39#include "i915_trace.h"
40#include "drm_dp_helper.h" 40#include "drm_dp_helper.h"
41
42#include "drm_crtc_helper.h" 41#include "drm_crtc_helper.h"
42#include <linux/dma_remapping.h>
43 43
44#define HAS_eDP (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) 44#define HAS_eDP (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))
45 45
@@ -4670,6 +4670,7 @@ static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
4670/** 4670/**
4671 * intel_choose_pipe_bpp_dither - figure out what color depth the pipe should send 4671 * intel_choose_pipe_bpp_dither - figure out what color depth the pipe should send
4672 * @crtc: CRTC structure 4672 * @crtc: CRTC structure
4673 * @mode: requested mode
4673 * 4674 *
4674 * A pipe may be connected to one or more outputs. Based on the depth of the 4675 * A pipe may be connected to one or more outputs. Based on the depth of the
4675 * attached framebuffer, choose a good color depth to use on the pipe. 4676 * attached framebuffer, choose a good color depth to use on the pipe.
@@ -4681,13 +4682,15 @@ static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv)
4681 * HDMI supports only 8bpc or 12bpc, so clamp to 8bpc with dither for 10bpc 4682 * HDMI supports only 8bpc or 12bpc, so clamp to 8bpc with dither for 10bpc
4682 * Displays may support a restricted set as well, check EDID and clamp as 4683 * Displays may support a restricted set as well, check EDID and clamp as
4683 * appropriate. 4684 * appropriate.
4685 * DP may want to dither down to 6bpc to fit larger modes
4684 * 4686 *
4685 * RETURNS: 4687 * RETURNS:
4686 * Dithering requirement (i.e. false if display bpc and pipe bpc match, 4688 * Dithering requirement (i.e. false if display bpc and pipe bpc match,
4687 * true if they don't match). 4689 * true if they don't match).
4688 */ 4690 */
4689static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc, 4691static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
4690 unsigned int *pipe_bpp) 4692 unsigned int *pipe_bpp,
4693 struct drm_display_mode *mode)
4691{ 4694{
4692 struct drm_device *dev = crtc->dev; 4695 struct drm_device *dev = crtc->dev;
4693 struct drm_i915_private *dev_priv = dev->dev_private; 4696 struct drm_i915_private *dev_priv = dev->dev_private;
@@ -4758,6 +4761,11 @@ static bool intel_choose_pipe_bpp_dither(struct drm_crtc *crtc,
4758 } 4761 }
4759 } 4762 }
4760 4763
4764 if (mode->private_flags & INTEL_MODE_DP_FORCE_6BPC) {
4765 DRM_DEBUG_KMS("Dithering DP to 6bpc\n");
4766 display_bpc = 6;
4767 }
4768
4761 /* 4769 /*
4762 * We could just drive the pipe at the highest bpc all the time and 4770 * We could just drive the pipe at the highest bpc all the time and
4763 * enable dithering as needed, but that costs bandwidth. So choose 4771 * enable dithering as needed, but that costs bandwidth. So choose
@@ -5019,6 +5027,16 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc,
5019 pipeconf &= ~PIPECONF_DOUBLE_WIDE; 5027 pipeconf &= ~PIPECONF_DOUBLE_WIDE;
5020 } 5028 }
5021 5029
5030 /* default to 8bpc */
5031 pipeconf &= ~(PIPECONF_BPP_MASK | PIPECONF_DITHER_EN);
5032 if (is_dp) {
5033 if (mode->private_flags & INTEL_MODE_DP_FORCE_6BPC) {
5034 pipeconf |= PIPECONF_BPP_6 |
5035 PIPECONF_DITHER_EN |
5036 PIPECONF_DITHER_TYPE_SP;
5037 }
5038 }
5039
5022 dpll |= DPLL_VCO_ENABLE; 5040 dpll |= DPLL_VCO_ENABLE;
5023 5041
5024 DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); 5042 DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B');
@@ -5480,7 +5498,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5480 /* determine panel color depth */ 5498 /* determine panel color depth */
5481 temp = I915_READ(PIPECONF(pipe)); 5499 temp = I915_READ(PIPECONF(pipe));
5482 temp &= ~PIPE_BPC_MASK; 5500 temp &= ~PIPE_BPC_MASK;
5483 dither = intel_choose_pipe_bpp_dither(crtc, &pipe_bpp); 5501 dither = intel_choose_pipe_bpp_dither(crtc, &pipe_bpp, mode);
5484 switch (pipe_bpp) { 5502 switch (pipe_bpp) {
5485 case 18: 5503 case 18:
5486 temp |= PIPE_6BPC; 5504 temp |= PIPE_6BPC;
@@ -7189,11 +7207,16 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
7189 work->old_fb_obj = intel_fb->obj; 7207 work->old_fb_obj = intel_fb->obj;
7190 INIT_WORK(&work->work, intel_unpin_work_fn); 7208 INIT_WORK(&work->work, intel_unpin_work_fn);
7191 7209
7210 ret = drm_vblank_get(dev, intel_crtc->pipe);
7211 if (ret)
7212 goto free_work;
7213
7192 /* We borrow the event spin lock for protecting unpin_work */ 7214 /* We borrow the event spin lock for protecting unpin_work */
7193 spin_lock_irqsave(&dev->event_lock, flags); 7215 spin_lock_irqsave(&dev->event_lock, flags);
7194 if (intel_crtc->unpin_work) { 7216 if (intel_crtc->unpin_work) {
7195 spin_unlock_irqrestore(&dev->event_lock, flags); 7217 spin_unlock_irqrestore(&dev->event_lock, flags);
7196 kfree(work); 7218 kfree(work);
7219 drm_vblank_put(dev, intel_crtc->pipe);
7197 7220
7198 DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); 7221 DRM_DEBUG_DRIVER("flip queue: crtc already busy\n");
7199 return -EBUSY; 7222 return -EBUSY;
@@ -7212,10 +7235,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
7212 7235
7213 crtc->fb = fb; 7236 crtc->fb = fb;
7214 7237
7215 ret = drm_vblank_get(dev, intel_crtc->pipe);
7216 if (ret)
7217 goto cleanup_objs;
7218
7219 work->pending_flip_obj = obj; 7238 work->pending_flip_obj = obj;
7220 7239
7221 work->enable_stall_check = true; 7240 work->enable_stall_check = true;
@@ -7238,7 +7257,6 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
7238 7257
7239cleanup_pending: 7258cleanup_pending:
7240 atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip); 7259 atomic_sub(1 << intel_crtc->plane, &work->old_fb_obj->pending_flip);
7241cleanup_objs:
7242 drm_gem_object_unreference(&work->old_fb_obj->base); 7260 drm_gem_object_unreference(&work->old_fb_obj->base);
7243 drm_gem_object_unreference(&obj->base); 7261 drm_gem_object_unreference(&obj->base);
7244 mutex_unlock(&dev->struct_mutex); 7262 mutex_unlock(&dev->struct_mutex);
@@ -7247,6 +7265,8 @@ cleanup_objs:
7247 intel_crtc->unpin_work = NULL; 7265 intel_crtc->unpin_work = NULL;
7248 spin_unlock_irqrestore(&dev->event_lock, flags); 7266 spin_unlock_irqrestore(&dev->event_lock, flags);
7249 7267
7268 drm_vblank_put(dev, intel_crtc->pipe);
7269free_work:
7250 kfree(work); 7270 kfree(work);
7251 7271
7252 return ret; 7272 return ret;
@@ -7887,6 +7907,33 @@ void intel_init_emon(struct drm_device *dev)
7887 dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK); 7907 dev_priv->corr = (lcfuse & LCFUSE_HIV_MASK);
7888} 7908}
7889 7909
7910static bool intel_enable_rc6(struct drm_device *dev)
7911{
7912 /*
7913 * Respect the kernel parameter if it is set
7914 */
7915 if (i915_enable_rc6 >= 0)
7916 return i915_enable_rc6;
7917
7918 /*
7919 * Disable RC6 on Ironlake
7920 */
7921 if (INTEL_INFO(dev)->gen == 5)
7922 return 0;
7923
7924 /*
7925 * Enable rc6 on Sandybridge if DMA remapping is disabled
7926 */
7927 if (INTEL_INFO(dev)->gen == 6) {
7928 DRM_DEBUG_DRIVER("Sandybridge: intel_iommu_enabled %s -- RC6 %sabled\n",
7929 intel_iommu_enabled ? "true" : "false",
7930 !intel_iommu_enabled ? "en" : "dis");
7931 return !intel_iommu_enabled;
7932 }
7933 DRM_DEBUG_DRIVER("RC6 enabled\n");
7934 return 1;
7935}
7936
7890void gen6_enable_rps(struct drm_i915_private *dev_priv) 7937void gen6_enable_rps(struct drm_i915_private *dev_priv)
7891{ 7938{
7892 u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP); 7939 u32 rp_state_cap = I915_READ(GEN6_RP_STATE_CAP);
@@ -7923,7 +7970,7 @@ void gen6_enable_rps(struct drm_i915_private *dev_priv)
7923 I915_WRITE(GEN6_RC6p_THRESHOLD, 100000); 7970 I915_WRITE(GEN6_RC6p_THRESHOLD, 100000);
7924 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */ 7971 I915_WRITE(GEN6_RC6pp_THRESHOLD, 64000); /* unused */
7925 7972
7926 if (i915_enable_rc6) 7973 if (intel_enable_rc6(dev_priv->dev))
7927 rc6_mask = GEN6_RC_CTL_RC6p_ENABLE | 7974 rc6_mask = GEN6_RC_CTL_RC6p_ENABLE |
7928 GEN6_RC_CTL_RC6_ENABLE; 7975 GEN6_RC_CTL_RC6_ENABLE;
7929 7976
@@ -8372,7 +8419,7 @@ void ironlake_enable_rc6(struct drm_device *dev)
8372 /* rc6 disabled by default due to repeated reports of hanging during 8419 /* rc6 disabled by default due to repeated reports of hanging during
8373 * boot and resume. 8420 * boot and resume.
8374 */ 8421 */
8375 if (!i915_enable_rc6) 8422 if (!intel_enable_rc6(dev))
8376 return; 8423 return;
8377 8424
8378 mutex_lock(&dev->struct_mutex); 8425 mutex_lock(&dev->struct_mutex);
@@ -8491,6 +8538,28 @@ static void intel_init_display(struct drm_device *dev)
8491 8538
8492 /* For FIFO watermark updates */ 8539 /* For FIFO watermark updates */
8493 if (HAS_PCH_SPLIT(dev)) { 8540 if (HAS_PCH_SPLIT(dev)) {
8541 dev_priv->display.force_wake_get = __gen6_gt_force_wake_get;
8542 dev_priv->display.force_wake_put = __gen6_gt_force_wake_put;
8543
8544 /* IVB configs may use multi-threaded forcewake */
8545 if (IS_IVYBRIDGE(dev)) {
8546 u32 ecobus;
8547
8548 mutex_lock(&dev->struct_mutex);
8549 __gen6_gt_force_wake_mt_get(dev_priv);
8550 ecobus = I915_READ(ECOBUS);
8551 __gen6_gt_force_wake_mt_put(dev_priv);
8552 mutex_unlock(&dev->struct_mutex);
8553
8554 if (ecobus & FORCEWAKE_MT_ENABLE) {
8555 DRM_DEBUG_KMS("Using MT version of forcewake\n");
8556 dev_priv->display.force_wake_get =
8557 __gen6_gt_force_wake_mt_get;
8558 dev_priv->display.force_wake_put =
8559 __gen6_gt_force_wake_mt_put;
8560 }
8561 }
8562
8494 if (HAS_PCH_IBX(dev)) 8563 if (HAS_PCH_IBX(dev))
8495 dev_priv->display.init_pch_clock_gating = ibx_init_clock_gating; 8564 dev_priv->display.init_pch_clock_gating = ibx_init_clock_gating;
8496 else if (HAS_PCH_CPT(dev)) 8565 else if (HAS_PCH_CPT(dev))