aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>2016-03-21 12:00:12 -0400
committerAnder Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com>2016-03-23 08:23:19 -0400
commit997c030cfdd0f87ca5ac8b77ef0821c5597263f8 (patch)
tree7a6d91e21580301bc3bab2ddb60b38c5f368aad6
parentb75ca6f62e57923e9c2870bf8d795c410ebb9534 (diff)
drm/i915: Merge ironlake_compute_clocks() and ironlake_crtc_compute_clock()
Merge ironlake_compute_clocks() into ironlake_crtc_compute_clock() so the clock computation logic is all in one place. The resulting function is still quite simple. Follow up patches will make the similar code for GMCH platforms look similar. Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira@intel.com> Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1458576016-30348-12-git-send-email-ander.conselvan.de.oliveira@intel.com
-rw-r--r--drivers/gpu/drm/i915/intel_display.c86
1 files changed, 33 insertions, 53 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 9741ee7783b9..894091fe9dab 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -846,6 +846,11 @@ pnv_find_best_dpll(const intel_limit_t *limit,
846 return (err != target); 846 return (err != target);
847} 847}
848 848
849/*
850 * Returns a set of divisors for the desired target clock with the given
851 * refclk, or FALSE. The returned values represent the clock equation:
852 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
853 */
849static bool 854static bool
850g4x_find_best_dpll(const intel_limit_t *limit, 855g4x_find_best_dpll(const intel_limit_t *limit,
851 struct intel_crtc_state *crtc_state, 856 struct intel_crtc_state *crtc_state,
@@ -8628,55 +8633,6 @@ static void haswell_set_pipemisc(struct drm_crtc *crtc)
8628 } 8633 }
8629} 8634}
8630 8635
8631static bool ironlake_compute_clocks(struct drm_crtc *crtc,
8632 struct intel_crtc_state *crtc_state,
8633 intel_clock_t *clock,
8634 bool *has_reduced_clock,
8635 intel_clock_t *reduced_clock)
8636{
8637 struct drm_device *dev = crtc->dev;
8638 struct drm_i915_private *dev_priv = dev->dev_private;
8639 int refclk;
8640 const intel_limit_t *limit;
8641 bool ret;
8642
8643 refclk = 120000;
8644
8645 if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) {
8646 if (intel_panel_use_ssc(dev_priv)) {
8647 DRM_DEBUG_KMS("using SSC reference clock of %d kHz\n",
8648 dev_priv->vbt.lvds_ssc_freq);
8649 refclk = dev_priv->vbt.lvds_ssc_freq;
8650 }
8651
8652 if (intel_is_dual_link_lvds(dev)) {
8653 if (refclk == 100000)
8654 limit = &intel_limits_ironlake_dual_lvds_100m;
8655 else
8656 limit = &intel_limits_ironlake_dual_lvds;
8657 } else {
8658 if (refclk == 100000)
8659 limit = &intel_limits_ironlake_single_lvds_100m;
8660 else
8661 limit = &intel_limits_ironlake_single_lvds;
8662 }
8663 } else {
8664 limit = &intel_limits_ironlake_dac;
8665 }
8666
8667 /*
8668 * Returns a set of divisors for the desired target clock with the given
8669 * refclk, or FALSE. The returned values represent the clock equation:
8670 * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2.
8671 */
8672 ret = g4x_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
8673 refclk, NULL, clock);
8674 if (!ret)
8675 return false;
8676
8677 return true;
8678}
8679
8680int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp) 8636int ironlake_get_lanes_required(int target_clock, int link_bw, int bpp)
8681{ 8637{
8682 /* 8638 /*
@@ -8801,9 +8757,13 @@ static void ironlake_compute_dpll(struct intel_crtc *intel_crtc,
8801static int ironlake_crtc_compute_clock(struct intel_crtc *crtc, 8757static int ironlake_crtc_compute_clock(struct intel_crtc *crtc,
8802 struct intel_crtc_state *crtc_state) 8758 struct intel_crtc_state *crtc_state)
8803{ 8759{
8760 struct drm_device *dev = crtc->base.dev;
8761 struct drm_i915_private *dev_priv = dev->dev_private;
8804 intel_clock_t reduced_clock; 8762 intel_clock_t reduced_clock;
8805 bool has_reduced_clock = false; 8763 bool has_reduced_clock = false;
8806 struct intel_shared_dpll *pll; 8764 struct intel_shared_dpll *pll;
8765 const intel_limit_t *limit;
8766 int refclk = 120000;
8807 8767
8808 memset(&crtc_state->dpll_hw_state, 0, 8768 memset(&crtc_state->dpll_hw_state, 0,
8809 sizeof(crtc_state->dpll_hw_state)); 8769 sizeof(crtc_state->dpll_hw_state));
@@ -8814,11 +8774,31 @@ static int ironlake_crtc_compute_clock(struct intel_crtc *crtc,
8814 if (!crtc_state->has_pch_encoder) 8774 if (!crtc_state->has_pch_encoder)
8815 return 0; 8775 return 0;
8816 8776
8777 if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) {
8778 if (intel_panel_use_ssc(dev_priv)) {
8779 DRM_DEBUG_KMS("using SSC reference clock of %d kHz\n",
8780 dev_priv->vbt.lvds_ssc_freq);
8781 refclk = dev_priv->vbt.lvds_ssc_freq;
8782 }
8783
8784 if (intel_is_dual_link_lvds(dev)) {
8785 if (refclk == 100000)
8786 limit = &intel_limits_ironlake_dual_lvds_100m;
8787 else
8788 limit = &intel_limits_ironlake_dual_lvds;
8789 } else {
8790 if (refclk == 100000)
8791 limit = &intel_limits_ironlake_single_lvds_100m;
8792 else
8793 limit = &intel_limits_ironlake_single_lvds;
8794 }
8795 } else {
8796 limit = &intel_limits_ironlake_dac;
8797 }
8798
8817 if (!crtc_state->clock_set && 8799 if (!crtc_state->clock_set &&
8818 !ironlake_compute_clocks(&crtc->base, crtc_state, 8800 !g4x_find_best_dpll(limit, crtc_state, crtc_state->port_clock,
8819 &crtc_state->dpll, 8801 refclk, NULL, &crtc_state->dpll)) {
8820 &has_reduced_clock,
8821 &reduced_clock)) {
8822 DRM_ERROR("Couldn't find PLL settings for mode!\n"); 8802 DRM_ERROR("Couldn't find PLL settings for mode!\n");
8823 return -EINVAL; 8803 return -EINVAL;
8824 } 8804 }