Rev 5097 | Rev 5367 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 5097 | Rev 5354 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | #include |
28 | #include |
29 | //#include |
29 | //#include |
30 | #include |
30 | #include |
31 | #include |
31 | #include |
32 | #include |
32 | #include |
33 | #include |
33 | #include |
34 | #include |
34 | #include |
35 | #include |
35 | #include |
36 | #include "intel_drv.h" |
36 | #include "intel_drv.h" |
37 | #include |
37 | #include |
38 | #include "i915_drv.h" |
38 | #include "i915_drv.h" |
Line 41... | Line 41... | ||
41 | #include |
41 | #include |
42 | #include |
42 | #include |
43 | #include |
43 | #include |
44 | #include |
44 | #include |
Line 45... | Line -... | ||
45 | - | ||
46 | static inline void ndelay(unsigned long x) |
- | |
47 | { |
- | |
48 | udelay(DIV_ROUND_UP(x, 1000)); |
- | |
49 | } |
- | |
50 | 45 | ||
51 | /* Primary plane formats supported by all gen */ |
46 | /* Primary plane formats supported by all gen */ |
52 | #define COMMON_PRIMARY_FORMATS \ |
47 | #define COMMON_PRIMARY_FORMATS \ |
53 | DRM_FORMAT_C8, \ |
48 | DRM_FORMAT_C8, \ |
54 | DRM_FORMAT_RGB565, \ |
49 | DRM_FORMAT_RGB565, \ |
Line 76... | Line 71... | ||
76 | /* Cursor formats */ |
71 | /* Cursor formats */ |
77 | static const uint32_t intel_cursor_formats[] = { |
72 | static const uint32_t intel_cursor_formats[] = { |
78 | DRM_FORMAT_ARGB8888, |
73 | DRM_FORMAT_ARGB8888, |
79 | }; |
74 | }; |
Line 80... | Line -... | ||
80 | - | ||
81 | #define DIV_ROUND_CLOSEST_ULL(ll, d) \ |
- | |
82 | ({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; }) |
- | |
83 | - | ||
84 | #define MAX_ERRNO 4095 |
- | |
85 | phys_addr_t get_bus_addr(void); |
- | |
86 | - | ||
87 | static inline void outb(u8 v, u16 port) |
- | |
88 | { |
- | |
89 | asm volatile("outb %0,%1" : : "a" (v), "dN" (port)); |
- | |
90 | } |
- | |
91 | static inline u8 inb(u16 port) |
- | |
92 | { |
- | |
93 | u8 v; |
- | |
94 | asm volatile("inb %1,%0" : "=a" (v) : "dN" (port)); |
- | |
95 | return v; |
- | |
96 | } |
- | |
97 | - | ||
98 | static void intel_increase_pllclock(struct drm_device *dev, |
- | |
99 | enum pipe pipe); |
75 | |
Line 100... | Line 76... | ||
100 | void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); |
76 | void intel_crtc_update_cursor(struct drm_crtc *crtc, bool on); |
101 | 77 | ||
102 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, |
78 | static void i9xx_crtc_clock_get(struct intel_crtc *crtc, |
Line 108... | Line 84... | ||
108 | int x, int y, struct drm_framebuffer *old_fb); |
84 | int x, int y, struct drm_framebuffer *old_fb); |
109 | static int intel_framebuffer_init(struct drm_device *dev, |
85 | static int intel_framebuffer_init(struct drm_device *dev, |
110 | struct intel_framebuffer *ifb, |
86 | struct intel_framebuffer *ifb, |
111 | struct drm_mode_fb_cmd2 *mode_cmd, |
87 | struct drm_mode_fb_cmd2 *mode_cmd, |
112 | struct drm_i915_gem_object *obj); |
88 | struct drm_i915_gem_object *obj); |
113 | static void intel_dp_set_m_n(struct intel_crtc *crtc); |
- | |
114 | static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc); |
89 | static void i9xx_set_pipeconf(struct intel_crtc *intel_crtc); |
115 | static void intel_set_pipe_timings(struct intel_crtc *intel_crtc); |
90 | static void intel_set_pipe_timings(struct intel_crtc *intel_crtc); |
116 | static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc, |
91 | static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc, |
- | 92 | struct intel_link_m_n *m_n, |
|
117 | struct intel_link_m_n *m_n); |
93 | struct intel_link_m_n *m2_n2); |
118 | static void ironlake_set_pipeconf(struct drm_crtc *crtc); |
94 | static void ironlake_set_pipeconf(struct drm_crtc *crtc); |
119 | static void haswell_set_pipeconf(struct drm_crtc *crtc); |
95 | static void haswell_set_pipeconf(struct drm_crtc *crtc); |
120 | static void intel_set_pipe_csc(struct drm_crtc *crtc); |
96 | static void intel_set_pipe_csc(struct drm_crtc *crtc); |
121 | static void vlv_prepare_pll(struct intel_crtc *crtc); |
97 | static void vlv_prepare_pll(struct intel_crtc *crtc, |
- | 98 | const struct intel_crtc_config *pipe_config); |
|
- | 99 | static void chv_prepare_pll(struct intel_crtc *crtc, |
|
- | 100 | const struct intel_crtc_config *pipe_config); |
|
Line 122... | Line 101... | ||
122 | 101 | ||
123 | static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe) |
102 | static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe) |
124 | { |
103 | { |
125 | if (!connector->mst_port) |
104 | if (!connector->mst_port) |
Line 427... | Line 406... | ||
427 | } |
406 | } |
Line 428... | Line 407... | ||
428 | 407 | ||
429 | /** |
408 | /** |
430 | * Returns whether any output on the specified pipe is of the specified type |
409 | * Returns whether any output on the specified pipe is of the specified type |
431 | */ |
410 | */ |
432 | static bool intel_pipe_has_type(struct drm_crtc *crtc, int type) |
411 | bool intel_pipe_has_type(struct intel_crtc *crtc, enum intel_output_type type) |
433 | { |
412 | { |
434 | struct drm_device *dev = crtc->dev; |
413 | struct drm_device *dev = crtc->base.dev; |
Line 435... | Line 414... | ||
435 | struct intel_encoder *encoder; |
414 | struct intel_encoder *encoder; |
436 | 415 | ||
437 | for_each_encoder_on_crtc(dev, crtc, encoder) |
416 | for_each_encoder_on_crtc(dev, &crtc->base, encoder) |
Line 438... | Line 417... | ||
438 | if (encoder->type == type) |
417 | if (encoder->type == type) |
439 | return true; |
418 | return true; |
Line -... | Line 419... | ||
- | 419 | ||
- | 420 | return false; |
|
- | 421 | } |
|
- | 422 | ||
- | 423 | /** |
|
- | 424 | * Returns whether any output on the specified pipe will have the specified |
|
- | 425 | * type after a staged modeset is complete, i.e., the same as |
|
- | 426 | * intel_pipe_has_type() but looking at encoder->new_crtc instead of |
|
- | 427 | * encoder->crtc. |
|
- | 428 | */ |
|
- | 429 | static bool intel_pipe_will_have_type(struct intel_crtc *crtc, int type) |
|
- | 430 | { |
|
- | 431 | struct drm_device *dev = crtc->base.dev; |
|
- | 432 | struct intel_encoder *encoder; |
|
- | 433 | ||
- | 434 | for_each_intel_encoder(dev, encoder) |
|
- | 435 | if (encoder->new_crtc == crtc && encoder->type == type) |
|
- | 436 | return true; |
|
440 | 437 | ||
441 | return false; |
438 | return false; |
442 | } |
439 | } |
443 | 440 | ||
444 | static const intel_limit_t *intel_ironlake_limit(struct drm_crtc *crtc, |
441 | static const intel_limit_t *intel_ironlake_limit(struct intel_crtc *crtc, |
Line 445... | Line 442... | ||
445 | int refclk) |
442 | int refclk) |
446 | { |
443 | { |
447 | struct drm_device *dev = crtc->dev; |
444 | struct drm_device *dev = crtc->base.dev; |
448 | const intel_limit_t *limit; |
445 | const intel_limit_t *limit; |
449 | 446 | ||
450 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
447 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
Line 463... | Line 460... | ||
463 | limit = &intel_limits_ironlake_dac; |
460 | limit = &intel_limits_ironlake_dac; |
Line 464... | Line 461... | ||
464 | 461 | ||
465 | return limit; |
462 | return limit; |
Line 466... | Line 463... | ||
466 | } |
463 | } |
467 | 464 | ||
468 | static const intel_limit_t *intel_g4x_limit(struct drm_crtc *crtc) |
465 | static const intel_limit_t *intel_g4x_limit(struct intel_crtc *crtc) |
469 | { |
466 | { |
Line 470... | Line 467... | ||
470 | struct drm_device *dev = crtc->dev; |
467 | struct drm_device *dev = crtc->base.dev; |
471 | const intel_limit_t *limit; |
468 | const intel_limit_t *limit; |
472 | 469 | ||
473 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
470 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
474 | if (intel_is_dual_link_lvds(dev)) |
471 | if (intel_is_dual_link_lvds(dev)) |
475 | limit = &intel_limits_g4x_dual_channel_lvds; |
472 | limit = &intel_limits_g4x_dual_channel_lvds; |
476 | else |
473 | else |
477 | limit = &intel_limits_g4x_single_channel_lvds; |
474 | limit = &intel_limits_g4x_single_channel_lvds; |
478 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI) || |
475 | } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_HDMI) || |
479 | intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG)) { |
476 | intel_pipe_will_have_type(crtc, INTEL_OUTPUT_ANALOG)) { |
480 | limit = &intel_limits_g4x_hdmi; |
477 | limit = &intel_limits_g4x_hdmi; |
481 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) { |
478 | } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_SDVO)) { |
Line 482... | Line 479... | ||
482 | limit = &intel_limits_g4x_sdvo; |
479 | limit = &intel_limits_g4x_sdvo; |
483 | } else /* The option is for other outputs */ |
480 | } else /* The option is for other outputs */ |
Line 484... | Line 481... | ||
484 | limit = &intel_limits_i9xx_sdvo; |
481 | limit = &intel_limits_i9xx_sdvo; |
485 | 482 | ||
486 | return limit; |
483 | return limit; |
487 | } |
484 | } |
Line 488... | Line 485... | ||
488 | 485 | ||
489 | static const intel_limit_t *intel_limit(struct drm_crtc *crtc, int refclk) |
486 | static const intel_limit_t *intel_limit(struct intel_crtc *crtc, int refclk) |
490 | { |
487 | { |
491 | struct drm_device *dev = crtc->dev; |
488 | struct drm_device *dev = crtc->base.dev; |
492 | const intel_limit_t *limit; |
489 | const intel_limit_t *limit; |
493 | 490 | ||
494 | if (HAS_PCH_SPLIT(dev)) |
491 | if (HAS_PCH_SPLIT(dev)) |
495 | limit = intel_ironlake_limit(crtc, refclk); |
492 | limit = intel_ironlake_limit(crtc, refclk); |
496 | else if (IS_G4X(dev)) { |
493 | else if (IS_G4X(dev)) { |
497 | limit = intel_g4x_limit(crtc); |
494 | limit = intel_g4x_limit(crtc); |
498 | } else if (IS_PINEVIEW(dev)) { |
495 | } else if (IS_PINEVIEW(dev)) { |
499 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) |
496 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) |
500 | limit = &intel_limits_pineview_lvds; |
497 | limit = &intel_limits_pineview_lvds; |
501 | else |
498 | else |
502 | limit = &intel_limits_pineview_sdvo; |
499 | limit = &intel_limits_pineview_sdvo; |
503 | } else if (IS_CHERRYVIEW(dev)) { |
500 | } else if (IS_CHERRYVIEW(dev)) { |
504 | limit = &intel_limits_chv; |
501 | limit = &intel_limits_chv; |
505 | } else if (IS_VALLEYVIEW(dev)) { |
502 | } else if (IS_VALLEYVIEW(dev)) { |
506 | limit = &intel_limits_vlv; |
503 | limit = &intel_limits_vlv; |
507 | } else if (!IS_GEN2(dev)) { |
504 | } else if (!IS_GEN2(dev)) { |
508 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) |
505 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) |
509 | limit = &intel_limits_i9xx_lvds; |
506 | limit = &intel_limits_i9xx_lvds; |
510 | else |
507 | else |
511 | limit = &intel_limits_i9xx_sdvo; |
508 | limit = &intel_limits_i9xx_sdvo; |
512 | } else { |
509 | } else { |
513 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) |
510 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) |
514 | limit = &intel_limits_i8xx_lvds; |
511 | limit = &intel_limits_i8xx_lvds; |
Line 597... | Line 594... | ||
597 | 594 | ||
598 | return true; |
595 | return true; |
Line 599... | Line 596... | ||
599 | } |
596 | } |
600 | 597 | ||
601 | static bool |
598 | static bool |
602 | i9xx_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, |
599 | i9xx_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, |
603 | int target, int refclk, intel_clock_t *match_clock, |
600 | int target, int refclk, intel_clock_t *match_clock, |
604 | intel_clock_t *best_clock) |
601 | intel_clock_t *best_clock) |
605 | { |
602 | { |
606 | struct drm_device *dev = crtc->dev; |
603 | struct drm_device *dev = crtc->base.dev; |
Line 607... | Line 604... | ||
607 | intel_clock_t clock; |
604 | intel_clock_t clock; |
608 | int err = target; |
605 | int err = target; |
609 | 606 | ||
610 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
607 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
611 | /* |
608 | /* |
612 | * For LVDS just rely on its current settings for dual-channel. |
609 | * For LVDS just rely on its current settings for dual-channel. |
Line 658... | Line 655... | ||
658 | 655 | ||
659 | return (err != target); |
656 | return (err != target); |
Line 660... | Line 657... | ||
660 | } |
657 | } |
661 | 658 | ||
662 | static bool |
659 | static bool |
663 | pnv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, |
660 | pnv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, |
664 | int target, int refclk, intel_clock_t *match_clock, |
661 | int target, int refclk, intel_clock_t *match_clock, |
665 | intel_clock_t *best_clock) |
662 | intel_clock_t *best_clock) |
666 | { |
663 | { |
667 | struct drm_device *dev = crtc->dev; |
664 | struct drm_device *dev = crtc->base.dev; |
Line 668... | Line 665... | ||
668 | intel_clock_t clock; |
665 | intel_clock_t clock; |
669 | int err = target; |
666 | int err = target; |
670 | 667 | ||
671 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
668 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
672 | /* |
669 | /* |
673 | * For LVDS just rely on its current settings for dual-channel. |
670 | * For LVDS just rely on its current settings for dual-channel. |
Line 717... | Line 714... | ||
717 | 714 | ||
718 | return (err != target); |
715 | return (err != target); |
Line 719... | Line 716... | ||
719 | } |
716 | } |
720 | 717 | ||
721 | static bool |
718 | static bool |
722 | g4x_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, |
719 | g4x_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, |
723 | int target, int refclk, intel_clock_t *match_clock, |
720 | int target, int refclk, intel_clock_t *match_clock, |
724 | intel_clock_t *best_clock) |
721 | intel_clock_t *best_clock) |
725 | { |
722 | { |
726 | struct drm_device *dev = crtc->dev; |
723 | struct drm_device *dev = crtc->base.dev; |
727 | intel_clock_t clock; |
724 | intel_clock_t clock; |
728 | int max_n; |
725 | int max_n; |
729 | bool found; |
726 | bool found; |
730 | /* approximately equals target * 0.00585 */ |
727 | /* approximately equals target * 0.00585 */ |
Line 731... | Line 728... | ||
731 | int err_most = (target >> 8) + (target >> 9); |
728 | int err_most = (target >> 8) + (target >> 9); |
732 | found = false; |
729 | found = false; |
733 | 730 | ||
734 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS)) { |
731 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
735 | if (intel_is_dual_link_lvds(dev)) |
732 | if (intel_is_dual_link_lvds(dev)) |
736 | clock.p2 = limit->p2.p2_fast; |
733 | clock.p2 = limit->p2.p2_fast; |
Line 774... | Line 771... | ||
774 | } |
771 | } |
775 | return found; |
772 | return found; |
776 | } |
773 | } |
Line 777... | Line 774... | ||
777 | 774 | ||
778 | static bool |
775 | static bool |
779 | vlv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, |
776 | vlv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, |
780 | int target, int refclk, intel_clock_t *match_clock, |
777 | int target, int refclk, intel_clock_t *match_clock, |
781 | intel_clock_t *best_clock) |
778 | intel_clock_t *best_clock) |
782 | { |
779 | { |
783 | struct drm_device *dev = crtc->dev; |
780 | struct drm_device *dev = crtc->base.dev; |
784 | intel_clock_t clock; |
781 | intel_clock_t clock; |
785 | unsigned int bestppm = 1000000; |
782 | unsigned int bestppm = 1000000; |
786 | /* min update 19.2 MHz */ |
783 | /* min update 19.2 MHz */ |
787 | int max_n = min(limit->n.max, refclk / 19200); |
784 | int max_n = min(limit->n.max, refclk / 19200); |
Line 831... | Line 828... | ||
831 | 828 | ||
832 | return found; |
829 | return found; |
Line 833... | Line 830... | ||
833 | } |
830 | } |
834 | 831 | ||
835 | static bool |
832 | static bool |
836 | chv_find_best_dpll(const intel_limit_t *limit, struct drm_crtc *crtc, |
833 | chv_find_best_dpll(const intel_limit_t *limit, struct intel_crtc *crtc, |
837 | int target, int refclk, intel_clock_t *match_clock, |
834 | int target, int refclk, intel_clock_t *match_clock, |
838 | intel_clock_t *best_clock) |
835 | intel_clock_t *best_clock) |
839 | { |
836 | { |
840 | struct drm_device *dev = crtc->dev; |
837 | struct drm_device *dev = crtc->base.dev; |
841 | intel_clock_t clock; |
838 | intel_clock_t clock; |
Line 842... | Line 839... | ||
842 | uint64_t m2; |
839 | uint64_t m2; |
Line 908... | Line 905... | ||
908 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
905 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Line 909... | Line 906... | ||
909 | 906 | ||
910 | return intel_crtc->config.cpu_transcoder; |
907 | return intel_crtc->config.cpu_transcoder; |
Line 911... | Line -... | ||
911 | } |
- | |
912 | - | ||
913 | static void g4x_wait_for_vblank(struct drm_device *dev, int pipe) |
- | |
914 | { |
- | |
915 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
916 | u32 frame, frame_reg = PIPE_FRMCOUNT_GM45(pipe); |
- | |
917 | - | ||
918 | frame = I915_READ(frame_reg); |
- | |
919 | - | ||
920 | if (wait_for(I915_READ_NOTRACE(frame_reg) != frame, 50)) |
- | |
921 | WARN(1, "vblank wait timed out\n"); |
- | |
922 | } |
- | |
923 | - | ||
924 | /** |
- | |
925 | * intel_wait_for_vblank - wait for vblank on a given pipe |
- | |
926 | * @dev: drm device |
- | |
927 | * @pipe: pipe to wait for |
- | |
928 | * |
- | |
929 | * Wait for vblank to occur on a given pipe. Needed for various bits of |
- | |
930 | * mode setting code. |
- | |
931 | */ |
- | |
932 | void intel_wait_for_vblank(struct drm_device *dev, int pipe) |
- | |
933 | { |
- | |
934 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
935 | int pipestat_reg = PIPESTAT(pipe); |
- | |
936 | - | ||
937 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) { |
- | |
938 | g4x_wait_for_vblank(dev, pipe); |
- | |
939 | return; |
- | |
940 | } |
- | |
941 | - | ||
942 | /* Clear existing vblank status. Note this will clear any other |
- | |
943 | * sticky status fields as well. |
- | |
944 | * |
- | |
945 | * This races with i915_driver_irq_handler() with the result |
- | |
946 | * that either function could miss a vblank event. Here it is not |
- | |
947 | * fatal, as we will either wait upon the next vblank interrupt or |
- | |
948 | * timeout. Generally speaking intel_wait_for_vblank() is only |
- | |
949 | * called during modeset at which time the GPU should be idle and |
- | |
950 | * should *not* be performing page flips and thus not waiting on |
- | |
951 | * vblanks... |
- | |
952 | * Currently, the result of us stealing a vblank from the irq |
- | |
953 | * handler is that a single frame will be skipped during swapbuffers. |
- | |
954 | */ |
- | |
955 | I915_WRITE(pipestat_reg, |
- | |
956 | I915_READ(pipestat_reg) | PIPE_VBLANK_INTERRUPT_STATUS); |
- | |
957 | - | ||
958 | /* Wait for vblank interrupt bit to set */ |
- | |
959 | if (wait_for(I915_READ(pipestat_reg) & |
- | |
960 | PIPE_VBLANK_INTERRUPT_STATUS, |
- | |
961 | 50)) |
- | |
962 | DRM_DEBUG_KMS("vblank wait timed out\n"); |
- | |
963 | } |
908 | } |
964 | 909 | ||
965 | static bool pipe_dsl_stopped(struct drm_device *dev, enum pipe pipe) |
910 | static bool pipe_dsl_stopped(struct drm_device *dev, enum pipe pipe) |
966 | { |
911 | { |
967 | struct drm_i915_private *dev_priv = dev->dev_private; |
912 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 981... | Line 926... | ||
981 | return line1 == line2; |
926 | return line1 == line2; |
982 | } |
927 | } |
Line 983... | Line 928... | ||
983 | 928 | ||
984 | /* |
929 | /* |
985 | * intel_wait_for_pipe_off - wait for pipe to turn off |
- | |
986 | * @dev: drm device |
930 | * intel_wait_for_pipe_off - wait for pipe to turn off |
987 | * @pipe: pipe to wait for |
931 | * @crtc: crtc whose pipe to wait for |
988 | * |
932 | * |
989 | * After disabling a pipe, we can't wait for vblank in the usual way, |
933 | * After disabling a pipe, we can't wait for vblank in the usual way, |
990 | * spinning on the vblank interrupt status bit, since we won't actually |
934 | * spinning on the vblank interrupt status bit, since we won't actually |
991 | * see an interrupt when the pipe is disabled. |
935 | * see an interrupt when the pipe is disabled. |
Line 996... | Line 940... | ||
996 | * Otherwise: |
940 | * Otherwise: |
997 | * wait for the display line value to settle (it usually |
941 | * wait for the display line value to settle (it usually |
998 | * ends up stopping at the start of the next frame). |
942 | * ends up stopping at the start of the next frame). |
999 | * |
943 | * |
1000 | */ |
944 | */ |
1001 | void intel_wait_for_pipe_off(struct drm_device *dev, int pipe) |
945 | static void intel_wait_for_pipe_off(struct intel_crtc *crtc) |
1002 | { |
946 | { |
- | 947 | struct drm_device *dev = crtc->base.dev; |
|
1003 | struct drm_i915_private *dev_priv = dev->dev_private; |
948 | struct drm_i915_private *dev_priv = dev->dev_private; |
1004 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
949 | enum transcoder cpu_transcoder = crtc->config.cpu_transcoder; |
1005 | pipe); |
950 | enum pipe pipe = crtc->pipe; |
Line 1006... | Line 951... | ||
1006 | 951 | ||
1007 | if (INTEL_INFO(dev)->gen >= 4) { |
952 | if (INTEL_INFO(dev)->gen >= 4) { |
Line 1008... | Line 953... | ||
1008 | int reg = PIPECONF(cpu_transcoder); |
953 | int reg = PIPECONF(cpu_transcoder); |
Line 1206... | Line 1151... | ||
1206 | WARN(cur_state != state, |
1151 | WARN(cur_state != state, |
1207 | "FDI RX PLL assertion failure (expected %s, current %s)\n", |
1152 | "FDI RX PLL assertion failure (expected %s, current %s)\n", |
1208 | state_string(state), state_string(cur_state)); |
1153 | state_string(state), state_string(cur_state)); |
1209 | } |
1154 | } |
Line 1210... | Line 1155... | ||
1210 | 1155 | ||
1211 | static void assert_panel_unlocked(struct drm_i915_private *dev_priv, |
1156 | void assert_panel_unlocked(struct drm_i915_private *dev_priv, |
1212 | enum pipe pipe) |
1157 | enum pipe pipe) |
- | 1158 | { |
|
1213 | { |
1159 | struct drm_device *dev = dev_priv->dev; |
1214 | int pp_reg, lvds_reg; |
1160 | int pp_reg; |
1215 | u32 val; |
1161 | u32 val; |
1216 | enum pipe panel_pipe = PIPE_A; |
1162 | enum pipe panel_pipe = PIPE_A; |
Line -... | Line 1163... | ||
- | 1163 | bool locked = true; |
|
- | 1164 | ||
- | 1165 | if (WARN_ON(HAS_DDI(dev))) |
|
1217 | bool locked = true; |
1166 | return; |
- | 1167 | ||
- | 1168 | if (HAS_PCH_SPLIT(dev)) { |
|
1218 | 1169 | u32 port_sel; |
|
- | 1170 | ||
- | 1171 | pp_reg = PCH_PP_CONTROL; |
|
- | 1172 | port_sel = I915_READ(PCH_PP_ON_DELAYS) & PANEL_PORT_SELECT_MASK; |
|
- | 1173 | ||
1219 | if (HAS_PCH_SPLIT(dev_priv->dev)) { |
1174 | if (port_sel == PANEL_PORT_SELECT_LVDS && |
- | 1175 | I915_READ(PCH_LVDS) & LVDS_PIPEB_SELECT) |
|
- | 1176 | panel_pipe = PIPE_B; |
|
- | 1177 | /* XXX: else fix for eDP */ |
|
- | 1178 | } else if (IS_VALLEYVIEW(dev)) { |
|
- | 1179 | /* presumably write lock depends on pipe, not port select */ |
|
1220 | pp_reg = PCH_PP_CONTROL; |
1180 | pp_reg = VLV_PIPE_PP_CONTROL(pipe); |
1221 | lvds_reg = PCH_LVDS; |
1181 | panel_pipe = pipe; |
- | 1182 | } else { |
|
1222 | } else { |
1183 | pp_reg = PP_CONTROL; |
1223 | pp_reg = PP_CONTROL; |
1184 | if (I915_READ(LVDS) & LVDS_PIPEB_SELECT) |
Line 1224... | Line 1185... | ||
1224 | lvds_reg = LVDS; |
1185 | panel_pipe = PIPE_B; |
1225 | } |
1186 | } |
1226 | 1187 | ||
1227 | val = I915_READ(pp_reg); |
1188 | val = I915_READ(pp_reg); |
Line 1228... | Line -... | ||
1228 | if (!(val & PANEL_POWER_ON) || |
- | |
1229 | ((val & PANEL_UNLOCK_REGS) == PANEL_UNLOCK_REGS)) |
- | |
1230 | locked = false; |
- | |
1231 | 1189 | if (!(val & PANEL_POWER_ON) || |
|
1232 | if (I915_READ(lvds_reg) & LVDS_PIPEB_SELECT) |
1190 | ((val & PANEL_UNLOCK_MASK) == PANEL_UNLOCK_REGS)) |
1233 | panel_pipe = PIPE_B; |
1191 | locked = false; |
1234 | 1192 | ||
Line 1262... | Line 1220... | ||
1262 | u32 val; |
1220 | u32 val; |
1263 | bool cur_state; |
1221 | bool cur_state; |
1264 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
1222 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
1265 | pipe); |
1223 | pipe); |
Line 1266... | Line 1224... | ||
1266 | 1224 | ||
1267 | /* if we need the pipe A quirk it must be always on */ |
1225 | /* if we need the pipe quirk it must be always on */ |
- | 1226 | if ((pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || |
|
1268 | if (pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) |
1227 | (pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) |
Line 1269... | Line 1228... | ||
1269 | state = true; |
1228 | state = true; |
1270 | 1229 | ||
1271 | if (!intel_display_power_enabled(dev_priv, |
1230 | if (!intel_display_power_is_enabled(dev_priv, |
1272 | POWER_DOMAIN_TRANSCODER(cpu_transcoder))) { |
1231 | POWER_DOMAIN_TRANSCODER(cpu_transcoder))) { |
1273 | cur_state = false; |
1232 | cur_state = false; |
1274 | } else { |
1233 | } else { |
Line 1317... | Line 1276... | ||
1317 | plane_name(pipe)); |
1276 | plane_name(pipe)); |
1318 | return; |
1277 | return; |
1319 | } |
1278 | } |
Line 1320... | Line 1279... | ||
1320 | 1279 | ||
1321 | /* Need to check both planes against the pipe */ |
1280 | /* Need to check both planes against the pipe */ |
1322 | for_each_pipe(i) { |
1281 | for_each_pipe(dev_priv, i) { |
1323 | reg = DSPCNTR(i); |
1282 | reg = DSPCNTR(i); |
1324 | val = I915_READ(reg); |
1283 | val = I915_READ(reg); |
1325 | cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >> |
1284 | cur_pipe = (val & DISPPLANE_SEL_PIPE_MASK) >> |
1326 | DISPPLANE_SEL_PIPE_SHIFT; |
1285 | DISPPLANE_SEL_PIPE_SHIFT; |
Line 1335... | Line 1294... | ||
1335 | { |
1294 | { |
1336 | struct drm_device *dev = dev_priv->dev; |
1295 | struct drm_device *dev = dev_priv->dev; |
1337 | int reg, sprite; |
1296 | int reg, sprite; |
1338 | u32 val; |
1297 | u32 val; |
Line -... | Line 1298... | ||
- | 1298 | ||
- | 1299 | if (INTEL_INFO(dev)->gen >= 9) { |
|
- | 1300 | for_each_sprite(pipe, sprite) { |
|
- | 1301 | val = I915_READ(PLANE_CTL(pipe, sprite)); |
|
- | 1302 | WARN(val & PLANE_CTL_ENABLE, |
|
- | 1303 | "plane %d assertion failure, should be off on pipe %c but is still active\n", |
|
- | 1304 | sprite, pipe_name(pipe)); |
|
1339 | 1305 | } |
|
1340 | if (IS_VALLEYVIEW(dev)) { |
1306 | } else if (IS_VALLEYVIEW(dev)) { |
1341 | for_each_sprite(pipe, sprite) { |
1307 | for_each_sprite(pipe, sprite) { |
1342 | reg = SPCNTR(pipe, sprite); |
1308 | reg = SPCNTR(pipe, sprite); |
1343 | val = I915_READ(reg); |
1309 | val = I915_READ(reg); |
1344 | WARN(val & SP_ENABLE, |
1310 | WARN(val & SP_ENABLE, |
Line 1358... | Line 1324... | ||
1358 | "sprite %c assertion failure, should be off on pipe %c but is still active\n", |
1324 | "sprite %c assertion failure, should be off on pipe %c but is still active\n", |
1359 | plane_name(pipe), pipe_name(pipe)); |
1325 | plane_name(pipe), pipe_name(pipe)); |
1360 | } |
1326 | } |
1361 | } |
1327 | } |
Line -... | Line 1328... | ||
- | 1328 | ||
- | 1329 | static void assert_vblank_disabled(struct drm_crtc *crtc) |
|
- | 1330 | { |
|
- | 1331 | if (WARN_ON(drm_crtc_vblank_get(crtc) == 0)) |
|
- | 1332 | drm_crtc_vblank_put(crtc); |
|
- | 1333 | } |
|
1362 | 1334 | ||
1363 | static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv) |
1335 | static void ibx_assert_pch_refclk_enabled(struct drm_i915_private *dev_priv) |
1364 | { |
1336 | { |
1365 | u32 val; |
1337 | u32 val; |
Line 1530... | Line 1502... | ||
1530 | } else { |
1502 | } else { |
1531 | DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO; |
1503 | DPIO_PHY_IOSF_PORT(DPIO_PHY0) = IOSF_PORT_DPIO; |
1532 | } |
1504 | } |
1533 | } |
1505 | } |
Line 1534... | Line 1506... | ||
1534 | 1506 | ||
1535 | static void intel_reset_dpio(struct drm_device *dev) |
- | |
1536 | { |
- | |
1537 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
1538 | - | ||
1539 | if (IS_CHERRYVIEW(dev)) { |
- | |
1540 | enum dpio_phy phy; |
- | |
1541 | u32 val; |
- | |
1542 | - | ||
1543 | for (phy = DPIO_PHY0; phy < I915_NUM_PHYS_VLV; phy++) { |
- | |
1544 | /* Poll for phypwrgood signal */ |
- | |
1545 | if (wait_for(I915_READ(DISPLAY_PHY_STATUS) & |
- | |
1546 | PHY_POWERGOOD(phy), 1)) |
- | |
1547 | DRM_ERROR("Display PHY %d is not power up\n", phy); |
- | |
1548 | - | ||
1549 | /* |
- | |
1550 | * Deassert common lane reset for PHY. |
- | |
1551 | * |
1507 | static void vlv_enable_pll(struct intel_crtc *crtc, |
1552 | * This should only be done on init and resume from S3 |
- | |
1553 | * with both PLLs disabled, or we risk losing DPIO and |
- | |
1554 | * PLL synchronization. |
- | |
1555 | */ |
- | |
1556 | val = I915_READ(DISPLAY_PHY_CONTROL); |
- | |
1557 | I915_WRITE(DISPLAY_PHY_CONTROL, |
- | |
1558 | PHY_COM_LANE_RESET_DEASSERT(phy, val)); |
- | |
1559 | } |
- | |
1560 | } |
- | |
1561 | } |
- | |
1562 | - | ||
1563 | static void vlv_enable_pll(struct intel_crtc *crtc) |
1508 | const struct intel_crtc_config *pipe_config) |
1564 | { |
1509 | { |
1565 | struct drm_device *dev = crtc->base.dev; |
1510 | struct drm_device *dev = crtc->base.dev; |
1566 | struct drm_i915_private *dev_priv = dev->dev_private; |
1511 | struct drm_i915_private *dev_priv = dev->dev_private; |
1567 | int reg = DPLL(crtc->pipe); |
1512 | int reg = DPLL(crtc->pipe); |
Line 1568... | Line 1513... | ||
1568 | u32 dpll = crtc->config.dpll_hw_state.dpll; |
1513 | u32 dpll = pipe_config->dpll_hw_state.dpll; |
Line 1569... | Line 1514... | ||
1569 | 1514 | ||
1570 | assert_pipe_disabled(dev_priv, crtc->pipe); |
1515 | assert_pipe_disabled(dev_priv, crtc->pipe); |
Line 1571... | Line 1516... | ||
1571 | 1516 | ||
1572 | /* No really, not for ILK+ */ |
1517 | /* No really, not for ILK+ */ |
1573 | BUG_ON(!IS_VALLEYVIEW(dev_priv->dev)); |
1518 | BUG_ON(!IS_VALLEYVIEW(dev_priv->dev)); |
Line 1574... | Line 1519... | ||
1574 | 1519 | ||
1575 | /* PLL is protected by panel, make sure we can write it */ |
1520 | /* PLL is protected by panel, make sure we can write it */ |
1576 | if (IS_MOBILE(dev_priv->dev) && !IS_I830(dev_priv->dev)) |
1521 | if (IS_MOBILE(dev_priv->dev)) |
Line 1577... | Line 1522... | ||
1577 | assert_panel_unlocked(dev_priv, crtc->pipe); |
1522 | assert_panel_unlocked(dev_priv, crtc->pipe); |
1578 | 1523 | ||
Line 1579... | Line 1524... | ||
1579 | I915_WRITE(reg, dpll); |
1524 | I915_WRITE(reg, dpll); |
1580 | POSTING_READ(reg); |
1525 | POSTING_READ(reg); |
Line 1581... | Line 1526... | ||
1581 | udelay(150); |
1526 | udelay(150); |
1582 | 1527 | ||
1583 | if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) |
1528 | if (wait_for(((I915_READ(reg) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) |
Line 1596... | Line 1541... | ||
1596 | I915_WRITE(reg, dpll); |
1541 | I915_WRITE(reg, dpll); |
1597 | POSTING_READ(reg); |
1542 | POSTING_READ(reg); |
1598 | udelay(150); /* wait for warmup */ |
1543 | udelay(150); /* wait for warmup */ |
1599 | } |
1544 | } |
Line 1600... | Line 1545... | ||
1600 | 1545 | ||
- | 1546 | static void chv_enable_pll(struct intel_crtc *crtc, |
|
1601 | static void chv_enable_pll(struct intel_crtc *crtc) |
1547 | const struct intel_crtc_config *pipe_config) |
1602 | { |
1548 | { |
1603 | struct drm_device *dev = crtc->base.dev; |
1549 | struct drm_device *dev = crtc->base.dev; |
1604 | struct drm_i915_private *dev_priv = dev->dev_private; |
1550 | struct drm_i915_private *dev_priv = dev->dev_private; |
1605 | int pipe = crtc->pipe; |
1551 | int pipe = crtc->pipe; |
Line 1621... | Line 1567... | ||
1621 | * Need to wait > 100ns between dclkp clock enable bit and PLL enable. |
1567 | * Need to wait > 100ns between dclkp clock enable bit and PLL enable. |
1622 | */ |
1568 | */ |
1623 | udelay(1); |
1569 | udelay(1); |
Line 1624... | Line 1570... | ||
1624 | 1570 | ||
1625 | /* Enable PLL */ |
1571 | /* Enable PLL */ |
Line 1626... | Line 1572... | ||
1626 | I915_WRITE(DPLL(pipe), crtc->config.dpll_hw_state.dpll); |
1572 | I915_WRITE(DPLL(pipe), pipe_config->dpll_hw_state.dpll); |
1627 | 1573 | ||
1628 | /* Check PLL is locked */ |
1574 | /* Check PLL is locked */ |
Line 1629... | Line 1575... | ||
1629 | if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) |
1575 | if (wait_for(((I915_READ(DPLL(pipe)) & DPLL_LOCK_VLV) == DPLL_LOCK_VLV), 1)) |
1630 | DRM_ERROR("PLL %d failed to lock\n", pipe); |
1576 | DRM_ERROR("PLL %d failed to lock\n", pipe); |
1631 | 1577 | ||
Line 1632... | Line 1578... | ||
1632 | /* not sure when this should be written */ |
1578 | /* not sure when this should be written */ |
1633 | I915_WRITE(DPLL_MD(pipe), crtc->config.dpll_hw_state.dpll_md); |
1579 | I915_WRITE(DPLL_MD(pipe), pipe_config->dpll_hw_state.dpll_md); |
Line -... | Line 1580... | ||
- | 1580 | POSTING_READ(DPLL_MD(pipe)); |
|
- | 1581 | ||
- | 1582 | mutex_unlock(&dev_priv->dpio_lock); |
|
- | 1583 | } |
|
- | 1584 | ||
- | 1585 | static int intel_num_dvo_pipes(struct drm_device *dev) |
|
- | 1586 | { |
|
- | 1587 | struct intel_crtc *crtc; |
|
- | 1588 | int count = 0; |
|
- | 1589 | ||
- | 1590 | for_each_intel_crtc(dev, crtc) |
|
- | 1591 | count += crtc->active && |
|
1634 | POSTING_READ(DPLL_MD(pipe)); |
1592 | intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO); |
1635 | 1593 | ||
1636 | mutex_unlock(&dev_priv->dpio_lock); |
1594 | return count; |
1637 | } |
1595 | } |
1638 | 1596 | ||
Line 1650... | Line 1608... | ||
1650 | 1608 | ||
1651 | /* PLL is protected by panel, make sure we can write it */ |
1609 | /* PLL is protected by panel, make sure we can write it */ |
1652 | if (IS_MOBILE(dev) && !IS_I830(dev)) |
1610 | if (IS_MOBILE(dev) && !IS_I830(dev)) |
Line -... | Line 1611... | ||
- | 1611 | assert_panel_unlocked(dev_priv, crtc->pipe); |
|
- | 1612 | ||
- | 1613 | /* Enable DVO 2x clock on both PLLs if necessary */ |
|
- | 1614 | if (IS_I830(dev) && intel_num_dvo_pipes(dev) > 0) { |
|
- | 1615 | /* |
|
- | 1616 | * It appears to be important that we don't enable this |
|
- | 1617 | * for the current pipe before otherwise configuring the |
|
- | 1618 | * PLL. No idea how this should be handled if multiple |
|
- | 1619 | * DVO outputs are enabled simultaneosly. |
|
1653 | assert_panel_unlocked(dev_priv, crtc->pipe); |
1620 | */ |
- | 1621 | dpll |= DPLL_DVO_2X_MODE; |
|
- | 1622 | I915_WRITE(DPLL(!crtc->pipe), |
|
Line 1654... | Line 1623... | ||
1654 | 1623 | I915_READ(DPLL(!crtc->pipe)) | DPLL_DVO_2X_MODE); |
|
1655 | I915_WRITE(reg, dpll); |
1624 | } |
1656 | 1625 | ||
Line 1689... | Line 1658... | ||
1689 | * |
1658 | * |
1690 | * Disable the PLL for @pipe, making sure the pipe is off first. |
1659 | * Disable the PLL for @pipe, making sure the pipe is off first. |
1691 | * |
1660 | * |
1692 | * Note! This is for pre-ILK only. |
1661 | * Note! This is for pre-ILK only. |
1693 | */ |
1662 | */ |
1694 | static void i9xx_disable_pll(struct drm_i915_private *dev_priv, enum pipe pipe) |
1663 | static void i9xx_disable_pll(struct intel_crtc *crtc) |
1695 | { |
1664 | { |
- | 1665 | struct drm_device *dev = crtc->base.dev; |
|
- | 1666 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 1667 | enum pipe pipe = crtc->pipe; |
|
- | 1668 | ||
- | 1669 | /* Disable DVO 2x clock on both PLLs if necessary */ |
|
- | 1670 | if (IS_I830(dev) && |
|
- | 1671 | intel_pipe_has_type(crtc, INTEL_OUTPUT_DVO) && |
|
- | 1672 | intel_num_dvo_pipes(dev) == 1) { |
|
- | 1673 | I915_WRITE(DPLL(PIPE_B), |
|
- | 1674 | I915_READ(DPLL(PIPE_B)) & ~DPLL_DVO_2X_MODE); |
|
- | 1675 | I915_WRITE(DPLL(PIPE_A), |
|
- | 1676 | I915_READ(DPLL(PIPE_A)) & ~DPLL_DVO_2X_MODE); |
|
- | 1677 | } |
|
- | 1678 | ||
1696 | /* Don't disable pipe A or pipe A PLLs if needed */ |
1679 | /* Don't disable pipe or pipe PLLs if needed */ |
1697 | if (pipe == PIPE_A && (dev_priv->quirks & QUIRK_PIPEA_FORCE)) |
1680 | if ((pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || |
- | 1681 | (pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) |
|
1698 | return; |
1682 | return; |
Line 1699... | Line 1683... | ||
1699 | 1683 | ||
1700 | /* Make sure the pipe isn't still relying on us */ |
1684 | /* Make sure the pipe isn't still relying on us */ |
Line 1729... | Line 1713... | ||
1729 | 1713 | ||
1730 | /* Make sure the pipe isn't still relying on us */ |
1714 | /* Make sure the pipe isn't still relying on us */ |
Line 1731... | Line 1715... | ||
1731 | assert_pipe_disabled(dev_priv, pipe); |
1715 | assert_pipe_disabled(dev_priv, pipe); |
1732 | 1716 | ||
1733 | /* Set PLL en = 0 */ |
1717 | /* Set PLL en = 0 */ |
1734 | val = DPLL_SSC_REF_CLOCK_CHV; |
1718 | val = DPLL_SSC_REF_CLOCK_CHV | DPLL_REFA_CLK_ENABLE_VLV; |
1735 | if (pipe != PIPE_A) |
1719 | if (pipe != PIPE_A) |
1736 | val |= DPLL_INTEGRATED_CRI_CLK_VLV; |
1720 | val |= DPLL_INTEGRATED_CRI_CLK_VLV; |
Line 1793... | Line 1777... | ||
1793 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
1777 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
Line 1794... | Line 1778... | ||
1794 | 1778 | ||
1795 | if (WARN_ON(pll == NULL)) |
1779 | if (WARN_ON(pll == NULL)) |
Line 1796... | Line 1780... | ||
1796 | return; |
1780 | return; |
1797 | 1781 | ||
1798 | WARN_ON(!pll->refcount); |
1782 | WARN_ON(!pll->config.crtc_mask); |
1799 | if (pll->active == 0) { |
1783 | if (pll->active == 0) { |
1800 | DRM_DEBUG_DRIVER("setting up %s\n", pll->name); |
1784 | DRM_DEBUG_DRIVER("setting up %s\n", pll->name); |
Line 1820... | Line 1804... | ||
1820 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
1804 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
Line 1821... | Line 1805... | ||
1821 | 1805 | ||
1822 | if (WARN_ON(pll == NULL)) |
1806 | if (WARN_ON(pll == NULL)) |
Line 1823... | Line 1807... | ||
1823 | return; |
1807 | return; |
1824 | 1808 | ||
Line 1825... | Line 1809... | ||
1825 | if (WARN_ON(pll->refcount == 0)) |
1809 | if (WARN_ON(pll->config.crtc_mask == 0)) |
1826 | return; |
1810 | return; |
1827 | 1811 | ||
Line 1841... | Line 1825... | ||
1841 | DRM_DEBUG_KMS("enabling %s\n", pll->name); |
1825 | DRM_DEBUG_KMS("enabling %s\n", pll->name); |
1842 | pll->enable(dev_priv, pll); |
1826 | pll->enable(dev_priv, pll); |
1843 | pll->on = true; |
1827 | pll->on = true; |
1844 | } |
1828 | } |
Line 1845... | Line 1829... | ||
1845 | 1829 | ||
1846 | void intel_disable_shared_dpll(struct intel_crtc *crtc) |
1830 | static void intel_disable_shared_dpll(struct intel_crtc *crtc) |
1847 | { |
1831 | { |
1848 | struct drm_device *dev = crtc->base.dev; |
1832 | struct drm_device *dev = crtc->base.dev; |
1849 | struct drm_i915_private *dev_priv = dev->dev_private; |
1833 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 1850... | Line 1834... | ||
1850 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
1834 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
1851 | 1835 | ||
1852 | /* PCH only available on ILK+ */ |
1836 | /* PCH only available on ILK+ */ |
1853 | BUG_ON(INTEL_INFO(dev)->gen < 5); |
1837 | BUG_ON(INTEL_INFO(dev)->gen < 5); |
Line 1854... | Line 1838... | ||
1854 | if (WARN_ON(pll == NULL)) |
1838 | if (WARN_ON(pll == NULL)) |
1855 | return; |
1839 | return; |
Line 1856... | Line 1840... | ||
1856 | 1840 | ||
1857 | if (WARN_ON(pll->refcount == 0)) |
1841 | if (WARN_ON(pll->config.crtc_mask == 0)) |
1858 | return; |
1842 | return; |
Line 1885... | Line 1869... | ||
1885 | struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe]; |
1869 | struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe]; |
1886 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1870 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
1887 | uint32_t reg, val, pipeconf_val; |
1871 | uint32_t reg, val, pipeconf_val; |
Line 1888... | Line 1872... | ||
1888 | 1872 | ||
1889 | /* PCH only available on ILK+ */ |
1873 | /* PCH only available on ILK+ */ |
Line 1890... | Line 1874... | ||
1890 | BUG_ON(INTEL_INFO(dev)->gen < 5); |
1874 | BUG_ON(!HAS_PCH_SPLIT(dev)); |
1891 | 1875 | ||
1892 | /* Make sure PCH DPLL is enabled */ |
1876 | /* Make sure PCH DPLL is enabled */ |
Line 1920... | Line 1904... | ||
1920 | } |
1904 | } |
Line 1921... | Line 1905... | ||
1921 | 1905 | ||
1922 | val &= ~TRANS_INTERLACE_MASK; |
1906 | val &= ~TRANS_INTERLACE_MASK; |
1923 | if ((pipeconf_val & PIPECONF_INTERLACE_MASK) == PIPECONF_INTERLACED_ILK) |
1907 | if ((pipeconf_val & PIPECONF_INTERLACE_MASK) == PIPECONF_INTERLACED_ILK) |
1924 | if (HAS_PCH_IBX(dev_priv->dev) && |
1908 | if (HAS_PCH_IBX(dev_priv->dev) && |
1925 | intel_pipe_has_type(crtc, INTEL_OUTPUT_SDVO)) |
1909 | intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_SDVO)) |
1926 | val |= TRANS_LEGACY_INTERLACED_ILK; |
1910 | val |= TRANS_LEGACY_INTERLACED_ILK; |
1927 | else |
1911 | else |
1928 | val |= TRANS_INTERLACED; |
1912 | val |= TRANS_INTERLACED; |
1929 | else |
1913 | else |
Line 1938... | Line 1922... | ||
1938 | enum transcoder cpu_transcoder) |
1922 | enum transcoder cpu_transcoder) |
1939 | { |
1923 | { |
1940 | u32 val, pipeconf_val; |
1924 | u32 val, pipeconf_val; |
Line 1941... | Line 1925... | ||
1941 | 1925 | ||
1942 | /* PCH only available on ILK+ */ |
1926 | /* PCH only available on ILK+ */ |
Line 1943... | Line 1927... | ||
1943 | BUG_ON(INTEL_INFO(dev_priv->dev)->gen < 5); |
1927 | BUG_ON(!HAS_PCH_SPLIT(dev_priv->dev)); |
1944 | 1928 | ||
1945 | /* FDI must be feeding us bits for PCH ports */ |
1929 | /* FDI must be feeding us bits for PCH ports */ |
Line 2043... | Line 2027... | ||
2043 | * A pipe without a PLL won't actually be able to drive bits from |
2027 | * A pipe without a PLL won't actually be able to drive bits from |
2044 | * a plane. On ILK+ the pipe PLLs are integrated, so we don't |
2028 | * a plane. On ILK+ the pipe PLLs are integrated, so we don't |
2045 | * need the check. |
2029 | * need the check. |
2046 | */ |
2030 | */ |
2047 | if (!HAS_PCH_SPLIT(dev_priv->dev)) |
2031 | if (!HAS_PCH_SPLIT(dev_priv->dev)) |
2048 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DSI)) |
2032 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) |
2049 | assert_dsi_pll_enabled(dev_priv); |
2033 | assert_dsi_pll_enabled(dev_priv); |
2050 | else |
2034 | else |
2051 | assert_pll_enabled(dev_priv, pipe); |
2035 | assert_pll_enabled(dev_priv, pipe); |
2052 | else { |
2036 | else { |
2053 | if (crtc->config.has_pch_encoder) { |
2037 | if (crtc->config.has_pch_encoder) { |
Line 2060... | Line 2044... | ||
2060 | } |
2044 | } |
Line 2061... | Line 2045... | ||
2061 | 2045 | ||
2062 | reg = PIPECONF(cpu_transcoder); |
2046 | reg = PIPECONF(cpu_transcoder); |
2063 | val = I915_READ(reg); |
2047 | val = I915_READ(reg); |
2064 | if (val & PIPECONF_ENABLE) { |
2048 | if (val & PIPECONF_ENABLE) { |
2065 | WARN_ON(!(pipe == PIPE_A && |
2049 | WARN_ON(!((pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || |
2066 | dev_priv->quirks & QUIRK_PIPEA_FORCE)); |
2050 | (pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE))); |
2067 | return; |
2051 | return; |
Line 2068... | Line 2052... | ||
2068 | } |
2052 | } |
2069 | 2053 | ||
2070 | I915_WRITE(reg, val | PIPECONF_ENABLE); |
2054 | I915_WRITE(reg, val | PIPECONF_ENABLE); |
Line 2071... | Line 2055... | ||
2071 | POSTING_READ(reg); |
2055 | POSTING_READ(reg); |
2072 | } |
2056 | } |
2073 | - | ||
2074 | /** |
2057 | |
2075 | * intel_disable_pipe - disable a pipe, asserting requirements |
- | |
2076 | * @dev_priv: i915 private structure |
- | |
2077 | * @pipe: pipe to disable |
- | |
2078 | * |
2058 | /** |
- | 2059 | * intel_disable_pipe - disable a pipe, asserting requirements |
|
- | 2060 | * @crtc: crtc whose pipes is to be disabled |
|
2079 | * Disable @pipe, making sure that various hardware specific requirements |
2061 | * |
2080 | * are met, if applicable, e.g. plane disabled, panel fitter off, etc. |
2062 | * Disable the pipe of @crtc, making sure that various hardware |
2081 | * |
2063 | * specific requirements are met, if applicable, e.g. plane |
2082 | * @pipe should be %PIPE_A or %PIPE_B. |
2064 | * disabled, panel fitter off, etc. |
2083 | * |
2065 | * |
2084 | * Will wait until the pipe has shut down before returning. |
- | |
2085 | */ |
2066 | * Will wait until the pipe has shut down before returning. |
- | 2067 | */ |
|
2086 | static void intel_disable_pipe(struct drm_i915_private *dev_priv, |
2068 | static void intel_disable_pipe(struct intel_crtc *crtc) |
2087 | enum pipe pipe) |
2069 | { |
2088 | { |
2070 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
2089 | enum transcoder cpu_transcoder = intel_pipe_to_cpu_transcoder(dev_priv, |
2071 | enum transcoder cpu_transcoder = crtc->config.cpu_transcoder; |
Line 2090... | Line 2072... | ||
2090 | pipe); |
2072 | enum pipe pipe = crtc->pipe; |
2091 | int reg; |
2073 | int reg; |
Line 2097... | Line 2079... | ||
2097 | */ |
2079 | */ |
2098 | assert_planes_disabled(dev_priv, pipe); |
2080 | assert_planes_disabled(dev_priv, pipe); |
2099 | assert_cursor_disabled(dev_priv, pipe); |
2081 | assert_cursor_disabled(dev_priv, pipe); |
2100 | assert_sprites_disabled(dev_priv, pipe); |
2082 | assert_sprites_disabled(dev_priv, pipe); |
Line 2101... | Line -... | ||
2101 | - | ||
2102 | /* Don't disable pipe A or pipe A PLLs if needed */ |
- | |
2103 | if (pipe == PIPE_A && (dev_priv->quirks & QUIRK_PIPEA_FORCE)) |
- | |
2104 | return; |
- | |
2105 | 2083 | ||
2106 | reg = PIPECONF(cpu_transcoder); |
2084 | reg = PIPECONF(cpu_transcoder); |
2107 | val = I915_READ(reg); |
2085 | val = I915_READ(reg); |
2108 | if ((val & PIPECONF_ENABLE) == 0) |
2086 | if ((val & PIPECONF_ENABLE) == 0) |
Line -... | Line 2087... | ||
- | 2087 | return; |
|
- | 2088 | ||
- | 2089 | /* |
|
- | 2090 | * Double wide has implications for planes |
|
- | 2091 | * so best keep it disabled when not needed. |
|
- | 2092 | */ |
|
- | 2093 | if (crtc->config.double_wide) |
|
- | 2094 | val &= ~PIPECONF_DOUBLE_WIDE; |
|
- | 2095 | ||
- | 2096 | /* Don't disable pipe or pipe PLLs if needed */ |
|
2109 | return; |
2097 | if (!(pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) && |
- | 2098 | !(pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) |
|
- | 2099 | val &= ~PIPECONF_ENABLE; |
|
- | 2100 | ||
2110 | 2101 | I915_WRITE(reg, val); |
|
2111 | I915_WRITE(reg, val & ~PIPECONF_ENABLE); |
2102 | if ((val & PIPECONF_ENABLE) == 0) |
Line 2112... | Line 2103... | ||
2112 | intel_wait_for_pipe_off(dev_priv->dev, pipe); |
2103 | intel_wait_for_pipe_off(crtc); |
2113 | } |
2104 | } |
2114 | 2105 | ||
Line 2126... | Line 2117... | ||
2126 | POSTING_READ(reg); |
2117 | POSTING_READ(reg); |
2127 | } |
2118 | } |
Line 2128... | Line 2119... | ||
2128 | 2119 | ||
2129 | /** |
2120 | /** |
2130 | * intel_enable_primary_hw_plane - enable the primary plane on a given pipe |
- | |
2131 | * @dev_priv: i915 private structure |
2121 | * intel_enable_primary_hw_plane - enable the primary plane on a given pipe |
2132 | * @plane: plane to enable |
2122 | * @plane: plane to be enabled |
2133 | * @pipe: pipe being fed |
2123 | * @crtc: crtc for the plane |
2134 | * |
2124 | * |
2135 | * Enable @plane on @pipe, making sure that @pipe is running first. |
2125 | * Enable @plane on @crtc, making sure that the pipe is running first. |
2136 | */ |
2126 | */ |
2137 | static void intel_enable_primary_hw_plane(struct drm_i915_private *dev_priv, |
2127 | static void intel_enable_primary_hw_plane(struct drm_plane *plane, |
2138 | enum plane plane, enum pipe pipe) |
2128 | struct drm_crtc *crtc) |
2139 | { |
2129 | { |
2140 | struct drm_device *dev = dev_priv->dev; |
2130 | struct drm_device *dev = plane->dev; |
2141 | struct intel_crtc *intel_crtc = |
2131 | struct drm_i915_private *dev_priv = dev->dev_private; |
2142 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
- | |
2143 | int reg; |
- | |
Line 2144... | Line 2132... | ||
2144 | u32 val; |
2132 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2145 | 2133 | ||
Line 2146... | Line 2134... | ||
2146 | /* If the pipe isn't enabled, we can't pump pixels and may hang */ |
2134 | /* If the pipe isn't enabled, we can't pump pixels and may hang */ |
2147 | assert_pipe_enabled(dev_priv, pipe); |
2135 | assert_pipe_enabled(dev_priv, intel_crtc->pipe); |
Line 2148... | Line 2136... | ||
2148 | 2136 | ||
Line 2149... | Line 2137... | ||
2149 | if (intel_crtc->primary_enabled) |
2137 | if (intel_crtc->primary_enabled) |
2150 | return; |
2138 | return; |
2151 | - | ||
Line -... | Line 2139... | ||
- | 2139 | ||
- | 2140 | intel_crtc->primary_enabled = true; |
|
2152 | intel_crtc->primary_enabled = true; |
2141 | |
- | 2142 | dev_priv->display.update_primary_plane(crtc, plane->fb, |
|
- | 2143 | crtc->x, crtc->y); |
|
- | 2144 | ||
2153 | 2145 | /* |
|
2154 | reg = DSPCNTR(plane); |
2146 | * BDW signals flip done immediately if the plane |
Line 2155... | Line 2147... | ||
2155 | val = I915_READ(reg); |
2147 | * is disabled, even if the plane enable is already |
2156 | WARN_ON(val & DISPLAY_PLANE_ENABLE); |
2148 | * armed to occur at the next vblank :( |
2157 | - | ||
2158 | I915_WRITE(reg, val | DISPLAY_PLANE_ENABLE); |
2149 | */ |
2159 | intel_flush_primary_plane(dev_priv, plane); |
2150 | if (IS_BROADWELL(dev)) |
2160 | } |
2151 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
2161 | 2152 | } |
|
2162 | /** |
2153 | |
2163 | * intel_disable_primary_hw_plane - disable the primary hardware plane |
2154 | /** |
2164 | * @dev_priv: i915 private structure |
2155 | * intel_disable_primary_hw_plane - disable the primary hardware plane |
2165 | * @plane: plane to disable |
2156 | * @plane: plane to be disabled |
2166 | * @pipe: pipe consuming the data |
2157 | * @crtc: crtc for the plane |
2167 | * |
2158 | * |
2168 | * Disable @plane; should be an independent operation. |
2159 | * Disable @plane on @crtc, making sure that the pipe is running first. |
2169 | */ |
2160 | */ |
- | 2161 | static void intel_disable_primary_hw_plane(struct drm_plane *plane, |
|
Line 2170... | Line 2162... | ||
2170 | static void intel_disable_primary_hw_plane(struct drm_i915_private *dev_priv, |
2162 | struct drm_crtc *crtc) |
2171 | enum plane plane, enum pipe pipe) |
2163 | { |
Line 2172... | Line 2164... | ||
2172 | { |
2164 | struct drm_device *dev = plane->dev; |
Line 2173... | Line -... | ||
2173 | struct intel_crtc *intel_crtc = |
- | |
2174 | to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
- | |
2175 | int reg; |
2165 | struct drm_i915_private *dev_priv = dev->dev_private; |
2176 | u32 val; |
- | |
2177 | - | ||
2178 | if (!intel_crtc->primary_enabled) |
2166 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2179 | return; |
2167 | |
Line 2180... | Line 2168... | ||
2180 | 2168 | assert_pipe_enabled(dev_priv, intel_crtc->pipe); |
|
2181 | intel_crtc->primary_enabled = false; |
2169 | |
2182 | 2170 | if (!intel_crtc->primary_enabled) |
|
Line 2204... | Line 2192... | ||
2204 | tile_height = tiled ? (IS_GEN2(dev) ? 16 : 8) : 1; |
2192 | tile_height = tiled ? (IS_GEN2(dev) ? 16 : 8) : 1; |
2205 | return ALIGN(height, tile_height); |
2193 | return ALIGN(height, tile_height); |
2206 | } |
2194 | } |
Line 2207... | Line 2195... | ||
2207 | 2195 | ||
2208 | int |
2196 | int |
2209 | intel_pin_and_fence_fb_obj(struct drm_device *dev, |
2197 | intel_pin_and_fence_fb_obj(struct drm_plane *plane, |
2210 | struct drm_i915_gem_object *obj, |
2198 | struct drm_framebuffer *fb, |
2211 | struct intel_engine_cs *pipelined) |
2199 | struct intel_engine_cs *pipelined) |
- | 2200 | { |
|
2212 | { |
2201 | struct drm_device *dev = fb->dev; |
- | 2202 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
2213 | struct drm_i915_private *dev_priv = dev->dev_private; |
2203 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
2214 | u32 alignment; |
2204 | u32 alignment; |
Line 2215... | Line 2205... | ||
2215 | int ret; |
2205 | int ret; |
Line 2216... | Line 2206... | ||
2216 | 2206 | ||
2217 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); |
2207 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); |
- | 2208 | ||
- | 2209 | switch (obj->tiling_mode) { |
|
2218 | 2210 | case I915_TILING_NONE: |
|
2219 | switch (obj->tiling_mode) { |
2211 | if (INTEL_INFO(dev)->gen >= 9) |
2220 | case I915_TILING_NONE: |
2212 | alignment = 256 * 1024; |
2221 | if (IS_BROADWATER(dev) || IS_CRESTLINE(dev)) |
2213 | else if (IS_BROADWATER(dev) || IS_CRESTLINE(dev)) |
2222 | alignment = 128 * 1024; |
2214 | alignment = 128 * 1024; |
2223 | else if (INTEL_INFO(dev)->gen >= 4) |
2215 | else if (INTEL_INFO(dev)->gen >= 4) |
2224 | alignment = 4 * 1024; |
2216 | alignment = 4 * 1024; |
2225 | else |
2217 | else |
- | 2218 | alignment = 64 * 1024; |
|
- | 2219 | break; |
|
- | 2220 | case I915_TILING_X: |
|
2226 | alignment = 64 * 1024; |
2221 | if (INTEL_INFO(dev)->gen >= 9) |
2227 | break; |
2222 | alignment = 256 * 1024; |
- | 2223 | else { |
|
2228 | case I915_TILING_X: |
2224 | /* pin() will align the object as required by fence */ |
2229 | /* pin() will align the object as required by fence */ |
2225 | alignment = 0; |
2230 | alignment = 0; |
2226 | } |
2231 | break; |
2227 | break; |
2232 | case I915_TILING_Y: |
2228 | case I915_TILING_Y: |
Line 2387... | Line 2383... | ||
2387 | 2383 | ||
2388 | static void intel_find_plane_obj(struct intel_crtc *intel_crtc, |
2384 | static void intel_find_plane_obj(struct intel_crtc *intel_crtc, |
2389 | struct intel_plane_config *plane_config) |
2385 | struct intel_plane_config *plane_config) |
2390 | { |
2386 | { |
- | 2387 | struct drm_device *dev = intel_crtc->base.dev; |
|
2391 | struct drm_device *dev = intel_crtc->base.dev; |
2388 | struct drm_i915_private *dev_priv = dev->dev_private; |
2392 | struct drm_crtc *c; |
2389 | struct drm_crtc *c; |
2393 | struct intel_crtc *i; |
2390 | struct intel_crtc *i; |
Line 2394... | Line 2391... | ||
2394 | struct drm_i915_gem_object *obj; |
2391 | struct drm_i915_gem_object *obj; |
Line 2418... | Line 2415... | ||
2418 | obj = intel_fb_obj(c->primary->fb); |
2415 | obj = intel_fb_obj(c->primary->fb); |
2419 | if (obj == NULL) |
2416 | if (obj == NULL) |
2420 | continue; |
2417 | continue; |
Line 2421... | Line 2418... | ||
2421 | 2418 | ||
- | 2419 | if (i915_gem_obj_ggtt_offset(obj) == plane_config->base) { |
|
- | 2420 | if (obj->tiling_mode != I915_TILING_NONE) |
|
- | 2421 | dev_priv->preserve_bios_swizzle = true; |
|
2422 | if (i915_gem_obj_ggtt_offset(obj) == plane_config->base) { |
2422 | |
2423 | drm_framebuffer_reference(c->primary->fb); |
2423 | drm_framebuffer_reference(c->primary->fb); |
2424 | intel_crtc->base.primary->fb = c->primary->fb; |
2424 | intel_crtc->base.primary->fb = c->primary->fb; |
2425 | obj->frontbuffer_bits |= INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe); |
2425 | obj->frontbuffer_bits |= INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe); |
2426 | break; |
2426 | break; |
Line 2433... | Line 2433... | ||
2433 | int x, int y) |
2433 | int x, int y) |
2434 | { |
2434 | { |
2435 | struct drm_device *dev = crtc->dev; |
2435 | struct drm_device *dev = crtc->dev; |
2436 | struct drm_i915_private *dev_priv = dev->dev_private; |
2436 | struct drm_i915_private *dev_priv = dev->dev_private; |
2437 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2437 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2438 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
2438 | struct drm_i915_gem_object *obj; |
2439 | int plane = intel_crtc->plane; |
2439 | int plane = intel_crtc->plane; |
2440 | unsigned long linear_offset; |
2440 | unsigned long linear_offset; |
2441 | u32 dspcntr; |
2441 | u32 dspcntr; |
- | 2442 | u32 reg = DSPCNTR(plane); |
|
- | 2443 | int pixel_size; |
|
- | 2444 | ||
- | 2445 | if (!intel_crtc->primary_enabled) { |
|
- | 2446 | I915_WRITE(reg, 0); |
|
- | 2447 | if (INTEL_INFO(dev)->gen >= 4) |
|
- | 2448 | I915_WRITE(DSPSURF(plane), 0); |
|
- | 2449 | else |
|
- | 2450 | I915_WRITE(DSPADDR(plane), 0); |
|
- | 2451 | POSTING_READ(reg); |
|
2442 | u32 reg; |
2452 | return; |
- | 2453 | } |
|
- | 2454 | ||
- | 2455 | obj = intel_fb_obj(fb); |
|
- | 2456 | if (WARN_ON(obj == NULL)) |
|
- | 2457 | return; |
|
- | 2458 | ||
- | 2459 | pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
|
- | 2460 | ||
- | 2461 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
|
- | 2462 | ||
- | 2463 | dspcntr |= DISPLAY_PLANE_ENABLE; |
|
- | 2464 | ||
- | 2465 | if (INTEL_INFO(dev)->gen < 4) { |
|
- | 2466 | if (intel_crtc->pipe == PIPE_B) |
|
- | 2467 | dspcntr |= DISPPLANE_SEL_PIPE_B; |
|
- | 2468 | ||
- | 2469 | /* pipesrc and dspsize control the size that is scaled from, |
|
- | 2470 | * which should always be the user's requested size. |
|
- | 2471 | */ |
|
- | 2472 | I915_WRITE(DSPSIZE(plane), |
|
- | 2473 | ((intel_crtc->config.pipe_src_h - 1) << 16) | |
|
- | 2474 | (intel_crtc->config.pipe_src_w - 1)); |
|
- | 2475 | I915_WRITE(DSPPOS(plane), 0); |
|
- | 2476 | } else if (IS_CHERRYVIEW(dev) && plane == PLANE_B) { |
|
- | 2477 | I915_WRITE(PRIMSIZE(plane), |
|
- | 2478 | ((intel_crtc->config.pipe_src_h - 1) << 16) | |
|
- | 2479 | (intel_crtc->config.pipe_src_w - 1)); |
|
- | 2480 | I915_WRITE(PRIMPOS(plane), 0); |
|
- | 2481 | I915_WRITE(PRIMCNSTALPHA(plane), 0); |
|
- | 2482 | } |
|
Line 2443... | Line -... | ||
2443 | - | ||
2444 | reg = DSPCNTR(plane); |
- | |
2445 | dspcntr = I915_READ(reg); |
- | |
2446 | /* Mask out pixel format bits in case we change it */ |
- | |
2447 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
2483 | |
2448 | switch (fb->pixel_format) { |
2484 | switch (fb->pixel_format) { |
2449 | case DRM_FORMAT_C8: |
2485 | case DRM_FORMAT_C8: |
2450 | dspcntr |= DISPPLANE_8BPP; |
2486 | dspcntr |= DISPPLANE_8BPP; |
2451 | break; |
2487 | break; |
Line 2474... | Line 2510... | ||
2474 | break; |
2510 | break; |
2475 | default: |
2511 | default: |
2476 | BUG(); |
2512 | BUG(); |
2477 | } |
2513 | } |
Line 2478... | Line 2514... | ||
2478 | 2514 | ||
2479 | if (INTEL_INFO(dev)->gen >= 4) { |
2515 | if (INTEL_INFO(dev)->gen >= 4 && |
2480 | if (obj->tiling_mode != I915_TILING_NONE) |
2516 | obj->tiling_mode != I915_TILING_NONE) |
2481 | dspcntr |= DISPPLANE_TILED; |
- | |
2482 | else |
- | |
2483 | dspcntr &= ~DISPPLANE_TILED; |
- | |
Line 2484... | Line 2517... | ||
2484 | } |
2517 | dspcntr |= DISPPLANE_TILED; |
2485 | 2518 | ||
Line 2486... | Line -... | ||
2486 | if (IS_G4X(dev)) |
- | |
2487 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
- | |
2488 | 2519 | if (IS_G4X(dev)) |
|
Line 2489... | Line 2520... | ||
2489 | I915_WRITE(reg, dspcntr); |
2520 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
2490 | 2521 | ||
2491 | linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); |
2522 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
2492 | 2523 | ||
2493 | if (INTEL_INFO(dev)->gen >= 4) { |
2524 | if (INTEL_INFO(dev)->gen >= 4) { |
2494 | intel_crtc->dspaddr_offset = |
2525 | intel_crtc->dspaddr_offset = |
2495 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
2526 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
2496 | fb->bits_per_pixel / 8, |
2527 | pixel_size, |
2497 | fb->pitches[0]); |
2528 | fb->pitches[0]); |
Line -... | Line 2529... | ||
- | 2529 | linear_offset -= intel_crtc->dspaddr_offset; |
|
- | 2530 | } else { |
|
- | 2531 | intel_crtc->dspaddr_offset = linear_offset; |
|
- | 2532 | } |
|
- | 2533 | ||
- | 2534 | if (to_intel_plane(crtc->primary)->rotation == BIT(DRM_ROTATE_180)) { |
|
- | 2535 | dspcntr |= DISPPLANE_ROTATE_180; |
|
- | 2536 | ||
- | 2537 | x += (intel_crtc->config.pipe_src_w - 1); |
|
- | 2538 | y += (intel_crtc->config.pipe_src_h - 1); |
|
- | 2539 | ||
- | 2540 | /* Finding the last pixel of the last line of the display |
|
- | 2541 | data and adding to linear_offset*/ |
|
- | 2542 | linear_offset += |
|
- | 2543 | (intel_crtc->config.pipe_src_h - 1) * fb->pitches[0] + |
|
2498 | linear_offset -= intel_crtc->dspaddr_offset; |
2544 | (intel_crtc->config.pipe_src_w - 1) * pixel_size; |
2499 | } else { |
2545 | } |
2500 | intel_crtc->dspaddr_offset = linear_offset; |
2546 | |
2501 | } |
2547 | I915_WRITE(reg, dspcntr); |
2502 | 2548 | ||
Line 2519... | Line 2565... | ||
2519 | int x, int y) |
2565 | int x, int y) |
2520 | { |
2566 | { |
2521 | struct drm_device *dev = crtc->dev; |
2567 | struct drm_device *dev = crtc->dev; |
2522 | struct drm_i915_private *dev_priv = dev->dev_private; |
2568 | struct drm_i915_private *dev_priv = dev->dev_private; |
2523 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2569 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2524 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
2570 | struct drm_i915_gem_object *obj; |
2525 | int plane = intel_crtc->plane; |
2571 | int plane = intel_crtc->plane; |
2526 | unsigned long linear_offset; |
2572 | unsigned long linear_offset; |
2527 | u32 dspcntr; |
2573 | u32 dspcntr; |
- | 2574 | u32 reg = DSPCNTR(plane); |
|
- | 2575 | int pixel_size; |
|
- | 2576 | ||
- | 2577 | if (!intel_crtc->primary_enabled) { |
|
- | 2578 | I915_WRITE(reg, 0); |
|
- | 2579 | I915_WRITE(DSPSURF(plane), 0); |
|
- | 2580 | POSTING_READ(reg); |
|
2528 | u32 reg; |
2581 | return; |
- | 2582 | } |
|
- | 2583 | ||
- | 2584 | obj = intel_fb_obj(fb); |
|
- | 2585 | if (WARN_ON(obj == NULL)) |
|
- | 2586 | return; |
|
- | 2587 | ||
- | 2588 | pixel_size = drm_format_plane_cpp(fb->pixel_format, 0); |
|
- | 2589 | ||
- | 2590 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
|
- | 2591 | ||
- | 2592 | dspcntr |= DISPLAY_PLANE_ENABLE; |
|
- | 2593 | ||
- | 2594 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
|
- | 2595 | dspcntr |= DISPPLANE_PIPE_CSC_ENABLE; |
|
Line 2529... | Line -... | ||
2529 | - | ||
2530 | reg = DSPCNTR(plane); |
- | |
2531 | dspcntr = I915_READ(reg); |
- | |
2532 | /* Mask out pixel format bits in case we change it */ |
- | |
2533 | dspcntr &= ~DISPPLANE_PIXFORMAT_MASK; |
2596 | |
2534 | switch (fb->pixel_format) { |
2597 | switch (fb->pixel_format) { |
2535 | case DRM_FORMAT_C8: |
2598 | case DRM_FORMAT_C8: |
2536 | dspcntr |= DISPPLANE_8BPP; |
2599 | dspcntr |= DISPPLANE_8BPP; |
2537 | break; |
2600 | break; |
Line 2558... | Line 2621... | ||
2558 | BUG(); |
2621 | BUG(); |
2559 | } |
2622 | } |
Line 2560... | Line 2623... | ||
2560 | 2623 | ||
2561 | if (obj->tiling_mode != I915_TILING_NONE) |
2624 | if (obj->tiling_mode != I915_TILING_NONE) |
2562 | dspcntr |= DISPPLANE_TILED; |
- | |
2563 | else |
- | |
Line 2564... | Line 2625... | ||
2564 | dspcntr &= ~DISPPLANE_TILED; |
2625 | dspcntr |= DISPPLANE_TILED; |
2565 | - | ||
2566 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
- | |
2567 | dspcntr &= ~DISPPLANE_TRICKLE_FEED_DISABLE; |
2626 | |
Line 2568... | Line -... | ||
2568 | else |
- | |
2569 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
- | |
2570 | 2627 | if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) |
|
2571 | I915_WRITE(reg, dspcntr); |
2628 | dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; |
2572 | 2629 | ||
2573 | linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8); |
2630 | linear_offset = y * fb->pitches[0] + x * pixel_size; |
2574 | intel_crtc->dspaddr_offset = |
2631 | intel_crtc->dspaddr_offset = |
2575 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
2632 | intel_gen4_compute_page_offset(&x, &y, obj->tiling_mode, |
- | 2633 | pixel_size, |
|
- | 2634 | fb->pitches[0]); |
|
- | 2635 | linear_offset -= intel_crtc->dspaddr_offset; |
|
- | 2636 | if (to_intel_plane(crtc->primary)->rotation == BIT(DRM_ROTATE_180)) { |
|
- | 2637 | dspcntr |= DISPPLANE_ROTATE_180; |
|
- | 2638 | ||
- | 2639 | if (!IS_HASWELL(dev) && !IS_BROADWELL(dev)) { |
|
- | 2640 | x += (intel_crtc->config.pipe_src_w - 1); |
|
- | 2641 | y += (intel_crtc->config.pipe_src_h - 1); |
|
- | 2642 | ||
- | 2643 | /* Finding the last pixel of the last line of the display |
|
- | 2644 | data and adding to linear_offset*/ |
|
- | 2645 | linear_offset += |
|
- | 2646 | (intel_crtc->config.pipe_src_h - 1) * fb->pitches[0] + |
|
- | 2647 | (intel_crtc->config.pipe_src_w - 1) * pixel_size; |
|
- | 2648 | } |
|
Line 2576... | Line 2649... | ||
2576 | fb->bits_per_pixel / 8, |
2649 | } |
2577 | fb->pitches[0]); |
2650 | |
2578 | linear_offset -= intel_crtc->dspaddr_offset; |
2651 | I915_WRITE(reg, dspcntr); |
2579 | 2652 | ||
Line 2590... | Line 2663... | ||
2590 | I915_WRITE(DSPLINOFF(plane), linear_offset); |
2663 | I915_WRITE(DSPLINOFF(plane), linear_offset); |
2591 | } |
2664 | } |
2592 | POSTING_READ(reg); |
2665 | POSTING_READ(reg); |
2593 | } |
2666 | } |
Line -... | Line 2667... | ||
- | 2667 | ||
- | 2668 | static void skylake_update_primary_plane(struct drm_crtc *crtc, |
|
- | 2669 | struct drm_framebuffer *fb, |
|
- | 2670 | int x, int y) |
|
- | 2671 | { |
|
- | 2672 | struct drm_device *dev = crtc->dev; |
|
- | 2673 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 2674 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 2675 | struct intel_framebuffer *intel_fb; |
|
- | 2676 | struct drm_i915_gem_object *obj; |
|
- | 2677 | int pipe = intel_crtc->pipe; |
|
- | 2678 | u32 plane_ctl, stride; |
|
- | 2679 | ||
- | 2680 | if (!intel_crtc->primary_enabled) { |
|
- | 2681 | I915_WRITE(PLANE_CTL(pipe, 0), 0); |
|
- | 2682 | I915_WRITE(PLANE_SURF(pipe, 0), 0); |
|
- | 2683 | POSTING_READ(PLANE_CTL(pipe, 0)); |
|
- | 2684 | return; |
|
- | 2685 | } |
|
- | 2686 | ||
- | 2687 | plane_ctl = PLANE_CTL_ENABLE | |
|
- | 2688 | PLANE_CTL_PIPE_GAMMA_ENABLE | |
|
- | 2689 | PLANE_CTL_PIPE_CSC_ENABLE; |
|
- | 2690 | ||
- | 2691 | switch (fb->pixel_format) { |
|
- | 2692 | case DRM_FORMAT_RGB565: |
|
- | 2693 | plane_ctl |= PLANE_CTL_FORMAT_RGB_565; |
|
- | 2694 | break; |
|
- | 2695 | case DRM_FORMAT_XRGB8888: |
|
- | 2696 | plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888; |
|
- | 2697 | break; |
|
- | 2698 | case DRM_FORMAT_XBGR8888: |
|
- | 2699 | plane_ctl |= PLANE_CTL_ORDER_RGBX; |
|
- | 2700 | plane_ctl |= PLANE_CTL_FORMAT_XRGB_8888; |
|
- | 2701 | break; |
|
- | 2702 | case DRM_FORMAT_XRGB2101010: |
|
- | 2703 | plane_ctl |= PLANE_CTL_FORMAT_XRGB_2101010; |
|
- | 2704 | break; |
|
- | 2705 | case DRM_FORMAT_XBGR2101010: |
|
- | 2706 | plane_ctl |= PLANE_CTL_ORDER_RGBX; |
|
- | 2707 | plane_ctl |= PLANE_CTL_FORMAT_XRGB_2101010; |
|
- | 2708 | break; |
|
- | 2709 | default: |
|
- | 2710 | BUG(); |
|
- | 2711 | } |
|
- | 2712 | ||
- | 2713 | intel_fb = to_intel_framebuffer(fb); |
|
- | 2714 | obj = intel_fb->obj; |
|
- | 2715 | ||
- | 2716 | /* |
|
- | 2717 | * The stride is either expressed as a multiple of 64 bytes chunks for |
|
- | 2718 | * linear buffers or in number of tiles for tiled buffers. |
|
- | 2719 | */ |
|
- | 2720 | switch (obj->tiling_mode) { |
|
- | 2721 | case I915_TILING_NONE: |
|
- | 2722 | stride = fb->pitches[0] >> 6; |
|
- | 2723 | break; |
|
- | 2724 | case I915_TILING_X: |
|
- | 2725 | plane_ctl |= PLANE_CTL_TILED_X; |
|
- | 2726 | stride = fb->pitches[0] >> 9; |
|
- | 2727 | break; |
|
- | 2728 | default: |
|
- | 2729 | BUG(); |
|
- | 2730 | } |
|
- | 2731 | ||
- | 2732 | plane_ctl |= PLANE_CTL_PLANE_GAMMA_DISABLE; |
|
- | 2733 | if (to_intel_plane(crtc->primary)->rotation == BIT(DRM_ROTATE_180)) |
|
- | 2734 | plane_ctl |= PLANE_CTL_ROTATE_180; |
|
- | 2735 | ||
- | 2736 | I915_WRITE(PLANE_CTL(pipe, 0), plane_ctl); |
|
- | 2737 | ||
- | 2738 | DRM_DEBUG_KMS("Writing base %08lX %d,%d,%d,%d pitch=%d\n", |
|
- | 2739 | i915_gem_obj_ggtt_offset(obj), |
|
- | 2740 | x, y, fb->width, fb->height, |
|
- | 2741 | fb->pitches[0]); |
|
- | 2742 | ||
- | 2743 | I915_WRITE(PLANE_POS(pipe, 0), 0); |
|
- | 2744 | I915_WRITE(PLANE_OFFSET(pipe, 0), (y << 16) | x); |
|
- | 2745 | I915_WRITE(PLANE_SIZE(pipe, 0), |
|
- | 2746 | (intel_crtc->config.pipe_src_h - 1) << 16 | |
|
- | 2747 | (intel_crtc->config.pipe_src_w - 1)); |
|
- | 2748 | I915_WRITE(PLANE_STRIDE(pipe, 0), stride); |
|
- | 2749 | I915_WRITE(PLANE_SURF(pipe, 0), i915_gem_obj_ggtt_offset(obj)); |
|
- | 2750 | ||
- | 2751 | POSTING_READ(PLANE_SURF(pipe, 0)); |
|
- | 2752 | } |
|
2594 | 2753 | ||
2595 | /* Assume fb object is pinned & idle & fenced and just update base pointers */ |
2754 | /* Assume fb object is pinned & idle & fenced and just update base pointers */ |
2596 | static int |
2755 | static int |
2597 | intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, |
2756 | intel_pipe_set_base_atomic(struct drm_crtc *crtc, struct drm_framebuffer *fb, |
2598 | int x, int y, enum mode_set_atomic state) |
2757 | int x, int y, enum mode_set_atomic state) |
2599 | { |
2758 | { |
2600 | struct drm_device *dev = crtc->dev; |
2759 | struct drm_device *dev = crtc->dev; |
Line 2601... | Line 2760... | ||
2601 | struct drm_i915_private *dev_priv = dev->dev_private; |
2760 | struct drm_i915_private *dev_priv = dev->dev_private; |
2602 | 2761 | ||
2603 | if (dev_priv->display.disable_fbc) |
- | |
Line 2604... | Line 2762... | ||
2604 | dev_priv->display.disable_fbc(dev); |
2762 | if (dev_priv->display.disable_fbc) |
Line 2605... | Line 2763... | ||
2605 | intel_increase_pllclock(dev, to_intel_crtc(crtc)->pipe); |
2763 | dev_priv->display.disable_fbc(dev); |
2606 | 2764 | ||
Line 2607... | Line 2765... | ||
2607 | dev_priv->display.update_primary_plane(crtc, fb, x, y); |
2765 | dev_priv->display.update_primary_plane(crtc, fb, x, y); |
2608 | 2766 | ||
2609 | return 0; |
2767 | return 0; |
2610 | } |
- | |
2611 | 2768 | } |
|
Line 2612... | Line -... | ||
2612 | #if 0 |
- | |
2613 | void intel_display_handle_reset(struct drm_device *dev) |
- | |
2614 | { |
- | |
2615 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
2616 | struct drm_crtc *crtc; |
- | |
2617 | - | ||
2618 | /* |
- | |
2619 | * Flips in the rings have been nuked by the reset, |
- | |
2620 | * so complete all pending flips so that user space |
- | |
2621 | * will get its events and not get stuck. |
- | |
2622 | * |
- | |
2623 | * Also update the base address of all primary |
- | |
2624 | * planes to the the last fb to make sure we're |
- | |
2625 | * showing the correct fb after a reset. |
- | |
2626 | * |
2769 | |
2627 | * Need to make two loops over the crtcs so that we |
2770 | #if 0 |
2628 | * don't try to grab a crtc mutex before the |
2771 | static void intel_complete_page_flips(struct drm_device *dev) |
Line 2629... | Line 2772... | ||
2629 | * pending_flip_queue really got woken up. |
2772 | { |
2630 | */ |
2773 | struct drm_crtc *crtc; |
2631 | 2774 | ||
- | 2775 | for_each_crtc(dev, crtc) { |
|
- | 2776 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 2777 | enum plane plane = intel_crtc->plane; |
|
- | 2778 | ||
- | 2779 | intel_prepare_page_flip(dev, plane); |
|
- | 2780 | intel_finish_page_flip_plane(dev, plane); |
|
Line 2632... | Line 2781... | ||
2632 | for_each_crtc(dev, crtc) { |
2781 | } |
2633 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2782 | } |
Line 2634... | Line 2783... | ||
2634 | enum plane plane = intel_crtc->plane; |
2783 | |
Line 2653... | Line 2802... | ||
2653 | crtc->y); |
2802 | crtc->y); |
2654 | drm_modeset_unlock(&crtc->mutex); |
2803 | drm_modeset_unlock(&crtc->mutex); |
2655 | } |
2804 | } |
2656 | } |
2805 | } |
Line -... | Line 2806... | ||
- | 2806 | ||
- | 2807 | void intel_prepare_reset(struct drm_device *dev) |
|
- | 2808 | { |
|
- | 2809 | struct drm_i915_private *dev_priv = to_i915(dev); |
|
- | 2810 | struct intel_crtc *crtc; |
|
- | 2811 | ||
- | 2812 | /* no reset support for gen2 */ |
|
- | 2813 | if (IS_GEN2(dev)) |
|
- | 2814 | return; |
|
- | 2815 | ||
- | 2816 | /* reset doesn't touch the display */ |
|
- | 2817 | if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) |
|
- | 2818 | return; |
|
- | 2819 | ||
- | 2820 | drm_modeset_lock_all(dev); |
|
- | 2821 | ||
- | 2822 | /* |
|
- | 2823 | * Disabling the crtcs gracefully seems nicer. Also the |
|
- | 2824 | * g33 docs say we should at least disable all the planes. |
|
- | 2825 | */ |
|
- | 2826 | for_each_intel_crtc(dev, crtc) { |
|
- | 2827 | if (crtc->active) |
|
- | 2828 | dev_priv->display.crtc_disable(&crtc->base); |
|
- | 2829 | } |
|
- | 2830 | } |
|
- | 2831 | ||
- | 2832 | void intel_finish_reset(struct drm_device *dev) |
|
- | 2833 | { |
|
- | 2834 | struct drm_i915_private *dev_priv = to_i915(dev); |
|
- | 2835 | ||
- | 2836 | /* |
|
- | 2837 | * Flips in the rings will be nuked by the reset, |
|
- | 2838 | * so complete all pending flips so that user space |
|
- | 2839 | * will get its events and not get stuck. |
|
- | 2840 | */ |
|
- | 2841 | intel_complete_page_flips(dev); |
|
- | 2842 | ||
- | 2843 | /* no reset support for gen2 */ |
|
- | 2844 | if (IS_GEN2(dev)) |
|
- | 2845 | return; |
|
- | 2846 | ||
- | 2847 | /* reset doesn't touch the display */ |
|
- | 2848 | if (INTEL_INFO(dev)->gen >= 5 || IS_G4X(dev)) { |
|
- | 2849 | /* |
|
- | 2850 | * Flips in the rings have been nuked by the reset, |
|
- | 2851 | * so update the base address of all primary |
|
- | 2852 | * planes to the the last fb to make sure we're |
|
- | 2853 | * showing the correct fb after a reset. |
|
- | 2854 | */ |
|
- | 2855 | intel_update_primary_planes(dev); |
|
- | 2856 | return; |
|
- | 2857 | } |
|
- | 2858 | ||
- | 2859 | /* |
|
- | 2860 | * The display has been reset as well, |
|
- | 2861 | * so need a full re-initialization. |
|
- | 2862 | */ |
|
- | 2863 | intel_runtime_pm_disable_interrupts(dev_priv); |
|
- | 2864 | intel_runtime_pm_enable_interrupts(dev_priv); |
|
- | 2865 | ||
- | 2866 | intel_modeset_init_hw(dev); |
|
- | 2867 | ||
- | 2868 | spin_lock_irq(&dev_priv->irq_lock); |
|
- | 2869 | if (dev_priv->display.hpd_irq_setup) |
|
- | 2870 | dev_priv->display.hpd_irq_setup(dev); |
|
- | 2871 | spin_unlock_irq(&dev_priv->irq_lock); |
|
- | 2872 | ||
- | 2873 | intel_modeset_setup_hw_state(dev, true); |
|
- | 2874 | ||
- | 2875 | intel_hpd_init(dev_priv); |
|
- | 2876 | ||
- | 2877 | drm_modeset_unlock_all(dev); |
|
- | 2878 | } |
|
2657 | 2879 | ||
2658 | static int |
2880 | static int |
2659 | intel_finish_fb(struct drm_framebuffer *old_fb) |
2881 | intel_finish_fb(struct drm_framebuffer *old_fb) |
2660 | { |
2882 | { |
2661 | struct drm_i915_gem_object *obj = intel_fb_obj(old_fb); |
2883 | struct drm_i915_gem_object *obj = intel_fb_obj(old_fb); |
Line 2681... | Line 2903... | ||
2681 | static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) |
2903 | static bool intel_crtc_has_pending_flip(struct drm_crtc *crtc) |
2682 | { |
2904 | { |
2683 | struct drm_device *dev = crtc->dev; |
2905 | struct drm_device *dev = crtc->dev; |
2684 | struct drm_i915_private *dev_priv = dev->dev_private; |
2906 | struct drm_i915_private *dev_priv = dev->dev_private; |
2685 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2907 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2686 | unsigned long flags; |
- | |
2687 | bool pending; |
2908 | bool pending; |
Line 2688... | Line 2909... | ||
2688 | 2909 | ||
2689 | if (i915_reset_in_progress(&dev_priv->gpu_error) || |
2910 | if (i915_reset_in_progress(&dev_priv->gpu_error) || |
2690 | intel_crtc->reset_counter != atomic_read(&dev_priv->gpu_error.reset_counter)) |
2911 | intel_crtc->reset_counter != atomic_read(&dev_priv->gpu_error.reset_counter)) |
Line 2691... | Line 2912... | ||
2691 | return false; |
2912 | return false; |
2692 | 2913 | ||
2693 | spin_lock_irqsave(&dev->event_lock, flags); |
2914 | spin_lock_irq(&dev->event_lock); |
Line 2694... | Line 2915... | ||
2694 | pending = to_intel_crtc(crtc)->unpin_work != NULL; |
2915 | pending = to_intel_crtc(crtc)->unpin_work != NULL; |
2695 | spin_unlock_irqrestore(&dev->event_lock, flags); |
2916 | spin_unlock_irq(&dev->event_lock); |
2696 | 2917 | ||
Line -... | Line 2918... | ||
- | 2918 | return pending; |
|
- | 2919 | } |
|
- | 2920 | #endif |
|
- | 2921 | ||
- | 2922 | static void intel_update_pipe_size(struct intel_crtc *crtc) |
|
- | 2923 | { |
|
- | 2924 | struct drm_device *dev = crtc->base.dev; |
|
- | 2925 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 2926 | const struct drm_display_mode *adjusted_mode; |
|
- | 2927 | ||
- | 2928 | if (!i915.fastboot) |
|
- | 2929 | return; |
|
- | 2930 | ||
- | 2931 | /* |
|
- | 2932 | * Update pipe size and adjust fitter if needed: the reason for this is |
|
- | 2933 | * that in compute_mode_changes we check the native mode (not the pfit |
|
- | 2934 | * mode) to see if we can flip rather than do a full mode set. In the |
|
- | 2935 | * fastboot case, we'll flip, but if we don't update the pipesrc and |
|
- | 2936 | * pfit state, we'll end up with a big fb scanned out into the wrong |
|
- | 2937 | * sized surface. |
|
- | 2938 | * |
|
- | 2939 | * To fix this properly, we need to hoist the checks up into |
|
- | 2940 | * compute_mode_changes (or above), check the actual pfit state and |
|
- | 2941 | * whether the platform allows pfit disable with pipe active, and only |
|
- | 2942 | * then update the pipesrc and pfit state, even on the flip path. |
|
- | 2943 | */ |
|
- | 2944 | ||
- | 2945 | adjusted_mode = &crtc->config.adjusted_mode; |
|
- | 2946 | ||
- | 2947 | I915_WRITE(PIPESRC(crtc->pipe), |
|
- | 2948 | ((adjusted_mode->crtc_hdisplay - 1) << 16) | |
|
- | 2949 | (adjusted_mode->crtc_vdisplay - 1)); |
|
- | 2950 | if (!crtc->config.pch_pfit.enabled && |
|
- | 2951 | (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) || |
|
- | 2952 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) { |
|
- | 2953 | I915_WRITE(PF_CTL(crtc->pipe), 0); |
|
- | 2954 | I915_WRITE(PF_WIN_POS(crtc->pipe), 0); |
|
- | 2955 | I915_WRITE(PF_WIN_SZ(crtc->pipe), 0); |
|
- | 2956 | } |
|
2697 | return pending; |
2957 | crtc->config.pipe_src_w = adjusted_mode->crtc_hdisplay; |
2698 | } |
2958 | crtc->config.pipe_src_h = adjusted_mode->crtc_vdisplay; |
2699 | #endif |
2959 | } |
2700 | 2960 | ||
2701 | static int |
2961 | static int |
2702 | intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, |
2962 | intel_pipe_set_base(struct drm_crtc *crtc, int x, int y, |
2703 | struct drm_framebuffer *fb) |
2963 | struct drm_framebuffer *fb) |
2704 | { |
2964 | { |
2705 | struct drm_device *dev = crtc->dev; |
2965 | struct drm_device *dev = crtc->dev; |
2706 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
2707 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
2966 | struct drm_i915_private *dev_priv = dev->dev_private; |
2708 | enum pipe pipe = intel_crtc->pipe; |
2967 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
Line 2709... | Line 2968... | ||
2709 | struct drm_framebuffer *old_fb = crtc->primary->fb; |
2968 | enum pipe pipe = intel_crtc->pipe; |
Line 2724... | Line 2983... | ||
2724 | INTEL_INFO(dev)->num_pipes); |
2983 | INTEL_INFO(dev)->num_pipes); |
2725 | return -EINVAL; |
2984 | return -EINVAL; |
2726 | } |
2985 | } |
Line 2727... | Line 2986... | ||
2727 | 2986 | ||
2728 | mutex_lock(&dev->struct_mutex); |
2987 | mutex_lock(&dev->struct_mutex); |
2729 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
2988 | ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL); |
2730 | if (ret == 0) |
2989 | if (ret == 0) |
2731 | i915_gem_track_fb(old_obj, obj, |
2990 | i915_gem_track_fb(old_obj, intel_fb_obj(fb), |
2732 | INTEL_FRONTBUFFER_PRIMARY(pipe)); |
2991 | INTEL_FRONTBUFFER_PRIMARY(pipe)); |
2733 | mutex_unlock(&dev->struct_mutex); |
2992 | mutex_unlock(&dev->struct_mutex); |
2734 | if (ret != 0) { |
2993 | if (ret != 0) { |
2735 | DRM_ERROR("pin & fence failed\n"); |
2994 | DRM_ERROR("pin & fence failed\n"); |
2736 | return ret; |
2995 | return ret; |
Line 2737... | Line -... | ||
2737 | } |
- | |
2738 | - | ||
2739 | /* |
- | |
2740 | * Update pipe size and adjust fitter if needed: the reason for this is |
- | |
2741 | * that in compute_mode_changes we check the native mode (not the pfit |
- | |
2742 | * mode) to see if we can flip rather than do a full mode set. In the |
- | |
2743 | * fastboot case, we'll flip, but if we don't update the pipesrc and |
- | |
2744 | * pfit state, we'll end up with a big fb scanned out into the wrong |
- | |
2745 | * sized surface. |
- | |
2746 | * |
- | |
2747 | * To fix this properly, we need to hoist the checks up into |
- | |
2748 | * compute_mode_changes (or above), check the actual pfit state and |
- | |
2749 | * whether the platform allows pfit disable with pipe active, and only |
- | |
2750 | * then update the pipesrc and pfit state, even on the flip path. |
- | |
2751 | */ |
- | |
2752 | if (i915.fastboot) { |
- | |
2753 | const struct drm_display_mode *adjusted_mode = |
- | |
2754 | &intel_crtc->config.adjusted_mode; |
- | |
2755 | - | ||
2756 | I915_WRITE(PIPESRC(intel_crtc->pipe), |
- | |
2757 | ((adjusted_mode->crtc_hdisplay - 1) << 16) | |
- | |
2758 | (adjusted_mode->crtc_vdisplay - 1)); |
- | |
2759 | if (!intel_crtc->config.pch_pfit.enabled && |
- | |
2760 | (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) || |
- | |
2761 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) { |
- | |
2762 | I915_WRITE(PF_CTL(intel_crtc->pipe), 0); |
- | |
2763 | I915_WRITE(PF_WIN_POS(intel_crtc->pipe), 0); |
- | |
2764 | I915_WRITE(PF_WIN_SZ(intel_crtc->pipe), 0); |
- | |
2765 | } |
- | |
2766 | intel_crtc->config.pipe_src_w = adjusted_mode->crtc_hdisplay; |
- | |
2767 | intel_crtc->config.pipe_src_h = adjusted_mode->crtc_vdisplay; |
- | |
2768 | } |
2996 | } |
Line 2769... | Line 2997... | ||
2769 | 2997 | ||
2770 | dev_priv->display.update_primary_plane(crtc, fb, x, y); |
2998 | dev_priv->display.update_primary_plane(crtc, fb, x, y); |
Line 3361... | Line 3589... | ||
3361 | void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) |
3589 | void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc) |
3362 | { |
3590 | { |
3363 | struct drm_device *dev = crtc->dev; |
3591 | struct drm_device *dev = crtc->dev; |
3364 | struct drm_i915_private *dev_priv = dev->dev_private; |
3592 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 3365... | Line -... | ||
3365 | - | ||
3366 | if (crtc->primary->fb == NULL) |
- | |
3367 | return; |
- | |
3368 | 3593 | ||
3369 | WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue)); |
- | |
3370 | 3594 | WARN_ON(waitqueue_active(&dev_priv->pending_flip_queue)); |
|
3371 | WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue, |
3595 | if (WARN_ON(wait_event_timeout(dev_priv->pending_flip_queue, |
3372 | !intel_crtc_has_pending_flip(crtc), |
3596 | !intel_crtc_has_pending_flip(crtc), |
- | 3597 | 60*HZ) == 0)) { |
|
- | 3598 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 3599 | ||
- | 3600 | spin_lock_irq(&dev->event_lock); |
|
- | 3601 | if (intel_crtc->unpin_work) { |
|
- | 3602 | WARN_ONCE(1, "Removing stuck page flip\n"); |
|
- | 3603 | page_flip_completed(intel_crtc); |
|
- | 3604 | } |
|
- | 3605 | spin_unlock_irq(&dev->event_lock); |
|
Line -... | Line 3606... | ||
- | 3606 | } |
|
3373 | 60*HZ) == 0); |
3607 | |
3374 | 3608 | if (crtc->primary->fb) { |
|
3375 | mutex_lock(&dev->struct_mutex); |
3609 | mutex_lock(&dev->struct_mutex); |
3376 | intel_finish_fb(crtc->primary->fb); |
3610 | intel_finish_fb(crtc->primary->fb); |
- | 3611 | mutex_unlock(&dev->struct_mutex); |
|
3377 | mutex_unlock(&dev->struct_mutex); |
3612 | } |
Line 3378... | Line 3613... | ||
3378 | } |
3613 | } |
3379 | #endif |
3614 | #endif |
3380 | 3615 | ||
Line 3591... | Line 3826... | ||
3591 | ironlake_pch_transcoder_set_timings(intel_crtc, pipe); |
3826 | ironlake_pch_transcoder_set_timings(intel_crtc, pipe); |
Line 3592... | Line 3827... | ||
3592 | 3827 | ||
Line 3593... | Line 3828... | ||
3593 | intel_fdi_normal_train(crtc); |
3828 | intel_fdi_normal_train(crtc); |
3594 | - | ||
3595 | /* For PCH DP, enable TRANS_DP_CTL */ |
- | |
3596 | if (HAS_PCH_CPT(dev) && |
3829 | |
3597 | (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT) || |
3830 | /* For PCH DP, enable TRANS_DP_CTL */ |
3598 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP))) { |
3831 | if (HAS_PCH_CPT(dev) && intel_crtc->config.has_dp_encoder) { |
3599 | u32 bpc = (I915_READ(PIPECONF(pipe)) & PIPECONF_BPC_MASK) >> 5; |
3832 | u32 bpc = (I915_READ(PIPECONF(pipe)) & PIPECONF_BPC_MASK) >> 5; |
3600 | reg = TRANS_DP_CTL(pipe); |
3833 | reg = TRANS_DP_CTL(pipe); |
3601 | temp = I915_READ(reg); |
3834 | temp = I915_READ(reg); |
Line 3653... | Line 3886... | ||
3653 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
3886 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
Line 3654... | Line 3887... | ||
3654 | 3887 | ||
3655 | if (pll == NULL) |
3888 | if (pll == NULL) |
Line 3656... | Line 3889... | ||
3656 | return; |
3889 | return; |
3657 | 3890 | ||
3658 | if (pll->refcount == 0) { |
3891 | if (!(pll->config.crtc_mask & (1 << crtc->pipe))) { |
3659 | WARN(1, "bad %s refcount\n", pll->name); |
3892 | WARN(1, "bad %s crtc mask\n", pll->name); |
Line -... | Line 3893... | ||
- | 3893 | return; |
|
3660 | return; |
3894 | } |
3661 | } |
3895 | |
3662 | 3896 | pll->config.crtc_mask &= ~(1 << crtc->pipe); |
|
3663 | if (--pll->refcount == 0) { |
3897 | if (pll->config.crtc_mask == 0) { |
Line 3664... | Line 3898... | ||
3664 | WARN_ON(pll->on); |
3898 | WARN_ON(pll->on); |
3665 | WARN_ON(pll->active); |
3899 | WARN_ON(pll->active); |
Line 3666... | Line 3900... | ||
3666 | } |
3900 | } |
3667 | 3901 | ||
3668 | crtc->config.shared_dpll = DPLL_ID_PRIVATE; |
3902 | crtc->config.shared_dpll = DPLL_ID_PRIVATE; |
3669 | } |
3903 | } |
3670 | 3904 | ||
Line 3671... | Line -... | ||
3671 | struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) |
- | |
3672 | { |
- | |
3673 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
- | |
3674 | struct intel_shared_dpll *pll = intel_crtc_to_shared_dpll(crtc); |
- | |
3675 | enum intel_dpll_id i; |
- | |
3676 | - | ||
3677 | if (pll) { |
3905 | struct intel_shared_dpll *intel_get_shared_dpll(struct intel_crtc *crtc) |
3678 | DRM_DEBUG_KMS("CRTC:%d dropping existing %s\n", |
3906 | { |
3679 | crtc->base.base.id, pll->name); |
3907 | struct drm_i915_private *dev_priv = crtc->base.dev->dev_private; |
3680 | intel_put_shared_dpll(crtc); |
3908 | struct intel_shared_dpll *pll; |
Line 3681... | Line 3909... | ||
3681 | } |
3909 | enum intel_dpll_id i; |
3682 | 3910 | ||
Line 3683... | Line 3911... | ||
3683 | if (HAS_PCH_IBX(dev_priv->dev)) { |
3911 | if (HAS_PCH_IBX(dev_priv->dev)) { |
Line 3684... | Line 3912... | ||
3684 | /* Ironlake PCH has a fixed PLL->PCH pipe mapping. */ |
3912 | /* Ironlake PCH has a fixed PLL->PCH pipe mapping. */ |
3685 | i = (enum intel_dpll_id) crtc->pipe; |
3913 | i = (enum intel_dpll_id) crtc->pipe; |
Line 3686... | Line 3914... | ||
3686 | pll = &dev_priv->shared_dplls[i]; |
3914 | pll = &dev_priv->shared_dplls[i]; |
3687 | 3915 | ||
Line 3688... | Line 3916... | ||
3688 | DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n", |
3916 | DRM_DEBUG_KMS("CRTC:%d using pre-allocated %s\n", |
3689 | crtc->base.base.id, pll->name); |
3917 | crtc->base.base.id, pll->name); |
3690 | 3918 | ||
Line 3691... | Line 3919... | ||
3691 | WARN_ON(pll->refcount); |
3919 | WARN_ON(pll->new_config->crtc_mask); |
- | 3920 | ||
3692 | 3921 | goto found; |
|
3693 | goto found; |
3922 | } |
3694 | } |
3923 | |
3695 | 3924 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
|
3696 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
- | |
- | 3925 | pll = &dev_priv->shared_dplls[i]; |
|
3697 | pll = &dev_priv->shared_dplls[i]; |
3926 | |
3698 | 3927 | /* Only want to check enabled timings first */ |
|
3699 | /* Only want to check enabled timings first */ |
3928 | if (pll->new_config->crtc_mask == 0) |
Line 3700... | Line 3929... | ||
3700 | if (pll->refcount == 0) |
3929 | continue; |
3701 | continue; |
3930 | |
3702 | 3931 | if (memcmp(&crtc->new_config->dpll_hw_state, |
|
3703 | if (memcmp(&crtc->config.dpll_hw_state, &pll->hw_state, |
3932 | &pll->new_config->hw_state, |
3704 | sizeof(pll->hw_state)) == 0) { |
3933 | sizeof(pll->new_config->hw_state)) == 0) { |
3705 | DRM_DEBUG_KMS("CRTC:%d sharing existing %s (refcount %d, ative %d)\n", |
3934 | DRM_DEBUG_KMS("CRTC:%d sharing existing %s (crtc mask 0x%08x, ative %d)\n", |
3706 | crtc->base.base.id, |
3935 | crtc->base.base.id, pll->name, |
3707 | pll->name, pll->refcount, pll->active); |
3936 | pll->new_config->crtc_mask, |
3708 | 3937 | pll->active); |
|
Line 3709... | Line 3938... | ||
3709 | goto found; |
3938 | goto found; |
Line 3710... | Line 3939... | ||
3710 | } |
3939 | } |
3711 | } |
3940 | } |
3712 | 3941 | ||
Line 3713... | Line 3942... | ||
3713 | /* Ok no matching timings, maybe there's a free one? */ |
3942 | /* Ok no matching timings, maybe there's a free one? */ |
3714 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
3943 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
3715 | pll = &dev_priv->shared_dplls[i]; |
3944 | pll = &dev_priv->shared_dplls[i]; |
Line 3716... | Line 3945... | ||
3716 | if (pll->refcount == 0) { |
3945 | if (pll->new_config->crtc_mask == 0) { |
Line 3717... | Line 3946... | ||
3717 | DRM_DEBUG_KMS("CRTC:%d allocated %s\n", |
3946 | DRM_DEBUG_KMS("CRTC:%d allocated %s\n", |
3718 | crtc->base.base.id, pll->name); |
3947 | crtc->base.base.id, pll->name); |
Line -... | Line 3948... | ||
- | 3948 | goto found; |
|
- | 3949 | } |
|
- | 3950 | } |
|
- | 3951 | ||
- | 3952 | return NULL; |
|
- | 3953 | ||
- | 3954 | found: |
|
- | 3955 | if (pll->new_config->crtc_mask == 0) |
|
- | 3956 | pll->new_config->hw_state = crtc->new_config->dpll_hw_state; |
|
- | 3957 | ||
- | 3958 | crtc->new_config->shared_dpll = i; |
|
- | 3959 | DRM_DEBUG_DRIVER("using %s for pipe %c\n", pll->name, |
|
- | 3960 | pipe_name(crtc->pipe)); |
|
- | 3961 | ||
- | 3962 | pll->new_config->crtc_mask |= 1 << crtc->pipe; |
|
- | 3963 | ||
- | 3964 | return pll; |
|
- | 3965 | } |
|
- | 3966 | ||
- | 3967 | /** |
|
- | 3968 | * intel_shared_dpll_start_config - start a new PLL staged config |
|
- | 3969 | * @dev_priv: DRM device |
|
- | 3970 | * @clear_pipes: mask of pipes that will have their PLLs freed |
|
- | 3971 | * |
|
- | 3972 | * Starts a new PLL staged config, copying the current config but |
|
- | 3973 | * releasing the references of pipes specified in clear_pipes. |
|
- | 3974 | */ |
|
- | 3975 | static int intel_shared_dpll_start_config(struct drm_i915_private *dev_priv, |
|
- | 3976 | unsigned clear_pipes) |
|
- | 3977 | { |
|
- | 3978 | struct intel_shared_dpll *pll; |
|
- | 3979 | enum intel_dpll_id i; |
|
- | 3980 | ||
- | 3981 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
|
- | 3982 | pll = &dev_priv->shared_dplls[i]; |
|
- | 3983 | ||
- | 3984 | pll->new_config = kmemdup(&pll->config, sizeof pll->config, |
|
- | 3985 | GFP_KERNEL); |
|
- | 3986 | if (!pll->new_config) |
|
- | 3987 | goto cleanup; |
|
- | 3988 | ||
- | 3989 | pll->new_config->crtc_mask &= ~clear_pipes; |
|
- | 3990 | } |
|
- | 3991 | ||
- | 3992 | return 0; |
|
- | 3993 | ||
- | 3994 | cleanup: |
|
- | 3995 | while (--i >= 0) { |
|
- | 3996 | pll = &dev_priv->shared_dplls[i]; |
|
- | 3997 | kfree(pll->new_config); |
|
- | 3998 | pll->new_config = NULL; |
|
- | 3999 | } |
|
- | 4000 | ||
- | 4001 | return -ENOMEM; |
|
- | 4002 | } |
|
- | 4003 | ||
- | 4004 | static void intel_shared_dpll_commit(struct drm_i915_private *dev_priv) |
|
- | 4005 | { |
|
- | 4006 | struct intel_shared_dpll *pll; |
|
- | 4007 | enum intel_dpll_id i; |
|
- | 4008 | ||
- | 4009 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
|
- | 4010 | pll = &dev_priv->shared_dplls[i]; |
|
- | 4011 | ||
- | 4012 | WARN_ON(pll->new_config == &pll->config); |
|
- | 4013 | ||
- | 4014 | pll->config = *pll->new_config; |
|
- | 4015 | kfree(pll->new_config); |
|
3719 | goto found; |
4016 | pll->new_config = NULL; |
3720 | } |
4017 | } |
3721 | } |
4018 | } |
3722 | 4019 | ||
3723 | return NULL; |
4020 | static void intel_shared_dpll_abort_config(struct drm_i915_private *dev_priv) |
Line 3747... | Line 4044... | ||
3747 | if (wait_for(I915_READ(dslreg) != temp, 5)) |
4044 | if (wait_for(I915_READ(dslreg) != temp, 5)) |
3748 | DRM_ERROR("mode set failed: pipe %c stuck\n", pipe_name(pipe)); |
4045 | DRM_ERROR("mode set failed: pipe %c stuck\n", pipe_name(pipe)); |
3749 | } |
4046 | } |
3750 | } |
4047 | } |
Line -... | Line 4048... | ||
- | 4048 | ||
- | 4049 | static void skylake_pfit_enable(struct intel_crtc *crtc) |
|
- | 4050 | { |
|
- | 4051 | struct drm_device *dev = crtc->base.dev; |
|
- | 4052 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 4053 | int pipe = crtc->pipe; |
|
- | 4054 | ||
- | 4055 | if (crtc->config.pch_pfit.enabled) { |
|
- | 4056 | I915_WRITE(PS_CTL(pipe), PS_ENABLE); |
|
- | 4057 | I915_WRITE(PS_WIN_POS(pipe), crtc->config.pch_pfit.pos); |
|
- | 4058 | I915_WRITE(PS_WIN_SZ(pipe), crtc->config.pch_pfit.size); |
|
- | 4059 | } |
|
- | 4060 | } |
|
3751 | 4061 | ||
3752 | static void ironlake_pfit_enable(struct intel_crtc *crtc) |
4062 | static void ironlake_pfit_enable(struct intel_crtc *crtc) |
3753 | { |
4063 | { |
3754 | struct drm_device *dev = crtc->base.dev; |
4064 | struct drm_device *dev = crtc->base.dev; |
3755 | struct drm_i915_private *dev_priv = dev->dev_private; |
4065 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 3870... | Line 4180... | ||
3870 | /* The clocks have to be on to load the palette. */ |
4180 | /* The clocks have to be on to load the palette. */ |
3871 | if (!crtc->enabled || !intel_crtc->active) |
4181 | if (!crtc->enabled || !intel_crtc->active) |
3872 | return; |
4182 | return; |
Line 3873... | Line 4183... | ||
3873 | 4183 | ||
3874 | if (!HAS_PCH_SPLIT(dev_priv->dev)) { |
4184 | if (!HAS_PCH_SPLIT(dev_priv->dev)) { |
3875 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) |
4185 | if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI)) |
3876 | assert_dsi_pll_enabled(dev_priv); |
4186 | assert_dsi_pll_enabled(dev_priv); |
3877 | else |
4187 | else |
3878 | assert_pll_enabled(dev_priv, pipe); |
4188 | assert_pll_enabled(dev_priv, pipe); |
Line 3909... | Line 4219... | ||
3909 | struct drm_device *dev = intel_crtc->base.dev; |
4219 | struct drm_device *dev = intel_crtc->base.dev; |
3910 | struct drm_i915_private *dev_priv = dev->dev_private; |
4220 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 3911... | Line 4221... | ||
3911 | 4221 | ||
3912 | mutex_lock(&dev->struct_mutex); |
4222 | mutex_lock(&dev->struct_mutex); |
- | 4223 | dev_priv->mm.interruptible = false; |
|
3913 | dev_priv->mm.interruptible = false; |
4224 | // (void) intel_overlay_switch_off(intel_crtc->overlay); |
3914 | dev_priv->mm.interruptible = true; |
4225 | dev_priv->mm.interruptible = true; |
3915 | mutex_unlock(&dev->struct_mutex); |
4226 | mutex_unlock(&dev->struct_mutex); |
Line 3916... | Line 4227... | ||
3916 | } |
4227 | } |
Line 3921... | Line 4232... | ||
3921 | } |
4232 | } |
Line 3922... | Line 4233... | ||
3922 | 4233 | ||
3923 | static void intel_crtc_enable_planes(struct drm_crtc *crtc) |
4234 | static void intel_crtc_enable_planes(struct drm_crtc *crtc) |
3924 | { |
4235 | { |
3925 | struct drm_device *dev = crtc->dev; |
- | |
3926 | struct drm_i915_private *dev_priv = dev->dev_private; |
4236 | struct drm_device *dev = crtc->dev; |
3927 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4237 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
3928 | int pipe = intel_crtc->pipe; |
- | |
3929 | int plane = intel_crtc->plane; |
- | |
3930 | - | ||
Line 3931... | Line 4238... | ||
3931 | drm_vblank_on(dev, pipe); |
4238 | int pipe = intel_crtc->pipe; |
3932 | 4239 | ||
3933 | intel_enable_primary_hw_plane(dev_priv, plane, pipe); |
4240 | intel_enable_primary_hw_plane(crtc->primary, crtc); |
3934 | intel_enable_planes(crtc); |
4241 | intel_enable_planes(crtc); |
Line 3935... | Line 4242... | ||
3935 | intel_crtc_update_cursor(crtc, true); |
4242 | intel_crtc_update_cursor(crtc, true); |
Line 3936... | Line 4243... | ||
3936 | intel_crtc_dpms_overlay(intel_crtc, true); |
4243 | intel_crtc_dpms_overlay(intel_crtc, true); |
3937 | 4244 | ||
3938 | hsw_enable_ips(intel_crtc); |
4245 | hsw_enable_ips(intel_crtc); |
- | 4246 | ||
- | 4247 | mutex_lock(&dev->struct_mutex); |
|
- | 4248 | intel_update_fbc(dev); |
|
- | 4249 | mutex_unlock(&dev->struct_mutex); |
|
- | 4250 | ||
- | 4251 | /* |
|
- | 4252 | * FIXME: Once we grow proper nuclear flip support out of this we need |
|
3939 | 4253 | * to compute the mask of flip planes precisely. For the time being |
|
Line 3940... | Line 4254... | ||
3940 | mutex_lock(&dev->struct_mutex); |
4254 | * consider this a flip from a NULL plane. |
3941 | intel_update_fbc(dev); |
4255 | */ |
3942 | mutex_unlock(&dev->struct_mutex); |
4256 | intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe)); |
Line 3957... | Line 4271... | ||
3957 | hsw_disable_ips(intel_crtc); |
4271 | hsw_disable_ips(intel_crtc); |
Line 3958... | Line 4272... | ||
3958 | 4272 | ||
3959 | intel_crtc_dpms_overlay(intel_crtc, false); |
4273 | intel_crtc_dpms_overlay(intel_crtc, false); |
3960 | intel_crtc_update_cursor(crtc, false); |
4274 | intel_crtc_update_cursor(crtc, false); |
3961 | intel_disable_planes(crtc); |
4275 | intel_disable_planes(crtc); |
- | 4276 | intel_disable_primary_hw_plane(crtc->primary, crtc); |
|
- | 4277 | ||
- | 4278 | /* |
|
- | 4279 | * FIXME: Once we grow proper nuclear flip support out of this we need |
|
3962 | intel_disable_primary_hw_plane(dev_priv, plane, pipe); |
4280 | * to compute the mask of flip planes precisely. For the time being |
- | 4281 | * consider this a flip to a NULL plane. |
|
- | 4282 | */ |
|
3963 | drm_vblank_off(dev, pipe); |
4283 | // intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe)); |
Line 3964... | Line 4284... | ||
3964 | } |
4284 | } |
3965 | 4285 | ||
3966 | static void ironlake_crtc_enable(struct drm_crtc *crtc) |
4286 | static void ironlake_crtc_enable(struct drm_crtc *crtc) |
3967 | { |
4287 | { |
3968 | struct drm_device *dev = crtc->dev; |
4288 | struct drm_device *dev = crtc->dev; |
3969 | struct drm_i915_private *dev_priv = dev->dev_private; |
4289 | struct drm_i915_private *dev_priv = dev->dev_private; |
3970 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4290 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
3971 | struct intel_encoder *encoder; |
- | |
Line 3972... | Line 4291... | ||
3972 | int pipe = intel_crtc->pipe; |
4291 | struct intel_encoder *encoder; |
Line 3973... | Line 4292... | ||
3973 | enum plane plane = intel_crtc->plane; |
4292 | int pipe = intel_crtc->pipe; |
3974 | 4293 | ||
Line 3985... | Line 4304... | ||
3985 | 4304 | ||
Line 3986... | Line 4305... | ||
3986 | intel_set_pipe_timings(intel_crtc); |
4305 | intel_set_pipe_timings(intel_crtc); |
3987 | 4306 | ||
3988 | if (intel_crtc->config.has_pch_encoder) { |
4307 | if (intel_crtc->config.has_pch_encoder) { |
3989 | intel_cpu_transcoder_set_m_n(intel_crtc, |
4308 | intel_cpu_transcoder_set_m_n(intel_crtc, |
Line 3990... | Line 4309... | ||
3990 | &intel_crtc->config.fdi_m_n); |
4309 | &intel_crtc->config.fdi_m_n, NULL); |
Line 3991... | Line -... | ||
3991 | } |
- | |
3992 | - | ||
3993 | ironlake_set_pipeconf(crtc); |
- | |
3994 | - | ||
3995 | /* Set up the display plane register */ |
- | |
3996 | I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE); |
- | |
3997 | POSTING_READ(DSPCNTR(plane)); |
- | |
3998 | 4310 | } |
|
Line 3999... | Line 4311... | ||
3999 | dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, |
4311 | |
4000 | crtc->x, crtc->y); |
4312 | ironlake_set_pipeconf(crtc); |
Line 4001... | Line 4313... | ||
4001 | 4313 | ||
4002 | intel_crtc->active = true; |
4314 | intel_crtc->active = true; |
4003 | 4315 | ||
Line 4036... | Line 4348... | ||
4036 | encoder->enable(encoder); |
4348 | encoder->enable(encoder); |
Line 4037... | Line 4349... | ||
4037 | 4349 | ||
4038 | if (HAS_PCH_CPT(dev)) |
4350 | if (HAS_PCH_CPT(dev)) |
Line -... | Line 4351... | ||
- | 4351 | cpt_verify_modeset(dev, intel_crtc->pipe); |
|
- | 4352 | ||
- | 4353 | assert_vblank_disabled(crtc); |
|
4039 | cpt_verify_modeset(dev, intel_crtc->pipe); |
4354 | drm_crtc_vblank_on(crtc); |
4040 | 4355 | ||
Line 4041... | Line 4356... | ||
4041 | intel_crtc_enable_planes(crtc); |
4356 | intel_crtc_enable_planes(crtc); |
4042 | } |
4357 | } |
Line 4081... | Line 4396... | ||
4081 | struct drm_device *dev = crtc->dev; |
4396 | struct drm_device *dev = crtc->dev; |
4082 | struct drm_i915_private *dev_priv = dev->dev_private; |
4397 | struct drm_i915_private *dev_priv = dev->dev_private; |
4083 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4398 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4084 | struct intel_encoder *encoder; |
4399 | struct intel_encoder *encoder; |
4085 | int pipe = intel_crtc->pipe; |
4400 | int pipe = intel_crtc->pipe; |
4086 | enum plane plane = intel_crtc->plane; |
- | |
Line 4087... | Line 4401... | ||
4087 | 4401 | ||
Line 4088... | Line 4402... | ||
4088 | WARN_ON(!crtc->enabled); |
4402 | WARN_ON(!crtc->enabled); |
4089 | 4403 | ||
Line 4096... | Line 4410... | ||
4096 | if (intel_crtc->config.has_dp_encoder) |
4410 | if (intel_crtc->config.has_dp_encoder) |
4097 | intel_dp_set_m_n(intel_crtc); |
4411 | intel_dp_set_m_n(intel_crtc); |
Line 4098... | Line 4412... | ||
4098 | 4412 | ||
Line -... | Line 4413... | ||
- | 4413 | intel_set_pipe_timings(intel_crtc); |
|
- | 4414 | ||
- | 4415 | if (intel_crtc->config.cpu_transcoder != TRANSCODER_EDP) { |
|
- | 4416 | I915_WRITE(PIPE_MULT(intel_crtc->config.cpu_transcoder), |
|
- | 4417 | intel_crtc->config.pixel_multiplier - 1); |
|
4099 | intel_set_pipe_timings(intel_crtc); |
4418 | } |
4100 | 4419 | ||
4101 | if (intel_crtc->config.has_pch_encoder) { |
4420 | if (intel_crtc->config.has_pch_encoder) { |
4102 | intel_cpu_transcoder_set_m_n(intel_crtc, |
4421 | intel_cpu_transcoder_set_m_n(intel_crtc, |
Line 4103... | Line 4422... | ||
4103 | &intel_crtc->config.fdi_m_n); |
4422 | &intel_crtc->config.fdi_m_n, NULL); |
Line 4104... | Line 4423... | ||
4104 | } |
4423 | } |
Line 4105... | Line -... | ||
4105 | - | ||
4106 | haswell_set_pipeconf(crtc); |
- | |
4107 | - | ||
4108 | intel_set_pipe_csc(crtc); |
- | |
4109 | - | ||
4110 | /* Set up the display plane register */ |
- | |
4111 | I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE | DISPPLANE_PIPE_CSC_ENABLE); |
- | |
4112 | POSTING_READ(DSPCNTR(plane)); |
4424 | |
Line 4113... | Line 4425... | ||
4113 | 4425 | haswell_set_pipeconf(crtc); |
|
4114 | dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, |
4426 | |
4115 | crtc->x, crtc->y); |
4427 | intel_set_pipe_csc(crtc); |
4116 | 4428 | ||
Line 4117... | Line 4429... | ||
4117 | intel_crtc->active = true; |
4429 | intel_crtc->active = true; |
4118 | 4430 | ||
- | 4431 | intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true); |
|
4119 | intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); |
4432 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4120 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4433 | if (encoder->pre_enable) |
Line 4121... | Line 4434... | ||
4121 | if (encoder->pre_enable) |
4434 | encoder->pre_enable(encoder); |
Line -... | Line 4435... | ||
- | 4435 | ||
- | 4436 | if (intel_crtc->config.has_pch_encoder) { |
|
- | 4437 | intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A, |
|
4122 | encoder->pre_enable(encoder); |
4438 | true); |
Line 4123... | Line 4439... | ||
4123 | 4439 | dev_priv->display.fdi_link_train(crtc); |
|
4124 | if (intel_crtc->config.has_pch_encoder) { |
4440 | } |
4125 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, true); |
4441 | |
Line 4151... | Line 4467... | ||
4151 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
4467 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
4152 | encoder->enable(encoder); |
4468 | encoder->enable(encoder); |
4153 | intel_opregion_notify_encoder(encoder, true); |
4469 | intel_opregion_notify_encoder(encoder, true); |
4154 | } |
4470 | } |
Line -... | Line 4471... | ||
- | 4471 | ||
- | 4472 | assert_vblank_disabled(crtc); |
|
- | 4473 | drm_crtc_vblank_on(crtc); |
|
4155 | 4474 | ||
4156 | /* If we change the relative order between pipe/planes enabling, we need |
4475 | /* If we change the relative order between pipe/planes enabling, we need |
4157 | * to change the workaround. */ |
4476 | * to change the workaround. */ |
4158 | haswell_mode_set_planes_workaround(intel_crtc); |
4477 | haswell_mode_set_planes_workaround(intel_crtc); |
4159 | intel_crtc_enable_planes(crtc); |
4478 | intel_crtc_enable_planes(crtc); |
Line -... | Line 4479... | ||
- | 4479 | } |
|
- | 4480 | ||
- | 4481 | static void skylake_pfit_disable(struct intel_crtc *crtc) |
|
- | 4482 | { |
|
- | 4483 | struct drm_device *dev = crtc->base.dev; |
|
- | 4484 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 4485 | int pipe = crtc->pipe; |
|
- | 4486 | ||
- | 4487 | /* To avoid upsetting the power well on haswell only disable the pfit if |
|
- | 4488 | * it's in use. The hw state code will make sure we get this right. */ |
|
- | 4489 | if (crtc->config.pch_pfit.enabled) { |
|
- | 4490 | I915_WRITE(PS_CTL(pipe), 0); |
|
- | 4491 | I915_WRITE(PS_WIN_POS(pipe), 0); |
|
- | 4492 | I915_WRITE(PS_WIN_SZ(pipe), 0); |
|
- | 4493 | } |
|
4160 | } |
4494 | } |
4161 | 4495 | ||
4162 | static void ironlake_pfit_disable(struct intel_crtc *crtc) |
4496 | static void ironlake_pfit_disable(struct intel_crtc *crtc) |
4163 | { |
4497 | { |
4164 | struct drm_device *dev = crtc->base.dev; |
4498 | struct drm_device *dev = crtc->base.dev; |
Line 4186... | Line 4520... | ||
4186 | if (!intel_crtc->active) |
4520 | if (!intel_crtc->active) |
4187 | return; |
4521 | return; |
Line 4188... | Line 4522... | ||
4188 | 4522 | ||
Line -... | Line 4523... | ||
- | 4523 | intel_crtc_disable_planes(crtc); |
|
- | 4524 | ||
- | 4525 | drm_crtc_vblank_off(crtc); |
|
4189 | intel_crtc_disable_planes(crtc); |
4526 | assert_vblank_disabled(crtc); |
4190 | 4527 | ||
Line 4191... | Line 4528... | ||
4191 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4528 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4192 | encoder->disable(encoder); |
4529 | encoder->disable(encoder); |
- | 4530 | ||
- | 4531 | if (intel_crtc->config.has_pch_encoder) |
|
Line 4193... | Line -... | ||
4193 | - | ||
4194 | if (intel_crtc->config.has_pch_encoder) |
4532 | intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, false); |
Line 4195... | Line 4533... | ||
4195 | intel_set_pch_fifo_underrun_reporting(dev, pipe, false); |
4533 | |
4196 | 4534 | intel_disable_pipe(intel_crtc); |
|
4197 | intel_disable_pipe(dev_priv, pipe); |
4535 | |
Line 4198... | Line 4536... | ||
4198 | ironlake_pfit_disable(intel_crtc); |
4536 | ironlake_pfit_disable(intel_crtc); |
4199 | 4537 | ||
Line 4200... | Line 4538... | ||
4200 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4538 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4201 | if (encoder->post_disable) |
- | |
Line 4202... | Line 4539... | ||
4202 | encoder->post_disable(encoder); |
4539 | if (encoder->post_disable) |
4203 | 4540 | encoder->post_disable(encoder); |
|
4204 | if (intel_crtc->config.has_pch_encoder) { |
4541 | |
4205 | ironlake_fdi_disable(crtc); |
4542 | if (intel_crtc->config.has_pch_encoder) { |
Line 4240... | Line 4577... | ||
4240 | { |
4577 | { |
4241 | struct drm_device *dev = crtc->dev; |
4578 | struct drm_device *dev = crtc->dev; |
4242 | struct drm_i915_private *dev_priv = dev->dev_private; |
4579 | struct drm_i915_private *dev_priv = dev->dev_private; |
4243 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4580 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4244 | struct intel_encoder *encoder; |
4581 | struct intel_encoder *encoder; |
4245 | int pipe = intel_crtc->pipe; |
- | |
4246 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
4582 | enum transcoder cpu_transcoder = intel_crtc->config.cpu_transcoder; |
Line 4247... | Line 4583... | ||
4247 | 4583 | ||
4248 | if (!intel_crtc->active) |
4584 | if (!intel_crtc->active) |
Line 4249... | Line 4585... | ||
4249 | return; |
4585 | return; |
Line -... | Line 4586... | ||
- | 4586 | ||
- | 4587 | intel_crtc_disable_planes(crtc); |
|
- | 4588 | ||
4250 | 4589 | drm_crtc_vblank_off(crtc); |
|
4251 | intel_crtc_disable_planes(crtc); |
4590 | assert_vblank_disabled(crtc); |
4252 | 4591 | ||
4253 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
4592 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
Line 4254... | Line 4593... | ||
4254 | intel_opregion_notify_encoder(encoder, false); |
4593 | intel_opregion_notify_encoder(encoder, false); |
4255 | encoder->disable(encoder); |
4594 | encoder->disable(encoder); |
- | 4595 | } |
|
4256 | } |
4596 | |
Line 4257... | Line 4597... | ||
4257 | 4597 | if (intel_crtc->config.has_pch_encoder) |
|
4258 | if (intel_crtc->config.has_pch_encoder) |
4598 | intel_set_pch_fifo_underrun_reporting(dev_priv, TRANSCODER_A, |
Line 4259... | Line 4599... | ||
4259 | intel_set_pch_fifo_underrun_reporting(dev, TRANSCODER_A, false); |
4599 | false); |
Line -... | Line 4600... | ||
- | 4600 | intel_disable_pipe(intel_crtc); |
|
- | 4601 | ||
- | 4602 | if (intel_crtc->config.dp_encoder_is_mst) |
|
4260 | intel_disable_pipe(dev_priv, pipe); |
4603 | intel_ddi_set_vc_payload_alloc(crtc, false); |
Line 4261... | Line 4604... | ||
4261 | 4604 | ||
Line 4262... | Line 4605... | ||
4262 | if (intel_crtc->config.dp_encoder_is_mst) |
4605 | intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder); |
4263 | intel_ddi_set_vc_payload_alloc(crtc, false); |
4606 | |
4264 | - | ||
4265 | intel_ddi_disable_transcoder_func(dev_priv, cpu_transcoder); |
4607 | if (IS_SKYLAKE(dev)) |
4266 | 4608 | skylake_pfit_disable(intel_crtc); |
|
Line 4267... | Line 4609... | ||
4267 | ironlake_pfit_disable(intel_crtc); |
4609 | else |
4268 | 4610 | ironlake_pfit_disable(intel_crtc); |
|
Line 4389... | Line 4731... | ||
4389 | mask |= BIT(intel_display_port_power_domain(intel_encoder)); |
4731 | mask |= BIT(intel_display_port_power_domain(intel_encoder)); |
Line 4390... | Line 4732... | ||
4390 | 4732 | ||
4391 | return mask; |
4733 | return mask; |
Line 4392... | Line -... | ||
4392 | } |
- | |
4393 | - | ||
4394 | void intel_display_set_init_power(struct drm_i915_private *dev_priv, |
- | |
4395 | bool enable) |
- | |
4396 | { |
- | |
4397 | if (dev_priv->power_domains.init_power_on == enable) |
- | |
4398 | return; |
- | |
4399 | - | ||
4400 | if (enable) |
- | |
4401 | intel_display_power_get(dev_priv, POWER_DOMAIN_INIT); |
- | |
4402 | else |
- | |
4403 | intel_display_power_put(dev_priv, POWER_DOMAIN_INIT); |
- | |
4404 | - | ||
4405 | dev_priv->power_domains.init_power_on = enable; |
- | |
4406 | } |
4734 | } |
4407 | 4735 | ||
4408 | static void modeset_update_crtc_power_domains(struct drm_device *dev) |
4736 | static void modeset_update_crtc_power_domains(struct drm_device *dev) |
4409 | { |
4737 | { |
4410 | struct drm_i915_private *dev_priv = dev->dev_private; |
4738 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 4425... | Line 4753... | ||
4425 | 4753 | ||
4426 | for_each_power_domain(domain, pipe_domains[crtc->pipe]) |
4754 | for_each_power_domain(domain, pipe_domains[crtc->pipe]) |
4427 | intel_display_power_get(dev_priv, domain); |
4755 | intel_display_power_get(dev_priv, domain); |
Line -... | Line 4756... | ||
- | 4756 | } |
|
- | 4757 | ||
- | 4758 | if (dev_priv->display.modeset_global_resources) |
|
4428 | } |
4759 | dev_priv->display.modeset_global_resources(dev); |
4429 | 4760 | ||
Line 4430... | Line 4761... | ||
4430 | for_each_intel_crtc(dev, crtc) { |
4761 | for_each_intel_crtc(dev, crtc) { |
4431 | enum intel_display_power_domain domain; |
4762 | enum intel_display_power_domain domain; |
Line 4456... | Line 4787... | ||
4456 | static void vlv_update_cdclk(struct drm_device *dev) |
4787 | static void vlv_update_cdclk(struct drm_device *dev) |
4457 | { |
4788 | { |
4458 | struct drm_i915_private *dev_priv = dev->dev_private; |
4789 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 4459... | Line 4790... | ||
4459 | 4790 | ||
4460 | dev_priv->vlv_cdclk_freq = dev_priv->display.get_display_clock_speed(dev); |
4791 | dev_priv->vlv_cdclk_freq = dev_priv->display.get_display_clock_speed(dev); |
4461 | DRM_DEBUG_DRIVER("Current CD clock rate: %d kHz", |
4792 | DRM_DEBUG_DRIVER("Current CD clock rate: %d kHz\n", |
Line 4462... | Line 4793... | ||
4462 | dev_priv->vlv_cdclk_freq); |
4793 | dev_priv->vlv_cdclk_freq); |
4463 | 4794 | ||
4464 | /* |
4795 | /* |
4465 | * Program the gmbus_freq based on the cdclk frequency. |
4796 | * Program the gmbus_freq based on the cdclk frequency. |
4466 | * BSpec erroneously claims we should aim for 4MHz, but |
4797 | * BSpec erroneously claims we should aim for 4MHz, but |
4467 | * in fact 1MHz is the correct frequency. |
4798 | * in fact 1MHz is the correct frequency. |
4468 | */ |
4799 | */ |
Line 4469... | Line 4800... | ||
4469 | I915_WRITE(GMBUSFREQ_VLV, dev_priv->vlv_cdclk_freq); |
4800 | I915_WRITE(GMBUSFREQ_VLV, DIV_ROUND_UP(dev_priv->vlv_cdclk_freq, 1000)); |
4470 | } |
4801 | } |
4471 | 4802 | ||
Line 4495... | Line 4826... | ||
4495 | DRM_ERROR("timed out waiting for CDclk change\n"); |
4826 | DRM_ERROR("timed out waiting for CDclk change\n"); |
4496 | } |
4827 | } |
4497 | mutex_unlock(&dev_priv->rps.hw_lock); |
4828 | mutex_unlock(&dev_priv->rps.hw_lock); |
Line 4498... | Line 4829... | ||
4498 | 4829 | ||
4499 | if (cdclk == 400000) { |
4830 | if (cdclk == 400000) { |
Line 4500... | Line -... | ||
4500 | u32 divider, vco; |
- | |
4501 | 4831 | u32 divider; |
|
Line 4502... | Line 4832... | ||
4502 | vco = valleyview_get_vco(dev_priv); |
4832 | |
4503 | divider = DIV_ROUND_CLOSEST(vco << 1, cdclk) - 1; |
4833 | divider = DIV_ROUND_CLOSEST(dev_priv->hpll_freq << 1, cdclk) - 1; |
4504 | 4834 | ||
4505 | mutex_lock(&dev_priv->dpio_lock); |
4835 | mutex_lock(&dev_priv->dpio_lock); |
Line 4533... | Line 4863... | ||
4533 | mutex_unlock(&dev_priv->dpio_lock); |
4863 | mutex_unlock(&dev_priv->dpio_lock); |
Line 4534... | Line 4864... | ||
4534 | 4864 | ||
4535 | vlv_update_cdclk(dev); |
4865 | vlv_update_cdclk(dev); |
Line -... | Line 4866... | ||
- | 4866 | } |
|
- | 4867 | ||
- | 4868 | static void cherryview_set_cdclk(struct drm_device *dev, int cdclk) |
|
- | 4869 | { |
|
- | 4870 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 4871 | u32 val, cmd; |
|
- | 4872 | ||
- | 4873 | WARN_ON(dev_priv->display.get_display_clock_speed(dev) != dev_priv->vlv_cdclk_freq); |
|
- | 4874 | ||
- | 4875 | switch (cdclk) { |
|
- | 4876 | case 400000: |
|
- | 4877 | cmd = 3; |
|
- | 4878 | break; |
|
- | 4879 | case 333333: |
|
- | 4880 | case 320000: |
|
- | 4881 | cmd = 2; |
|
- | 4882 | break; |
|
- | 4883 | case 266667: |
|
- | 4884 | cmd = 1; |
|
- | 4885 | break; |
|
- | 4886 | case 200000: |
|
- | 4887 | cmd = 0; |
|
- | 4888 | break; |
|
- | 4889 | default: |
|
- | 4890 | WARN_ON(1); |
|
- | 4891 | return; |
|
- | 4892 | } |
|
- | 4893 | ||
- | 4894 | mutex_lock(&dev_priv->rps.hw_lock); |
|
- | 4895 | val = vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ); |
|
- | 4896 | val &= ~DSPFREQGUAR_MASK_CHV; |
|
- | 4897 | val |= (cmd << DSPFREQGUAR_SHIFT_CHV); |
|
- | 4898 | vlv_punit_write(dev_priv, PUNIT_REG_DSPFREQ, val); |
|
- | 4899 | if (wait_for((vlv_punit_read(dev_priv, PUNIT_REG_DSPFREQ) & |
|
- | 4900 | DSPFREQSTAT_MASK_CHV) == (cmd << DSPFREQSTAT_SHIFT_CHV), |
|
- | 4901 | 50)) { |
|
- | 4902 | DRM_ERROR("timed out waiting for CDclk change\n"); |
|
- | 4903 | } |
|
- | 4904 | mutex_unlock(&dev_priv->rps.hw_lock); |
|
- | 4905 | ||
- | 4906 | vlv_update_cdclk(dev); |
|
4536 | } |
4907 | } |
4537 | 4908 | ||
4538 | static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv, |
4909 | static int valleyview_calc_cdclk(struct drm_i915_private *dev_priv, |
4539 | int max_pixclk) |
- | |
4540 | { |
4910 | int max_pixclk) |
- | 4911 | { |
|
- | 4912 | int freq_320 = (dev_priv->hpll_freq << 1) % 320000 != 0 ? 333333 : 320000; |
|
- | 4913 | ||
- | 4914 | /* FIXME: Punit isn't quite ready yet */ |
|
Line 4541... | Line 4915... | ||
4541 | int vco = valleyview_get_vco(dev_priv); |
4915 | if (IS_CHERRYVIEW(dev_priv->dev)) |
4542 | int freq_320 = (vco << 1) % 320000 != 0 ? 333333 : 320000; |
4916 | return 400000; |
4543 | 4917 | ||
4544 | /* |
4918 | /* |
Line 4601... | Line 4975... | ||
4601 | { |
4975 | { |
4602 | struct drm_i915_private *dev_priv = dev->dev_private; |
4976 | struct drm_i915_private *dev_priv = dev->dev_private; |
4603 | int max_pixclk = intel_mode_max_pixclk(dev_priv); |
4977 | int max_pixclk = intel_mode_max_pixclk(dev_priv); |
4604 | int req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk); |
4978 | int req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk); |
Line 4605... | Line 4979... | ||
4605 | 4979 | ||
- | 4980 | if (req_cdclk != dev_priv->vlv_cdclk_freq) { |
|
- | 4981 | /* |
|
- | 4982 | * FIXME: We can end up here with all power domains off, yet |
|
- | 4983 | * with a CDCLK frequency other than the minimum. To account |
|
- | 4984 | * for this take the PIPE-A power domain, which covers the HW |
|
- | 4985 | * blocks needed for the following programming. This can be |
|
- | 4986 | * removed once it's guaranteed that we get here either with |
|
- | 4987 | * the minimum CDCLK set, or the required power domains |
|
- | 4988 | * enabled. |
|
- | 4989 | */ |
|
- | 4990 | intel_display_power_get(dev_priv, POWER_DOMAIN_PIPE_A); |
|
- | 4991 | ||
- | 4992 | if (IS_CHERRYVIEW(dev)) |
|
- | 4993 | cherryview_set_cdclk(dev, req_cdclk); |
|
4606 | if (req_cdclk != dev_priv->vlv_cdclk_freq) |
4994 | else |
- | 4995 | valleyview_set_cdclk(dev, req_cdclk); |
|
4607 | valleyview_set_cdclk(dev, req_cdclk); |
4996 | |
- | 4997 | intel_display_power_put(dev_priv, POWER_DOMAIN_PIPE_A); |
|
4608 | modeset_update_crtc_power_domains(dev); |
4998 | } |
Line 4609... | Line 4999... | ||
4609 | } |
4999 | } |
4610 | 5000 | ||
4611 | static void valleyview_crtc_enable(struct drm_crtc *crtc) |
5001 | static void valleyview_crtc_enable(struct drm_crtc *crtc) |
4612 | { |
5002 | { |
4613 | struct drm_device *dev = crtc->dev; |
5003 | struct drm_device *dev = crtc->dev; |
4614 | struct drm_i915_private *dev_priv = dev->dev_private; |
5004 | struct drm_i915_private *dev_priv = to_i915(dev); |
4615 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
5005 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4616 | struct intel_encoder *encoder; |
- | |
4617 | int pipe = intel_crtc->pipe; |
5006 | struct intel_encoder *encoder; |
4618 | int plane = intel_crtc->plane; |
- | |
Line 4619... | Line 5007... | ||
4619 | bool is_dsi; |
5007 | int pipe = intel_crtc->pipe; |
Line 4620... | Line 5008... | ||
4620 | u32 dspcntr; |
5008 | bool is_dsi; |
4621 | 5009 | ||
Line 4622... | Line 5010... | ||
4622 | WARN_ON(!crtc->enabled); |
5010 | WARN_ON(!crtc->enabled); |
4623 | - | ||
4624 | if (intel_crtc->active) |
- | |
4625 | return; |
- | |
Line -... | Line 5011... | ||
- | 5011 | ||
- | 5012 | if (intel_crtc->active) |
|
4626 | 5013 | return; |
|
- | 5014 | ||
4627 | is_dsi = intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI); |
5015 | is_dsi = intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI); |
- | 5016 | ||
Line 4628... | Line 5017... | ||
4628 | 5017 | if (!is_dsi) { |
|
4629 | if (!is_dsi && !IS_CHERRYVIEW(dev)) |
5018 | if (IS_CHERRYVIEW(dev)) |
Line 4630... | Line 5019... | ||
4630 | vlv_prepare_pll(intel_crtc); |
5019 | chv_prepare_pll(intel_crtc, &intel_crtc->config); |
Line 4631... | Line -... | ||
4631 | - | ||
4632 | /* Set up the display plane register */ |
- | |
4633 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
- | |
4634 | - | ||
4635 | if (intel_crtc->config.has_dp_encoder) |
5020 | else |
4636 | intel_dp_set_m_n(intel_crtc); |
5021 | vlv_prepare_pll(intel_crtc, &intel_crtc->config); |
4637 | - | ||
4638 | intel_set_pipe_timings(intel_crtc); |
- | |
4639 | - | ||
Line 4640... | Line 5022... | ||
4640 | /* pipesrc and dspsize control the size that is scaled from, |
5022 | } |
4641 | * which should always be the user's requested size. |
5023 | |
- | 5024 | if (intel_crtc->config.has_dp_encoder) |
|
Line 4642... | Line -... | ||
4642 | */ |
- | |
4643 | I915_WRITE(DSPSIZE(plane), |
5025 | intel_dp_set_m_n(intel_crtc); |
Line 4644... | Line 5026... | ||
4644 | ((intel_crtc->config.pipe_src_h - 1) << 16) | |
5026 | |
Line 4645... | Line 5027... | ||
4645 | (intel_crtc->config.pipe_src_w - 1)); |
5027 | intel_set_pipe_timings(intel_crtc); |
Line 4646... | Line 5028... | ||
4646 | I915_WRITE(DSPPOS(plane), 0); |
5028 | |
4647 | 5029 | if (IS_CHERRYVIEW(dev) && pipe == PIPE_B) { |
|
4648 | i9xx_set_pipeconf(intel_crtc); |
5030 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 4649... | Line 5031... | ||
4649 | 5031 | ||
4650 | I915_WRITE(DSPCNTR(plane), dspcntr); |
5032 | I915_WRITE(CHV_BLEND(pipe), CHV_BLEND_LEGACY); |
4651 | POSTING_READ(DSPCNTR(plane)); |
5033 | I915_WRITE(CHV_CANVAS(pipe), 0); |
4652 | 5034 | } |
|
4653 | dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, |
5035 | |
4654 | crtc->x, crtc->y); |
5036 | i9xx_set_pipeconf(intel_crtc); |
Line 4655... | Line 5037... | ||
4655 | 5037 | ||
4656 | intel_crtc->active = true; |
5038 | intel_crtc->active = true; |
4657 | 5039 | ||
Line 4680... | Line 5062... | ||
4680 | intel_enable_pipe(intel_crtc); |
5062 | intel_enable_pipe(intel_crtc); |
Line 4681... | Line 5063... | ||
4681 | 5063 | ||
4682 | for_each_encoder_on_crtc(dev, crtc, encoder) |
5064 | for_each_encoder_on_crtc(dev, crtc, encoder) |
Line -... | Line 5065... | ||
- | 5065 | encoder->enable(encoder); |
|
- | 5066 | ||
- | 5067 | assert_vblank_disabled(crtc); |
|
4683 | encoder->enable(encoder); |
5068 | drm_crtc_vblank_on(crtc); |
Line 4684... | Line 5069... | ||
4684 | 5069 | ||
4685 | intel_crtc_enable_planes(crtc); |
5070 | intel_crtc_enable_planes(crtc); |
4686 | 5071 | ||
Line 4687... | Line 5072... | ||
4687 | /* Underruns don't raise interrupts, so check manually. */ |
5072 | /* Underruns don't raise interrupts, so check manually. */ |
4688 | i9xx_check_fifo_underruns(dev); |
5073 | i9xx_check_fifo_underruns(dev_priv); |
4689 | } |
5074 | } |
Line 4698... | Line 5083... | ||
4698 | } |
5083 | } |
Line 4699... | Line 5084... | ||
4699 | 5084 | ||
4700 | static void i9xx_crtc_enable(struct drm_crtc *crtc) |
5085 | static void i9xx_crtc_enable(struct drm_crtc *crtc) |
4701 | { |
5086 | { |
4702 | struct drm_device *dev = crtc->dev; |
5087 | struct drm_device *dev = crtc->dev; |
4703 | struct drm_i915_private *dev_priv = dev->dev_private; |
5088 | struct drm_i915_private *dev_priv = to_i915(dev); |
4704 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
5089 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
4705 | struct intel_encoder *encoder; |
5090 | struct intel_encoder *encoder; |
4706 | int pipe = intel_crtc->pipe; |
- | |
4707 | int plane = intel_crtc->plane; |
- | |
Line 4708... | Line 5091... | ||
4708 | u32 dspcntr; |
5091 | int pipe = intel_crtc->pipe; |
Line 4709... | Line 5092... | ||
4709 | 5092 | ||
4710 | WARN_ON(!crtc->enabled); |
5093 | WARN_ON(!crtc->enabled); |
Line 4711... | Line 5094... | ||
4711 | 5094 | ||
Line 4712... | Line -... | ||
4712 | if (intel_crtc->active) |
- | |
4713 | return; |
- | |
4714 | - | ||
4715 | i9xx_set_pll_dividers(intel_crtc); |
- | |
4716 | - | ||
4717 | /* Set up the display plane register */ |
- | |
4718 | dspcntr = DISPPLANE_GAMMA_ENABLE; |
- | |
4719 | - | ||
4720 | if (pipe == 0) |
5095 | if (intel_crtc->active) |
4721 | dspcntr &= ~DISPPLANE_SEL_PIPE_MASK; |
5096 | return; |
Line 4722... | Line 5097... | ||
4722 | else |
5097 | |
Line 4723... | Line -... | ||
4723 | dspcntr |= DISPPLANE_SEL_PIPE_B; |
- | |
4724 | - | ||
4725 | if (intel_crtc->config.has_dp_encoder) |
- | |
4726 | intel_dp_set_m_n(intel_crtc); |
- | |
4727 | - | ||
4728 | intel_set_pipe_timings(intel_crtc); |
- | |
4729 | - | ||
4730 | /* pipesrc and dspsize control the size that is scaled from, |
- | |
4731 | * which should always be the user's requested size. |
5098 | i9xx_set_pll_dividers(intel_crtc); |
Line 4732... | Line -... | ||
4732 | */ |
- | |
4733 | I915_WRITE(DSPSIZE(plane), |
- | |
4734 | ((intel_crtc->config.pipe_src_h - 1) << 16) | |
- | |
4735 | (intel_crtc->config.pipe_src_w - 1)); |
- | |
4736 | I915_WRITE(DSPPOS(plane), 0); |
- | |
4737 | - | ||
4738 | i9xx_set_pipeconf(intel_crtc); |
5099 | |
Line 4739... | Line 5100... | ||
4739 | 5100 | if (intel_crtc->config.has_dp_encoder) |
|
4740 | I915_WRITE(DSPCNTR(plane), dspcntr); |
5101 | intel_dp_set_m_n(intel_crtc); |
Line 4741... | Line 5102... | ||
4741 | POSTING_READ(DSPCNTR(plane)); |
5102 | |
4742 | 5103 | intel_set_pipe_timings(intel_crtc); |
|
4743 | dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, |
5104 | |
Line 4762... | Line 5123... | ||
4762 | intel_enable_pipe(intel_crtc); |
5123 | intel_enable_pipe(intel_crtc); |
Line 4763... | Line 5124... | ||
4763 | 5124 | ||
4764 | for_each_encoder_on_crtc(dev, crtc, encoder) |
5125 | for_each_encoder_on_crtc(dev, crtc, encoder) |
Line -... | Line 5126... | ||
- | 5126 | encoder->enable(encoder); |
|
- | 5127 | ||
- | 5128 | assert_vblank_disabled(crtc); |
|
4765 | encoder->enable(encoder); |
5129 | drm_crtc_vblank_on(crtc); |
Line 4766... | Line 5130... | ||
4766 | 5130 | ||
4767 | intel_crtc_enable_planes(crtc); |
5131 | intel_crtc_enable_planes(crtc); |
4768 | 5132 | ||
4769 | /* |
5133 | /* |
4770 | * Gen2 reports pipe underruns whenever all planes are disabled. |
5134 | * Gen2 reports pipe underruns whenever all planes are disabled. |
4771 | * So don't enable underrun reporting before at least some planes |
5135 | * So don't enable underrun reporting before at least some planes |
4772 | * are enabled. |
5136 | * are enabled. |
4773 | * FIXME: Need to fix the logic to work when we turn off all planes |
5137 | * FIXME: Need to fix the logic to work when we turn off all planes |
4774 | * but leave the pipe running. |
5138 | * but leave the pipe running. |
Line 4775... | Line 5139... | ||
4775 | */ |
5139 | */ |
4776 | if (IS_GEN2(dev)) |
5140 | if (IS_GEN2(dev)) |
4777 | intel_set_cpu_fifo_underrun_reporting(dev, pipe, true); |
5141 | intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, true); |
Line 4778... | Line 5142... | ||
4778 | 5142 | ||
4779 | /* Underruns don't raise interrupts, so check manually. */ |
5143 | /* Underruns don't raise interrupts, so check manually. */ |
4780 | i9xx_check_fifo_underruns(dev); |
5144 | i9xx_check_fifo_underruns(dev_priv); |
Line 4811... | Line 5175... | ||
4811 | * So diasble underrun reporting before all the planes get disabled. |
5175 | * So diasble underrun reporting before all the planes get disabled. |
4812 | * FIXME: Need to fix the logic to work when we turn off all planes |
5176 | * FIXME: Need to fix the logic to work when we turn off all planes |
4813 | * but leave the pipe running. |
5177 | * but leave the pipe running. |
4814 | */ |
5178 | */ |
4815 | if (IS_GEN2(dev)) |
5179 | if (IS_GEN2(dev)) |
4816 | intel_set_cpu_fifo_underrun_reporting(dev, pipe, false); |
5180 | intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false); |
Line 4817... | Line 5181... | ||
4817 | 5181 | ||
4818 | /* |
5182 | /* |
4819 | * Vblank time updates from the shadow to live plane control register |
5183 | * Vblank time updates from the shadow to live plane control register |
4820 | * are blocked if the memory self-refresh mode is active at that |
5184 | * are blocked if the memory self-refresh mode is active at that |
Line 4825... | Line 5189... | ||
4825 | * wait-for-vblank between disabling the plane and the pipe. |
5189 | * wait-for-vblank between disabling the plane and the pipe. |
4826 | */ |
5190 | */ |
4827 | intel_set_memory_cxsr(dev_priv, false); |
5191 | intel_set_memory_cxsr(dev_priv, false); |
4828 | intel_crtc_disable_planes(crtc); |
5192 | intel_crtc_disable_planes(crtc); |
Line 4829... | Line -... | ||
4829 | - | ||
4830 | for_each_encoder_on_crtc(dev, crtc, encoder) |
- | |
4831 | encoder->disable(encoder); |
- | |
4832 | 5193 | ||
4833 | /* |
5194 | /* |
4834 | * On gen2 planes are double buffered but the pipe isn't, so we must |
5195 | * On gen2 planes are double buffered but the pipe isn't, so we must |
4835 | * wait for planes to fully turn off before disabling the pipe. |
5196 | * wait for planes to fully turn off before disabling the pipe. |
4836 | * We also need to wait on all gmch platforms because of the |
5197 | * We also need to wait on all gmch platforms because of the |
4837 | * self-refresh mode constraint explained above. |
5198 | * self-refresh mode constraint explained above. |
4838 | */ |
5199 | */ |
Line -... | Line 5200... | ||
- | 5200 | intel_wait_for_vblank(dev, pipe); |
|
- | 5201 | ||
- | 5202 | drm_crtc_vblank_off(crtc); |
|
- | 5203 | assert_vblank_disabled(crtc); |
|
- | 5204 | ||
- | 5205 | for_each_encoder_on_crtc(dev, crtc, encoder) |
|
4839 | intel_wait_for_vblank(dev, pipe); |
5206 | encoder->disable(encoder); |
Line 4840... | Line 5207... | ||
4840 | 5207 | ||
Line 4841... | Line 5208... | ||
4841 | intel_disable_pipe(dev_priv, pipe); |
5208 | intel_disable_pipe(intel_crtc); |
4842 | 5209 | ||
4843 | i9xx_pfit_disable(intel_crtc); |
5210 | i9xx_pfit_disable(intel_crtc); |
Line 4844... | Line 5211... | ||
4844 | 5211 | ||
4845 | for_each_encoder_on_crtc(dev, crtc, encoder) |
5212 | for_each_encoder_on_crtc(dev, crtc, encoder) |
4846 | if (encoder->post_disable) |
5213 | if (encoder->post_disable) |
4847 | encoder->post_disable(encoder); |
5214 | encoder->post_disable(encoder); |
4848 | 5215 | ||
4849 | if (!intel_pipe_has_type(crtc, INTEL_OUTPUT_DSI)) { |
5216 | if (!intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_DSI)) { |
4850 | if (IS_CHERRYVIEW(dev)) |
5217 | if (IS_CHERRYVIEW(dev)) |
4851 | chv_disable_pll(dev_priv, pipe); |
5218 | chv_disable_pll(dev_priv, pipe); |
Line 4852... | Line 5219... | ||
4852 | else if (IS_VALLEYVIEW(dev)) |
5219 | else if (IS_VALLEYVIEW(dev)) |
4853 | vlv_disable_pll(dev_priv, pipe); |
5220 | vlv_disable_pll(dev_priv, pipe); |
Line 4854... | Line 5221... | ||
4854 | else |
5221 | else |
4855 | i9xx_disable_pll(dev_priv, pipe); |
5222 | i9xx_disable_pll(intel_crtc); |
Line 4856... | Line 5223... | ||
4856 | } |
5223 | } |
Line 4868... | Line 5235... | ||
4868 | 5235 | ||
4869 | static void i9xx_crtc_off(struct drm_crtc *crtc) |
5236 | static void i9xx_crtc_off(struct drm_crtc *crtc) |
4870 | { |
5237 | { |
Line 4871... | Line -... | ||
4871 | } |
- | |
4872 | - | ||
4873 | static void intel_crtc_update_sarea(struct drm_crtc *crtc, |
- | |
4874 | bool enabled) |
- | |
4875 | { |
- | |
4876 | struct drm_device *dev = crtc->dev; |
- | |
4877 | struct drm_i915_master_private *master_priv; |
- | |
4878 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
- | |
4879 | int pipe = intel_crtc->pipe; |
- | |
4880 | - | ||
4881 | - | ||
4882 | #if 0 |
- | |
4883 | if (!dev->primary->master) |
- | |
4884 | return; |
- | |
4885 | - | ||
4886 | master_priv = dev->primary->master->driver_priv; |
- | |
4887 | if (!master_priv->sarea_priv) |
- | |
4888 | return; |
- | |
4889 | - | ||
4890 | switch (pipe) { |
- | |
4891 | case 0: |
- | |
4892 | master_priv->sarea_priv->pipeA_w = enabled ? crtc->mode.hdisplay : 0; |
- | |
4893 | master_priv->sarea_priv->pipeA_h = enabled ? crtc->mode.vdisplay : 0; |
- | |
4894 | break; |
- | |
4895 | case 1: |
- | |
4896 | master_priv->sarea_priv->pipeB_w = enabled ? crtc->mode.hdisplay : 0; |
- | |
4897 | master_priv->sarea_priv->pipeB_h = enabled ? crtc->mode.vdisplay : 0; |
- | |
4898 | break; |
- | |
4899 | default: |
- | |
4900 | DRM_ERROR("Can't update pipe %c in SAREA\n", pipe_name(pipe)); |
- | |
4901 | break; |
- | |
4902 | } |
- | |
4903 | #endif |
- | |
4904 | } |
5238 | } |
4905 | 5239 | ||
4906 | /* Master function to enable/disable CRTC and corresponding power wells */ |
5240 | /* Master function to enable/disable CRTC and corresponding power wells */ |
4907 | void intel_crtc_control(struct drm_crtc *crtc, bool enable) |
5241 | void intel_crtc_control(struct drm_crtc *crtc, bool enable) |
4908 | { |
5242 | { |
Line 4944... | Line 5278... | ||
4944 | 5278 | ||
4945 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
5279 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) |
Line 4946... | Line 5280... | ||
4946 | enable |= intel_encoder->connectors_active; |
5280 | enable |= intel_encoder->connectors_active; |
4947 | - | ||
4948 | intel_crtc_control(crtc, enable); |
- | |
4949 | 5281 | ||
Line 4950... | Line 5282... | ||
4950 | intel_crtc_update_sarea(crtc, enable); |
5282 | intel_crtc_control(crtc, enable); |
4951 | } |
5283 | } |
4952 | 5284 | ||
Line 4960... | Line 5292... | ||
4960 | 5292 | ||
4961 | /* crtc should still be enabled when we disable it. */ |
5293 | /* crtc should still be enabled when we disable it. */ |
Line 4962... | Line 5294... | ||
4962 | WARN_ON(!crtc->enabled); |
5294 | WARN_ON(!crtc->enabled); |
4963 | - | ||
4964 | dev_priv->display.crtc_disable(crtc); |
5295 | |
Line 4965... | Line 5296... | ||
4965 | intel_crtc_update_sarea(crtc, false); |
5296 | dev_priv->display.crtc_disable(crtc); |
4966 | dev_priv->display.off(crtc); |
5297 | dev_priv->display.off(crtc); |
4967 | 5298 | ||
Line 5199... | Line 5530... | ||
5199 | 5530 | ||
5200 | static int intel_crtc_compute_config(struct intel_crtc *crtc, |
5531 | static int intel_crtc_compute_config(struct intel_crtc *crtc, |
5201 | struct intel_crtc_config *pipe_config) |
5532 | struct intel_crtc_config *pipe_config) |
5202 | { |
5533 | { |
- | 5534 | struct drm_device *dev = crtc->base.dev; |
|
5203 | struct drm_device *dev = crtc->base.dev; |
5535 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 5204... | Line 5536... | ||
5204 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
5536 | struct drm_display_mode *adjusted_mode = &pipe_config->adjusted_mode; |
5205 | 5537 | ||
5206 | /* FIXME should check pixel clock limits on all platforms */ |
- | |
5207 | if (INTEL_INFO(dev)->gen < 4) { |
5538 | /* FIXME should check pixel clock limits on all platforms */ |
5208 | struct drm_i915_private *dev_priv = dev->dev_private; |
5539 | if (INTEL_INFO(dev)->gen < 4) { |
Line 5209... | Line 5540... | ||
5209 | int clock_limit = |
5540 | int clock_limit = |
5210 | dev_priv->display.get_display_clock_speed(dev); |
5541 | dev_priv->display.get_display_clock_speed(dev); |
Line 5230... | Line 5561... | ||
5230 | * Pipe horizontal size must be even in: |
5561 | * Pipe horizontal size must be even in: |
5231 | * - DVO ganged mode |
5562 | * - DVO ganged mode |
5232 | * - LVDS dual channel mode |
5563 | * - LVDS dual channel mode |
5233 | * - Double wide pipe |
5564 | * - Double wide pipe |
5234 | */ |
5565 | */ |
5235 | if ((intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) && |
5566 | if ((intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && |
5236 | intel_is_dual_link_lvds(dev)) || pipe_config->double_wide) |
5567 | intel_is_dual_link_lvds(dev)) || pipe_config->double_wide) |
5237 | pipe_config->pipe_src_w &= ~1; |
5568 | pipe_config->pipe_src_w &= ~1; |
Line 5238... | Line 5569... | ||
5238 | 5569 | ||
5239 | /* Cantiga+ cannot handle modes with a hsync front porch of 0. |
5570 | /* Cantiga+ cannot handle modes with a hsync front porch of 0. |
Line 5252... | Line 5583... | ||
5252 | } |
5583 | } |
Line 5253... | Line 5584... | ||
5253 | 5584 | ||
5254 | if (HAS_IPS(dev)) |
5585 | if (HAS_IPS(dev)) |
Line 5255... | Line -... | ||
5255 | hsw_compute_ips_config(crtc, pipe_config); |
- | |
5256 | - | ||
5257 | /* |
- | |
5258 | * XXX: PCH/WRPLL clock sharing is done in ->mode_set, so make sure the |
- | |
5259 | * old clock survives for now. |
- | |
5260 | */ |
- | |
5261 | if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev) || HAS_DDI(dev)) |
- | |
5262 | pipe_config->shared_dpll = crtc->config.shared_dpll; |
5586 | hsw_compute_ips_config(crtc, pipe_config); |
5263 | 5587 | ||
Line 5264... | Line 5588... | ||
5264 | if (pipe_config->has_pch_encoder) |
5588 | if (pipe_config->has_pch_encoder) |
5265 | return ironlake_fdi_compute_config(crtc, pipe_config); |
5589 | return ironlake_fdi_compute_config(crtc, pipe_config); |
Line 5266... | Line 5590... | ||
5266 | 5590 | ||
5267 | return 0; |
5591 | return 0; |
5268 | } |
5592 | } |
5269 | - | ||
5270 | static int valleyview_get_display_clock_speed(struct drm_device *dev) |
5593 | |
5271 | { |
5594 | static int valleyview_get_display_clock_speed(struct drm_device *dev) |
Line -... | Line 5595... | ||
- | 5595 | { |
|
- | 5596 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 5597 | u32 val; |
|
- | 5598 | int divider; |
|
- | 5599 | ||
- | 5600 | /* FIXME: Punit isn't quite ready yet */ |
|
- | 5601 | if (IS_CHERRYVIEW(dev)) |
|
5272 | struct drm_i915_private *dev_priv = dev->dev_private; |
5602 | return 400000; |
5273 | int vco = valleyview_get_vco(dev_priv); |
5603 | |
5274 | u32 val; |
5604 | if (dev_priv->hpll_freq == 0) |
Line 5275... | Line 5605... | ||
5275 | int divider; |
5605 | dev_priv->hpll_freq = valleyview_get_vco(dev_priv); |
Line 5276... | Line 5606... | ||
5276 | 5606 | ||
5277 | mutex_lock(&dev_priv->dpio_lock); |
5607 | mutex_lock(&dev_priv->dpio_lock); |
5278 | val = vlv_cck_read(dev_priv, CCK_DISPLAY_CLOCK_CONTROL); |
5608 | val = vlv_cck_read(dev_priv, CCK_DISPLAY_CLOCK_CONTROL); |
Line 5279... | Line 5609... | ||
5279 | mutex_unlock(&dev_priv->dpio_lock); |
5609 | mutex_unlock(&dev_priv->dpio_lock); |
5280 | 5610 | ||
Line 5281... | Line 5611... | ||
5281 | divider = val & DISPLAY_FREQUENCY_VALUES; |
5611 | divider = val & DISPLAY_FREQUENCY_VALUES; |
5282 | 5612 | ||
5283 | WARN((val & DISPLAY_FREQUENCY_STATUS) != |
5613 | WARN((val & DISPLAY_FREQUENCY_STATUS) != |
Line 5414... | Line 5744... | ||
5414 | return i915.panel_use_ssc != 0; |
5744 | return i915.panel_use_ssc != 0; |
5415 | return dev_priv->vbt.lvds_use_ssc |
5745 | return dev_priv->vbt.lvds_use_ssc |
5416 | && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE); |
5746 | && !(dev_priv->quirks & QUIRK_LVDS_SSC_DISABLE); |
5417 | } |
5747 | } |
Line 5418... | Line 5748... | ||
5418 | 5748 | ||
5419 | static int i9xx_get_refclk(struct drm_crtc *crtc, int num_connectors) |
5749 | static int i9xx_get_refclk(struct intel_crtc *crtc, int num_connectors) |
5420 | { |
5750 | { |
5421 | struct drm_device *dev = crtc->dev; |
5751 | struct drm_device *dev = crtc->base.dev; |
5422 | struct drm_i915_private *dev_priv = dev->dev_private; |
5752 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 5423... | Line 5753... | ||
5423 | int refclk; |
5753 | int refclk; |
5424 | 5754 | ||
5425 | if (IS_VALLEYVIEW(dev)) { |
5755 | if (IS_VALLEYVIEW(dev)) { |
5426 | refclk = 100000; |
5756 | refclk = 100000; |
5427 | } else if (intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS) && |
5757 | } else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) && |
5428 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) { |
5758 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) { |
5429 | refclk = dev_priv->vbt.lvds_ssc_freq; |
5759 | refclk = dev_priv->vbt.lvds_ssc_freq; |
5430 | DRM_DEBUG_KMS("using SSC reference clock of %d kHz\n", refclk); |
5760 | DRM_DEBUG_KMS("using SSC reference clock of %d kHz\n", refclk); |
Line 5452... | Line 5782... | ||
5452 | { |
5782 | { |
5453 | struct drm_device *dev = crtc->base.dev; |
5783 | struct drm_device *dev = crtc->base.dev; |
5454 | u32 fp, fp2 = 0; |
5784 | u32 fp, fp2 = 0; |
Line 5455... | Line 5785... | ||
5455 | 5785 | ||
5456 | if (IS_PINEVIEW(dev)) { |
5786 | if (IS_PINEVIEW(dev)) { |
5457 | fp = pnv_dpll_compute_fp(&crtc->config.dpll); |
5787 | fp = pnv_dpll_compute_fp(&crtc->new_config->dpll); |
5458 | if (reduced_clock) |
5788 | if (reduced_clock) |
5459 | fp2 = pnv_dpll_compute_fp(reduced_clock); |
5789 | fp2 = pnv_dpll_compute_fp(reduced_clock); |
5460 | } else { |
5790 | } else { |
5461 | fp = i9xx_dpll_compute_fp(&crtc->config.dpll); |
5791 | fp = i9xx_dpll_compute_fp(&crtc->new_config->dpll); |
5462 | if (reduced_clock) |
5792 | if (reduced_clock) |
5463 | fp2 = i9xx_dpll_compute_fp(reduced_clock); |
5793 | fp2 = i9xx_dpll_compute_fp(reduced_clock); |
Line 5464... | Line 5794... | ||
5464 | } |
5794 | } |
Line 5465... | Line 5795... | ||
5465 | 5795 | ||
5466 | crtc->config.dpll_hw_state.fp0 = fp; |
5796 | crtc->new_config->dpll_hw_state.fp0 = fp; |
5467 | 5797 | ||
5468 | crtc->lowfreq_avail = false; |
5798 | crtc->lowfreq_avail = false; |
5469 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) && |
5799 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) && |
5470 | reduced_clock && i915.powersave) { |
5800 | reduced_clock && i915.powersave) { |
5471 | crtc->config.dpll_hw_state.fp1 = fp2; |
5801 | crtc->new_config->dpll_hw_state.fp1 = fp2; |
5472 | crtc->lowfreq_avail = true; |
5802 | crtc->lowfreq_avail = true; |
5473 | } else { |
5803 | } else { |
Line 5474... | Line 5804... | ||
5474 | crtc->config.dpll_hw_state.fp1 = fp; |
5804 | crtc->new_config->dpll_hw_state.fp1 = fp; |
5475 | } |
5805 | } |
Line 5516... | Line 5846... | ||
5516 | I915_WRITE(PCH_TRANS_LINK_M1(pipe), m_n->link_m); |
5846 | I915_WRITE(PCH_TRANS_LINK_M1(pipe), m_n->link_m); |
5517 | I915_WRITE(PCH_TRANS_LINK_N1(pipe), m_n->link_n); |
5847 | I915_WRITE(PCH_TRANS_LINK_N1(pipe), m_n->link_n); |
5518 | } |
5848 | } |
Line 5519... | Line 5849... | ||
5519 | 5849 | ||
5520 | static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc, |
5850 | static void intel_cpu_transcoder_set_m_n(struct intel_crtc *crtc, |
- | 5851 | struct intel_link_m_n *m_n, |
|
5521 | struct intel_link_m_n *m_n) |
5852 | struct intel_link_m_n *m2_n2) |
5522 | { |
5853 | { |
5523 | struct drm_device *dev = crtc->base.dev; |
5854 | struct drm_device *dev = crtc->base.dev; |
5524 | struct drm_i915_private *dev_priv = dev->dev_private; |
5855 | struct drm_i915_private *dev_priv = dev->dev_private; |
5525 | int pipe = crtc->pipe; |
5856 | int pipe = crtc->pipe; |
Line 5528... | Line 5859... | ||
5528 | if (INTEL_INFO(dev)->gen >= 5) { |
5859 | if (INTEL_INFO(dev)->gen >= 5) { |
5529 | I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m); |
5860 | I915_WRITE(PIPE_DATA_M1(transcoder), TU_SIZE(m_n->tu) | m_n->gmch_m); |
5530 | I915_WRITE(PIPE_DATA_N1(transcoder), m_n->gmch_n); |
5861 | I915_WRITE(PIPE_DATA_N1(transcoder), m_n->gmch_n); |
5531 | I915_WRITE(PIPE_LINK_M1(transcoder), m_n->link_m); |
5862 | I915_WRITE(PIPE_LINK_M1(transcoder), m_n->link_m); |
5532 | I915_WRITE(PIPE_LINK_N1(transcoder), m_n->link_n); |
5863 | I915_WRITE(PIPE_LINK_N1(transcoder), m_n->link_n); |
- | 5864 | /* M2_N2 registers to be set only for gen < 8 (M2_N2 available |
|
- | 5865 | * for gen < 8) and if DRRS is supported (to make sure the |
|
- | 5866 | * registers are not unnecessarily accessed). |
|
- | 5867 | */ |
|
- | 5868 | if (m2_n2 && INTEL_INFO(dev)->gen < 8 && |
|
- | 5869 | crtc->config.has_drrs) { |
|
- | 5870 | I915_WRITE(PIPE_DATA_M2(transcoder), |
|
- | 5871 | TU_SIZE(m2_n2->tu) | m2_n2->gmch_m); |
|
- | 5872 | I915_WRITE(PIPE_DATA_N2(transcoder), m2_n2->gmch_n); |
|
- | 5873 | I915_WRITE(PIPE_LINK_M2(transcoder), m2_n2->link_m); |
|
- | 5874 | I915_WRITE(PIPE_LINK_N2(transcoder), m2_n2->link_n); |
|
- | 5875 | } |
|
5533 | } else { |
5876 | } else { |
5534 | I915_WRITE(PIPE_DATA_M_G4X(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m); |
5877 | I915_WRITE(PIPE_DATA_M_G4X(pipe), TU_SIZE(m_n->tu) | m_n->gmch_m); |
5535 | I915_WRITE(PIPE_DATA_N_G4X(pipe), m_n->gmch_n); |
5878 | I915_WRITE(PIPE_DATA_N_G4X(pipe), m_n->gmch_n); |
5536 | I915_WRITE(PIPE_LINK_M_G4X(pipe), m_n->link_m); |
5879 | I915_WRITE(PIPE_LINK_M_G4X(pipe), m_n->link_m); |
5537 | I915_WRITE(PIPE_LINK_N_G4X(pipe), m_n->link_n); |
5880 | I915_WRITE(PIPE_LINK_N_G4X(pipe), m_n->link_n); |
5538 | } |
5881 | } |
5539 | } |
5882 | } |
Line 5540... | Line 5883... | ||
5540 | 5883 | ||
5541 | static void intel_dp_set_m_n(struct intel_crtc *crtc) |
5884 | void intel_dp_set_m_n(struct intel_crtc *crtc) |
5542 | { |
5885 | { |
5543 | if (crtc->config.has_pch_encoder) |
5886 | if (crtc->config.has_pch_encoder) |
5544 | intel_pch_transcoder_set_m_n(crtc, &crtc->config.dp_m_n); |
5887 | intel_pch_transcoder_set_m_n(crtc, &crtc->config.dp_m_n); |
5545 | else |
5888 | else |
- | 5889 | intel_cpu_transcoder_set_m_n(crtc, &crtc->config.dp_m_n, |
|
5546 | intel_cpu_transcoder_set_m_n(crtc, &crtc->config.dp_m_n); |
5890 | &crtc->config.dp_m2_n2); |
Line 5547... | Line 5891... | ||
5547 | } |
5891 | } |
- | 5892 | ||
5548 | 5893 | static void vlv_update_pll(struct intel_crtc *crtc, |
|
5549 | static void vlv_update_pll(struct intel_crtc *crtc) |
5894 | struct intel_crtc_config *pipe_config) |
Line 5550... | Line 5895... | ||
5550 | { |
5895 | { |
5551 | u32 dpll, dpll_md; |
5896 | u32 dpll, dpll_md; |
Line 5559... | Line 5904... | ||
5559 | DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV; |
5904 | DPLL_VGA_MODE_DIS | DPLL_INTEGRATED_CLOCK_VLV; |
5560 | /* We should never disable this, set it here for state tracking */ |
5905 | /* We should never disable this, set it here for state tracking */ |
5561 | if (crtc->pipe == PIPE_B) |
5906 | if (crtc->pipe == PIPE_B) |
5562 | dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; |
5907 | dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; |
5563 | dpll |= DPLL_VCO_ENABLE; |
5908 | dpll |= DPLL_VCO_ENABLE; |
5564 | crtc->config.dpll_hw_state.dpll = dpll; |
5909 | pipe_config->dpll_hw_state.dpll = dpll; |
Line 5565... | Line 5910... | ||
5565 | 5910 | ||
5566 | dpll_md = (crtc->config.pixel_multiplier - 1) |
5911 | dpll_md = (pipe_config->pixel_multiplier - 1) |
5567 | << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
5912 | << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
5568 | crtc->config.dpll_hw_state.dpll_md = dpll_md; |
5913 | pipe_config->dpll_hw_state.dpll_md = dpll_md; |
Line 5569... | Line 5914... | ||
5569 | } |
5914 | } |
- | 5915 | ||
5570 | 5916 | static void vlv_prepare_pll(struct intel_crtc *crtc, |
|
5571 | static void vlv_prepare_pll(struct intel_crtc *crtc) |
5917 | const struct intel_crtc_config *pipe_config) |
5572 | { |
5918 | { |
5573 | struct drm_device *dev = crtc->base.dev; |
5919 | struct drm_device *dev = crtc->base.dev; |
5574 | struct drm_i915_private *dev_priv = dev->dev_private; |
5920 | struct drm_i915_private *dev_priv = dev->dev_private; |
5575 | int pipe = crtc->pipe; |
5921 | int pipe = crtc->pipe; |
5576 | u32 mdiv; |
5922 | u32 mdiv; |
Line 5577... | Line 5923... | ||
5577 | u32 bestn, bestm1, bestm2, bestp1, bestp2; |
5923 | u32 bestn, bestm1, bestm2, bestp1, bestp2; |
Line 5578... | Line 5924... | ||
5578 | u32 coreclk, reg_val; |
5924 | u32 coreclk, reg_val; |
5579 | 5925 | ||
5580 | mutex_lock(&dev_priv->dpio_lock); |
5926 | mutex_lock(&dev_priv->dpio_lock); |
5581 | 5927 | ||
5582 | bestn = crtc->config.dpll.n; |
5928 | bestn = pipe_config->dpll.n; |
Line 5583... | Line 5929... | ||
5583 | bestm1 = crtc->config.dpll.m1; |
5929 | bestm1 = pipe_config->dpll.m1; |
Line 5584... | Line 5930... | ||
5584 | bestm2 = crtc->config.dpll.m2; |
5930 | bestm2 = pipe_config->dpll.m2; |
5585 | bestp1 = crtc->config.dpll.p1; |
5931 | bestp1 = pipe_config->dpll.p1; |
Line 5618... | Line 5964... | ||
5618 | 5964 | ||
5619 | mdiv |= DPIO_ENABLE_CALIBRATION; |
5965 | mdiv |= DPIO_ENABLE_CALIBRATION; |
Line 5620... | Line 5966... | ||
5620 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv); |
5966 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW3(pipe), mdiv); |
5621 | 5967 | ||
5622 | /* Set HBR and RBR LPF coefficients */ |
5968 | /* Set HBR and RBR LPF coefficients */ |
5623 | if (crtc->config.port_clock == 162000 || |
5969 | if (pipe_config->port_clock == 162000 || |
5624 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_ANALOG) || |
5970 | intel_pipe_has_type(crtc, INTEL_OUTPUT_ANALOG) || |
5625 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI)) |
5971 | intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI)) |
5626 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe), |
5972 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe), |
5627 | 0x009f0003); |
5973 | 0x009f0003); |
5628 | else |
5974 | else |
Line 5629... | Line 5975... | ||
5629 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe), |
5975 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW10(pipe), |
5630 | 0x00d0000f); |
- | |
5631 | 5976 | 0x00d0000f); |
|
5632 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP) || |
5977 | |
5633 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT)) { |
5978 | if (crtc->config.has_dp_encoder) { |
5634 | /* Use SSC source */ |
5979 | /* Use SSC source */ |
5635 | if (pipe == PIPE_A) |
5980 | if (pipe == PIPE_A) |
Line 5648... | Line 5993... | ||
5648 | 0x0df40000); |
5993 | 0x0df40000); |
5649 | } |
5994 | } |
Line 5650... | Line 5995... | ||
5650 | 5995 | ||
5651 | coreclk = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW7(pipe)); |
5996 | coreclk = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW7(pipe)); |
5652 | coreclk = (coreclk & 0x0000ff00) | 0x01c00000; |
5997 | coreclk = (coreclk & 0x0000ff00) | 0x01c00000; |
5653 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DISPLAYPORT) || |
5998 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT) || |
5654 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_EDP)) |
5999 | intel_pipe_has_type(crtc, INTEL_OUTPUT_EDP)) |
5655 | coreclk |= 0x01000000; |
6000 | coreclk |= 0x01000000; |
Line 5656... | Line 6001... | ||
5656 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW7(pipe), coreclk); |
6001 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW7(pipe), coreclk); |
5657 | 6002 | ||
5658 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW11(pipe), 0x87871000); |
6003 | vlv_dpio_write(dev_priv, pipe, VLV_PLL_DW11(pipe), 0x87871000); |
Line 5659... | Line 6004... | ||
5659 | mutex_unlock(&dev_priv->dpio_lock); |
6004 | mutex_unlock(&dev_priv->dpio_lock); |
- | 6005 | } |
|
- | 6006 | ||
- | 6007 | static void chv_update_pll(struct intel_crtc *crtc, |
|
- | 6008 | struct intel_crtc_config *pipe_config) |
|
- | 6009 | { |
|
- | 6010 | pipe_config->dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV | |
|
- | 6011 | DPLL_REFA_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS | |
|
- | 6012 | DPLL_VCO_ENABLE; |
|
- | 6013 | if (crtc->pipe != PIPE_A) |
|
- | 6014 | pipe_config->dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; |
|
- | 6015 | ||
- | 6016 | pipe_config->dpll_hw_state.dpll_md = |
|
- | 6017 | (pipe_config->pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
|
- | 6018 | } |
|
5660 | } |
6019 | |
5661 | 6020 | static void chv_prepare_pll(struct intel_crtc *crtc, |
|
5662 | static void chv_update_pll(struct intel_crtc *crtc) |
6021 | const struct intel_crtc_config *pipe_config) |
5663 | { |
6022 | { |
5664 | struct drm_device *dev = crtc->base.dev; |
6023 | struct drm_device *dev = crtc->base.dev; |
5665 | struct drm_i915_private *dev_priv = dev->dev_private; |
6024 | struct drm_i915_private *dev_priv = dev->dev_private; |
5666 | int pipe = crtc->pipe; |
6025 | int pipe = crtc->pipe; |
5667 | int dpll_reg = DPLL(crtc->pipe); |
6026 | int dpll_reg = DPLL(crtc->pipe); |
5668 | enum dpio_channel port = vlv_pipe_to_channel(pipe); |
6027 | enum dpio_channel port = vlv_pipe_to_channel(pipe); |
Line 5669... | Line -... | ||
5669 | u32 loopfilter, intcoeff; |
- | |
5670 | u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac; |
- | |
5671 | int refclk; |
- | |
5672 | - | ||
5673 | crtc->config.dpll_hw_state.dpll = DPLL_SSC_REF_CLOCK_CHV | |
- | |
5674 | DPLL_REFA_CLK_ENABLE_VLV | DPLL_VGA_MODE_DIS | |
- | |
5675 | DPLL_VCO_ENABLE; |
- | |
5676 | if (pipe != PIPE_A) |
- | |
5677 | crtc->config.dpll_hw_state.dpll |= DPLL_INTEGRATED_CRI_CLK_VLV; |
- | |
5678 | 6028 | u32 loopfilter, intcoeff; |
|
5679 | crtc->config.dpll_hw_state.dpll_md = |
6029 | u32 bestn, bestm1, bestm2, bestp1, bestp2, bestm2_frac; |
5680 | (crtc->config.pixel_multiplier - 1) << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
6030 | int refclk; |
5681 | 6031 | ||
5682 | bestn = crtc->config.dpll.n; |
6032 | bestn = pipe_config->dpll.n; |
5683 | bestm2_frac = crtc->config.dpll.m2 & 0x3fffff; |
6033 | bestm2_frac = pipe_config->dpll.m2 & 0x3fffff; |
Line 5684... | Line 6034... | ||
5684 | bestm1 = crtc->config.dpll.m1; |
6034 | bestm1 = pipe_config->dpll.m1; |
5685 | bestm2 = crtc->config.dpll.m2 >> 22; |
6035 | bestm2 = pipe_config->dpll.m2 >> 22; |
5686 | bestp1 = crtc->config.dpll.p1; |
6036 | bestp1 = pipe_config->dpll.p1; |
5687 | bestp2 = crtc->config.dpll.p2; |
6037 | bestp2 = pipe_config->dpll.p2; |
5688 | 6038 | ||
Line 5689... | Line 6039... | ||
5689 | /* |
6039 | /* |
Line 5690... | Line 6040... | ||
5690 | * Enable Refclk and SSC |
6040 | * Enable Refclk and SSC |
5691 | */ |
6041 | */ |
Line 5716... | Line 6066... | ||
5716 | vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW3(port), |
6066 | vlv_dpio_write(dev_priv, pipe, CHV_PLL_DW3(port), |
5717 | DPIO_CHV_FRAC_DIV_EN | |
6067 | DPIO_CHV_FRAC_DIV_EN | |
5718 | (2 << DPIO_CHV_FEEDFWD_GAIN_SHIFT)); |
6068 | (2 << DPIO_CHV_FEEDFWD_GAIN_SHIFT)); |
Line 5719... | Line 6069... | ||
5719 | 6069 | ||
5720 | /* Loop filter */ |
6070 | /* Loop filter */ |
5721 | refclk = i9xx_get_refclk(&crtc->base, 0); |
6071 | refclk = i9xx_get_refclk(crtc, 0); |
5722 | loopfilter = 5 << DPIO_CHV_PROP_COEFF_SHIFT | |
6072 | loopfilter = 5 << DPIO_CHV_PROP_COEFF_SHIFT | |
5723 | 2 << DPIO_CHV_GAIN_CTRL_SHIFT; |
6073 | 2 << DPIO_CHV_GAIN_CTRL_SHIFT; |
5724 | if (refclk == 100000) |
6074 | if (refclk == 100000) |
5725 | intcoeff = 11; |
6075 | intcoeff = 11; |
Line 5736... | Line 6086... | ||
5736 | DPIO_AFC_RECAL); |
6086 | DPIO_AFC_RECAL); |
Line 5737... | Line 6087... | ||
5737 | 6087 | ||
5738 | mutex_unlock(&dev_priv->dpio_lock); |
6088 | mutex_unlock(&dev_priv->dpio_lock); |
Line -... | Line 6089... | ||
- | 6089 | } |
|
- | 6090 | ||
- | 6091 | /** |
|
- | 6092 | * vlv_force_pll_on - forcibly enable just the PLL |
|
- | 6093 | * @dev_priv: i915 private structure |
|
- | 6094 | * @pipe: pipe PLL to enable |
|
- | 6095 | * @dpll: PLL configuration |
|
- | 6096 | * |
|
- | 6097 | * Enable the PLL for @pipe using the supplied @dpll config. To be used |
|
- | 6098 | * in cases where we need the PLL enabled even when @pipe is not going to |
|
- | 6099 | * be enabled. |
|
- | 6100 | */ |
|
- | 6101 | void vlv_force_pll_on(struct drm_device *dev, enum pipe pipe, |
|
- | 6102 | const struct dpll *dpll) |
|
- | 6103 | { |
|
- | 6104 | struct intel_crtc *crtc = |
|
- | 6105 | to_intel_crtc(intel_get_crtc_for_pipe(dev, pipe)); |
|
- | 6106 | struct intel_crtc_config pipe_config = { |
|
- | 6107 | .pixel_multiplier = 1, |
|
- | 6108 | .dpll = *dpll, |
|
- | 6109 | }; |
|
- | 6110 | ||
- | 6111 | if (IS_CHERRYVIEW(dev)) { |
|
- | 6112 | chv_update_pll(crtc, &pipe_config); |
|
- | 6113 | chv_prepare_pll(crtc, &pipe_config); |
|
- | 6114 | chv_enable_pll(crtc, &pipe_config); |
|
- | 6115 | } else { |
|
- | 6116 | vlv_update_pll(crtc, &pipe_config); |
|
- | 6117 | vlv_prepare_pll(crtc, &pipe_config); |
|
- | 6118 | vlv_enable_pll(crtc, &pipe_config); |
|
- | 6119 | } |
|
- | 6120 | } |
|
- | 6121 | ||
- | 6122 | /** |
|
- | 6123 | * vlv_force_pll_off - forcibly disable just the PLL |
|
- | 6124 | * @dev_priv: i915 private structure |
|
- | 6125 | * @pipe: pipe PLL to disable |
|
- | 6126 | * |
|
- | 6127 | * Disable the PLL for @pipe. To be used in cases where we need |
|
- | 6128 | * the PLL enabled even when @pipe is not going to be enabled. |
|
- | 6129 | */ |
|
- | 6130 | void vlv_force_pll_off(struct drm_device *dev, enum pipe pipe) |
|
- | 6131 | { |
|
- | 6132 | if (IS_CHERRYVIEW(dev)) |
|
- | 6133 | chv_disable_pll(to_i915(dev), pipe); |
|
- | 6134 | else |
|
- | 6135 | vlv_disable_pll(to_i915(dev), pipe); |
|
5739 | } |
6136 | } |
5740 | 6137 | ||
5741 | static void i9xx_update_pll(struct intel_crtc *crtc, |
6138 | static void i9xx_update_pll(struct intel_crtc *crtc, |
5742 | intel_clock_t *reduced_clock, |
6139 | intel_clock_t *reduced_clock, |
5743 | int num_connectors) |
6140 | int num_connectors) |
5744 | { |
6141 | { |
5745 | struct drm_device *dev = crtc->base.dev; |
6142 | struct drm_device *dev = crtc->base.dev; |
5746 | struct drm_i915_private *dev_priv = dev->dev_private; |
6143 | struct drm_i915_private *dev_priv = dev->dev_private; |
5747 | u32 dpll; |
6144 | u32 dpll; |
Line 5748... | Line 6145... | ||
5748 | bool is_sdvo; |
6145 | bool is_sdvo; |
Line 5749... | Line 6146... | ||
5749 | struct dpll *clock = &crtc->config.dpll; |
6146 | struct dpll *clock = &crtc->new_config->dpll; |
5750 | 6147 | ||
Line 5751... | Line 6148... | ||
5751 | i9xx_update_pll_dividers(crtc, reduced_clock); |
6148 | i9xx_update_pll_dividers(crtc, reduced_clock); |
Line 5752... | Line 6149... | ||
5752 | 6149 | ||
5753 | is_sdvo = intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_SDVO) || |
6150 | is_sdvo = intel_pipe_will_have_type(crtc, INTEL_OUTPUT_SDVO) || |
5754 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI); |
6151 | intel_pipe_will_have_type(crtc, INTEL_OUTPUT_HDMI); |
5755 | 6152 | ||
Line 5756... | Line 6153... | ||
5756 | dpll = DPLL_VGA_MODE_DIS; |
6153 | dpll = DPLL_VGA_MODE_DIS; |
5757 | 6154 | ||
5758 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS)) |
6155 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) |
5759 | dpll |= DPLLB_MODE_LVDS; |
6156 | dpll |= DPLLB_MODE_LVDS; |
Line 5760... | Line 6157... | ||
5760 | else |
6157 | else |
5761 | dpll |= DPLLB_MODE_DAC_SERIAL; |
6158 | dpll |= DPLLB_MODE_DAC_SERIAL; |
Line 5762... | Line 6159... | ||
5762 | 6159 | ||
5763 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) { |
6160 | if (IS_I945G(dev) || IS_I945GM(dev) || IS_G33(dev)) { |
Line 5764... | Line 6161... | ||
5764 | dpll |= (crtc->config.pixel_multiplier - 1) |
6161 | dpll |= (crtc->new_config->pixel_multiplier - 1) |
5765 | << SDVO_MULTIPLIER_SHIFT_HIRES; |
6162 | << SDVO_MULTIPLIER_SHIFT_HIRES; |
5766 | } |
6163 | } |
Line 5794... | Line 6191... | ||
5794 | break; |
6191 | break; |
5795 | } |
6192 | } |
5796 | if (INTEL_INFO(dev)->gen >= 4) |
6193 | if (INTEL_INFO(dev)->gen >= 4) |
5797 | dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT); |
6194 | dpll |= (6 << PLL_LOAD_PULSE_PHASE_SHIFT); |
Line 5798... | Line 6195... | ||
5798 | 6195 | ||
5799 | if (crtc->config.sdvo_tv_clock) |
6196 | if (crtc->new_config->sdvo_tv_clock) |
5800 | dpll |= PLL_REF_INPUT_TVCLKINBC; |
6197 | dpll |= PLL_REF_INPUT_TVCLKINBC; |
5801 | else if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) && |
6198 | else if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) && |
5802 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) |
6199 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) |
5803 | dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN; |
6200 | dpll |= PLLB_REF_INPUT_SPREADSPECTRUMIN; |
5804 | else |
6201 | else |
Line 5805... | Line 6202... | ||
5805 | dpll |= PLL_REF_INPUT_DREFCLK; |
6202 | dpll |= PLL_REF_INPUT_DREFCLK; |
5806 | 6203 | ||
Line 5807... | Line 6204... | ||
5807 | dpll |= DPLL_VCO_ENABLE; |
6204 | dpll |= DPLL_VCO_ENABLE; |
5808 | crtc->config.dpll_hw_state.dpll = dpll; |
6205 | crtc->new_config->dpll_hw_state.dpll = dpll; |
5809 | 6206 | ||
5810 | if (INTEL_INFO(dev)->gen >= 4) { |
6207 | if (INTEL_INFO(dev)->gen >= 4) { |
5811 | u32 dpll_md = (crtc->config.pixel_multiplier - 1) |
6208 | u32 dpll_md = (crtc->new_config->pixel_multiplier - 1) |
5812 | << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
6209 | << DPLL_MD_UDI_MULTIPLIER_SHIFT; |
Line 5813... | Line 6210... | ||
5813 | crtc->config.dpll_hw_state.dpll_md = dpll_md; |
6210 | crtc->new_config->dpll_hw_state.dpll_md = dpll_md; |
5814 | } |
6211 | } |
5815 | } |
6212 | } |
5816 | 6213 | ||
5817 | static void i8xx_update_pll(struct intel_crtc *crtc, |
6214 | static void i8xx_update_pll(struct intel_crtc *crtc, |
5818 | intel_clock_t *reduced_clock, |
6215 | intel_clock_t *reduced_clock, |
5819 | int num_connectors) |
6216 | int num_connectors) |
5820 | { |
6217 | { |
Line 5821... | Line 6218... | ||
5821 | struct drm_device *dev = crtc->base.dev; |
6218 | struct drm_device *dev = crtc->base.dev; |
Line 5822... | Line 6219... | ||
5822 | struct drm_i915_private *dev_priv = dev->dev_private; |
6219 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 5823... | Line 6220... | ||
5823 | u32 dpll; |
6220 | u32 dpll; |
5824 | struct dpll *clock = &crtc->config.dpll; |
6221 | struct dpll *clock = &crtc->new_config->dpll; |
5825 | 6222 | ||
5826 | i9xx_update_pll_dividers(crtc, reduced_clock); |
6223 | i9xx_update_pll_dividers(crtc, reduced_clock); |
5827 | 6224 | ||
5828 | dpll = DPLL_VGA_MODE_DIS; |
6225 | dpll = DPLL_VGA_MODE_DIS; |
5829 | 6226 | ||
5830 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS)) { |
6227 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS)) { |
5831 | dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
6228 | dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
5832 | } else { |
6229 | } else { |
Line 5833... | Line 6230... | ||
5833 | if (clock->p1 == 2) |
6230 | if (clock->p1 == 2) |
5834 | dpll |= PLL_P1_DIVIDE_BY_TWO; |
6231 | dpll |= PLL_P1_DIVIDE_BY_TWO; |
Line 5835... | Line 6232... | ||
5835 | else |
6232 | else |
5836 | dpll |= (clock->p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
6233 | dpll |= (clock->p1 - 2) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
5837 | if (clock->p2 == 4) |
6234 | if (clock->p2 == 4) |
5838 | dpll |= PLL_P2_DIVIDE_BY_4; |
6235 | dpll |= PLL_P2_DIVIDE_BY_4; |
5839 | } |
6236 | } |
Line 5840... | Line 6237... | ||
5840 | 6237 | ||
5841 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_DVO)) |
6238 | if (!IS_I830(dev) && intel_pipe_will_have_type(crtc, INTEL_OUTPUT_DVO)) |
5842 | dpll |= DPLL_DVO_2X_MODE; |
6239 | dpll |= DPLL_DVO_2X_MODE; |
Line 5843... | Line 6240... | ||
5843 | 6240 | ||
5844 | if (intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_LVDS) && |
6241 | if (intel_pipe_will_have_type(crtc, INTEL_OUTPUT_LVDS) && |
5845 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) |
6242 | intel_panel_use_ssc(dev_priv) && num_connectors < 2) |
Line 5870... | Line 6267... | ||
5870 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) { |
6267 | if (adjusted_mode->flags & DRM_MODE_FLAG_INTERLACE) { |
5871 | /* the chip adds 2 halflines automatically */ |
6268 | /* the chip adds 2 halflines automatically */ |
5872 | crtc_vtotal -= 1; |
6269 | crtc_vtotal -= 1; |
5873 | crtc_vblank_end -= 1; |
6270 | crtc_vblank_end -= 1; |
Line 5874... | Line 6271... | ||
5874 | 6271 | ||
5875 | if (intel_pipe_has_type(&intel_crtc->base, INTEL_OUTPUT_SDVO)) |
6272 | if (intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_SDVO)) |
5876 | vsyncshift = (adjusted_mode->crtc_htotal - 1) / 2; |
6273 | vsyncshift = (adjusted_mode->crtc_htotal - 1) / 2; |
5877 | else |
6274 | else |
5878 | vsyncshift = adjusted_mode->crtc_hsync_start - |
6275 | vsyncshift = adjusted_mode->crtc_hsync_start - |
5879 | adjusted_mode->crtc_htotal / 2; |
6276 | adjusted_mode->crtc_htotal / 2; |
Line 5987... | Line 6384... | ||
5987 | struct drm_i915_private *dev_priv = dev->dev_private; |
6384 | struct drm_i915_private *dev_priv = dev->dev_private; |
5988 | uint32_t pipeconf; |
6385 | uint32_t pipeconf; |
Line 5989... | Line 6386... | ||
5989 | 6386 | ||
Line 5990... | Line 6387... | ||
5990 | pipeconf = 0; |
6387 | pipeconf = 0; |
5991 | 6388 | ||
5992 | if (dev_priv->quirks & QUIRK_PIPEA_FORCE && |
6389 | if ((intel_crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || |
Line 5993... | Line 6390... | ||
5993 | I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE) |
6390 | (intel_crtc->pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) |
5994 | pipeconf |= PIPECONF_ENABLE; |
6391 | pipeconf |= I915_READ(PIPECONF(intel_crtc->pipe)) & PIPECONF_ENABLE; |
Line 5995... | Line 6392... | ||
5995 | 6392 | ||
Line 6028... | Line 6425... | ||
6028 | } |
6425 | } |
6029 | } |
6426 | } |
Line 6030... | Line 6427... | ||
6030 | 6427 | ||
6031 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) { |
6428 | if (intel_crtc->config.adjusted_mode.flags & DRM_MODE_FLAG_INTERLACE) { |
6032 | if (INTEL_INFO(dev)->gen < 4 || |
6429 | if (INTEL_INFO(dev)->gen < 4 || |
6033 | intel_pipe_has_type(&intel_crtc->base, INTEL_OUTPUT_SDVO)) |
6430 | intel_pipe_has_type(intel_crtc, INTEL_OUTPUT_SDVO)) |
6034 | pipeconf |= PIPECONF_INTERLACE_W_FIELD_INDICATION; |
6431 | pipeconf |= PIPECONF_INTERLACE_W_FIELD_INDICATION; |
6035 | else |
6432 | else |
6036 | pipeconf |= PIPECONF_INTERLACE_W_SYNC_SHIFT; |
6433 | pipeconf |= PIPECONF_INTERLACE_W_SYNC_SHIFT; |
6037 | } else |
6434 | } else |
Line 6042... | Line 6439... | ||
6042 | 6439 | ||
6043 | I915_WRITE(PIPECONF(intel_crtc->pipe), pipeconf); |
6440 | I915_WRITE(PIPECONF(intel_crtc->pipe), pipeconf); |
6044 | POSTING_READ(PIPECONF(intel_crtc->pipe)); |
6441 | POSTING_READ(PIPECONF(intel_crtc->pipe)); |
Line 6045... | Line 6442... | ||
6045 | } |
6442 | } |
6046 | - | ||
6047 | static int i9xx_crtc_mode_set(struct drm_crtc *crtc, |
- | |
6048 | int x, int y, |
6443 | |
6049 | struct drm_framebuffer *fb) |
6444 | static int i9xx_crtc_compute_clock(struct intel_crtc *crtc) |
6050 | { |
6445 | { |
6051 | struct drm_device *dev = crtc->dev; |
- | |
6052 | struct drm_i915_private *dev_priv = dev->dev_private; |
6446 | struct drm_device *dev = crtc->base.dev; |
6053 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
6447 | struct drm_i915_private *dev_priv = dev->dev_private; |
6054 | int refclk, num_connectors = 0; |
6448 | int refclk, num_connectors = 0; |
6055 | intel_clock_t clock, reduced_clock; |
6449 | intel_clock_t clock, reduced_clock; |
6056 | bool ok, has_reduced_clock = false; |
6450 | bool ok, has_reduced_clock = false; |
6057 | bool is_lvds = false, is_dsi = false; |
6451 | bool is_lvds = false, is_dsi = false; |
Line 6058... | Line 6452... | ||
6058 | struct intel_encoder *encoder; |
6452 | struct intel_encoder *encoder; |
- | 6453 | const intel_limit_t *limit; |
|
- | 6454 | ||
- | 6455 | for_each_intel_encoder(dev, encoder) { |
|
6059 | const intel_limit_t *limit; |
6456 | if (encoder->new_crtc != crtc) |
6060 | 6457 | continue; |
|
6061 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
6458 | |
6062 | switch (encoder->type) { |
6459 | switch (encoder->type) { |
6063 | case INTEL_OUTPUT_LVDS: |
6460 | case INTEL_OUTPUT_LVDS: |
6064 | is_lvds = true; |
6461 | is_lvds = true; |
6065 | break; |
6462 | break; |
- | 6463 | case INTEL_OUTPUT_DSI: |
|
- | 6464 | is_dsi = true; |
|
6066 | case INTEL_OUTPUT_DSI: |
6465 | break; |
Line 6067... | Line 6466... | ||
6067 | is_dsi = true; |
6466 | default: |
6068 | break; |
6467 | break; |
Line 6069... | Line 6468... | ||
6069 | } |
6468 | } |
6070 | 6469 | ||
Line 6071... | Line 6470... | ||
6071 | num_connectors++; |
6470 | num_connectors++; |
6072 | } |
6471 | } |
Line 6073... | Line 6472... | ||
6073 | 6472 | ||
6074 | if (is_dsi) |
6473 | if (is_dsi) |
6075 | return 0; |
6474 | return 0; |
6076 | 6475 | ||
6077 | if (!intel_crtc->config.clock_set) { |
6476 | if (!crtc->new_config->clock_set) { |
6078 | refclk = i9xx_get_refclk(crtc, num_connectors); |
6477 | refclk = i9xx_get_refclk(crtc, num_connectors); |
6079 | 6478 | ||
6080 | /* |
6479 | /* |
6081 | * Returns a set of divisors for the desired target clock with |
6480 | * Returns a set of divisors for the desired target clock with |
6082 | * the given refclk, or FALSE. The returned values represent |
6481 | * the given refclk, or FALSE. The returned values represent |
6083 | * the clock equation: reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + |
6482 | * the clock equation: reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + |
6084 | * 2) / p1 / p2. |
6483 | * 2) / p1 / p2. |
6085 | */ |
6484 | */ |
6086 | limit = intel_limit(crtc, refclk); |
6485 | limit = intel_limit(crtc, refclk); |
Line 6104... | Line 6503... | ||
6104 | dev_priv->lvds_downclock, |
6503 | dev_priv->lvds_downclock, |
6105 | refclk, &clock, |
6504 | refclk, &clock, |
6106 | &reduced_clock); |
6505 | &reduced_clock); |
6107 | } |
6506 | } |
6108 | /* Compat-code for transition, will disappear. */ |
6507 | /* Compat-code for transition, will disappear. */ |
6109 | intel_crtc->config.dpll.n = clock.n; |
6508 | crtc->new_config->dpll.n = clock.n; |
6110 | intel_crtc->config.dpll.m1 = clock.m1; |
6509 | crtc->new_config->dpll.m1 = clock.m1; |
6111 | intel_crtc->config.dpll.m2 = clock.m2; |
6510 | crtc->new_config->dpll.m2 = clock.m2; |
6112 | intel_crtc->config.dpll.p1 = clock.p1; |
6511 | crtc->new_config->dpll.p1 = clock.p1; |
6113 | intel_crtc->config.dpll.p2 = clock.p2; |
6512 | crtc->new_config->dpll.p2 = clock.p2; |
6114 | } |
6513 | } |
Line 6115... | Line 6514... | ||
6115 | 6514 | ||
6116 | if (IS_GEN2(dev)) { |
6515 | if (IS_GEN2(dev)) { |
6117 | i8xx_update_pll(intel_crtc, |
6516 | i8xx_update_pll(crtc, |
6118 | has_reduced_clock ? &reduced_clock : NULL, |
6517 | has_reduced_clock ? &reduced_clock : NULL, |
6119 | num_connectors); |
6518 | num_connectors); |
6120 | } else if (IS_CHERRYVIEW(dev)) { |
6519 | } else if (IS_CHERRYVIEW(dev)) { |
6121 | chv_update_pll(intel_crtc); |
6520 | chv_update_pll(crtc, crtc->new_config); |
6122 | } else if (IS_VALLEYVIEW(dev)) { |
6521 | } else if (IS_VALLEYVIEW(dev)) { |
6123 | vlv_update_pll(intel_crtc); |
6522 | vlv_update_pll(crtc, crtc->new_config); |
6124 | } else { |
6523 | } else { |
6125 | i9xx_update_pll(intel_crtc, |
6524 | i9xx_update_pll(crtc, |
6126 | has_reduced_clock ? &reduced_clock : NULL, |
6525 | has_reduced_clock ? &reduced_clock : NULL, |
6127 | num_connectors); |
6526 | num_connectors); |
Line 6128... | Line 6527... | ||
6128 | } |
6527 | } |
Line 6232... | Line 6631... | ||
6232 | val = I915_READ(PIPESRC(pipe)); |
6631 | val = I915_READ(PIPESRC(pipe)); |
6233 | crtc->base.primary->fb->width = ((val >> 16) & 0xfff) + 1; |
6632 | crtc->base.primary->fb->width = ((val >> 16) & 0xfff) + 1; |
6234 | crtc->base.primary->fb->height = ((val >> 0) & 0xfff) + 1; |
6633 | crtc->base.primary->fb->height = ((val >> 0) & 0xfff) + 1; |
Line 6235... | Line 6634... | ||
6235 | 6634 | ||
6236 | val = I915_READ(DSPSTRIDE(pipe)); |
6635 | val = I915_READ(DSPSTRIDE(pipe)); |
Line 6237... | Line 6636... | ||
6237 | crtc->base.primary->fb->pitches[0] = val & 0xffffff80; |
6636 | crtc->base.primary->fb->pitches[0] = val & 0xffffffc0; |
6238 | 6637 | ||
Line 6239... | Line 6638... | ||
6239 | aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, |
6638 | aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, |
Line 6286... | Line 6685... | ||
6286 | { |
6685 | { |
6287 | struct drm_device *dev = crtc->base.dev; |
6686 | struct drm_device *dev = crtc->base.dev; |
6288 | struct drm_i915_private *dev_priv = dev->dev_private; |
6687 | struct drm_i915_private *dev_priv = dev->dev_private; |
6289 | uint32_t tmp; |
6688 | uint32_t tmp; |
Line 6290... | Line 6689... | ||
6290 | 6689 | ||
6291 | if (!intel_display_power_enabled(dev_priv, |
6690 | if (!intel_display_power_is_enabled(dev_priv, |
6292 | POWER_DOMAIN_PIPE(crtc->pipe))) |
6691 | POWER_DOMAIN_PIPE(crtc->pipe))) |
Line 6293... | Line 6692... | ||
6293 | return false; |
6692 | return false; |
6294 | 6693 | ||
Line 6342... | Line 6741... | ||
6342 | * function. */ |
6741 | * function. */ |
6343 | pipe_config->pixel_multiplier = 1; |
6742 | pipe_config->pixel_multiplier = 1; |
6344 | } |
6743 | } |
6345 | pipe_config->dpll_hw_state.dpll = I915_READ(DPLL(crtc->pipe)); |
6744 | pipe_config->dpll_hw_state.dpll = I915_READ(DPLL(crtc->pipe)); |
6346 | if (!IS_VALLEYVIEW(dev)) { |
6745 | if (!IS_VALLEYVIEW(dev)) { |
- | 6746 | /* |
|
- | 6747 | * DPLL_DVO_2X_MODE must be enabled for both DPLLs |
|
- | 6748 | * on 830. Filter it out here so that we don't |
|
- | 6749 | * report errors due to that. |
|
- | 6750 | */ |
|
- | 6751 | if (IS_I830(dev)) |
|
- | 6752 | pipe_config->dpll_hw_state.dpll &= ~DPLL_DVO_2X_MODE; |
|
- | 6753 | ||
6347 | pipe_config->dpll_hw_state.fp0 = I915_READ(FP0(crtc->pipe)); |
6754 | pipe_config->dpll_hw_state.fp0 = I915_READ(FP0(crtc->pipe)); |
6348 | pipe_config->dpll_hw_state.fp1 = I915_READ(FP1(crtc->pipe)); |
6755 | pipe_config->dpll_hw_state.fp1 = I915_READ(FP1(crtc->pipe)); |
6349 | } else { |
6756 | } else { |
6350 | /* Mask out read-only status bits. */ |
6757 | /* Mask out read-only status bits. */ |
6351 | pipe_config->dpll_hw_state.dpll &= ~(DPLL_LOCK_VLV | |
6758 | pipe_config->dpll_hw_state.dpll &= ~(DPLL_LOCK_VLV | |
Line 6364... | Line 6771... | ||
6364 | } |
6771 | } |
Line 6365... | Line 6772... | ||
6365 | 6772 | ||
6366 | static void ironlake_init_pch_refclk(struct drm_device *dev) |
6773 | static void ironlake_init_pch_refclk(struct drm_device *dev) |
6367 | { |
6774 | { |
6368 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
6369 | struct drm_mode_config *mode_config = &dev->mode_config; |
6775 | struct drm_i915_private *dev_priv = dev->dev_private; |
6370 | struct intel_encoder *encoder; |
6776 | struct intel_encoder *encoder; |
6371 | u32 val, final; |
6777 | u32 val, final; |
6372 | bool has_lvds = false; |
6778 | bool has_lvds = false; |
6373 | bool has_cpu_edp = false; |
6779 | bool has_cpu_edp = false; |
6374 | bool has_panel = false; |
6780 | bool has_panel = false; |
6375 | bool has_ck505 = false; |
6781 | bool has_ck505 = false; |
Line 6376... | Line 6782... | ||
6376 | bool can_ssc = false; |
6782 | bool can_ssc = false; |
6377 | 6783 | ||
6378 | /* We need to take the global config into account */ |
- | |
6379 | list_for_each_entry(encoder, &mode_config->encoder_list, |
6784 | /* We need to take the global config into account */ |
6380 | base.head) { |
6785 | for_each_intel_encoder(dev, encoder) { |
6381 | switch (encoder->type) { |
6786 | switch (encoder->type) { |
6382 | case INTEL_OUTPUT_LVDS: |
6787 | case INTEL_OUTPUT_LVDS: |
6383 | has_panel = true; |
6788 | has_panel = true; |
6384 | has_lvds = true; |
6789 | has_lvds = true; |
6385 | break; |
6790 | break; |
6386 | case INTEL_OUTPUT_EDP: |
6791 | case INTEL_OUTPUT_EDP: |
6387 | has_panel = true; |
6792 | has_panel = true; |
6388 | if (enc_to_dig_port(&encoder->base)->port == PORT_A) |
6793 | if (enc_to_dig_port(&encoder->base)->port == PORT_A) |
- | 6794 | has_cpu_edp = true; |
|
- | 6795 | break; |
|
6389 | has_cpu_edp = true; |
6796 | default: |
6390 | break; |
6797 | break; |
Line 6391... | Line 6798... | ||
6391 | } |
6798 | } |
6392 | } |
6799 | } |
Line 6682... | Line 7089... | ||
6682 | mutex_unlock(&dev_priv->dpio_lock); |
7089 | mutex_unlock(&dev_priv->dpio_lock); |
6683 | } |
7090 | } |
Line 6684... | Line 7091... | ||
6684 | 7091 | ||
6685 | static void lpt_init_pch_refclk(struct drm_device *dev) |
7092 | static void lpt_init_pch_refclk(struct drm_device *dev) |
6686 | { |
- | |
6687 | struct drm_mode_config *mode_config = &dev->mode_config; |
7093 | { |
6688 | struct intel_encoder *encoder; |
7094 | struct intel_encoder *encoder; |
Line 6689... | Line 7095... | ||
6689 | bool has_vga = false; |
7095 | bool has_vga = false; |
6690 | 7096 | ||
6691 | list_for_each_entry(encoder, &mode_config->encoder_list, base.head) { |
7097 | for_each_intel_encoder(dev, encoder) { |
6692 | switch (encoder->type) { |
7098 | switch (encoder->type) { |
6693 | case INTEL_OUTPUT_ANALOG: |
7099 | case INTEL_OUTPUT_ANALOG: |
- | 7100 | has_vga = true; |
|
- | 7101 | break; |
|
6694 | has_vga = true; |
7102 | default: |
6695 | break; |
7103 | break; |
Line 6696... | Line 7104... | ||
6696 | } |
7104 | } |
6697 | } |
7105 | } |
Line 6719... | Line 7127... | ||
6719 | struct drm_i915_private *dev_priv = dev->dev_private; |
7127 | struct drm_i915_private *dev_priv = dev->dev_private; |
6720 | struct intel_encoder *encoder; |
7128 | struct intel_encoder *encoder; |
6721 | int num_connectors = 0; |
7129 | int num_connectors = 0; |
6722 | bool is_lvds = false; |
7130 | bool is_lvds = false; |
Line 6723... | Line 7131... | ||
6723 | 7131 | ||
- | 7132 | for_each_intel_encoder(dev, encoder) { |
|
- | 7133 | if (encoder->new_crtc != to_intel_crtc(crtc)) |
|
- | 7134 | continue; |
|
6724 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
7135 | |
6725 | switch (encoder->type) { |
7136 | switch (encoder->type) { |
6726 | case INTEL_OUTPUT_LVDS: |
7137 | case INTEL_OUTPUT_LVDS: |
6727 | is_lvds = true; |
7138 | is_lvds = true; |
- | 7139 | break; |
|
- | 7140 | default: |
|
6728 | break; |
7141 | break; |
6729 | } |
7142 | } |
6730 | num_connectors++; |
7143 | num_connectors++; |
Line 6731... | Line 7144... | ||
6731 | } |
7144 | } |
Line 6868... | Line 7281... | ||
6868 | POSTING_READ(PIPECONF(cpu_transcoder)); |
7281 | POSTING_READ(PIPECONF(cpu_transcoder)); |
Line 6869... | Line 7282... | ||
6869 | 7282 | ||
6870 | I915_WRITE(GAMMA_MODE(intel_crtc->pipe), GAMMA_MODE_MODE_8BIT); |
7283 | I915_WRITE(GAMMA_MODE(intel_crtc->pipe), GAMMA_MODE_MODE_8BIT); |
Line 6871... | Line 7284... | ||
6871 | POSTING_READ(GAMMA_MODE(intel_crtc->pipe)); |
7284 | POSTING_READ(GAMMA_MODE(intel_crtc->pipe)); |
6872 | 7285 | ||
Line 6873... | Line 7286... | ||
6873 | if (IS_BROADWELL(dev)) { |
7286 | if (IS_BROADWELL(dev) || INTEL_INFO(dev)->gen >= 9) { |
6874 | val = 0; |
7287 | val = 0; |
6875 | 7288 | ||
Line 6903... | Line 7316... | ||
6903 | bool *has_reduced_clock, |
7316 | bool *has_reduced_clock, |
6904 | intel_clock_t *reduced_clock) |
7317 | intel_clock_t *reduced_clock) |
6905 | { |
7318 | { |
6906 | struct drm_device *dev = crtc->dev; |
7319 | struct drm_device *dev = crtc->dev; |
6907 | struct drm_i915_private *dev_priv = dev->dev_private; |
7320 | struct drm_i915_private *dev_priv = dev->dev_private; |
6908 | struct intel_encoder *intel_encoder; |
7321 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
6909 | int refclk; |
7322 | int refclk; |
6910 | const intel_limit_t *limit; |
7323 | const intel_limit_t *limit; |
6911 | bool ret, is_lvds = false; |
7324 | bool ret, is_lvds = false; |
Line 6912... | Line 7325... | ||
6912 | 7325 | ||
6913 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
- | |
6914 | switch (intel_encoder->type) { |
- | |
6915 | case INTEL_OUTPUT_LVDS: |
- | |
6916 | is_lvds = true; |
- | |
6917 | break; |
- | |
6918 | } |
- | |
Line 6919... | Line 7326... | ||
6919 | } |
7326 | is_lvds = intel_pipe_will_have_type(intel_crtc, INTEL_OUTPUT_LVDS); |
Line 6920... | Line 7327... | ||
6920 | 7327 | ||
6921 | refclk = ironlake_get_refclk(crtc); |
7328 | refclk = ironlake_get_refclk(crtc); |
6922 | 7329 | ||
6923 | /* |
7330 | /* |
6924 | * Returns a set of divisors for the desired target clock with the given |
7331 | * Returns a set of divisors for the desired target clock with the given |
6925 | * refclk, or FALSE. The returned values represent the clock equation: |
7332 | * refclk, or FALSE. The returned values represent the clock equation: |
6926 | * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2. |
7333 | * reflck * (5 * (m1 + 2) + (m2 + 2)) / (n + 2) / p1 / p2. |
6927 | */ |
7334 | */ |
6928 | limit = intel_limit(crtc, refclk); |
7335 | limit = intel_limit(intel_crtc, refclk); |
6929 | ret = dev_priv->display.find_dpll(limit, crtc, |
7336 | ret = dev_priv->display.find_dpll(limit, intel_crtc, |
6930 | to_intel_crtc(crtc)->config.port_clock, |
7337 | intel_crtc->new_config->port_clock, |
Line 6931... | Line 7338... | ||
6931 | refclk, NULL, clock); |
7338 | refclk, NULL, clock); |
Line 6938... | Line 7345... | ||
6938 | * If the clocks don't match, we can't switch the display clock |
7345 | * If the clocks don't match, we can't switch the display clock |
6939 | * by using the FP0/FP1. In such case we will disable the LVDS |
7346 | * by using the FP0/FP1. In such case we will disable the LVDS |
6940 | * downclock feature. |
7347 | * downclock feature. |
6941 | */ |
7348 | */ |
6942 | *has_reduced_clock = |
7349 | *has_reduced_clock = |
6943 | dev_priv->display.find_dpll(limit, crtc, |
7350 | dev_priv->display.find_dpll(limit, intel_crtc, |
6944 | dev_priv->lvds_downclock, |
7351 | dev_priv->lvds_downclock, |
6945 | refclk, clock, |
7352 | refclk, clock, |
6946 | reduced_clock); |
7353 | reduced_clock); |
6947 | } |
7354 | } |
Line 6975... | Line 7382... | ||
6975 | struct intel_encoder *intel_encoder; |
7382 | struct intel_encoder *intel_encoder; |
6976 | uint32_t dpll; |
7383 | uint32_t dpll; |
6977 | int factor, num_connectors = 0; |
7384 | int factor, num_connectors = 0; |
6978 | bool is_lvds = false, is_sdvo = false; |
7385 | bool is_lvds = false, is_sdvo = false; |
Line 6979... | Line 7386... | ||
6979 | 7386 | ||
- | 7387 | for_each_intel_encoder(dev, intel_encoder) { |
|
- | 7388 | if (intel_encoder->new_crtc != to_intel_crtc(crtc)) |
|
- | 7389 | continue; |
|
6980 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
7390 | |
6981 | switch (intel_encoder->type) { |
7391 | switch (intel_encoder->type) { |
6982 | case INTEL_OUTPUT_LVDS: |
7392 | case INTEL_OUTPUT_LVDS: |
6983 | is_lvds = true; |
7393 | is_lvds = true; |
6984 | break; |
7394 | break; |
6985 | case INTEL_OUTPUT_SDVO: |
7395 | case INTEL_OUTPUT_SDVO: |
6986 | case INTEL_OUTPUT_HDMI: |
7396 | case INTEL_OUTPUT_HDMI: |
6987 | is_sdvo = true; |
7397 | is_sdvo = true; |
- | 7398 | break; |
|
- | 7399 | default: |
|
6988 | break; |
7400 | break; |
Line 6989... | Line 7401... | ||
6989 | } |
7401 | } |
6990 | 7402 | ||
Line 6996... | Line 7408... | ||
6996 | if (is_lvds) { |
7408 | if (is_lvds) { |
6997 | if ((intel_panel_use_ssc(dev_priv) && |
7409 | if ((intel_panel_use_ssc(dev_priv) && |
6998 | dev_priv->vbt.lvds_ssc_freq == 100000) || |
7410 | dev_priv->vbt.lvds_ssc_freq == 100000) || |
6999 | (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev))) |
7411 | (HAS_PCH_IBX(dev) && intel_is_dual_link_lvds(dev))) |
7000 | factor = 25; |
7412 | factor = 25; |
7001 | } else if (intel_crtc->config.sdvo_tv_clock) |
7413 | } else if (intel_crtc->new_config->sdvo_tv_clock) |
7002 | factor = 20; |
7414 | factor = 20; |
Line 7003... | Line 7415... | ||
7003 | 7415 | ||
7004 | if (ironlake_needs_fb_cb_tune(&intel_crtc->config.dpll, factor)) |
7416 | if (ironlake_needs_fb_cb_tune(&intel_crtc->new_config->dpll, factor)) |
Line 7005... | Line 7417... | ||
7005 | *fp |= FP_CB_TUNE; |
7417 | *fp |= FP_CB_TUNE; |
7006 | 7418 | ||
Line 7012... | Line 7424... | ||
7012 | if (is_lvds) |
7424 | if (is_lvds) |
7013 | dpll |= DPLLB_MODE_LVDS; |
7425 | dpll |= DPLLB_MODE_LVDS; |
7014 | else |
7426 | else |
7015 | dpll |= DPLLB_MODE_DAC_SERIAL; |
7427 | dpll |= DPLLB_MODE_DAC_SERIAL; |
Line 7016... | Line 7428... | ||
7016 | 7428 | ||
7017 | dpll |= (intel_crtc->config.pixel_multiplier - 1) |
7429 | dpll |= (intel_crtc->new_config->pixel_multiplier - 1) |
Line 7018... | Line 7430... | ||
7018 | << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; |
7430 | << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; |
7019 | 7431 | ||
7020 | if (is_sdvo) |
7432 | if (is_sdvo) |
7021 | dpll |= DPLL_SDVO_HIGH_SPEED; |
7433 | dpll |= DPLL_SDVO_HIGH_SPEED; |
Line 7022... | Line 7434... | ||
7022 | if (intel_crtc->config.has_dp_encoder) |
7434 | if (intel_crtc->new_config->has_dp_encoder) |
7023 | dpll |= DPLL_SDVO_HIGH_SPEED; |
7435 | dpll |= DPLL_SDVO_HIGH_SPEED; |
7024 | 7436 | ||
7025 | /* compute bitmask from p1 value */ |
7437 | /* compute bitmask from p1 value */ |
Line 7026... | Line 7438... | ||
7026 | dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
7438 | dpll |= (1 << (intel_crtc->new_config->dpll.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
7027 | /* also FPA1 */ |
7439 | /* also FPA1 */ |
7028 | dpll |= (1 << (intel_crtc->config.dpll.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; |
7440 | dpll |= (1 << (intel_crtc->new_config->dpll.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; |
7029 | 7441 | ||
7030 | switch (intel_crtc->config.dpll.p2) { |
7442 | switch (intel_crtc->new_config->dpll.p2) { |
7031 | case 5: |
7443 | case 5: |
Line 7048... | Line 7460... | ||
7048 | dpll |= PLL_REF_INPUT_DREFCLK; |
7460 | dpll |= PLL_REF_INPUT_DREFCLK; |
Line 7049... | Line 7461... | ||
7049 | 7461 | ||
7050 | return dpll | DPLL_VCO_ENABLE; |
7462 | return dpll | DPLL_VCO_ENABLE; |
Line 7051... | Line 7463... | ||
7051 | } |
7463 | } |
7052 | - | ||
7053 | static int ironlake_crtc_mode_set(struct drm_crtc *crtc, |
- | |
7054 | int x, int y, |
7464 | |
7055 | struct drm_framebuffer *fb) |
7465 | static int ironlake_crtc_compute_clock(struct intel_crtc *crtc) |
7056 | { |
- | |
7057 | struct drm_device *dev = crtc->dev; |
- | |
7058 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
7466 | { |
7059 | int num_connectors = 0; |
7467 | struct drm_device *dev = crtc->base.dev; |
7060 | intel_clock_t clock, reduced_clock; |
7468 | intel_clock_t clock, reduced_clock; |
7061 | u32 dpll = 0, fp = 0, fp2 = 0; |
7469 | u32 dpll = 0, fp = 0, fp2 = 0; |
7062 | bool ok, has_reduced_clock = false; |
- | |
7063 | bool is_lvds = false; |
7470 | bool ok, has_reduced_clock = false; |
Line 7064... | Line -... | ||
7064 | struct intel_encoder *encoder; |
- | |
7065 | struct intel_shared_dpll *pll; |
- | |
7066 | 7471 | bool is_lvds = false; |
|
7067 | for_each_encoder_on_crtc(dev, crtc, encoder) { |
- | |
7068 | switch (encoder->type) { |
- | |
7069 | case INTEL_OUTPUT_LVDS: |
- | |
7070 | is_lvds = true; |
- | |
7071 | break; |
- | |
7072 | } |
- | |
Line 7073... | Line 7472... | ||
7073 | 7472 | struct intel_shared_dpll *pll; |
|
7074 | num_connectors++; |
7473 | |
Line 7075... | Line 7474... | ||
7075 | } |
7474 | is_lvds = intel_pipe_has_type(crtc, INTEL_OUTPUT_LVDS); |
7076 | 7475 | ||
7077 | WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)), |
7476 | WARN(!(HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)), |
7078 | "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev)); |
7477 | "Unexpected PCH type %d\n", INTEL_PCH_TYPE(dev)); |
7079 | 7478 | ||
7080 | ok = ironlake_compute_clocks(crtc, &clock, |
7479 | ok = ironlake_compute_clocks(&crtc->base, &clock, |
7081 | &has_reduced_clock, &reduced_clock); |
7480 | &has_reduced_clock, &reduced_clock); |
7082 | if (!ok && !intel_crtc->config.clock_set) { |
7481 | if (!ok && !crtc->new_config->clock_set) { |
7083 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); |
7482 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); |
7084 | return -EINVAL; |
7483 | return -EINVAL; |
7085 | } |
7484 | } |
7086 | /* Compat-code for transition, will disappear. */ |
7485 | /* Compat-code for transition, will disappear. */ |
7087 | if (!intel_crtc->config.clock_set) { |
7486 | if (!crtc->new_config->clock_set) { |
7088 | intel_crtc->config.dpll.n = clock.n; |
7487 | crtc->new_config->dpll.n = clock.n; |
Line 7089... | Line 7488... | ||
7089 | intel_crtc->config.dpll.m1 = clock.m1; |
7488 | crtc->new_config->dpll.m1 = clock.m1; |
7090 | intel_crtc->config.dpll.m2 = clock.m2; |
7489 | crtc->new_config->dpll.m2 = clock.m2; |
7091 | intel_crtc->config.dpll.p1 = clock.p1; |
7490 | crtc->new_config->dpll.p1 = clock.p1; |
7092 | intel_crtc->config.dpll.p2 = clock.p2; |
7491 | crtc->new_config->dpll.p2 = clock.p2; |
7093 | } |
7492 | } |
Line 7094... | Line 7493... | ||
7094 | 7493 | ||
7095 | /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */ |
7494 | /* CPU eDP is the only output that doesn't need a PCH PLL of its own. */ |
7096 | if (intel_crtc->config.has_pch_encoder) { |
7495 | if (crtc->new_config->has_pch_encoder) { |
Line 7097... | Line 7496... | ||
7097 | fp = i9xx_dpll_compute_fp(&intel_crtc->config.dpll); |
7496 | fp = i9xx_dpll_compute_fp(&crtc->new_config->dpll); |
7098 | if (has_reduced_clock) |
7497 | if (has_reduced_clock) |
7099 | fp2 = i9xx_dpll_compute_fp(&reduced_clock); |
7498 | fp2 = i9xx_dpll_compute_fp(&reduced_clock); |
7100 | 7499 | ||
7101 | dpll = ironlake_compute_dpll(intel_crtc, |
7500 | dpll = ironlake_compute_dpll(crtc, |
7102 | &fp, &reduced_clock, |
7501 | &fp, &reduced_clock, |
Line 7103... | Line 7502... | ||
7103 | has_reduced_clock ? &fp2 : NULL); |
7502 | has_reduced_clock ? &fp2 : NULL); |
7104 | 7503 | ||
7105 | intel_crtc->config.dpll_hw_state.dpll = dpll; |
7504 | crtc->new_config->dpll_hw_state.dpll = dpll; |
7106 | intel_crtc->config.dpll_hw_state.fp0 = fp; |
7505 | crtc->new_config->dpll_hw_state.fp0 = fp; |
7107 | if (has_reduced_clock) |
7506 | if (has_reduced_clock) |
7108 | intel_crtc->config.dpll_hw_state.fp1 = fp2; |
7507 | crtc->new_config->dpll_hw_state.fp1 = fp2; |
7109 | else |
7508 | else |
7110 | intel_crtc->config.dpll_hw_state.fp1 = fp; |
- | |
Line 7111... | Line 7509... | ||
7111 | 7509 | crtc->new_config->dpll_hw_state.fp1 = fp; |
|
7112 | pll = intel_get_shared_dpll(intel_crtc); |
7510 | |
7113 | if (pll == NULL) { |
7511 | pll = intel_get_shared_dpll(crtc); |
7114 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
7512 | if (pll == NULL) { |
Line 7115... | Line 7513... | ||
7115 | pipe_name(intel_crtc->pipe)); |
7513 | DRM_DEBUG_DRIVER("failed to find PLL for pipe %c\n", |
7116 | return -EINVAL; |
7514 | pipe_name(crtc->pipe)); |
Line 7117... | Line 7515... | ||
7117 | } |
7515 | return -EINVAL; |
Line 7142... | Line 7540... | ||
7142 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
7540 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
7143 | } |
7541 | } |
Line 7144... | Line 7542... | ||
7144 | 7542 | ||
7145 | static void intel_cpu_transcoder_get_m_n(struct intel_crtc *crtc, |
7543 | static void intel_cpu_transcoder_get_m_n(struct intel_crtc *crtc, |
7146 | enum transcoder transcoder, |
7544 | enum transcoder transcoder, |
- | 7545 | struct intel_link_m_n *m_n, |
|
7147 | struct intel_link_m_n *m_n) |
7546 | struct intel_link_m_n *m2_n2) |
7148 | { |
7547 | { |
7149 | struct drm_device *dev = crtc->base.dev; |
7548 | struct drm_device *dev = crtc->base.dev; |
7150 | struct drm_i915_private *dev_priv = dev->dev_private; |
7549 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line 7156... | Line 7555... | ||
7156 | m_n->gmch_m = I915_READ(PIPE_DATA_M1(transcoder)) |
7555 | m_n->gmch_m = I915_READ(PIPE_DATA_M1(transcoder)) |
7157 | & ~TU_SIZE_MASK; |
7556 | & ~TU_SIZE_MASK; |
7158 | m_n->gmch_n = I915_READ(PIPE_DATA_N1(transcoder)); |
7557 | m_n->gmch_n = I915_READ(PIPE_DATA_N1(transcoder)); |
7159 | m_n->tu = ((I915_READ(PIPE_DATA_M1(transcoder)) |
7558 | m_n->tu = ((I915_READ(PIPE_DATA_M1(transcoder)) |
7160 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
7559 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
- | 7560 | /* Read M2_N2 registers only for gen < 8 (M2_N2 available for |
|
- | 7561 | * gen < 8) and if DRRS is supported (to make sure the |
|
- | 7562 | * registers are not unnecessarily read). |
|
- | 7563 | */ |
|
- | 7564 | if (m2_n2 && INTEL_INFO(dev)->gen < 8 && |
|
- | 7565 | crtc->config.has_drrs) { |
|
- | 7566 | m2_n2->link_m = I915_READ(PIPE_LINK_M2(transcoder)); |
|
- | 7567 | m2_n2->link_n = I915_READ(PIPE_LINK_N2(transcoder)); |
|
- | 7568 | m2_n2->gmch_m = I915_READ(PIPE_DATA_M2(transcoder)) |
|
- | 7569 | & ~TU_SIZE_MASK; |
|
- | 7570 | m2_n2->gmch_n = I915_READ(PIPE_DATA_N2(transcoder)); |
|
- | 7571 | m2_n2->tu = ((I915_READ(PIPE_DATA_M2(transcoder)) |
|
- | 7572 | & TU_SIZE_MASK) >> TU_SIZE_SHIFT) + 1; |
|
- | 7573 | } |
|
7161 | } else { |
7574 | } else { |
7162 | m_n->link_m = I915_READ(PIPE_LINK_M_G4X(pipe)); |
7575 | m_n->link_m = I915_READ(PIPE_LINK_M_G4X(pipe)); |
7163 | m_n->link_n = I915_READ(PIPE_LINK_N_G4X(pipe)); |
7576 | m_n->link_n = I915_READ(PIPE_LINK_N_G4X(pipe)); |
7164 | m_n->gmch_m = I915_READ(PIPE_DATA_M_G4X(pipe)) |
7577 | m_n->gmch_m = I915_READ(PIPE_DATA_M_G4X(pipe)) |
7165 | & ~TU_SIZE_MASK; |
7578 | & ~TU_SIZE_MASK; |
Line 7174... | Line 7587... | ||
7174 | { |
7587 | { |
7175 | if (crtc->config.has_pch_encoder) |
7588 | if (crtc->config.has_pch_encoder) |
7176 | intel_pch_transcoder_get_m_n(crtc, &pipe_config->dp_m_n); |
7589 | intel_pch_transcoder_get_m_n(crtc, &pipe_config->dp_m_n); |
7177 | else |
7590 | else |
7178 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, |
7591 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, |
- | 7592 | &pipe_config->dp_m_n, |
|
7179 | &pipe_config->dp_m_n); |
7593 | &pipe_config->dp_m2_n2); |
7180 | } |
7594 | } |
Line 7181... | Line 7595... | ||
7181 | 7595 | ||
7182 | static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc, |
7596 | static void ironlake_get_fdi_m_n_config(struct intel_crtc *crtc, |
7183 | struct intel_crtc_config *pipe_config) |
7597 | struct intel_crtc_config *pipe_config) |
7184 | { |
7598 | { |
7185 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, |
7599 | intel_cpu_transcoder_get_m_n(crtc, pipe_config->cpu_transcoder, |
- | 7600 | &pipe_config->fdi_m_n, NULL); |
|
- | 7601 | } |
|
- | 7602 | ||
- | 7603 | static void skylake_get_pfit_config(struct intel_crtc *crtc, |
|
- | 7604 | struct intel_crtc_config *pipe_config) |
|
- | 7605 | { |
|
- | 7606 | struct drm_device *dev = crtc->base.dev; |
|
- | 7607 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 7608 | uint32_t tmp; |
|
- | 7609 | ||
- | 7610 | tmp = I915_READ(PS_CTL(crtc->pipe)); |
|
- | 7611 | ||
- | 7612 | if (tmp & PS_ENABLE) { |
|
- | 7613 | pipe_config->pch_pfit.enabled = true; |
|
- | 7614 | pipe_config->pch_pfit.pos = I915_READ(PS_WIN_POS(crtc->pipe)); |
|
- | 7615 | pipe_config->pch_pfit.size = I915_READ(PS_WIN_SZ(crtc->pipe)); |
|
7186 | &pipe_config->fdi_m_n); |
7616 | } |
Line 7187... | Line 7617... | ||
7187 | } |
7617 | } |
7188 | 7618 | ||
7189 | static void ironlake_get_pfit_config(struct intel_crtc *crtc, |
7619 | static void ironlake_get_pfit_config(struct intel_crtc *crtc, |
Line 7252... | Line 7682... | ||
7252 | val = I915_READ(PIPESRC(pipe)); |
7682 | val = I915_READ(PIPESRC(pipe)); |
7253 | crtc->base.primary->fb->width = ((val >> 16) & 0xfff) + 1; |
7683 | crtc->base.primary->fb->width = ((val >> 16) & 0xfff) + 1; |
7254 | crtc->base.primary->fb->height = ((val >> 0) & 0xfff) + 1; |
7684 | crtc->base.primary->fb->height = ((val >> 0) & 0xfff) + 1; |
Line 7255... | Line 7685... | ||
7255 | 7685 | ||
7256 | val = I915_READ(DSPSTRIDE(pipe)); |
7686 | val = I915_READ(DSPSTRIDE(pipe)); |
Line 7257... | Line 7687... | ||
7257 | crtc->base.primary->fb->pitches[0] = val & 0xffffff80; |
7687 | crtc->base.primary->fb->pitches[0] = val & 0xffffffc0; |
7258 | 7688 | ||
Line 7259... | Line 7689... | ||
7259 | aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, |
7689 | aligned_height = intel_align_height(dev, crtc->base.primary->fb->height, |
- | 7690 | plane_config->tiled); |
|
Line 7260... | Line 7691... | ||
7260 | plane_config->tiled); |
7691 | |
7261 | 7692 | plane_config->size = PAGE_ALIGN(crtc->base.primary->fb->pitches[0] * |
|
7262 | plane_config->size = 16*1024*1024; |
7693 | aligned_height); |
7263 | 7694 | ||
Line 7274... | Line 7705... | ||
7274 | { |
7705 | { |
7275 | struct drm_device *dev = crtc->base.dev; |
7706 | struct drm_device *dev = crtc->base.dev; |
7276 | struct drm_i915_private *dev_priv = dev->dev_private; |
7707 | struct drm_i915_private *dev_priv = dev->dev_private; |
7277 | uint32_t tmp; |
7708 | uint32_t tmp; |
Line 7278... | Line 7709... | ||
7278 | 7709 | ||
7279 | if (!intel_display_power_enabled(dev_priv, |
7710 | if (!intel_display_power_is_enabled(dev_priv, |
7280 | POWER_DOMAIN_PIPE(crtc->pipe))) |
7711 | POWER_DOMAIN_PIPE(crtc->pipe))) |
Line 7281... | Line 7712... | ||
7281 | return false; |
7712 | return false; |
7282 | 7713 | ||
Line 7468... | Line 7899... | ||
7468 | * source. |
7899 | * source. |
7469 | */ |
7900 | */ |
7470 | static void hsw_restore_lcpll(struct drm_i915_private *dev_priv) |
7901 | static void hsw_restore_lcpll(struct drm_i915_private *dev_priv) |
7471 | { |
7902 | { |
7472 | uint32_t val; |
7903 | uint32_t val; |
7473 | unsigned long irqflags; |
- | |
Line 7474... | Line 7904... | ||
7474 | 7904 | ||
Line 7475... | Line 7905... | ||
7475 | val = I915_READ(LCPLL_CTL); |
7905 | val = I915_READ(LCPLL_CTL); |
7476 | 7906 | ||
Line 7488... | Line 7918... | ||
7488 | * intel_runtime_pm_get(), and we can't change the runtime PM refcount |
7918 | * intel_runtime_pm_get(), and we can't change the runtime PM refcount |
7489 | * while we are on the resume sequence. So to solve this problem we have |
7919 | * while we are on the resume sequence. So to solve this problem we have |
7490 | * to call special forcewake code that doesn't touch runtime PM and |
7920 | * to call special forcewake code that doesn't touch runtime PM and |
7491 | * doesn't enable the forcewake delayed work. |
7921 | * doesn't enable the forcewake delayed work. |
7492 | */ |
7922 | */ |
7493 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
7923 | spin_lock_irq(&dev_priv->uncore.lock); |
7494 | if (dev_priv->uncore.forcewake_count++ == 0) |
7924 | if (dev_priv->uncore.forcewake_count++ == 0) |
7495 | dev_priv->uncore.funcs.force_wake_get(dev_priv, FORCEWAKE_ALL); |
7925 | dev_priv->uncore.funcs.force_wake_get(dev_priv, FORCEWAKE_ALL); |
7496 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
7926 | spin_unlock_irq(&dev_priv->uncore.lock); |
Line 7497... | Line 7927... | ||
7497 | 7927 | ||
7498 | if (val & LCPLL_POWER_DOWN_ALLOW) { |
7928 | if (val & LCPLL_POWER_DOWN_ALLOW) { |
7499 | val &= ~LCPLL_POWER_DOWN_ALLOW; |
7929 | val &= ~LCPLL_POWER_DOWN_ALLOW; |
7500 | I915_WRITE(LCPLL_CTL, val); |
7930 | I915_WRITE(LCPLL_CTL, val); |
Line 7522... | Line 7952... | ||
7522 | LCPLL_CD_SOURCE_FCLK_DONE) == 0, 1)) |
7952 | LCPLL_CD_SOURCE_FCLK_DONE) == 0, 1)) |
7523 | DRM_ERROR("Switching back to LCPLL failed\n"); |
7953 | DRM_ERROR("Switching back to LCPLL failed\n"); |
7524 | } |
7954 | } |
Line 7525... | Line 7955... | ||
7525 | 7955 | ||
7526 | /* See the big comment above. */ |
7956 | /* See the big comment above. */ |
7527 | spin_lock_irqsave(&dev_priv->uncore.lock, irqflags); |
7957 | spin_lock_irq(&dev_priv->uncore.lock); |
7528 | if (--dev_priv->uncore.forcewake_count == 0) |
7958 | if (--dev_priv->uncore.forcewake_count == 0) |
7529 | dev_priv->uncore.funcs.force_wake_put(dev_priv, FORCEWAKE_ALL); |
7959 | dev_priv->uncore.funcs.force_wake_put(dev_priv, FORCEWAKE_ALL); |
7530 | spin_unlock_irqrestore(&dev_priv->uncore.lock, irqflags); |
7960 | spin_unlock_irq(&dev_priv->uncore.lock); |
Line 7531... | Line 7961... | ||
7531 | } |
7961 | } |
7532 | 7962 | ||
7533 | /* |
7963 | /* |
Line 7587... | Line 8017... | ||
7587 | } |
8017 | } |
Line 7588... | Line 8018... | ||
7588 | 8018 | ||
7589 | intel_prepare_ddi(dev); |
8019 | intel_prepare_ddi(dev); |
Line 7590... | Line 8020... | ||
7590 | } |
8020 | } |
7591 | 8021 | ||
7592 | static void snb_modeset_global_resources(struct drm_device *dev) |
8022 | static int haswell_crtc_compute_clock(struct intel_crtc *crtc) |
7593 | { |
8023 | { |
Line 7594... | Line 8024... | ||
7594 | modeset_update_crtc_power_domains(dev); |
8024 | if (!intel_ddi_pll_select(crtc)) |
7595 | } |
8025 | return -EINVAL; |
7596 | 8026 | ||
7597 | static void haswell_modeset_global_resources(struct drm_device *dev) |
8027 | crtc->lowfreq_avail = false; |
Line 7598... | Line 8028... | ||
7598 | { |
8028 | |
7599 | modeset_update_crtc_power_domains(dev); |
8029 | return 0; |
7600 | } |
8030 | } |
7601 | 8031 | ||
7602 | static int haswell_crtc_mode_set(struct drm_crtc *crtc, |
8032 | static void skylake_get_ddi_pll(struct drm_i915_private *dev_priv, |
Line -... | Line 8033... | ||
- | 8033 | enum port port, |
|
7603 | int x, int y, |
8034 | struct intel_crtc_config *pipe_config) |
7604 | struct drm_framebuffer *fb) |
- | |
Line 7605... | Line 8035... | ||
7605 | { |
8035 | { |
- | 8036 | u32 temp; |
|
- | 8037 | ||
- | 8038 | temp = I915_READ(DPLL_CTRL2) & DPLL_CTRL2_DDI_CLK_SEL_MASK(port); |
|
- | 8039 | pipe_config->ddi_pll_sel = temp >> (port * 3 + 1); |
|
- | 8040 | ||
- | 8041 | switch (pipe_config->ddi_pll_sel) { |
|
- | 8042 | case SKL_DPLL1: |
|
- | 8043 | pipe_config->shared_dpll = DPLL_ID_SKL_DPLL1; |
|
- | 8044 | break; |
|
- | 8045 | case SKL_DPLL2: |
|
- | 8046 | pipe_config->shared_dpll = DPLL_ID_SKL_DPLL2; |
|
Line -... | Line 8047... | ||
- | 8047 | break; |
|
- | 8048 | case SKL_DPLL3: |
|
- | 8049 | pipe_config->shared_dpll = DPLL_ID_SKL_DPLL3; |
|
- | 8050 | break; |
|
- | 8051 | } |
|
- | 8052 | } |
|
- | 8053 | ||
- | 8054 | static void haswell_get_ddi_pll(struct drm_i915_private *dev_priv, |
|
- | 8055 | enum port port, |
|
7606 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
8056 | struct intel_crtc_config *pipe_config) |
- | 8057 | { |
|
- | 8058 | pipe_config->ddi_pll_sel = I915_READ(PORT_CLK_SEL(port)); |
|
- | 8059 | ||
- | 8060 | switch (pipe_config->ddi_pll_sel) { |
|
7607 | 8061 | case PORT_CLK_SEL_WRPLL1: |
|
Line 7608... | Line 8062... | ||
7608 | if (!intel_ddi_pll_select(intel_crtc)) |
8062 | pipe_config->shared_dpll = DPLL_ID_WRPLL1; |
7609 | return -EINVAL; |
8063 | break; |
7610 | 8064 | case PORT_CLK_SEL_WRPLL2: |
|
Line 7624... | Line 8078... | ||
7624 | 8078 | ||
Line 7625... | Line 8079... | ||
7625 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe_config->cpu_transcoder)); |
8079 | tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe_config->cpu_transcoder)); |
Line 7626... | Line -... | ||
7626 | - | ||
7627 | port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT; |
- | |
7628 | - | ||
7629 | pipe_config->ddi_pll_sel = I915_READ(PORT_CLK_SEL(port)); |
8080 | |
7630 | 8081 | port = (tmp & TRANS_DDI_PORT_MASK) >> TRANS_DDI_PORT_SHIFT; |
|
7631 | switch (pipe_config->ddi_pll_sel) { |
8082 | |
7632 | case PORT_CLK_SEL_WRPLL1: |
- | |
7633 | pipe_config->shared_dpll = DPLL_ID_WRPLL1; |
8083 | if (IS_SKYLAKE(dev)) |
7634 | break; |
- | |
7635 | case PORT_CLK_SEL_WRPLL2: |
- | |
Line 7636... | Line 8084... | ||
7636 | pipe_config->shared_dpll = DPLL_ID_WRPLL2; |
8084 | skylake_get_ddi_pll(dev_priv, port, pipe_config); |
7637 | break; |
8085 | else |
Line 7638... | Line 8086... | ||
7638 | } |
8086 | haswell_get_ddi_pll(dev_priv, port, pipe_config); |
Line 7647... | Line 8095... | ||
7647 | /* |
8095 | /* |
7648 | * Haswell has only FDI/PCH transcoder A. It is which is connected to |
8096 | * Haswell has only FDI/PCH transcoder A. It is which is connected to |
7649 | * DDI E. So just check whether this pipe is wired to DDI E and whether |
8097 | * DDI E. So just check whether this pipe is wired to DDI E and whether |
7650 | * the PCH transcoder is on. |
8098 | * the PCH transcoder is on. |
7651 | */ |
8099 | */ |
- | 8100 | if (INTEL_INFO(dev)->gen < 9 && |
|
7652 | if ((port == PORT_E) && I915_READ(LPT_TRANSCONF) & TRANS_ENABLE) { |
8101 | (port == PORT_E) && I915_READ(LPT_TRANSCONF) & TRANS_ENABLE) { |
7653 | pipe_config->has_pch_encoder = true; |
8102 | pipe_config->has_pch_encoder = true; |
Line 7654... | Line 8103... | ||
7654 | 8103 | ||
7655 | tmp = I915_READ(FDI_RX_CTL(PIPE_A)); |
8104 | tmp = I915_READ(FDI_RX_CTL(PIPE_A)); |
7656 | pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >> |
8105 | pipe_config->fdi_lanes = ((FDI_DP_PORT_WIDTH_MASK & tmp) >> |
Line 7666... | Line 8115... | ||
7666 | struct drm_device *dev = crtc->base.dev; |
8115 | struct drm_device *dev = crtc->base.dev; |
7667 | struct drm_i915_private *dev_priv = dev->dev_private; |
8116 | struct drm_i915_private *dev_priv = dev->dev_private; |
7668 | enum intel_display_power_domain pfit_domain; |
8117 | enum intel_display_power_domain pfit_domain; |
7669 | uint32_t tmp; |
8118 | uint32_t tmp; |
Line 7670... | Line 8119... | ||
7670 | 8119 | ||
7671 | if (!intel_display_power_enabled(dev_priv, |
8120 | if (!intel_display_power_is_enabled(dev_priv, |
7672 | POWER_DOMAIN_PIPE(crtc->pipe))) |
8121 | POWER_DOMAIN_PIPE(crtc->pipe))) |
Line 7673... | Line 8122... | ||
7673 | return false; |
8122 | return false; |
7674 | 8123 | ||
Line 7695... | Line 8144... | ||
7695 | 8144 | ||
7696 | if (trans_edp_pipe == crtc->pipe) |
8145 | if (trans_edp_pipe == crtc->pipe) |
7697 | pipe_config->cpu_transcoder = TRANSCODER_EDP; |
8146 | pipe_config->cpu_transcoder = TRANSCODER_EDP; |
Line 7698... | Line 8147... | ||
7698 | } |
8147 | } |
7699 | 8148 | ||
7700 | if (!intel_display_power_enabled(dev_priv, |
8149 | if (!intel_display_power_is_enabled(dev_priv, |
Line 7701... | Line 8150... | ||
7701 | POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder))) |
8150 | POWER_DOMAIN_TRANSCODER(pipe_config->cpu_transcoder))) |
7702 | return false; |
8151 | return false; |
Line 7708... | Line 8157... | ||
7708 | haswell_get_ddi_port_state(crtc, pipe_config); |
8157 | haswell_get_ddi_port_state(crtc, pipe_config); |
Line 7709... | Line 8158... | ||
7709 | 8158 | ||
Line 7710... | Line 8159... | ||
7710 | intel_get_pipe_timings(crtc, pipe_config); |
8159 | intel_get_pipe_timings(crtc, pipe_config); |
7711 | 8160 | ||
- | 8161 | pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe); |
|
- | 8162 | if (intel_display_power_is_enabled(dev_priv, pfit_domain)) { |
|
- | 8163 | if (IS_SKYLAKE(dev)) |
|
7712 | pfit_domain = POWER_DOMAIN_PIPE_PANEL_FITTER(crtc->pipe); |
8164 | skylake_get_pfit_config(crtc, pipe_config); |
- | 8165 | else |
|
Line 7713... | Line 8166... | ||
7713 | if (intel_display_power_enabled(dev_priv, pfit_domain)) |
8166 | ironlake_get_pfit_config(crtc, pipe_config); |
7714 | ironlake_get_pfit_config(crtc, pipe_config); |
8167 | } |
7715 | 8168 | ||
Line -... | Line 8169... | ||
- | 8169 | if (IS_HASWELL(dev)) |
|
- | 8170 | pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) && |
|
- | 8171 | (I915_READ(IPS_CTL) & IPS_ENABLE); |
|
- | 8172 | ||
7716 | if (IS_HASWELL(dev)) |
8173 | if (pipe_config->cpu_transcoder != TRANSCODER_EDP) { |
7717 | pipe_config->ips_enabled = hsw_crtc_supports_ips(crtc) && |
- | |
7718 | (I915_READ(IPS_CTL) & IPS_ENABLE); |
- | |
7719 | - | ||
7720 | pipe_config->pixel_multiplier = 1; |
- | |
7721 | - | ||
7722 | return true; |
- | |
7723 | } |
- | |
7724 | - | ||
7725 | static struct { |
- | |
7726 | int clock; |
- | |
7727 | u32 config; |
- | |
7728 | } hdmi_audio_clock[] = { |
- | |
7729 | { DIV_ROUND_UP(25200 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_25175 }, |
- | |
7730 | { 25200, AUD_CONFIG_PIXEL_CLOCK_HDMI_25200 }, /* default per bspec */ |
- | |
7731 | { 27000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27000 }, |
- | |
7732 | { 27000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_27027 }, |
- | |
7733 | { 54000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54000 }, |
- | |
7734 | { 54000 * 1001 / 1000, AUD_CONFIG_PIXEL_CLOCK_HDMI_54054 }, |
- | |
7735 | { DIV_ROUND_UP(74250 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_74176 }, |
- | |
7736 | { 74250, AUD_CONFIG_PIXEL_CLOCK_HDMI_74250 }, |
- | |
7737 | { DIV_ROUND_UP(148500 * 1000, 1001), AUD_CONFIG_PIXEL_CLOCK_HDMI_148352 }, |
- | |
7738 | { 148500, AUD_CONFIG_PIXEL_CLOCK_HDMI_148500 }, |
- | |
7739 | }; |
- | |
7740 | - | ||
7741 | /* get AUD_CONFIG_PIXEL_CLOCK_HDMI_* value for mode */ |
- | |
7742 | static u32 audio_config_hdmi_pixel_clock(struct drm_display_mode *mode) |
- | |
7743 | { |
- | |
7744 | int i; |
- | |
7745 | - | ||
7746 | for (i = 0; i < ARRAY_SIZE(hdmi_audio_clock); i++) { |
- | |
7747 | if (mode->clock == hdmi_audio_clock[i].clock) |
- | |
7748 | break; |
- | |
7749 | } |
- | |
7750 | 8174 | pipe_config->pixel_multiplier = |
|
Line 7751... | Line -... | ||
7751 | if (i == ARRAY_SIZE(hdmi_audio_clock)) { |
- | |
7752 | DRM_DEBUG_KMS("HDMI audio pixel clock setting for %d not found, falling back to defaults\n", mode->clock); |
- | |
7753 | i = 1; |
- | |
7754 | } |
- | |
7755 | - | ||
7756 | DRM_DEBUG_KMS("Configuring HDMI audio for pixel clock %d (0x%08x)\n", |
- | |
7757 | hdmi_audio_clock[i].clock, |
- | |
7758 | hdmi_audio_clock[i].config); |
- | |
7759 | - | ||
7760 | return hdmi_audio_clock[i].config; |
- | |
7761 | } |
- | |
7762 | - | ||
7763 | static bool intel_eld_uptodate(struct drm_connector *connector, |
- | |
7764 | int reg_eldv, uint32_t bits_eldv, |
- | |
7765 | int reg_elda, uint32_t bits_elda, |
- | |
7766 | int reg_edid) |
- | |
7767 | { |
- | |
7768 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
7769 | uint8_t *eld = connector->eld; |
- | |
7770 | uint32_t i; |
- | |
7771 | - | ||
7772 | i = I915_READ(reg_eldv); |
- | |
7773 | i &= bits_eldv; |
- | |
7774 | - | ||
7775 | if (!eld[0]) |
- | |
7776 | return !i; |
- | |
7777 | - | ||
7778 | if (!i) |
- | |
7779 | return false; |
- | |
7780 | - | ||
7781 | i = I915_READ(reg_elda); |
- | |
7782 | i &= ~bits_elda; |
- | |
7783 | I915_WRITE(reg_elda, i); |
- | |
7784 | 8175 | I915_READ(PIPE_MULT(pipe_config->cpu_transcoder)) + 1; |
|
7785 | for (i = 0; i < eld[2]; i++) |
8176 | } else { |
Line 7786... | Line 8177... | ||
7786 | if (I915_READ(reg_edid) != *((uint32_t *)eld + i)) |
8177 | pipe_config->pixel_multiplier = 1; |
7787 | return false; |
- | |
7788 | - | ||
7789 | return true; |
- | |
7790 | } |
- | |
7791 | - | ||
7792 | static void g4x_write_eld(struct drm_connector *connector, |
- | |
7793 | struct drm_crtc *crtc, |
- | |
7794 | struct drm_display_mode *mode) |
- | |
7795 | { |
- | |
7796 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
7797 | uint8_t *eld = connector->eld; |
- | |
7798 | uint32_t eldv; |
- | |
7799 | uint32_t len; |
- | |
7800 | uint32_t i; |
- | |
7801 | - | ||
7802 | i = I915_READ(G4X_AUD_VID_DID); |
- | |
7803 | - | ||
7804 | if (i == INTEL_AUDIO_DEVBLC || i == INTEL_AUDIO_DEVCL) |
- | |
7805 | eldv = G4X_ELDV_DEVCL_DEVBLC; |
- | |
7806 | else |
- | |
7807 | eldv = G4X_ELDV_DEVCTG; |
- | |
7808 | - | ||
7809 | if (intel_eld_uptodate(connector, |
- | |
7810 | G4X_AUD_CNTL_ST, eldv, |
- | |
7811 | G4X_AUD_CNTL_ST, G4X_ELD_ADDR, |
- | |
7812 | G4X_HDMIW_HDMIEDID)) |
- | |
7813 | return; |
- | |
7814 | - | ||
7815 | i = I915_READ(G4X_AUD_CNTL_ST); |
- | |
7816 | i &= ~(eldv | G4X_ELD_ADDR); |
- | |
7817 | len = (i >> 9) & 0x1f; /* ELD buffer size */ |
- | |
7818 | I915_WRITE(G4X_AUD_CNTL_ST, i); |
- | |
7819 | - | ||
7820 | if (!eld[0]) |
- | |
7821 | return; |
- | |
7822 | - | ||
7823 | len = min_t(uint8_t, eld[2], len); |
- | |
7824 | DRM_DEBUG_DRIVER("ELD size %d\n", len); |
- | |
7825 | for (i = 0; i < len; i++) |
- | |
7826 | I915_WRITE(G4X_HDMIW_HDMIEDID, *((uint32_t *)eld + i)); |
- | |
7827 | - | ||
7828 | i = I915_READ(G4X_AUD_CNTL_ST); |
- | |
7829 | i |= eldv; |
- | |
7830 | I915_WRITE(G4X_AUD_CNTL_ST, i); |
- | |
7831 | } |
- | |
7832 | - | ||
7833 | static void haswell_write_eld(struct drm_connector *connector, |
- | |
7834 | struct drm_crtc *crtc, |
- | |
7835 | struct drm_display_mode *mode) |
- | |
7836 | { |
- | |
7837 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
7838 | uint8_t *eld = connector->eld; |
- | |
7839 | uint32_t eldv; |
- | |
7840 | uint32_t i; |
- | |
7841 | int len; |
- | |
7842 | int pipe = to_intel_crtc(crtc)->pipe; |
- | |
7843 | int tmp; |
- | |
7844 | - | ||
7845 | int hdmiw_hdmiedid = HSW_AUD_EDID_DATA(pipe); |
- | |
7846 | int aud_cntl_st = HSW_AUD_DIP_ELD_CTRL(pipe); |
- | |
7847 | int aud_config = HSW_AUD_CFG(pipe); |
- | |
7848 | int aud_cntrl_st2 = HSW_AUD_PIN_ELD_CP_VLD; |
- | |
7849 | - | ||
7850 | /* Audio output enable */ |
- | |
7851 | DRM_DEBUG_DRIVER("HDMI audio: enable codec\n"); |
- | |
7852 | tmp = I915_READ(aud_cntrl_st2); |
- | |
7853 | tmp |= (AUDIO_OUTPUT_ENABLE_A << (pipe * 4)); |
- | |
7854 | I915_WRITE(aud_cntrl_st2, tmp); |
- | |
7855 | POSTING_READ(aud_cntrl_st2); |
- | |
7856 | - | ||
7857 | assert_pipe_disabled(dev_priv, to_intel_crtc(crtc)->pipe); |
- | |
7858 | - | ||
7859 | /* Set ELD valid state */ |
- | |
7860 | tmp = I915_READ(aud_cntrl_st2); |
- | |
7861 | DRM_DEBUG_DRIVER("HDMI audio: pin eld vld status=0x%08x\n", tmp); |
- | |
7862 | tmp |= (AUDIO_ELD_VALID_A << (pipe * 4)); |
- | |
7863 | I915_WRITE(aud_cntrl_st2, tmp); |
- | |
7864 | tmp = I915_READ(aud_cntrl_st2); |
- | |
7865 | DRM_DEBUG_DRIVER("HDMI audio: eld vld status=0x%08x\n", tmp); |
- | |
7866 | - | ||
7867 | /* Enable HDMI mode */ |
- | |
7868 | tmp = I915_READ(aud_config); |
- | |
7869 | DRM_DEBUG_DRIVER("HDMI audio: audio conf: 0x%08x\n", tmp); |
- | |
7870 | /* clear N_programing_enable and N_value_index */ |
- | |
7871 | tmp &= ~(AUD_CONFIG_N_VALUE_INDEX | AUD_CONFIG_N_PROG_ENABLE); |
- | |
7872 | I915_WRITE(aud_config, tmp); |
- | |
7873 | - | ||
7874 | DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe)); |
- | |
7875 | - | ||
7876 | eldv = AUDIO_ELD_VALID_A << (pipe * 4); |
- | |
7877 | - | ||
7878 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) { |
- | |
7879 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); |
- | |
7880 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ |
- | |
7881 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ |
- | |
7882 | } else { |
- | |
7883 | I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode)); |
- | |
7884 | } |
- | |
7885 | - | ||
7886 | if (intel_eld_uptodate(connector, |
- | |
7887 | aud_cntrl_st2, eldv, |
- | |
7888 | aud_cntl_st, IBX_ELD_ADDRESS, |
- | |
7889 | hdmiw_hdmiedid)) |
- | |
7890 | return; |
- | |
7891 | - | ||
7892 | i = I915_READ(aud_cntrl_st2); |
- | |
7893 | i &= ~eldv; |
- | |
7894 | I915_WRITE(aud_cntrl_st2, i); |
- | |
7895 | - | ||
7896 | if (!eld[0]) |
- | |
7897 | return; |
- | |
7898 | - | ||
7899 | i = I915_READ(aud_cntl_st); |
- | |
7900 | i &= ~IBX_ELD_ADDRESS; |
- | |
7901 | I915_WRITE(aud_cntl_st, i); |
- | |
7902 | i = (i >> 29) & DIP_PORT_SEL_MASK; /* DIP_Port_Select, 0x1 = PortB */ |
- | |
7903 | DRM_DEBUG_DRIVER("port num:%d\n", i); |
- | |
7904 | - | ||
7905 | len = min_t(uint8_t, eld[2], 21); /* 84 bytes of hw ELD buffer */ |
- | |
7906 | DRM_DEBUG_DRIVER("ELD size %d\n", len); |
- | |
7907 | for (i = 0; i < len; i++) |
- | |
7908 | I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i)); |
- | |
7909 | - | ||
7910 | i = I915_READ(aud_cntrl_st2); |
- | |
7911 | i |= eldv; |
- | |
7912 | I915_WRITE(aud_cntrl_st2, i); |
- | |
7913 | - | ||
7914 | } |
- | |
7915 | - | ||
7916 | static void ironlake_write_eld(struct drm_connector *connector, |
- | |
7917 | struct drm_crtc *crtc, |
- | |
7918 | struct drm_display_mode *mode) |
- | |
7919 | { |
- | |
7920 | struct drm_i915_private *dev_priv = connector->dev->dev_private; |
- | |
7921 | uint8_t *eld = connector->eld; |
- | |
7922 | uint32_t eldv; |
- | |
7923 | uint32_t i; |
- | |
7924 | int len; |
- | |
7925 | int hdmiw_hdmiedid; |
- | |
7926 | int aud_config; |
- | |
7927 | int aud_cntl_st; |
- | |
7928 | int aud_cntrl_st2; |
- | |
7929 | int pipe = to_intel_crtc(crtc)->pipe; |
- | |
7930 | - | ||
7931 | if (HAS_PCH_IBX(connector->dev)) { |
- | |
7932 | hdmiw_hdmiedid = IBX_HDMIW_HDMIEDID(pipe); |
- | |
7933 | aud_config = IBX_AUD_CFG(pipe); |
- | |
7934 | aud_cntl_st = IBX_AUD_CNTL_ST(pipe); |
- | |
7935 | aud_cntrl_st2 = IBX_AUD_CNTL_ST2; |
- | |
7936 | } else if (IS_VALLEYVIEW(connector->dev)) { |
- | |
7937 | hdmiw_hdmiedid = VLV_HDMIW_HDMIEDID(pipe); |
- | |
7938 | aud_config = VLV_AUD_CFG(pipe); |
- | |
7939 | aud_cntl_st = VLV_AUD_CNTL_ST(pipe); |
- | |
7940 | aud_cntrl_st2 = VLV_AUD_CNTL_ST2; |
- | |
7941 | } else { |
- | |
7942 | hdmiw_hdmiedid = CPT_HDMIW_HDMIEDID(pipe); |
- | |
7943 | aud_config = CPT_AUD_CFG(pipe); |
- | |
7944 | aud_cntl_st = CPT_AUD_CNTL_ST(pipe); |
- | |
7945 | aud_cntrl_st2 = CPT_AUD_CNTRL_ST2; |
- | |
7946 | } |
- | |
7947 | - | ||
7948 | DRM_DEBUG_DRIVER("ELD on pipe %c\n", pipe_name(pipe)); |
- | |
7949 | - | ||
7950 | if (IS_VALLEYVIEW(connector->dev)) { |
- | |
7951 | struct intel_encoder *intel_encoder; |
- | |
7952 | struct intel_digital_port *intel_dig_port; |
- | |
7953 | - | ||
7954 | intel_encoder = intel_attached_encoder(connector); |
- | |
7955 | intel_dig_port = enc_to_dig_port(&intel_encoder->base); |
- | |
7956 | i = intel_dig_port->port; |
- | |
7957 | } else { |
- | |
7958 | i = I915_READ(aud_cntl_st); |
- | |
7959 | i = (i >> 29) & DIP_PORT_SEL_MASK; |
- | |
7960 | /* DIP_Port_Select, 0x1 = PortB */ |
- | |
7961 | } |
- | |
7962 | - | ||
7963 | if (!i) { |
- | |
7964 | DRM_DEBUG_DRIVER("Audio directed to unknown port\n"); |
- | |
7965 | /* operate blindly on all ports */ |
- | |
7966 | eldv = IBX_ELD_VALIDB; |
- | |
7967 | eldv |= IBX_ELD_VALIDB << 4; |
- | |
7968 | eldv |= IBX_ELD_VALIDB << 8; |
- | |
7969 | } else { |
- | |
7970 | DRM_DEBUG_DRIVER("ELD on port %c\n", port_name(i)); |
- | |
7971 | eldv = IBX_ELD_VALIDB << ((i - 1) * 4); |
- | |
7972 | } |
- | |
7973 | - | ||
7974 | if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) { |
- | |
7975 | DRM_DEBUG_DRIVER("ELD: DisplayPort detected\n"); |
- | |
7976 | eld[5] |= (1 << 2); /* Conn_Type, 0x1 = DisplayPort */ |
- | |
7977 | I915_WRITE(aud_config, AUD_CONFIG_N_VALUE_INDEX); /* 0x1 = DP */ |
- | |
7978 | } else { |
- | |
7979 | I915_WRITE(aud_config, audio_config_hdmi_pixel_clock(mode)); |
- | |
7980 | } |
- | |
7981 | - | ||
7982 | if (intel_eld_uptodate(connector, |
- | |
7983 | aud_cntrl_st2, eldv, |
- | |
7984 | aud_cntl_st, IBX_ELD_ADDRESS, |
- | |
7985 | hdmiw_hdmiedid)) |
- | |
7986 | return; |
- | |
7987 | - | ||
7988 | i = I915_READ(aud_cntrl_st2); |
- | |
7989 | i &= ~eldv; |
- | |
7990 | I915_WRITE(aud_cntrl_st2, i); |
- | |
7991 | - | ||
7992 | if (!eld[0]) |
- | |
7993 | return; |
- | |
7994 | - | ||
7995 | i = I915_READ(aud_cntl_st); |
- | |
7996 | i &= ~IBX_ELD_ADDRESS; |
- | |
7997 | I915_WRITE(aud_cntl_st, i); |
- | |
7998 | - | ||
7999 | len = min_t(uint8_t, eld[2], 21); /* 84 bytes of hw ELD buffer */ |
- | |
8000 | DRM_DEBUG_DRIVER("ELD size %d\n", len); |
- | |
8001 | for (i = 0; i < len; i++) |
- | |
8002 | I915_WRITE(hdmiw_hdmiedid, *((uint32_t *)eld + i)); |
- | |
8003 | - | ||
8004 | i = I915_READ(aud_cntrl_st2); |
- | |
8005 | i |= eldv; |
8178 | } |
8006 | I915_WRITE(aud_cntrl_st2, i); |
- | |
8007 | } |
- | |
8008 | 8179 | ||
8009 | void intel_write_eld(struct drm_encoder *encoder, |
8180 | return true; |
- | 8181 | } |
|
- | 8182 | ||
Line -... | Line 8183... | ||
- | 8183 | static void i845_update_cursor(struct drm_crtc *crtc, u32 base) |
|
8010 | struct drm_display_mode *mode) |
8184 | { |
8011 | { |
8185 | struct drm_device *dev = crtc->dev; |
8012 | struct drm_crtc *crtc = encoder->crtc; |
8186 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line -... | Line 8187... | ||
- | 8187 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 8188 | uint32_t cntl = 0, size = 0; |
|
8013 | struct drm_connector *connector; |
8189 | |
8014 | struct drm_device *dev = encoder->dev; |
8190 | if (base) { |
8015 | struct drm_i915_private *dev_priv = dev->dev_private; |
8191 | unsigned int width = intel_crtc->cursor_width; |
8016 | 8192 | unsigned int height = intel_crtc->cursor_height; |
|
- | 8193 | unsigned int stride = roundup_pow_of_two(width) * 4; |
|
- | 8194 | ||
- | 8195 | switch (stride) { |
|
- | 8196 | default: |
|
8017 | connector = drm_select_eld(encoder, mode); |
8197 | WARN_ONCE(1, "Invalid cursor width/stride, width=%u, stride=%u\n", |
- | 8198 | width, stride); |
|
Line -... | Line 8199... | ||
- | 8199 | stride = 256; |
|
- | 8200 | /* fallthrough */ |
|
- | 8201 | case 256: |
|
8018 | if (!connector) |
8202 | case 512: |
Line 8019... | Line 8203... | ||
8019 | return; |
8203 | case 1024: |
8020 | - | ||
8021 | DRM_DEBUG_DRIVER("ELD on [CONNECTOR:%d:%s], [ENCODER:%d:%s]\n", |
8204 | case 2048: |
Line 8022... | Line -... | ||
8022 | connector->base.id, |
- | |
8023 | connector->name, |
- | |
8024 | connector->encoder->base.id, |
8205 | break; |
8025 | connector->encoder->name); |
8206 | } |
8026 | 8207 | ||
8027 | connector->eld[6] = drm_av_sync_delay(connector, mode) / 2; |
- | |
8028 | - | ||
8029 | if (dev_priv->display.write_eld) |
8208 | cntl |= CURSOR_ENABLE | |
8030 | dev_priv->display.write_eld(connector, crtc, mode); |
8209 | CURSOR_GAMMA_ENABLE | |
8031 | } |
8210 | CURSOR_FORMAT_ARGB | |
8032 | 8211 | CURSOR_STRIDE(stride); |
|
8033 | static void i845_update_cursor(struct drm_crtc *crtc, u32 base) |
- | |
8034 | { |
8212 | |
8035 | struct drm_device *dev = crtc->dev; |
8213 | size = (height << 12) | width; |
8036 | struct drm_i915_private *dev_priv = dev->dev_private; |
8214 | } |
8037 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
8215 | |
Line -... | Line 8216... | ||
- | 8216 | if (intel_crtc->cursor_cntl != 0 && |
|
8038 | uint32_t cntl; |
8217 | (intel_crtc->cursor_base != base || |
- | 8218 | intel_crtc->cursor_size != size || |
|
- | 8219 | intel_crtc->cursor_cntl != cntl)) { |
|
- | 8220 | /* On these chipsets we can only modify the base/size/stride |
|
- | 8221 | * whilst the cursor is disabled. |
|
8039 | 8222 | */ |
|
- | 8223 | I915_WRITE(_CURACNTR, 0); |
|
8040 | if (base != intel_crtc->cursor_base) { |
8224 | POSTING_READ(_CURACNTR); |
Line 8041... | Line -... | ||
8041 | /* On these chipsets we can only modify the base whilst |
- | |
8042 | * the cursor is disabled. |
- | |
8043 | */ |
- | |
8044 | if (intel_crtc->cursor_cntl) { |
- | |
8045 | I915_WRITE(_CURACNTR, 0); |
- | |
8046 | POSTING_READ(_CURACNTR); |
- | |
8047 | intel_crtc->cursor_cntl = 0; |
8225 | intel_crtc->cursor_cntl = 0; |
8048 | } |
8226 | } |
8049 | 8227 | ||
8050 | I915_WRITE(_CURABASE, base); |
8228 | if (intel_crtc->cursor_base != base) { |
8051 | POSTING_READ(_CURABASE); |
8229 | I915_WRITE(_CURABASE, base); |
Line 8088... | Line 8266... | ||
8088 | default: |
8266 | default: |
8089 | WARN_ON(1); |
8267 | WARN_ON(1); |
8090 | return; |
8268 | return; |
8091 | } |
8269 | } |
8092 | cntl |= pipe << 28; /* Connect to correct pipe */ |
8270 | cntl |= pipe << 28; /* Connect to correct pipe */ |
8093 | } |
- | |
8094 | if (intel_crtc->cursor_cntl != cntl) { |
- | |
8095 | I915_WRITE(CURCNTR(pipe), cntl); |
- | |
8096 | POSTING_READ(CURCNTR(pipe)); |
- | |
8097 | intel_crtc->cursor_cntl = cntl; |
- | |
8098 | } |
- | |
8099 | - | ||
8100 | /* and commit changes on next vblank */ |
- | |
8101 | I915_WRITE(CURBASE(pipe), base); |
- | |
8102 | POSTING_READ(CURBASE(pipe)); |
- | |
8103 | } |
- | |
8104 | - | ||
8105 | static void ivb_update_cursor(struct drm_crtc *crtc, u32 base) |
- | |
8106 | { |
- | |
8107 | struct drm_device *dev = crtc->dev; |
- | |
8108 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
8109 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
- | |
8110 | int pipe = intel_crtc->pipe; |
- | |
8111 | uint32_t cntl; |
- | |
Line 8112... | Line -... | ||
8112 | - | ||
8113 | cntl = 0; |
- | |
8114 | if (base) { |
- | |
8115 | cntl = MCURSOR_GAMMA_ENABLE; |
- | |
8116 | switch (intel_crtc->cursor_width) { |
- | |
8117 | case 64: |
- | |
8118 | cntl |= CURSOR_MODE_64_ARGB_AX; |
- | |
8119 | break; |
- | |
8120 | case 128: |
- | |
8121 | cntl |= CURSOR_MODE_128_ARGB_AX; |
- | |
8122 | break; |
- | |
8123 | case 256: |
- | |
8124 | cntl |= CURSOR_MODE_256_ARGB_AX; |
- | |
8125 | break; |
- | |
8126 | default: |
- | |
8127 | WARN_ON(1); |
- | |
8128 | return; |
- | |
8129 | } |
- | |
8130 | } |
8271 | |
8131 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
8272 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
- | 8273 | cntl |= CURSOR_PIPE_CSC_ENABLE; |
|
- | 8274 | } |
|
- | 8275 | ||
- | 8276 | if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) |
|
Line 8132... | Line 8277... | ||
8132 | cntl |= CURSOR_PIPE_CSC_ENABLE; |
8277 | cntl |= CURSOR_ROTATE_180; |
8133 | 8278 | ||
8134 | if (intel_crtc->cursor_cntl != cntl) { |
8279 | if (intel_crtc->cursor_cntl != cntl) { |
8135 | I915_WRITE(CURCNTR(pipe), cntl); |
8280 | I915_WRITE(CURCNTR(pipe), cntl); |
8136 | POSTING_READ(CURCNTR(pipe)); |
8281 | POSTING_READ(CURCNTR(pipe)); |
Line 8137... | Line 8282... | ||
8137 | intel_crtc->cursor_cntl = cntl; |
8282 | intel_crtc->cursor_cntl = cntl; |
8138 | } |
8283 | } |
8139 | 8284 | ||
- | 8285 | /* and commit changes on next vblank */ |
|
- | 8286 | I915_WRITE(CURBASE(pipe), base); |
|
8140 | /* and commit changes on next vblank */ |
8287 | POSTING_READ(CURBASE(pipe)); |
Line 8141... | Line 8288... | ||
8141 | I915_WRITE(CURBASE(pipe), base); |
8288 | |
8142 | POSTING_READ(CURBASE(pipe)); |
8289 | intel_crtc->cursor_base = base; |
8143 | } |
8290 | } |
Line 8184... | Line 8331... | ||
8184 | if (base == 0 && intel_crtc->cursor_base == 0) |
8331 | if (base == 0 && intel_crtc->cursor_base == 0) |
8185 | return; |
8332 | return; |
Line 8186... | Line 8333... | ||
8186 | 8333 | ||
Line -... | Line 8334... | ||
- | 8334 | I915_WRITE(CURPOS(pipe), pos); |
|
- | 8335 | ||
8187 | I915_WRITE(CURPOS(pipe), pos); |
8336 | /* ILK+ do this automagically */ |
- | 8337 | if (HAS_GMCH_DISPLAY(dev) && |
|
8188 | 8338 | to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) { |
|
- | 8339 | base += (intel_crtc->cursor_height * |
|
- | 8340 | intel_crtc->cursor_width - 1) * 4; |
|
8189 | if (IS_IVYBRIDGE(dev) || IS_HASWELL(dev) || IS_BROADWELL(dev)) |
8341 | } |
8190 | ivb_update_cursor(crtc, base); |
8342 | |
8191 | else if (IS_845G(dev) || IS_I865G(dev)) |
8343 | if (IS_845G(dev) || IS_I865G(dev)) |
8192 | i845_update_cursor(crtc, base); |
8344 | i845_update_cursor(crtc, base); |
8193 | else |
- | |
8194 | i9xx_update_cursor(crtc, base); |
8345 | else |
Line -... | Line 8346... | ||
- | 8346 | i9xx_update_cursor(crtc, base); |
|
- | 8347 | } |
|
- | 8348 | ||
- | 8349 | static bool cursor_size_ok(struct drm_device *dev, |
|
- | 8350 | uint32_t width, uint32_t height) |
|
- | 8351 | { |
|
8195 | intel_crtc->cursor_base = base; |
8352 | if (width == 0 || height == 0) |
8196 | } |
8353 | return false; |
8197 | - | ||
8198 | /* |
8354 | |
8199 | * intel_crtc_cursor_set_obj - Set cursor to specified GEM object |
8355 | /* |
8200 | * |
8356 | * 845g/865g are special in that they are only limited by |
8201 | * Note that the object's reference will be consumed if the update fails. If |
8357 | * the width of their cursors, the height is arbitrary up to |
- | 8358 | * the precision of the register. Everything else requires |
|
- | 8359 | * square cursors, limited to a few power-of-two sizes. |
|
- | 8360 | */ |
|
- | 8361 | if (IS_845G(dev) || IS_I865G(dev)) { |
|
- | 8362 | if ((width & 63) != 0) |
|
- | 8363 | return false; |
|
- | 8364 | ||
- | 8365 | if (width > (IS_845G(dev) ? 64 : 512)) |
|
- | 8366 | return false; |
|
- | 8367 | ||
- | 8368 | if (height > 1023) |
|
- | 8369 | return false; |
|
- | 8370 | } else { |
|
- | 8371 | switch (width | height) { |
|
- | 8372 | case 256: |
|
- | 8373 | case 128: |
|
- | 8374 | if (IS_GEN2(dev)) |
|
- | 8375 | return false; |
|
- | 8376 | case 64: |
|
- | 8377 | break; |
|
- | 8378 | default: |
|
- | 8379 | return false; |
|
- | 8380 | } |
|
- | 8381 | } |
|
- | 8382 | ||
8202 | * the update succeeds, the reference of the old object (if any) will be |
8383 | return true; |
8203 | * consumed. |
8384 | } |
8204 | */ |
8385 | |
8205 | static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc, |
8386 | static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc, |
8206 | struct drm_i915_gem_object *obj, |
8387 | struct drm_i915_gem_object *obj, |
8207 | uint32_t width, uint32_t height) |
8388 | uint32_t width, uint32_t height) |
8208 | { |
8389 | { |
8209 | struct drm_device *dev = crtc->dev; |
8390 | struct drm_device *dev = crtc->dev; |
8210 | struct drm_i915_private *dev_priv = dev->dev_private; |
8391 | struct drm_i915_private *dev_priv = to_i915(dev); |
8211 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
8392 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
8212 | enum pipe pipe = intel_crtc->pipe; |
8393 | enum pipe pipe = intel_crtc->pipe; |
Line 8213... | Line 8394... | ||
8213 | unsigned old_width; |
8394 | unsigned old_width; |
8214 | uint32_t addr; |
8395 | uint32_t addr; |
8215 | int ret; |
8396 | int ret; |
8216 | 8397 | ||
8217 | /* if we want to turn off the cursor ignore width and height */ |
- | |
8218 | if (!obj) { |
8398 | /* if we want to turn off the cursor ignore width and height */ |
8219 | DRM_DEBUG_KMS("cursor off\n"); |
8399 | if (!obj) { |
8220 | addr = 0; |
8400 | DRM_DEBUG_KMS("cursor off\n"); |
Line 8221... | Line -... | ||
8221 | obj = NULL; |
- | |
8222 | mutex_lock(&dev->struct_mutex); |
- | |
8223 | goto finish; |
- | |
8224 | } |
- | |
8225 | - | ||
8226 | /* Check for which cursor types we support */ |
- | |
8227 | if (!((width == 64 && height == 64) || |
- | |
8228 | (width == 128 && height == 128 && !IS_GEN2(dev)) || |
- | |
8229 | (width == 256 && height == 256 && !IS_GEN2(dev)))) { |
- | |
8230 | DRM_DEBUG("Cursor dimension not supported\n"); |
- | |
8231 | return -EINVAL; |
- | |
8232 | } |
- | |
8233 | - | ||
8234 | if (obj->base.size < width * height * 4) { |
- | |
8235 | DRM_DEBUG_KMS("buffer is too small\n"); |
8401 | addr = 0; |
8236 | ret = -ENOMEM; |
8402 | mutex_lock(&dev->struct_mutex); |
8237 | goto fail; |
8403 | goto finish; |
8238 | } |
8404 | } |
Line 8239... | Line -... | ||
8239 | - | ||
8240 | /* we only need to pin inside GTT if cursor is non-phy */ |
- | |
8241 | mutex_lock(&dev->struct_mutex); |
- | |
8242 | if (!INTEL_INFO(dev)->cursor_needs_physical) { |
- | |
8243 | unsigned alignment; |
- | |
8244 | - | ||
8245 | if (obj->tiling_mode) { |
8405 | |
8246 | DRM_DEBUG_KMS("cursor cannot be tiled\n"); |
8406 | /* we only need to pin inside GTT if cursor is non-phy */ |
8247 | ret = -EINVAL; |
8407 | mutex_lock(&dev->struct_mutex); |
8248 | goto fail_locked; |
8408 | if (!INTEL_INFO(dev)->cursor_needs_physical) { |
8249 | } |
8409 | unsigned alignment; |
Line 8283... | Line 8443... | ||
8283 | addr = i915_gem_obj_ggtt_offset(obj); |
8443 | addr = i915_gem_obj_ggtt_offset(obj); |
Line 8284... | Line 8444... | ||
8284 | 8444 | ||
8285 | intel_runtime_pm_put(dev_priv); |
8445 | intel_runtime_pm_put(dev_priv); |
8286 | } else { |
8446 | } else { |
8287 | int align = IS_I830(dev) ? 16 * 1024 : 256; |
8447 | int align = IS_I830(dev) ? 16 * 1024 : 256; |
8288 | // ret = i915_gem_object_attach_phys(obj, align); |
8448 | ret = 1;//i915_gem_object_attach_phys(obj, align); |
8289 | // if (ret) { |
8449 | if (ret) { |
8290 | // DRM_DEBUG_KMS("failed to attach phys object\n"); |
8450 | DRM_DEBUG_KMS("failed to attach phys object\n"); |
8291 | // goto fail_locked; |
8451 | goto fail_locked; |
8292 | // } |
8452 | } |
8293 | // addr = obj->phys_handle->busaddr; |
8453 | addr = obj->phys_handle->busaddr; |
8294 | } |
- | |
8295 | - | ||
8296 | if (IS_GEN2(dev)) |
- | |
Line 8297... | Line 8454... | ||
8297 | I915_WRITE(CURSIZE, (height << 12) | width); |
8454 | } |
8298 | 8455 | ||
8299 | finish: |
8456 | finish: |
8300 | if (intel_crtc->cursor_bo) { |
8457 | if (intel_crtc->cursor_bo) { |
Line 8315... | Line 8472... | ||
8315 | 8472 | ||
8316 | if (intel_crtc->active) { |
8473 | if (intel_crtc->active) { |
8317 | if (old_width != width) |
8474 | if (old_width != width) |
8318 | intel_update_watermarks(crtc); |
8475 | intel_update_watermarks(crtc); |
- | 8476 | intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
|
- | 8477 | ||
8319 | intel_crtc_update_cursor(crtc, intel_crtc->cursor_bo != NULL); |
8478 | intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_CURSOR(pipe)); |
Line 8320... | Line 8479... | ||
8320 | } |
8479 | } |
8321 | 8480 | ||
8322 | return 0; |
8481 | return 0; |
8323 | fail_unpin: |
8482 | fail_unpin: |
8324 | i915_gem_object_unpin_from_display_plane(obj); |
8483 | i915_gem_object_unpin_from_display_plane(obj); |
8325 | fail_locked: |
- | |
8326 | mutex_unlock(&dev->struct_mutex); |
- | |
8327 | fail: |
8484 | fail_locked: |
8328 | drm_gem_object_unreference_unlocked(&obj->base); |
8485 | mutex_unlock(&dev->struct_mutex); |
Line 8329... | Line 8486... | ||
8329 | return ret; |
8486 | return ret; |
8330 | } |
8487 | } |
Line 8358... | Line 8515... | ||
8358 | struct intel_framebuffer *intel_fb; |
8515 | struct intel_framebuffer *intel_fb; |
8359 | int ret; |
8516 | int ret; |
Line 8360... | Line 8517... | ||
8360 | 8517 | ||
8361 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); |
8518 | intel_fb = kzalloc(sizeof(*intel_fb), GFP_KERNEL); |
8362 | if (!intel_fb) { |
8519 | if (!intel_fb) { |
8363 | drm_gem_object_unreference_unlocked(&obj->base); |
8520 | drm_gem_object_unreference(&obj->base); |
8364 | return ERR_PTR(-ENOMEM); |
8521 | return ERR_PTR(-ENOMEM); |
Line 8365... | Line 8522... | ||
8365 | } |
8522 | } |
8366 | 8523 | ||
8367 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); |
8524 | ret = intel_framebuffer_init(dev, intel_fb, mode_cmd, obj); |
Line 8368... | Line 8525... | ||
8368 | if (ret) |
8525 | if (ret) |
8369 | goto err; |
8526 | goto err; |
8370 | 8527 | ||
8371 | return &intel_fb->base; |
8528 | return &intel_fb->base; |
Line 8372... | Line 8529... | ||
8372 | err: |
8529 | err: |
8373 | drm_gem_object_unreference_unlocked(&obj->base); |
8530 | drm_gem_object_unreference(&obj->base); |
Line 8501... | Line 8658... | ||
8501 | crtc = encoder->crtc; |
8658 | crtc = encoder->crtc; |
Line 8502... | Line 8659... | ||
8502 | 8659 | ||
8503 | ret = drm_modeset_lock(&crtc->mutex, ctx); |
8660 | ret = drm_modeset_lock(&crtc->mutex, ctx); |
8504 | if (ret) |
8661 | if (ret) |
- | 8662 | goto fail_unlock; |
|
- | 8663 | ret = drm_modeset_lock(&crtc->primary->mutex, ctx); |
|
- | 8664 | if (ret) |
|
Line 8505... | Line 8665... | ||
8505 | goto fail_unlock; |
8665 | goto fail_unlock; |
8506 | 8666 | ||
Line 8507... | Line 8667... | ||
8507 | old->dpms_mode = connector->dpms; |
8667 | old->dpms_mode = connector->dpms; |
Line 8538... | Line 8698... | ||
8538 | } |
8698 | } |
Line 8539... | Line 8699... | ||
8539 | 8699 | ||
8540 | ret = drm_modeset_lock(&crtc->mutex, ctx); |
8700 | ret = drm_modeset_lock(&crtc->mutex, ctx); |
8541 | if (ret) |
8701 | if (ret) |
- | 8702 | goto fail_unlock; |
|
- | 8703 | ret = drm_modeset_lock(&crtc->primary->mutex, ctx); |
|
- | 8704 | if (ret) |
|
8542 | goto fail_unlock; |
8705 | goto fail_unlock; |
8543 | intel_encoder->new_crtc = to_intel_crtc(crtc); |
8706 | intel_encoder->new_crtc = to_intel_crtc(crtc); |
Line 8544... | Line 8707... | ||
8544 | to_intel_connector(connector)->new_encoder = intel_encoder; |
8707 | to_intel_connector(connector)->new_encoder = intel_encoder; |
8545 | 8708 | ||
Line 8820... | Line 8983... | ||
8820 | drm_mode_set_name(mode); |
8983 | drm_mode_set_name(mode); |
Line 8821... | Line 8984... | ||
8821 | 8984 | ||
8822 | return mode; |
8985 | return mode; |
Line 8823... | Line -... | ||
8823 | } |
- | |
8824 | - | ||
8825 | static void intel_increase_pllclock(struct drm_device *dev, |
- | |
8826 | enum pipe pipe) |
- | |
8827 | { |
- | |
8828 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
8829 | int dpll_reg = DPLL(pipe); |
- | |
8830 | int dpll; |
- | |
8831 | - | ||
8832 | if (!HAS_GMCH_DISPLAY(dev)) |
- | |
8833 | return; |
- | |
8834 | - | ||
8835 | if (!dev_priv->lvds_downclock_avail) |
- | |
8836 | return; |
- | |
8837 | - | ||
8838 | dpll = I915_READ(dpll_reg); |
- | |
8839 | if (!HAS_PIPE_CXSR(dev) && (dpll & DISPLAY_RATE_SELECT_FPA1)) { |
- | |
8840 | DRM_DEBUG_DRIVER("upclocking LVDS\n"); |
- | |
8841 | - | ||
8842 | assert_panel_unlocked(dev_priv, pipe); |
- | |
8843 | - | ||
8844 | dpll &= ~DISPLAY_RATE_SELECT_FPA1; |
- | |
8845 | I915_WRITE(dpll_reg, dpll); |
- | |
8846 | intel_wait_for_vblank(dev, pipe); |
- | |
8847 | - | ||
8848 | dpll = I915_READ(dpll_reg); |
- | |
8849 | if (dpll & DISPLAY_RATE_SELECT_FPA1) |
- | |
8850 | DRM_DEBUG_DRIVER("failed to upclock LVDS!\n"); |
- | |
8851 | } |
- | |
8852 | } |
8986 | } |
8853 | 8987 | ||
8854 | static void intel_decrease_pllclock(struct drm_crtc *crtc) |
8988 | static void intel_decrease_pllclock(struct drm_crtc *crtc) |
8855 | { |
8989 | { |
8856 | struct drm_device *dev = crtc->dev; |
8990 | struct drm_device *dev = crtc->dev; |
Line 8924... | Line 9058... | ||
8924 | 9058 | ||
8925 | out: |
9059 | out: |
8926 | intel_runtime_pm_put(dev_priv); |
9060 | intel_runtime_pm_put(dev_priv); |
Line 8927... | Line -... | ||
8927 | } |
- | |
8928 | - | ||
8929 | - | ||
8930 | /** |
- | |
8931 | * intel_mark_fb_busy - mark given planes as busy |
- | |
8932 | * @dev: DRM device |
- | |
8933 | * @frontbuffer_bits: bits for the affected planes |
- | |
8934 | * @ring: optional ring for asynchronous commands |
- | |
8935 | * |
- | |
8936 | * This function gets called every time the screen contents change. It can be |
- | |
8937 | * used to keep e.g. the update rate at the nominal refresh rate with DRRS. |
- | |
8938 | */ |
- | |
8939 | static void intel_mark_fb_busy(struct drm_device *dev, |
- | |
8940 | unsigned frontbuffer_bits, |
- | |
8941 | struct intel_engine_cs *ring) |
- | |
8942 | { |
- | |
8943 | enum pipe pipe; |
- | |
8944 | - | ||
8945 | if (!i915.powersave) |
- | |
8946 | return; |
- | |
8947 | - | ||
8948 | for_each_pipe(pipe) { |
- | |
8949 | if (!(frontbuffer_bits & INTEL_FRONTBUFFER_ALL_MASK(pipe))) |
- | |
8950 | continue; |
- | |
8951 | - | ||
8952 | intel_increase_pllclock(dev, pipe); |
- | |
8953 | if (ring && intel_fbc_enabled(dev)) |
- | |
8954 | ring->fbc_dirty = true; |
- | |
8955 | } |
- | |
8956 | } |
- | |
8957 | - | ||
8958 | /** |
- | |
8959 | * intel_fb_obj_invalidate - invalidate frontbuffer object |
- | |
8960 | * @obj: GEM object to invalidate |
- | |
8961 | * @ring: set for asynchronous rendering |
- | |
8962 | * |
- | |
8963 | * This function gets called every time rendering on the given object starts and |
- | |
8964 | * frontbuffer caching (fbc, low refresh rate for DRRS, panel self refresh) must |
- | |
8965 | * be invalidated. If @ring is non-NULL any subsequent invalidation will be delayed |
- | |
8966 | * until the rendering completes or a flip on this frontbuffer plane is |
- | |
8967 | * scheduled. |
- | |
8968 | */ |
- | |
8969 | void intel_fb_obj_invalidate(struct drm_i915_gem_object *obj, |
- | |
8970 | struct intel_engine_cs *ring) |
- | |
8971 | { |
- | |
8972 | struct drm_device *dev = obj->base.dev; |
- | |
8973 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
8974 | - | ||
8975 | WARN_ON(!mutex_is_locked(&dev->struct_mutex)); |
- | |
8976 | - | ||
8977 | if (!obj->frontbuffer_bits) |
- | |
8978 | return; |
- | |
8979 | - | ||
8980 | if (ring) { |
- | |
8981 | mutex_lock(&dev_priv->fb_tracking.lock); |
- | |
8982 | dev_priv->fb_tracking.busy_bits |
- | |
8983 | |= obj->frontbuffer_bits; |
- | |
8984 | dev_priv->fb_tracking.flip_bits |
- | |
8985 | &= ~obj->frontbuffer_bits; |
- | |
8986 | mutex_unlock(&dev_priv->fb_tracking.lock); |
- | |
8987 | } |
- | |
8988 | - | ||
8989 | intel_mark_fb_busy(dev, obj->frontbuffer_bits, ring); |
- | |
8990 | - | ||
8991 | intel_edp_psr_invalidate(dev, obj->frontbuffer_bits); |
- | |
8992 | } |
- | |
8993 | - | ||
8994 | /** |
- | |
8995 | * intel_frontbuffer_flush - flush frontbuffer |
- | |
8996 | * @dev: DRM device |
- | |
8997 | * @frontbuffer_bits: frontbuffer plane tracking bits |
- | |
8998 | * |
- | |
8999 | * This function gets called every time rendering on the given planes has |
- | |
9000 | * completed and frontbuffer caching can be started again. Flushes will get |
- | |
9001 | * delayed if they're blocked by some oustanding asynchronous rendering. |
- | |
9002 | * |
- | |
9003 | * Can be called without any locks held. |
- | |
9004 | */ |
- | |
9005 | void intel_frontbuffer_flush(struct drm_device *dev, |
- | |
9006 | unsigned frontbuffer_bits) |
- | |
9007 | { |
- | |
9008 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
9009 | - | ||
9010 | /* Delay flushing when rings are still busy.*/ |
- | |
9011 | mutex_lock(&dev_priv->fb_tracking.lock); |
- | |
9012 | frontbuffer_bits &= ~dev_priv->fb_tracking.busy_bits; |
- | |
9013 | mutex_unlock(&dev_priv->fb_tracking.lock); |
- | |
9014 | - | ||
9015 | intel_mark_fb_busy(dev, frontbuffer_bits, NULL); |
- | |
9016 | - | ||
9017 | intel_edp_psr_flush(dev, frontbuffer_bits); |
9061 | } |
9018 | } |
9062 | |
9019 | static void intel_crtc_destroy(struct drm_crtc *crtc) |
9063 | static void intel_crtc_destroy(struct drm_crtc *crtc) |
9020 | { |
9064 | { |
9021 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9065 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9022 | struct drm_device *dev = crtc->dev; |
- | |
Line 9023... | Line 9066... | ||
9023 | struct intel_unpin_work *work; |
9066 | struct drm_device *dev = crtc->dev; |
9024 | unsigned long flags; |
9067 | struct intel_unpin_work *work; |
9025 | 9068 | ||
9026 | spin_lock_irqsave(&dev->event_lock, flags); |
9069 | spin_lock_irq(&dev->event_lock); |
Line 9027... | Line 9070... | ||
9027 | work = intel_crtc->unpin_work; |
9070 | work = intel_crtc->unpin_work; |
9028 | intel_crtc->unpin_work = NULL; |
9071 | intel_crtc->unpin_work = NULL; |
9029 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9072 | spin_unlock_irq(&dev->event_lock); |
9030 | 9073 | ||
Line 9052... | Line 9095... | ||
9052 | drm_gem_object_unreference(&work->old_fb_obj->base); |
9095 | drm_gem_object_unreference(&work->old_fb_obj->base); |
Line 9053... | Line 9096... | ||
9053 | 9096 | ||
9054 | intel_update_fbc(dev); |
9097 | intel_update_fbc(dev); |
Line -... | Line 9098... | ||
- | 9098 | mutex_unlock(&dev->struct_mutex); |
|
- | 9099 | ||
9055 | mutex_unlock(&dev->struct_mutex); |
9100 | intel_frontbuffer_flip_complete(dev, INTEL_FRONTBUFFER_PRIMARY(pipe)); |
9056 | 9101 | ||
Line 9057... | Line 9102... | ||
9057 | BUG_ON(atomic_read(&to_intel_crtc(work->crtc)->unpin_work_count) == 0); |
9102 | BUG_ON(atomic_read(&to_intel_crtc(work->crtc)->unpin_work_count) == 0); |
9058 | atomic_dec(&to_intel_crtc(work->crtc)->unpin_work_count); |
9103 | atomic_dec(&to_intel_crtc(work->crtc)->unpin_work_count); |
Line 9059... | Line 9104... | ||
9059 | 9104 | ||
9060 | kfree(work); |
9105 | kfree(work); |
9061 | } |
9106 | } |
9062 | - | ||
9063 | static void do_intel_finish_page_flip(struct drm_device *dev, |
9107 | |
9064 | struct drm_crtc *crtc) |
9108 | static void do_intel_finish_page_flip(struct drm_device *dev, |
9065 | { |
9109 | struct drm_crtc *crtc) |
Line 9066... | Line 9110... | ||
9066 | struct drm_i915_private *dev_priv = dev->dev_private; |
9110 | { |
9067 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9111 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9068 | struct intel_unpin_work *work; |
9112 | struct intel_unpin_work *work; |
Line -... | Line 9113... | ||
- | 9113 | unsigned long flags; |
|
- | 9114 | ||
- | 9115 | /* Ignore early vblank irqs */ |
|
- | 9116 | if (intel_crtc == NULL) |
|
9069 | unsigned long flags; |
9117 | return; |
9070 | 9118 | ||
Line 9071... | Line 9119... | ||
9071 | /* Ignore early vblank irqs */ |
9119 | /* |
9072 | if (intel_crtc == NULL) |
9120 | * This is called both by irq handlers and the reset code (to complete |
Line 9081... | Line 9129... | ||
9081 | if (work == NULL || atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
9129 | if (work == NULL || atomic_read(&work->pending) < INTEL_FLIP_COMPLETE) { |
9082 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9130 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9083 | return; |
9131 | return; |
9084 | } |
9132 | } |
Line 9085... | Line -... | ||
9085 | - | ||
9086 | /* and that the unpin work is consistent wrt ->pending. */ |
- | |
9087 | smp_rmb(); |
- | |
9088 | - | ||
9089 | intel_crtc->unpin_work = NULL; |
- | |
9090 | - | ||
9091 | if (work->event) |
- | |
9092 | drm_send_vblank_event(dev, intel_crtc->pipe, work->event); |
- | |
9093 | 9133 | ||
Line 9094... | Line 9134... | ||
9094 | drm_crtc_vblank_put(crtc); |
9134 | page_flip_completed(intel_crtc); |
9095 | - | ||
9096 | spin_unlock_irqrestore(&dev->event_lock, flags); |
- | |
9097 | - | ||
9098 | wake_up_all(&dev_priv->pending_flip_queue); |
- | |
9099 | - | ||
9100 | queue_work(dev_priv->wq, &work->work); |
- | |
9101 | 9135 | ||
Line 9102... | Line 9136... | ||
9102 | trace_i915_flip_complete(intel_crtc->plane, work->pending_flip_obj); |
9136 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9103 | } |
9137 | } |
9104 | 9138 | ||
Line 9127... | Line 9161... | ||
9127 | static bool page_flip_finished(struct intel_crtc *crtc) |
9161 | static bool page_flip_finished(struct intel_crtc *crtc) |
9128 | { |
9162 | { |
9129 | struct drm_device *dev = crtc->base.dev; |
9163 | struct drm_device *dev = crtc->base.dev; |
9130 | struct drm_i915_private *dev_priv = dev->dev_private; |
9164 | struct drm_i915_private *dev_priv = dev->dev_private; |
Line -... | Line 9165... | ||
- | 9165 | ||
- | 9166 | if (i915_reset_in_progress(&dev_priv->gpu_error) || |
|
- | 9167 | crtc->reset_counter != atomic_read(&dev_priv->gpu_error.reset_counter)) |
|
- | 9168 | return true; |
|
9131 | 9169 | ||
9132 | /* |
9170 | /* |
9133 | * The relevant registers doen't exist on pre-ctg. |
9171 | * The relevant registers doen't exist on pre-ctg. |
9134 | * As the flip done interrupt doesn't trigger for mmio |
9172 | * As the flip done interrupt doesn't trigger for mmio |
9135 | * flips on gmch platforms, a flip count check isn't |
9173 | * flips on gmch platforms, a flip count check isn't |
Line 9165... | Line 9203... | ||
9165 | struct drm_i915_private *dev_priv = dev->dev_private; |
9203 | struct drm_i915_private *dev_priv = dev->dev_private; |
9166 | struct intel_crtc *intel_crtc = |
9204 | struct intel_crtc *intel_crtc = |
9167 | to_intel_crtc(dev_priv->plane_to_crtc_mapping[plane]); |
9205 | to_intel_crtc(dev_priv->plane_to_crtc_mapping[plane]); |
9168 | unsigned long flags; |
9206 | unsigned long flags; |
Line -... | Line 9207... | ||
- | 9207 | ||
- | 9208 | ||
- | 9209 | /* |
|
- | 9210 | * This is called both by irq handlers and the reset code (to complete |
|
- | 9211 | * lost pageflips) so needs the full irqsave spinlocks. |
|
9169 | 9212 | * |
|
9170 | /* NB: An MMIO update of the plane base pointer will also |
9213 | * NB: An MMIO update of the plane base pointer will also |
9171 | * generate a page-flip completion irq, i.e. every modeset |
9214 | * generate a page-flip completion irq, i.e. every modeset |
9172 | * is also accompanied by a spurious intel_prepare_page_flip(). |
9215 | * is also accompanied by a spurious intel_prepare_page_flip(). |
9173 | */ |
9216 | */ |
9174 | spin_lock_irqsave(&dev->event_lock, flags); |
9217 | spin_lock_irqsave(&dev->event_lock, flags); |
Line 9444... | Line 9487... | ||
9444 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
9487 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
9445 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9488 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
9446 | enum pipe pipe = intel_crtc->pipe; |
9489 | enum pipe pipe = intel_crtc->pipe; |
9447 | struct intel_unpin_work *work; |
9490 | struct intel_unpin_work *work; |
9448 | struct intel_engine_cs *ring; |
9491 | struct intel_engine_cs *ring; |
9449 | unsigned long flags; |
- | |
9450 | int ret; |
9492 | int ret; |
Line 9451... | Line 9493... | ||
9451 | 9493 | ||
9452 | /* |
9494 | /* |
9453 | * drm_mode_page_flip_ioctl() should already catch this, but double |
9495 | * drm_mode_page_flip_ioctl() should already catch this, but double |
Line 9468... | Line 9510... | ||
9468 | if (INTEL_INFO(dev)->gen > 3 && |
9510 | if (INTEL_INFO(dev)->gen > 3 && |
9469 | (fb->offsets[0] != crtc->primary->fb->offsets[0] || |
9511 | (fb->offsets[0] != crtc->primary->fb->offsets[0] || |
9470 | fb->pitches[0] != crtc->primary->fb->pitches[0])) |
9512 | fb->pitches[0] != crtc->primary->fb->pitches[0])) |
9471 | return -EINVAL; |
9513 | return -EINVAL; |
Line -... | Line 9514... | ||
- | 9514 | ||
- | 9515 | if (i915_terminally_wedged(&dev_priv->gpu_error)) |
|
- | 9516 | goto out_hang; |
|
9472 | 9517 | ||
9473 | work = kzalloc(sizeof(*work), GFP_KERNEL); |
9518 | work = kzalloc(sizeof(*work), GFP_KERNEL); |
9474 | if (work == NULL) |
9519 | if (work == NULL) |
Line 9475... | Line 9520... | ||
9475 | return -ENOMEM; |
9520 | return -ENOMEM; |
Line 9482... | Line 9527... | ||
9482 | ret = drm_crtc_vblank_get(crtc); |
9527 | ret = drm_crtc_vblank_get(crtc); |
9483 | if (ret) |
9528 | if (ret) |
9484 | goto free_work; |
9529 | goto free_work; |
Line 9485... | Line 9530... | ||
9485 | 9530 | ||
9486 | /* We borrow the event spin lock for protecting unpin_work */ |
9531 | /* We borrow the event spin lock for protecting unpin_work */ |
9487 | spin_lock_irqsave(&dev->event_lock, flags); |
9532 | spin_lock_irq(&dev->event_lock); |
9488 | if (intel_crtc->unpin_work) { |
9533 | if (intel_crtc->unpin_work) { |
- | 9534 | /* Before declaring the flip queue wedged, check if |
|
9489 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9535 | * the hardware completed the operation behind our backs. |
- | 9536 | */ |
|
- | 9537 | if (__intel_pageflip_stall_check(dev, crtc)) { |
|
9490 | kfree(work); |
9538 | DRM_DEBUG_DRIVER("flip queue: previous flip completed, continuing\n"); |
9491 | drm_crtc_vblank_put(crtc); |
9539 | page_flip_completed(intel_crtc); |
9492 | 9540 | } else { |
|
- | 9541 | DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); |
|
- | 9542 | spin_unlock_irq(&dev->event_lock); |
|
- | 9543 | ||
- | 9544 | drm_crtc_vblank_put(crtc); |
|
9493 | DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); |
9545 | kfree(work); |
9494 | return -EBUSY; |
9546 | return -EBUSY; |
- | 9547 | } |
|
9495 | } |
9548 | } |
9496 | intel_crtc->unpin_work = work; |
9549 | intel_crtc->unpin_work = work; |
Line 9497... | Line 9550... | ||
9497 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9550 | spin_unlock_irq(&dev->event_lock); |
9498 | 9551 | ||
Line 9499... | Line 9552... | ||
9499 | if (atomic_read(&intel_crtc->unpin_work_count) >= 2) |
9552 | if (atomic_read(&intel_crtc->unpin_work_count) >= 2) |
Line 9509... | Line 9562... | ||
9509 | 9562 | ||
Line 9510... | Line 9563... | ||
9510 | crtc->primary->fb = fb; |
9563 | crtc->primary->fb = fb; |
Line 9511... | Line -... | ||
9511 | - | ||
9512 | work->pending_flip_obj = obj; |
- | |
9513 | 9564 | ||
9514 | work->enable_stall_check = true; |
9565 | work->pending_flip_obj = obj; |
Line 9515... | Line 9566... | ||
9515 | 9566 | ||
9516 | atomic_inc(&intel_crtc->unpin_work_count); |
9567 | atomic_inc(&intel_crtc->unpin_work_count); |
Line 9532... | Line 9583... | ||
9532 | ring = &dev_priv->ring[BCS]; |
9583 | ring = &dev_priv->ring[BCS]; |
9533 | } else { |
9584 | } else { |
9534 | ring = &dev_priv->ring[RCS]; |
9585 | ring = &dev_priv->ring[RCS]; |
9535 | } |
9586 | } |
Line 9536... | Line 9587... | ||
9536 | 9587 | ||
9537 | ret = intel_pin_and_fence_fb_obj(dev, obj, ring); |
9588 | ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, ring); |
9538 | if (ret) |
9589 | if (ret) |
Line 9539... | Line 9590... | ||
9539 | goto cleanup_pending; |
9590 | goto cleanup_pending; |
9540 | 9591 | ||
Line 9541... | Line 9592... | ||
9541 | work->gtt_offset = |
9592 | work->gtt_offset = |
9542 | i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset; |
9593 | i915_gem_obj_ggtt_offset(obj) + intel_crtc->dspaddr_offset; |
9543 | 9594 | ||
- | 9595 | if (use_mmio_flip(ring, obj)) { |
|
- | 9596 | ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring, |
|
- | 9597 | page_flip_flags); |
|
- | 9598 | if (ret) |
|
- | 9599 | goto cleanup_unpin; |
|
9544 | if (use_mmio_flip(ring, obj)) |
9600 | |
9545 | ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring, |
9601 | work->flip_queued_seqno = obj->last_write_seqno; |
9546 | page_flip_flags); |
9602 | work->flip_queued_ring = obj->ring; |
9547 | else |
9603 | } else { |
9548 | ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring, |
9604 | ret = dev_priv->display.queue_flip(dev, crtc, fb, obj, ring, |
Line -... | Line 9605... | ||
- | 9605 | page_flip_flags); |
|
- | 9606 | if (ret) |
|
- | 9607 | goto cleanup_unpin; |
|
- | 9608 | ||
- | 9609 | work->flip_queued_seqno = intel_ring_get_seqno(ring); |
|
- | 9610 | work->flip_queued_ring = ring; |
|
- | 9611 | } |
|
9549 | page_flip_flags); |
9612 | |
9550 | if (ret) |
9613 | work->flip_queued_vblank = drm_vblank_count(dev, intel_crtc->pipe); |
Line 9551... | Line 9614... | ||
9551 | goto cleanup_unpin; |
9614 | work->enable_stall_check = true; |
9552 | 9615 | ||
Line 9569... | Line 9632... | ||
9569 | drm_gem_object_unreference(&work->old_fb_obj->base); |
9632 | drm_gem_object_unreference(&work->old_fb_obj->base); |
9570 | drm_gem_object_unreference(&obj->base); |
9633 | drm_gem_object_unreference(&obj->base); |
9571 | mutex_unlock(&dev->struct_mutex); |
9634 | mutex_unlock(&dev->struct_mutex); |
Line 9572... | Line 9635... | ||
9572 | 9635 | ||
9573 | cleanup: |
9636 | cleanup: |
9574 | spin_lock_irqsave(&dev->event_lock, flags); |
9637 | spin_lock_irq(&dev->event_lock); |
9575 | intel_crtc->unpin_work = NULL; |
9638 | intel_crtc->unpin_work = NULL; |
Line 9576... | Line 9639... | ||
9576 | spin_unlock_irqrestore(&dev->event_lock, flags); |
9639 | spin_unlock_irq(&dev->event_lock); |
9577 | 9640 | ||
9578 | drm_crtc_vblank_put(crtc); |
9641 | drm_crtc_vblank_put(crtc); |
Line 9579... | Line 9642... | ||
9579 | free_work: |
9642 | free_work: |
9580 | kfree(work); |
9643 | kfree(work); |
9581 | 9644 | ||
9582 | if (ret == -EIO) { |
9645 | if (ret == -EIO) { |
9583 | out_hang: |
9646 | out_hang: |
- | 9647 | // intel_crtc_wait_for_pending_flips(crtc); |
|
9584 | intel_crtc_wait_for_pending_flips(crtc); |
9648 | ret = intel_pipe_set_base(crtc, crtc->x, crtc->y, fb); |
- | 9649 | if (ret == 0 && event) { |
|
- | 9650 | spin_lock_irq(&dev->event_lock); |
|
9585 | ret = intel_pipe_set_base(crtc, crtc->x, crtc->y, fb); |
9651 | drm_send_vblank_event(dev, pipe, event); |
9586 | if (ret == 0 && event) |
9652 | spin_unlock_irq(&dev->event_lock); |
9587 | drm_send_vblank_event(dev, pipe, event); |
9653 | } |
9588 | } |
9654 | } |
Line 9611... | Line 9677... | ||
9611 | base.head) { |
9677 | base.head) { |
9612 | connector->new_encoder = |
9678 | connector->new_encoder = |
9613 | to_intel_encoder(connector->base.encoder); |
9679 | to_intel_encoder(connector->base.encoder); |
9614 | } |
9680 | } |
Line 9615... | Line 9681... | ||
9615 | 9681 | ||
9616 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
9617 | base.head) { |
9682 | for_each_intel_encoder(dev, encoder) { |
9618 | encoder->new_crtc = |
9683 | encoder->new_crtc = |
9619 | to_intel_crtc(encoder->base.crtc); |
9684 | to_intel_crtc(encoder->base.crtc); |
Line 9620... | Line 9685... | ||
9620 | } |
9685 | } |
Line 9643... | Line 9708... | ||
9643 | list_for_each_entry(connector, &dev->mode_config.connector_list, |
9708 | list_for_each_entry(connector, &dev->mode_config.connector_list, |
9644 | base.head) { |
9709 | base.head) { |
9645 | connector->base.encoder = &connector->new_encoder->base; |
9710 | connector->base.encoder = &connector->new_encoder->base; |
9646 | } |
9711 | } |
Line 9647... | Line 9712... | ||
9647 | 9712 | ||
9648 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
9649 | base.head) { |
9713 | for_each_intel_encoder(dev, encoder) { |
9650 | encoder->base.crtc = &encoder->new_crtc->base; |
9714 | encoder->base.crtc = &encoder->new_crtc->base; |
Line 9651... | Line 9715... | ||
9651 | } |
9715 | } |
9652 | 9716 | ||
Line 9771... | Line 9835... | ||
9771 | DRM_DEBUG_KMS("dp: %i, gmch_m: %u, gmch_n: %u, link_m: %u, link_n: %u, tu: %u\n", |
9835 | DRM_DEBUG_KMS("dp: %i, gmch_m: %u, gmch_n: %u, link_m: %u, link_n: %u, tu: %u\n", |
9772 | pipe_config->has_dp_encoder, |
9836 | pipe_config->has_dp_encoder, |
9773 | pipe_config->dp_m_n.gmch_m, pipe_config->dp_m_n.gmch_n, |
9837 | pipe_config->dp_m_n.gmch_m, pipe_config->dp_m_n.gmch_n, |
9774 | pipe_config->dp_m_n.link_m, pipe_config->dp_m_n.link_n, |
9838 | pipe_config->dp_m_n.link_m, pipe_config->dp_m_n.link_n, |
9775 | pipe_config->dp_m_n.tu); |
9839 | pipe_config->dp_m_n.tu); |
- | 9840 | ||
- | 9841 | DRM_DEBUG_KMS("dp: %i, gmch_m2: %u, gmch_n2: %u, link_m2: %u, link_n2: %u, tu2: %u\n", |
|
- | 9842 | pipe_config->has_dp_encoder, |
|
- | 9843 | pipe_config->dp_m2_n2.gmch_m, |
|
- | 9844 | pipe_config->dp_m2_n2.gmch_n, |
|
- | 9845 | pipe_config->dp_m2_n2.link_m, |
|
- | 9846 | pipe_config->dp_m2_n2.link_n, |
|
- | 9847 | pipe_config->dp_m2_n2.tu); |
|
- | 9848 | ||
- | 9849 | DRM_DEBUG_KMS("audio: %i, infoframes: %i\n", |
|
- | 9850 | pipe_config->has_audio, |
|
- | 9851 | pipe_config->has_infoframe); |
|
- | 9852 | ||
9776 | DRM_DEBUG_KMS("requested mode:\n"); |
9853 | DRM_DEBUG_KMS("requested mode:\n"); |
9777 | drm_mode_debug_printmodeline(&pipe_config->requested_mode); |
9854 | drm_mode_debug_printmodeline(&pipe_config->requested_mode); |
9778 | DRM_DEBUG_KMS("adjusted mode:\n"); |
9855 | DRM_DEBUG_KMS("adjusted mode:\n"); |
9779 | drm_mode_debug_printmodeline(&pipe_config->adjusted_mode); |
9856 | drm_mode_debug_printmodeline(&pipe_config->adjusted_mode); |
9780 | intel_dump_crtc_timings(&pipe_config->adjusted_mode); |
9857 | intel_dump_crtc_timings(&pipe_config->adjusted_mode); |
Line 9805... | Line 9882... | ||
9805 | struct intel_encoder *encoder) |
9882 | struct intel_encoder *encoder) |
9806 | { |
9883 | { |
9807 | struct drm_device *dev = crtc->base.dev; |
9884 | struct drm_device *dev = crtc->base.dev; |
9808 | struct intel_encoder *source_encoder; |
9885 | struct intel_encoder *source_encoder; |
Line 9809... | Line 9886... | ||
9809 | 9886 | ||
9810 | list_for_each_entry(source_encoder, |
- | |
9811 | &dev->mode_config.encoder_list, base.head) { |
9887 | for_each_intel_encoder(dev, source_encoder) { |
9812 | if (source_encoder->new_crtc != crtc) |
9888 | if (source_encoder->new_crtc != crtc) |
Line 9813... | Line 9889... | ||
9813 | continue; |
9889 | continue; |
9814 | 9890 | ||
Line 9822... | Line 9898... | ||
9822 | static bool check_encoder_cloning(struct intel_crtc *crtc) |
9898 | static bool check_encoder_cloning(struct intel_crtc *crtc) |
9823 | { |
9899 | { |
9824 | struct drm_device *dev = crtc->base.dev; |
9900 | struct drm_device *dev = crtc->base.dev; |
9825 | struct intel_encoder *encoder; |
9901 | struct intel_encoder *encoder; |
Line 9826... | Line 9902... | ||
9826 | 9902 | ||
9827 | list_for_each_entry(encoder, |
- | |
9828 | &dev->mode_config.encoder_list, base.head) { |
9903 | for_each_intel_encoder(dev, encoder) { |
9829 | if (encoder->new_crtc != crtc) |
9904 | if (encoder->new_crtc != crtc) |
Line 9830... | Line 9905... | ||
9830 | continue; |
9905 | continue; |
9831 | 9906 | ||
9832 | if (!check_single_encoder_cloning(crtc, encoder)) |
9907 | if (!check_single_encoder_cloning(crtc, encoder)) |
Line 9833... | Line 9908... | ||
9833 | return false; |
9908 | return false; |
9834 | } |
9909 | } |
Line -... | Line 9910... | ||
- | 9910 | ||
- | 9911 | return true; |
|
- | 9912 | } |
|
- | 9913 | ||
- | 9914 | static bool check_digital_port_conflicts(struct drm_device *dev) |
|
- | 9915 | { |
|
- | 9916 | struct intel_connector *connector; |
|
- | 9917 | unsigned int used_ports = 0; |
|
- | 9918 | ||
- | 9919 | /* |
|
- | 9920 | * Walk the connector list instead of the encoder |
|
- | 9921 | * list to detect the problem on ddi platforms |
|
- | 9922 | * where there's just one encoder per digital port. |
|
- | 9923 | */ |
|
- | 9924 | list_for_each_entry(connector, |
|
- | 9925 | &dev->mode_config.connector_list, base.head) { |
|
- | 9926 | struct intel_encoder *encoder = connector->new_encoder; |
|
- | 9927 | ||
- | 9928 | if (!encoder) |
|
- | 9929 | continue; |
|
- | 9930 | ||
- | 9931 | WARN_ON(!encoder->new_crtc); |
|
- | 9932 | ||
- | 9933 | switch (encoder->type) { |
|
- | 9934 | unsigned int port_mask; |
|
- | 9935 | case INTEL_OUTPUT_UNKNOWN: |
|
- | 9936 | if (WARN_ON(!HAS_DDI(dev))) |
|
- | 9937 | break; |
|
- | 9938 | case INTEL_OUTPUT_DISPLAYPORT: |
|
- | 9939 | case INTEL_OUTPUT_HDMI: |
|
- | 9940 | case INTEL_OUTPUT_EDP: |
|
- | 9941 | port_mask = 1 << enc_to_dig_port(&encoder->base)->port; |
|
- | 9942 | ||
- | 9943 | /* the same port mustn't appear more than once */ |
|
- | 9944 | if (used_ports & port_mask) |
|
- | 9945 | return false; |
|
- | 9946 | ||
- | 9947 | used_ports |= port_mask; |
|
- | 9948 | default: |
|
- | 9949 | break; |
|
- | 9950 | } |
|
- | 9951 | } |
|
9835 | 9952 | ||
9836 | return true; |
9953 | return true; |
9837 | } |
9954 | } |
9838 | 9955 | ||
9839 | static struct intel_crtc_config * |
9956 | static struct intel_crtc_config * |
Line 9850... | Line 9967... | ||
9850 | if (!check_encoder_cloning(to_intel_crtc(crtc))) { |
9967 | if (!check_encoder_cloning(to_intel_crtc(crtc))) { |
9851 | DRM_DEBUG_KMS("rejecting invalid cloning configuration\n"); |
9968 | DRM_DEBUG_KMS("rejecting invalid cloning configuration\n"); |
9852 | return ERR_PTR(-EINVAL); |
9969 | return ERR_PTR(-EINVAL); |
9853 | } |
9970 | } |
Line -... | Line 9971... | ||
- | 9971 | ||
- | 9972 | if (!check_digital_port_conflicts(dev)) { |
|
- | 9973 | DRM_DEBUG_KMS("rejecting conflicting digital port configuration\n"); |
|
- | 9974 | return ERR_PTR(-EINVAL); |
|
- | 9975 | } |
|
9854 | 9976 | ||
9855 | pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL); |
9977 | pipe_config = kzalloc(sizeof(*pipe_config), GFP_KERNEL); |
9856 | if (!pipe_config) |
9978 | if (!pipe_config) |
Line 9857... | Line 9979... | ||
9857 | return ERR_PTR(-ENOMEM); |
9979 | return ERR_PTR(-ENOMEM); |
Line 9907... | Line 10029... | ||
9907 | 10029 | ||
9908 | /* Pass our mode to the connectors and the CRTC to give them a chance to |
10030 | /* Pass our mode to the connectors and the CRTC to give them a chance to |
9909 | * adjust it according to limitations or connector properties, and also |
10031 | * adjust it according to limitations or connector properties, and also |
9910 | * a chance to reject the mode entirely. |
10032 | * a chance to reject the mode entirely. |
9911 | */ |
10033 | */ |
9912 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
Line 9913... | Line 10034... | ||
9913 | base.head) { |
10034 | for_each_intel_encoder(dev, encoder) { |
9914 | 10035 | ||
Line 9915... | Line 10036... | ||
9915 | if (&encoder->new_crtc->base != crtc) |
10036 | if (&encoder->new_crtc->base != crtc) |
Line 9986... | Line 10107... | ||
9986 | if (connector->new_encoder) |
10107 | if (connector->new_encoder) |
9987 | *prepare_pipes |= |
10108 | *prepare_pipes |= |
9988 | 1 << connector->new_encoder->new_crtc->pipe; |
10109 | 1 << connector->new_encoder->new_crtc->pipe; |
9989 | } |
10110 | } |
Line 9990... | Line 10111... | ||
9990 | 10111 | ||
9991 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
9992 | base.head) { |
10112 | for_each_intel_encoder(dev, encoder) { |
9993 | if (encoder->base.crtc == &encoder->new_crtc->base) |
10113 | if (encoder->base.crtc == &encoder->new_crtc->base) |
Line 9994... | Line 10114... | ||
9994 | continue; |
10114 | continue; |
9995 | 10115 | ||
Line 10057... | Line 10177... | ||
10057 | } |
10177 | } |
Line 10058... | Line 10178... | ||
10058 | 10178 | ||
10059 | static void |
10179 | static void |
10060 | intel_modeset_update_state(struct drm_device *dev, unsigned prepare_pipes) |
10180 | intel_modeset_update_state(struct drm_device *dev, unsigned prepare_pipes) |
- | 10181 | { |
|
10061 | { |
10182 | struct drm_i915_private *dev_priv = dev->dev_private; |
10062 | struct intel_encoder *intel_encoder; |
10183 | struct intel_encoder *intel_encoder; |
10063 | struct intel_crtc *intel_crtc; |
10184 | struct intel_crtc *intel_crtc; |
Line 10064... | Line 10185... | ||
10064 | struct drm_connector *connector; |
10185 | struct drm_connector *connector; |
- | 10186 | ||
10065 | 10187 | intel_shared_dpll_commit(dev_priv); |
|
10066 | list_for_each_entry(intel_encoder, &dev->mode_config.encoder_list, |
10188 | |
10067 | base.head) { |
10189 | for_each_intel_encoder(dev, intel_encoder) { |
Line 10068... | Line 10190... | ||
10068 | if (!intel_encoder->base.crtc) |
10190 | if (!intel_encoder->base.crtc) |
Line 10151... | Line 10273... | ||
10151 | current_config->name, \ |
10273 | current_config->name, \ |
10152 | pipe_config->name); \ |
10274 | pipe_config->name); \ |
10153 | return false; \ |
10275 | return false; \ |
10154 | } |
10276 | } |
Line -... | Line 10277... | ||
- | 10277 | ||
- | 10278 | /* This is required for BDW+ where there is only one set of registers for |
|
- | 10279 | * switching between high and low RR. |
|
- | 10280 | * This macro can be used whenever a comparison has to be made between one |
|
- | 10281 | * hw state and multiple sw state variables. |
|
- | 10282 | */ |
|
- | 10283 | #define PIPE_CONF_CHECK_I_ALT(name, alt_name) \ |
|
- | 10284 | if ((current_config->name != pipe_config->name) && \ |
|
- | 10285 | (current_config->alt_name != pipe_config->name)) { \ |
|
- | 10286 | DRM_ERROR("mismatch in " #name " " \ |
|
- | 10287 | "(expected %i or %i, found %i)\n", \ |
|
- | 10288 | current_config->name, \ |
|
- | 10289 | current_config->alt_name, \ |
|
- | 10290 | pipe_config->name); \ |
|
- | 10291 | return false; \ |
|
- | 10292 | } |
|
10155 | 10293 | ||
10156 | #define PIPE_CONF_CHECK_FLAGS(name, mask) \ |
10294 | #define PIPE_CONF_CHECK_FLAGS(name, mask) \ |
10157 | if ((current_config->name ^ pipe_config->name) & (mask)) { \ |
10295 | if ((current_config->name ^ pipe_config->name) & (mask)) { \ |
10158 | DRM_ERROR("mismatch in " #name "(" #mask ") " \ |
10296 | DRM_ERROR("mismatch in " #name "(" #mask ") " \ |
10159 | "(expected %i, found %i)\n", \ |
10297 | "(expected %i, found %i)\n", \ |
Line 10183... | Line 10321... | ||
10183 | PIPE_CONF_CHECK_I(fdi_m_n.link_m); |
10321 | PIPE_CONF_CHECK_I(fdi_m_n.link_m); |
10184 | PIPE_CONF_CHECK_I(fdi_m_n.link_n); |
10322 | PIPE_CONF_CHECK_I(fdi_m_n.link_n); |
10185 | PIPE_CONF_CHECK_I(fdi_m_n.tu); |
10323 | PIPE_CONF_CHECK_I(fdi_m_n.tu); |
Line 10186... | Line 10324... | ||
10186 | 10324 | ||
- | 10325 | PIPE_CONF_CHECK_I(has_dp_encoder); |
|
- | 10326 | ||
10187 | PIPE_CONF_CHECK_I(has_dp_encoder); |
10327 | if (INTEL_INFO(dev)->gen < 8) { |
10188 | PIPE_CONF_CHECK_I(dp_m_n.gmch_m); |
10328 | PIPE_CONF_CHECK_I(dp_m_n.gmch_m); |
10189 | PIPE_CONF_CHECK_I(dp_m_n.gmch_n); |
10329 | PIPE_CONF_CHECK_I(dp_m_n.gmch_n); |
10190 | PIPE_CONF_CHECK_I(dp_m_n.link_m); |
10330 | PIPE_CONF_CHECK_I(dp_m_n.link_m); |
10191 | PIPE_CONF_CHECK_I(dp_m_n.link_n); |
10331 | PIPE_CONF_CHECK_I(dp_m_n.link_n); |
Line -... | Line 10332... | ||
- | 10332 | PIPE_CONF_CHECK_I(dp_m_n.tu); |
|
- | 10333 | ||
- | 10334 | if (current_config->has_drrs) { |
|
- | 10335 | PIPE_CONF_CHECK_I(dp_m2_n2.gmch_m); |
|
- | 10336 | PIPE_CONF_CHECK_I(dp_m2_n2.gmch_n); |
|
- | 10337 | PIPE_CONF_CHECK_I(dp_m2_n2.link_m); |
|
- | 10338 | PIPE_CONF_CHECK_I(dp_m2_n2.link_n); |
|
- | 10339 | PIPE_CONF_CHECK_I(dp_m2_n2.tu); |
|
- | 10340 | } |
|
- | 10341 | } else { |
|
- | 10342 | PIPE_CONF_CHECK_I_ALT(dp_m_n.gmch_m, dp_m2_n2.gmch_m); |
|
- | 10343 | PIPE_CONF_CHECK_I_ALT(dp_m_n.gmch_n, dp_m2_n2.gmch_n); |
|
- | 10344 | PIPE_CONF_CHECK_I_ALT(dp_m_n.link_m, dp_m2_n2.link_m); |
|
- | 10345 | PIPE_CONF_CHECK_I_ALT(dp_m_n.link_n, dp_m2_n2.link_n); |
|
- | 10346 | PIPE_CONF_CHECK_I_ALT(dp_m_n.tu, dp_m2_n2.tu); |
|
10192 | PIPE_CONF_CHECK_I(dp_m_n.tu); |
10347 | } |
10193 | 10348 | ||
10194 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hdisplay); |
10349 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hdisplay); |
10195 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_htotal); |
10350 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_htotal); |
10196 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_start); |
10351 | PIPE_CONF_CHECK_I(adjusted_mode.crtc_hblank_start); |
Line 10208... | Line 10363... | ||
10208 | PIPE_CONF_CHECK_I(pixel_multiplier); |
10363 | PIPE_CONF_CHECK_I(pixel_multiplier); |
10209 | PIPE_CONF_CHECK_I(has_hdmi_sink); |
10364 | PIPE_CONF_CHECK_I(has_hdmi_sink); |
10210 | if ((INTEL_INFO(dev)->gen < 8 && !IS_HASWELL(dev)) || |
10365 | if ((INTEL_INFO(dev)->gen < 8 && !IS_HASWELL(dev)) || |
10211 | IS_VALLEYVIEW(dev)) |
10366 | IS_VALLEYVIEW(dev)) |
10212 | PIPE_CONF_CHECK_I(limited_color_range); |
10367 | PIPE_CONF_CHECK_I(limited_color_range); |
- | 10368 | PIPE_CONF_CHECK_I(has_infoframe); |
|
Line 10213... | Line 10369... | ||
10213 | 10369 | ||
Line 10214... | Line 10370... | ||
10214 | PIPE_CONF_CHECK_I(has_audio); |
10370 | PIPE_CONF_CHECK_I(has_audio); |
10215 | 10371 | ||
Line 10264... | Line 10420... | ||
10264 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll); |
10420 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll); |
10265 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md); |
10421 | PIPE_CONF_CHECK_X(dpll_hw_state.dpll_md); |
10266 | PIPE_CONF_CHECK_X(dpll_hw_state.fp0); |
10422 | PIPE_CONF_CHECK_X(dpll_hw_state.fp0); |
10267 | PIPE_CONF_CHECK_X(dpll_hw_state.fp1); |
10423 | PIPE_CONF_CHECK_X(dpll_hw_state.fp1); |
10268 | PIPE_CONF_CHECK_X(dpll_hw_state.wrpll); |
10424 | PIPE_CONF_CHECK_X(dpll_hw_state.wrpll); |
- | 10425 | PIPE_CONF_CHECK_X(dpll_hw_state.ctrl1); |
|
- | 10426 | PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr1); |
|
- | 10427 | PIPE_CONF_CHECK_X(dpll_hw_state.cfgcr2); |
|
Line 10269... | Line 10428... | ||
10269 | 10428 | ||
10270 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) |
10429 | if (IS_G4X(dev) || INTEL_INFO(dev)->gen >= 5) |
Line 10271... | Line 10430... | ||
10271 | PIPE_CONF_CHECK_I(pipe_bpp); |
10430 | PIPE_CONF_CHECK_I(pipe_bpp); |
10272 | 10431 | ||
Line 10273... | Line 10432... | ||
10273 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); |
10432 | PIPE_CONF_CHECK_CLOCK_FUZZY(adjusted_mode.crtc_clock); |
10274 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); |
10433 | PIPE_CONF_CHECK_CLOCK_FUZZY(port_clock); |
- | 10434 | ||
10275 | 10435 | #undef PIPE_CONF_CHECK_X |
|
10276 | #undef PIPE_CONF_CHECK_X |
10436 | #undef PIPE_CONF_CHECK_I |
10277 | #undef PIPE_CONF_CHECK_I |
10437 | #undef PIPE_CONF_CHECK_I_ALT |
Line 10278... | Line 10438... | ||
10278 | #undef PIPE_CONF_CHECK_FLAGS |
10438 | #undef PIPE_CONF_CHECK_FLAGS |
10279 | #undef PIPE_CONF_CHECK_CLOCK_FUZZY |
10439 | #undef PIPE_CONF_CHECK_CLOCK_FUZZY |
Line -... | Line 10440... | ||
- | 10440 | #undef PIPE_CONF_QUIRK |
|
- | 10441 | ||
- | 10442 | return true; |
|
- | 10443 | } |
|
- | 10444 | ||
- | 10445 | static void check_wm_state(struct drm_device *dev) |
|
- | 10446 | { |
|
- | 10447 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 10448 | struct skl_ddb_allocation hw_ddb, *sw_ddb; |
|
- | 10449 | struct intel_crtc *intel_crtc; |
|
- | 10450 | int plane; |
|
- | 10451 | ||
- | 10452 | if (INTEL_INFO(dev)->gen < 9) |
|
- | 10453 | return; |
|
- | 10454 | ||
- | 10455 | skl_ddb_get_hw_state(dev_priv, &hw_ddb); |
|
- | 10456 | sw_ddb = &dev_priv->wm.skl_hw.ddb; |
|
- | 10457 | ||
- | 10458 | for_each_intel_crtc(dev, intel_crtc) { |
|
- | 10459 | struct skl_ddb_entry *hw_entry, *sw_entry; |
|
- | 10460 | const enum pipe pipe = intel_crtc->pipe; |
|
- | 10461 | ||
- | 10462 | if (!intel_crtc->active) |
|
- | 10463 | continue; |
|
- | 10464 | ||
- | 10465 | /* planes */ |
|
- | 10466 | for_each_plane(pipe, plane) { |
|
- | 10467 | hw_entry = &hw_ddb.plane[pipe][plane]; |
|
- | 10468 | sw_entry = &sw_ddb->plane[pipe][plane]; |
|
- | 10469 | ||
- | 10470 | if (skl_ddb_entry_equal(hw_entry, sw_entry)) |
|
- | 10471 | continue; |
|
- | 10472 | ||
- | 10473 | DRM_ERROR("mismatch in DDB state pipe %c plane %d " |
|
- | 10474 | "(expected (%u,%u), found (%u,%u))\n", |
|
- | 10475 | pipe_name(pipe), plane + 1, |
|
- | 10476 | sw_entry->start, sw_entry->end, |
|
- | 10477 | hw_entry->start, hw_entry->end); |
|
- | 10478 | } |
|
- | 10479 | ||
- | 10480 | /* cursor */ |
|
- | 10481 | hw_entry = &hw_ddb.cursor[pipe]; |
|
- | 10482 | sw_entry = &sw_ddb->cursor[pipe]; |
|
- | 10483 | ||
- | 10484 | if (skl_ddb_entry_equal(hw_entry, sw_entry)) |
|
- | 10485 | continue; |
|
- | 10486 | ||
- | 10487 | DRM_ERROR("mismatch in DDB state pipe %c cursor " |
|
- | 10488 | "(expected (%u,%u), found (%u,%u))\n", |
|
- | 10489 | pipe_name(pipe), |
|
10280 | #undef PIPE_CONF_QUIRK |
10490 | sw_entry->start, sw_entry->end, |
10281 | 10491 | hw_entry->start, hw_entry->end); |
|
10282 | return true; |
10492 | } |
10283 | } |
10493 | } |
Line 10302... | Line 10512... | ||
10302 | check_encoder_state(struct drm_device *dev) |
10512 | check_encoder_state(struct drm_device *dev) |
10303 | { |
10513 | { |
10304 | struct intel_encoder *encoder; |
10514 | struct intel_encoder *encoder; |
10305 | struct intel_connector *connector; |
10515 | struct intel_connector *connector; |
Line 10306... | Line 10516... | ||
10306 | 10516 | ||
10307 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
10308 | base.head) { |
10517 | for_each_intel_encoder(dev, encoder) { |
10309 | bool enabled = false; |
10518 | bool enabled = false; |
10310 | bool active = false; |
10519 | bool active = false; |
Line 10311... | Line 10520... | ||
10311 | enum pipe pipe, tracked_pipe; |
10520 | enum pipe pipe, tracked_pipe; |
Line 10382... | Line 10591... | ||
10382 | crtc->base.base.id); |
10591 | crtc->base.base.id); |
Line 10383... | Line 10592... | ||
10383 | 10592 | ||
10384 | WARN(crtc->active && !crtc->base.enabled, |
10593 | WARN(crtc->active && !crtc->base.enabled, |
Line 10385... | Line 10594... | ||
10385 | "active crtc, but not enabled in sw tracking\n"); |
10594 | "active crtc, but not enabled in sw tracking\n"); |
10386 | - | ||
10387 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
10595 | |
10388 | base.head) { |
10596 | for_each_intel_encoder(dev, encoder) { |
10389 | if (encoder->base.crtc != &crtc->base) |
10597 | if (encoder->base.crtc != &crtc->base) |
10390 | continue; |
10598 | continue; |
10391 | enabled = true; |
10599 | enabled = true; |
Line 10401... | Line 10609... | ||
10401 | "(expected %i, found %i)\n", enabled, crtc->base.enabled); |
10609 | "(expected %i, found %i)\n", enabled, crtc->base.enabled); |
Line 10402... | Line 10610... | ||
10402 | 10610 | ||
10403 | active = dev_priv->display.get_pipe_config(crtc, |
10611 | active = dev_priv->display.get_pipe_config(crtc, |
Line 10404... | Line 10612... | ||
10404 | &pipe_config); |
10612 | &pipe_config); |
10405 | 10613 | ||
- | 10614 | /* hw state is inconsistent with the pipe quirk */ |
|
10406 | /* hw state is inconsistent with the pipe A quirk */ |
10615 | if ((crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) || |
Line 10407... | Line 10616... | ||
10407 | if (crtc->pipe == PIPE_A && dev_priv->quirks & QUIRK_PIPEA_FORCE) |
10616 | (crtc->pipe == PIPE_B && dev_priv->quirks & QUIRK_PIPEB_FORCE)) |
10408 | active = crtc->active; |
- | |
10409 | 10617 | active = crtc->active; |
|
10410 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
10618 | |
10411 | base.head) { |
10619 | for_each_intel_encoder(dev, encoder) { |
10412 | enum pipe pipe; |
10620 | enum pipe pipe; |
10413 | if (encoder->base.crtc != &crtc->base) |
10621 | if (encoder->base.crtc != &crtc->base) |
Line 10448... | Line 10656... | ||
10448 | 10656 | ||
Line 10449... | Line 10657... | ||
10449 | DRM_DEBUG_KMS("%s\n", pll->name); |
10657 | DRM_DEBUG_KMS("%s\n", pll->name); |
Line 10450... | Line 10658... | ||
10450 | 10658 | ||
10451 | active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state); |
10659 | active = pll->get_hw_state(dev_priv, pll, &dpll_hw_state); |
10452 | 10660 | ||
10453 | WARN(pll->active > pll->refcount, |
10661 | WARN(pll->active > hweight32(pll->config.crtc_mask), |
10454 | "more active pll users than references: %i vs %i\n", |
10662 | "more active pll users than references: %i vs %i\n", |
10455 | pll->active, pll->refcount); |
10663 | pll->active, hweight32(pll->config.crtc_mask)); |
10456 | WARN(pll->active && !pll->on, |
10664 | WARN(pll->active && !pll->on, |
10457 | "pll in active use but not on in sw tracking\n"); |
10665 | "pll in active use but not on in sw tracking\n"); |
Line 10468... | Line 10676... | ||
10468 | active_crtcs++; |
10676 | active_crtcs++; |
10469 | } |
10677 | } |
10470 | WARN(pll->active != active_crtcs, |
10678 | WARN(pll->active != active_crtcs, |
10471 | "pll active crtcs mismatch (expected %i, found %i)\n", |
10679 | "pll active crtcs mismatch (expected %i, found %i)\n", |
10472 | pll->active, active_crtcs); |
10680 | pll->active, active_crtcs); |
10473 | WARN(pll->refcount != enabled_crtcs, |
10681 | WARN(hweight32(pll->config.crtc_mask) != enabled_crtcs, |
10474 | "pll enabled crtcs mismatch (expected %i, found %i)\n", |
10682 | "pll enabled crtcs mismatch (expected %i, found %i)\n", |
10475 | pll->refcount, enabled_crtcs); |
10683 | hweight32(pll->config.crtc_mask), enabled_crtcs); |
Line 10476... | Line 10684... | ||
10476 | 10684 | ||
10477 | WARN(pll->on && memcmp(&pll->hw_state, &dpll_hw_state, |
10685 | WARN(pll->on && memcmp(&pll->config.hw_state, &dpll_hw_state, |
10478 | sizeof(dpll_hw_state)), |
10686 | sizeof(dpll_hw_state)), |
10479 | "pll hw state mismatch\n"); |
10687 | "pll hw state mismatch\n"); |
10480 | } |
10688 | } |
Line 10481... | Line 10689... | ||
10481 | } |
10689 | } |
10482 | 10690 | ||
10483 | void |
10691 | void |
- | 10692 | intel_modeset_check_state(struct drm_device *dev) |
|
10484 | intel_modeset_check_state(struct drm_device *dev) |
10693 | { |
10485 | { |
10694 | check_wm_state(dev); |
10486 | check_connector_state(dev); |
10695 | check_connector_state(dev); |
10487 | check_encoder_state(dev); |
10696 | check_encoder_state(dev); |
10488 | check_crtc_state(dev); |
10697 | check_crtc_state(dev); |
Line 10531... | Line 10740... | ||
10531 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
10740 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
10532 | vtotal /= 2; |
10741 | vtotal /= 2; |
Line 10533... | Line 10742... | ||
10533 | 10742 | ||
10534 | crtc->scanline_offset = vtotal - 1; |
10743 | crtc->scanline_offset = vtotal - 1; |
10535 | } else if (HAS_DDI(dev) && |
10744 | } else if (HAS_DDI(dev) && |
10536 | intel_pipe_has_type(&crtc->base, INTEL_OUTPUT_HDMI)) { |
10745 | intel_pipe_has_type(crtc, INTEL_OUTPUT_HDMI)) { |
10537 | crtc->scanline_offset = 2; |
10746 | crtc->scanline_offset = 2; |
10538 | } else |
10747 | } else |
10539 | crtc->scanline_offset = 1; |
10748 | crtc->scanline_offset = 1; |
Line -... | Line 10749... | ||
- | 10749 | } |
|
- | 10750 | ||
- | 10751 | static struct intel_crtc_config * |
|
- | 10752 | intel_modeset_compute_config(struct drm_crtc *crtc, |
|
- | 10753 | struct drm_display_mode *mode, |
|
- | 10754 | struct drm_framebuffer *fb, |
|
- | 10755 | unsigned *modeset_pipes, |
|
- | 10756 | unsigned *prepare_pipes, |
|
- | 10757 | unsigned *disable_pipes) |
|
- | 10758 | { |
|
- | 10759 | struct intel_crtc_config *pipe_config = NULL; |
|
- | 10760 | ||
- | 10761 | intel_modeset_affected_pipes(crtc, modeset_pipes, |
|
- | 10762 | prepare_pipes, disable_pipes); |
|
- | 10763 | ||
- | 10764 | if ((*modeset_pipes) == 0) |
|
- | 10765 | goto out; |
|
- | 10766 | ||
- | 10767 | /* |
|
- | 10768 | * Note this needs changes when we start tracking multiple modes |
|
- | 10769 | * and crtcs. At that point we'll need to compute the whole config |
|
- | 10770 | * (i.e. one pipe_config for each crtc) rather than just the one |
|
- | 10771 | * for this crtc. |
|
- | 10772 | */ |
|
- | 10773 | pipe_config = intel_modeset_pipe_config(crtc, fb, mode); |
|
- | 10774 | if (IS_ERR(pipe_config)) { |
|
- | 10775 | goto out; |
|
- | 10776 | } |
|
- | 10777 | intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config, |
|
- | 10778 | "[modeset]"); |
|
- | 10779 | ||
- | 10780 | out: |
|
- | 10781 | return pipe_config; |
|
10540 | } |
10782 | } |
10541 | 10783 | ||
10542 | static int __intel_set_mode(struct drm_crtc *crtc, |
10784 | static int __intel_set_mode(struct drm_crtc *crtc, |
- | 10785 | struct drm_display_mode *mode, |
|
- | 10786 | int x, int y, struct drm_framebuffer *fb, |
|
- | 10787 | struct intel_crtc_config *pipe_config, |
|
- | 10788 | unsigned modeset_pipes, |
|
10543 | struct drm_display_mode *mode, |
10789 | unsigned prepare_pipes, |
10544 | int x, int y, struct drm_framebuffer *fb) |
10790 | unsigned disable_pipes) |
10545 | { |
10791 | { |
10546 | struct drm_device *dev = crtc->dev; |
10792 | struct drm_device *dev = crtc->dev; |
10547 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
10548 | struct drm_display_mode *saved_mode; |
10793 | struct drm_i915_private *dev_priv = dev->dev_private; |
10549 | struct intel_crtc_config *pipe_config = NULL; |
- | |
10550 | struct intel_crtc *intel_crtc; |
10794 | struct drm_display_mode *saved_mode; |
Line 10551... | Line 10795... | ||
10551 | unsigned disable_pipes, prepare_pipes, modeset_pipes; |
10795 | struct intel_crtc *intel_crtc; |
10552 | int ret = 0; |
10796 | int ret = 0; |
10553 | 10797 | ||
Line 10554... | Line -... | ||
10554 | saved_mode = kmalloc(sizeof(*saved_mode), GFP_KERNEL); |
- | |
10555 | if (!saved_mode) |
- | |
10556 | return -ENOMEM; |
- | |
10557 | 10798 | saved_mode = kmalloc(sizeof(*saved_mode), GFP_KERNEL); |
|
Line 10558... | Line -... | ||
10558 | intel_modeset_affected_pipes(crtc, &modeset_pipes, |
- | |
10559 | &prepare_pipes, &disable_pipes); |
- | |
10560 | - | ||
10561 | *saved_mode = crtc->mode; |
- | |
10562 | - | ||
10563 | /* Hack: Because we don't (yet) support global modeset on multiple |
10799 | if (!saved_mode) |
10564 | * crtcs, we don't keep track of the new mode for more than one crtc. |
- | |
10565 | * Hence simply check whether any bit is set in modeset_pipes in all the |
- | |
10566 | * pieces of code that are not yet converted to deal with mutliple crtcs |
- | |
10567 | * changing their mode at the same time. */ |
- | |
10568 | if (modeset_pipes) { |
- | |
10569 | pipe_config = intel_modeset_pipe_config(crtc, fb, mode); |
- | |
10570 | if (IS_ERR(pipe_config)) { |
- | |
10571 | ret = PTR_ERR(pipe_config); |
- | |
10572 | pipe_config = NULL; |
- | |
10573 | 10800 | return -ENOMEM; |
|
10574 | goto out; |
- | |
Line 10575... | Line 10801... | ||
10575 | } |
10801 | |
10576 | intel_dump_pipe_config(to_intel_crtc(crtc), pipe_config, |
10802 | *saved_mode = crtc->mode; |
10577 | "[modeset]"); |
10803 | |
10578 | to_intel_crtc(crtc)->new_config = pipe_config; |
10804 | if (modeset_pipes) |
Line 10590... | Line 10816... | ||
10590 | 10816 | ||
10591 | /* may have added more to prepare_pipes than we should */ |
10817 | /* may have added more to prepare_pipes than we should */ |
10592 | prepare_pipes &= ~disable_pipes; |
10818 | prepare_pipes &= ~disable_pipes; |
Line -... | Line 10819... | ||
- | 10819 | } |
|
- | 10820 | ||
- | 10821 | if (dev_priv->display.crtc_compute_clock) { |
|
- | 10822 | unsigned clear_pipes = modeset_pipes | disable_pipes; |
|
- | 10823 | ||
- | 10824 | ret = intel_shared_dpll_start_config(dev_priv, clear_pipes); |
|
- | 10825 | if (ret) |
|
- | 10826 | goto done; |
|
- | 10827 | ||
- | 10828 | for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { |
|
- | 10829 | ret = dev_priv->display.crtc_compute_clock(intel_crtc); |
|
- | 10830 | if (ret) { |
|
- | 10831 | intel_shared_dpll_abort_config(dev_priv); |
|
- | 10832 | goto done; |
|
- | 10833 | } |
|
- | 10834 | } |
|
10593 | } |
10835 | } |
10594 | 10836 | ||
Line 10595... | Line 10837... | ||
10595 | for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc) |
10837 | for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc) |
10596 | intel_crtc_disable(&intel_crtc->base); |
10838 | intel_crtc_disable(&intel_crtc->base); |
10597 | 10839 | ||
10598 | for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc) { |
10840 | for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc) { |
Line 10599... | Line 10841... | ||
10599 | if (intel_crtc->base.enabled) |
10841 | if (intel_crtc->base.enabled) |
10600 | dev_priv->display.crtc_disable(&intel_crtc->base); |
10842 | dev_priv->display.crtc_disable(&intel_crtc->base); |
- | 10843 | } |
|
- | 10844 | ||
- | 10845 | /* crtc->mode is already used by the ->mode_set callbacks, hence we need |
|
- | 10846 | * to set it here already despite that we pass it down the callchain. |
|
10601 | } |
10847 | * |
10602 | 10848 | * Note we'll need to fix this up when we start tracking multiple |
|
10603 | /* crtc->mode is already used by the ->mode_set callbacks, hence we need |
10849 | * pipes; here we assume a single modeset_pipe and only track the |
10604 | * to set it here already despite that we pass it down the callchain. |
10850 | * single crtc and mode. |
10605 | */ |
10851 | */ |
Line 10621... | Line 10867... | ||
10621 | 10867 | ||
10622 | /* Only after disabling all output pipelines that will be changed can we |
10868 | /* Only after disabling all output pipelines that will be changed can we |
10623 | * update the the output configuration. */ |
10869 | * update the the output configuration. */ |
Line 10624... | Line -... | ||
10624 | intel_modeset_update_state(dev, prepare_pipes); |
- | |
10625 | 10870 | intel_modeset_update_state(dev, prepare_pipes); |
|
Line 10626... | Line 10871... | ||
10626 | if (dev_priv->display.modeset_global_resources) |
10871 | |
10627 | dev_priv->display.modeset_global_resources(dev); |
10872 | modeset_update_crtc_power_domains(dev); |
10628 | 10873 | ||
10629 | /* Set up the DPLL and any encoders state that needs to adjust or depend |
10874 | /* Set up the DPLL and any encoders state that needs to adjust or depend |
10630 | * on the DPLL. |
10875 | * on the DPLL. |
10631 | */ |
10876 | */ |
10632 | for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { |
10877 | for_each_intel_crtc_masked(dev, modeset_pipes, intel_crtc) { |
Line 10633... | Line 10878... | ||
10633 | struct drm_framebuffer *old_fb = crtc->primary->fb; |
10878 | struct drm_framebuffer *old_fb = crtc->primary->fb; |
10634 | struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb); |
10879 | struct drm_i915_gem_object *old_obj = intel_fb_obj(old_fb); |
10635 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
- | |
10636 | - | ||
10637 | mutex_lock(&dev->struct_mutex); |
10880 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
10638 | ret = intel_pin_and_fence_fb_obj(dev, |
10881 | |
10639 | obj, |
10882 | mutex_lock(&dev->struct_mutex); |
10640 | NULL); |
10883 | ret = intel_pin_and_fence_fb_obj(crtc->primary, fb, NULL); |
10641 | if (ret != 0) { |
10884 | if (ret != 0) { |
Line 10650... | Line 10893... | ||
10650 | mutex_unlock(&dev->struct_mutex); |
10893 | mutex_unlock(&dev->struct_mutex); |
Line 10651... | Line 10894... | ||
10651 | 10894 | ||
10652 | crtc->primary->fb = fb; |
10895 | crtc->primary->fb = fb; |
10653 | crtc->x = x; |
10896 | crtc->x = x; |
10654 | crtc->y = y; |
- | |
10655 | - | ||
10656 | ret = dev_priv->display.crtc_mode_set(&intel_crtc->base, |
- | |
10657 | x, y, fb); |
- | |
10658 | if (ret) |
- | |
10659 | goto done; |
10897 | crtc->y = y; |
Line 10660... | Line 10898... | ||
10660 | } |
10898 | } |
10661 | 10899 | ||
10662 | /* Now enable the clocks, plane, pipe, and connectors that we set up. */ |
10900 | /* Now enable the clocks, plane, pipe, and connectors that we set up. */ |
Line 10669... | Line 10907... | ||
10669 | /* FIXME: add subpixel order */ |
10907 | /* FIXME: add subpixel order */ |
10670 | done: |
10908 | done: |
10671 | if (ret && crtc->enabled) |
10909 | if (ret && crtc->enabled) |
10672 | crtc->mode = *saved_mode; |
10910 | crtc->mode = *saved_mode; |
Line 10673... | Line -... | ||
10673 | - | ||
10674 | out: |
10911 | |
10675 | kfree(pipe_config); |
10912 | kfree(pipe_config); |
10676 | kfree(saved_mode); |
10913 | kfree(saved_mode); |
10677 | return ret; |
10914 | return ret; |
Line 10678... | Line 10915... | ||
10678 | } |
10915 | } |
10679 | 10916 | ||
10680 | static int intel_set_mode(struct drm_crtc *crtc, |
10917 | static int intel_set_mode_pipes(struct drm_crtc *crtc, |
- | 10918 | struct drm_display_mode *mode, |
|
- | 10919 | int x, int y, struct drm_framebuffer *fb, |
|
- | 10920 | struct intel_crtc_config *pipe_config, |
|
- | 10921 | unsigned modeset_pipes, |
|
10681 | struct drm_display_mode *mode, |
10922 | unsigned prepare_pipes, |
10682 | int x, int y, struct drm_framebuffer *fb) |
10923 | unsigned disable_pipes) |
Line 10683... | Line 10924... | ||
10683 | { |
10924 | { |
- | 10925 | int ret; |
|
Line 10684... | Line 10926... | ||
10684 | int ret; |
10926 | |
10685 | 10927 | ret = __intel_set_mode(crtc, mode, x, y, fb, pipe_config, modeset_pipes, |
|
Line 10686... | Line 10928... | ||
10686 | ret = __intel_set_mode(crtc, mode, x, y, fb); |
10928 | prepare_pipes, disable_pipes); |
10687 | 10929 | ||
Line -... | Line 10930... | ||
- | 10930 | if (ret == 0) |
|
- | 10931 | intel_modeset_check_state(crtc->dev); |
|
- | 10932 | ||
- | 10933 | return ret; |
|
- | 10934 | } |
|
- | 10935 | ||
- | 10936 | static int intel_set_mode(struct drm_crtc *crtc, |
|
- | 10937 | struct drm_display_mode *mode, |
|
- | 10938 | int x, int y, struct drm_framebuffer *fb) |
|
- | 10939 | { |
|
- | 10940 | struct intel_crtc_config *pipe_config; |
|
- | 10941 | unsigned modeset_pipes, prepare_pipes, disable_pipes; |
|
- | 10942 | ||
- | 10943 | pipe_config = intel_modeset_compute_config(crtc, mode, fb, |
|
- | 10944 | &modeset_pipes, |
|
- | 10945 | &prepare_pipes, |
|
- | 10946 | &disable_pipes); |
|
- | 10947 | ||
- | 10948 | if (IS_ERR(pipe_config)) |
|
- | 10949 | return PTR_ERR(pipe_config); |
|
10688 | if (ret == 0) |
10950 | |
10689 | intel_modeset_check_state(crtc->dev); |
10951 | return intel_set_mode_pipes(crtc, mode, x, y, fb, pipe_config, |
10690 | 10952 | modeset_pipes, prepare_pipes, |
|
10691 | return ret; |
10953 | disable_pipes); |
Line 10774... | Line 11036... | ||
10774 | else |
11036 | else |
10775 | crtc->new_config = NULL; |
11037 | crtc->new_config = NULL; |
10776 | } |
11038 | } |
Line 10777... | Line 11039... | ||
10777 | 11039 | ||
10778 | count = 0; |
11040 | count = 0; |
10779 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { |
11041 | for_each_intel_encoder(dev, encoder) { |
10780 | encoder->new_crtc = |
11042 | encoder->new_crtc = |
10781 | to_intel_crtc(config->save_encoder_crtcs[count++]); |
11043 | to_intel_crtc(config->save_encoder_crtcs[count++]); |
Line 10782... | Line 11044... | ||
10782 | } |
11044 | } |
Line 10933... | Line 11195... | ||
10933 | connector->base.name, |
11195 | connector->base.name, |
10934 | new_crtc->base.id); |
11196 | new_crtc->base.id); |
10935 | } |
11197 | } |
Line 10936... | Line 11198... | ||
10936 | 11198 | ||
10937 | /* Check for any encoders that needs to be disabled. */ |
11199 | /* Check for any encoders that needs to be disabled. */ |
10938 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
10939 | base.head) { |
11200 | for_each_intel_encoder(dev, encoder) { |
10940 | int num_connectors = 0; |
11201 | int num_connectors = 0; |
10941 | list_for_each_entry(connector, |
11202 | list_for_each_entry(connector, |
10942 | &dev->mode_config.connector_list, |
11203 | &dev->mode_config.connector_list, |
10943 | base.head) { |
11204 | base.head) { |
Line 10967... | Line 11228... | ||
10967 | connector->encoder = connector->new_encoder; |
11228 | connector->encoder = connector->new_encoder; |
10968 | } |
11229 | } |
10969 | for_each_intel_crtc(dev, crtc) { |
11230 | for_each_intel_crtc(dev, crtc) { |
10970 | crtc->new_enabled = false; |
11231 | crtc->new_enabled = false; |
Line 10971... | Line 11232... | ||
10971 | 11232 | ||
10972 | list_for_each_entry(encoder, |
- | |
10973 | &dev->mode_config.encoder_list, |
- | |
10974 | base.head) { |
11233 | for_each_intel_encoder(dev, encoder) { |
10975 | if (encoder->new_crtc == crtc) { |
11234 | if (encoder->new_crtc == crtc) { |
10976 | crtc->new_enabled = true; |
11235 | crtc->new_enabled = true; |
10977 | break; |
11236 | break; |
10978 | } |
11237 | } |
Line 11006... | Line 11265... | ||
11006 | if (connector->new_encoder && |
11265 | if (connector->new_encoder && |
11007 | connector->new_encoder->new_crtc == crtc) |
11266 | connector->new_encoder->new_crtc == crtc) |
11008 | connector->new_encoder = NULL; |
11267 | connector->new_encoder = NULL; |
11009 | } |
11268 | } |
Line 11010... | Line 11269... | ||
11010 | 11269 | ||
11011 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { |
11270 | for_each_intel_encoder(dev, encoder) { |
11012 | if (encoder->new_crtc == crtc) |
11271 | if (encoder->new_crtc == crtc) |
11013 | encoder->new_crtc = NULL; |
11272 | encoder->new_crtc = NULL; |
Line 11014... | Line 11273... | ||
11014 | } |
11273 | } |
Line 11020... | Line 11279... | ||
11020 | static int intel_crtc_set_config(struct drm_mode_set *set) |
11279 | static int intel_crtc_set_config(struct drm_mode_set *set) |
11021 | { |
11280 | { |
11022 | struct drm_device *dev; |
11281 | struct drm_device *dev; |
11023 | struct drm_mode_set save_set; |
11282 | struct drm_mode_set save_set; |
11024 | struct intel_set_config *config; |
11283 | struct intel_set_config *config; |
- | 11284 | struct intel_crtc_config *pipe_config; |
|
- | 11285 | unsigned modeset_pipes, prepare_pipes, disable_pipes; |
|
11025 | int ret; |
11286 | int ret; |
Line 11026... | Line 11287... | ||
11026 | 11287 | ||
11027 | BUG_ON(!set); |
11288 | BUG_ON(!set); |
11028 | BUG_ON(!set->crtc); |
11289 | BUG_ON(!set->crtc); |
Line 11065... | Line 11326... | ||
11065 | 11326 | ||
11066 | ret = intel_modeset_stage_output_state(dev, set, config); |
11327 | ret = intel_modeset_stage_output_state(dev, set, config); |
11067 | if (ret) |
11328 | if (ret) |
Line -... | Line 11329... | ||
- | 11329 | goto fail; |
|
- | 11330 | ||
- | 11331 | pipe_config = intel_modeset_compute_config(set->crtc, set->mode, |
|
- | 11332 | set->fb, |
|
- | 11333 | &modeset_pipes, |
|
- | 11334 | &prepare_pipes, |
|
- | 11335 | &disable_pipes); |
|
- | 11336 | if (IS_ERR(pipe_config)) { |
|
- | 11337 | ret = PTR_ERR(pipe_config); |
|
- | 11338 | goto fail; |
|
- | 11339 | } else if (pipe_config) { |
|
- | 11340 | if (pipe_config->has_audio != |
|
- | 11341 | to_intel_crtc(set->crtc)->config.has_audio) |
|
- | 11342 | config->mode_changed = true; |
|
- | 11343 | ||
- | 11344 | /* |
|
- | 11345 | * Note we have an issue here with infoframes: current code |
|
- | 11346 | * only updates them on the full mode set path per hw |
|
- | 11347 | * requirements. So here we should be checking for any |
|
- | 11348 | * required changes and forcing a mode set. |
|
- | 11349 | */ |
|
- | 11350 | } |
|
- | 11351 | ||
- | 11352 | /* set_mode will free it in the mode_changed case */ |
|
- | 11353 | if (!config->mode_changed) |
|
- | 11354 | kfree(pipe_config); |
|
- | 11355 | ||
11068 | goto fail; |
11356 | intel_update_pipe_size(to_intel_crtc(set->crtc)); |
11069 | 11357 | ||
11070 | if (config->mode_changed) { |
11358 | if (config->mode_changed) { |
- | 11359 | ret = intel_set_mode_pipes(set->crtc, set->mode, |
|
- | 11360 | set->x, set->y, set->fb, pipe_config, |
|
11071 | ret = intel_set_mode(set->crtc, set->mode, |
11361 | modeset_pipes, prepare_pipes, |
11072 | set->x, set->y, set->fb); |
- | |
11073 | } else if (config->fb_changed) { |
11362 | disable_pipes); |
Line -... | Line 11363... | ||
- | 11363 | } else if (config->fb_changed) { |
|
Line 11074... | Line 11364... | ||
11074 | struct drm_i915_private *dev_priv = dev->dev_private; |
11364 | struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc); |
11075 | struct intel_crtc *intel_crtc = to_intel_crtc(set->crtc); |
11365 | |
Line 11076... | Line 11366... | ||
11076 | 11366 | // intel_crtc_wait_for_pending_flips(set->crtc); |
|
11077 | 11367 | ||
11078 | ret = intel_pipe_set_base(set->crtc, |
11368 | ret = intel_pipe_set_base(set->crtc, |
11079 | set->x, set->y, set->fb); |
11369 | set->x, set->y, set->fb); |
11080 | 11370 | ||
11081 | /* |
11371 | /* |
11082 | * We need to make sure the primary plane is re-enabled if it |
11372 | * We need to make sure the primary plane is re-enabled if it |
11083 | * has previously been turned off. |
- | |
11084 | */ |
11373 | * has previously been turned off. |
Line 11085... | Line 11374... | ||
11085 | if (!intel_crtc->primary_enabled && ret == 0) { |
11374 | */ |
11086 | WARN_ON(!intel_crtc->active); |
11375 | if (!intel_crtc->primary_enabled && ret == 0) { |
11087 | intel_enable_primary_hw_plane(dev_priv, intel_crtc->plane, |
11376 | WARN_ON(!intel_crtc->active); |
Line 11138... | Line 11427... | ||
11138 | struct intel_shared_dpll *pll, |
11427 | struct intel_shared_dpll *pll, |
11139 | struct intel_dpll_hw_state *hw_state) |
11428 | struct intel_dpll_hw_state *hw_state) |
11140 | { |
11429 | { |
11141 | uint32_t val; |
11430 | uint32_t val; |
Line 11142... | Line 11431... | ||
11142 | 11431 | ||
11143 | if (!intel_display_power_enabled(dev_priv, POWER_DOMAIN_PLLS)) |
11432 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_PLLS)) |
Line 11144... | Line 11433... | ||
11144 | return false; |
11433 | return false; |
11145 | 11434 | ||
11146 | val = I915_READ(PCH_DPLL(pll->id)); |
11435 | val = I915_READ(PCH_DPLL(pll->id)); |
Line 11152... | Line 11441... | ||
11152 | } |
11441 | } |
Line 11153... | Line 11442... | ||
11153 | 11442 | ||
11154 | static void ibx_pch_dpll_mode_set(struct drm_i915_private *dev_priv, |
11443 | static void ibx_pch_dpll_mode_set(struct drm_i915_private *dev_priv, |
11155 | struct intel_shared_dpll *pll) |
11444 | struct intel_shared_dpll *pll) |
11156 | { |
11445 | { |
11157 | I915_WRITE(PCH_FP0(pll->id), pll->hw_state.fp0); |
11446 | I915_WRITE(PCH_FP0(pll->id), pll->config.hw_state.fp0); |
11158 | I915_WRITE(PCH_FP1(pll->id), pll->hw_state.fp1); |
11447 | I915_WRITE(PCH_FP1(pll->id), pll->config.hw_state.fp1); |
Line 11159... | Line 11448... | ||
11159 | } |
11448 | } |
11160 | 11449 | ||
11161 | static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv, |
11450 | static void ibx_pch_dpll_enable(struct drm_i915_private *dev_priv, |
11162 | struct intel_shared_dpll *pll) |
11451 | struct intel_shared_dpll *pll) |
11163 | { |
11452 | { |
Line 11164... | Line 11453... | ||
11164 | /* PCH refclock must be enabled first */ |
11453 | /* PCH refclock must be enabled first */ |
Line 11165... | Line 11454... | ||
11165 | ibx_assert_pch_refclk_enabled(dev_priv); |
11454 | ibx_assert_pch_refclk_enabled(dev_priv); |
11166 | 11455 | ||
11167 | I915_WRITE(PCH_DPLL(pll->id), pll->hw_state.dpll); |
11456 | I915_WRITE(PCH_DPLL(pll->id), pll->config.hw_state.dpll); |
Line 11168... | Line 11457... | ||
11168 | 11457 | ||
11169 | /* Wait for the clocks to stabilize. */ |
11458 | /* Wait for the clocks to stabilize. */ |
11170 | POSTING_READ(PCH_DPLL(pll->id)); |
11459 | POSTING_READ(PCH_DPLL(pll->id)); |
11171 | udelay(150); |
11460 | udelay(150); |
11172 | 11461 | ||
11173 | /* The pixel multiplier can only be updated once the |
11462 | /* The pixel multiplier can only be updated once the |
11174 | * DPLL is enabled and the clocks are stable. |
11463 | * DPLL is enabled and the clocks are stable. |
11175 | * |
11464 | * |
11176 | * So write it again. |
11465 | * So write it again. |
Line 11177... | Line 11466... | ||
11177 | */ |
11466 | */ |
Line 11236... | Line 11525... | ||
11236 | 11525 | ||
11237 | static int |
11526 | static int |
11238 | intel_primary_plane_disable(struct drm_plane *plane) |
11527 | intel_primary_plane_disable(struct drm_plane *plane) |
11239 | { |
11528 | { |
11240 | struct drm_device *dev = plane->dev; |
- | |
11241 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | |
11242 | struct intel_plane *intel_plane = to_intel_plane(plane); |
11529 | struct drm_device *dev = plane->dev; |
Line 11243... | Line 11530... | ||
11243 | struct intel_crtc *intel_crtc; |
11530 | struct intel_crtc *intel_crtc; |
11244 | 11531 | ||
Line 11259... | Line 11546... | ||
11259 | * updated, but otherwise we don't need to touch the hardware. |
11546 | * updated, but otherwise we don't need to touch the hardware. |
11260 | */ |
11547 | */ |
11261 | if (!intel_crtc->primary_enabled) |
11548 | if (!intel_crtc->primary_enabled) |
11262 | goto disable_unpin; |
11549 | goto disable_unpin; |
Line 11263... | Line 11550... | ||
11263 | 11550 | ||
11264 | intel_disable_primary_hw_plane(dev_priv, intel_plane->plane, |
11551 | // intel_crtc_wait_for_pending_flips(plane->crtc); |
- | 11552 | intel_disable_primary_hw_plane(plane, plane->crtc); |
|
11265 | intel_plane->pipe); |
11553 | |
11266 | disable_unpin: |
11554 | disable_unpin: |
11267 | mutex_lock(&dev->struct_mutex); |
11555 | mutex_lock(&dev->struct_mutex); |
11268 | i915_gem_track_fb(intel_fb_obj(plane->fb), NULL, |
11556 | i915_gem_track_fb(intel_fb_obj(plane->fb), NULL, |
11269 | INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe)); |
11557 | INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe)); |
Line 11273... | Line 11561... | ||
11273 | 11561 | ||
11274 | return 0; |
11562 | return 0; |
Line 11275... | Line 11563... | ||
11275 | } |
11563 | } |
11276 | 11564 | ||
11277 | static int |
- | |
11278 | intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, |
- | |
11279 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
- | |
11280 | unsigned int crtc_w, unsigned int crtc_h, |
11565 | static int |
11281 | uint32_t src_x, uint32_t src_y, |
11566 | intel_check_primary_plane(struct drm_plane *plane, |
- | 11567 | struct intel_plane_state *state) |
|
- | 11568 | { |
|
- | 11569 | struct drm_crtc *crtc = state->crtc; |
|
- | 11570 | struct drm_framebuffer *fb = state->fb; |
|
- | 11571 | struct drm_rect *dest = &state->dst; |
|
- | 11572 | struct drm_rect *src = &state->src; |
|
- | 11573 | const struct drm_rect *clip = &state->clip; |
|
- | 11574 | ||
- | 11575 | return drm_plane_helper_check_update(plane, crtc, fb, |
|
- | 11576 | src, dest, clip, |
|
- | 11577 | DRM_PLANE_HELPER_NO_SCALING, |
|
- | 11578 | DRM_PLANE_HELPER_NO_SCALING, |
|
- | 11579 | false, true, &state->visible); |
|
- | 11580 | } |
|
- | 11581 | ||
- | 11582 | static int |
|
- | 11583 | intel_prepare_primary_plane(struct drm_plane *plane, |
|
- | 11584 | struct intel_plane_state *state) |
|
- | 11585 | { |
|
11282 | uint32_t src_w, uint32_t src_h) |
11586 | struct drm_crtc *crtc = state->crtc; |
11283 | { |
- | |
11284 | struct drm_device *dev = crtc->dev; |
11587 | struct drm_framebuffer *fb = state->fb; |
11285 | struct drm_i915_private *dev_priv = dev->dev_private; |
11588 | struct drm_device *dev = crtc->dev; |
11286 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
11589 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
11287 | struct intel_plane *intel_plane = to_intel_plane(plane); |
11590 | enum pipe pipe = intel_crtc->pipe; |
11288 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
- | |
11289 | struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb); |
- | |
11290 | struct drm_rect dest = { |
- | |
11291 | /* integer pixels */ |
- | |
11292 | .x1 = crtc_x, |
- | |
11293 | .y1 = crtc_y, |
- | |
11294 | .x2 = crtc_x + crtc_w, |
- | |
11295 | .y2 = crtc_y + crtc_h, |
- | |
11296 | }; |
- | |
11297 | struct drm_rect src = { |
- | |
11298 | /* 16.16 fixed point */ |
- | |
11299 | .x1 = src_x, |
- | |
11300 | .y1 = src_y, |
- | |
11301 | .x2 = src_x + src_w, |
- | |
11302 | .y2 = src_y + src_h, |
- | |
11303 | }; |
- | |
11304 | const struct drm_rect clip = { |
- | |
11305 | /* integer pixels */ |
- | |
11306 | .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, |
- | |
11307 | .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0, |
- | |
11308 | }; |
11591 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
Line 11309... | Line -... | ||
11309 | bool visible; |
- | |
11310 | int ret; |
- | |
11311 | - | ||
11312 | ret = drm_plane_helper_check_update(plane, crtc, fb, |
- | |
11313 | &src, &dest, &clip, |
- | |
Line 11314... | Line -... | ||
11314 | DRM_PLANE_HELPER_NO_SCALING, |
- | |
11315 | DRM_PLANE_HELPER_NO_SCALING, |
- | |
Line 11316... | Line -... | ||
11316 | false, true, &visible); |
- | |
11317 | - | ||
11318 | if (ret) |
- | |
11319 | return ret; |
- | |
11320 | - | ||
11321 | /* |
- | |
11322 | * If the CRTC isn't enabled, we're just pinning the framebuffer, |
11592 | struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb); |
11323 | * updating the fb pointer, and returning without touching the |
11593 | int ret; |
- | 11594 | ||
- | 11595 | ||
- | 11596 | ||
- | 11597 | if (old_obj != obj) { |
|
- | 11598 | mutex_lock(&dev->struct_mutex); |
|
- | 11599 | ret = intel_pin_and_fence_fb_obj(plane, fb, NULL); |
|
- | 11600 | if (ret == 0) |
|
- | 11601 | i915_gem_track_fb(old_obj, obj, |
|
- | 11602 | INTEL_FRONTBUFFER_PRIMARY(pipe)); |
|
- | 11603 | mutex_unlock(&dev->struct_mutex); |
|
Line 11324... | Line 11604... | ||
11324 | * hardware. This allows us to later do a drmModeSetCrtc with fb=-1 to |
11604 | if (ret != 0) { |
11325 | * turn on the display with all planes setup as desired. |
- | |
11326 | */ |
- | |
11327 | if (!crtc->enabled) { |
11605 | DRM_DEBUG_KMS("pin & fence failed\n"); |
11328 | mutex_lock(&dev->struct_mutex); |
- | |
11329 | - | ||
Line -... | Line 11606... | ||
- | 11606 | return ret; |
|
- | 11607 | } |
|
- | 11608 | } |
|
- | 11609 | ||
- | 11610 | return 0; |
|
11330 | /* |
11611 | } |
- | 11612 | ||
- | 11613 | static void |
|
- | 11614 | intel_commit_primary_plane(struct drm_plane *plane, |
|
11331 | * If we already called setplane while the crtc was disabled, |
11615 | struct intel_plane_state *state) |
- | 11616 | { |
|
- | 11617 | struct drm_crtc *crtc = state->crtc; |
|
- | 11618 | struct drm_framebuffer *fb = state->fb; |
|
- | 11619 | struct drm_device *dev = crtc->dev; |
|
- | 11620 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
Line 11332... | Line 11621... | ||
11332 | * we may have an fb pinned; unpin it. |
11621 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
11333 | */ |
11622 | enum pipe pipe = intel_crtc->pipe; |
11334 | if (plane->fb) |
11623 | struct drm_framebuffer *old_fb = plane->fb; |
Line -... | Line 11624... | ||
- | 11624 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
|
- | 11625 | struct drm_i915_gem_object *old_obj = intel_fb_obj(plane->fb); |
|
- | 11626 | struct intel_plane *intel_plane = to_intel_plane(plane); |
|
- | 11627 | struct drm_rect *src = &state->src; |
|
- | 11628 | ||
- | 11629 | crtc->primary->fb = fb; |
|
- | 11630 | crtc->x = src->x1 >> 16; |
|
- | 11631 | crtc->y = src->y1 >> 16; |
|
- | 11632 | ||
- | 11633 | intel_plane->crtc_x = state->orig_dst.x1; |
|
- | 11634 | intel_plane->crtc_y = state->orig_dst.y1; |
|
- | 11635 | intel_plane->crtc_w = drm_rect_width(&state->orig_dst); |
|
- | 11636 | intel_plane->crtc_h = drm_rect_height(&state->orig_dst); |
|
- | 11637 | intel_plane->src_x = state->orig_src.x1; |
|
- | 11638 | intel_plane->src_y = state->orig_src.y1; |
|
- | 11639 | intel_plane->src_w = drm_rect_width(&state->orig_src); |
|
- | 11640 | intel_plane->src_h = drm_rect_height(&state->orig_src); |
|
- | 11641 | intel_plane->obj = obj; |
|
- | 11642 | ||
11335 | intel_unpin_fb_obj(old_obj); |
11643 | if (intel_crtc->active) { |
- | 11644 | /* |
|
- | 11645 | * FBC does not work on some platforms for rotated |
|
- | 11646 | * planes, so disable it when rotation is not 0 and |
|
- | 11647 | * update it when rotation is set back to 0. |
|
- | 11648 | * |
|
- | 11649 | * FIXME: This is redundant with the fbc update done in |
|
11336 | 11650 | * the primary plane enable function except that that |
|
Line -... | Line 11651... | ||
- | 11651 | * one is done too late. We eventually need to unify |
|
- | 11652 | * this. |
|
- | 11653 | */ |
|
- | 11654 | if (intel_crtc->primary_enabled && |
|
- | 11655 | INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) && |
|
- | 11656 | dev_priv->fbc.plane == intel_crtc->plane && |
|
- | 11657 | intel_plane->rotation != BIT(DRM_ROTATE_0)) { |
|
Line -... | Line 11658... | ||
- | 11658 | intel_disable_fbc(dev); |
|
- | 11659 | } |
|
- | 11660 | ||
- | 11661 | if (state->visible) { |
|
- | 11662 | bool was_enabled = intel_crtc->primary_enabled; |
|
- | 11663 | ||
- | 11664 | /* FIXME: kill this fastboot hack */ |
|
- | 11665 | intel_update_pipe_size(intel_crtc); |
|
- | 11666 | ||
- | 11667 | intel_crtc->primary_enabled = true; |
|
- | 11668 | ||
11337 | i915_gem_track_fb(old_obj, obj, |
11669 | dev_priv->display.update_primary_plane(crtc, plane->fb, |
11338 | INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe)); |
11670 | crtc->x, crtc->y); |
11339 | 11671 | ||
- | 11672 | /* |
|
11340 | /* Pin and return without programming hardware */ |
11673 | * BDW signals flip done immediately if the plane |
11341 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
11674 | * is disabled, even if the plane enable is already |
11342 | mutex_unlock(&dev->struct_mutex); |
11675 | * armed to occur at the next vblank :( |
11343 | 11676 | */ |
|
- | 11677 | if (IS_BROADWELL(dev) && !was_enabled) |
|
- | 11678 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
|
- | 11679 | } else { |
|
- | 11680 | /* |
|
11344 | return ret; |
11681 | * If clipping results in a non-visible primary plane, |
- | 11682 | * we'll disable the primary plane. Note that this is |
|
- | 11683 | * a bit different than what happens if userspace |
|
- | 11684 | * explicitly disables the plane by passing fb=0 |
|
Line 11345... | Line -... | ||
11345 | } |
- | |
11346 | 11685 | * because plane->fb still gets set and pinned. |
|
11347 | 11686 | */ |
|
- | 11687 | intel_disable_primary_hw_plane(plane, crtc); |
|
11348 | /* |
11688 | } |
11349 | * If clipping results in a non-visible primary plane, we'll disable |
11689 | |
11350 | * the primary plane. Note that this is a bit different than what |
11690 | intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_PRIMARY(pipe)); |
11351 | * happens if userspace explicitly disables the plane by passing fb=0 |
- | |
11352 | * because plane->fb still gets set and pinned. |
11691 | |
11353 | */ |
- | |
11354 | if (!visible) { |
11692 | mutex_lock(&dev->struct_mutex); |
11355 | mutex_lock(&dev->struct_mutex); |
11693 | intel_update_fbc(dev); |
Line -... | Line 11694... | ||
- | 11694 | mutex_unlock(&dev->struct_mutex); |
|
- | 11695 | } |
|
- | 11696 | ||
- | 11697 | if (old_fb && old_fb != fb) { |
|
11356 | 11698 | if (intel_crtc->active) |
|
- | 11699 | intel_wait_for_vblank(dev, intel_crtc->pipe); |
|
- | 11700 | ||
- | 11701 | mutex_lock(&dev->struct_mutex); |
|
11357 | /* |
11702 | intel_unpin_fb_obj(old_obj); |
- | 11703 | mutex_unlock(&dev->struct_mutex); |
|
Line 11358... | Line 11704... | ||
11358 | * Try to pin the new fb first so that we can bail out if we |
11704 | } |
11359 | * fail. |
- | |
11360 | */ |
- | |
11361 | if (plane->fb != fb) { |
11705 | } |
Line -... | Line 11706... | ||
- | 11706 | ||
- | 11707 | static int |
|
- | 11708 | intel_primary_plane_setplane(struct drm_plane *plane, struct drm_crtc *crtc, |
|
- | 11709 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
|
- | 11710 | unsigned int crtc_w, unsigned int crtc_h, |
|
Line 11362... | Line 11711... | ||
11362 | ret = intel_pin_and_fence_fb_obj(dev, obj, NULL); |
11711 | uint32_t src_x, uint32_t src_y, |
- | 11712 | uint32_t src_w, uint32_t src_h) |
|
- | 11713 | { |
|
- | 11714 | struct intel_plane_state state; |
|
- | 11715 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 11716 | int ret; |
|
11363 | if (ret) { |
11717 | |
11364 | mutex_unlock(&dev->struct_mutex); |
11718 | state.crtc = crtc; |
- | 11719 | state.fb = fb; |
|
- | 11720 | ||
Line -... | Line 11721... | ||
- | 11721 | /* sample coordinates in 16.16 fixed point */ |
|
11365 | return ret; |
11722 | state.src.x1 = src_x; |
Line -... | Line 11723... | ||
- | 11723 | state.src.x2 = src_x + src_w; |
|
- | 11724 | state.src.y1 = src_y; |
|
11366 | } |
11725 | state.src.y2 = src_y + src_h; |
11367 | } |
- | |
Line 11368... | Line 11726... | ||
11368 | 11726 | ||
11369 | i915_gem_track_fb(old_obj, obj, |
11727 | /* integer pixels */ |
11370 | INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe)); |
11728 | state.dst.x1 = crtc_x; |
Line 11371... | Line -... | ||
11371 | - | ||
11372 | if (intel_crtc->primary_enabled) |
11729 | state.dst.x2 = crtc_x + crtc_w; |
11373 | intel_disable_primary_hw_plane(dev_priv, |
- | |
Line 11374... | Line 11730... | ||
11374 | intel_plane->plane, |
11730 | state.dst.y1 = crtc_y; |
11375 | intel_plane->pipe); |
11731 | state.dst.y2 = crtc_y + crtc_h; |
Line 11376... | Line 11732... | ||
11376 | 11732 | ||
Line 11405... | Line 11761... | ||
11405 | 11761 | ||
11406 | static const struct drm_plane_funcs intel_primary_plane_funcs = { |
11762 | static const struct drm_plane_funcs intel_primary_plane_funcs = { |
11407 | .update_plane = intel_primary_plane_setplane, |
11763 | .update_plane = intel_primary_plane_setplane, |
11408 | .disable_plane = intel_primary_plane_disable, |
11764 | .disable_plane = intel_primary_plane_disable, |
- | 11765 | .destroy = intel_plane_destroy, |
|
11409 | .destroy = intel_plane_destroy, |
11766 | .set_property = intel_plane_set_property |
Line 11410... | Line 11767... | ||
11410 | }; |
11767 | }; |
11411 | 11768 | ||
11412 | static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, |
11769 | static struct drm_plane *intel_primary_plane_create(struct drm_device *dev, |
Line 11422... | Line 11779... | ||
11422 | 11779 | ||
11423 | primary->can_scale = false; |
11780 | primary->can_scale = false; |
11424 | primary->max_downscale = 1; |
11781 | primary->max_downscale = 1; |
11425 | primary->pipe = pipe; |
11782 | primary->pipe = pipe; |
- | 11783 | primary->plane = pipe; |
|
11426 | primary->plane = pipe; |
11784 | primary->rotation = BIT(DRM_ROTATE_0); |
11427 | if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) |
11785 | if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4) |
Line 11428... | Line 11786... | ||
11428 | primary->plane = !pipe; |
11786 | primary->plane = !pipe; |
11429 | 11787 | ||
Line 11437... | Line 11795... | ||
11437 | 11795 | ||
11438 | drm_universal_plane_init(dev, &primary->base, 0, |
11796 | drm_universal_plane_init(dev, &primary->base, 0, |
11439 | &intel_primary_plane_funcs, |
11797 | &intel_primary_plane_funcs, |
11440 | intel_primary_formats, num_formats, |
11798 | intel_primary_formats, num_formats, |
- | 11799 | DRM_PLANE_TYPE_PRIMARY); |
|
- | 11800 | ||
- | 11801 | if (INTEL_INFO(dev)->gen >= 4) { |
|
- | 11802 | if (!dev->mode_config.rotation_property) |
|
- | 11803 | dev->mode_config.rotation_property = |
|
- | 11804 | drm_mode_create_rotation_property(dev, |
|
- | 11805 | BIT(DRM_ROTATE_0) | |
|
- | 11806 | BIT(DRM_ROTATE_180)); |
|
- | 11807 | if (dev->mode_config.rotation_property) |
|
- | 11808 | drm_object_attach_property(&primary->base.base, |
|
- | 11809 | dev->mode_config.rotation_property, |
|
- | 11810 | primary->rotation); |
|
- | 11811 | } |
|
11441 | DRM_PLANE_TYPE_PRIMARY); |
11812 | |
11442 | return &primary->base; |
11813 | return &primary->base; |
Line 11443... | Line 11814... | ||
11443 | } |
11814 | } |
11444 | 11815 | ||
Line 11452... | Line 11823... | ||
11452 | 11823 | ||
11453 | return intel_crtc_cursor_set_obj(plane->crtc, NULL, 0, 0); |
11824 | return intel_crtc_cursor_set_obj(plane->crtc, NULL, 0, 0); |
Line 11454... | Line 11825... | ||
11454 | } |
11825 | } |
11455 | 11826 | ||
11456 | static int |
- | |
11457 | intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, |
- | |
11458 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
- | |
11459 | unsigned int crtc_w, unsigned int crtc_h, |
11827 | static int |
11460 | uint32_t src_x, uint32_t src_y, |
11828 | intel_check_cursor_plane(struct drm_plane *plane, |
11461 | uint32_t src_w, uint32_t src_h) |
11829 | struct intel_plane_state *state) |
11462 | { |
11830 | { |
11463 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
11831 | struct drm_crtc *crtc = state->crtc; |
11464 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
11832 | struct drm_device *dev = crtc->dev; |
11465 | struct drm_i915_gem_object *obj = intel_fb->obj; |
- | |
11466 | struct drm_rect dest = { |
- | |
11467 | /* integer pixels */ |
- | |
11468 | .x1 = crtc_x, |
- | |
11469 | .y1 = crtc_y, |
- | |
11470 | .x2 = crtc_x + crtc_w, |
- | |
11471 | .y2 = crtc_y + crtc_h, |
11833 | struct drm_framebuffer *fb = state->fb; |
11472 | }; |
- | |
11473 | struct drm_rect src = { |
- | |
11474 | /* 16.16 fixed point */ |
- | |
11475 | .x1 = src_x, |
- | |
11476 | .y1 = src_y, |
- | |
11477 | .x2 = src_x + src_w, |
- | |
11478 | .y2 = src_y + src_h, |
11834 | struct drm_rect *dest = &state->dst; |
11479 | }; |
- | |
11480 | const struct drm_rect clip = { |
11835 | struct drm_rect *src = &state->src; |
11481 | /* integer pixels */ |
11836 | const struct drm_rect *clip = &state->clip; |
11482 | .x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0, |
- | |
11483 | .y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0, |
11837 | struct drm_i915_gem_object *obj = intel_fb_obj(fb); |
11484 | }; |
11838 | int crtc_w, crtc_h; |
Line 11485... | Line 11839... | ||
11485 | bool visible; |
11839 | unsigned stride; |
11486 | int ret; |
11840 | int ret; |
11487 | 11841 | ||
11488 | ret = drm_plane_helper_check_update(plane, crtc, fb, |
11842 | ret = drm_plane_helper_check_update(plane, crtc, fb, |
11489 | &src, &dest, &clip, |
11843 | src, dest, clip, |
11490 | DRM_PLANE_HELPER_NO_SCALING, |
11844 | DRM_PLANE_HELPER_NO_SCALING, |
11491 | DRM_PLANE_HELPER_NO_SCALING, |
11845 | DRM_PLANE_HELPER_NO_SCALING, |
Line -... | Line 11846... | ||
- | 11846 | true, true, &state->visible); |
|
- | 11847 | if (ret) |
|
- | 11848 | return ret; |
|
- | 11849 | ||
- | 11850 | ||
- | 11851 | /* if we want to turn off the cursor ignore width and height */ |
|
- | 11852 | if (!obj) |
|
- | 11853 | return 0; |
|
- | 11854 | ||
- | 11855 | /* Check for which cursor types we support */ |
|
- | 11856 | crtc_w = drm_rect_width(&state->orig_dst); |
|
- | 11857 | crtc_h = drm_rect_height(&state->orig_dst); |
|
- | 11858 | if (!cursor_size_ok(dev, crtc_w, crtc_h)) { |
|
- | 11859 | DRM_DEBUG("Cursor dimension not supported\n"); |
|
- | 11860 | return -EINVAL; |
|
- | 11861 | } |
|
- | 11862 | ||
- | 11863 | stride = roundup_pow_of_two(crtc_w) * 4; |
|
- | 11864 | if (obj->base.size < stride * crtc_h) { |
|
- | 11865 | DRM_DEBUG_KMS("buffer is too small\n"); |
|
- | 11866 | return -ENOMEM; |
|
- | 11867 | } |
|
- | 11868 | ||
- | 11869 | if (fb == crtc->cursor->fb) |
|
- | 11870 | return 0; |
|
- | 11871 | ||
- | 11872 | /* we only need to pin inside GTT if cursor is non-phy */ |
|
- | 11873 | mutex_lock(&dev->struct_mutex); |
|
- | 11874 | if (!INTEL_INFO(dev)->cursor_needs_physical && obj->tiling_mode) { |
|
- | 11875 | DRM_DEBUG_KMS("cursor cannot be tiled\n"); |
|
- | 11876 | ret = -EINVAL; |
|
- | 11877 | } |
|
- | 11878 | mutex_unlock(&dev->struct_mutex); |
|
- | 11879 | ||
- | 11880 | return ret; |
|
- | 11881 | } |
|
- | 11882 | ||
- | 11883 | static int |
|
- | 11884 | intel_commit_cursor_plane(struct drm_plane *plane, |
|
- | 11885 | struct intel_plane_state *state) |
|
- | 11886 | { |
|
- | 11887 | struct drm_crtc *crtc = state->crtc; |
|
- | 11888 | struct drm_framebuffer *fb = state->fb; |
|
- | 11889 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 11890 | struct intel_plane *intel_plane = to_intel_plane(plane); |
|
11492 | true, true, &visible); |
11891 | struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb); |
11493 | if (ret) |
11892 | struct drm_i915_gem_object *obj = intel_fb->obj; |
- | 11893 | int crtc_w, crtc_h; |
|
- | 11894 | ||
- | 11895 | crtc->cursor_x = state->orig_dst.x1; |
|
- | 11896 | crtc->cursor_y = state->orig_dst.y1; |
|
- | 11897 | ||
- | 11898 | intel_plane->crtc_x = state->orig_dst.x1; |
|
- | 11899 | intel_plane->crtc_y = state->orig_dst.y1; |
|
- | 11900 | intel_plane->crtc_w = drm_rect_width(&state->orig_dst); |
|
- | 11901 | intel_plane->crtc_h = drm_rect_height(&state->orig_dst); |
|
- | 11902 | intel_plane->src_x = state->orig_src.x1; |
|
- | 11903 | intel_plane->src_y = state->orig_src.y1; |
|
11494 | return ret; |
11904 | intel_plane->src_w = drm_rect_width(&state->orig_src); |
- | 11905 | intel_plane->src_h = drm_rect_height(&state->orig_src); |
|
- | 11906 | intel_plane->obj = obj; |
|
11495 | 11907 | ||
11496 | crtc->cursor_x = crtc_x; |
11908 | if (fb != crtc->cursor->fb) { |
11497 | crtc->cursor_y = crtc_y; |
11909 | crtc_w = drm_rect_width(&state->orig_dst); |
- | 11910 | crtc_h = drm_rect_height(&state->orig_dst); |
|
- | 11911 | return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h); |
|
11498 | if (fb != crtc->cursor->fb) { |
11912 | } else { |
11499 | return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h); |
11913 | intel_crtc_update_cursor(crtc, state->visible); |
11500 | } else { |
11914 | |
- | 11915 | ||
- | 11916 | return 0; |
|
- | 11917 | } |
|
- | 11918 | } |
|
- | 11919 | ||
- | 11920 | static int |
|
- | 11921 | intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc, |
|
- | 11922 | struct drm_framebuffer *fb, int crtc_x, int crtc_y, |
|
- | 11923 | unsigned int crtc_w, unsigned int crtc_h, |
|
- | 11924 | uint32_t src_x, uint32_t src_y, |
|
- | 11925 | uint32_t src_w, uint32_t src_h) |
|
- | 11926 | { |
|
- | 11927 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); |
|
- | 11928 | struct intel_plane_state state; |
|
- | 11929 | int ret; |
|
- | 11930 | ||
- | 11931 | state.crtc = crtc; |
|
- | 11932 | state.fb = fb; |
|
- | 11933 | ||
- | 11934 | /* sample coordinates in 16.16 fixed point */ |
|
- | 11935 | state.src.x1 = src_x; |
|
- | 11936 | state.src.x2 = src_x + src_w; |
|
- | 11937 | state.src.y1 = src_y; |
|
- | 11938 | state.src.y2 = src_y + src_h; |
|
- | 11939 | ||
- | 11940 | /* integer pixels */ |
|
- | 11941 | state.dst.x1 = crtc_x; |
|
- | 11942 | state.dst.x2 = crtc_x + crtc_w; |
|
- | 11943 | state.dst.y1 = crtc_y; |
|
- | 11944 | state.dst.y2 = crtc_y + crtc_h; |
|
- | 11945 | ||
- | 11946 | state.clip.x1 = 0; |
|
- | 11947 | state.clip.y1 = 0; |
|
- | 11948 | state.clip.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0; |
|
- | 11949 | state.clip.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0; |
|
- | 11950 | ||
- | 11951 | state.orig_src = state.src; |
|
- | 11952 | state.orig_dst = state.dst; |
|
- | 11953 | ||
- | 11954 | ret = intel_check_cursor_plane(plane, &state); |
|
- | 11955 | if (ret) |
|
- | 11956 | return ret; |
|
11501 | intel_crtc_update_cursor(crtc, visible); |
11957 | |
11502 | return 0; |
11958 | return intel_commit_cursor_plane(plane, &state); |
11503 | } |
11959 | } |
11504 | } |
11960 | |
- | 11961 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { |
|
11505 | static const struct drm_plane_funcs intel_cursor_plane_funcs = { |
11962 | .update_plane = intel_cursor_plane_update, |
Line 11506... | Line 11963... | ||
11506 | .update_plane = intel_cursor_plane_update, |
11963 | .disable_plane = intel_cursor_plane_disable, |
11507 | .disable_plane = intel_cursor_plane_disable, |
11964 | .destroy = intel_plane_destroy, |
11508 | .destroy = intel_plane_destroy, |
11965 | .set_property = intel_plane_set_property, |
Line 11519... | Line 11976... | ||
11519 | 11976 | ||
11520 | cursor->can_scale = false; |
11977 | cursor->can_scale = false; |
11521 | cursor->max_downscale = 1; |
11978 | cursor->max_downscale = 1; |
11522 | cursor->pipe = pipe; |
11979 | cursor->pipe = pipe; |
- | 11980 | cursor->plane = pipe; |
|
Line 11523... | Line 11981... | ||
11523 | cursor->plane = pipe; |
11981 | cursor->rotation = BIT(DRM_ROTATE_0); |
11524 | 11982 | ||
11525 | drm_universal_plane_init(dev, &cursor->base, 0, |
11983 | drm_universal_plane_init(dev, &cursor->base, 0, |
11526 | &intel_cursor_plane_funcs, |
11984 | &intel_cursor_plane_funcs, |
11527 | intel_cursor_formats, |
11985 | intel_cursor_formats, |
- | 11986 | ARRAY_SIZE(intel_cursor_formats), |
|
- | 11987 | DRM_PLANE_TYPE_CURSOR); |
|
- | 11988 | ||
- | 11989 | if (INTEL_INFO(dev)->gen >= 4) { |
|
- | 11990 | if (!dev->mode_config.rotation_property) |
|
- | 11991 | dev->mode_config.rotation_property = |
|
- | 11992 | drm_mode_create_rotation_property(dev, |
|
- | 11993 | BIT(DRM_ROTATE_0) | |
|
- | 11994 | BIT(DRM_ROTATE_180)); |
|
- | 11995 | if (dev->mode_config.rotation_property) |
|
- | 11996 | drm_object_attach_property(&cursor->base.base, |
|
- | 11997 | dev->mode_config.rotation_property, |
|
- | 11998 | cursor->rotation); |
|
11528 | ARRAY_SIZE(intel_cursor_formats), |
11999 | } |
11529 | DRM_PLANE_TYPE_CURSOR); |
12000 | |
Line 11530... | Line 12001... | ||
11530 | return &cursor->base; |
12001 | return &cursor->base; |
11531 | } |
12002 | } |
Line 11573... | Line 12044... | ||
11573 | intel_crtc->plane = !pipe; |
12044 | intel_crtc->plane = !pipe; |
11574 | } |
12045 | } |
Line 11575... | Line 12046... | ||
11575 | 12046 | ||
11576 | intel_crtc->cursor_base = ~0; |
12047 | intel_crtc->cursor_base = ~0; |
11577 | intel_crtc->cursor_cntl = ~0; |
- | |
11578 | 12048 | intel_crtc->cursor_cntl = ~0; |
|
Line 11579... | Line 12049... | ||
11579 | init_waitqueue_head(&intel_crtc->vbl_wait); |
12049 | intel_crtc->cursor_size = ~0; |
11580 | 12050 | ||
11581 | BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) || |
12051 | BUG_ON(pipe >= ARRAY_SIZE(dev_priv->plane_to_crtc_mapping) || |
11582 | dev_priv->plane_to_crtc_mapping[intel_crtc->plane] != NULL); |
12052 | dev_priv->plane_to_crtc_mapping[intel_crtc->plane] != NULL); |
Line 11601... | Line 12071... | ||
11601 | struct drm_encoder *encoder = connector->base.encoder; |
12071 | struct drm_encoder *encoder = connector->base.encoder; |
11602 | struct drm_device *dev = connector->base.dev; |
12072 | struct drm_device *dev = connector->base.dev; |
Line 11603... | Line 12073... | ||
11603 | 12073 | ||
Line 11604... | Line 12074... | ||
11604 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); |
12074 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); |
11605 | 12075 | ||
Line 11606... | Line 12076... | ||
11606 | if (!encoder) |
12076 | if (!encoder || WARN_ON(!encoder->crtc)) |
11607 | return INVALID_PIPE; |
12077 | return INVALID_PIPE; |
Line 11637... | Line 12107... | ||
11637 | struct drm_device *dev = encoder->base.dev; |
12107 | struct drm_device *dev = encoder->base.dev; |
11638 | struct intel_encoder *source_encoder; |
12108 | struct intel_encoder *source_encoder; |
11639 | int index_mask = 0; |
12109 | int index_mask = 0; |
11640 | int entry = 0; |
12110 | int entry = 0; |
Line 11641... | Line 12111... | ||
11641 | 12111 | ||
11642 | list_for_each_entry(source_encoder, |
- | |
11643 | &dev->mode_config.encoder_list, base.head) { |
12112 | for_each_intel_encoder(dev, source_encoder) { |
11644 | if (encoders_cloneable(encoder, source_encoder)) |
12113 | if (encoders_cloneable(encoder, source_encoder)) |
Line 11645... | Line 12114... | ||
11645 | index_mask |= (1 << entry); |
12114 | index_mask |= (1 << entry); |
11646 | 12115 | ||
Line 11690... | Line 12159... | ||
11690 | 12159 | ||
11691 | static bool intel_crt_present(struct drm_device *dev) |
12160 | static bool intel_crt_present(struct drm_device *dev) |
11692 | { |
12161 | { |
Line 11693... | Line 12162... | ||
11693 | struct drm_i915_private *dev_priv = dev->dev_private; |
12162 | struct drm_i915_private *dev_priv = dev->dev_private; |
- | 12163 | ||
- | 12164 | if (INTEL_INFO(dev)->gen >= 9) |
|
- | 12165 | return false; |
|
11694 | 12166 | ||
Line 11695... | Line 12167... | ||
11695 | if (IS_ULT(dev)) |
12167 | if (IS_HSW_ULT(dev) || IS_BDW_ULT(dev)) |
11696 | return false; |
12168 | return false; |
Line 11760... | Line 12232... | ||
11760 | intel_dp_init(dev, PCH_DP_C, PORT_C); |
12232 | intel_dp_init(dev, PCH_DP_C, PORT_C); |
Line 11761... | Line 12233... | ||
11761 | 12233 | ||
11762 | if (I915_READ(PCH_DP_D) & DP_DETECTED) |
12234 | if (I915_READ(PCH_DP_D) & DP_DETECTED) |
11763 | intel_dp_init(dev, PCH_DP_D, PORT_D); |
12235 | intel_dp_init(dev, PCH_DP_D, PORT_D); |
- | 12236 | } else if (IS_VALLEYVIEW(dev)) { |
|
- | 12237 | /* |
|
- | 12238 | * The DP_DETECTED bit is the latched state of the DDC |
|
- | 12239 | * SDA pin at boot. However since eDP doesn't require DDC |
|
- | 12240 | * (no way to plug in a DP->HDMI dongle) the DDC pins for |
|
- | 12241 | * eDP ports may have been muxed to an alternate function. |
|
- | 12242 | * Thus we can't rely on the DP_DETECTED bit alone to detect |
|
- | 12243 | * eDP ports. Consult the VBT as well as DP_DETECTED to |
|
- | 12244 | * detect eDP ports. |
|
11764 | } else if (IS_VALLEYVIEW(dev)) { |
12245 | */ |
11765 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) { |
12246 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIB) & SDVO_DETECTED) |
11766 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB, |
12247 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIB, |
11767 | PORT_B); |
12248 | PORT_B); |
- | 12249 | if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED || |
|
11768 | if (I915_READ(VLV_DISPLAY_BASE + DP_B) & DP_DETECTED) |
12250 | intel_dp_is_edp(dev, PORT_B)) |
11769 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B); |
- | |
Line 11770... | Line 12251... | ||
11770 | } |
12251 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_B, PORT_B); |
11771 | 12252 | ||
11772 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) { |
12253 | if (I915_READ(VLV_DISPLAY_BASE + GEN4_HDMIC) & SDVO_DETECTED) |
11773 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, |
12254 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + GEN4_HDMIC, |
- | 12255 | PORT_C); |
|
11774 | PORT_C); |
12256 | if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED || |
11775 | if (I915_READ(VLV_DISPLAY_BASE + DP_C) & DP_DETECTED) |
- | |
Line 11776... | Line 12257... | ||
11776 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C); |
12257 | intel_dp_is_edp(dev, PORT_C)) |
11777 | } |
12258 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_C, PORT_C); |
11778 | 12259 | ||
11779 | if (IS_CHERRYVIEW(dev)) { |
12260 | if (IS_CHERRYVIEW(dev)) { |
- | 12261 | if (I915_READ(VLV_DISPLAY_BASE + CHV_HDMID) & SDVO_DETECTED) |
|
11780 | if (I915_READ(VLV_DISPLAY_BASE + CHV_HDMID) & SDVO_DETECTED) { |
12262 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + CHV_HDMID, |
11781 | intel_hdmi_init(dev, VLV_DISPLAY_BASE + CHV_HDMID, |
12263 | PORT_D); |
11782 | PORT_D); |
12264 | /* eDP not supported on port D, so don't check VBT */ |
11783 | if (I915_READ(VLV_DISPLAY_BASE + DP_D) & DP_DETECTED) |
- | |
Line 11784... | Line 12265... | ||
11784 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_D, PORT_D); |
12265 | if (I915_READ(VLV_DISPLAY_BASE + DP_D) & DP_DETECTED) |
11785 | } |
12266 | intel_dp_init(dev, VLV_DISPLAY_BASE + DP_D, PORT_D); |
11786 | } |
12267 | } |
Line 11823... | Line 12304... | ||
11823 | intel_dp_init(dev, DP_D, PORT_D); |
12304 | intel_dp_init(dev, DP_D, PORT_D); |
11824 | } else if (IS_GEN2(dev)) |
12305 | } else if (IS_GEN2(dev)) |
11825 | intel_dvo_init(dev); |
12306 | intel_dvo_init(dev); |
Line 11826... | Line 12307... | ||
11826 | 12307 | ||
Line 11827... | Line 12308... | ||
11827 | 12308 | ||
11828 | intel_edp_psr_init(dev); |
12309 | intel_psr_init(dev); |
11829 | 12310 | ||
11830 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) { |
12311 | for_each_intel_encoder(dev, encoder) { |
11831 | encoder->base.possible_crtcs = encoder->crtc_mask; |
12312 | encoder->base.possible_crtcs = encoder->crtc_mask; |
Line 11991... | Line 12472... | ||
11991 | dev_priv->display.find_dpll = i9xx_find_best_dpll; |
12472 | dev_priv->display.find_dpll = i9xx_find_best_dpll; |
Line 11992... | Line 12473... | ||
11992 | 12473 | ||
11993 | if (HAS_DDI(dev)) { |
12474 | if (HAS_DDI(dev)) { |
11994 | dev_priv->display.get_pipe_config = haswell_get_pipe_config; |
12475 | dev_priv->display.get_pipe_config = haswell_get_pipe_config; |
11995 | dev_priv->display.get_plane_config = ironlake_get_plane_config; |
12476 | dev_priv->display.get_plane_config = ironlake_get_plane_config; |
- | 12477 | dev_priv->display.crtc_compute_clock = |
|
11996 | dev_priv->display.crtc_mode_set = haswell_crtc_mode_set; |
12478 | haswell_crtc_compute_clock; |
11997 | dev_priv->display.crtc_enable = haswell_crtc_enable; |
12479 | dev_priv->display.crtc_enable = haswell_crtc_enable; |
11998 | dev_priv->display.crtc_disable = haswell_crtc_disable; |
12480 | dev_priv->display.crtc_disable = haswell_crtc_disable; |
- | 12481 | dev_priv->display.off = ironlake_crtc_off; |
|
- | 12482 | if (INTEL_INFO(dev)->gen >= 9) |
|
- | 12483 | dev_priv->display.update_primary_plane = |
|
- | 12484 | skylake_update_primary_plane; |
|
11999 | dev_priv->display.off = ironlake_crtc_off; |
12485 | else |
12000 | dev_priv->display.update_primary_plane = |
12486 | dev_priv->display.update_primary_plane = |
12001 | ironlake_update_primary_plane; |
12487 | ironlake_update_primary_plane; |
12002 | } else if (HAS_PCH_SPLIT(dev)) { |
12488 | } else if (HAS_PCH_SPLIT(dev)) { |
12003 | dev_priv->display.get_pipe_config = ironlake_get_pipe_config; |
12489 | dev_priv->display.get_pipe_config = ironlake_get_pipe_config; |
12004 | dev_priv->display.get_plane_config = ironlake_get_plane_config; |
12490 | dev_priv->display.get_plane_config = ironlake_get_plane_config; |
- | 12491 | dev_priv->display.crtc_compute_clock = |
|
12005 | dev_priv->display.crtc_mode_set = ironlake_crtc_mode_set; |
12492 | ironlake_crtc_compute_clock; |
12006 | dev_priv->display.crtc_enable = ironlake_crtc_enable; |
12493 | dev_priv->display.crtc_enable = ironlake_crtc_enable; |
12007 | dev_priv->display.crtc_disable = ironlake_crtc_disable; |
12494 | dev_priv->display.crtc_disable = ironlake_crtc_disable; |
12008 | dev_priv->display.off = ironlake_crtc_off; |
12495 | dev_priv->display.off = ironlake_crtc_off; |
12009 | dev_priv->display.update_primary_plane = |
12496 | dev_priv->display.update_primary_plane = |
12010 | ironlake_update_primary_plane; |
12497 | ironlake_update_primary_plane; |
12011 | } else if (IS_VALLEYVIEW(dev)) { |
12498 | } else if (IS_VALLEYVIEW(dev)) { |
12012 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
12499 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
12013 | dev_priv->display.get_plane_config = i9xx_get_plane_config; |
12500 | dev_priv->display.get_plane_config = i9xx_get_plane_config; |
12014 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; |
12501 | dev_priv->display.crtc_compute_clock = i9xx_crtc_compute_clock; |
12015 | dev_priv->display.crtc_enable = valleyview_crtc_enable; |
12502 | dev_priv->display.crtc_enable = valleyview_crtc_enable; |
12016 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
12503 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
12017 | dev_priv->display.off = i9xx_crtc_off; |
12504 | dev_priv->display.off = i9xx_crtc_off; |
12018 | dev_priv->display.update_primary_plane = |
12505 | dev_priv->display.update_primary_plane = |
12019 | i9xx_update_primary_plane; |
12506 | i9xx_update_primary_plane; |
12020 | } else { |
12507 | } else { |
12021 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
12508 | dev_priv->display.get_pipe_config = i9xx_get_pipe_config; |
12022 | dev_priv->display.get_plane_config = i9xx_get_plane_config; |
12509 | dev_priv->display.get_plane_config = i9xx_get_plane_config; |
12023 | dev_priv->display.crtc_mode_set = i9xx_crtc_mode_set; |
12510 | dev_priv->display.crtc_compute_clock = i9xx_crtc_compute_clock; |
12024 | dev_priv->display.crtc_enable = i9xx_crtc_enable; |
12511 | dev_priv->display.crtc_enable = i9xx_crtc_enable; |
12025 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
12512 | dev_priv->display.crtc_disable = i9xx_crtc_disable; |
12026 | dev_priv->display.off = i9xx_crtc_off; |
12513 | dev_priv->display.off = i9xx_crtc_off; |
12027 | dev_priv->display.update_primary_plane = |
12514 | dev_priv->display.update_primary_plane = |
Line 12055... | Line 12542... | ||
12055 | i855_get_display_clock_speed; |
12542 | i855_get_display_clock_speed; |
12056 | else /* 852, 830 */ |
12543 | else /* 852, 830 */ |
12057 | dev_priv->display.get_display_clock_speed = |
12544 | dev_priv->display.get_display_clock_speed = |
12058 | i830_get_display_clock_speed; |
12545 | i830_get_display_clock_speed; |
Line 12059... | Line -... | ||
12059 | - | ||
12060 | if (HAS_PCH_SPLIT(dev)) { |
12546 | |
12061 | if (IS_GEN5(dev)) { |
12547 | if (IS_GEN5(dev)) { |
12062 | dev_priv->display.fdi_link_train = ironlake_fdi_link_train; |
- | |
12063 | dev_priv->display.write_eld = ironlake_write_eld; |
12548 | dev_priv->display.fdi_link_train = ironlake_fdi_link_train; |
12064 | } else if (IS_GEN6(dev)) { |
12549 | } else if (IS_GEN6(dev)) { |
12065 | dev_priv->display.fdi_link_train = gen6_fdi_link_train; |
- | |
12066 | dev_priv->display.write_eld = ironlake_write_eld; |
- | |
12067 | dev_priv->display.modeset_global_resources = |
- | |
12068 | snb_modeset_global_resources; |
12550 | dev_priv->display.fdi_link_train = gen6_fdi_link_train; |
12069 | } else if (IS_IVYBRIDGE(dev)) { |
12551 | } else if (IS_IVYBRIDGE(dev)) { |
12070 | /* FIXME: detect B0+ stepping and use auto training */ |
12552 | /* FIXME: detect B0+ stepping and use auto training */ |
12071 | dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train; |
- | |
12072 | dev_priv->display.write_eld = ironlake_write_eld; |
12553 | dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train; |
12073 | dev_priv->display.modeset_global_resources = |
12554 | dev_priv->display.modeset_global_resources = |
12074 | ivb_modeset_global_resources; |
12555 | ivb_modeset_global_resources; |
12075 | } else if (IS_HASWELL(dev) || IS_GEN8(dev)) { |
12556 | } else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) { |
12076 | dev_priv->display.fdi_link_train = hsw_fdi_link_train; |
- | |
12077 | dev_priv->display.write_eld = haswell_write_eld; |
- | |
12078 | dev_priv->display.modeset_global_resources = |
- | |
12079 | haswell_modeset_global_resources; |
- | |
12080 | } |
- | |
12081 | } else if (IS_G4X(dev)) { |
- | |
12082 | dev_priv->display.write_eld = g4x_write_eld; |
12557 | dev_priv->display.fdi_link_train = hsw_fdi_link_train; |
12083 | } else if (IS_VALLEYVIEW(dev)) { |
12558 | } else if (IS_VALLEYVIEW(dev)) { |
12084 | dev_priv->display.modeset_global_resources = |
12559 | dev_priv->display.modeset_global_resources = |
12085 | valleyview_modeset_global_resources; |
- | |
12086 | dev_priv->display.write_eld = ironlake_write_eld; |
12560 | valleyview_modeset_global_resources; |
Line 12087... | Line 12561... | ||
12087 | } |
12561 | } |
12088 | 12562 | ||
Line 12089... | Line 12563... | ||
12089 | /* Default just returns -ENODEV to indicate unsupported */ |
12563 | /* Default just returns -ENODEV to indicate unsupported */ |
- | 12564 | // dev_priv->display.queue_flip = intel_default_queue_flip; |
|
- | 12565 | ||
12090 | // dev_priv->display.queue_flip = intel_default_queue_flip; |
12566 | |
Line 12091... | Line 12567... | ||
12091 | 12567 | ||
12092 | 12568 | ||
12093 | 12569 | intel_panel_init_backlight_funcs(dev); |
|
Line 12106... | Line 12582... | ||
12106 | 12582 | ||
12107 | dev_priv->quirks |= QUIRK_PIPEA_FORCE; |
12583 | dev_priv->quirks |= QUIRK_PIPEA_FORCE; |
12108 | DRM_INFO("applying pipe a force quirk\n"); |
12584 | DRM_INFO("applying pipe a force quirk\n"); |
Line -... | Line 12585... | ||
- | 12585 | } |
|
- | 12586 | ||
- | 12587 | static void quirk_pipeb_force(struct drm_device *dev) |
|
- | 12588 | { |
|
- | 12589 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 12590 | ||
- | 12591 | dev_priv->quirks |= QUIRK_PIPEB_FORCE; |
|
- | 12592 | DRM_INFO("applying pipe b force quirk\n"); |
|
12109 | } |
12593 | } |
12110 | 12594 | ||
12111 | /* |
12595 | /* |
12112 | * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason |
12596 | * Some machines (Lenovo U160) do not work with SSC on LVDS for some reason |
12113 | */ |
12597 | */ |
Line 12210... | Line 12694... | ||
12210 | { 0x0a06, 0x1025, 0x0a11, quirk_backlight_present }, |
12694 | { 0x0a06, 0x1025, 0x0a11, quirk_backlight_present }, |
Line 12211... | Line 12695... | ||
12211 | 12695 | ||
12212 | /* Acer C720 Chromebook (Core i3 4005U) */ |
12696 | /* Acer C720 Chromebook (Core i3 4005U) */ |
Line -... | Line 12697... | ||
- | 12697 | { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, |
|
- | 12698 | ||
- | 12699 | /* Apple Macbook 2,1 (Core 2 T7400) */ |
|
12213 | { 0x0a16, 0x1025, 0x0a11, quirk_backlight_present }, |
12700 | { 0x27a2, 0x8086, 0x7270, quirk_backlight_present }, |
12214 | 12701 | ||
Line 12215... | Line 12702... | ||
12215 | /* Toshiba CB35 Chromebook (Celeron 2955U) */ |
12702 | /* Toshiba CB35 Chromebook (Celeron 2955U) */ |
12216 | { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, |
12703 | { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, |
Line 12252... | Line 12739... | ||
12252 | sr1 = inb(VGA_SR_DATA); |
12739 | sr1 = inb(VGA_SR_DATA); |
12253 | outb(sr1 | 1<<5, VGA_SR_DATA); |
12740 | outb(sr1 | 1<<5, VGA_SR_DATA); |
12254 | // vga_put(dev->pdev, VGA_RSRC_LEGACY_IO); |
12741 | // vga_put(dev->pdev, VGA_RSRC_LEGACY_IO); |
12255 | udelay(300); |
12742 | udelay(300); |
Line -... | Line 12743... | ||
- | 12743 | ||
- | 12744 | /* |
|
- | 12745 | * Fujitsu-Siemens Lifebook S6010 (830) has problems resuming |
|
- | 12746 | * from S3 without preserving (some of?) the other bits. |
|
12256 | 12747 | */ |
|
12257 | I915_WRITE(vga_reg, VGA_DISP_DISABLE); |
12748 | I915_WRITE(vga_reg, dev_priv->bios_vgacntr | VGA_DISP_DISABLE); |
12258 | POSTING_READ(vga_reg); |
12749 | POSTING_READ(vga_reg); |
Line 12259... | Line 12750... | ||
12259 | } |
12750 | } |
12260 | 12751 | ||
Line 12265... | Line 12756... | ||
12265 | if (IS_VALLEYVIEW(dev)) |
12756 | if (IS_VALLEYVIEW(dev)) |
12266 | vlv_update_cdclk(dev); |
12757 | vlv_update_cdclk(dev); |
Line 12267... | Line 12758... | ||
12267 | 12758 | ||
Line 12268... | Line -... | ||
12268 | intel_init_clock_gating(dev); |
- | |
12269 | - | ||
12270 | intel_reset_dpio(dev); |
12759 | intel_init_clock_gating(dev); |
12271 | 12760 | ||
Line 12272... | Line -... | ||
12272 | intel_enable_gt_powersave(dev); |
- | |
12273 | } |
- | |
12274 | - | ||
12275 | void intel_modeset_suspend_hw(struct drm_device *dev) |
- | |
12276 | { |
- | |
12277 | intel_suspend_hw(dev); |
12761 | intel_enable_gt_powersave(dev); |
12278 | } |
12762 | } |
12279 | 12763 | ||
12280 | void intel_modeset_init(struct drm_device *dev) |
12764 | void intel_modeset_init(struct drm_device *dev) |
12281 | { |
12765 | { |
Line 12326... | Line 12810... | ||
12326 | 12810 | ||
12327 | DRM_DEBUG_KMS("%d display pipe%s available.\n", |
12811 | DRM_DEBUG_KMS("%d display pipe%s available.\n", |
12328 | INTEL_INFO(dev)->num_pipes, |
12812 | INTEL_INFO(dev)->num_pipes, |
Line 12329... | Line 12813... | ||
12329 | INTEL_INFO(dev)->num_pipes > 1 ? "s" : ""); |
12813 | INTEL_INFO(dev)->num_pipes > 1 ? "s" : ""); |
12330 | 12814 | ||
12331 | for_each_pipe(pipe) { |
12815 | for_each_pipe(dev_priv, pipe) { |
12332 | intel_crtc_init(dev, pipe); |
12816 | intel_crtc_init(dev, pipe); |
12333 | for_each_sprite(pipe, sprite) { |
12817 | for_each_sprite(pipe, sprite) { |
12334 | ret = intel_plane_init(dev, pipe, sprite); |
12818 | ret = intel_plane_init(dev, pipe, sprite); |
12335 | if (ret) |
12819 | if (ret) |
12336 | DRM_DEBUG_KMS("pipe %c sprite %c init failed: %d\n", |
12820 | DRM_DEBUG_KMS("pipe %c sprite %c init failed: %d\n", |
12337 | pipe_name(pipe), sprite_name(pipe, sprite), ret); |
12821 | pipe_name(pipe), sprite_name(pipe, sprite), ret); |
Line 12338... | Line 12822... | ||
12338 | } |
12822 | } |
12339 | } |
- | |
Line 12340... | Line 12823... | ||
12340 | 12823 | } |
|
Line -... | Line 12824... | ||
- | 12824 | ||
- | 12825 | intel_init_dpio(dev); |
|
12341 | intel_init_dpio(dev); |
12826 | |
12342 | intel_reset_dpio(dev); |
12827 | intel_shared_dpll_init(dev); |
12343 | 12828 | ||
Line 12344... | Line 12829... | ||
12344 | intel_shared_dpll_init(dev); |
12829 | /* save the BIOS value before clobbering it */ |
Line 12432... | Line 12917... | ||
12432 | /* Clear any frame start delays used for debugging left by the BIOS */ |
12917 | /* Clear any frame start delays used for debugging left by the BIOS */ |
12433 | reg = PIPECONF(crtc->config.cpu_transcoder); |
12918 | reg = PIPECONF(crtc->config.cpu_transcoder); |
12434 | I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK); |
12919 | I915_WRITE(reg, I915_READ(reg) & ~PIPECONF_FRAME_START_DELAY_MASK); |
Line 12435... | Line 12920... | ||
12435 | 12920 | ||
12436 | /* restore vblank interrupts to correct state */ |
12921 | /* restore vblank interrupts to correct state */ |
- | 12922 | if (crtc->active) { |
|
12437 | if (crtc->active) |
12923 | update_scanline_offset(crtc); |
12438 | drm_vblank_on(dev, crtc->pipe); |
12924 | drm_vblank_on(dev, crtc->pipe); |
12439 | else |
12925 | } else |
Line 12440... | Line 12926... | ||
12440 | drm_vblank_off(dev, crtc->pipe); |
12926 | drm_vblank_off(dev, crtc->pipe); |
12441 | 12927 | ||
12442 | /* We need to sanitize the plane -> pipe mapping first because this will |
12928 | /* We need to sanitize the plane -> pipe mapping first because this will |
Line 12517... | Line 13003... | ||
12517 | WARN_ON(encoder->connectors_active); |
13003 | WARN_ON(encoder->connectors_active); |
12518 | encoder->base.crtc = NULL; |
13004 | encoder->base.crtc = NULL; |
12519 | } |
13005 | } |
12520 | } |
13006 | } |
Line 12521... | Line 13007... | ||
12521 | 13007 | ||
12522 | if (crtc->active || IS_VALLEYVIEW(dev) || INTEL_INFO(dev)->gen < 5) { |
13008 | if (crtc->active || HAS_GMCH_DISPLAY(dev)) { |
12523 | /* |
13009 | /* |
12524 | * We start out with underrun reporting disabled to avoid races. |
13010 | * We start out with underrun reporting disabled to avoid races. |
12525 | * For correct bookkeeping mark this on active crtcs. |
13011 | * For correct bookkeeping mark this on active crtcs. |
12526 | * |
13012 | * |
Line 12533... | Line 13019... | ||
12533 | * No protection against concurrent access is required - at |
13019 | * No protection against concurrent access is required - at |
12534 | * worst a fifo underrun happens which also sets this to false. |
13020 | * worst a fifo underrun happens which also sets this to false. |
12535 | */ |
13021 | */ |
12536 | crtc->cpu_fifo_underrun_disabled = true; |
13022 | crtc->cpu_fifo_underrun_disabled = true; |
12537 | crtc->pch_fifo_underrun_disabled = true; |
13023 | crtc->pch_fifo_underrun_disabled = true; |
12538 | - | ||
12539 | update_scanline_offset(crtc); |
- | |
12540 | } |
13024 | } |
12541 | } |
13025 | } |
Line 12542... | Line 13026... | ||
12542 | 13026 | ||
12543 | static void intel_sanitize_encoder(struct intel_encoder *encoder) |
13027 | static void intel_sanitize_encoder(struct intel_encoder *encoder) |
Line 12607... | Line 13091... | ||
12607 | * structures are not yet restored. Since this function is at a very |
13091 | * structures are not yet restored. Since this function is at a very |
12608 | * paranoid "someone might have enabled VGA while we were not looking" |
13092 | * paranoid "someone might have enabled VGA while we were not looking" |
12609 | * level, just check if the power well is enabled instead of trying to |
13093 | * level, just check if the power well is enabled instead of trying to |
12610 | * follow the "don't touch the power well if we don't need it" policy |
13094 | * follow the "don't touch the power well if we don't need it" policy |
12611 | * the rest of the driver uses. */ |
13095 | * the rest of the driver uses. */ |
12612 | if (!intel_display_power_enabled(dev_priv, POWER_DOMAIN_VGA)) |
13096 | if (!intel_display_power_is_enabled(dev_priv, POWER_DOMAIN_VGA)) |
12613 | return; |
13097 | return; |
Line 12614... | Line 13098... | ||
12614 | 13098 | ||
12615 | i915_redisable_vga_power_on(dev); |
13099 | i915_redisable_vga_power_on(dev); |
Line 12651... | Line 13135... | ||
12651 | } |
13135 | } |
Line 12652... | Line 13136... | ||
12652 | 13136 | ||
12653 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
13137 | for (i = 0; i < dev_priv->num_shared_dpll; i++) { |
Line 12654... | Line 13138... | ||
12654 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
13138 | struct intel_shared_dpll *pll = &dev_priv->shared_dplls[i]; |
- | 13139 | ||
12655 | 13140 | pll->on = pll->get_hw_state(dev_priv, pll, |
|
- | 13141 | &pll->config.hw_state); |
|
12656 | pll->on = pll->get_hw_state(dev_priv, pll, &pll->hw_state); |
13142 | pll->active = 0; |
12657 | pll->active = 0; |
13143 | pll->config.crtc_mask = 0; |
12658 | for_each_intel_crtc(dev, crtc) { |
13144 | for_each_intel_crtc(dev, crtc) { |
- | 13145 | if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) { |
|
- | 13146 | pll->active++; |
|
12659 | if (crtc->active && intel_crtc_to_shared_dpll(crtc) == pll) |
13147 | pll->config.crtc_mask |= 1 << crtc->pipe; |
12660 | pll->active++; |
- | |
Line 12661... | Line 13148... | ||
12661 | } |
13148 | } |
12662 | pll->refcount = pll->active; |
13149 | } |
Line 12663... | Line 13150... | ||
12663 | 13150 | ||
12664 | DRM_DEBUG_KMS("%s hw state readout: refcount %i, on %i\n", |
13151 | DRM_DEBUG_KMS("%s hw state readout: crtc_mask 0x%08x, on %i\n", |
12665 | pll->name, pll->refcount, pll->on); |
13152 | pll->name, pll->config.crtc_mask, pll->on); |
Line 12666... | Line 13153... | ||
12666 | 13153 | ||
12667 | if (pll->refcount) |
- | |
12668 | intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS); |
13154 | if (pll->config.crtc_mask) |
Line 12669... | Line 13155... | ||
12669 | } |
13155 | intel_display_power_get(dev_priv, POWER_DOMAIN_PLLS); |
12670 | 13156 | } |
|
12671 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
13157 | |
Line 12731... | Line 13217... | ||
12731 | drm_mode_debug_printmodeline(&crtc->base.mode); |
13217 | drm_mode_debug_printmodeline(&crtc->base.mode); |
12732 | } |
13218 | } |
12733 | } |
13219 | } |
Line 12734... | Line 13220... | ||
12734 | 13220 | ||
12735 | /* HW state is read out, now we need to sanitize this mess. */ |
13221 | /* HW state is read out, now we need to sanitize this mess. */ |
12736 | list_for_each_entry(encoder, &dev->mode_config.encoder_list, |
- | |
12737 | base.head) { |
13222 | for_each_intel_encoder(dev, encoder) { |
12738 | intel_sanitize_encoder(encoder); |
13223 | intel_sanitize_encoder(encoder); |
Line 12739... | Line 13224... | ||
12739 | } |
13224 | } |
12740 | 13225 | ||
12741 | for_each_pipe(pipe) { |
13226 | for_each_pipe(dev_priv, pipe) { |
12742 | crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
13227 | crtc = to_intel_crtc(dev_priv->pipe_to_crtc_mapping[pipe]); |
12743 | intel_sanitize_crtc(crtc); |
13228 | intel_sanitize_crtc(crtc); |
Line 12754... | Line 13239... | ||
12754 | 13239 | ||
12755 | pll->disable(dev_priv, pll); |
13240 | pll->disable(dev_priv, pll); |
12756 | pll->on = false; |
13241 | pll->on = false; |
Line -... | Line 13242... | ||
- | 13242 | } |
|
- | 13243 | ||
12757 | } |
13244 | if (IS_GEN9(dev)) |
12758 | 13245 | skl_wm_get_hw_state(dev); |
|
Line 12759... | Line 13246... | ||
12759 | if (HAS_PCH_SPLIT(dev)) |
13246 | else if (HAS_PCH_SPLIT(dev)) |
12760 | ilk_wm_get_hw_state(dev); |
13247 | ilk_wm_get_hw_state(dev); |
Line 12761... | Line 13248... | ||
12761 | 13248 | ||
12762 | if (force_restore) { |
13249 | if (force_restore) { |
12763 | i915_redisable_vga(dev); |
13250 | i915_redisable_vga(dev); |
12764 | 13251 | ||
12765 | /* |
13252 | /* |
12766 | * We need to use raw interfaces for restoring state to avoid |
13253 | * We need to use raw interfaces for restoring state to avoid |
12767 | * checking (bogus) intermediate states. |
13254 | * checking (bogus) intermediate states. |
Line 12768... | Line 13255... | ||
12768 | */ |
13255 | */ |
12769 | for_each_pipe(pipe) { |
13256 | for_each_pipe(dev_priv, pipe) { |
12770 | struct drm_crtc *crtc = |
13257 | struct drm_crtc *crtc = |
12771 | dev_priv->pipe_to_crtc_mapping[pipe]; |
13258 | dev_priv->pipe_to_crtc_mapping[pipe]; |
12772 | 13259 | ||
12773 | __intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, |
13260 | intel_set_mode(crtc, &crtc->mode, crtc->x, crtc->y, |
Line 12780... | Line 13267... | ||
12780 | intel_modeset_check_state(dev); |
13267 | intel_modeset_check_state(dev); |
12781 | } |
13268 | } |
Line 12782... | Line 13269... | ||
12782 | 13269 | ||
12783 | void intel_modeset_gem_init(struct drm_device *dev) |
13270 | void intel_modeset_gem_init(struct drm_device *dev) |
- | 13271 | { |
|
12784 | { |
13272 | struct drm_i915_private *dev_priv = dev->dev_private; |
12785 | struct drm_crtc *c; |
13273 | struct drm_crtc *c; |
Line 12786... | Line 13274... | ||
12786 | struct drm_i915_gem_object *obj; |
13274 | struct drm_i915_gem_object *obj; |
12787 | 13275 | ||
12788 | mutex_lock(&dev->struct_mutex); |
13276 | mutex_lock(&dev->struct_mutex); |
Line -... | Line 13277... | ||
- | 13277 | intel_init_gt_powersave(dev); |
|
- | 13278 | mutex_unlock(&dev->struct_mutex); |
|
- | 13279 | ||
- | 13280 | /* |
|
- | 13281 | * There may be no VBT; and if the BIOS enabled SSC we can |
|
- | 13282 | * just keep using it to avoid unnecessary flicker. Whereas if the |
|
- | 13283 | * BIOS isn't using it, don't assume it will work even if the VBT |
|
- | 13284 | * indicates as much. |
|
- | 13285 | */ |
|
- | 13286 | if (HAS_PCH_IBX(dev) || HAS_PCH_CPT(dev)) |
|
12789 | intel_init_gt_powersave(dev); |
13287 | dev_priv->vbt.lvds_use_ssc = !!(I915_READ(PCH_DREF_CONTROL) & |
Line 12790... | Line 13288... | ||
12790 | mutex_unlock(&dev->struct_mutex); |
13288 | DREF_SSC1_ENABLE); |
Line 12791... | Line 13289... | ||
12791 | 13289 | ||
Line 12802... | Line 13300... | ||
12802 | for_each_crtc(dev, c) { |
13300 | for_each_crtc(dev, c) { |
12803 | obj = intel_fb_obj(c->primary->fb); |
13301 | obj = intel_fb_obj(c->primary->fb); |
12804 | if (obj == NULL) |
13302 | if (obj == NULL) |
12805 | continue; |
13303 | continue; |
Line 12806... | Line 13304... | ||
12806 | 13304 | ||
- | 13305 | if (intel_pin_and_fence_fb_obj(c->primary, |
|
- | 13306 | c->primary->fb, |
|
12807 | if (intel_pin_and_fence_fb_obj(dev, obj, NULL)) { |
13307 | NULL)) { |
12808 | DRM_ERROR("failed to pin boot fb on pipe %d\n", |
13308 | DRM_ERROR("failed to pin boot fb on pipe %d\n", |
12809 | to_intel_crtc(c)->pipe); |
13309 | to_intel_crtc(c)->pipe); |
12810 | drm_framebuffer_unreference(c->primary->fb); |
13310 | drm_framebuffer_unreference(c->primary->fb); |
12811 | c->primary->fb = NULL; |
13311 | c->primary->fb = NULL; |
Line 12826... | Line 13326... | ||
12826 | { |
13326 | { |
12827 | #if 0 |
13327 | #if 0 |
12828 | struct drm_i915_private *dev_priv = dev->dev_private; |
13328 | struct drm_i915_private *dev_priv = dev->dev_private; |
12829 | struct drm_connector *connector; |
13329 | struct drm_connector *connector; |
Line -... | Line 13330... | ||
- | 13330 | ||
- | 13331 | intel_disable_gt_powersave(dev); |
|
- | 13332 | ||
- | 13333 | intel_backlight_unregister(dev); |
|
12830 | 13334 | ||
12831 | /* |
13335 | /* |
12832 | * Interrupts and polling as the first thing to avoid creating havoc. |
13336 | * Interrupts and polling as the first thing to avoid creating havoc. |
12833 | * Too much stuff here (turning of rps, connectors, ...) would |
13337 | * Too much stuff here (turning of connectors, ...) would |
12834 | * experience fancy races otherwise. |
13338 | * experience fancy races otherwise. |
12835 | */ |
13339 | */ |
12836 | drm_irq_uninstall(dev); |
- | |
12837 | intel_hpd_cancel_work(dev_priv); |
- | |
Line 12838... | Line 13340... | ||
12838 | dev_priv->pm._irqs_disabled = true; |
13340 | intel_irq_uninstall(dev_priv); |
12839 | 13341 | ||
12840 | /* |
13342 | /* |
12841 | * Due to the hpd irq storm handling the hotplug work can re-arm the |
13343 | * Due to the hpd irq storm handling the hotplug work can re-arm the |
Line 12847... | Line 13349... | ||
12847 | 13349 | ||
Line 12848... | Line 13350... | ||
12848 | intel_unregister_dsm_handler(); |
13350 | intel_unregister_dsm_handler(); |
Line 12849... | Line -... | ||
12849 | - | ||
12850 | intel_disable_fbc(dev); |
- | |
12851 | 13351 | ||
Line 12852... | Line 13352... | ||
12852 | intel_disable_gt_powersave(dev); |
13352 | intel_disable_fbc(dev); |
Line 12853... | Line 13353... | ||
12853 | 13353 | ||
Line 12989... | Line 13489... | ||
12989 | return NULL; |
13489 | return NULL; |
Line 12990... | Line 13490... | ||
12990 | 13490 | ||
12991 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
13491 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
Line 12992... | Line 13492... | ||
12992 | error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER); |
13492 | error->power_well_driver = I915_READ(HSW_PWR_WELL_DRIVER); |
12993 | 13493 | ||
12994 | for_each_pipe(i) { |
13494 | for_each_pipe(dev_priv, i) { |
12995 | error->pipe[i].power_domain_on = |
13495 | error->pipe[i].power_domain_on = |
12996 | intel_display_power_enabled_unlocked(dev_priv, |
13496 | __intel_display_power_is_enabled(dev_priv, |
12997 | POWER_DOMAIN_PIPE(i)); |
13497 | POWER_DOMAIN_PIPE(i)); |
Line 12998... | Line 13498... | ||
12998 | if (!error->pipe[i].power_domain_on) |
13498 | if (!error->pipe[i].power_domain_on) |
Line 13027... | Line 13527... | ||
13027 | 13527 | ||
13028 | for (i = 0; i < error->num_transcoders; i++) { |
13528 | for (i = 0; i < error->num_transcoders; i++) { |
Line 13029... | Line 13529... | ||
13029 | enum transcoder cpu_transcoder = transcoders[i]; |
13529 | enum transcoder cpu_transcoder = transcoders[i]; |
13030 | 13530 | ||
13031 | error->transcoder[i].power_domain_on = |
13531 | error->transcoder[i].power_domain_on = |
13032 | intel_display_power_enabled_unlocked(dev_priv, |
13532 | __intel_display_power_is_enabled(dev_priv, |
13033 | POWER_DOMAIN_TRANSCODER(cpu_transcoder)); |
13533 | POWER_DOMAIN_TRANSCODER(cpu_transcoder)); |
Line 13034... | Line 13534... | ||
13034 | if (!error->transcoder[i].power_domain_on) |
13534 | if (!error->transcoder[i].power_domain_on) |
Line 13053... | Line 13553... | ||
13053 | void |
13553 | void |
13054 | intel_display_print_error_state(struct drm_i915_error_state_buf *m, |
13554 | intel_display_print_error_state(struct drm_i915_error_state_buf *m, |
13055 | struct drm_device *dev, |
13555 | struct drm_device *dev, |
13056 | struct intel_display_error_state *error) |
13556 | struct intel_display_error_state *error) |
13057 | { |
13557 | { |
- | 13558 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
13058 | int i; |
13559 | int i; |
Line 13059... | Line 13560... | ||
13059 | 13560 | ||
13060 | if (!error) |
13561 | if (!error) |
Line 13061... | Line 13562... | ||
13061 | return; |
13562 | return; |
13062 | 13563 | ||
13063 | err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes); |
13564 | err_printf(m, "Num Pipes: %d\n", INTEL_INFO(dev)->num_pipes); |
13064 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
13565 | if (IS_HASWELL(dev) || IS_BROADWELL(dev)) |
13065 | err_printf(m, "PWR_WELL_CTL2: %08x\n", |
13566 | err_printf(m, "PWR_WELL_CTL2: %08x\n", |
13066 | error->power_well_driver); |
13567 | error->power_well_driver); |
13067 | for_each_pipe(i) { |
13568 | for_each_pipe(dev_priv, i) { |
13068 | err_printf(m, "Pipe [%d]:\n", i); |
13569 | err_printf(m, "Pipe [%d]:\n", i); |
13069 | err_printf(m, " Power: %s\n", |
13570 | err_printf(m, " Power: %s\n", |
13070 | error->pipe[i].power_domain_on ? "on" : "off"); |
13571 | error->pipe[i].power_domain_on ? "on" : "off"); |
Line 13104... | Line 13605... | ||
13104 | err_printf(m, " VBLANK: %08x\n", error->transcoder[i].vblank); |
13605 | err_printf(m, " VBLANK: %08x\n", error->transcoder[i].vblank); |
13105 | err_printf(m, " VSYNC: %08x\n", error->transcoder[i].vsync); |
13606 | err_printf(m, " VSYNC: %08x\n", error->transcoder[i].vsync); |
13106 | } |
13607 | } |
13107 | } |
13608 | } |
13108 | #endif>=>=>>=>=>>>>>5,><5,>>>>>>>><>>>=>>>>>>>>>(intel_crtc)-><(intel_crtc)->>><>><>><>><>><>><>><>><>><>><>><>>>><>><>>>>>>><>>>>><>>><>><>=>>><>><>=>>><>><>>><>><>><>><>>><>><>><>><>>>>>><>><>><>><>><>>>><>><>><>><>->>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>><>>><>>=>>><>><>><>><>><>><>><>>>><>><>><>><>>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>><>><>=>>=>=>><>><>><>><>><>><>><>><>><>>><>><>>>>><>><>><>><>><>><>><>>>>>>>>>>>>><>><>><>><>>>>>>><>>><>>>=>=>>=>>>=>=>=>=>>>=>=>=>=>>>>>>>>>>=>=>>>>>>>>>><>><>><>=> |
13609 | #endif |
- | 13610 | ||
- | 13611 | void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file) |
|
- | 13612 | { |
|
- | 13613 | struct intel_crtc *crtc; |
|
- | 13614 | ||
- | 13615 | for_each_intel_crtc(dev, crtc) { |
|
- | 13616 | struct intel_unpin_work *work; |
|
- | 13617 | ||
- | 13618 | spin_lock_irq(&dev->event_lock); |
|
- | 13619 | ||
- | 13620 | work = crtc->unpin_work; |
|
- | 13621 | ||
- | 13622 | if (work && work->event && |
|
- | 13623 | work->event->base.file_priv == file) { |
|
- | 13624 | kfree(work->event); |
|
- | 13625 | work->event = NULL; |
|
- | 13626 | } |
|
- | 13627 | ||
- | 13628 | spin_unlock_irq(&dev->event_lock); |
|
- | 13629 | } |
|
- | 13630 | }>=>=>>=>=>>><>>>5,><5,>>>>>>>><>>>>=>>=>>>>>>>>>>(intel_crtc)-><(intel_crtc)->>><>><>><>><>><>><>><>><>><>><>><>>>><>><>><>>>>>>><>>>>><>><>=>>><>><>=>>><>><>>>>>>><>><>><>><>><>>>><>><>><>><>->>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>><>>><>>=>>><>><>><>><>><>><>><>>>><>><>><>><>>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>><>>>>><>><>><>><>>><>><>=>>=>=>><>><>><>><>><>><>><>><>><>>><>><>>>>>><>>>><>><>><>><>><>><>><>><>><>>>>>>>>>>>>><>><>><>><>><>><>><>><>>>>><>>><>>>=>=>>=>>>=>=>=>=>>>=>=>=>=>>>>>>>>>>=>=>>>>>>>>>><>><>><>=> |