Commit 3b1429d9 authored by Ville Syrjälä's avatar Ville Syrjälä Committed by Daniel Vetter

drm/i915: Factor out p2 divider selection for pre-ilk platforms

The same dpll p2 divider selection is repeated three times in the
gen2-4 .find_dpll() functions. Factor it out.
Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: default avatarImre Deak <imre.deak@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8c841e57
...@@ -641,16 +641,12 @@ static bool intel_PLL_is_valid(struct drm_device *dev, ...@@ -641,16 +641,12 @@ static bool intel_PLL_is_valid(struct drm_device *dev,
return true; return true;
} }
static bool static int
i9xx_find_best_dpll(const intel_limit_t *limit, i9xx_select_p2_div(const intel_limit_t *limit,
struct intel_crtc_state *crtc_state, const struct intel_crtc_state *crtc_state,
int target, int refclk, intel_clock_t *match_clock, int target)
intel_clock_t *best_clock)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); struct drm_device *dev = crtc_state->base.crtc->dev;
struct drm_device *dev = crtc->base.dev;
intel_clock_t clock;
int err = target;
if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) { if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) {
/* /*
...@@ -659,18 +655,31 @@ i9xx_find_best_dpll(const intel_limit_t *limit, ...@@ -659,18 +655,31 @@ i9xx_find_best_dpll(const intel_limit_t *limit,
* single/dual channel state, if we even can. * single/dual channel state, if we even can.
*/ */
if (intel_is_dual_link_lvds(dev)) if (intel_is_dual_link_lvds(dev))
clock.p2 = limit->p2.p2_fast; return limit->p2.p2_fast;
else else
clock.p2 = limit->p2.p2_slow; return limit->p2.p2_slow;
} else { } else {
if (target < limit->p2.dot_limit) if (target < limit->p2.dot_limit)
clock.p2 = limit->p2.p2_slow; return limit->p2.p2_slow;
else else
clock.p2 = limit->p2.p2_fast; return limit->p2.p2_fast;
} }
}
static bool
i9xx_find_best_dpll(const intel_limit_t *limit,
struct intel_crtc_state *crtc_state,
int target, int refclk, intel_clock_t *match_clock,
intel_clock_t *best_clock)
{
struct drm_device *dev = crtc_state->base.crtc->dev;
intel_clock_t clock;
int err = target;
memset(best_clock, 0, sizeof(*best_clock)); memset(best_clock, 0, sizeof(*best_clock));
clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
clock.m1++) { clock.m1++) {
for (clock.m2 = limit->m2.min; for (clock.m2 = limit->m2.min;
...@@ -710,30 +719,14 @@ pnv_find_best_dpll(const intel_limit_t *limit, ...@@ -710,30 +719,14 @@ pnv_find_best_dpll(const intel_limit_t *limit,
int target, int refclk, intel_clock_t *match_clock, int target, int refclk, intel_clock_t *match_clock,
intel_clock_t *best_clock) intel_clock_t *best_clock)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); struct drm_device *dev = crtc_state->base.crtc->dev;
struct drm_device *dev = crtc->base.dev;
intel_clock_t clock; intel_clock_t clock;
int err = target; int err = target;
if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) {
/*
* For LVDS just rely on its current settings for dual-channel.
* We haven't figured out how to reliably set up different
* single/dual channel state, if we even can.
*/
if (intel_is_dual_link_lvds(dev))
clock.p2 = limit->p2.p2_fast;
else
clock.p2 = limit->p2.p2_slow;
} else {
if (target < limit->p2.dot_limit)
clock.p2 = limit->p2.p2_slow;
else
clock.p2 = limit->p2.p2_fast;
}
memset(best_clock, 0, sizeof(*best_clock)); memset(best_clock, 0, sizeof(*best_clock));
clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
clock.m1++) { clock.m1++) {
for (clock.m2 = limit->m2.min; for (clock.m2 = limit->m2.min;
...@@ -771,28 +764,17 @@ g4x_find_best_dpll(const intel_limit_t *limit, ...@@ -771,28 +764,17 @@ g4x_find_best_dpll(const intel_limit_t *limit,
int target, int refclk, intel_clock_t *match_clock, int target, int refclk, intel_clock_t *match_clock,
intel_clock_t *best_clock) intel_clock_t *best_clock)
{ {
struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc); struct drm_device *dev = crtc_state->base.crtc->dev;
struct drm_device *dev = crtc->base.dev;
intel_clock_t clock; intel_clock_t clock;
int max_n; int max_n;
bool found; bool found = false;
/* approximately equals target * 0.00585 */ /* approximately equals target * 0.00585 */
int err_most = (target >> 8) + (target >> 9); int err_most = (target >> 8) + (target >> 9);
found = false;
if (intel_pipe_will_have_type(crtc_state, INTEL_OUTPUT_LVDS)) {
if (intel_is_dual_link_lvds(dev))
clock.p2 = limit->p2.p2_fast;
else
clock.p2 = limit->p2.p2_slow;
} else {
if (target < limit->p2.dot_limit)
clock.p2 = limit->p2.p2_slow;
else
clock.p2 = limit->p2.p2_fast;
}
memset(best_clock, 0, sizeof(*best_clock)); memset(best_clock, 0, sizeof(*best_clock));
clock.p2 = i9xx_select_p2_div(limit, crtc_state, target);
max_n = limit->n.max; max_n = limit->n.max;
/* based on hardware requirement, prefer smaller n to precision */ /* based on hardware requirement, prefer smaller n to precision */
for (clock.n = limit->n.min; clock.n <= max_n; clock.n++) { for (clock.n = limit->n.min; clock.n <= max_n; clock.n++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment