diff options
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 1701 |
1 files changed, 1097 insertions, 604 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index d78d33f9337d..3cddd508d110 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -41,14 +41,13 @@ | |||
41 | #include <drm/drm_crtc_helper.h> | 41 | #include <drm/drm_crtc_helper.h> |
42 | #include <linux/dma_remapping.h> | 42 | #include <linux/dma_remapping.h> |
43 | 43 | ||
44 | bool intel_pipe_has_type(struct drm_crtc *crtc, int type); | ||
45 | static void intel_increase_pllclock(struct drm_crtc *crtc); | 44 | static void intel_increase_pllclock(struct drm_crtc *crtc); |
46 | static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); | 45 | static void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); |
47 | 46 | ||
48 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | 47 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, |
49 | struct intel_crtc_config *pipe_config); | 48 | struct intel_crtc_config *pipe_config); |
50 | static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | 49 | static void ironlake_pch_clock_get(struct intel_crtc *crtc, |
51 | struct intel_crtc_config *pipe_config); | 50 | struct intel_crtc_config *pipe_config); |
52 | 51 | ||
53 | static int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, | 52 | static int intel_set_mode(struct drm_crtc *crtc, struct drm_display_mode *mode, |
54 | int x, int y, struct drm_framebuffer *old_fb); | 53 | int x, int y, struct drm_framebuffer *old_fb); |
@@ -69,9 +68,6 @@ struct intel_limit { | |||
69 | intel_p2_t p2; | 68 | intel_p2_t p2; |
70 | }; | 69 | }; |
71 | 70 | ||
72 | /* FDI */ | ||
73 | #define IRONLAKE_FDI_FREQ 2700000 /* in kHz for mode->clock */ | ||
74 | |||
75 | int | 71 | int |
76 | intel_pch_rawclk(struct drm_device *dev) | 72 | intel_pch_rawclk(struct drm_device *dev) |
77 | { | 73 | { |
@@ -313,44 +309,44 @@ static const intel_limit_t intel_limits_ironlake_dual_lvds_100m = { | |||
313 | .p2_slow = 7, .p2_fast = 7 }, | 309 | .p2_slow = 7, .p2_fast = 7 }, |
314 | }; | 310 | }; |
315 | 311 | ||
316 | static const intel_limit_t intel_limits_vlv_dac = { | 312 | static const intel_limit_t intel_limits_vlv = { |
317 | .dot = { .min = 25000, .max = 270000 }, | 313 | /* |
318 | .vco = { .min = 4000000, .max = 6000000 }, | 314 | * These are the data rate limits (measured in fast clocks) |
319 | .n = { .min = 1, .max = 7 }, | 315 | * since those are the strictest limits we have. The fast |
320 | .m = { .min = 22, .max = 450 }, /* guess */ | 316 | * clock and actual rate limits are more relaxed, so checking |
321 | .m1 = { .min = 2, .max = 3 }, | 317 | * them would make no difference. |
322 | .m2 = { .min = 11, .max = 156 }, | 318 | */ |
323 | .p = { .min = 10, .max = 30 }, | 319 | .dot = { .min = 25000 * 5, .max = 270000 * 5 }, |
324 | .p1 = { .min = 1, .max = 3 }, | ||
325 | .p2 = { .dot_limit = 270000, | ||
326 | .p2_slow = 2, .p2_fast = 20 }, | ||
327 | }; | ||
328 | |||
329 | static const intel_limit_t intel_limits_vlv_hdmi = { | ||
330 | .dot = { .min = 25000, .max = 270000 }, | ||
331 | .vco = { .min = 4000000, .max = 6000000 }, | 320 | .vco = { .min = 4000000, .max = 6000000 }, |
332 | .n = { .min = 1, .max = 7 }, | 321 | .n = { .min = 1, .max = 7 }, |
333 | .m = { .min = 60, .max = 300 }, /* guess */ | ||
334 | .m1 = { .min = 2, .max = 3 }, | 322 | .m1 = { .min = 2, .max = 3 }, |
335 | .m2 = { .min = 11, .max = 156 }, | 323 | .m2 = { .min = 11, .max = 156 }, |
336 | .p = { .min = 10, .max = 30 }, | ||
337 | .p1 = { .min = 2, .max = 3 }, | 324 | .p1 = { .min = 2, .max = 3 }, |
338 | .p2 = { .dot_limit = 270000, | 325 | .p2 = { .p2_slow = 2, .p2_fast = 20 }, /* slow=min, fast=max */ |
339 | .p2_slow = 2, .p2_fast = 20 }, | ||
340 | }; | 326 | }; |
341 | 327 | ||
342 | static const intel_limit_t intel_limits_vlv_dp = { | 328 | static void vlv_clock(int refclk, intel_clock_t *clock) |
343 | .dot = { .min = 25000, .max = 270000 }, | 329 | { |
344 | .vco = { .min = 4000000, .max = 6000000 }, | 330 | clock->m = clock->m1 * clock->m2; |
345 | .n = { .min = 1, .max = 7 }, | 331 | clock->p = clock->p1 * clock->p2; |
346 | .m = { .min = 22, .max = 450 }, | 332 | clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n); |
347 | .m1 = { .min = 2, .max = 3 }, | 333 | clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p); |
348 | .m2 = { .min = 11, .max = 156 }, | 334 | } |
349 | .p = { .min = 10, .max = 30 }, | 335 | |
350 | .p1 = { .min = 1, .max = 3 }, | 336 | /** |
351 | .p2 = { .dot_limit = 270000, | 337 | * Returns whether any output on the specified pipe is of the specified type |
352 | .p2_slow = 2, .p2_fast = 20 }, | 338 | */ |
353 | }; | 339 | static bool intel_pipe_has_type(struct drm_crtc *crtc, int type) |
340 | { | ||
341 | struct drm_device *dev = crtc->dev; | ||
342 | struct intel_encoder *encoder; | ||
343 | |||
344 | for_each_encoder_on_crtc(dev, crtc, encoder) | ||
345 | if (encoder->type == type) | ||
346 | return true; | ||
347 | |||
348 | return false; | ||
349 | } | ||
354 | 350 | ||
355 | static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc, | 351 | static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc, |
356 | int refclk) | 352 | int refclk) |
@@ -412,12 +408,7 @@ static const intel_limit_t *intel_limit(struct drm_crtc *crtc, int refclk) | |||
412 | else | 408 | else |
413 | limit = &intel_limits_pineview_sdvo; | 409 | limit = &intel_limits_pineview_sdvo; |
414 | } else if (IS_VALLEYVIEW(dev)) { | 410 | } else if (IS_VALLEYVIEW(dev)) { |
415 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) | 411 | limit = &intel_limits_vlv; |
416 | limit = &intel_limits_vlv_dac; | ||
417 | else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI)) | ||
418 | limit = &intel_limits_vlv_hdmi; | ||
419 | else | ||
420 | limit = &intel_limits_vlv_dp; | ||
421 | } else if (!IS_GEN2(dev)) { | 412 | } else if (!IS_GEN2(dev)) { |
422 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) | 413 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) |
423 | limit = &intel_limits_i9xx_lvds; | 414 | limit = &intel_limits_i9xx_lvds; |
@@ -439,8 +430,8 @@ static void pineview_clock(int refclk, intel_clock_t *clock) | |||
439 | { | 430 | { |
440 | clock->m = clock->m2 + 2; | 431 | clock->m = clock->m2 + 2; |
441 | clock->p = clock->p1 * clock->p2; | 432 | clock->p = clock->p1 * clock->p2; |
442 | clock->vco = refclk * clock->m / clock->n; | 433 | clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n); |
443 | clock->dot = clock->vco / clock->p; | 434 | clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p); |
444 | } | 435 | } |
445 | 436 | ||
446 | static uint32_t i9xx_dpll_compute_m(struct dpll *dpll) | 437 | static uint32_t i9xx_dpll_compute_m(struct dpll *dpll) |
@@ -452,23 +443,8 @@ static void i9xx_clock(int refclk, intel_clock_t *clock) | |||
452 | { | 443 | { |
453 | clock->m = i9xx_dpll_compute_m(clock); | 444 | clock->m = i9xx_dpll_compute_m(clock); |
454 | clock->p = clock->p1 * clock->p2; | 445 | clock->p = clock->p1 * clock->p2; |
455 | clock->vco = refclk * clock->m / (clock->n + 2); | 446 | clock->vco = DIV_ROUND_CLOSEST(refclk * clock->m, clock->n + 2); |
456 | clock->dot = clock->vco / clock->p; | 447 | clock->dot = DIV_ROUND_CLOSEST(clock->vco, clock->p); |
457 | } | ||
458 | |||
459 | /** | ||
460 | * Returns whether any output on the specified pipe is of the specified type | ||
461 | */ | ||
462 | bool intel_pipe_has_type(struct drm_crtc *crtc, int type) | ||
463 | { | ||
464 | struct drm_device *dev = crtc->dev; | ||
465 | struct intel_encoder *encoder; | ||
466 | |||
467 | for_each_encoder_on_crtc(dev, crtc, encoder) | ||
468 | if (encoder->type == type) | ||
469 | return true; | ||
470 | |||
471 | return false; | ||
472 | } | 448 | } |
473 | 449 | ||
474 | #define INTELPllInvalid(s) do { /* DRM_DEBUG(s); */ return false; } while (0) | 450 | #define INTELPllInvalid(s) do { /* DRM_DEBUG(s); */ return false; } while (0) |
@@ -481,20 +457,26 @@ static bool intel_PLL_is_valid(struct drm_device *dev, | |||
481 | const intel_limit_t *limit, | 457 | const intel_limit_t *limit, |
482 | const intel_clock_t *clock) | 458 | const intel_clock_t *clock) |
483 | { | 459 | { |
460 | if (clock->n < limit->n.min || limit->n.max < clock->n) | ||
461 | INTELPllInvalid("n out of range\n"); | ||
484 | if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1) | 462 | if (clock->p1 < limit->p1.min || limit->p1.max < clock->p1) |
485 | INTELPllInvalid("p1 out of range\n"); | 463 | INTELPllInvalid("p1 out of range\n"); |
486 | if (clock->p < limit->p.min || limit->p.max < clock->p) | ||
487 | INTELPllInvalid("p out of range\n"); | ||
488 | if (clock->m2 < limit->m2.min || limit->m2.max < clock->m2) | 464 | if (clock->m2 < limit->m2.min || limit->m2.max < clock->m2) |
489 | INTELPllInvalid("m2 out of range\n"); | 465 | INTELPllInvalid("m2 out of range\n"); |
490 | if (clock->m1 < limit->m1.min || limit->m1.max < clock->m1) | 466 | if (clock->m1 < limit->m1.min || limit->m1.max < clock->m1) |
491 | INTELPllInvalid("m1 out of range\n"); | 467 | INTELPllInvalid("m1 out of range\n"); |
492 | if (clock->m1 <= clock->m2 && !IS_PINEVIEW(dev)) | 468 | |
493 | INTELPllInvalid("m1 <= m2\n"); | 469 | if (!IS_PINEVIEW(dev) && !IS_VALLEYVIEW(dev)) |
494 | if (clock->m < limit->m.min || limit->m.max < clock->m) | 470 | if (clock->m1 <= clock->m2) |
495 | INTELPllInvalid("m out of range\n"); | 471 | INTELPllInvalid("m1 <= m2\n"); |
496 | if (clock->n < limit->n.min || limit->n.max < clock->n) | 472 | |
497 | INTELPllInvalid("n out of range\n"); | 473 | if (!IS_VALLEYVIEW(dev)) { |
474 | if (clock->p < limit->p.min || limit->p.max < clock->p) | ||
475 | INTELPllInvalid("p out of range\n"); | ||
476 | if (clock->m < limit->m.min || limit->m.max < clock->m) | ||
477 | INTELPllInvalid("m out of range\n"); | ||
478 | } | ||
479 | |||
498 | if (clock->vco < limit->vco.min || limit->vco.max < clock->vco) | 480 | if (clock->vco < limit->vco.min || limit->vco.max < clock->vco) |
499 | INTELPllInvalid("vco out of range\n"); | 481 | INTELPllInvalid("vco out of range\n"); |
500 | /* XXX: We may need to be checking "Dot clock" depending on the multiplier, | 482 | /* XXX: We may need to be checking "Dot clock" depending on the multiplier, |
@@ -688,67 +670,73 @@ vlv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, | |||
688 | int target, int refclk, intel_clock_t *match_clock, | 670 | int target, int refclk, intel_clock_t *match_clock, |
689 | intel_clock_t *best_clock) | 671 | intel_clock_t *best_clock) |
690 | { | 672 | { |
691 | u32 p1, p2, m1, m2, vco, bestn, bestm1, bestm2, bestp1, bestp2; | 673 | struct drm_device *dev = crtc->dev; |
692 | u32 m, n, fastclk; | 674 | intel_clock_t clock; |
693 | u32 updrate, minupdate, p; | 675 | unsigned int bestppm = 1000000; |
694 | unsigned long bestppm, ppm, absppm; | 676 | /* min update 19.2 MHz */ |
695 | int dotclk, flag; | 677 | int max_n = min(limit->n.max, refclk / 19200); |
696 | 678 | bool found = false; | |
697 | flag = 0; | 679 | |
698 | dotclk = target * 1000; | 680 | target *= 5; /* fast clock */ |
699 | bestppm = 1000000; | 681 | |
700 | ppm = absppm = 0; | 682 | memset(best_clock, 0, sizeof(*best_clock)); |
701 | fastclk = dotclk / (2*100); | ||
702 | updrate = 0; | ||
703 | minupdate = 19200; | ||
704 | n = p = p1 = p2 = m = m1 = m2 = vco = bestn = 0; | ||
705 | bestm1 = bestm2 = bestp1 = bestp2 = 0; | ||
706 | 683 | ||
707 | /* based on hardware requirement, prefer smaller n to precision */ | 684 | /* based on hardware requirement, prefer smaller n to precision */ |
708 | for (n = limit->n.min; n <= ((refclk) / minupdate); n++) { | 685 | for (clock.n = limit->n.min; clock.n <= max_n; clock.n++) { |
709 | updrate = refclk / n; | 686 | for (clock.p1 = limit->p1.max; clock.p1 >= limit->p1.min; clock.p1--) { |
710 | for (p1 = limit->p1.max; p1 > limit->p1.min; p1--) { | 687 | for (clock.p2 = limit->p2.p2_fast; clock.p2 >= limit->p2.p2_slow; |
711 | for (p2 = limit->p2.p2_fast+1; p2 > 0; p2--) { | 688 | clock.p2 -= clock.p2 > 10 ? 2 : 1) { |
712 | if (p2 > 10) | 689 | clock.p = clock.p1 * clock.p2; |
713 | p2 = p2 - 1; | ||
714 | p = p1 * p2; | ||
715 | /* based on hardware requirement, prefer bigger m1,m2 values */ | 690 | /* based on hardware requirement, prefer bigger m1,m2 values */ |
716 | for (m1 = limit->m1.min; m1 <= limit->m1.max; m1++) { | 691 | for (clock.m1 = limit->m1.min; clock.m1 <= limit->m1.max; clock.m1++) { |
717 | m2 = (((2*(fastclk * p * n / m1 )) + | 692 | unsigned int ppm, diff; |
718 | refclk) / (2*refclk)); | 693 | |
719 | m = m1 * m2; | 694 | clock.m2 = DIV_ROUND_CLOSEST(target * clock.p * clock.n, |
720 | vco = updrate * m; | 695 | refclk * clock.m1); |
721 | if (vco >= limit->vco.min && vco < limit->vco.max) { | 696 | |
722 | ppm = 1000000 * ((vco / p) - fastclk) / fastclk; | 697 | vlv_clock(refclk, &clock); |
723 | absppm = (ppm > 0) ? ppm : (-ppm); | 698 | |
724 | if (absppm < 100 && ((p1 * p2) > (bestp1 * bestp2))) { | 699 | if (!intel_PLL_is_valid(dev, limit, |
725 | bestppm = 0; | 700 | &clock)) |
726 | flag = 1; | 701 | continue; |
727 | } | 702 | |
728 | if (absppm < bestppm - 10) { | 703 | diff = abs(clock.dot - target); |
729 | bestppm = absppm; | 704 | ppm = div_u64(1000000ULL * diff, target); |
730 | flag = 1; | 705 | |
731 | } | 706 | if (ppm < 100 && clock.p > best_clock->p) { |
732 | if (flag) { | 707 | bestppm = 0; |
733 | bestn = n; | 708 | *best_clock = clock; |
734 | bestm1 = m1; | 709 | found = true; |
735 | bestm2 = m2; | 710 | } |
736 | bestp1 = p1; | 711 | |
737 | bestp2 = p2; | 712 | if (bestppm >= 10 && ppm < bestppm - 10) { |
738 | flag = 0; | 713 | bestppm = ppm; |
739 | } | 714 | *best_clock = clock; |
715 | found = true; | ||
740 | } | 716 | } |
741 | } | 717 | } |
742 | } | 718 | } |
743 | } | 719 | } |
744 | } | 720 | } |
745 | best_clock->n = bestn; | ||
746 | best_clock->m1 = bestm1; | ||
747 | best_clock->m2 = bestm2; | ||
748 | best_clock->p1 = bestp1; | ||
749 | best_clock->p2 = bestp2; | ||
750 | 721 | ||
751 | return true; | 722 | return found; |
723 | } | ||
724 | |||
725 | bool intel_crtc_active(struct drm_crtc *crtc) | ||
726 | { | ||
727 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
728 | |||
729 | /* Be paranoid as we can arrive here with only partial | ||
730 | * state retrieved from the hardware during setup. | ||
731 | * | ||
732 | * We can ditch the adjusted_mode.crtc_clock check as soon | ||
733 | * as Haswell has gained clock readout/fastboot support. | ||
734 | * | ||
735 | * We can ditch the crtc->fb check as soon as we can | ||
736 | * properly reconstruct framebuffers. | ||
737 | */ | ||
738 | return intel_crtc->active && crtc->fb && | ||
739 | intel_crtc->config.adjusted_mode.crtc_clock; | ||
752 | } | 740 | } |
753 | 741 | ||
754 | enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv, | 742 | enum transcoder intel_pipe_to_cpu_transcoder(struct drm_i915_private *dev_priv, |
@@ -812,6 +800,25 @@ void intel_wait_for_vblank(struct drm_device *dev, int pipe) | |||
812 | DRM_DEBUG_KMS("vblank wait timed out\n"); | 800 | DRM_DEBUG_KMS("vblank wait timed out\n"); |
813 | } | 801 | } |
814 | 802 | ||
803 | static bool pipe_dsl_stopped(struct drm_device *dev, enum pipe pipe) | ||
804 | { | ||
805 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
806 | u32 reg = PIPEDSL(pipe); | ||
807 | u32 line1, line2; | ||
808 | u32 line_mask; | ||
809 | |||
810 | if (IS_GEN2(dev)) | ||
811 | line_mask = DSL_LINEMASK_GEN2; | ||
812 | else | ||
813 | line_mask = DSL_LINEMASK_GEN3; | ||
814 | |||
815 | line1 = I915_READ(reg) & line_mask; | ||
816 | mdelay(5); | ||
817 | line2 = I915_READ(reg) & line_mask; | ||
818 | |||
819 | return line1 == line2; | ||
820 | } | ||
821 | |||
815 | /* | 822 | /* |
816 | * intel_wait_for_pipe_off - wait for pipe to turn off | 823 | * intel_wait_for_pipe_off - wait for pipe to turn off |
817 | * @dev: drm device | 824 | * @dev: drm device |
@@ -843,22 +850,8 @@ void intel_wait_for_pipe_off(struct drm_device *dev, int pipe) | |||
843 | 100)) | 850 | 100)) |
844 | WARN(1, "pipe_off wait timed out\n"); | 851 | WARN(1, "pipe_off wait timed out\n"); |
845 | } else { | 852 | } else { |
846 | u32 last_line, line_mask; | ||
847 | int reg = PIPEDSL(pipe); | ||
848 | unsigned long timeout = jiffies + msecs_to_jiffies(100); | ||
849 | |||
850 | if (IS_GEN2(dev)) | ||
851 | line_mask = DSL_LINEMASK_GEN2; | ||
852 | else | ||
853 | line_mask = DSL_LINEMASK_GEN3; | ||
854 | |||
855 | /* Wait for the display line to settle */ | 853 | /* Wait for the display line to settle */ |
856 | do { | 854 | if (wait_for(pipe_dsl_stopped(dev, pipe), 100)) |
857 | last_line = I915_READ(reg) & line_mask; | ||
858 | mdelay(5); | ||
859 | } while (((I915_READ(reg) & line_mask) != last_line) && | ||
860 | time_after(timeout, jiffies)); | ||
861 | if (time_after(jiffies, timeout)) | ||
862 | WARN(1, "pipe_off wait timed out\n"); | 855 | WARN(1, "pipe_off wait timed out\n"); |
863 | } | 856 | } |
864 | } | 857 | } |
@@ -929,6 +922,24 @@ void assert_pll(struct drm_i915_private *dev_priv, | |||
929 | state_string(state), state_string(cur_state)); | 922 | state_string(state), state_string(cur_state)); |
930 | } | 923 | } |
931 | 924 | ||
925 | /* XXX: the dsi pll is shared between MIPI DSI ports */ | ||
926 | static void assert_dsi_pll(struct drm_i915_private *dev_priv, bool state) | ||
927 | { | ||
928 | u32 val; | ||
929 | bool cur_state; | ||
930 | |||
931 | mutex_lock(&dev_priv->dpio_lock); | ||
932 | val = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL); | ||
933 | mutex_unlock(&dev_priv->dpio_lock); | ||
934 | |||
935 | cur_state = val & DSI_PLL_VCO_EN; | ||
936 | WARN(cur_state != state, | ||
937 | "DSI PLL state assertion failure (expected %s, current %s)\n", | ||
938 | state_string(state), state_string(cur_state)); | ||
939 | } | ||
940 | #define assert_dsi_pll_enabled(d) assert_dsi_pll(d, true) | ||
941 | #define assert_dsi_pll_disabled(d) assert_dsi_pll(d, false) | ||
942 | |||
932 | struct intel_shared_dpll * | 943 | struct intel_shared_dpll * |
933 | intel_crtc_to_shared_dpll(struct intel_crtc *crtc) | 944 | intel_crtc_to_shared_dpll(struct intel_crtc *crtc) |
934 | { | 945 | { |
@@ -1069,6 +1080,26 @@ static void assert_panel_unlocked(struct drm_i915_private *dev_priv, | |||
1069 | pipe_name(pipe)); | 1080 | pipe_name(pipe)); |
1070 | } | 1081 | } |
1071 | 1082 | ||
1083 | static void assert_cursor(struct drm_i915_private *dev_priv, | ||
1084 | enum pipe pipe, bool state) | ||
1085 | { | ||
1086 | struct drm_device *dev = dev_priv->dev; | ||
1087 | bool cur_state; | ||
1088 | |||
1089 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) | ||
1090 | cur_state = I915_READ(CURCNTR_IVB(pipe)) & CURSOR_MODE; | ||
1091 | else if (IS_845G(dev) || IS_I865G(dev)) | ||
1092 | cur_state = I915_READ(_CURACNTR) & CURSOR_ENABLE; | ||
1093 | else | ||
1094 | cur_state = I915_READ(CURCNTR(pipe)) & CURSOR_MODE; | ||
1095 | |||
1096 | WARN(cur_state != state, | ||
1097 | "cursor on pipe %c assertion failure (expected %s, current %s)\n", | ||
1098 | pipe_name(pipe), state_string(state), state_string(cur_state)); | ||
1099 | } | ||
1100 | #define assert_cursor_enabled(d, p) assert_cursor(d, p, true) | ||
1101 | #define assert_cursor_disabled(d, p) assert_cursor(d, p, false) | ||
1102 | |||
1072 | void assert_pipe(struct drm_i915_private *dev_priv, | 1103 | void assert_pipe(struct drm_i915_private *dev_priv, |
1073 | enum pipe pipe, bool state) | 1104 | enum pipe pipe, bool state) |
1074 | { | 1105 | { |
@@ -1323,6 +1354,26 @@ static void assert_pch_ports_disabled(struct drm_i915_private *dev_priv, | |||
1323 | assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID); | 1354 | assert_pch_hdmi_disabled(dev_priv, pipe, PCH_HDMID); |
1324 | } | 1355 | } |
1325 | 1356 | ||
1357 | static void intel_init_dpio(struct drm_device *dev) | ||
1358 | { | ||
1359 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
1360 | |||
1361 | if (!IS_VALLEYVIEW(dev)) | ||
1362 | return; | ||
1363 | |||
1364 | /* | ||
1365 | * From VLV2A0_DP_eDP_DPIO_driver_vbios_notes_10.docx - | ||
1366 | * 6. De-assert cmn_reset/side_reset. Same as VLV X0. | ||
1367 | * a. GUnit 0x2110 bit[0] set to 1 (def 0) | ||
1368 | * b. The other bits such as sfr settings / modesel may all be set | ||
1369 | * to 0. | ||
1370 | * | ||
1371 | * This should only be done on init and resume from S3 with both | ||
1372 | * PLLs disabled, or we risk losing DPIO and PLL synchronization. | ||
1373 | */ | ||
1374 | I915_WRITE(DPIO_CTL, I915_READ(DPIO_CTL) | DPIO_CMNRST); | ||
1375 | } | ||
1376 | |||
1326 | static void vlv_enable_pll(struct intel_crtc *crtc) | 1377 | static void vlv_enable_pll(struct intel_crtc *crtc) |
1327 | { | 1378 | { |
1328 | struct drm_device *dev = crtc->base.dev; | 1379 | struct drm_device *dev = crtc->base.dev; |
@@ -1429,6 +1480,20 @@ static void i9xx_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe) | |||
1429 | POSTING_READ(DPLL(pipe)); | 1480 | POSTING_READ(DPLL(pipe)); |
1430 | } | 1481 | } |
1431 | 1482 | ||
1483 | static void vlv_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe) | ||
1484 | { | ||
1485 | u32 val = 0; | ||
1486 | |||
1487 | /* Make sure the pipe isn't still relying on us */ | ||
1488 | assert_pipe_disabled(dev_priv, pipe); | ||
1489 | |||
1490 | /* Leave integrated clock source enabled */ | ||
1491 | if (pipe == PIPE_B) | ||
1492 | val = DPLL_INTEGRATED_CRI_CLK_VLV; | ||
1493 | I915_WRITE(DPLL(pipe), val); | ||
1494 | POSTING_READ(DPLL(pipe)); | ||
1495 | } | ||
1496 | |||
1432 | void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port) | 1497 | void vlv_wait_port_ready(struct drm_i915_private *dev_priv, int port) |
1433 | { | 1498 | { |
1434 | u32 port_mask; | 1499 | u32 port_mask; |
@@ -1661,7 +1726,7 @@ static void lpt_disable_pch_transcoder(struct drm_i915_private *dev_priv) | |||
1661 | * returning. | 1726 | * returning. |
1662 | */ | 1727 | */ |
1663 | static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, | 1728 | static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, |
1664 | bool pch_port) | 1729 | bool pch_port, bool dsi) |
1665 | { | 1730 | { |
1666 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, | 1731 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
1667 | pipe); | 1732 | pipe); |
@@ -1670,6 +1735,7 @@ static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, | |||
1670 | u32 val; | 1735 | u32 val; |
1671 | 1736 | ||
1672 | assert_planes_disabled(dev_priv, pipe); | 1737 | assert_planes_disabled(dev_priv, pipe); |
1738 | assert_cursor_disabled(dev_priv, pipe); | ||
1673 | assert_sprites_disabled(dev_priv, pipe); | 1739 | assert_sprites_disabled(dev_priv, pipe); |
1674 | 1740 | ||
1675 | if (HAS_PCH_LPT(dev_priv->dev)) | 1741 | if (HAS_PCH_LPT(dev_priv->dev)) |
@@ -1683,7 +1749,10 @@ static void intel_enable_pipe(struct drm_i915_private *dev_priv, enum pipe pipe, | |||
1683 | * need the check. | 1749 | * need the check. |
1684 | */ | 1750 | */ |
1685 | if (!HAS_PCH_SPLIT(dev_priv->dev)) | 1751 | if (!HAS_PCH_SPLIT(dev_priv->dev)) |
1686 | assert_pll_enabled(dev_priv, pipe); | 1752 | if (dsi) |
1753 | assert_dsi_pll_enabled(dev_priv); | ||
1754 | else | ||
1755 | assert_pll_enabled(dev_priv, pipe); | ||
1687 | else { | 1756 | else { |
1688 | if (pch_port) { | 1757 | if (pch_port) { |
1689 | /* if driving the PCH, we need FDI enabled */ | 1758 | /* if driving the PCH, we need FDI enabled */ |
@@ -1728,6 +1797,7 @@ static void intel_disable_pipe(struct drm_i915_private *dev_priv, | |||
1728 | * or we might hang the display. | 1797 | * or we might hang the display. |
1729 | */ | 1798 | */ |
1730 | assert_planes_disabled(dev_priv, pipe); | 1799 | assert_planes_disabled(dev_priv, pipe); |
1800 | assert_cursor_disabled(dev_priv, pipe); | ||
1731 | assert_sprites_disabled(dev_priv, pipe); | 1801 | assert_sprites_disabled(dev_priv, pipe); |
1732 | 1802 | ||
1733 | /* Don't disable pipe A or pipe A PLLs if needed */ | 1803 | /* Don't disable pipe A or pipe A PLLs if needed */ |
@@ -1747,63 +1817,75 @@ static void intel_disable_pipe(struct drm_i915_private *dev_priv, | |||
1747 | * Plane regs are double buffered, going from enabled->disabled needs a | 1817 | * Plane regs are double buffered, going from enabled->disabled needs a |
1748 | * trigger in order to latch. The display address reg provides this. | 1818 | * trigger in order to latch. The display address reg provides this. |
1749 | */ | 1819 | */ |
1750 | void intel_flush_display_plane(struct drm_i915_private *dev_priv, | 1820 | void intel_flush_primary_plane(struct drm_i915_private *dev_priv, |
1751 | enum plane plane) | 1821 | enum plane plane) |
1752 | { | 1822 | { |
1753 | if (dev_priv->info->gen >= 4) | 1823 | u32 reg = dev_priv->info->gen >= 4 ? DSPSURF(plane) : DSPADDR(plane); |
1754 | I915_WRITE(DSPSURF(plane), I915_READ(DSPSURF(plane))); | 1824 | |
1755 | else | 1825 | I915_WRITE(reg, I915_READ(reg)); |
1756 | I915_WRITE(DSPADDR(plane), I915_READ(DSPADDR(plane))); | 1826 | POSTING_READ(reg); |
1757 | } | 1827 | } |
1758 | 1828 | ||
1759 | /** | 1829 | /** |
1760 | * intel_enable_plane - enable a display plane on a given pipe | 1830 | * intel_enable_primary_plane - enable the primary plane on a given pipe |
1761 | * @dev_priv: i915 private structure | 1831 | * @dev_priv: i915 private structure |
1762 | * @plane: plane to enable | 1832 | * @plane: plane to enable |
1763 | * @pipe: pipe being fed | 1833 | * @pipe: pipe being fed |
1764 | * | 1834 | * |
1765 | * Enable @plane on @pipe, making sure that @pipe is running first. | 1835 | * Enable @plane on @pipe, making sure that @pipe is running first. |
1766 | */ | 1836 | */ |
1767 | static void intel_enable_plane(struct drm_i915_private *dev_priv, | 1837 | static void intel_enable_primary_plane(struct drm_i915_private *dev_priv, |
1768 | enum plane plane, enum pipe pipe) | 1838 | enum plane plane, enum pipe pipe) |
1769 | { | 1839 | { |
1840 | struct intel_crtc *intel_crtc = | ||
1841 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); | ||
1770 | int reg; | 1842 | int reg; |
1771 | u32 val; | 1843 | u32 val; |
1772 | 1844 | ||
1773 | /* If the pipe isn't enabled, we can't pump pixels and may hang */ | 1845 | /* If the pipe isn't enabled, we can't pump pixels and may hang */ |
1774 | assert_pipe_enabled(dev_priv, pipe); | 1846 | assert_pipe_enabled(dev_priv, pipe); |
1775 | 1847 | ||
1848 | WARN(intel_crtc->primary_enabled, "Primary plane already enabled\n"); | ||
1849 | |||
1850 | intel_crtc->primary_enabled = true; | ||
1851 | |||
1776 | reg = DSPCNTR(plane); | 1852 | reg = DSPCNTR(plane); |
1777 | val = I915_READ(reg); | 1853 | val = I915_READ(reg); |
1778 | if (val & DISPLAY_PLANE_ENABLE) | 1854 | if (val & DISPLAY_PLANE_ENABLE) |
1779 | return; | 1855 | return; |
1780 | 1856 | ||
1781 | I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE); | 1857 | I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE); |
1782 | intel_flush_display_plane(dev_priv, plane); | 1858 | intel_flush_primary_plane(dev_priv, plane); |
1783 | intel_wait_for_vblank(dev_priv->dev, pipe); | 1859 | intel_wait_for_vblank(dev_priv->dev, pipe); |
1784 | } | 1860 | } |
1785 | 1861 | ||
1786 | /** | 1862 | /** |
1787 | * intel_disable_plane - disable a display plane | 1863 | * intel_disable_primary_plane - disable the primary plane |
1788 | * @dev_priv: i915 private structure | 1864 | * @dev_priv: i915 private structure |
1789 | * @plane: plane to disable | 1865 | * @plane: plane to disable |
1790 | * @pipe: pipe consuming the data | 1866 | * @pipe: pipe consuming the data |
1791 | * | 1867 | * |
1792 | * Disable @plane; should be an independent operation. | 1868 | * Disable @plane; should be an independent operation. |
1793 | */ | 1869 | */ |
1794 | static void intel_disable_plane(struct drm_i915_private *dev_priv, | 1870 | static void intel_disable_primary_plane(struct drm_i915_private *dev_priv, |
1795 | enum plane plane, enum pipe pipe) | 1871 | enum plane plane, enum pipe pipe) |
1796 | { | 1872 | { |
1873 | struct intel_crtc *intel_crtc = | ||
1874 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); | ||
1797 | int reg; | 1875 | int reg; |
1798 | u32 val; | 1876 | u32 val; |
1799 | 1877 | ||
1878 | WARN(!intel_crtc->primary_enabled, "Primary plane already disabled\n"); | ||
1879 | |||
1880 | intel_crtc->primary_enabled = false; | ||
1881 | |||
1800 | reg = DSPCNTR(plane); | 1882 | reg = DSPCNTR(plane); |
1801 | val = I915_READ(reg); | 1883 | val = I915_READ(reg); |
1802 | if ((val & DISPLAY_PLANE_ENABLE) == 0) | 1884 | if ((val & DISPLAY_PLANE_ENABLE) == 0) |
1803 | return; | 1885 | return; |
1804 | 1886 | ||
1805 | I915_WRITE(reg, val & ~DISPLAY_PLANE_ENABLE); | 1887 | I915_WRITE(reg, val & ~DISPLAY_PLANE_ENABLE); |
1806 | intel_flush_display_plane(dev_priv, plane); | 1888 | intel_flush_primary_plane(dev_priv, plane); |
1807 | intel_wait_for_vblank(dev_priv->dev, pipe); | 1889 | intel_wait_for_vblank(dev_priv->dev, pipe); |
1808 | } | 1890 | } |
1809 | 1891 | ||
@@ -1839,10 +1921,7 @@ intel_pin_and_fence_fb_obj(struct drm_device *dev, | |||
1839 | alignment = 0; | 1921 | alignment = 0; |
1840 | break; | 1922 | break; |
1841 | case I915_TILING_Y: | 1923 | case I915_TILING_Y: |
1842 | /* Despite that we check this in framebuffer_init userspace can | 1924 | WARN(1, "Y tiled bo slipped through, driver bug!\n"); |
1843 | * screw us over and change the tiling after the fact. Only | ||
1844 | * pinned buffers can't change their tiling. */ | ||
1845 | DRM_DEBUG_DRIVER("Y tiled not allowed for scan out buffers\n"); | ||
1846 | return -EINVAL; | 1925 | return -EINVAL; |
1847 | default: | 1926 | default: |
1848 | BUG(); | 1927 | BUG(); |
@@ -2077,7 +2156,7 @@ static int ironlake_update_plane(struct drm_crtc *crtc, | |||
2077 | else | 2156 | else |
2078 | dspcntr &= ~DISPPLANE_TILED; | 2157 | dspcntr &= ~DISPPLANE_TILED; |
2079 | 2158 | ||
2080 | if (IS_HASWELL(dev)) | 2159 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
2081 | dspcntr &= ~DISPPLANE_TRICKLE_FEED_DISABLE; | 2160 | dspcntr &= ~DISPPLANE_TRICKLE_FEED_DISABLE; |
2082 | else | 2161 | else |
2083 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; | 2162 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
@@ -2097,7 +2176,7 @@ static int ironlake_update_plane(struct drm_crtc *crtc, | |||
2097 | I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]); | 2176 | I915_WRITE(DSPSTRIDE(plane), fb->pitches[0]); |
2098 | I915_MODIFY_DISPBASE(DSPSURF(plane), | 2177 | I915_MODIFY_DISPBASE(DSPSURF(plane), |
2099 | i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset); | 2178 | i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset); |
2100 | if (IS_HASWELL(dev)) { | 2179 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
2101 | I915_WRITE(DSPOFFSET(plane), (y << 16) | x); | 2180 | I915_WRITE(DSPOFFSET(plane), (y << 16) | x); |
2102 | } else { | 2181 | } else { |
2103 | I915_WRITE(DSPTILEOFF(plane), (y << 16) | x); | 2182 | I915_WRITE(DSPTILEOFF(plane), (y << 16) | x); |
@@ -2244,11 +2323,26 @@ intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, | |||
2244 | return ret; | 2323 | return ret; |
2245 | } | 2324 | } |
2246 | 2325 | ||
2247 | /* Update pipe size and adjust fitter if needed */ | 2326 | /* |
2327 | * Update pipe size and adjust fitter if needed: the reason for this is | ||
2328 | * that in compute_mode_changes we check the native mode (not the pfit | ||
2329 | * mode) to see if we can flip rather than do a full mode set. In the | ||
2330 | * fastboot case, we'll flip, but if we don't update the pipesrc and | ||
2331 | * pfit state, we'll end up with a big fb scanned out into the wrong | ||
2332 | * sized surface. | ||
2333 | * | ||
2334 | * To fix this properly, we need to hoist the checks up into | ||
2335 | * compute_mode_changes (or above), check the actual pfit state and | ||
2336 | * whether the platform allows pfit disable with pipe active, and only | ||
2337 | * then update the pipesrc and pfit state, even on the flip path. | ||
2338 | */ | ||
2248 | if (i915_fastboot) { | 2339 | if (i915_fastboot) { |
2340 | const struct drm_display_mode *adjusted_mode = | ||
2341 | &intel_crtc->config.adjusted_mode; | ||
2342 | |||
2249 | I915_WRITE(PIPESRC(intel_crtc->pipe), | 2343 | I915_WRITE(PIPESRC(intel_crtc->pipe), |
2250 | ((crtc->mode.hdisplay - 1) << 16) | | 2344 | ((adjusted_mode->crtc_hdisplay - 1) << 16) | |
2251 | (crtc->mode.vdisplay - 1)); | 2345 | (adjusted_mode->crtc_vdisplay - 1)); |
2252 | if (!intel_crtc->config.pch_pfit.enabled && | 2346 | if (!intel_crtc->config.pch_pfit.enabled && |
2253 | (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) || | 2347 | (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) || |
2254 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) { | 2348 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) { |
@@ -2873,6 +2967,7 @@ static void lpt_program_iclkip(struct drm_crtc *crtc) | |||
2873 | { | 2967 | { |
2874 | struct drm_device *dev = crtc->dev; | 2968 | struct drm_device *dev = crtc->dev; |
2875 | struct drm_i915_private *dev_priv = dev->dev_private; | 2969 | struct drm_i915_private *dev_priv = dev->dev_private; |
2970 | int clock = to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock; | ||
2876 | u32 divsel, phaseinc, auxdiv, phasedir = 0; | 2971 | u32 divsel, phaseinc, auxdiv, phasedir = 0; |
2877 | u32 temp; | 2972 | u32 temp; |
2878 | 2973 | ||
@@ -2890,14 +2985,14 @@ static void lpt_program_iclkip(struct drm_crtc *crtc) | |||
2890 | SBI_ICLK); | 2985 | SBI_ICLK); |
2891 | 2986 | ||
2892 | /* 20MHz is a corner case which is out of range for the 7-bit divisor */ | 2987 | /* 20MHz is a corner case which is out of range for the 7-bit divisor */ |
2893 | if (crtc->mode.clock == 20000) { | 2988 | if (clock == 20000) { |
2894 | auxdiv = 1; | 2989 | auxdiv = 1; |
2895 | divsel = 0x41; | 2990 | divsel = 0x41; |
2896 | phaseinc = 0x20; | 2991 | phaseinc = 0x20; |
2897 | } else { | 2992 | } else { |
2898 | /* The iCLK virtual clock root frequency is in MHz, | 2993 | /* The iCLK virtual clock root frequency is in MHz, |
2899 | * but the crtc->mode.clock in in KHz. To get the divisors, | 2994 | * but the adjusted_mode->crtc_clock in in KHz. To get the |
2900 | * it is necessary to divide one by another, so we | 2995 | * divisors, it is necessary to divide one by another, so we |
2901 | * convert the virtual clock precision to KHz here for higher | 2996 | * convert the virtual clock precision to KHz here for higher |
2902 | * precision. | 2997 | * precision. |
2903 | */ | 2998 | */ |
@@ -2905,7 +3000,7 @@ static void lpt_program_iclkip(struct drm_crtc *crtc) | |||
2905 | u32 iclk_pi_range = 64; | 3000 | u32 iclk_pi_range = 64; |
2906 | u32 desired_divisor, msb_divisor_value, pi_value; | 3001 | u32 desired_divisor, msb_divisor_value, pi_value; |
2907 | 3002 | ||
2908 | desired_divisor = (iclk_virtual_root_freq / crtc->mode.clock); | 3003 | desired_divisor = (iclk_virtual_root_freq / clock); |
2909 | msb_divisor_value = desired_divisor / iclk_pi_range; | 3004 | msb_divisor_value = desired_divisor / iclk_pi_range; |
2910 | pi_value = desired_divisor % iclk_pi_range; | 3005 | pi_value = desired_divisor % iclk_pi_range; |
2911 | 3006 | ||
@@ -2921,7 +3016,7 @@ static void lpt_program_iclkip(struct drm_crtc *crtc) | |||
2921 | ~SBI_SSCDIVINTPHASE_INCVAL_MASK); | 3016 | ~SBI_SSCDIVINTPHASE_INCVAL_MASK); |
2922 | 3017 | ||
2923 | DRM_DEBUG_KMS("iCLKIP clock: found settings for %dKHz refresh rate: auxdiv=%x, divsel=%x, phasedir=%x, phaseinc=%x\n", | 3018 | DRM_DEBUG_KMS("iCLKIP clock: found settings for %dKHz refresh rate: auxdiv=%x, divsel=%x, phasedir=%x, phaseinc=%x\n", |
2924 | crtc->mode.clock, | 3019 | clock, |
2925 | auxdiv, | 3020 | auxdiv, |
2926 | divsel, | 3021 | divsel, |
2927 | phasedir, | 3022 | phasedir, |
@@ -3286,6 +3381,108 @@ static void intel_disable_planes(struct drm_crtc *crtc) | |||
3286 | intel_plane_disable(&intel_plane->base); | 3381 | intel_plane_disable(&intel_plane->base); |
3287 | } | 3382 | } |
3288 | 3383 | ||
3384 | void hsw_enable_ips(struct intel_crtc *crtc) | ||
3385 | { | ||
3386 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; | ||
3387 | |||
3388 | if (!crtc->config.ips_enabled) | ||
3389 | return; | ||
3390 | |||
3391 | /* We can only enable IPS after we enable a plane and wait for a vblank. | ||
3392 | * We guarantee that the plane is enabled by calling intel_enable_ips | ||
3393 | * only after intel_enable_plane. And intel_enable_plane already waits | ||
3394 | * for a vblank, so all we need to do here is to enable the IPS bit. */ | ||
3395 | assert_plane_enabled(dev_priv, crtc->plane); | ||
3396 | if (IS_BROADWELL(crtc->base.dev)) { | ||
3397 | mutex_lock(&dev_priv->rps.hw_lock); | ||
3398 | WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0xc0000000)); | ||
3399 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
3400 | /* Quoting Art Runyan: "its not safe to expect any particular | ||
3401 | * value in IPS_CTL bit 31 after enabling IPS through the | ||
3402 | * mailbox." Therefore we need to defer waiting on the state | ||
3403 | * change. | ||
3404 | * TODO: need to fix this for state checker | ||
3405 | */ | ||
3406 | } else { | ||
3407 | I915_WRITE(IPS_CTL, IPS_ENABLE); | ||
3408 | /* The bit only becomes 1 in the next vblank, so this wait here | ||
3409 | * is essentially intel_wait_for_vblank. If we don't have this | ||
3410 | * and don't wait for vblanks until the end of crtc_enable, then | ||
3411 | * the HW state readout code will complain that the expected | ||
3412 | * IPS_CTL value is not the one we read. */ | ||
3413 | if (wait_for(I915_READ_NOTRACE(IPS_CTL) & IPS_ENABLE, 50)) | ||
3414 | DRM_ERROR("Timed out waiting for IPS enable\n"); | ||
3415 | } | ||
3416 | } | ||
3417 | |||
3418 | void hsw_disable_ips(struct intel_crtc *crtc) | ||
3419 | { | ||
3420 | struct drm_device *dev = crtc->base.dev; | ||
3421 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
3422 | |||
3423 | if (!crtc->config.ips_enabled) | ||
3424 | return; | ||
3425 | |||
3426 | assert_plane_enabled(dev_priv, crtc->plane); | ||
3427 | if (IS_BROADWELL(crtc->base.dev)) { | ||
3428 | mutex_lock(&dev_priv->rps.hw_lock); | ||
3429 | WARN_ON(sandybridge_pcode_write(dev_priv, DISPLAY_IPS_CONTROL, 0)); | ||
3430 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
3431 | } else | ||
3432 | I915_WRITE(IPS_CTL, 0); | ||
3433 | POSTING_READ(IPS_CTL); | ||
3434 | |||
3435 | /* We need to wait for a vblank before we can disable the plane. */ | ||
3436 | intel_wait_for_vblank(dev, crtc->pipe); | ||
3437 | } | ||
3438 | |||
3439 | /** Loads the palette/gamma unit for the CRTC with the prepared values */ | ||
3440 | static void intel_crtc_load_lut(struct drm_crtc *crtc) | ||
3441 | { | ||
3442 | struct drm_device *dev = crtc->dev; | ||
3443 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
3444 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
3445 | enum pipe pipe = intel_crtc->pipe; | ||
3446 | int palreg = PALETTE(pipe); | ||
3447 | int i; | ||
3448 | bool reenable_ips = false; | ||
3449 | |||
3450 | /* The clocks have to be on to load the palette. */ | ||
3451 | if (!crtc->enabled || !intel_crtc->active) | ||
3452 | return; | ||
3453 | |||
3454 | if (!HAS_PCH_SPLIT(dev_priv->dev)) { | ||
3455 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) | ||
3456 | assert_dsi_pll_enabled(dev_priv); | ||
3457 | else | ||
3458 | assert_pll_enabled(dev_priv, pipe); | ||
3459 | } | ||
3460 | |||
3461 | /* use legacy palette for Ironlake */ | ||
3462 | if (HAS_PCH_SPLIT(dev)) | ||
3463 | palreg = LGC_PALETTE(pipe); | ||
3464 | |||
3465 | /* Workaround : Do not read or write the pipe palette/gamma data while | ||
3466 | * GAMMA_MODE is configured for split gamma and IPS_CTL has IPS enabled. | ||
3467 | */ | ||
3468 | if (intel_crtc->config.ips_enabled && | ||
3469 | ((I915_READ(GAMMA_MODE(pipe)) & GAMMA_MODE_MODE_MASK) == | ||
3470 | GAMMA_MODE_MODE_SPLIT)) { | ||
3471 | hsw_disable_ips(intel_crtc); | ||
3472 | reenable_ips = true; | ||
3473 | } | ||
3474 | |||
3475 | for (i = 0; i < 256; i++) { | ||
3476 | I915_WRITE(palreg + 4 * i, | ||
3477 | (intel_crtc->lut_r[i] << 16) | | ||
3478 | (intel_crtc->lut_g[i] << 8) | | ||
3479 | intel_crtc->lut_b[i]); | ||
3480 | } | ||
3481 | |||
3482 | if (reenable_ips) | ||
3483 | hsw_enable_ips(intel_crtc); | ||
3484 | } | ||
3485 | |||
3289 | static void ironlake_crtc_enable(struct drm_crtc *crtc) | 3486 | static void ironlake_crtc_enable(struct drm_crtc *crtc) |
3290 | { | 3487 | { |
3291 | struct drm_device *dev = crtc->dev; | 3488 | struct drm_device *dev = crtc->dev; |
@@ -3305,8 +3502,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
3305 | intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); | 3502 | intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); |
3306 | intel_set_pch_fifo_underrun_reporting(dev, pipe, true); | 3503 | intel_set_pch_fifo_underrun_reporting(dev, pipe, true); |
3307 | 3504 | ||
3308 | intel_update_watermarks(dev); | ||
3309 | |||
3310 | for_each_encoder_on_crtc(dev, crtc, encoder) | 3505 | for_each_encoder_on_crtc(dev, crtc, encoder) |
3311 | if (encoder->pre_enable) | 3506 | if (encoder->pre_enable) |
3312 | encoder->pre_enable(encoder); | 3507 | encoder->pre_enable(encoder); |
@@ -3329,9 +3524,10 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc) | |||
3329 | */ | 3524 | */ |
3330 | intel_crtc_load_lut(crtc); | 3525 | intel_crtc_load_lut(crtc); |
3331 | 3526 | ||
3527 | intel_update_watermarks(crtc); | ||
3332 | intel_enable_pipe(dev_priv, pipe, | 3528 | intel_enable_pipe(dev_priv, pipe, |
3333 | intel_crtc->config.has_pch_encoder); | 3529 | intel_crtc->config.has_pch_encoder, false); |
3334 | intel_enable_plane(dev_priv, plane, pipe); | 3530 | intel_enable_primary_plane(dev_priv, plane, pipe); |
3335 | intel_enable_planes(crtc); | 3531 | intel_enable_planes(crtc); |
3336 | intel_crtc_update_cursor(crtc, true); | 3532 | intel_crtc_update_cursor(crtc, true); |
3337 | 3533 | ||
@@ -3365,34 +3561,74 @@ static bool hsw_crtc_supports_ips(struct intel_crtc *crtc) | |||
3365 | return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A; | 3561 | return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A; |
3366 | } | 3562 | } |
3367 | 3563 | ||
3368 | static void hsw_enable_ips(struct intel_crtc *crtc) | 3564 | static void haswell_crtc_enable_planes(struct drm_crtc *crtc) |
3369 | { | 3565 | { |
3370 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; | 3566 | struct drm_device *dev = crtc->dev; |
3567 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
3568 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
3569 | int pipe = intel_crtc->pipe; | ||
3570 | int plane = intel_crtc->plane; | ||
3371 | 3571 | ||
3372 | if (!crtc->config.ips_enabled) | 3572 | intel_enable_primary_plane(dev_priv, plane, pipe); |
3373 | return; | 3573 | intel_enable_planes(crtc); |
3574 | intel_crtc_update_cursor(crtc, true); | ||
3374 | 3575 | ||
3375 | /* We can only enable IPS after we enable a plane and wait for a vblank. | 3576 | hsw_enable_ips(intel_crtc); |
3376 | * We guarantee that the plane is enabled by calling intel_enable_ips | 3577 | |
3377 | * only after intel_enable_plane. And intel_enable_plane already waits | 3578 | mutex_lock(&dev->struct_mutex); |
3378 | * for a vblank, so all we need to do here is to enable the IPS bit. */ | 3579 | intel_update_fbc(dev); |
3379 | assert_plane_enabled(dev_priv, crtc->plane); | 3580 | mutex_unlock(&dev->struct_mutex); |
3380 | I915_WRITE(IPS_CTL, IPS_ENABLE); | ||
3381 | } | 3581 | } |
3382 | 3582 | ||
3383 | static void hsw_disable_ips(struct intel_crtc *crtc) | 3583 | static void haswell_crtc_disable_planes(struct drm_crtc *crtc) |
3384 | { | 3584 | { |
3385 | struct drm_device *dev = crtc->base.dev; | 3585 | struct drm_device *dev = crtc->dev; |
3386 | struct drm_i915_private *dev_priv = dev->dev_private; | 3586 | struct drm_i915_private *dev_priv = dev->dev_private; |
3587 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
3588 | int pipe = intel_crtc->pipe; | ||
3589 | int plane = intel_crtc->plane; | ||
3387 | 3590 | ||
3388 | if (!crtc->config.ips_enabled) | 3591 | intel_crtc_wait_for_pending_flips(crtc); |
3389 | return; | 3592 | drm_vblank_off(dev, pipe); |
3390 | 3593 | ||
3391 | assert_plane_enabled(dev_priv, crtc->plane); | 3594 | /* FBC must be disabled before disabling the plane on HSW. */ |
3392 | I915_WRITE(IPS_CTL, 0); | 3595 | if (dev_priv->fbc.plane == plane) |
3596 | intel_disable_fbc(dev); | ||
3393 | 3597 | ||
3394 | /* We need to wait for a vblank before we can disable the plane. */ | 3598 | hsw_disable_ips(intel_crtc); |
3395 | intel_wait_for_vblank(dev, crtc->pipe); | 3599 | |
3600 | intel_crtc_update_cursor(crtc, false); | ||
3601 | intel_disable_planes(crtc); | ||
3602 | intel_disable_primary_plane(dev_priv, plane, pipe); | ||
3603 | } | ||
3604 | |||
3605 | /* | ||
3606 | * This implements the workaround described in the "notes" section of the mode | ||
3607 | * set sequence documentation. When going from no pipes or single pipe to | ||
3608 | * multiple pipes, and planes are enabled after the pipe, we need to wait at | ||
3609 | * least 2 vblanks on the first pipe before enabling planes on the second pipe. | ||
3610 | */ | ||
3611 | static void haswell_mode_set_planes_workaround(struct intel_crtc *crtc) | ||
3612 | { | ||
3613 | struct drm_device *dev = crtc->base.dev; | ||
3614 | struct intel_crtc *crtc_it, *other_active_crtc = NULL; | ||
3615 | |||
3616 | /* We want to get the other_active_crtc only if there's only 1 other | ||
3617 | * active crtc. */ | ||
3618 | list_for_each_entry(crtc_it, &dev->mode_config.crtc_list, base.head) { | ||
3619 | if (!crtc_it->active || crtc_it == crtc) | ||
3620 | continue; | ||
3621 | |||
3622 | if (other_active_crtc) | ||
3623 | return; | ||
3624 | |||
3625 | other_active_crtc = crtc_it; | ||
3626 | } | ||
3627 | if (!other_active_crtc) | ||
3628 | return; | ||
3629 | |||
3630 | intel_wait_for_vblank(dev, other_active_crtc->pipe); | ||
3631 | intel_wait_for_vblank(dev, other_active_crtc->pipe); | ||
3396 | } | 3632 | } |
3397 | 3633 | ||
3398 | static void haswell_crtc_enable(struct drm_crtc *crtc) | 3634 | static void haswell_crtc_enable(struct drm_crtc *crtc) |
@@ -3402,7 +3638,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc) | |||
3402 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 3638 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
3403 | struct intel_encoder *encoder; | 3639 | struct intel_encoder *encoder; |
3404 | int pipe = intel_crtc->pipe; | 3640 | int pipe = intel_crtc->pipe; |
3405 | int plane = intel_crtc->plane; | ||
3406 | 3641 | ||
3407 | WARN_ON(!crtc->enabled); | 3642 | WARN_ON(!crtc->enabled); |
3408 | 3643 | ||
@@ -3415,8 +3650,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc) | |||
3415 | if (intel_crtc->config.has_pch_encoder) | 3650 | if (intel_crtc->config.has_pch_encoder) |
3416 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, true); | 3651 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, true); |
3417 | 3652 | ||
3418 | intel_update_watermarks(dev); | ||
3419 | |||
3420 | if (intel_crtc->config.has_pch_encoder) | 3653 | if (intel_crtc->config.has_pch_encoder) |
3421 | dev_priv->display.fdi_link_train(crtc); | 3654 | dev_priv->display.fdi_link_train(crtc); |
3422 | 3655 | ||
@@ -3437,23 +3670,22 @@ static void haswell_crtc_enable(struct drm_crtc *crtc) | |||
3437 | intel_ddi_set_pipe_settings(crtc); | 3670 | intel_ddi_set_pipe_settings(crtc); |
3438 | intel_ddi_enable_transcoder_func(crtc); | 3671 | intel_ddi_enable_transcoder_func(crtc); |
3439 | 3672 | ||
3673 | intel_update_watermarks(crtc); | ||
3440 | intel_enable_pipe(dev_priv, pipe, | 3674 | intel_enable_pipe(dev_priv, pipe, |
3441 | intel_crtc->config.has_pch_encoder); | 3675 | intel_crtc->config.has_pch_encoder, false); |
3442 | intel_enable_plane(dev_priv, plane, pipe); | ||
3443 | intel_enable_planes(crtc); | ||
3444 | intel_crtc_update_cursor(crtc, true); | ||
3445 | |||
3446 | hsw_enable_ips(intel_crtc); | ||
3447 | 3676 | ||
3448 | if (intel_crtc->config.has_pch_encoder) | 3677 | if (intel_crtc->config.has_pch_encoder) |
3449 | lpt_pch_enable(crtc); | 3678 | lpt_pch_enable(crtc); |
3450 | 3679 | ||
3451 | mutex_lock(&dev->struct_mutex); | 3680 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
3452 | intel_update_fbc(dev); | ||
3453 | mutex_unlock(&dev->struct_mutex); | ||
3454 | |||
3455 | for_each_encoder_on_crtc(dev, crtc, encoder) | ||
3456 | encoder->enable(encoder); | 3681 | encoder->enable(encoder); |
3682 | intel_opregion_notify_encoder(encoder, true); | ||
3683 | } | ||
3684 | |||
3685 | /* If we change the relative order between pipe/planes enabling, we need | ||
3686 | * to change the workaround. */ | ||
3687 | haswell_mode_set_planes_workaround(intel_crtc); | ||
3688 | haswell_crtc_enable_planes(crtc); | ||
3457 | 3689 | ||
3458 | /* | 3690 | /* |
3459 | * There seems to be a race in PCH platform hw (at least on some | 3691 | * There seems to be a race in PCH platform hw (at least on some |
@@ -3506,7 +3738,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
3506 | 3738 | ||
3507 | intel_crtc_update_cursor(crtc, false); | 3739 | intel_crtc_update_cursor(crtc, false); |
3508 | intel_disable_planes(crtc); | 3740 | intel_disable_planes(crtc); |
3509 | intel_disable_plane(dev_priv, plane, pipe); | 3741 | intel_disable_primary_plane(dev_priv, plane, pipe); |
3510 | 3742 | ||
3511 | if (intel_crtc->config.has_pch_encoder) | 3743 | if (intel_crtc->config.has_pch_encoder) |
3512 | intel_set_pch_fifo_underrun_reporting(dev, pipe, false); | 3744 | intel_set_pch_fifo_underrun_reporting(dev, pipe, false); |
@@ -3547,7 +3779,7 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc) | |||
3547 | } | 3779 | } |
3548 | 3780 | ||
3549 | intel_crtc->active = false; | 3781 | intel_crtc->active = false; |
3550 | intel_update_watermarks(dev); | 3782 | intel_update_watermarks(crtc); |
3551 | 3783 | ||
3552 | mutex_lock(&dev->struct_mutex); | 3784 | mutex_lock(&dev->struct_mutex); |
3553 | intel_update_fbc(dev); | 3785 | intel_update_fbc(dev); |
@@ -3561,27 +3793,17 @@ static void haswell_crtc_disable(struct drm_crtc *crtc) | |||
3561 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 3793 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
3562 | struct intel_encoder *encoder; | 3794 | struct intel_encoder *encoder; |
3563 | int pipe = intel_crtc->pipe; | 3795 | int pipe = intel_crtc->pipe; |
3564 | int plane = intel_crtc->plane; | ||
3565 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; | 3796 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
3566 | 3797 | ||
3567 | if (!intel_crtc->active) | 3798 | if (!intel_crtc->active) |
3568 | return; | 3799 | return; |
3569 | 3800 | ||
3570 | for_each_encoder_on_crtc(dev, crtc, encoder) | 3801 | haswell_crtc_disable_planes(crtc); |
3571 | encoder->disable(encoder); | ||
3572 | |||
3573 | intel_crtc_wait_for_pending_flips(crtc); | ||
3574 | drm_vblank_off(dev, pipe); | ||
3575 | 3802 | ||
3576 | /* FBC must be disabled before disabling the plane on HSW. */ | 3803 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
3577 | if (dev_priv->fbc.plane == plane) | 3804 | intel_opregion_notify_encoder(encoder, false); |
3578 | intel_disable_fbc(dev); | 3805 | encoder->disable(encoder); |
3579 | 3806 | } | |
3580 | hsw_disable_ips(intel_crtc); | ||
3581 | |||
3582 | intel_crtc_update_cursor(crtc, false); | ||
3583 | intel_disable_planes(crtc); | ||
3584 | intel_disable_plane(dev_priv, plane, pipe); | ||
3585 | 3807 | ||
3586 | if (intel_crtc->config.has_pch_encoder) | 3808 | if (intel_crtc->config.has_pch_encoder) |
3587 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, false); | 3809 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, false); |
@@ -3604,7 +3826,7 @@ static void haswell_crtc_disable(struct drm_crtc *crtc) | |||
3604 | } | 3826 | } |
3605 | 3827 | ||
3606 | intel_crtc->active = false; | 3828 | intel_crtc->active = false; |
3607 | intel_update_watermarks(dev); | 3829 | intel_update_watermarks(crtc); |
3608 | 3830 | ||
3609 | mutex_lock(&dev->struct_mutex); | 3831 | mutex_lock(&dev->struct_mutex); |
3610 | intel_update_fbc(dev); | 3832 | intel_update_fbc(dev); |
@@ -3696,6 +3918,7 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) | |||
3696 | struct intel_encoder *encoder; | 3918 | struct intel_encoder *encoder; |
3697 | int pipe = intel_crtc->pipe; | 3919 | int pipe = intel_crtc->pipe; |
3698 | int plane = intel_crtc->plane; | 3920 | int plane = intel_crtc->plane; |
3921 | bool is_dsi; | ||
3699 | 3922 | ||
3700 | WARN_ON(!crtc->enabled); | 3923 | WARN_ON(!crtc->enabled); |
3701 | 3924 | ||
@@ -3703,13 +3926,15 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) | |||
3703 | return; | 3926 | return; |
3704 | 3927 | ||
3705 | intel_crtc->active = true; | 3928 | intel_crtc->active = true; |
3706 | intel_update_watermarks(dev); | ||
3707 | 3929 | ||
3708 | for_each_encoder_on_crtc(dev, crtc, encoder) | 3930 | for_each_encoder_on_crtc(dev, crtc, encoder) |
3709 | if (encoder->pre_pll_enable) | 3931 | if (encoder->pre_pll_enable) |
3710 | encoder->pre_pll_enable(encoder); | 3932 | encoder->pre_pll_enable(encoder); |
3711 | 3933 | ||
3712 | vlv_enable_pll(intel_crtc); | 3934 | is_dsi = intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI); |
3935 | |||
3936 | if (!is_dsi) | ||
3937 | vlv_enable_pll(intel_crtc); | ||
3713 | 3938 | ||
3714 | for_each_encoder_on_crtc(dev, crtc, encoder) | 3939 | for_each_encoder_on_crtc(dev, crtc, encoder) |
3715 | if (encoder->pre_enable) | 3940 | if (encoder->pre_enable) |
@@ -3719,8 +3944,9 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc) | |||
3719 | 3944 | ||
3720 | intel_crtc_load_lut(crtc); | 3945 | intel_crtc_load_lut(crtc); |
3721 | 3946 | ||
3722 | intel_enable_pipe(dev_priv, pipe, false); | 3947 | intel_update_watermarks(crtc); |
3723 | intel_enable_plane(dev_priv, plane, pipe); | 3948 | intel_enable_pipe(dev_priv, pipe, false, is_dsi); |
3949 | intel_enable_primary_plane(dev_priv, plane, pipe); | ||
3724 | intel_enable_planes(crtc); | 3950 | intel_enable_planes(crtc); |
3725 | intel_crtc_update_cursor(crtc, true); | 3951 | intel_crtc_update_cursor(crtc, true); |
3726 | 3952 | ||
@@ -3745,7 +3971,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc) | |||
3745 | return; | 3971 | return; |
3746 | 3972 | ||
3747 | intel_crtc->active = true; | 3973 | intel_crtc->active = true; |
3748 | intel_update_watermarks(dev); | ||
3749 | 3974 | ||
3750 | for_each_encoder_on_crtc(dev, crtc, encoder) | 3975 | for_each_encoder_on_crtc(dev, crtc, encoder) |
3751 | if (encoder->pre_enable) | 3976 | if (encoder->pre_enable) |
@@ -3757,8 +3982,9 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc) | |||
3757 | 3982 | ||
3758 | intel_crtc_load_lut(crtc); | 3983 | intel_crtc_load_lut(crtc); |
3759 | 3984 | ||
3760 | intel_enable_pipe(dev_priv, pipe, false); | 3985 | intel_update_watermarks(crtc); |
3761 | intel_enable_plane(dev_priv, plane, pipe); | 3986 | intel_enable_pipe(dev_priv, pipe, false, false); |
3987 | intel_enable_primary_plane(dev_priv, plane, pipe); | ||
3762 | intel_enable_planes(crtc); | 3988 | intel_enable_planes(crtc); |
3763 | /* The fixup needs to happen before cursor is enabled */ | 3989 | /* The fixup needs to happen before cursor is enabled */ |
3764 | if (IS_G4X(dev)) | 3990 | if (IS_G4X(dev)) |
@@ -3814,7 +4040,7 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc) | |||
3814 | intel_crtc_dpms_overlay(intel_crtc, false); | 4040 | intel_crtc_dpms_overlay(intel_crtc, false); |
3815 | intel_crtc_update_cursor(crtc, false); | 4041 | intel_crtc_update_cursor(crtc, false); |
3816 | intel_disable_planes(crtc); | 4042 | intel_disable_planes(crtc); |
3817 | intel_disable_plane(dev_priv, plane, pipe); | 4043 | intel_disable_primary_plane(dev_priv, plane, pipe); |
3818 | 4044 | ||
3819 | intel_disable_pipe(dev_priv, pipe); | 4045 | intel_disable_pipe(dev_priv, pipe); |
3820 | 4046 | ||
@@ -3824,11 +4050,15 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc) | |||
3824 | if (encoder->post_disable) | 4050 | if (encoder->post_disable) |
3825 | encoder->post_disable(encoder); | 4051 | encoder->post_disable(encoder); |
3826 | 4052 | ||
3827 | i9xx_disable_pll(dev_priv, pipe); | 4053 | if (IS_VALLEYVIEW(dev) && !intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) |
4054 | vlv_disable_pll(dev_priv, pipe); | ||
4055 | else if (!IS_VALLEYVIEW(dev)) | ||
4056 | i9xx_disable_pll(dev_priv, pipe); | ||
3828 | 4057 | ||
3829 | intel_crtc->active = false; | 4058 | intel_crtc->active = false; |
4059 | intel_update_watermarks(crtc); | ||
4060 | |||
3830 | intel_update_fbc(dev); | 4061 | intel_update_fbc(dev); |
3831 | intel_update_watermarks(dev); | ||
3832 | } | 4062 | } |
3833 | 4063 | ||
3834 | static void i9xx_crtc_off(struct drm_crtc *crtc) | 4064 | static void i9xx_crtc_off(struct drm_crtc *crtc) |
@@ -3902,6 +4132,7 @@ static void intel_crtc_disable(struct drm_crtc *crtc) | |||
3902 | dev_priv->display.off(crtc); | 4132 | dev_priv->display.off(crtc); |
3903 | 4133 | ||
3904 | assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); | 4134 | assert_plane_disabled(dev->dev_private, to_intel_crtc(crtc)->plane); |
4135 | assert_cursor_disabled(dev_priv, to_intel_crtc(crtc)->pipe); | ||
3905 | assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); | 4136 | assert_pipe_disabled(dev->dev_private, to_intel_crtc(crtc)->pipe); |
3906 | 4137 | ||
3907 | if (crtc->fb) { | 4138 | if (crtc->fb) { |
@@ -4029,7 +4260,7 @@ static bool ironlake_check_fdi_lanes(struct drm_device *dev, enum pipe pipe, | |||
4029 | return false; | 4260 | return false; |
4030 | } | 4261 | } |
4031 | 4262 | ||
4032 | if (IS_HASWELL(dev)) { | 4263 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
4033 | if (pipe_config->fdi_lanes > 2) { | 4264 | if (pipe_config->fdi_lanes > 2) { |
4034 | DRM_DEBUG_KMS("only 2 lanes on haswell, required: %i lanes\n", | 4265 | DRM_DEBUG_KMS("only 2 lanes on haswell, required: %i lanes\n", |
4035 | pipe_config->fdi_lanes); | 4266 | pipe_config->fdi_lanes); |
@@ -4091,8 +4322,7 @@ retry: | |||
4091 | */ | 4322 | */ |
4092 | link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10; | 4323 | link_bw = intel_fdi_link_freq(dev) * MHz(100)/KHz(1)/10; |
4093 | 4324 | ||
4094 | fdi_dotclock = adjusted_mode->clock; | 4325 | fdi_dotclock = adjusted_mode->crtc_clock; |
4095 | fdi_dotclock /= pipe_config->pixel_multiplier; | ||
4096 | 4326 | ||
4097 | lane = ironlake_get_lanes_required(fdi_dotclock, link_bw, | 4327 | lane = ironlake_get_lanes_required(fdi_dotclock, link_bw, |
4098 | pipe_config->pipe_bpp); | 4328 | pipe_config->pipe_bpp); |
@@ -4134,13 +4364,39 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc, | |||
4134 | struct drm_device *dev = crtc->base.dev; | 4364 | struct drm_device *dev = crtc->base.dev; |
4135 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; | 4365 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
4136 | 4366 | ||
4137 | if (HAS_PCH_SPLIT(dev)) { | 4367 | /* FIXME should check pixel clock limits on all platforms */ |
4138 | /* FDI link clock is fixed at 2.7G */ | 4368 | if (INTEL_INFO(dev)->gen < 4) { |
4139 | if (pipe_config->requested_mode.clock * 3 | 4369 | struct drm_i915_private *dev_priv = dev->dev_private; |
4140 | > IRONLAKE_FDI_FREQ * 4) | 4370 | int clock_limit = |
4371 | dev_priv->display.get_display_clock_speed(dev); | ||
4372 | |||
4373 | /* | ||
4374 | * Enable pixel doubling when the dot clock | ||
4375 | * is > 90% of the (display) core speed. | ||
4376 | * | ||
4377 | * GDG double wide on either pipe, | ||
4378 | * otherwise pipe A only. | ||
4379 | */ | ||
4380 | if ((crtc->pipe == PIPE_A || IS_I915G(dev)) && | ||
4381 | adjusted_mode->crtc_clock > clock_limit * 9 / 10) { | ||
4382 | clock_limit *= 2; | ||
4383 | pipe_config->double_wide = true; | ||
4384 | } | ||
4385 | |||
4386 | if (adjusted_mode->crtc_clock > clock_limit * 9 / 10) | ||
4141 | return -EINVAL; | 4387 | return -EINVAL; |
4142 | } | 4388 | } |
4143 | 4389 | ||
4390 | /* | ||
4391 | * Pipe horizontal size must be even in: | ||
4392 | * - DVO ganged mode | ||
4393 | * - LVDS dual channel mode | ||
4394 | * - Double wide pipe | ||
4395 | */ | ||
4396 | if ((intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) && | ||
4397 | intel_is_dual_link_lvds(dev)) || pipe_config->double_wide) | ||
4398 | pipe_config->pipe_src_w &= ~1; | ||
4399 | |||
4144 | /* Cantiga+ cannot handle modes with a hsync front porch of 0. | 4400 | /* Cantiga+ cannot handle modes with a hsync front porch of 0. |
4145 | * WaPruneModeWithIncorrectHsyncOffset:ctg,elk,ilk,snb,ivb,vlv,hsw. | 4401 | * WaPruneModeWithIncorrectHsyncOffset:ctg,elk,ilk,snb,ivb,vlv,hsw. |
4146 | */ | 4402 | */ |
@@ -4304,28 +4560,6 @@ static inline bool intel_panel_use_ssc(struct drm_i915_private *dev_priv) | |||
4304 | && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE); | 4560 | && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE); |
4305 | } | 4561 | } |
4306 | 4562 | ||
4307 | static int vlv_get_refclk(struct drm_crtc *crtc) | ||
4308 | { | ||
4309 | struct drm_device *dev = crtc->dev; | ||
4310 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
4311 | int refclk = 27000; /* for DP & HDMI */ | ||
4312 | |||
4313 | return 100000; /* only one validated so far */ | ||
4314 | |||
4315 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) { | ||
4316 | refclk = 96000; | ||
4317 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { | ||
4318 | if (intel_panel_use_ssc(dev_priv)) | ||
4319 | refclk = 100000; | ||
4320 | else | ||
4321 | refclk = 96000; | ||
4322 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) { | ||
4323 | refclk = 100000; | ||
4324 | } | ||
4325 | |||
4326 | return refclk; | ||
4327 | } | ||
4328 | |||
4329 | static int i9xx_get_refclk(struct drm_crtc *crtc, int num_connectors) | 4563 | static int i9xx_get_refclk(struct drm_crtc *crtc, int num_connectors) |
4330 | { | 4564 | { |
4331 | struct drm_device *dev = crtc->dev; | 4565 | struct drm_device *dev = crtc->dev; |
@@ -4333,7 +4567,7 @@ static int i9xx_get_refclk(struct drm_crtc *crtc, int num_connectors) | |||
4333 | int refclk; | 4567 | int refclk; |
4334 | 4568 | ||
4335 | if (IS_VALLEYVIEW(dev)) { | 4569 | if (IS_VALLEYVIEW(dev)) { |
4336 | refclk = vlv_get_refclk(crtc); | 4570 | refclk = 100000; |
4337 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && | 4571 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && |
4338 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) { | 4572 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) { |
4339 | refclk = dev_priv->vbt.lvds_ssc_freq * 1000; | 4573 | refclk = dev_priv->vbt.lvds_ssc_freq * 1000; |
@@ -4391,7 +4625,8 @@ static void i9xx_update_pll_dividers(struct intel_crtc *crtc, | |||
4391 | } | 4625 | } |
4392 | } | 4626 | } |
4393 | 4627 | ||
4394 | static void vlv_pllb_recal_opamp(struct drm_i915_private *dev_priv) | 4628 | static void vlv_pllb_recal_opamp(struct drm_i915_private *dev_priv, enum pipe |
4629 | pipe) | ||
4395 | { | 4630 | { |
4396 | u32 reg_val; | 4631 | u32 reg_val; |
4397 | 4632 | ||
@@ -4399,24 +4634,24 @@ static void vlv_pllb_recal_opamp(struct drm_i915_private *dev_priv) | |||
4399 | * PLLB opamp always calibrates to max value of 0x3f, force enable it | 4634 | * PLLB opamp always calibrates to max value of 0x3f, force enable it |
4400 | * and set it to a reasonable value instead. | 4635 | * and set it to a reasonable value instead. |
4401 | */ | 4636 | */ |
4402 | reg_val = vlv_dpio_read(dev_priv, DPIO_IREF(1)); | 4637 | reg_val = vlv_dpio_read(dev_priv, pipe, DPIO_IREF(1)); |
4403 | reg_val &= 0xffffff00; | 4638 | reg_val &= 0xffffff00; |
4404 | reg_val |= 0x00000030; | 4639 | reg_val |= 0x00000030; |
4405 | vlv_dpio_write(dev_priv, DPIO_IREF(1), reg_val); | 4640 | vlv_dpio_write(dev_priv, pipe, DPIO_IREF(1), reg_val); |
4406 | 4641 | ||
4407 | reg_val = vlv_dpio_read(dev_priv, DPIO_CALIBRATION); | 4642 | reg_val = vlv_dpio_read(dev_priv, pipe, DPIO_CALIBRATION); |
4408 | reg_val &= 0x8cffffff; | 4643 | reg_val &= 0x8cffffff; |
4409 | reg_val = 0x8c000000; | 4644 | reg_val = 0x8c000000; |
4410 | vlv_dpio_write(dev_priv, DPIO_CALIBRATION, reg_val); | 4645 | vlv_dpio_write(dev_priv, pipe, DPIO_CALIBRATION, reg_val); |
4411 | 4646 | ||
4412 | reg_val = vlv_dpio_read(dev_priv, DPIO_IREF(1)); | 4647 | reg_val = vlv_dpio_read(dev_priv, pipe, DPIO_IREF(1)); |
4413 | reg_val &= 0xffffff00; | 4648 | reg_val &= 0xffffff00; |
4414 | vlv_dpio_write(dev_priv, DPIO_IREF(1), reg_val); | 4649 | vlv_dpio_write(dev_priv, pipe, DPIO_IREF(1), reg_val); |
4415 | 4650 | ||
4416 | reg_val = vlv_dpio_read(dev_priv, DPIO_CALIBRATION); | 4651 | reg_val = vlv_dpio_read(dev_priv, pipe, DPIO_CALIBRATION); |
4417 | reg_val &= 0x00ffffff; | 4652 | reg_val &= 0x00ffffff; |
4418 | reg_val |= 0xb0000000; | 4653 | reg_val |= 0xb0000000; |
4419 | vlv_dpio_write(dev_priv, DPIO_CALIBRATION, reg_val); | 4654 | vlv_dpio_write(dev_priv, pipe, DPIO_CALIBRATION, reg_val); |
4420 | } | 4655 | } |
4421 | 4656 | ||
4422 | static void intel_pch_transcoder_set_m_n(struct intel_crtc *crtc, | 4657 | static void intel_pch_transcoder_set_m_n(struct intel_crtc *crtc, |
@@ -4482,18 +4717,18 @@ static void vlv_update_pll(struct intel_crtc *crtc) | |||
4482 | 4717 | ||
4483 | /* PLL B needs special handling */ | 4718 | /* PLL B needs special handling */ |
4484 | if (pipe) | 4719 | if (pipe) |
4485 | vlv_pllb_recal_opamp(dev_priv); | 4720 | vlv_pllb_recal_opamp(dev_priv, pipe); |
4486 | 4721 | ||
4487 | /* Set up Tx target for periodic Rcomp update */ | 4722 | /* Set up Tx target for periodic Rcomp update */ |
4488 | vlv_dpio_write(dev_priv, DPIO_IREF_BCAST, 0x0100000f); | 4723 | vlv_dpio_write(dev_priv, pipe, DPIO_IREF_BCAST, 0x0100000f); |
4489 | 4724 | ||
4490 | /* Disable target IRef on PLL */ | 4725 | /* Disable target IRef on PLL */ |
4491 | reg_val = vlv_dpio_read(dev_priv, DPIO_IREF_CTL(pipe)); | 4726 | reg_val = vlv_dpio_read(dev_priv, pipe, DPIO_IREF_CTL(pipe)); |
4492 | reg_val &= 0x00ffffff; | 4727 | reg_val &= 0x00ffffff; |
4493 | vlv_dpio_write(dev_priv, DPIO_IREF_CTL(pipe), reg_val); | 4728 | vlv_dpio_write(dev_priv, pipe, DPIO_IREF_CTL(pipe), reg_val); |
4494 | 4729 | ||
4495 | /* Disable fast lock */ | 4730 | /* Disable fast lock */ |
4496 | vlv_dpio_write(dev_priv, DPIO_FASTCLK_DISABLE, 0x610); | 4731 | vlv_dpio_write(dev_priv, pipe, DPIO_FASTCLK_DISABLE, 0x610); |
4497 | 4732 | ||
4498 | /* Set idtafcrecal before PLL is enabled */ | 4733 | /* Set idtafcrecal before PLL is enabled */ |
4499 | mdiv = ((bestm1 << DPIO_M1DIV_SHIFT) | (bestm2 & DPIO_M2DIV_MASK)); | 4734 | mdiv = ((bestm1 << DPIO_M1DIV_SHIFT) | (bestm2 & DPIO_M2DIV_MASK)); |
@@ -4507,55 +4742,55 @@ static void vlv_update_pll(struct intel_crtc *crtc) | |||
4507 | * Note: don't use the DAC post divider as it seems unstable. | 4742 | * Note: don't use the DAC post divider as it seems unstable. |
4508 | */ | 4743 | */ |
4509 | mdiv |= (DPIO_POST_DIV_HDMIDP << DPIO_POST_DIV_SHIFT); | 4744 | mdiv |= (DPIO_POST_DIV_HDMIDP << DPIO_POST_DIV_SHIFT); |
4510 | vlv_dpio_write(dev_priv, DPIO_DIV(pipe), mdiv); | 4745 | vlv_dpio_write(dev_priv, pipe, DPIO_DIV(pipe), mdiv); |
4511 | 4746 | ||
4512 | mdiv |= DPIO_ENABLE_CALIBRATION; | 4747 | mdiv |= DPIO_ENABLE_CALIBRATION; |
4513 | vlv_dpio_write(dev_priv, DPIO_DIV(pipe), mdiv); | 4748 | vlv_dpio_write(dev_priv, pipe, DPIO_DIV(pipe), mdiv); |
4514 | 4749 | ||
4515 | /* Set HBR and RBR LPF coefficients */ | 4750 | /* Set HBR and RBR LPF coefficients */ |
4516 | if (crtc->config.port_clock == 162000 || | 4751 | if (crtc->config.port_clock == 162000 || |
4517 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_ANALOG) || | 4752 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_ANALOG) || |
4518 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI)) | 4753 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI)) |
4519 | vlv_dpio_write(dev_priv, DPIO_LPF_COEFF(pipe), | 4754 | vlv_dpio_write(dev_priv, pipe, DPIO_LPF_COEFF(pipe), |
4520 | 0x009f0003); | 4755 | 0x009f0003); |
4521 | else | 4756 | else |
4522 | vlv_dpio_write(dev_priv, DPIO_LPF_COEFF(pipe), | 4757 | vlv_dpio_write(dev_priv, pipe, DPIO_LPF_COEFF(pipe), |
4523 | 0x00d0000f); | 4758 | 0x00d0000f); |
4524 | 4759 | ||
4525 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP) || | 4760 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP) || |
4526 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT)) { | 4761 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT)) { |
4527 | /* Use SSC source */ | 4762 | /* Use SSC source */ |
4528 | if (!pipe) | 4763 | if (!pipe) |
4529 | vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe), | 4764 | vlv_dpio_write(dev_priv, pipe, DPIO_REFSFR(pipe), |
4530 | 0x0df40000); | 4765 | 0x0df40000); |
4531 | else | 4766 | else |
4532 | vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe), | 4767 | vlv_dpio_write(dev_priv, pipe, DPIO_REFSFR(pipe), |
4533 | 0x0df70000); | 4768 | 0x0df70000); |
4534 | } else { /* HDMI or VGA */ | 4769 | } else { /* HDMI or VGA */ |
4535 | /* Use bend source */ | 4770 | /* Use bend source */ |
4536 | if (!pipe) | 4771 | if (!pipe) |
4537 | vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe), | 4772 | vlv_dpio_write(dev_priv, pipe, DPIO_REFSFR(pipe), |
4538 | 0x0df70000); | 4773 | 0x0df70000); |
4539 | else | 4774 | else |
4540 | vlv_dpio_write(dev_priv, DPIO_REFSFR(pipe), | 4775 | vlv_dpio_write(dev_priv, pipe, DPIO_REFSFR(pipe), |
4541 | 0x0df40000); | 4776 | 0x0df40000); |
4542 | } | 4777 | } |
4543 | 4778 | ||
4544 | coreclk = vlv_dpio_read(dev_priv, DPIO_CORE_CLK(pipe)); | 4779 | coreclk = vlv_dpio_read(dev_priv, pipe, DPIO_CORE_CLK(pipe)); |
4545 | coreclk = (coreclk & 0x0000ff00) | 0x01c00000; | 4780 | coreclk = (coreclk & 0x0000ff00) | 0x01c00000; |
4546 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT) || | 4781 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT) || |
4547 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP)) | 4782 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP)) |
4548 | coreclk |= 0x01000000; | 4783 | coreclk |= 0x01000000; |
4549 | vlv_dpio_write(dev_priv, DPIO_CORE_CLK(pipe), coreclk); | 4784 | vlv_dpio_write(dev_priv, pipe, DPIO_CORE_CLK(pipe), coreclk); |
4550 | 4785 | ||
4551 | vlv_dpio_write(dev_priv, DPIO_PLL_CML(pipe), 0x87871000); | 4786 | vlv_dpio_write(dev_priv, pipe, DPIO_PLL_CML(pipe), 0x87871000); |
4552 | 4787 | ||
4553 | /* Enable DPIO clock input */ | 4788 | /* Enable DPIO clock input */ |
4554 | dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV | | 4789 | dpll = DPLL_EXT_BUFFER_ENABLE_VLV | DPLL_REFA_CLK_ENABLE_VLV | |
4555 | DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV; | 4790 | DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV; |
4556 | if (pipe) | 4791 | /* We should never disable this, set it here for state tracking */ |
4792 | if (pipe == PIPE_B) | ||
4557 | dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; | 4793 | dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; |
4558 | |||
4559 | dpll |= DPLL_VCO_ENABLE; | 4794 | dpll |= DPLL_VCO_ENABLE; |
4560 | crtc->config.dpll_hw_state.dpll = dpll; | 4795 | crtc->config.dpll_hw_state.dpll = dpll; |
4561 | 4796 | ||
@@ -4693,7 +4928,6 @@ static void intel_set_pipe_timings(struct intel_crtc *intel_crtc) | |||
4693 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; | 4928 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
4694 | struct drm_display_mode *adjusted_mode = | 4929 | struct drm_display_mode *adjusted_mode = |
4695 | &intel_crtc->config.adjusted_mode; | 4930 | &intel_crtc->config.adjusted_mode; |
4696 | struct drm_display_mode *mode = &intel_crtc->config.requested_mode; | ||
4697 | uint32_t vsyncshift, crtc_vtotal, crtc_vblank_end; | 4931 | uint32_t vsyncshift, crtc_vtotal, crtc_vblank_end; |
4698 | 4932 | ||
4699 | /* We need to be careful not to changed the adjusted mode, for otherwise | 4933 | /* We need to be careful not to changed the adjusted mode, for otherwise |
@@ -4746,7 +4980,8 @@ static void intel_set_pipe_timings(struct intel_crtc *intel_crtc) | |||
4746 | * always be the user's requested size. | 4980 | * always be the user's requested size. |
4747 | */ | 4981 | */ |
4748 | I915_WRITE(PIPESRC(pipe), | 4982 | I915_WRITE(PIPESRC(pipe), |
4749 | ((mode->hdisplay - 1) << 16) | (mode->vdisplay - 1)); | 4983 | ((intel_crtc->config.pipe_src_w - 1) << 16) | |
4984 | (intel_crtc->config.pipe_src_h - 1)); | ||
4750 | } | 4985 | } |
4751 | 4986 | ||
4752 | static void intel_get_pipe_timings(struct intel_crtc *crtc, | 4987 | static void intel_get_pipe_timings(struct intel_crtc *crtc, |
@@ -4784,8 +5019,11 @@ static void intel_get_pipe_timings(struct intel_crtc *crtc, | |||
4784 | } | 5019 | } |
4785 | 5020 | ||
4786 | tmp = I915_READ(PIPESRC(crtc->pipe)); | 5021 | tmp = I915_READ(PIPESRC(crtc->pipe)); |
4787 | pipe_config->requested_mode.vdisplay = (tmp & 0xffff) + 1; | 5022 | pipe_config->pipe_src_h = (tmp & 0xffff) + 1; |
4788 | pipe_config->requested_mode.hdisplay = ((tmp >> 16) & 0xffff) + 1; | 5023 | pipe_config->pipe_src_w = ((tmp >> 16) & 0xffff) + 1; |
5024 | |||
5025 | pipe_config->requested_mode.vdisplay = pipe_config->pipe_src_h; | ||
5026 | pipe_config->requested_mode.hdisplay = pipe_config->pipe_src_w; | ||
4789 | } | 5027 | } |
4790 | 5028 | ||
4791 | static void intel_crtc_mode_from_pipe_config(struct intel_crtc *intel_crtc, | 5029 | static void intel_crtc_mode_from_pipe_config(struct intel_crtc *intel_crtc, |
@@ -4805,7 +5043,7 @@ static void intel_crtc_mode_from_pipe_config(struct intel_crtc *intel_crtc, | |||
4805 | 5043 | ||
4806 | crtc->mode.flags = pipe_config->adjusted_mode.flags; | 5044 | crtc->mode.flags = pipe_config->adjusted_mode.flags; |
4807 | 5045 | ||
4808 | crtc->mode.clock = pipe_config->adjusted_mode.clock; | 5046 | crtc->mode.clock = pipe_config->adjusted_mode.crtc_clock; |
4809 | crtc->mode.flags |= pipe_config->adjusted_mode.flags; | 5047 | crtc->mode.flags |= pipe_config->adjusted_mode.flags; |
4810 | } | 5048 | } |
4811 | 5049 | ||
@@ -4821,17 +5059,8 @@ static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc) | |||
4821 | I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE) | 5059 | I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE) |
4822 | pipeconf |= PIPECONF_ENABLE; | 5060 | pipeconf |= PIPECONF_ENABLE; |
4823 | 5061 | ||
4824 | if (intel_crtc->pipe == 0 && INTEL_INFO(dev)->gen < 4) { | 5062 | if (intel_crtc->config.double_wide) |
4825 | /* Enable pixel doubling when the dot clock is > 90% of the (display) | 5063 | pipeconf |= PIPECONF_DOUBLE_WIDE; |
4826 | * core speed. | ||
4827 | * | ||
4828 | * XXX: No double-wide on 915GM pipe B. Is that the only reason for the | ||
4829 | * pipe == 0 check? | ||
4830 | */ | ||
4831 | if (intel_crtc->config.requested_mode.clock > | ||
4832 | dev_priv->display.get_display_clock_speed(dev) * 9 / 10) | ||
4833 | pipeconf |= PIPECONF_DOUBLE_WIDE; | ||
4834 | } | ||
4835 | 5064 | ||
4836 | /* only g4x and later have fancy bpc/dither controls */ | 5065 | /* only g4x and later have fancy bpc/dither controls */ |
4837 | if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) { | 5066 | if (IS_G4X(dev) || IS_VALLEYVIEW(dev)) { |
@@ -4885,14 +5114,13 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4885 | struct drm_device *dev = crtc->dev; | 5114 | struct drm_device *dev = crtc->dev; |
4886 | struct drm_i915_private *dev_priv = dev->dev_private; | 5115 | struct drm_i915_private *dev_priv = dev->dev_private; |
4887 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 5116 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4888 | struct drm_display_mode *mode = &intel_crtc->config.requested_mode; | ||
4889 | int pipe = intel_crtc->pipe; | 5117 | int pipe = intel_crtc->pipe; |
4890 | int plane = intel_crtc->plane; | 5118 | int plane = intel_crtc->plane; |
4891 | int refclk, num_connectors = 0; | 5119 | int refclk, num_connectors = 0; |
4892 | intel_clock_t clock, reduced_clock; | 5120 | intel_clock_t clock, reduced_clock; |
4893 | u32 dspcntr; | 5121 | u32 dspcntr; |
4894 | bool ok, has_reduced_clock = false; | 5122 | bool ok, has_reduced_clock = false; |
4895 | bool is_lvds = false; | 5123 | bool is_lvds = false, is_dsi = false; |
4896 | struct intel_encoder *encoder; | 5124 | struct intel_encoder *encoder; |
4897 | const intel_limit_t *limit; | 5125 | const intel_limit_t *limit; |
4898 | int ret; | 5126 | int ret; |
@@ -4902,42 +5130,49 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4902 | case INTEL_OUTPUT_LVDS: | 5130 | case INTEL_OUTPUT_LVDS: |
4903 | is_lvds = true; | 5131 | is_lvds = true; |
4904 | break; | 5132 | break; |
5133 | case INTEL_OUTPUT_DSI: | ||
5134 | is_dsi = true; | ||
5135 | break; | ||
4905 | } | 5136 | } |
4906 | 5137 | ||
4907 | num_connectors++; | 5138 | num_connectors++; |
4908 | } | 5139 | } |
4909 | 5140 | ||
4910 | refclk = i9xx_get_refclk(crtc, num_connectors); | 5141 | if (is_dsi) |
5142 | goto skip_dpll; | ||
4911 | 5143 | ||
4912 | /* | 5144 | if (!intel_crtc->config.clock_set) { |
4913 | * Returns a set of divisors for the desired target clock with the given | 5145 | refclk = i9xx_get_refclk(crtc, num_connectors); |
4914 | * refclk, or FALSE. The returned values represent the clock equation: | ||
4915 | * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2. | ||
4916 | */ | ||
4917 | limit = intel_limit(crtc, refclk); | ||
4918 | ok = dev_priv->display.find_dpll(limit, crtc, | ||
4919 | intel_crtc->config.port_clock, | ||
4920 | refclk, NULL, &clock); | ||
4921 | if (!ok && !intel_crtc->config.clock_set) { | ||
4922 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); | ||
4923 | return -EINVAL; | ||
4924 | } | ||
4925 | 5146 | ||
4926 | if (is_lvds && dev_priv->lvds_downclock_avail) { | ||
4927 | /* | 5147 | /* |
4928 | * Ensure we match the reduced clock's P to the target clock. | 5148 | * Returns a set of divisors for the desired target clock with |
4929 | * If the clocks don't match, we can't switch the display clock | 5149 | * the given refclk, or FALSE. The returned values represent |
4930 | * by using the FP0/FP1. In such case we will disable the LVDS | 5150 | * the clock equation: reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + |
4931 | * downclock feature. | 5151 | * 2) / p1 / p2. |
4932 | */ | 5152 | */ |
4933 | has_reduced_clock = | 5153 | limit = intel_limit(crtc, refclk); |
4934 | dev_priv->display.find_dpll(limit, crtc, | 5154 | ok = dev_priv->display.find_dpll(limit, crtc, |
4935 | dev_priv->lvds_downclock, | 5155 | intel_crtc->config.port_clock, |
4936 | refclk, &clock, | 5156 | refclk, NULL, &clock); |
4937 | &reduced_clock); | 5157 | if (!ok) { |
4938 | } | 5158 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); |
4939 | /* Compat-code for transition, will disappear. */ | 5159 | return -EINVAL; |
4940 | if (!intel_crtc->config.clock_set) { | 5160 | } |
5161 | |||
5162 | if (is_lvds && dev_priv->lvds_downclock_avail) { | ||
5163 | /* | ||
5164 | * Ensure we match the reduced clock's P to the target | ||
5165 | * clock. If the clocks don't match, we can't switch | ||
5166 | * the display clock by using the FP0/FP1. In such case | ||
5167 | * we will disable the LVDS downclock feature. | ||
5168 | */ | ||
5169 | has_reduced_clock = | ||
5170 | dev_priv->display.find_dpll(limit, crtc, | ||
5171 | dev_priv->lvds_downclock, | ||
5172 | refclk, &clock, | ||
5173 | &reduced_clock); | ||
5174 | } | ||
5175 | /* Compat-code for transition, will disappear. */ | ||
4941 | intel_crtc->config.dpll.n = clock.n; | 5176 | intel_crtc->config.dpll.n = clock.n; |
4942 | intel_crtc->config.dpll.m1 = clock.m1; | 5177 | intel_crtc->config.dpll.m1 = clock.m1; |
4943 | intel_crtc->config.dpll.m2 = clock.m2; | 5178 | intel_crtc->config.dpll.m2 = clock.m2; |
@@ -4945,17 +5180,19 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4945 | intel_crtc->config.dpll.p2 = clock.p2; | 5180 | intel_crtc->config.dpll.p2 = clock.p2; |
4946 | } | 5181 | } |
4947 | 5182 | ||
4948 | if (IS_GEN2(dev)) | 5183 | if (IS_GEN2(dev)) { |
4949 | i8xx_update_pll(intel_crtc, | 5184 | i8xx_update_pll(intel_crtc, |
4950 | has_reduced_clock ? &reduced_clock : NULL, | 5185 | has_reduced_clock ? &reduced_clock : NULL, |
4951 | num_connectors); | 5186 | num_connectors); |
4952 | else if (IS_VALLEYVIEW(dev)) | 5187 | } else if (IS_VALLEYVIEW(dev)) { |
4953 | vlv_update_pll(intel_crtc); | 5188 | vlv_update_pll(intel_crtc); |
4954 | else | 5189 | } else { |
4955 | i9xx_update_pll(intel_crtc, | 5190 | i9xx_update_pll(intel_crtc, |
4956 | has_reduced_clock ? &reduced_clock : NULL, | 5191 | has_reduced_clock ? &reduced_clock : NULL, |
4957 | num_connectors); | 5192 | num_connectors); |
5193 | } | ||
4958 | 5194 | ||
5195 | skip_dpll: | ||
4959 | /* Set up the display plane register */ | 5196 | /* Set up the display plane register */ |
4960 | dspcntr = DISPPLANE_GAMMA_ENABLE; | 5197 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
4961 | 5198 | ||
@@ -4972,8 +5209,8 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4972 | * which should always be the user's requested size. | 5209 | * which should always be the user's requested size. |
4973 | */ | 5210 | */ |
4974 | I915_WRITE(DSPSIZE(plane), | 5211 | I915_WRITE(DSPSIZE(plane), |
4975 | ((mode->vdisplay - 1) << 16) | | 5212 | ((intel_crtc->config.pipe_src_h - 1) << 16) | |
4976 | (mode->hdisplay - 1)); | 5213 | (intel_crtc->config.pipe_src_w - 1)); |
4977 | I915_WRITE(DSPPOS(plane), 0); | 5214 | I915_WRITE(DSPPOS(plane), 0); |
4978 | 5215 | ||
4979 | i9xx_set_pipeconf(intel_crtc); | 5216 | i9xx_set_pipeconf(intel_crtc); |
@@ -4983,8 +5220,6 @@ static int i9xx_crtc_mode_set(struct drm_crtc *crtc, | |||
4983 | 5220 | ||
4984 | ret = intel_pipe_set_base(crtc, x, y, fb); | 5221 | ret = intel_pipe_set_base(crtc, x, y, fb); |
4985 | 5222 | ||
4986 | intel_update_watermarks(dev); | ||
4987 | |||
4988 | return ret; | 5223 | return ret; |
4989 | } | 5224 | } |
4990 | 5225 | ||
@@ -5015,6 +5250,32 @@ static void i9xx_get_pfit_config(struct intel_crtc *crtc, | |||
5015 | I915_READ(LVDS) & LVDS_BORDER_ENABLE; | 5250 | I915_READ(LVDS) & LVDS_BORDER_ENABLE; |
5016 | } | 5251 | } |
5017 | 5252 | ||
5253 | static void vlv_crtc_clock_get(struct intel_crtc *crtc, | ||
5254 | struct intel_crtc_config *pipe_config) | ||
5255 | { | ||
5256 | struct drm_device *dev = crtc->base.dev; | ||
5257 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5258 | int pipe = pipe_config->cpu_transcoder; | ||
5259 | intel_clock_t clock; | ||
5260 | u32 mdiv; | ||
5261 | int refclk = 100000; | ||
5262 | |||
5263 | mutex_lock(&dev_priv->dpio_lock); | ||
5264 | mdiv = vlv_dpio_read(dev_priv, pipe, DPIO_DIV(pipe)); | ||
5265 | mutex_unlock(&dev_priv->dpio_lock); | ||
5266 | |||
5267 | clock.m1 = (mdiv >> DPIO_M1DIV_SHIFT) & 7; | ||
5268 | clock.m2 = mdiv & DPIO_M2DIV_MASK; | ||
5269 | clock.n = (mdiv >> DPIO_N_SHIFT) & 0xf; | ||
5270 | clock.p1 = (mdiv >> DPIO_P1_SHIFT) & 7; | ||
5271 | clock.p2 = (mdiv >> DPIO_P2_SHIFT) & 0x1f; | ||
5272 | |||
5273 | vlv_clock(refclk, &clock); | ||
5274 | |||
5275 | /* clock.dot is the fast clock */ | ||
5276 | pipe_config->port_clock = clock.dot / 5; | ||
5277 | } | ||
5278 | |||
5018 | static bool i9xx_get_pipe_config(struct intel_crtc *crtc, | 5279 | static bool i9xx_get_pipe_config(struct intel_crtc *crtc, |
5019 | struct intel_crtc_config *pipe_config) | 5280 | struct intel_crtc_config *pipe_config) |
5020 | { | 5281 | { |
@@ -5045,6 +5306,9 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc, | |||
5045 | } | 5306 | } |
5046 | } | 5307 | } |
5047 | 5308 | ||
5309 | if (INTEL_INFO(dev)->gen < 4) | ||
5310 | pipe_config->double_wide = tmp & PIPECONF_DOUBLE_WIDE; | ||
5311 | |||
5048 | intel_get_pipe_timings(crtc, pipe_config); | 5312 | intel_get_pipe_timings(crtc, pipe_config); |
5049 | 5313 | ||
5050 | i9xx_get_pfit_config(crtc, pipe_config); | 5314 | i9xx_get_pfit_config(crtc, pipe_config); |
@@ -5077,6 +5341,11 @@ static bool i9xx_get_pipe_config(struct intel_crtc *crtc, | |||
5077 | DPLL_PORTB_READY_MASK); | 5341 | DPLL_PORTB_READY_MASK); |
5078 | } | 5342 | } |
5079 | 5343 | ||
5344 | if (IS_VALLEYVIEW(dev)) | ||
5345 | vlv_crtc_clock_get(crtc, pipe_config); | ||
5346 | else | ||
5347 | i9xx_crtc_clock_get(crtc, pipe_config); | ||
5348 | |||
5080 | return true; | 5349 | return true; |
5081 | } | 5350 | } |
5082 | 5351 | ||
@@ -5565,14 +5834,16 @@ static void intel_set_pipe_csc(struct drm_crtc *crtc) | |||
5565 | 5834 | ||
5566 | static void haswell_set_pipeconf(struct drm_crtc *crtc) | 5835 | static void haswell_set_pipeconf(struct drm_crtc *crtc) |
5567 | { | 5836 | { |
5568 | struct drm_i915_private *dev_priv = crtc->dev->dev_private; | 5837 | struct drm_device *dev = crtc->dev; |
5838 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
5569 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 5839 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
5840 | enum pipe pipe = intel_crtc->pipe; | ||
5570 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; | 5841 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
5571 | uint32_t val; | 5842 | uint32_t val; |
5572 | 5843 | ||
5573 | val = 0; | 5844 | val = 0; |
5574 | 5845 | ||
5575 | if (intel_crtc->config.dither) | 5846 | if (IS_HASWELL(dev) && intel_crtc->config.dither) |
5576 | val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP); | 5847 | val |= (PIPECONF_DITHER_EN | PIPECONF_DITHER_TYPE_SP); |
5577 | 5848 | ||
5578 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) | 5849 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) |
@@ -5585,6 +5856,33 @@ static void haswell_set_pipeconf(struct drm_crtc *crtc) | |||
5585 | 5856 | ||
5586 | I915_WRITE(GAMMA_MODE(intel_crtc->pipe), GAMMA_MODE_MODE_8BIT); | 5857 | I915_WRITE(GAMMA_MODE(intel_crtc->pipe), GAMMA_MODE_MODE_8BIT); |
5587 | POSTING_READ(GAMMA_MODE(intel_crtc->pipe)); | 5858 | POSTING_READ(GAMMA_MODE(intel_crtc->pipe)); |
5859 | |||
5860 | if (IS_BROADWELL(dev)) { | ||
5861 | val = 0; | ||
5862 | |||
5863 | switch (intel_crtc->config.pipe_bpp) { | ||
5864 | case 18: | ||
5865 | val |= PIPEMISC_DITHER_6_BPC; | ||
5866 | break; | ||
5867 | case 24: | ||
5868 | val |= PIPEMISC_DITHER_8_BPC; | ||
5869 | break; | ||
5870 | case 30: | ||
5871 | val |= PIPEMISC_DITHER_10_BPC; | ||
5872 | break; | ||
5873 | case 36: | ||
5874 | val |= PIPEMISC_DITHER_12_BPC; | ||
5875 | break; | ||
5876 | default: | ||
5877 | /* Case prevented by pipe_config_set_bpp. */ | ||
5878 | BUG(); | ||
5879 | } | ||
5880 | |||
5881 | if (intel_crtc->config.dither) | ||
5882 | val |= PIPEMISC_DITHER_ENABLE | PIPEMISC_DITHER_TYPE_SP; | ||
5883 | |||
5884 | I915_WRITE(PIPEMISC(pipe), val); | ||
5885 | } | ||
5588 | } | 5886 | } |
5589 | 5887 | ||
5590 | static bool ironlake_compute_clocks(struct drm_crtc *crtc, | 5888 | static bool ironlake_compute_clocks(struct drm_crtc *crtc, |
@@ -5819,11 +6117,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
5819 | else | 6117 | else |
5820 | intel_crtc->lowfreq_avail = false; | 6118 | intel_crtc->lowfreq_avail = false; |
5821 | 6119 | ||
5822 | if (intel_crtc->config.has_pch_encoder) { | ||
5823 | pll = intel_crtc_to_shared_dpll(intel_crtc); | ||
5824 | |||
5825 | } | ||
5826 | |||
5827 | intel_set_pipe_timings(intel_crtc); | 6120 | intel_set_pipe_timings(intel_crtc); |
5828 | 6121 | ||
5829 | if (intel_crtc->config.has_pch_encoder) { | 6122 | if (intel_crtc->config.has_pch_encoder) { |
@@ -5839,25 +6132,67 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
5839 | 6132 | ||
5840 | ret = intel_pipe_set_base(crtc, x, y, fb); | 6133 | ret = intel_pipe_set_base(crtc, x, y, fb); |
5841 | 6134 | ||
5842 | intel_update_watermarks(dev); | ||
5843 | |||
5844 | return ret; | 6135 | return ret; |
5845 | } | 6136 | } |
5846 | 6137 | ||
5847 | static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc, | 6138 | static void intel_pch_transcoder_get_m_n(struct intel_crtc *crtc, |
5848 | struct intel_crtc_config *pipe_config) | 6139 | struct intel_link_m_n *m_n) |
5849 | { | 6140 | { |
5850 | struct drm_device *dev = crtc->base.dev; | 6141 | struct drm_device *dev = crtc->base.dev; |
5851 | struct drm_i915_private *dev_priv = dev->dev_private; | 6142 | struct drm_i915_private *dev_priv = dev->dev_private; |
5852 | enum transcoder transcoder = pipe_config->cpu_transcoder; | 6143 | enum pipe pipe = crtc->pipe; |
5853 | 6144 | ||
5854 | pipe_config->fdi_m_n.link_m = I915_READ(PIPE_LINK_M1(transcoder)); | 6145 | m_n->link_m = I915_READ(PCH_TRANS_LINK_M1(pipe)); |
5855 | pipe_config->fdi_m_n.link_n = I915_READ(PIPE_LINK_N1(transcoder)); | 6146 | m_n->link_n = I915_READ(PCH_TRANS_LINK_N1(pipe)); |
5856 | pipe_config->fdi_m_n.gmch_m = I915_READ(PIPE_DATA_M1(transcoder)) | 6147 | m_n->gmch_m = I915_READ(PCH_TRANS_DATA_M1(pipe)) |
5857 | & ~TU_SIZE_MASK; | 6148 | & ~TU_SIZE_MASK; |
5858 | pipe_config->fdi_m_n.gmch_n = I915_READ(PIPE_DATA_N1(transcoder)); | 6149 | m_n->gmch_n = I915_READ(PCH_TRANS_DATA_N1(pipe)); |
5859 | pipe_config->fdi_m_n.tu = ((I915_READ(PIPE_DATA_M1(transcoder)) | 6150 | m_n->tu = ((I915_READ(PCH_TRANS_DATA_M1(pipe)) |
5860 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; | 6151 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
6152 | } | ||
6153 | |||
6154 | static void intel_cpu_transcoder_get_m_n(struct intel_crtc *crtc, | ||
6155 | enum transcoder transcoder, | ||
6156 | struct intel_link_m_n *m_n) | ||
6157 | { | ||
6158 | struct drm_device *dev = crtc->base.dev; | ||
6159 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
6160 | enum pipe pipe = crtc->pipe; | ||
6161 | |||
6162 | if (INTEL_INFO(dev)->gen >= 5) { | ||
6163 | m_n->link_m = I915_READ(PIPE_LINK_M1(transcoder)); | ||
6164 | m_n->link_n = I915_READ(PIPE_LINK_N1(transcoder)); | ||
6165 | m_n->gmch_m = I915_READ(PIPE_DATA_M1(transcoder)) | ||
6166 | & ~TU_SIZE_MASK; | ||
6167 | m_n->gmch_n = I915_READ(PIPE_DATA_N1(transcoder)); | ||
6168 | m_n->tu = ((I915_READ(PIPE_DATA_M1(transcoder)) | ||
6169 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; | ||
6170 | } else { | ||
6171 | m_n->link_m = I915_READ(PIPE_LINK_M_G4X(pipe)); | ||
6172 | m_n->link_n = I915_READ(PIPE_LINK_N_G4X(pipe)); | ||
6173 | m_n->gmch_m = I915_READ(PIPE_DATA_M_G4X(pipe)) | ||
6174 | & ~TU_SIZE_MASK; | ||
6175 | m_n->gmch_n = I915_READ(PIPE_DATA_N_G4X(pipe)); | ||
6176 | m_n->tu = ((I915_READ(PIPE_DATA_M_G4X(pipe)) | ||
6177 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; | ||
6178 | } | ||
6179 | } | ||
6180 | |||
6181 | void intel_dp_get_m_n(struct intel_crtc *crtc, | ||
6182 | struct intel_crtc_config *pipe_config) | ||
6183 | { | ||
6184 | if (crtc->config.has_pch_encoder) | ||
6185 | intel_pch_transcoder_get_m_n(crtc, &pipe_config->dp_m_n); | ||
6186 | else | ||
6187 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, | ||
6188 | &pipe_config->dp_m_n); | ||
6189 | } | ||
6190 | |||
6191 | static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc, | ||
6192 | struct intel_crtc_config *pipe_config) | ||
6193 | { | ||
6194 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, | ||
6195 | &pipe_config->fdi_m_n); | ||
5861 | } | 6196 | } |
5862 | 6197 | ||
5863 | static void ironlake_get_pfit_config(struct intel_crtc *crtc, | 6198 | static void ironlake_get_pfit_config(struct intel_crtc *crtc, |
@@ -5946,6 +6281,8 @@ static bool ironlake_get_pipe_config(struct intel_crtc *crtc, | |||
5946 | pipe_config->pixel_multiplier = | 6281 | pipe_config->pixel_multiplier = |
5947 | ((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK) | 6282 | ((tmp & PLL_REF_SDVO_HDMI_MULTIPLIER_MASK) |
5948 | >> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1; | 6283 | >> PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT) + 1; |
6284 | |||
6285 | ironlake_pch_clock_get(crtc, pipe_config); | ||
5949 | } else { | 6286 | } else { |
5950 | pipe_config->pixel_multiplier = 1; | 6287 | pipe_config->pixel_multiplier = 1; |
5951 | } | 6288 | } |
@@ -6002,8 +6339,8 @@ static void assert_can_disable_lcpll(struct drm_i915_private *dev_priv) | |||
6002 | * register. Callers should take care of disabling all the display engine | 6339 | * register. Callers should take care of disabling all the display engine |
6003 | * functions, doing the mode unset, fixing interrupts, etc. | 6340 | * functions, doing the mode unset, fixing interrupts, etc. |
6004 | */ | 6341 | */ |
6005 | void hsw_disable_lcpll(struct drm_i915_private *dev_priv, | 6342 | static void hsw_disable_lcpll(struct drm_i915_private *dev_priv, |
6006 | bool switch_to_fclk, bool allow_power_down) | 6343 | bool switch_to_fclk, bool allow_power_down) |
6007 | { | 6344 | { |
6008 | uint32_t val; | 6345 | uint32_t val; |
6009 | 6346 | ||
@@ -6031,7 +6368,10 @@ void hsw_disable_lcpll(struct drm_i915_private *dev_priv, | |||
6031 | 6368 | ||
6032 | val = I915_READ(D_COMP); | 6369 | val = I915_READ(D_COMP); |
6033 | val |= D_COMP_COMP_DISABLE; | 6370 | val |= D_COMP_COMP_DISABLE; |
6034 | I915_WRITE(D_COMP, val); | 6371 | mutex_lock(&dev_priv->rps.hw_lock); |
6372 | if (sandybridge_pcode_write(dev_priv, GEN6_PCODE_WRITE_D_COMP, val)) | ||
6373 | DRM_ERROR("Failed to disable D_COMP\n"); | ||
6374 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
6035 | POSTING_READ(D_COMP); | 6375 | POSTING_READ(D_COMP); |
6036 | ndelay(100); | 6376 | ndelay(100); |
6037 | 6377 | ||
@@ -6050,7 +6390,7 @@ void hsw_disable_lcpll(struct drm_i915_private *dev_priv, | |||
6050 | * Fully restores LCPLL, disallowing power down and switching back to LCPLL | 6390 | * Fully restores LCPLL, disallowing power down and switching back to LCPLL |
6051 | * source. | 6391 | * source. |
6052 | */ | 6392 | */ |
6053 | void hsw_restore_lcpll(struct drm_i915_private *dev_priv) | 6393 | static void hsw_restore_lcpll(struct drm_i915_private *dev_priv) |
6054 | { | 6394 | { |
6055 | uint32_t val; | 6395 | uint32_t val; |
6056 | 6396 | ||
@@ -6073,7 +6413,10 @@ void hsw_restore_lcpll(struct drm_i915_private *dev_priv) | |||
6073 | val = I915_READ(D_COMP); | 6413 | val = I915_READ(D_COMP); |
6074 | val |= D_COMP_COMP_FORCE; | 6414 | val |= D_COMP_COMP_FORCE; |
6075 | val &= ~D_COMP_COMP_DISABLE; | 6415 | val &= ~D_COMP_COMP_DISABLE; |
6076 | I915_WRITE(D_COMP, val); | 6416 | mutex_lock(&dev_priv->rps.hw_lock); |
6417 | if (sandybridge_pcode_write(dev_priv, GEN6_PCODE_WRITE_D_COMP, val)) | ||
6418 | DRM_ERROR("Failed to enable D_COMP\n"); | ||
6419 | mutex_unlock(&dev_priv->rps.hw_lock); | ||
6077 | POSTING_READ(D_COMP); | 6420 | POSTING_READ(D_COMP); |
6078 | 6421 | ||
6079 | val = I915_READ(LCPLL_CTL); | 6422 | val = I915_READ(LCPLL_CTL); |
@@ -6256,22 +6599,79 @@ static void hsw_package_c8_gpu_busy(struct drm_i915_private *dev_priv) | |||
6256 | } | 6599 | } |
6257 | } | 6600 | } |
6258 | 6601 | ||
6259 | static void haswell_modeset_global_resources(struct drm_device *dev) | 6602 | #define for_each_power_domain(domain, mask) \ |
6603 | for ((domain) = 0; (domain) < POWER_DOMAIN_NUM; (domain)++) \ | ||
6604 | if ((1 << (domain)) & (mask)) | ||
6605 | |||
6606 | static unsigned long get_pipe_power_domains(struct drm_device *dev, | ||
6607 | enum pipe pipe, bool pfit_enabled) | ||
6260 | { | 6608 | { |
6261 | bool enable = false; | 6609 | unsigned long mask; |
6610 | enum transcoder transcoder; | ||
6611 | |||
6612 | transcoder = intel_pipe_to_cpu_transcoder(dev->dev_private, pipe); | ||
6613 | |||
6614 | mask = BIT(POWER_DOMAIN_PIPE(pipe)); | ||
6615 | mask |= BIT(POWER_DOMAIN_TRANSCODER(transcoder)); | ||
6616 | if (pfit_enabled) | ||
6617 | mask |= BIT(POWER_DOMAIN_PIPE_PANEL_FITTER(pipe)); | ||
6618 | |||
6619 | return mask; | ||
6620 | } | ||
6621 | |||
6622 | void intel_display_set_init_power(struct drm_device *dev, bool enable) | ||
6623 | { | ||
6624 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
6625 | |||
6626 | if (dev_priv->power_domains.init_power_on == enable) | ||
6627 | return; | ||
6628 | |||
6629 | if (enable) | ||
6630 | intel_display_power_get(dev, POWER_DOMAIN_INIT); | ||
6631 | else | ||
6632 | intel_display_power_put(dev, POWER_DOMAIN_INIT); | ||
6633 | |||
6634 | dev_priv->power_domains.init_power_on = enable; | ||
6635 | } | ||
6636 | |||
6637 | static void modeset_update_power_wells(struct drm_device *dev) | ||
6638 | { | ||
6639 | unsigned long pipe_domains[I915_MAX_PIPES] = { 0, }; | ||
6262 | struct intel_crtc *crtc; | 6640 | struct intel_crtc *crtc; |
6263 | 6641 | ||
6642 | /* | ||
6643 | * First get all needed power domains, then put all unneeded, to avoid | ||
6644 | * any unnecessary toggling of the power wells. | ||
6645 | */ | ||
6264 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { | 6646 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { |
6647 | enum intel_display_power_domain domain; | ||
6648 | |||
6265 | if (!crtc->base.enabled) | 6649 | if (!crtc->base.enabled) |
6266 | continue; | 6650 | continue; |
6267 | 6651 | ||
6268 | if (crtc->pipe != PIPE_A || crtc->config.pch_pfit.enabled || | 6652 | pipe_domains[crtc->pipe] = get_pipe_power_domains(dev, |
6269 | crtc->config.cpu_transcoder != TRANSCODER_EDP) | 6653 | crtc->pipe, |
6270 | enable = true; | 6654 | crtc->config.pch_pfit.enabled); |
6655 | |||
6656 | for_each_power_domain(domain, pipe_domains[crtc->pipe]) | ||
6657 | intel_display_power_get(dev, domain); | ||
6271 | } | 6658 | } |
6272 | 6659 | ||
6273 | intel_set_power_well(dev, enable); | 6660 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, base.head) { |
6661 | enum intel_display_power_domain domain; | ||
6662 | |||
6663 | for_each_power_domain(domain, crtc->enabled_power_domains) | ||
6664 | intel_display_power_put(dev, domain); | ||
6274 | 6665 | ||
6666 | crtc->enabled_power_domains = pipe_domains[crtc->pipe]; | ||
6667 | } | ||
6668 | |||
6669 | intel_display_set_init_power(dev, false); | ||
6670 | } | ||
6671 | |||
6672 | static void haswell_modeset_global_resources(struct drm_device *dev) | ||
6673 | { | ||
6674 | modeset_update_power_wells(dev); | ||
6275 | hsw_update_package_c8(dev); | 6675 | hsw_update_package_c8(dev); |
6276 | } | 6676 | } |
6277 | 6677 | ||
@@ -6310,8 +6710,6 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc, | |||
6310 | 6710 | ||
6311 | ret = intel_pipe_set_base(crtc, x, y, fb); | 6711 | ret = intel_pipe_set_base(crtc, x, y, fb); |
6312 | 6712 | ||
6313 | intel_update_watermarks(dev); | ||
6314 | |||
6315 | return ret; | 6713 | return ret; |
6316 | } | 6714 | } |
6317 | 6715 | ||
@@ -6419,6 +6817,44 @@ static int intel_crtc_mode_set(struct drm_crtc *crtc, | |||
6419 | return 0; | 6817 | return 0; |
6420 | } | 6818 | } |
6421 | 6819 | ||
6820 | static struct { | ||
6821 | int clock; | ||
6822 | u32 config; | ||
6823 | } hdmi_audio_clock[] = { | ||
6824 | { DIV_ROUND_UP(25200 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 }, | ||
6825 | { 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */ | ||
6826 | { 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 }, | ||
6827 | { 27000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 }, | ||
6828 | { 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 }, | ||
6829 | { 54000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 }, | ||
6830 | { DIV_ROUND_UP(74250 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 }, | ||
6831 | { 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 }, | ||
6832 | { DIV_ROUND_UP(148500 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 }, | ||
6833 | { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 }, | ||
6834 | }; | ||
6835 | |||
6836 | /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ | ||
6837 | static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode) | ||
6838 | { | ||
6839 | int i; | ||
6840 | |||
6841 | for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) { | ||
6842 | if (mode->clock == hdmi_audio_clock[i].clock) | ||
6843 | break; | ||
6844 | } | ||
6845 | |||
6846 | if (i == ARRAY_SIZE(hdmi_audio_clock)) { | ||
6847 | DRM_DEBUG_KMS("HDMI audio pixel clock setting for %d not found, falling back to defaults\n", mode->clock); | ||
6848 | i = 1; | ||
6849 | } | ||
6850 | |||
6851 | DRM_DEBUG_KMS("Configuring HDMI audio for pixel clock %d (0x%08x)\n", | ||
6852 | hdmi_audio_clock[i].clock, | ||
6853 | hdmi_audio_clock[i].config); | ||
6854 | |||
6855 | return hdmi_audio_clock[i].config; | ||
6856 | } | ||
6857 | |||
6422 | static bool intel_eld_uptodate(struct drm_connector *connector, | 6858 | static bool intel_eld_uptodate(struct drm_connector *connector, |
6423 | int reg_eldv, uint32_t bits_eldv, | 6859 | int reg_eldv, uint32_t bits_eldv, |
6424 | int reg_elda, uint32_t bits_elda, | 6860 | int reg_elda, uint32_t bits_elda, |
@@ -6449,7 +6885,8 @@ static bool intel_eld_uptodate(struct drm_connector *connector, | |||
6449 | } | 6885 | } |
6450 | 6886 | ||
6451 | static void g4x_write_eld(struct drm_connector *connector, | 6887 | static void g4x_write_eld(struct drm_connector *connector, |
6452 | struct drm_crtc *crtc) | 6888 | struct drm_crtc *crtc, |
6889 | struct drm_display_mode *mode) | ||
6453 | { | 6890 | { |
6454 | struct drm_i915_private *dev_priv = connector->dev->dev_private; | 6891 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
6455 | uint8_t *eld = connector->eld; | 6892 | uint8_t *eld = connector->eld; |
@@ -6489,7 +6926,8 @@ static void g4x_write_eld(struct drm_connector *connector, | |||
6489 | } | 6926 | } |
6490 | 6927 | ||
6491 | static void haswell_write_eld(struct drm_connector *connector, | 6928 | static void haswell_write_eld(struct drm_connector *connector, |
6492 | struct drm_crtc *crtc) | 6929 | struct drm_crtc *crtc, |
6930 | struct drm_display_mode *mode) | ||
6493 | { | 6931 | { |
6494 | struct drm_i915_private *dev_priv = connector->dev->dev_private; | 6932 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
6495 | uint8_t *eld = connector->eld; | 6933 | uint8_t *eld = connector->eld; |
@@ -6542,8 +6980,9 @@ static void haswell_write_eld(struct drm_connector *connector, | |||
6542 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); | 6980 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); |
6543 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ | 6981 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ |
6544 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ | 6982 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ |
6545 | } else | 6983 | } else { |
6546 | I915_WRITE(aud_config, 0); | 6984 | I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode)); |
6985 | } | ||
6547 | 6986 | ||
6548 | if (intel_eld_uptodate(connector, | 6987 | if (intel_eld_uptodate(connector, |
6549 | aud_cntrl_st2, eldv, | 6988 | aud_cntrl_st2, eldv, |
@@ -6576,7 +7015,8 @@ static void haswell_write_eld(struct drm_connector *connector, | |||
6576 | } | 7015 | } |
6577 | 7016 | ||
6578 | static void ironlake_write_eld(struct drm_connector *connector, | 7017 | static void ironlake_write_eld(struct drm_connector *connector, |
6579 | struct drm_crtc *crtc) | 7018 | struct drm_crtc *crtc, |
7019 | struct drm_display_mode *mode) | ||
6580 | { | 7020 | { |
6581 | struct drm_i915_private *dev_priv = connector->dev->dev_private; | 7021 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
6582 | uint8_t *eld = connector->eld; | 7022 | uint8_t *eld = connector->eld; |
@@ -6594,6 +7034,11 @@ static void ironlake_write_eld(struct drm_connector *connector, | |||
6594 | aud_config = IBX_AUD_CFG(pipe); | 7034 | aud_config = IBX_AUD_CFG(pipe); |
6595 | aud_cntl_st = IBX_AUD_CNTL_ST(pipe); | 7035 | aud_cntl_st = IBX_AUD_CNTL_ST(pipe); |
6596 | aud_cntrl_st2 = IBX_AUD_CNTL_ST2; | 7036 | aud_cntrl_st2 = IBX_AUD_CNTL_ST2; |
7037 | } else if (IS_VALLEYVIEW(connector->dev)) { | ||
7038 | hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe); | ||
7039 | aud_config = VLV_AUD_CFG(pipe); | ||
7040 | aud_cntl_st = VLV_AUD_CNTL_ST(pipe); | ||
7041 | aud_cntrl_st2 = VLV_AUD_CNTL_ST2; | ||
6597 | } else { | 7042 | } else { |
6598 | hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe); | 7043 | hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe); |
6599 | aud_config = CPT_AUD_CFG(pipe); | 7044 | aud_config = CPT_AUD_CFG(pipe); |
@@ -6603,8 +7048,19 @@ static void ironlake_write_eld(struct drm_connector *connector, | |||
6603 | 7048 | ||
6604 | DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe)); | 7049 | DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe)); |
6605 | 7050 | ||
6606 | i = I915_READ(aud_cntl_st); | 7051 | if (IS_VALLEYVIEW(connector->dev)) { |
6607 | i = (i >> 29) & DIP_PORT_SEL_MASK; /* DIP_Port_Select, 0x1 = PortB */ | 7052 | struct intel_encoder *intel_encoder; |
7053 | struct intel_digital_port *intel_dig_port; | ||
7054 | |||
7055 | intel_encoder = intel_attached_encoder(connector); | ||
7056 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); | ||
7057 | i = intel_dig_port->port; | ||
7058 | } else { | ||
7059 | i = I915_READ(aud_cntl_st); | ||
7060 | i = (i >> 29) & DIP_PORT_SEL_MASK; | ||
7061 | /* DIP_Port_Select, 0x1 = PortB */ | ||
7062 | } | ||
7063 | |||
6608 | if (!i) { | 7064 | if (!i) { |
6609 | DRM_DEBUG_DRIVER("Audio directed to unknown port\n"); | 7065 | DRM_DEBUG_DRIVER("Audio directed to unknown port\n"); |
6610 | /* operate blindly on all ports */ | 7066 | /* operate blindly on all ports */ |
@@ -6620,8 +7076,9 @@ static void ironlake_write_eld(struct drm_connector *connector, | |||
6620 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); | 7076 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); |
6621 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ | 7077 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ |
6622 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ | 7078 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ |
6623 | } else | 7079 | } else { |
6624 | I915_WRITE(aud_config, 0); | 7080 | I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode)); |
7081 | } | ||
6625 | 7082 | ||
6626 | if (intel_eld_uptodate(connector, | 7083 | if (intel_eld_uptodate(connector, |
6627 | aud_cntrl_st2, eldv, | 7084 | aud_cntrl_st2, eldv, |
@@ -6671,50 +7128,7 @@ void intel_write_eld(struct drm_encoder *encoder, | |||
6671 | connector->eld[6] = drm_av_sync_delay(connector, mode) / 2; | 7128 | connector->eld[6] = drm_av_sync_delay(connector, mode) / 2; |
6672 | 7129 | ||
6673 | if (dev_priv->display.write_eld) | 7130 | if (dev_priv->display.write_eld) |
6674 | dev_priv->display.write_eld(connector, crtc); | 7131 | dev_priv->display.write_eld(connector, crtc, mode); |
6675 | } | ||
6676 | |||
6677 | /** Loads the palette/gamma unit for the CRTC with the prepared values */ | ||
6678 | void intel_crtc_load_lut(struct drm_crtc *crtc) | ||
6679 | { | ||
6680 | struct drm_device *dev = crtc->dev; | ||
6681 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
6682 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
6683 | enum pipe pipe = intel_crtc->pipe; | ||
6684 | int palreg = PALETTE(pipe); | ||
6685 | int i; | ||
6686 | bool reenable_ips = false; | ||
6687 | |||
6688 | /* The clocks have to be on to load the palette. */ | ||
6689 | if (!crtc->enabled || !intel_crtc->active) | ||
6690 | return; | ||
6691 | |||
6692 | if (!HAS_PCH_SPLIT(dev_priv->dev)) | ||
6693 | assert_pll_enabled(dev_priv, pipe); | ||
6694 | |||
6695 | /* use legacy palette for Ironlake */ | ||
6696 | if (HAS_PCH_SPLIT(dev)) | ||
6697 | palreg = LGC_PALETTE(pipe); | ||
6698 | |||
6699 | /* Workaround : Do not read or write the pipe palette/gamma data while | ||
6700 | * GAMMA_MODE is configured for split gamma and IPS_CTL has IPS enabled. | ||
6701 | */ | ||
6702 | if (intel_crtc->config.ips_enabled && | ||
6703 | ((I915_READ(GAMMA_MODE(pipe)) & GAMMA_MODE_MODE_MASK) == | ||
6704 | GAMMA_MODE_MODE_SPLIT)) { | ||
6705 | hsw_disable_ips(intel_crtc); | ||
6706 | reenable_ips = true; | ||
6707 | } | ||
6708 | |||
6709 | for (i = 0; i < 256; i++) { | ||
6710 | I915_WRITE(palreg + 4 * i, | ||
6711 | (intel_crtc->lut_r[i] << 16) | | ||
6712 | (intel_crtc->lut_g[i] << 8) | | ||
6713 | intel_crtc->lut_b[i]); | ||
6714 | } | ||
6715 | |||
6716 | if (reenable_ips) | ||
6717 | hsw_enable_ips(intel_crtc); | ||
6718 | } | 7132 | } |
6719 | 7133 | ||
6720 | static void i845_update_cursor(struct drm_crtc *crtc, u32 base) | 7134 | static void i845_update_cursor(struct drm_crtc *crtc, u32 base) |
@@ -6790,7 +7204,7 @@ static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) | |||
6790 | cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); | 7204 | cntl &= ~(CURSOR_MODE | MCURSOR_GAMMA_ENABLE); |
6791 | cntl |= CURSOR_MODE_DISABLE; | 7205 | cntl |= CURSOR_MODE_DISABLE; |
6792 | } | 7206 | } |
6793 | if (IS_HASWELL(dev)) { | 7207 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
6794 | cntl |= CURSOR_PIPE_CSC_ENABLE; | 7208 | cntl |= CURSOR_PIPE_CSC_ENABLE; |
6795 | cntl &= ~CURSOR_TRICKLE_FEED_DISABLE; | 7209 | cntl &= ~CURSOR_TRICKLE_FEED_DISABLE; |
6796 | } | 7210 | } |
@@ -6812,23 +7226,20 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, | |||
6812 | int pipe = intel_crtc->pipe; | 7226 | int pipe = intel_crtc->pipe; |
6813 | int x = intel_crtc->cursor_x; | 7227 | int x = intel_crtc->cursor_x; |
6814 | int y = intel_crtc->cursor_y; | 7228 | int y = intel_crtc->cursor_y; |
6815 | u32 base, pos; | 7229 | u32 base = 0, pos = 0; |
6816 | bool visible; | 7230 | bool visible; |
6817 | 7231 | ||
6818 | pos = 0; | 7232 | if (on) |
6819 | |||
6820 | if (on && crtc->enabled && crtc->fb) { | ||
6821 | base = intel_crtc->cursor_addr; | 7233 | base = intel_crtc->cursor_addr; |
6822 | if (x > (int) crtc->fb->width) | ||
6823 | base = 0; | ||
6824 | 7234 | ||
6825 | if (y > (int) crtc->fb->height) | 7235 | if (x >= intel_crtc->config.pipe_src_w) |
6826 | base = 0; | 7236 | base = 0; |
6827 | } else | 7237 | |
7238 | if (y >= intel_crtc->config.pipe_src_h) | ||
6828 | base = 0; | 7239 | base = 0; |
6829 | 7240 | ||
6830 | if (x < 0) { | 7241 | if (x < 0) { |
6831 | if (x + intel_crtc->cursor_width < 0) | 7242 | if (x + intel_crtc->cursor_width <= 0) |
6832 | base = 0; | 7243 | base = 0; |
6833 | 7244 | ||
6834 | pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT; | 7245 | pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT; |
@@ -6837,7 +7248,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, | |||
6837 | pos |= x << CURSOR_X_SHIFT; | 7248 | pos |= x << CURSOR_X_SHIFT; |
6838 | 7249 | ||
6839 | if (y < 0) { | 7250 | if (y < 0) { |
6840 | if (y + intel_crtc->cursor_height < 0) | 7251 | if (y + intel_crtc->cursor_height <= 0) |
6841 | base = 0; | 7252 | base = 0; |
6842 | 7253 | ||
6843 | pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT; | 7254 | pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT; |
@@ -6849,7 +7260,7 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc, | |||
6849 | if (!visible && !intel_crtc->cursor_visible) | 7260 | if (!visible && !intel_crtc->cursor_visible) |
6850 | return; | 7261 | return; |
6851 | 7262 | ||
6852 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev)) { | 7263 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
6853 | I915_WRITE(CURPOS_IVB(pipe), pos); | 7264 | I915_WRITE(CURPOS_IVB(pipe), pos); |
6854 | ivb_update_cursor(crtc, base); | 7265 | ivb_update_cursor(crtc, base); |
6855 | } else { | 7266 | } else { |
@@ -6980,8 +7391,8 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | |||
6980 | { | 7391 | { |
6981 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 7392 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
6982 | 7393 | ||
6983 | intel_crtc->cursor_x = x; | 7394 | intel_crtc->cursor_x = clamp_t(int, x, SHRT_MIN, SHRT_MAX); |
6984 | intel_crtc->cursor_y = y; | 7395 | intel_crtc->cursor_y = clamp_t(int, y, SHRT_MIN, SHRT_MAX); |
6985 | 7396 | ||
6986 | if (intel_crtc->active) | 7397 | if (intel_crtc->active) |
6987 | intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); | 7398 | intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
@@ -6989,27 +7400,6 @@ static int intel_crtc_cursor_move(struct drm_crtc *crtc, int x, int y) | |||
6989 | return 0; | 7400 | return 0; |
6990 | } | 7401 | } |
6991 | 7402 | ||
6992 | /** Sets the color ramps on behalf of RandR */ | ||
6993 | void intel_crtc_fb_gamma_set(struct drm_crtc *crtc, u16 red, u16 green, | ||
6994 | u16 blue, int regno) | ||
6995 | { | ||
6996 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
6997 | |||
6998 | intel_crtc->lut_r[regno] = red >> 8; | ||
6999 | intel_crtc->lut_g[regno] = green >> 8; | ||
7000 | intel_crtc->lut_b[regno] = blue >> 8; | ||
7001 | } | ||
7002 | |||
7003 | void intel_crtc_fb_gamma_get(struct drm_crtc *crtc, u16 *red, u16 *green, | ||
7004 | u16 *blue, int regno) | ||
7005 | { | ||
7006 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
7007 | |||
7008 | *red = intel_crtc->lut_r[regno] << 8; | ||
7009 | *green = intel_crtc->lut_g[regno] << 8; | ||
7010 | *blue = intel_crtc->lut_b[regno] << 8; | ||
7011 | } | ||
7012 | |||
7013 | static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, | 7403 | static void intel_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green, |
7014 | u16 *blue, uint32_t start, uint32_t size) | 7404 | u16 *blue, uint32_t start, uint32_t size) |
7015 | { | 7405 | { |
@@ -7045,14 +7435,21 @@ intel_framebuffer_create(struct drm_device *dev, | |||
7045 | return ERR_PTR(-ENOMEM); | 7435 | return ERR_PTR(-ENOMEM); |
7046 | } | 7436 | } |
7047 | 7437 | ||
7438 | ret = i915_mutex_lock_interruptible(dev); | ||
7439 | if (ret) | ||
7440 | goto err; | ||
7441 | |||
7048 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); | 7442 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); |
7049 | if (ret) { | 7443 | mutex_unlock(&dev->struct_mutex); |
7050 | drm_gem_object_unreference_unlocked(&obj->base); | 7444 | if (ret) |
7051 | kfree(intel_fb); | 7445 | goto err; |
7052 | return ERR_PTR(ret); | ||
7053 | } | ||
7054 | 7446 | ||
7055 | return &intel_fb->base; | 7447 | return &intel_fb->base; |
7448 | err: | ||
7449 | drm_gem_object_unreference_unlocked(&obj->base); | ||
7450 | kfree(intel_fb); | ||
7451 | |||
7452 | return ERR_PTR(ret); | ||
7056 | } | 7453 | } |
7057 | 7454 | ||
7058 | static u32 | 7455 | static u32 |
@@ -7095,6 +7492,7 @@ static struct drm_framebuffer * | |||
7095 | mode_fits_in_fbdev(struct drm_device *dev, | 7492 | mode_fits_in_fbdev(struct drm_device *dev, |
7096 | struct drm_display_mode *mode) | 7493 | struct drm_display_mode *mode) |
7097 | { | 7494 | { |
7495 | #ifdef CONFIG_DRM_I915_FBDEV | ||
7098 | struct drm_i915_private *dev_priv = dev->dev_private; | 7496 | struct drm_i915_private *dev_priv = dev->dev_private; |
7099 | struct drm_i915_gem_object *obj; | 7497 | struct drm_i915_gem_object *obj; |
7100 | struct drm_framebuffer *fb; | 7498 | struct drm_framebuffer *fb; |
@@ -7115,6 +7513,9 @@ mode_fits_in_fbdev(struct drm_device *dev, | |||
7115 | return NULL; | 7513 | return NULL; |
7116 | 7514 | ||
7117 | return fb; | 7515 | return fb; |
7516 | #else | ||
7517 | return NULL; | ||
7518 | #endif | ||
7118 | } | 7519 | } |
7119 | 7520 | ||
7120 | bool intel_get_load_detect_pipe(struct drm_connector *connector, | 7521 | bool intel_get_load_detect_pipe(struct drm_connector *connector, |
@@ -7258,6 +7659,22 @@ void intel_release_load_detect_pipe(struct drm_connector *connector, | |||
7258 | mutex_unlock(&crtc->mutex); | 7659 | mutex_unlock(&crtc->mutex); |
7259 | } | 7660 | } |
7260 | 7661 | ||
7662 | static int i9xx_pll_refclk(struct drm_device *dev, | ||
7663 | const struct intel_crtc_config *pipe_config) | ||
7664 | { | ||
7665 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7666 | u32 dpll = pipe_config->dpll_hw_state.dpll; | ||
7667 | |||
7668 | if ((dpll & PLL_REF_INPUT_MASK) == PLLB_REF_INPUT_SPREADSPECTRUMIN) | ||
7669 | return dev_priv->vbt.lvds_ssc_freq * 1000; | ||
7670 | else if (HAS_PCH_SPLIT(dev)) | ||
7671 | return 120000; | ||
7672 | else if (!IS_GEN2(dev)) | ||
7673 | return 96000; | ||
7674 | else | ||
7675 | return 48000; | ||
7676 | } | ||
7677 | |||
7261 | /* Returns the clock of the currently programmed mode of the given pipe. */ | 7678 | /* Returns the clock of the currently programmed mode of the given pipe. */ |
7262 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | 7679 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, |
7263 | struct intel_crtc_config *pipe_config) | 7680 | struct intel_crtc_config *pipe_config) |
@@ -7265,14 +7682,15 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | |||
7265 | struct drm_device *dev = crtc->base.dev; | 7682 | struct drm_device *dev = crtc->base.dev; |
7266 | struct drm_i915_private *dev_priv = dev->dev_private; | 7683 | struct drm_i915_private *dev_priv = dev->dev_private; |
7267 | int pipe = pipe_config->cpu_transcoder; | 7684 | int pipe = pipe_config->cpu_transcoder; |
7268 | u32 dpll = I915_READ(DPLL(pipe)); | 7685 | u32 dpll = pipe_config->dpll_hw_state.dpll; |
7269 | u32 fp; | 7686 | u32 fp; |
7270 | intel_clock_t clock; | 7687 | intel_clock_t clock; |
7688 | int refclk = i9xx_pll_refclk(dev, pipe_config); | ||
7271 | 7689 | ||
7272 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) | 7690 | if ((dpll & DISPLAY_RATE_SELECT_FPA1) == 0) |
7273 | fp = I915_READ(FP0(pipe)); | 7691 | fp = pipe_config->dpll_hw_state.fp0; |
7274 | else | 7692 | else |
7275 | fp = I915_READ(FP1(pipe)); | 7693 | fp = pipe_config->dpll_hw_state.fp1; |
7276 | 7694 | ||
7277 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; | 7695 | clock.m1 = (fp & FP_M1_DIV_MASK) >> FP_M1_DIV_SHIFT; |
7278 | if (IS_PINEVIEW(dev)) { | 7696 | if (IS_PINEVIEW(dev)) { |
@@ -7303,14 +7721,13 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | |||
7303 | default: | 7721 | default: |
7304 | DRM_DEBUG_KMS("Unknown DPLL mode %08x in programmed " | 7722 | DRM_DEBUG_KMS("Unknown DPLL mode %08x in programmed " |
7305 | "mode\n", (int)(dpll & DPLL_MODE_MASK)); | 7723 | "mode\n", (int)(dpll & DPLL_MODE_MASK)); |
7306 | pipe_config->adjusted_mode.clock = 0; | ||
7307 | return; | 7724 | return; |
7308 | } | 7725 | } |
7309 | 7726 | ||
7310 | if (IS_PINEVIEW(dev)) | 7727 | if (IS_PINEVIEW(dev)) |
7311 | pineview_clock(96000, &clock); | 7728 | pineview_clock(refclk, &clock); |
7312 | else | 7729 | else |
7313 | i9xx_clock(96000, &clock); | 7730 | i9xx_clock(refclk, &clock); |
7314 | } else { | 7731 | } else { |
7315 | bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN); | 7732 | bool is_lvds = (pipe == 1) && (I915_READ(LVDS) & LVDS_PORT_EN); |
7316 | 7733 | ||
@@ -7318,13 +7735,6 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | |||
7318 | clock.p1 = ffs((dpll & DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >> | 7735 | clock.p1 = ffs((dpll & DPLL_FPA01_P1_POST_DIV_MASK_I830_LVDS) >> |
7319 | DPLL_FPA01_P1_POST_DIV_SHIFT); | 7736 | DPLL_FPA01_P1_POST_DIV_SHIFT); |
7320 | clock.p2 = 14; | 7737 | clock.p2 = 14; |
7321 | |||
7322 | if ((dpll & PLL_REF_INPUT_MASK) == | ||
7323 | PLLB_REF_INPUT_SPREADSPECTRUMIN) { | ||
7324 | /* XXX: might not be 66MHz */ | ||
7325 | i9xx_clock(66000, &clock); | ||
7326 | } else | ||
7327 | i9xx_clock(48000, &clock); | ||
7328 | } else { | 7738 | } else { |
7329 | if (dpll & PLL_P1_DIVIDE_BY_TWO) | 7739 | if (dpll & PLL_P1_DIVIDE_BY_TWO) |
7330 | clock.p1 = 2; | 7740 | clock.p1 = 2; |
@@ -7336,59 +7746,55 @@ static void i9xx_crtc_clock_get(struct intel_crtc *crtc, | |||
7336 | clock.p2 = 4; | 7746 | clock.p2 = 4; |
7337 | else | 7747 | else |
7338 | clock.p2 = 2; | 7748 | clock.p2 = 2; |
7339 | |||
7340 | i9xx_clock(48000, &clock); | ||
7341 | } | 7749 | } |
7750 | |||
7751 | i9xx_clock(refclk, &clock); | ||
7342 | } | 7752 | } |
7343 | 7753 | ||
7344 | pipe_config->adjusted_mode.clock = clock.dot; | 7754 | /* |
7755 | * This value includes pixel_multiplier. We will use | ||
7756 | * port_clock to compute adjusted_mode.crtc_clock in the | ||
7757 | * encoder's get_config() function. | ||
7758 | */ | ||
7759 | pipe_config->port_clock = clock.dot; | ||
7345 | } | 7760 | } |
7346 | 7761 | ||
7347 | static void ironlake_crtc_clock_get(struct intel_crtc *crtc, | 7762 | int intel_dotclock_calculate(int link_freq, |
7348 | struct intel_crtc_config *pipe_config) | 7763 | const struct intel_link_m_n *m_n) |
7349 | { | 7764 | { |
7350 | struct drm_device *dev = crtc->base.dev; | ||
7351 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
7352 | enum transcoder cpu_transcoder = pipe_config->cpu_transcoder; | ||
7353 | int link_freq, repeat; | ||
7354 | u64 clock; | ||
7355 | u32 link_m, link_n; | ||
7356 | |||
7357 | repeat = pipe_config->pixel_multiplier; | ||
7358 | |||
7359 | /* | 7765 | /* |
7360 | * The calculation for the data clock is: | 7766 | * The calculation for the data clock is: |
7361 | * pixel_clock = ((m/n)*(link_clock * nr_lanes * repeat))/bpp | 7767 | * pixel_clock = ((m/n)*(link_clock * nr_lanes))/bpp |
7362 | * But we want to avoid losing precison if possible, so: | 7768 | * But we want to avoid losing precison if possible, so: |
7363 | * pixel_clock = ((m * link_clock * nr_lanes * repeat)/(n*bpp)) | 7769 | * pixel_clock = ((m * link_clock * nr_lanes)/(n*bpp)) |
7364 | * | 7770 | * |
7365 | * and the link clock is simpler: | 7771 | * and the link clock is simpler: |
7366 | * link_clock = (m * link_clock * repeat) / n | 7772 | * link_clock = (m * link_clock) / n |
7367 | */ | 7773 | */ |
7368 | 7774 | ||
7369 | /* | 7775 | if (!m_n->link_n) |
7370 | * We need to get the FDI or DP link clock here to derive | 7776 | return 0; |
7371 | * the M/N dividers. | ||
7372 | * | ||
7373 | * For FDI, we read it from the BIOS or use a fixed 2.7GHz. | ||
7374 | * For DP, it's either 1.62GHz or 2.7GHz. | ||
7375 | * We do our calculations in 10*MHz since we don't need much precison. | ||
7376 | */ | ||
7377 | if (pipe_config->has_pch_encoder) | ||
7378 | link_freq = intel_fdi_link_freq(dev) * 10000; | ||
7379 | else | ||
7380 | link_freq = pipe_config->port_clock; | ||
7381 | 7777 | ||
7382 | link_m = I915_READ(PIPE_LINK_M1(cpu_transcoder)); | 7778 | return div_u64((u64)m_n->link_m * link_freq, m_n->link_n); |
7383 | link_n = I915_READ(PIPE_LINK_N1(cpu_transcoder)); | 7779 | } |
7384 | 7780 | ||
7385 | if (!link_m || !link_n) | 7781 | static void ironlake_pch_clock_get(struct intel_crtc *crtc, |
7386 | return; | 7782 | struct intel_crtc_config *pipe_config) |
7783 | { | ||
7784 | struct drm_device *dev = crtc->base.dev; | ||
7387 | 7785 | ||
7388 | clock = ((u64)link_m * (u64)link_freq * (u64)repeat); | 7786 | /* read out port_clock from the DPLL */ |
7389 | do_div(clock, link_n); | 7787 | i9xx_crtc_clock_get(crtc, pipe_config); |
7390 | 7788 | ||
7391 | pipe_config->adjusted_mode.clock = clock; | 7789 | /* |
7790 | * This value does not include pixel_multiplier. | ||
7791 | * We will check that port_clock and adjusted_mode.crtc_clock | ||
7792 | * agree once we know their relationship in the encoder's | ||
7793 | * get_config() function. | ||
7794 | */ | ||
7795 | pipe_config->adjusted_mode.crtc_clock = | ||
7796 | intel_dotclock_calculate(intel_fdi_link_freq(dev) * 10000, | ||
7797 | &pipe_config->fdi_m_n); | ||
7392 | } | 7798 | } |
7393 | 7799 | ||
7394 | /** Returns the currently programmed mode of the given pipe. */ | 7800 | /** Returns the currently programmed mode of the given pipe. */ |
@@ -7404,6 +7810,7 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, | |||
7404 | int hsync = I915_READ(HSYNC(cpu_transcoder)); | 7810 | int hsync = I915_READ(HSYNC(cpu_transcoder)); |
7405 | int vtot = I915_READ(VTOTAL(cpu_transcoder)); | 7811 | int vtot = I915_READ(VTOTAL(cpu_transcoder)); |
7406 | int vsync = I915_READ(VSYNC(cpu_transcoder)); | 7812 | int vsync = I915_READ(VSYNC(cpu_transcoder)); |
7813 | enum pipe pipe = intel_crtc->pipe; | ||
7407 | 7814 | ||
7408 | mode = kzalloc(sizeof(*mode), GFP_KERNEL); | 7815 | mode = kzalloc(sizeof(*mode), GFP_KERNEL); |
7409 | if (!mode) | 7816 | if (!mode) |
@@ -7416,11 +7823,14 @@ struct drm_display_mode *intel_crtc_mode_get(struct drm_device *dev, | |||
7416 | * Note, if LVDS ever uses a non-1 pixel multiplier, we'll need | 7823 | * Note, if LVDS ever uses a non-1 pixel multiplier, we'll need |
7417 | * to use a real value here instead. | 7824 | * to use a real value here instead. |
7418 | */ | 7825 | */ |
7419 | pipe_config.cpu_transcoder = (enum transcoder) intel_crtc->pipe; | 7826 | pipe_config.cpu_transcoder = (enum transcoder) pipe; |
7420 | pipe_config.pixel_multiplier = 1; | 7827 | pipe_config.pixel_multiplier = 1; |
7828 | pipe_config.dpll_hw_state.dpll = I915_READ(DPLL(pipe)); | ||
7829 | pipe_config.dpll_hw_state.fp0 = I915_READ(FP0(pipe)); | ||
7830 | pipe_config.dpll_hw_state.fp1 = I915_READ(FP1(pipe)); | ||
7421 | i9xx_crtc_clock_get(intel_crtc, &pipe_config); | 7831 | i9xx_crtc_clock_get(intel_crtc, &pipe_config); |
7422 | 7832 | ||
7423 | mode->clock = pipe_config.adjusted_mode.clock; | 7833 | mode->clock = pipe_config.port_clock / pipe_config.pixel_multiplier; |
7424 | mode->hdisplay = (htot & 0xffff) + 1; | 7834 | mode->hdisplay = (htot & 0xffff) + 1; |
7425 | mode->htotal = ((htot & 0xffff0000) >> 16) + 1; | 7835 | mode->htotal = ((htot & 0xffff0000) >> 16) + 1; |
7426 | mode->hsync_start = (hsync & 0xffff) + 1; | 7836 | mode->hsync_start = (hsync & 0xffff) + 1; |
@@ -7526,6 +7936,9 @@ void intel_mark_idle(struct drm_device *dev) | |||
7526 | 7936 | ||
7527 | intel_decrease_pllclock(crtc); | 7937 | intel_decrease_pllclock(crtc); |
7528 | } | 7938 | } |
7939 | |||
7940 | if (dev_priv->info->gen >= 6) | ||
7941 | gen6_rps_idle(dev->dev_private); | ||
7529 | } | 7942 | } |
7530 | 7943 | ||
7531 | void intel_mark_fb_busy(struct drm_i915_gem_object *obj, | 7944 | void intel_mark_fb_busy(struct drm_i915_gem_object *obj, |
@@ -7714,7 +8127,7 @@ static int intel_gen2_queue_flip(struct drm_device *dev, | |||
7714 | intel_ring_emit(ring, 0); /* aux display base address, unused */ | 8127 | intel_ring_emit(ring, 0); /* aux display base address, unused */ |
7715 | 8128 | ||
7716 | intel_mark_page_flip_active(intel_crtc); | 8129 | intel_mark_page_flip_active(intel_crtc); |
7717 | intel_ring_advance(ring); | 8130 | __intel_ring_advance(ring); |
7718 | return 0; | 8131 | return 0; |
7719 | 8132 | ||
7720 | err_unpin: | 8133 | err_unpin: |
@@ -7756,7 +8169,7 @@ static int intel_gen3_queue_flip(struct drm_device *dev, | |||
7756 | intel_ring_emit(ring, MI_NOOP); | 8169 | intel_ring_emit(ring, MI_NOOP); |
7757 | 8170 | ||
7758 | intel_mark_page_flip_active(intel_crtc); | 8171 | intel_mark_page_flip_active(intel_crtc); |
7759 | intel_ring_advance(ring); | 8172 | __intel_ring_advance(ring); |
7760 | return 0; | 8173 | return 0; |
7761 | 8174 | ||
7762 | err_unpin: | 8175 | err_unpin: |
@@ -7805,7 +8218,7 @@ static int intel_gen4_queue_flip(struct drm_device *dev, | |||
7805 | intel_ring_emit(ring, pf | pipesrc); | 8218 | intel_ring_emit(ring, pf | pipesrc); |
7806 | 8219 | ||
7807 | intel_mark_page_flip_active(intel_crtc); | 8220 | intel_mark_page_flip_active(intel_crtc); |
7808 | intel_ring_advance(ring); | 8221 | __intel_ring_advance(ring); |
7809 | return 0; | 8222 | return 0; |
7810 | 8223 | ||
7811 | err_unpin: | 8224 | err_unpin: |
@@ -7850,7 +8263,7 @@ static int intel_gen6_queue_flip(struct drm_device *dev, | |||
7850 | intel_ring_emit(ring, pf | pipesrc); | 8263 | intel_ring_emit(ring, pf | pipesrc); |
7851 | 8264 | ||
7852 | intel_mark_page_flip_active(intel_crtc); | 8265 | intel_mark_page_flip_active(intel_crtc); |
7853 | intel_ring_advance(ring); | 8266 | __intel_ring_advance(ring); |
7854 | return 0; | 8267 | return 0; |
7855 | 8268 | ||
7856 | err_unpin: | 8269 | err_unpin: |
@@ -7929,7 +8342,7 @@ static int intel_gen7_queue_flip(struct drm_device *dev, | |||
7929 | intel_ring_emit(ring, (MI_NOOP)); | 8342 | intel_ring_emit(ring, (MI_NOOP)); |
7930 | 8343 | ||
7931 | intel_mark_page_flip_active(intel_crtc); | 8344 | intel_mark_page_flip_active(intel_crtc); |
7932 | intel_ring_advance(ring); | 8345 | __intel_ring_advance(ring); |
7933 | return 0; | 8346 | return 0; |
7934 | 8347 | ||
7935 | err_unpin: | 8348 | err_unpin: |
@@ -7974,7 +8387,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc, | |||
7974 | fb->pitches[0] != crtc->fb->pitches[0])) | 8387 | fb->pitches[0] != crtc->fb->pitches[0])) |
7975 | return -EINVAL; | 8388 | return -EINVAL; |
7976 | 8389 | ||
7977 | work = kzalloc(sizeof *work, GFP_KERNEL); | 8390 | work = kzalloc(sizeof(*work), GFP_KERNEL); |
7978 | if (work == NULL) | 8391 | if (work == NULL) |
7979 | return -ENOMEM; | 8392 | return -ENOMEM; |
7980 | 8393 | ||
@@ -8209,6 +8622,17 @@ compute_baseline_pipe_bpp(struct intel_crtc *crtc, | |||
8209 | return bpp; | 8622 | return bpp; |
8210 | } | 8623 | } |
8211 | 8624 | ||
8625 | static void intel_dump_crtc_timings(const struct drm_display_mode *mode) | ||
8626 | { | ||
8627 | DRM_DEBUG_KMS("crtc timings: %d %d %d %d %d %d %d %d %d, " | ||
8628 | "type: 0x%x flags: 0x%x\n", | ||
8629 | mode->crtc_clock, | ||
8630 | mode->crtc_hdisplay, mode->crtc_hsync_start, | ||
8631 | mode->crtc_hsync_end, mode->crtc_htotal, | ||
8632 | mode->crtc_vdisplay, mode->crtc_vsync_start, | ||
8633 | mode->crtc_vsync_end, mode->crtc_vtotal, mode->type, mode->flags); | ||
8634 | } | ||
8635 | |||
8212 | static void intel_dump_pipe_config(struct intel_crtc *crtc, | 8636 | static void intel_dump_pipe_config(struct intel_crtc *crtc, |
8213 | struct intel_crtc_config *pipe_config, | 8637 | struct intel_crtc_config *pipe_config, |
8214 | const char *context) | 8638 | const char *context) |
@@ -8225,10 +8649,19 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, | |||
8225 | pipe_config->fdi_m_n.gmch_m, pipe_config->fdi_m_n.gmch_n, | 8649 | pipe_config->fdi_m_n.gmch_m, pipe_config->fdi_m_n.gmch_n, |
8226 | pipe_config->fdi_m_n.link_m, pipe_config->fdi_m_n.link_n, | 8650 | pipe_config->fdi_m_n.link_m, pipe_config->fdi_m_n.link_n, |
8227 | pipe_config->fdi_m_n.tu); | 8651 | pipe_config->fdi_m_n.tu); |
8652 | DRM_DEBUG_KMS("dp: %i, gmch_m: %u, gmch_n: %u, link_m: %u, link_n: %u, tu: %u\n", | ||
8653 | pipe_config->has_dp_encoder, | ||
8654 | pipe_config->dp_m_n.gmch_m, pipe_config->dp_m_n.gmch_n, | ||
8655 | pipe_config->dp_m_n.link_m, pipe_config->dp_m_n.link_n, | ||
8656 | pipe_config->dp_m_n.tu); | ||
8228 | DRM_DEBUG_KMS("requested mode:\n"); | 8657 | DRM_DEBUG_KMS("requested mode:\n"); |
8229 | drm_mode_debug_printmodeline(&pipe_config->requested_mode); | 8658 | drm_mode_debug_printmodeline(&pipe_config->requested_mode); |
8230 | DRM_DEBUG_KMS("adjusted mode:\n"); | 8659 | DRM_DEBUG_KMS("adjusted mode:\n"); |
8231 | drm_mode_debug_printmodeline(&pipe_config->adjusted_mode); | 8660 | drm_mode_debug_printmodeline(&pipe_config->adjusted_mode); |
8661 | intel_dump_crtc_timings(&pipe_config->adjusted_mode); | ||
8662 | DRM_DEBUG_KMS("port clock: %d\n", pipe_config->port_clock); | ||
8663 | DRM_DEBUG_KMS("pipe src size: %dx%d\n", | ||
8664 | pipe_config->pipe_src_w, pipe_config->pipe_src_h); | ||
8232 | DRM_DEBUG_KMS("gmch pfit: control: 0x%08x, ratios: 0x%08x, lvds border: 0x%08x\n", | 8665 | DRM_DEBUG_KMS("gmch pfit: control: 0x%08x, ratios: 0x%08x, lvds border: 0x%08x\n", |
8233 | pipe_config->gmch_pfit.control, | 8666 | pipe_config->gmch_pfit.control, |
8234 | pipe_config->gmch_pfit.pgm_ratios, | 8667 | pipe_config->gmch_pfit.pgm_ratios, |
@@ -8238,6 +8671,7 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc, | |||
8238 | pipe_config->pch_pfit.size, | 8671 | pipe_config->pch_pfit.size, |
8239 | pipe_config->pch_pfit.enabled ? "enabled" : "disabled"); | 8672 | pipe_config->pch_pfit.enabled ? "enabled" : "disabled"); |
8240 | DRM_DEBUG_KMS("ips: %i\n", pipe_config->ips_enabled); | 8673 | DRM_DEBUG_KMS("ips: %i\n", pipe_config->ips_enabled); |
8674 | DRM_DEBUG_KMS("double wide: %i\n", pipe_config->double_wide); | ||
8241 | } | 8675 | } |
8242 | 8676 | ||
8243 | static bool check_encoder_cloning(struct drm_crtc *crtc) | 8677 | static bool check_encoder_cloning(struct drm_crtc *crtc) |
@@ -8281,6 +8715,7 @@ intel_modeset_pipe_config(struct drm_crtc *crtc, | |||
8281 | 8715 | ||
8282 | drm_mode_copy(&pipe_config->adjusted_mode, mode); | 8716 | drm_mode_copy(&pipe_config->adjusted_mode, mode); |
8283 | drm_mode_copy(&pipe_config->requested_mode, mode); | 8717 | drm_mode_copy(&pipe_config->requested_mode, mode); |
8718 | |||
8284 | pipe_config->cpu_transcoder = | 8719 | pipe_config->cpu_transcoder = |
8285 | (enum transcoder) to_intel_crtc(crtc)->pipe; | 8720 | (enum transcoder) to_intel_crtc(crtc)->pipe; |
8286 | pipe_config->shared_dpll = DPLL_ID_PRIVATE; | 8721 | pipe_config->shared_dpll = DPLL_ID_PRIVATE; |
@@ -8307,13 +8742,25 @@ intel_modeset_pipe_config(struct drm_crtc *crtc, | |||
8307 | if (plane_bpp < 0) | 8742 | if (plane_bpp < 0) |
8308 | goto fail; | 8743 | goto fail; |
8309 | 8744 | ||
8745 | /* | ||
8746 | * Determine the real pipe dimensions. Note that stereo modes can | ||
8747 | * increase the actual pipe size due to the frame doubling and | ||
8748 | * insertion of additional space for blanks between the frame. This | ||
8749 | * is stored in the crtc timings. We use the requested mode to do this | ||
8750 | * computation to clearly distinguish it from the adjusted mode, which | ||
8751 | * can be changed by the connectors in the below retry loop. | ||
8752 | */ | ||
8753 | drm_mode_set_crtcinfo(&pipe_config->requested_mode, CRTC_STEREO_DOUBLE); | ||
8754 | pipe_config->pipe_src_w = pipe_config->requested_mode.crtc_hdisplay; | ||
8755 | pipe_config->pipe_src_h = pipe_config->requested_mode.crtc_vdisplay; | ||
8756 | |||
8310 | encoder_retry: | 8757 | encoder_retry: |
8311 | /* Ensure the port clock defaults are reset when retrying. */ | 8758 | /* Ensure the port clock defaults are reset when retrying. */ |
8312 | pipe_config->port_clock = 0; | 8759 | pipe_config->port_clock = 0; |
8313 | pipe_config->pixel_multiplier = 1; | 8760 | pipe_config->pixel_multiplier = 1; |
8314 | 8761 | ||
8315 | /* Fill in default crtc timings, allow encoders to overwrite them. */ | 8762 | /* Fill in default crtc timings, allow encoders to overwrite them. */ |
8316 | drm_mode_set_crtcinfo(&pipe_config->adjusted_mode, 0); | 8763 | drm_mode_set_crtcinfo(&pipe_config->adjusted_mode, CRTC_STEREO_DOUBLE); |
8317 | 8764 | ||
8318 | /* Pass our mode to the connectors and the CRTC to give them a chance to | 8765 | /* Pass our mode to the connectors and the CRTC to give them a chance to |
8319 | * adjust it according to limitations or connector properties, and also | 8766 | * adjust it according to limitations or connector properties, and also |
@@ -8334,7 +8781,8 @@ encoder_retry: | |||
8334 | /* Set default port clock if not overwritten by the encoder. Needs to be | 8781 | /* Set default port clock if not overwritten by the encoder. Needs to be |
8335 | * done afterwards in case the encoder adjusts the mode. */ | 8782 | * done afterwards in case the encoder adjusts the mode. */ |
8336 | if (!pipe_config->port_clock) | 8783 | if (!pipe_config->port_clock) |
8337 | pipe_config->port_clock = pipe_config->adjusted_mode.clock; | 8784 | pipe_config->port_clock = pipe_config->adjusted_mode.crtc_clock |
8785 | * pipe_config->pixel_multiplier; | ||
8338 | 8786 | ||
8339 | ret = intel_crtc_compute_config(to_intel_crtc(crtc), pipe_config); | 8787 | ret = intel_crtc_compute_config(to_intel_crtc(crtc), pipe_config); |
8340 | if (ret < 0) { | 8788 | if (ret < 0) { |
@@ -8521,13 +8969,9 @@ intel_modeset_update_state(struct drm_device *dev, unsigned prepare_pipes) | |||
8521 | 8969 | ||
8522 | } | 8970 | } |
8523 | 8971 | ||
8524 | static bool intel_fuzzy_clock_check(struct intel_crtc_config *cur, | 8972 | static bool intel_fuzzy_clock_check(int clock1, int clock2) |
8525 | struct intel_crtc_config *new) | ||
8526 | { | 8973 | { |
8527 | int clock1, clock2, diff; | 8974 | int diff; |
8528 | |||
8529 | clock1 = cur->adjusted_mode.clock; | ||
8530 | clock2 = new->adjusted_mode.clock; | ||
8531 | 8975 | ||
8532 | if (clock1 == clock2) | 8976 | if (clock1 == clock2) |
8533 | return true; | 8977 | return true; |
@@ -8581,6 +9025,15 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
8581 | return false; \ | 9025 | return false; \ |
8582 | } | 9026 | } |
8583 | 9027 | ||
9028 | #define PIPE_CONF_CHECK_CLOCK_FUZZY(name) \ | ||
9029 | if (!intel_fuzzy_clock_check(current_config->name, pipe_config->name)) { \ | ||
9030 | DRM_ERROR("mismatch in " #name " " \ | ||
9031 | "(expected %i, found %i)\n", \ | ||
9032 | current_config->name, \ | ||
9033 | pipe_config->name); \ | ||
9034 | return false; \ | ||
9035 | } | ||
9036 | |||
8584 | #define PIPE_CONF_QUIRK(quirk) \ | 9037 | #define PIPE_CONF_QUIRK(quirk) \ |
8585 | ((current_config->quirks | pipe_config->quirks) & (quirk)) | 9038 | ((current_config->quirks | pipe_config->quirks) & (quirk)) |
8586 | 9039 | ||
@@ -8594,6 +9047,13 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
8594 | PIPE_CONF_CHECK_I(fdi_m_n.link_n); | 9047 | PIPE_CONF_CHECK_I(fdi_m_n.link_n); |
8595 | PIPE_CONF_CHECK_I(fdi_m_n.tu); | 9048 | PIPE_CONF_CHECK_I(fdi_m_n.tu); |
8596 | 9049 | ||
9050 | PIPE_CONF_CHECK_I(has_dp_encoder); | ||
9051 | PIPE_CONF_CHECK_I(dp_m_n.gmch_m); | ||
9052 | PIPE_CONF_CHECK_I(dp_m_n.gmch_n); | ||
9053 | PIPE_CONF_CHECK_I(dp_m_n.link_m); | ||
9054 | PIPE_CONF_CHECK_I(dp_m_n.link_n); | ||
9055 | PIPE_CONF_CHECK_I(dp_m_n.tu); | ||
9056 | |||
8597 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hdisplay); | 9057 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hdisplay); |
8598 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_htotal); | 9058 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_htotal); |
8599 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_start); | 9059 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_start); |
@@ -8624,8 +9084,8 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
8624 | DRM_MODE_FLAG_NVSYNC); | 9084 | DRM_MODE_FLAG_NVSYNC); |
8625 | } | 9085 | } |
8626 | 9086 | ||
8627 | PIPE_CONF_CHECK_I(requested_mode.hdisplay); | 9087 | PIPE_CONF_CHECK_I(pipe_src_w); |
8628 | PIPE_CONF_CHECK_I(requested_mode.vdisplay); | 9088 | PIPE_CONF_CHECK_I(pipe_src_h); |
8629 | 9089 | ||
8630 | PIPE_CONF_CHECK_I(gmch_pfit.control); | 9090 | PIPE_CONF_CHECK_I(gmch_pfit.control); |
8631 | /* pfit ratios are autocomputed by the hw on gen4+ */ | 9091 | /* pfit ratios are autocomputed by the hw on gen4+ */ |
@@ -8640,6 +9100,8 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
8640 | 9100 | ||
8641 | PIPE_CONF_CHECK_I(ips_enabled); | 9101 | PIPE_CONF_CHECK_I(ips_enabled); |
8642 | 9102 | ||
9103 | PIPE_CONF_CHECK_I(double_wide); | ||
9104 | |||
8643 | PIPE_CONF_CHECK_I(shared_dpll); | 9105 | PIPE_CONF_CHECK_I(shared_dpll); |
8644 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll); | 9106 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll); |
8645 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md); | 9107 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md); |
@@ -8649,20 +9111,17 @@ intel_pipe_config_compare(struct drm_device *dev, | |||
8649 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) | 9111 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) |
8650 | PIPE_CONF_CHECK_I(pipe_bpp); | 9112 | PIPE_CONF_CHECK_I(pipe_bpp); |
8651 | 9113 | ||
9114 | if (!IS_HASWELL(dev)) { | ||
9115 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); | ||
9116 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); | ||
9117 | } | ||
9118 | |||
8652 | #undef PIPE_CONF_CHECK_X | 9119 | #undef PIPE_CONF_CHECK_X |
8653 | #undef PIPE_CONF_CHECK_I | 9120 | #undef PIPE_CONF_CHECK_I |
8654 | #undef PIPE_CONF_CHECK_FLAGS | 9121 | #undef PIPE_CONF_CHECK_FLAGS |
9122 | #undef PIPE_CONF_CHECK_CLOCK_FUZZY | ||
8655 | #undef PIPE_CONF_QUIRK | 9123 | #undef PIPE_CONF_QUIRK |
8656 | 9124 | ||
8657 | if (!IS_HASWELL(dev)) { | ||
8658 | if (!intel_fuzzy_clock_check(current_config, pipe_config)) { | ||
8659 | DRM_ERROR("mismatch in clock (expected %d, found %d)\n", | ||
8660 | current_config->adjusted_mode.clock, | ||
8661 | pipe_config->adjusted_mode.clock); | ||
8662 | return false; | ||
8663 | } | ||
8664 | } | ||
8665 | |||
8666 | return true; | 9125 | return true; |
8667 | } | 9126 | } |
8668 | 9127 | ||
@@ -8794,9 +9253,6 @@ check_crtc_state(struct drm_device *dev) | |||
8794 | encoder->get_config(encoder, &pipe_config); | 9253 | encoder->get_config(encoder, &pipe_config); |
8795 | } | 9254 | } |
8796 | 9255 | ||
8797 | if (dev_priv->display.get_clock) | ||
8798 | dev_priv->display.get_clock(crtc, &pipe_config); | ||
8799 | |||
8800 | WARN(crtc->active != active, | 9256 | WARN(crtc->active != active, |
8801 | "crtc active state doesn't match with hw state " | 9257 | "crtc active state doesn't match with hw state " |
8802 | "(expected %i, found %i)\n", crtc->active, active); | 9258 | "(expected %i, found %i)\n", crtc->active, active); |
@@ -8871,6 +9327,18 @@ intel_modeset_check_state(struct drm_device *dev) | |||
8871 | check_shared_dpll_state(dev); | 9327 | check_shared_dpll_state(dev); |
8872 | } | 9328 | } |
8873 | 9329 | ||
9330 | void ironlake_check_encoder_dotclock(const struct intel_crtc_config *pipe_config, | ||
9331 | int dotclock) | ||
9332 | { | ||
9333 | /* | ||
9334 | * FDI already provided one idea for the dotclock. | ||
9335 | * Yell if the encoder disagrees. | ||
9336 | */ | ||
9337 | WARN(!intel_fuzzy_clock_check(pipe_config->adjusted_mode.crtc_clock, dotclock), | ||
9338 | "FDI dotclock and encoder dotclock mismatch, fdi: %i, encoder: %i\n", | ||
9339 | pipe_config->adjusted_mode.crtc_clock, dotclock); | ||
9340 | } | ||
9341 | |||
8874 | static int __intel_set_mode(struct drm_crtc *crtc, | 9342 | static int __intel_set_mode(struct drm_crtc *crtc, |
8875 | struct drm_display_mode *mode, | 9343 | struct drm_display_mode *mode, |
8876 | int x, int y, struct drm_framebuffer *fb) | 9344 | int x, int y, struct drm_framebuffer *fb) |
@@ -8883,7 +9351,7 @@ static int __intel_set_mode(struct drm_crtc *crtc, | |||
8883 | unsigned disable_pipes, prepare_pipes, modeset_pipes; | 9351 | unsigned disable_pipes, prepare_pipes, modeset_pipes; |
8884 | int ret = 0; | 9352 | int ret = 0; |
8885 | 9353 | ||
8886 | saved_mode = kmalloc(2 * sizeof(*saved_mode), GFP_KERNEL); | 9354 | saved_mode = kcalloc(2, sizeof(*saved_mode), GFP_KERNEL); |
8887 | if (!saved_mode) | 9355 | if (!saved_mode) |
8888 | return -ENOMEM; | 9356 | return -ENOMEM; |
8889 | saved_hwmode = saved_mode + 1; | 9357 | saved_hwmode = saved_mode + 1; |
@@ -9422,7 +9890,7 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) | |||
9422 | struct intel_crtc *intel_crtc; | 9890 | struct intel_crtc *intel_crtc; |
9423 | int i; | 9891 | int i; |
9424 | 9892 | ||
9425 | intel_crtc = kzalloc(sizeof(struct intel_crtc) + (INTELFB_CONN_LIMIT * sizeof(struct drm_connector *)), GFP_KERNEL); | 9893 | intel_crtc = kzalloc(sizeof(*intel_crtc), GFP_KERNEL); |
9426 | if (intel_crtc == NULL) | 9894 | if (intel_crtc == NULL) |
9427 | return; | 9895 | return; |
9428 | 9896 | ||
@@ -9451,6 +9919,18 @@ static void intel_crtc_init(struct drm_device *dev, int pipe) | |||
9451 | drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); | 9919 | drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs); |
9452 | } | 9920 | } |
9453 | 9921 | ||
9922 | enum pipe intel_get_pipe_from_connector(struct intel_connector *connector) | ||
9923 | { | ||
9924 | struct drm_encoder *encoder = connector->base.encoder; | ||
9925 | |||
9926 | WARN_ON(!mutex_is_locked(&connector->base.dev->mode_config.mutex)); | ||
9927 | |||
9928 | if (!encoder) | ||
9929 | return INVALID_PIPE; | ||
9930 | |||
9931 | return to_intel_crtc(encoder->crtc)->pipe; | ||
9932 | } | ||
9933 | |||
9454 | int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, | 9934 | int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, |
9455 | struct drm_file *file) | 9935 | struct drm_file *file) |
9456 | { | 9936 | { |
@@ -9466,7 +9946,7 @@ int intel_get_pipe_from_crtc_id(struct drm_device *dev, void *data, | |||
9466 | 9946 | ||
9467 | if (!drmmode_obj) { | 9947 | if (!drmmode_obj) { |
9468 | DRM_ERROR("no such CRTC id\n"); | 9948 | DRM_ERROR("no such CRTC id\n"); |
9469 | return -EINVAL; | 9949 | return -ENOENT; |
9470 | } | 9950 | } |
9471 | 9951 | ||
9472 | crtc = to_intel_crtc(obj_to_crtc(drmmode_obj)); | 9952 | crtc = to_intel_crtc(obj_to_crtc(drmmode_obj)); |
@@ -9573,7 +10053,13 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
9573 | if (I915_READ(PCH_DP_D) & DP_DETECTED) | 10053 | if (I915_READ(PCH_DP_D) & DP_DETECTED) |
9574 | intel_dp_init(dev, PCH_DP_D, PORT_D); | 10054 | intel_dp_init(dev, PCH_DP_D, PORT_D); |
9575 | } else if (IS_VALLEYVIEW(dev)) { | 10055 | } else if (IS_VALLEYVIEW(dev)) { |
9576 | /* Check for built-in panel first. Shares lanes with HDMI on SDVOC */ | 10056 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) { |
10057 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB, | ||
10058 | PORT_B); | ||
10059 | if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED) | ||
10060 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B); | ||
10061 | } | ||
10062 | |||
9577 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) { | 10063 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) { |
9578 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, | 10064 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, |
9579 | PORT_C); | 10065 | PORT_C); |
@@ -9582,12 +10068,7 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
9582 | PORT_C); | 10068 | PORT_C); |
9583 | } | 10069 | } |
9584 | 10070 | ||
9585 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) { | 10071 | intel_dsi_init(dev); |
9586 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB, | ||
9587 | PORT_B); | ||
9588 | if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED) | ||
9589 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B); | ||
9590 | } | ||
9591 | } else if (SUPPORTS_DIGITAL_OUTPUTS(dev)) { | 10072 | } else if (SUPPORTS_DIGITAL_OUTPUTS(dev)) { |
9592 | bool found = false; | 10073 | bool found = false; |
9593 | 10074 | ||
@@ -9643,6 +10124,7 @@ static void intel_setup_outputs(struct drm_device *dev) | |||
9643 | void intel_framebuffer_fini(struct intel_framebuffer *fb) | 10124 | void intel_framebuffer_fini(struct intel_framebuffer *fb) |
9644 | { | 10125 | { |
9645 | drm_framebuffer_cleanup(&fb->base); | 10126 | drm_framebuffer_cleanup(&fb->base); |
10127 | WARN_ON(!fb->obj->framebuffer_references--); | ||
9646 | drm_gem_object_unreference_unlocked(&fb->obj->base); | 10128 | drm_gem_object_unreference_unlocked(&fb->obj->base); |
9647 | } | 10129 | } |
9648 | 10130 | ||
@@ -9674,9 +10156,12 @@ int intel_framebuffer_init(struct drm_device *dev, | |||
9674 | struct drm_mode_fb_cmd2 *mode_cmd, | 10156 | struct drm_mode_fb_cmd2 *mode_cmd, |
9675 | struct drm_i915_gem_object *obj) | 10157 | struct drm_i915_gem_object *obj) |
9676 | { | 10158 | { |
10159 | int aligned_height, tile_height; | ||
9677 | int pitch_limit; | 10160 | int pitch_limit; |
9678 | int ret; | 10161 | int ret; |
9679 | 10162 | ||
10163 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); | ||
10164 | |||
9680 | if (obj->tiling_mode == I915_TILING_Y) { | 10165 | if (obj->tiling_mode == I915_TILING_Y) { |
9681 | DRM_DEBUG("hardware does not support tiling Y\n"); | 10166 | DRM_DEBUG("hardware does not support tiling Y\n"); |
9682 | return -EINVAL; | 10167 | return -EINVAL; |
@@ -9765,8 +10250,16 @@ int intel_framebuffer_init(struct drm_device *dev, | |||
9765 | if (mode_cmd->offsets[0] != 0) | 10250 | if (mode_cmd->offsets[0] != 0) |
9766 | return -EINVAL; | 10251 | return -EINVAL; |
9767 | 10252 | ||
10253 | tile_height = IS_GEN2(dev) ? 16 : 8; | ||
10254 | aligned_height = ALIGN(mode_cmd->height, | ||
10255 | obj->tiling_mode ? tile_height : 1); | ||
10256 | /* FIXME drm helper for size checks (especially planar formats)? */ | ||
10257 | if (obj->base.size < aligned_height * mode_cmd->pitches[0]) | ||
10258 | return -EINVAL; | ||
10259 | |||
9768 | drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd); | 10260 | drm_helper_mode_fill_fb_struct(&intel_fb->base, mode_cmd); |
9769 | intel_fb->obj = obj; | 10261 | intel_fb->obj = obj; |
10262 | intel_fb->obj->framebuffer_references++; | ||
9770 | 10263 | ||
9771 | ret = drm_framebuffer_init(dev, &intel_fb->base, &intel_fb_funcs); | 10264 | ret = drm_framebuffer_init(dev, &intel_fb->base, &intel_fb_funcs); |
9772 | if (ret) { | 10265 | if (ret) { |
@@ -9792,9 +10285,15 @@ intel_user_framebuffer_create(struct drm_device *dev, | |||
9792 | return intel_framebuffer_create(dev, mode_cmd, obj); | 10285 | return intel_framebuffer_create(dev, mode_cmd, obj); |
9793 | } | 10286 | } |
9794 | 10287 | ||
10288 | #ifndef CONFIG_DRM_I915_FBDEV | ||
10289 | static inline void intel_fbdev_output_poll_changed(struct drm_device *dev) | ||
10290 | { | ||
10291 | } | ||
10292 | #endif | ||
10293 | |||
9795 | static const struct drm_mode_config_funcs intel_mode_funcs = { | 10294 | static const struct drm_mode_config_funcs intel_mode_funcs = { |
9796 | .fb_create = intel_user_framebuffer_create, | 10295 | .fb_create = intel_user_framebuffer_create, |
9797 | .output_poll_changed = intel_fb_output_poll_changed, | 10296 | .output_poll_changed = intel_fbdev_output_poll_changed, |
9798 | }; | 10297 | }; |
9799 | 10298 | ||
9800 | /* Set up chip specific display functions */ | 10299 | /* Set up chip specific display functions */ |
@@ -9820,7 +10319,6 @@ static void intel_init_display(struct drm_device *dev) | |||
9820 | dev_priv->display.update_plane = ironlake_update_plane; | 10319 | dev_priv->display.update_plane = ironlake_update_plane; |
9821 | } else if (HAS_PCH_SPLIT(dev)) { | 10320 | } else if (HAS_PCH_SPLIT(dev)) { |
9822 | dev_priv->display.get_pipe_config = ironlake_get_pipe_config; | 10321 | dev_priv->display.get_pipe_config = ironlake_get_pipe_config; |
9823 | dev_priv->display.get_clock = ironlake_crtc_clock_get; | ||
9824 | dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set; | 10322 | dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set; |
9825 | dev_priv->display.crtc_enable = ironlake_crtc_enable; | 10323 | dev_priv->display.crtc_enable = ironlake_crtc_enable; |
9826 | dev_priv->display.crtc_disable = ironlake_crtc_disable; | 10324 | dev_priv->display.crtc_disable = ironlake_crtc_disable; |
@@ -9828,7 +10326,6 @@ static void intel_init_display(struct drm_device *dev) | |||
9828 | dev_priv->display.update_plane = ironlake_update_plane; | 10326 | dev_priv->display.update_plane = ironlake_update_plane; |
9829 | } else if (IS_VALLEYVIEW(dev)) { | 10327 | } else if (IS_VALLEYVIEW(dev)) { |
9830 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; | 10328 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
9831 | dev_priv->display.get_clock = i9xx_crtc_clock_get; | ||
9832 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; | 10329 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; |
9833 | dev_priv->display.crtc_enable = valleyview_crtc_enable; | 10330 | dev_priv->display.crtc_enable = valleyview_crtc_enable; |
9834 | dev_priv->display.crtc_disable = i9xx_crtc_disable; | 10331 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
@@ -9836,7 +10333,6 @@ static void intel_init_display(struct drm_device *dev) | |||
9836 | dev_priv->display.update_plane = i9xx_update_plane; | 10333 | dev_priv->display.update_plane = i9xx_update_plane; |
9837 | } else { | 10334 | } else { |
9838 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; | 10335 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
9839 | dev_priv->display.get_clock = i9xx_crtc_clock_get; | ||
9840 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; | 10336 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; |
9841 | dev_priv->display.crtc_enable = i9xx_crtc_enable; | 10337 | dev_priv->display.crtc_enable = i9xx_crtc_enable; |
9842 | dev_priv->display.crtc_disable = i9xx_crtc_disable; | 10338 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
@@ -9886,7 +10382,7 @@ static void intel_init_display(struct drm_device *dev) | |||
9886 | dev_priv->display.write_eld = ironlake_write_eld; | 10382 | dev_priv->display.write_eld = ironlake_write_eld; |
9887 | dev_priv->display.modeset_global_resources = | 10383 | dev_priv->display.modeset_global_resources = |
9888 | ivb_modeset_global_resources; | 10384 | ivb_modeset_global_resources; |
9889 | } else if (IS_HASWELL(dev)) { | 10385 | } else if (IS_HASWELL(dev) || IS_GEN8(dev)) { |
9890 | dev_priv->display.fdi_link_train = hsw_fdi_link_train; | 10386 | dev_priv->display.fdi_link_train = hsw_fdi_link_train; |
9891 | dev_priv->display.write_eld = haswell_write_eld; | 10387 | dev_priv->display.write_eld = haswell_write_eld; |
9892 | dev_priv->display.modeset_global_resources = | 10388 | dev_priv->display.modeset_global_resources = |
@@ -9894,7 +10390,8 @@ static void intel_init_display(struct drm_device *dev) | |||
9894 | } | 10390 | } |
9895 | } else if (IS_G4X(dev)) { | 10391 | } else if (IS_G4X(dev)) { |
9896 | dev_priv->display.write_eld = g4x_write_eld; | 10392 | dev_priv->display.write_eld = g4x_write_eld; |
9897 | } | 10393 | } else if (IS_VALLEYVIEW(dev)) |
10394 | dev_priv->display.write_eld = ironlake_write_eld; | ||
9898 | 10395 | ||
9899 | /* Default just returns -ENODEV to indicate unsupported */ | 10396 | /* Default just returns -ENODEV to indicate unsupported */ |
9900 | dev_priv->display.queue_flip = intel_default_queue_flip; | 10397 | dev_priv->display.queue_flip = intel_default_queue_flip; |
@@ -9917,6 +10414,7 @@ static void intel_init_display(struct drm_device *dev) | |||
9917 | dev_priv->display.queue_flip = intel_gen6_queue_flip; | 10414 | dev_priv->display.queue_flip = intel_gen6_queue_flip; |
9918 | break; | 10415 | break; |
9919 | case 7: | 10416 | case 7: |
10417 | case 8: /* FIXME(BDW): Check that the gen8 RCS flip works. */ | ||
9920 | dev_priv->display.queue_flip = intel_gen7_queue_flip; | 10418 | dev_priv->display.queue_flip = intel_gen7_queue_flip; |
9921 | break; | 10419 | break; |
9922 | } | 10420 | } |
@@ -10012,8 +10510,7 @@ static struct intel_quirk intel_quirks[] = { | |||
10012 | /* ThinkPad T60 needs pipe A force quirk (bug #16494) */ | 10510 | /* ThinkPad T60 needs pipe A force quirk (bug #16494) */ |
10013 | { 0x2782, 0x17aa, 0x201a, quirk_pipea_force }, | 10511 | { 0x2782, 0x17aa, 0x201a, quirk_pipea_force }, |
10014 | 10512 | ||
10015 | /* 830/845 need to leave pipe A & dpll A up */ | 10513 | /* 830 needs to leave pipe A & dpll A up */ |
10016 | { 0x2562, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force }, | ||
10017 | { 0x3577, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force }, | 10514 | { 0x3577, PCI_ANY_ID, PCI_ANY_ID, quirk_pipea_force }, |
10018 | 10515 | ||
10019 | /* Lenovo U160 cannot use SSC on LVDS */ | 10516 | /* Lenovo U160 cannot use SSC on LVDS */ |
@@ -10022,20 +10519,11 @@ static struct intel_quirk intel_quirks[] = { | |||
10022 | /* Sony Vaio Y cannot use SSC on LVDS */ | 10519 | /* Sony Vaio Y cannot use SSC on LVDS */ |
10023 | { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, | 10520 | { 0x0046, 0x104d, 0x9076, quirk_ssc_force_disable }, |
10024 | 10521 | ||
10025 | /* Acer Aspire 5734Z must invert backlight brightness */ | 10522 | /* |
10026 | { 0x2a42, 0x1025, 0x0459, quirk_invert_brightness }, | 10523 | * All GM45 Acer (and its brands eMachines and Packard Bell) laptops |
10027 | 10524 | * seem to use inverted backlight PWM. | |
10028 | /* Acer/eMachines G725 */ | 10525 | */ |
10029 | { 0x2a42, 0x1025, 0x0210, quirk_invert_brightness }, | 10526 | { 0x2a42, 0x1025, PCI_ANY_ID, quirk_invert_brightness }, |
10030 | |||
10031 | /* Acer/eMachines e725 */ | ||
10032 | { 0x2a42, 0x1025, 0x0212, quirk_invert_brightness }, | ||
10033 | |||
10034 | /* Acer/Packard Bell NCL20 */ | ||
10035 | { 0x2a42, 0x1025, 0x034b, quirk_invert_brightness }, | ||
10036 | |||
10037 | /* Acer Aspire 4736Z */ | ||
10038 | { 0x2a42, 0x1025, 0x0260, quirk_invert_brightness }, | ||
10039 | 10527 | ||
10040 | /* Dell XPS13 HD Sandy Bridge */ | 10528 | /* Dell XPS13 HD Sandy Bridge */ |
10041 | { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable }, | 10529 | { 0x0116, 0x1028, 0x052e, quirk_no_pcm_pwm_enable }, |
@@ -10084,12 +10572,19 @@ static void i915_disable_vga(struct drm_device *dev) | |||
10084 | 10572 | ||
10085 | void intel_modeset_init_hw(struct drm_device *dev) | 10573 | void intel_modeset_init_hw(struct drm_device *dev) |
10086 | { | 10574 | { |
10087 | intel_init_power_well(dev); | 10575 | struct drm_i915_private *dev_priv = dev->dev_private; |
10088 | 10576 | ||
10089 | intel_prepare_ddi(dev); | 10577 | intel_prepare_ddi(dev); |
10090 | 10578 | ||
10091 | intel_init_clock_gating(dev); | 10579 | intel_init_clock_gating(dev); |
10092 | 10580 | ||
10581 | /* Enable the CRI clock source so we can get at the display */ | ||
10582 | if (IS_VALLEYVIEW(dev)) | ||
10583 | I915_WRITE(DPLL(PIPE_B), I915_READ(DPLL(PIPE_B)) | | ||
10584 | DPLL_INTEGRATED_CRI_CLK_VLV); | ||
10585 | |||
10586 | intel_init_dpio(dev); | ||
10587 | |||
10093 | mutex_lock(&dev->struct_mutex); | 10588 | mutex_lock(&dev->struct_mutex); |
10094 | intel_enable_gt_powersave(dev); | 10589 | intel_enable_gt_powersave(dev); |
10095 | mutex_unlock(&dev->struct_mutex); | 10590 | mutex_unlock(&dev->struct_mutex); |
@@ -10357,7 +10852,7 @@ void i915_redisable_vga(struct drm_device *dev) | |||
10357 | (I915_READ(HSW_PWR_WELL_DRIVER) & HSW_PWR_WELL_STATE_ENABLED) == 0) | 10852 | (I915_READ(HSW_PWR_WELL_DRIVER) & HSW_PWR_WELL_STATE_ENABLED) == 0) |
10358 | return; | 10853 | return; |
10359 | 10854 | ||
10360 | if (I915_READ(vga_reg) != VGA_DISP_DISABLE) { | 10855 | if (!(I915_READ(vga_reg) & VGA_DISP_DISABLE)) { |
10361 | DRM_DEBUG_KMS("Something enabled VGA plane, disabling it\n"); | 10856 | DRM_DEBUG_KMS("Something enabled VGA plane, disabling it\n"); |
10362 | i915_disable_vga(dev); | 10857 | i915_disable_vga(dev); |
10363 | } | 10858 | } |
@@ -10380,6 +10875,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) | |||
10380 | &crtc->config); | 10875 | &crtc->config); |
10381 | 10876 | ||
10382 | crtc->base.enabled = crtc->active; | 10877 | crtc->base.enabled = crtc->active; |
10878 | crtc->primary_enabled = crtc->active; | ||
10383 | 10879 | ||
10384 | DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", | 10880 | DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n", |
10385 | crtc->base.base.id, | 10881 | crtc->base.base.id, |
@@ -10420,20 +10916,11 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev) | |||
10420 | } | 10916 | } |
10421 | 10917 | ||
10422 | encoder->connectors_active = false; | 10918 | encoder->connectors_active = false; |
10423 | DRM_DEBUG_KMS("[ENCODER:%d:%s] hw state readout: %s, pipe=%i\n", | 10919 | DRM_DEBUG_KMS("[ENCODER:%d:%s] hw state readout: %s, pipe %c\n", |
10424 | encoder->base.base.id, | 10920 | encoder->base.base.id, |
10425 | drm_get_encoder_name(&encoder->base), | 10921 | drm_get_encoder_name(&encoder->base), |
10426 | encoder->base.crtc ? "enabled" : "disabled", | 10922 | encoder->base.crtc ? "enabled" : "disabled", |
10427 | pipe); | 10923 | pipe_name(pipe)); |
10428 | } | ||
10429 | |||
10430 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, | ||
10431 | base.head) { | ||
10432 | if (!crtc->active) | ||
10433 | continue; | ||
10434 | if (dev_priv->display.get_clock) | ||
10435 | dev_priv->display.get_clock(crtc, | ||
10436 | &crtc->config); | ||
10437 | } | 10924 | } |
10438 | 10925 | ||
10439 | list_for_each_entry(connector, &dev->mode_config.connector_list, | 10926 | list_for_each_entry(connector, &dev->mode_config.connector_list, |
@@ -10460,7 +10947,6 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, | |||
10460 | { | 10947 | { |
10461 | struct drm_i915_private *dev_priv = dev->dev_private; | 10948 | struct drm_i915_private *dev_priv = dev->dev_private; |
10462 | enum pipe pipe; | 10949 | enum pipe pipe; |
10463 | struct drm_plane *plane; | ||
10464 | struct intel_crtc *crtc; | 10950 | struct intel_crtc *crtc; |
10465 | struct intel_encoder *encoder; | 10951 | struct intel_encoder *encoder; |
10466 | int i; | 10952 | int i; |
@@ -10507,7 +10993,12 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, | |||
10507 | pll->on = false; | 10993 | pll->on = false; |
10508 | } | 10994 | } |
10509 | 10995 | ||
10996 | if (IS_HASWELL(dev)) | ||
10997 | ilk_wm_get_hw_state(dev); | ||
10998 | |||
10510 | if (force_restore) { | 10999 | if (force_restore) { |
11000 | i915_redisable_vga(dev); | ||
11001 | |||
10511 | /* | 11002 | /* |
10512 | * We need to use raw interfaces for restoring state to avoid | 11003 | * We need to use raw interfaces for restoring state to avoid |
10513 | * checking (bogus) intermediate states. | 11004 | * checking (bogus) intermediate states. |
@@ -10519,10 +11010,6 @@ void intel_modeset_setup_hw_state(struct drm_device *dev, | |||
10519 | __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, | 11010 | __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, |
10520 | crtc->fb); | 11011 | crtc->fb); |
10521 | } | 11012 | } |
10522 | list_for_each_entry(plane, &dev->mode_config.plane_list, head) | ||
10523 | intel_plane_restore(plane); | ||
10524 | |||
10525 | i915_redisable_vga(dev); | ||
10526 | } else { | 11013 | } else { |
10527 | intel_modeset_update_staged_output_state(dev); | 11014 | intel_modeset_update_staged_output_state(dev); |
10528 | } | 11015 | } |
@@ -10545,6 +11032,7 @@ void intel_modeset_cleanup(struct drm_device *dev) | |||
10545 | { | 11032 | { |
10546 | struct drm_i915_private *dev_priv = dev->dev_private; | 11033 | struct drm_i915_private *dev_priv = dev->dev_private; |
10547 | struct drm_crtc *crtc; | 11034 | struct drm_crtc *crtc; |
11035 | struct drm_connector *connector; | ||
10548 | 11036 | ||
10549 | /* | 11037 | /* |
10550 | * Interrupts and polling as the first thing to avoid creating havoc. | 11038 | * Interrupts and polling as the first thing to avoid creating havoc. |
@@ -10585,6 +11073,10 @@ void intel_modeset_cleanup(struct drm_device *dev) | |||
10585 | /* destroy backlight, if any, before the connectors */ | 11073 | /* destroy backlight, if any, before the connectors */ |
10586 | intel_panel_destroy_backlight(dev); | 11074 | intel_panel_destroy_backlight(dev); |
10587 | 11075 | ||
11076 | /* destroy the sysfs files before encoders/connectors */ | ||
11077 | list_for_each_entry(connector, &dev->mode_config.connector_list, head) | ||
11078 | drm_sysfs_connector_remove(connector); | ||
11079 | |||
10588 | drm_mode_config_cleanup(dev); | 11080 | drm_mode_config_cleanup(dev); |
10589 | 11081 | ||
10590 | intel_cleanup_overlay(dev); | 11082 | intel_cleanup_overlay(dev); |
@@ -10680,7 +11172,7 @@ intel_display_capture_error_state(struct drm_device *dev) | |||
10680 | if (INTEL_INFO(dev)->num_pipes == 0) | 11172 | if (INTEL_INFO(dev)->num_pipes == 0) |
10681 | return NULL; | 11173 | return NULL; |
10682 | 11174 | ||
10683 | error = kmalloc(sizeof(*error), GFP_ATOMIC); | 11175 | error = kzalloc(sizeof(*error), GFP_ATOMIC); |
10684 | if (error == NULL) | 11176 | if (error == NULL) |
10685 | return NULL; | 11177 | return NULL; |
10686 | 11178 | ||
@@ -10688,6 +11180,9 @@ intel_display_capture_error_state(struct drm_device *dev) | |||
10688 | error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER); | 11180 | error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER); |
10689 | 11181 | ||
10690 | for_each_pipe(i) { | 11182 | for_each_pipe(i) { |
11183 | if (!intel_display_power_enabled(dev, POWER_DOMAIN_PIPE(i))) | ||
11184 | continue; | ||
11185 | |||
10691 | if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) { | 11186 | if (INTEL_INFO(dev)->gen <= 6 || IS_VALLEYVIEW(dev)) { |
10692 | error->cursor[i].control = I915_READ(CURCNTR(i)); | 11187 | error->cursor[i].control = I915_READ(CURCNTR(i)); |
10693 | error->cursor[i].position = I915_READ(CURPOS(i)); | 11188 | error->cursor[i].position = I915_READ(CURPOS(i)); |
@@ -10721,6 +11216,10 @@ intel_display_capture_error_state(struct drm_device *dev) | |||
10721 | for (i = 0; i < error->num_transcoders; i++) { | 11216 | for (i = 0; i < error->num_transcoders; i++) { |
10722 | enum transcoder cpu_transcoder = transcoders[i]; | 11217 | enum transcoder cpu_transcoder = transcoders[i]; |
10723 | 11218 | ||
11219 | if (!intel_display_power_enabled(dev, | ||
11220 | POWER_DOMAIN_TRANSCODER(cpu_transcoder))) | ||
11221 | continue; | ||
11222 | |||
10724 | error->transcoder[i].cpu_transcoder = cpu_transcoder; | 11223 | error->transcoder[i].cpu_transcoder = cpu_transcoder; |
10725 | 11224 | ||
10726 | error->transcoder[i].conf = I915_READ(PIPECONF(cpu_transcoder)); | 11225 | error->transcoder[i].conf = I915_READ(PIPECONF(cpu_transcoder)); |
@@ -10732,12 +11231,6 @@ intel_display_capture_error_state(struct drm_device *dev) | |||
10732 | error->transcoder[i].vsync = I915_READ(VSYNC(cpu_transcoder)); | 11231 | error->transcoder[i].vsync = I915_READ(VSYNC(cpu_transcoder)); |
10733 | } | 11232 | } |
10734 | 11233 | ||
10735 | /* In the code above we read the registers without checking if the power | ||
10736 | * well was on, so here we have to clear the FPGA_DBG_RM_NOCLAIM bit to | ||
10737 | * prevent the next I915_WRITE from detecting it and printing an error | ||
10738 | * message. */ | ||
10739 | intel_uncore_clear_errors(dev); | ||
10740 | |||
10741 | return error; | 11234 | return error; |
10742 | } | 11235 | } |
10743 | 11236 | ||
@@ -10782,7 +11275,7 @@ intel_display_print_error_state(struct drm_i915_error_state_buf *m, | |||
10782 | } | 11275 | } |
10783 | 11276 | ||
10784 | for (i = 0; i < error->num_transcoders; i++) { | 11277 | for (i = 0; i < error->num_transcoders; i++) { |
10785 | err_printf(m, " CPU transcoder: %c\n", | 11278 | err_printf(m, "CPU transcoder: %c\n", |
10786 | transcoder_name(error->transcoder[i].cpu_transcoder)); | 11279 | transcoder_name(error->transcoder[i].cpu_transcoder)); |
10787 | err_printf(m, " CONF: %08x\n", error->transcoder[i].conf); | 11280 | err_printf(m, " CONF: %08x\n", error->transcoder[i].conf); |
10788 | err_printf(m, " HTOTAL: %08x\n", error->transcoder[i].htotal); | 11281 | err_printf(m, " HTOTAL: %08x\n", error->transcoder[i].htotal); |