aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-06-01 11:16:17 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-06-04 07:54:37 -0400
commitac58c3f046dde3c29b0e3fc7ea71a82b5f80c470 (patch)
tree7b502e7cddeca283923c300d8cd8bffe5c37ce56
parent1b829e05469963301736df69f0a2a2c3d3fb2225 (diff)
drm/i915: split out intel_pnv_find_best_PLL
Pineview is just different. Also split out i9xx_clock from intel_clock and drop the now redundant struct device * parameter. Note that in this patch I kill an XXX comment about 100MHz clocks. I couldn't figure out what this is about, and we don't seem to have any bug reports about this either. I suspect that it's a remnant from when the i9xx and ilk+ modeset code was all in the same file since ilk+ does indeed have a 100MHz clock. So I've just killed it to stop the cargo-culting. Reviewed-by: Paulo Zanoni <przanoni@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/intel_display.c92
1 files changed, 77 insertions, 15 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index cd22680e595c..5d22abe19b1f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -97,10 +97,13 @@ intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
97 int target, int refclk, intel_clock_t *match_clock, 97 int target, int refclk, intel_clock_t *match_clock,
98 intel_clock_t *best_clock); 98 intel_clock_t *best_clock);
99static bool 99static bool
100intel_pnv_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
101 int target, int refclk, intel_clock_t *match_clock,
102 intel_clock_t *best_clock);
103static bool
100intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc, 104intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
101 int target, int refclk, intel_clock_t *match_clock, 105 int target, int refclk, intel_clock_t *match_clock,
102 intel_clock_t *best_clock); 106 intel_clock_t *best_clock);
103
104static bool 107static bool
105intel_vlv_find_best_pll(const intel_limit_t *limit, struct drm_crtc *crtc, 108intel_vlv_find_best_pll(const intel_limit_t *limit, struct drm_crtc *crtc,
106 int target, int refclk, intel_clock_t *match_clock, 109 int target, int refclk, intel_clock_t *match_clock,
@@ -246,7 +249,7 @@ static const intel_limit_t intel_limits_pineview_sdvo = {
246 .p1 = { .min = 1, .max = 8 }, 249 .p1 = { .min = 1, .max = 8 },
247 .p2 = { .dot_limit = 200000, 250 .p2 = { .dot_limit = 200000,
248 .p2_slow = 10, .p2_fast = 5 }, 251 .p2_slow = 10, .p2_fast = 5 },
249 .find_pll = intel_find_best_PLL, 252 .find_pll = intel_pnv_find_best_PLL,
250}; 253};
251 254
252static const intel_limit_t intel_limits_pineview_lvds = { 255static const intel_limit_t intel_limits_pineview_lvds = {
@@ -260,7 +263,7 @@ static const intel_limit_t intel_limits_pineview_lvds = {
260 .p1 = { .min = 1, .max = 8 }, 263 .p1 = { .min = 1, .max = 8 },
261 .p2 = { .dot_limit = 112000, 264 .p2 = { .dot_limit = 112000,
262 .p2_slow = 14, .p2_fast = 14 }, 265 .p2_slow = 14, .p2_fast = 14 },
263 .find_pll = intel_find_best_PLL, 266 .find_pll = intel_pnv_find_best_PLL,
264}; 267};
265 268
266/* Ironlake / Sandybridge 269/* Ironlake / Sandybridge
@@ -475,12 +478,8 @@ static uint32_t i9xx_dpll_compute_m(struct dpll *dpll)
475 return 5 * (dpll->m1 + 2) + (dpll->m2 + 2); 478 return 5 * (dpll->m1 + 2) + (dpll->m2 + 2);
476} 479}
477 480
478static void intel_clock(struct drm_device *dev, int refclk, intel_clock_t *clock) 481static void i9xx_clock(int refclk, intel_clock_t *clock)
479{ 482{
480 if (IS_PINEVIEW(dev)) {
481 pineview_clock(refclk, clock);
482 return;
483 }
484 clock->m = i9xx_dpll_compute_m(clock); 483 clock->m = i9xx_dpll_compute_m(clock);
485 clock->p = clock->p1 * clock->p2; 484 clock->p = clock->p1 * clock->p2;
486 clock->vco = refclk * clock->m / (clock->n + 2); 485 clock->vco = refclk * clock->m / (clock->n + 2);
@@ -541,7 +540,68 @@ static bool
541intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc, 540intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
542 int target, int refclk, intel_clock_t *match_clock, 541 int target, int refclk, intel_clock_t *match_clock,
543 intel_clock_t *best_clock) 542 intel_clock_t *best_clock)
543{
544 struct drm_device *dev = crtc->dev;
545 intel_clock_t clock;
546 int err = target;
547
548 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) {
549 /*
550 * For LVDS just rely on its current settings for dual-channel.
551 * We haven't figured out how to reliably set up different
552 * single/dual channel state, if we even can.
553 */
554 if (intel_is_dual_link_lvds(dev))
555 clock.p2 = limit->p2.p2_fast;
556 else
557 clock.p2 = limit->p2.p2_slow;
558 } else {
559 if (target < limit->p2.dot_limit)
560 clock.p2 = limit->p2.p2_slow;
561 else
562 clock.p2 = limit->p2.p2_fast;
563 }
564
565 memset(best_clock, 0, sizeof(*best_clock));
566
567 for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max;
568 clock.m1++) {
569 for (clock.m2 = limit->m2.min;
570 clock.m2 <= limit->m2.max; clock.m2++) {
571 /* m1 is always 0 in Pineview */
572 if (clock.m2 >= clock.m1 && !IS_PINEVIEW(dev))
573 break;
574 for (clock.n = limit->n.min;
575 clock.n <= limit->n.max; clock.n++) {
576 for (clock.p1 = limit->p1.min;
577 clock.p1 <= limit->p1.max; clock.p1++) {
578 int this_err;
544 579
580 i9xx_clock(refclk, &clock);
581 if (!intel_PLL_is_valid(dev, limit,
582 &clock))
583 continue;
584 if (match_clock &&
585 clock.p != match_clock->p)
586 continue;
587
588 this_err = abs(clock.dot - target);
589 if (this_err < err) {
590 *best_clock = clock;
591 err = this_err;
592 }
593 }
594 }
595 }
596 }
597
598 return (err != target);
599}
600
601static bool
602intel_pnv_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
603 int target, int refclk, intel_clock_t *match_clock,
604 intel_clock_t *best_clock)
545{ 605{
546 struct drm_device *dev = crtc->dev; 606 struct drm_device *dev = crtc->dev;
547 intel_clock_t clock; 607 intel_clock_t clock;
@@ -579,7 +639,7 @@ intel_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
579 clock.p1 <= limit->p1.max; clock.p1++) { 639 clock.p1 <= limit->p1.max; clock.p1++) {
580 int this_err; 640 int this_err;
581 641
582 intel_clock(dev, refclk, &clock); 642 pineview_clock(refclk, &clock);
583 if (!intel_PLL_is_valid(dev, limit, 643 if (!intel_PLL_is_valid(dev, limit,
584 &clock)) 644 &clock))
585 continue; 645 continue;
@@ -638,7 +698,7 @@ intel_g4x_find_best_PLL(const intel_limit_t *limit, struct drm_crtc *crtc,
638 clock.p1 >= limit->p1.min; clock.p1--) { 698 clock.p1 >= limit->p1.min; clock.p1--) {
639 int this_err; 699 int this_err;
640 700
641 intel_clock(dev, refclk, &clock); 701 i9xx_clock(refclk, &clock);
642 if (!intel_PLL_is_valid(dev, limit, 702 if (!intel_PLL_is_valid(dev, limit,
643 &clock)) 703 &clock))
644 continue; 704 continue;
@@ -6910,8 +6970,10 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
6910 return 0; 6970 return 0;
6911 } 6971 }
6912 6972
6913 /* XXX: Handle the 100Mhz refclk */ 6973 if (IS_PINEVIEW(dev))
6914 intel_clock(dev, 96000, &clock); 6974 pineview_clock(96000, &clock);
6975 else
6976 i9xx_clock(96000, &clock);
6915 } else { 6977 } else {
6916 bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN); 6978 bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN);
6917 6979
@@ -6923,9 +6985,9 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
6923 if ((dpll & PLL_REF_INPUT_MASK) == 6985 if ((dpll & PLL_REF_INPUT_MASK) ==
6924 PLLB_REF_INPUT_SPREADSPECTRUMIN) { 6986 PLLB_REF_INPUT_SPREADSPECTRUMIN) {
6925 /* XXX: might not be 66MHz */ 6987 /* XXX: might not be 66MHz */
6926 intel_clock(dev, 66000, &clock); 6988 i9xx_clock(66000, &clock);
6927 } else 6989 } else
6928 intel_clock(dev, 48000, &clock); 6990 i9xx_clock(48000, &clock);
6929 } else { 6991 } else {
6930 if (dpll & PLL_P1_DIVIDE_BY_TWO) 6992 if (dpll & PLL_P1_DIVIDE_BY_TWO)
6931 clock.p1 = 2; 6993 clock.p1 = 2;
@@ -6938,7 +7000,7 @@ static int intel_crtc_clock_get(struct drm_device *dev, struct drm_crtc *crtc)
6938 else 7000 else
6939 clock.p2 = 2; 7001 clock.p2 = 2;
6940 7002
6941 intel_clock(dev, 48000, &clock); 7003 i9xx_clock(48000, &clock);
6942 } 7004 }
6943 } 7005 }
6944 7006