diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2011-12-15 15:30:37 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-01-17 05:06:10 -0500 |
commit | a7516a05311d0e2deb8ce8ae8b8c12a513ca8ca2 (patch) | |
tree | a2d1b8d780bd869fbd3ad7b8603d9d9ca83cc433 /drivers/gpu/drm/i915/intel_display.c | |
parent | c65d77d83ccffc60f8729b2e7806cac2564ee1b1 (diff) |
drm/i915: split out pll divider code
This cleans up the mode set path a little further, making it easier to
extend for future platforms.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
[danvet: shut up stupid gcc warning about potential use of
un-initlized fp2]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 62 |
1 files changed, 40 insertions, 22 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index b050a7785167..f3e706c2bd31 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -5024,6 +5024,40 @@ static void i9xx_adjust_sdvo_tv_clock(struct drm_display_mode *adjusted_mode, | |||
5024 | } | 5024 | } |
5025 | } | 5025 | } |
5026 | 5026 | ||
5027 | static void i9xx_update_pll_dividers(struct drm_crtc *crtc, | ||
5028 | intel_clock_t *clock, | ||
5029 | intel_clock_t *reduced_clock) | ||
5030 | { | ||
5031 | struct drm_device *dev = crtc->dev; | ||
5032 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5033 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
5034 | int pipe = intel_crtc->pipe; | ||
5035 | u32 fp, fp2 = 0; | ||
5036 | |||
5037 | if (IS_PINEVIEW(dev)) { | ||
5038 | fp = (1 << clock->n) << 16 | clock->m1 << 8 | clock->m2; | ||
5039 | if (reduced_clock) | ||
5040 | fp2 = (1 << reduced_clock->n) << 16 | | ||
5041 | reduced_clock->m1 << 8 | reduced_clock->m2; | ||
5042 | } else { | ||
5043 | fp = clock->n << 16 | clock->m1 << 8 | clock->m2; | ||
5044 | if (reduced_clock) | ||
5045 | fp2 = reduced_clock->n << 16 | reduced_clock->m1 << 8 | | ||
5046 | reduced_clock->m2; | ||
5047 | } | ||
5048 | |||
5049 | I915_WRITE(FP0(pipe), fp); | ||
5050 | |||
5051 | intel_crtc->lowfreq_avail = false; | ||
5052 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && | ||
5053 | reduced_clock && i915_powersave) { | ||
5054 | I915_WRITE(FP1(pipe), fp2); | ||
5055 | intel_crtc->lowfreq_avail = true; | ||
5056 | } else { | ||
5057 | I915_WRITE(FP1(pipe), fp); | ||
5058 | } | ||
5059 | } | ||
5060 | |||
5027 | static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | 5061 | static int i9xx_crtc_mode_set(struct drm_crtc *crtc, |
5028 | struct drm_display_mode *mode, | 5062 | struct drm_display_mode *mode, |
5029 | struct drm_display_mode *adjusted_mode, | 5063 | struct drm_display_mode *adjusted_mode, |
@@ -5037,7 +5071,7 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
5037 | int plane = intel_crtc->plane; | 5071 | int plane = intel_crtc->plane; |
5038 | int refclk, num_connectors = 0; | 5072 | int refclk, num_connectors = 0; |
5039 | intel_clock_t clock, reduced_clock; | 5073 | intel_clock_t clock, reduced_clock; |
5040 | u32 dpll, fp = 0, fp2 = 0, dspcntr, pipeconf; | 5074 | u32 dpll, dspcntr, pipeconf; |
5041 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; | 5075 | bool ok, has_reduced_clock = false, is_sdvo = false, is_dvo = false; |
5042 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | 5076 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; |
5043 | struct drm_mode_config *mode_config = &dev->mode_config; | 5077 | struct drm_mode_config *mode_config = &dev->mode_config; |
@@ -5113,17 +5147,8 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
5113 | if (is_sdvo && is_tv) | 5147 | if (is_sdvo && is_tv) |
5114 | i9xx_adjust_sdvo_tv_clock(adjusted_mode, &clock); | 5148 | i9xx_adjust_sdvo_tv_clock(adjusted_mode, &clock); |
5115 | 5149 | ||
5116 | if (IS_PINEVIEW(dev)) { | 5150 | i9xx_update_pll_dividers(crtc, &clock, has_reduced_clock ? |
5117 | fp = (1 << clock.n) << 16 | clock.m1 << 8 | clock.m2; | 5151 | &reduced_clock : NULL); |
5118 | if (has_reduced_clock) | ||
5119 | fp2 = (1 << reduced_clock.n) << 16 | | ||
5120 | reduced_clock.m1 << 8 | reduced_clock.m2; | ||
5121 | } else { | ||
5122 | fp = clock.n << 16 | clock.m1 << 8 | clock.m2; | ||
5123 | if (has_reduced_clock) | ||
5124 | fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 | | ||
5125 | reduced_clock.m2; | ||
5126 | } | ||
5127 | 5152 | ||
5128 | dpll = DPLL_VGA_MODE_DIS; | 5153 | dpll = DPLL_VGA_MODE_DIS; |
5129 | 5154 | ||
@@ -5233,7 +5258,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
5233 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); | 5258 | DRM_DEBUG_KMS("Mode for pipe %c:\n", pipe == 0 ? 'A' : 'B'); |
5234 | drm_mode_debug_printmodeline(mode); | 5259 | drm_mode_debug_printmodeline(mode); |
5235 | 5260 | ||
5236 | I915_WRITE(FP0(pipe), fp); | ||
5237 | I915_WRITE(DPLL(pipe), dpll & ~DPLL_VCO_ENABLE); | 5261 | I915_WRITE(DPLL(pipe), dpll & ~DPLL_VCO_ENABLE); |
5238 | 5262 | ||
5239 | POSTING_READ(DPLL(pipe)); | 5263 | POSTING_READ(DPLL(pipe)); |
@@ -5320,17 +5344,11 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
5320 | I915_WRITE(DPLL(pipe), dpll); | 5344 | I915_WRITE(DPLL(pipe), dpll); |
5321 | } | 5345 | } |
5322 | 5346 | ||
5323 | intel_crtc->lowfreq_avail = false; | 5347 | if (HAS_PIPE_CXSR(dev)) { |
5324 | if (is_lvds && has_reduced_clock && i915_powersave) { | 5348 | if (intel_crtc->lowfreq_avail) { |
5325 | I915_WRITE(FP1(pipe), fp2); | ||
5326 | intel_crtc->lowfreq_avail = true; | ||
5327 | if (HAS_PIPE_CXSR(dev)) { | ||
5328 | DRM_DEBUG_KMS("enabling CxSR downclocking\n"); | 5349 | DRM_DEBUG_KMS("enabling CxSR downclocking\n"); |
5329 | pipeconf |= PIPECONF_CXSR_DOWNCLOCK; | 5350 | pipeconf |= PIPECONF_CXSR_DOWNCLOCK; |
5330 | } | 5351 | } else { |
5331 | } else { | ||
5332 | I915_WRITE(FP1(pipe), fp); | ||
5333 | if (HAS_PIPE_CXSR(dev)) { | ||
5334 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); | 5352 | DRM_DEBUG_KMS("disabling CxSR downclocking\n"); |
5335 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; | 5353 | pipeconf &= ~PIPECONF_CXSR_DOWNCLOCK; |
5336 | } | 5354 | } |