aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorZhao Yakui <yakui.zhao@intel.com>2010-03-22 10:45:36 -0400
committerEric Anholt <eric@anholt.net>2010-04-12 12:27:46 -0400
commitd4294342fd4b94a3297867da00c1c5e929c28d4f (patch)
treee73174d08c90854f1f87d4b1a173122f8c631089 /drivers/gpu/drm/i915/intel_display.c
parenta2c459ee9aa52a659611ec1f1b43bfde49017b23 (diff)
drm/i915: Move Pineview CxSR and watermark code into update_wm hook.
Previously, after setting up the Pineview CxSR state, i9xx_update_wm would get called and overwrite our state. BTW: We will disable the self-refresh and never enable it any more if we can't find the appropriate the latency on pineview plaftorm. In such case the update_wm callback will be NULL. The bitmask macro is also defined to access the corresponding fifo watermark register. Signed-off-by: Zhao Yakui <yakui.zhao@intel.com> Signed-off-by: Zhenyu Wang <zhenyuw@linux.intel.com>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c153
1 files changed, 79 insertions, 74 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 32a248987867..e38c9068a04e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2645,66 +2645,6 @@ static void pineview_disable_cxsr(struct drm_device *dev)
2645 DRM_INFO("Big FIFO is disabled\n"); 2645 DRM_INFO("Big FIFO is disabled\n");
2646} 2646}
2647 2647
2648static void pineview_enable_cxsr(struct drm_device *dev, unsigned long clock,
2649 int pixel_size)
2650{
2651 struct drm_i915_private *dev_priv = dev->dev_private;
2652 u32 reg;
2653 unsigned long wm;
2654 struct cxsr_latency *latency;
2655
2656 latency = intel_get_cxsr_latency(IS_PINEVIEW_G(dev), dev_priv->fsb_freq,
2657 dev_priv->mem_freq);
2658 if (!latency) {
2659 DRM_DEBUG_KMS("Unknown FSB/MEM found, disable CxSR\n");
2660 pineview_disable_cxsr(dev);
2661 return;
2662 }
2663
2664 /* Display SR */
2665 wm = intel_calculate_wm(clock, &pineview_display_wm, pixel_size,
2666 latency->display_sr);
2667 reg = I915_READ(DSPFW1);
2668 reg &= 0x7fffff;
2669 reg |= wm << 23;
2670 I915_WRITE(DSPFW1, reg);
2671 DRM_DEBUG_KMS("DSPFW1 register is %x\n", reg);
2672
2673 /* cursor SR */
2674 wm = intel_calculate_wm(clock, &pineview_cursor_wm, pixel_size,
2675 latency->cursor_sr);
2676 reg = I915_READ(DSPFW3);
2677 reg &= ~(0x3f << 24);
2678 reg |= (wm & 0x3f) << 24;
2679 I915_WRITE(DSPFW3, reg);
2680
2681 /* Display HPLL off SR */
2682 wm = intel_calculate_wm(clock, &pineview_display_hplloff_wm,
2683 latency->display_hpll_disable, I915_FIFO_LINE_SIZE);
2684 reg = I915_READ(DSPFW3);
2685 reg &= 0xfffffe00;
2686 reg |= wm & 0x1ff;
2687 I915_WRITE(DSPFW3, reg);
2688
2689 /* cursor HPLL off SR */
2690 wm = intel_calculate_wm(clock, &pineview_cursor_hplloff_wm, pixel_size,
2691 latency->cursor_hpll_disable);
2692 reg = I915_READ(DSPFW3);
2693 reg &= ~(0x3f << 16);
2694 reg |= (wm & 0x3f) << 16;
2695 I915_WRITE(DSPFW3, reg);
2696 DRM_DEBUG_KMS("DSPFW3 register is %x\n", reg);
2697
2698 /* activate cxsr */
2699 reg = I915_READ(DSPFW3);
2700 reg |= PINEVIEW_SELF_REFRESH_EN;
2701 I915_WRITE(DSPFW3, reg);
2702
2703 DRM_INFO("Big FIFO is enabled\n");
2704
2705 return;
2706}
2707
2708/* 2648/*
2709 * Latency for FIFO fetches is dependent on several factors: 2649 * Latency for FIFO fetches is dependent on several factors:
2710 * - memory configuration (speed, channels) 2650 * - memory configuration (speed, channels)
@@ -2789,6 +2729,71 @@ static int i830_get_fifo_size(struct drm_device *dev, int plane)
2789 return size; 2729 return size;
2790} 2730}
2791 2731
2732static void pineview_update_wm(struct drm_device *dev, int planea_clock,
2733 int planeb_clock, int sr_hdisplay, int pixel_size)
2734{
2735 struct drm_i915_private *dev_priv = dev->dev_private;
2736 u32 reg;
2737 unsigned long wm;
2738 struct cxsr_latency *latency;
2739 int sr_clock;
2740
2741 latency = intel_get_cxsr_latency(IS_PINEVIEW_G(dev), dev_priv->fsb_freq,
2742 dev_priv->mem_freq);
2743 if (!latency) {
2744 DRM_DEBUG_KMS("Unknown FSB/MEM found, disable CxSR\n");
2745 pineview_disable_cxsr(dev);
2746 return;
2747 }
2748
2749 if (!planea_clock || !planeb_clock) {
2750 sr_clock = planea_clock ? planea_clock : planeb_clock;
2751
2752 /* Display SR */
2753 wm = intel_calculate_wm(sr_clock, &pineview_display_wm,
2754 pixel_size, latency->display_sr);
2755 reg = I915_READ(DSPFW1);
2756 reg &= ~DSPFW_SR_MASK;
2757 reg |= wm << DSPFW_SR_SHIFT;
2758 I915_WRITE(DSPFW1, reg);
2759 DRM_DEBUG_KMS("DSPFW1 register is %x\n", reg);
2760
2761 /* cursor SR */
2762 wm = intel_calculate_wm(sr_clock, &pineview_cursor_wm,
2763 pixel_size, latency->cursor_sr);
2764 reg = I915_READ(DSPFW3);
2765 reg &= ~DSPFW_CURSOR_SR_MASK;
2766 reg |= (wm & 0x3f) << DSPFW_CURSOR_SR_SHIFT;
2767 I915_WRITE(DSPFW3, reg);
2768
2769 /* Display HPLL off SR */
2770 wm = intel_calculate_wm(sr_clock, &pineview_display_hplloff_wm,
2771 pixel_size, latency->display_hpll_disable);
2772 reg = I915_READ(DSPFW3);
2773 reg &= ~DSPFW_HPLL_SR_MASK;
2774 reg |= wm & DSPFW_HPLL_SR_MASK;
2775 I915_WRITE(DSPFW3, reg);
2776
2777 /* cursor HPLL off SR */
2778 wm = intel_calculate_wm(sr_clock, &pineview_cursor_hplloff_wm,
2779 pixel_size, latency->cursor_hpll_disable);
2780 reg = I915_READ(DSPFW3);
2781 reg &= ~DSPFW_HPLL_CURSOR_MASK;
2782 reg |= (wm & 0x3f) << DSPFW_HPLL_CURSOR_SHIFT;
2783 I915_WRITE(DSPFW3, reg);
2784 DRM_DEBUG_KMS("DSPFW3 register is %x\n", reg);
2785
2786 /* activate cxsr */
2787 reg = I915_READ(DSPFW3);
2788 reg |= PINEVIEW_SELF_REFRESH_EN;
2789 I915_WRITE(DSPFW3, reg);
2790 DRM_DEBUG_KMS("Self-refresh is enabled\n");
2791 } else {
2792 pineview_disable_cxsr(dev);
2793 DRM_DEBUG_KMS("Self-refresh is disabled\n");
2794 }
2795}
2796
2792static void g4x_update_wm(struct drm_device *dev, int planea_clock, 2797static void g4x_update_wm(struct drm_device *dev, int planea_clock,
2793 int planeb_clock, int sr_hdisplay, int pixel_size) 2798 int planeb_clock, int sr_hdisplay, int pixel_size)
2794{ 2799{
@@ -3078,12 +3083,6 @@ static void intel_update_watermarks(struct drm_device *dev)
3078 if (enabled <= 0) 3083 if (enabled <= 0)
3079 return; 3084 return;
3080 3085
3081 /* Single plane configs can enable self refresh */
3082 if (enabled == 1 && IS_PINEVIEW(dev))
3083 pineview_enable_cxsr(dev, sr_clock, pixel_size);
3084 else if (IS_PINEVIEW(dev))
3085 pineview_disable_cxsr(dev);
3086
3087 dev_priv->display.update_wm(dev, planea_clock, planeb_clock, 3086 dev_priv->display.update_wm(dev, planea_clock, planeb_clock,
3088 sr_hdisplay, pixel_size); 3087 sr_hdisplay, pixel_size);
3089} 3088}
@@ -5091,7 +5090,20 @@ static void intel_init_display(struct drm_device *dev)
5091 /* For FIFO watermark updates */ 5090 /* For FIFO watermark updates */
5092 if (HAS_PCH_SPLIT(dev)) 5091 if (HAS_PCH_SPLIT(dev))
5093 dev_priv->display.update_wm = NULL; 5092 dev_priv->display.update_wm = NULL;
5094 else if (IS_G4X(dev)) 5093 else if (IS_PINEVIEW(dev)) {
5094 if (!intel_get_cxsr_latency(IS_PINEVIEW_G(dev),
5095 dev_priv->fsb_freq,
5096 dev_priv->mem_freq)) {
5097 DRM_INFO("failed to find known CxSR latency "
5098 "(found fsb freq %d, mem freq %d), "
5099 "disabling CxSR\n",
5100 dev_priv->fsb_freq, dev_priv->mem_freq);
5101 /* Disable CxSR and never update its watermark again */
5102 pineview_disable_cxsr(dev);
5103 dev_priv->display.update_wm = NULL;
5104 } else
5105 dev_priv->display.update_wm = pineview_update_wm;
5106 } else if (IS_G4X(dev))
5095 dev_priv->display.update_wm = g4x_update_wm; 5107 dev_priv->display.update_wm = g4x_update_wm;
5096 else if (IS_I965G(dev)) 5108 else if (IS_I965G(dev))
5097 dev_priv->display.update_wm = i965_update_wm; 5109 dev_priv->display.update_wm = i965_update_wm;
@@ -5164,13 +5176,6 @@ void intel_modeset_init(struct drm_device *dev)
5164 (unsigned long)dev); 5176 (unsigned long)dev);
5165 5177
5166 intel_setup_overlay(dev); 5178 intel_setup_overlay(dev);
5167
5168 if (IS_PINEVIEW(dev) && !intel_get_cxsr_latency(IS_PINEVIEW_G(dev),
5169 dev_priv->fsb_freq,
5170 dev_priv->mem_freq))
5171 DRM_INFO("failed to find known CxSR latency "
5172 "(found fsb freq %d, mem freq %d), disabling CxSR\n",
5173 dev_priv->fsb_freq, dev_priv->mem_freq);
5174} 5179}
5175 5180
5176void intel_modeset_cleanup(struct drm_device *dev) 5181void intel_modeset_cleanup(struct drm_device *dev)