diff options
author | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2013-09-13 08:59:11 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2013-09-16 16:38:51 -0400 |
commit | 6878da05006feb68efe23a6ae010b1a5df32ca5f (patch) | |
tree | 55953ec781636feac00474c488f8b30229a22510 /drivers/gpu/drm/i915/intel_display.c | |
parent | 794a79a6b00db14c535c951b03820ea5199c82a3 (diff) |
drm/i915: Add intel_dotclock_calculate()
Extract the code to calculate the dotclock from the link clock and M/N
values into a new function from ironlake_crtc_clock_get().
The new function can be used to calculate the dotclock for both FDI and
DP cases.
Also simplify the code a bit along the way.
v2: Don't forget about non-pch encoders in ironlake_crtc_clock_get()
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
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 | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 2e74ccce447d..94ef15c87b80 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -7427,16 +7427,9 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | |||
7427 | pipe_config->adjusted_mode.clock = clock.dot; | 7427 | pipe_config->adjusted_mode.clock = clock.dot; |
7428 | } | 7428 | } |
7429 | 7429 | ||
7430 | static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | 7430 | int intel_dotclock_calculate(int link_freq, |
7431 | struct intel_crtc_config *pipe_config) | 7431 | const struct intel_link_m_n *m_n) |
7432 | { | 7432 | { |
7433 | struct drm_device *dev = crtc->base.dev; | ||
7434 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7435 | enum transcoder cpu_transcoder = pipe_config->cpu_transcoder; | ||
7436 | int link_freq; | ||
7437 | u64 clock; | ||
7438 | u32 link_m, link_n; | ||
7439 | |||
7440 | /* | 7433 | /* |
7441 | * The calculation for the data clock is: | 7434 | * The calculation for the data clock is: |
7442 | * pixel_clock = ((m/n)*(link_clock * nr_lanes))/bpp | 7435 | * pixel_clock = ((m/n)*(link_clock * nr_lanes))/bpp |
@@ -7447,6 +7440,18 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | |||
7447 | * link_clock = (m * link_clock) / n | 7440 | * link_clock = (m * link_clock) / n |
7448 | */ | 7441 | */ |
7449 | 7442 | ||
7443 | if (!m_n->link_n) | ||
7444 | return 0; | ||
7445 | |||
7446 | return div_u64((u64)m_n->link_m * link_freq, m_n->link_n); | ||
7447 | } | ||
7448 | |||
7449 | static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | ||
7450 | struct intel_crtc_config *pipe_config) | ||
7451 | { | ||
7452 | struct drm_device *dev = crtc->base.dev; | ||
7453 | int link_freq; | ||
7454 | |||
7450 | /* | 7455 | /* |
7451 | * We need to get the FDI or DP link clock here to derive | 7456 | * We need to get the FDI or DP link clock here to derive |
7452 | * the M/N dividers. | 7457 | * the M/N dividers. |
@@ -7455,21 +7460,17 @@ static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | |||
7455 | * For DP, it's either 1.62GHz or 2.7GHz. | 7460 | * For DP, it's either 1.62GHz or 2.7GHz. |
7456 | * We do our calculations in 10*MHz since we don't need much precison. | 7461 | * We do our calculations in 10*MHz since we don't need much precison. |
7457 | */ | 7462 | */ |
7458 | if (pipe_config->has_pch_encoder) | 7463 | if (pipe_config->has_pch_encoder) { |
7459 | link_freq = intel_fdi_link_freq(dev) * 10000; | 7464 | link_freq = intel_fdi_link_freq(dev) * 10000; |
7460 | else | ||
7461 | link_freq = pipe_config->port_clock; | ||
7462 | 7465 | ||
7463 | link_m = I915_READ(PIPE_LINK_M1(cpu_transcoder)); | 7466 | pipe_config->adjusted_mode.clock = |
7464 | link_n = I915_READ(PIPE_LINK_N1(cpu_transcoder)); | 7467 | intel_dotclock_calculate(link_freq, &pipe_config->fdi_m_n); |
7465 | 7468 | } else { | |
7466 | if (!link_m || !link_n) | 7469 | link_freq = pipe_config->port_clock; |
7467 | return; | ||
7468 | |||
7469 | clock = ((u64)link_m * (u64)link_freq); | ||
7470 | do_div(clock, link_n); | ||
7471 | 7470 | ||
7472 | pipe_config->adjusted_mode.clock = clock; | 7471 | pipe_config->adjusted_mode.clock = |
7472 | intel_dotclock_calculate(link_freq, &pipe_config->dp_m_n); | ||
7473 | } | ||
7473 | } | 7474 | } |
7474 | 7475 | ||
7475 | /** Returns the currently programmed mode of the given pipe. */ | 7476 | /** Returns the currently programmed mode of the given pipe. */ |