diff options
author | Paulo Zanoni <paulo.r.zanoni@intel.com> | 2012-09-20 17:36:05 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-09-25 04:40:04 -0400 |
commit | de13a2e3f88a4da8e85063b6de37096795079e41 (patch) | |
tree | 904b731641c6dbd4855faeb069d91e76d439568c /drivers/gpu/drm/i915/intel_display.c | |
parent | f48d8f235a9e3d2331b25743807340fc65b86587 (diff) |
drm/i915: extract compute_dpll from ironlake_crtc_mode_set
Too many lines just to compute the value of a single variable, so
move this to its own function.
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm/i915/intel_display.c')
-rw-r--r-- | drivers/gpu/drm/i915/intel_display.c | 149 |
1 files changed, 97 insertions, 52 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index e92c6d329137..c7fa2a82c84a 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
@@ -4783,53 +4783,39 @@ static void ironlake_set_m_n(struct drm_crtc *crtc, | |||
4783 | I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n); | 4783 | I915_WRITE(PIPE_LINK_N1(pipe), m_n.link_n); |
4784 | } | 4784 | } |
4785 | 4785 | ||
4786 | static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | 4786 | static uint32_t ironlake_compute_dpll(struct intel_crtc *intel_crtc, |
4787 | struct drm_display_mode *mode, | 4787 | struct drm_display_mode *adjusted_mode, |
4788 | struct drm_display_mode *adjusted_mode, | 4788 | intel_clock_t *clock, u32 fp) |
4789 | int x, int y, | ||
4790 | struct drm_framebuffer *fb) | ||
4791 | { | 4789 | { |
4790 | struct drm_crtc *crtc = &intel_crtc->base; | ||
4792 | struct drm_device *dev = crtc->dev; | 4791 | struct drm_device *dev = crtc->dev; |
4793 | struct drm_i915_private *dev_priv = dev->dev_private; | 4792 | struct drm_i915_private *dev_priv = dev->dev_private; |
4794 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | 4793 | struct intel_encoder *intel_encoder; |
4795 | int pipe = intel_crtc->pipe; | 4794 | uint32_t dpll; |
4796 | int plane = intel_crtc->plane; | 4795 | int factor, pixel_multiplier, num_connectors = 0; |
4797 | int num_connectors = 0; | 4796 | bool is_lvds = false, is_sdvo = false, is_tv = false; |
4798 | intel_clock_t clock, reduced_clock; | 4797 | bool is_dp = false, is_cpu_edp = false; |
4799 | u32 dpll, fp = 0, fp2 = 0; | ||
4800 | bool ok, has_reduced_clock = false, is_sdvo = false; | ||
4801 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | ||
4802 | struct intel_encoder *encoder; | ||
4803 | u32 temp; | ||
4804 | int ret, factor; | ||
4805 | bool dither; | ||
4806 | bool is_cpu_edp = false, is_pch_edp = false; | ||
4807 | 4798 | ||
4808 | for_each_encoder_on_crtc(dev, crtc, encoder) { | 4799 | for_each_encoder_on_crtc(dev, crtc, intel_encoder) { |
4809 | switch (encoder->type) { | 4800 | switch (intel_encoder->type) { |
4810 | case INTEL_OUTPUT_LVDS: | 4801 | case INTEL_OUTPUT_LVDS: |
4811 | is_lvds = true; | 4802 | is_lvds = true; |
4812 | break; | 4803 | break; |
4813 | case INTEL_OUTPUT_SDVO: | 4804 | case INTEL_OUTPUT_SDVO: |
4814 | case INTEL_OUTPUT_HDMI: | 4805 | case INTEL_OUTPUT_HDMI: |
4815 | is_sdvo = true; | 4806 | is_sdvo = true; |
4816 | if (encoder->needs_tv_clock) | 4807 | if (intel_encoder->needs_tv_clock) |
4817 | is_tv = true; | 4808 | is_tv = true; |
4818 | break; | 4809 | break; |
4819 | case INTEL_OUTPUT_TVOUT: | 4810 | case INTEL_OUTPUT_TVOUT: |
4820 | is_tv = true; | 4811 | is_tv = true; |
4821 | break; | 4812 | break; |
4822 | case INTEL_OUTPUT_ANALOG: | ||
4823 | is_crt = true; | ||
4824 | break; | ||
4825 | case INTEL_OUTPUT_DISPLAYPORT: | 4813 | case INTEL_OUTPUT_DISPLAYPORT: |
4826 | is_dp = true; | 4814 | is_dp = true; |
4827 | break; | 4815 | break; |
4828 | case INTEL_OUTPUT_EDP: | 4816 | case INTEL_OUTPUT_EDP: |
4829 | is_dp = true; | 4817 | is_dp = true; |
4830 | if (intel_encoder_is_pch_edp(&encoder->base)) | 4818 | if (!intel_encoder_is_pch_edp(&intel_encoder->base)) |
4831 | is_pch_edp = true; | ||
4832 | else | ||
4833 | is_cpu_edp = true; | 4819 | is_cpu_edp = true; |
4834 | break; | 4820 | break; |
4835 | } | 4821 | } |
@@ -4837,26 +4823,6 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4837 | num_connectors++; | 4823 | num_connectors++; |
4838 | } | 4824 | } |
4839 | 4825 | ||
4840 | ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock, | ||
4841 | &has_reduced_clock, &reduced_clock); | ||
4842 | if (!ok) { | ||
4843 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); | ||
4844 | return -EINVAL; | ||
4845 | } | ||
4846 | |||
4847 | /* Ensure that the cursor is valid for the new mode before changing... */ | ||
4848 | intel_crtc_update_cursor(crtc, true); | ||
4849 | |||
4850 | /* determine panel color depth */ | ||
4851 | dither = intel_choose_pipe_bpp_dither(crtc, fb, &intel_crtc->bpp, mode); | ||
4852 | if (is_lvds && dev_priv->lvds_dither) | ||
4853 | dither = true; | ||
4854 | |||
4855 | fp = clock.n << 16 | clock.m1 << 8 | clock.m2; | ||
4856 | if (has_reduced_clock) | ||
4857 | fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 | | ||
4858 | reduced_clock.m2; | ||
4859 | |||
4860 | /* Enable autotuning of the PLL clock (if permissible) */ | 4826 | /* Enable autotuning of the PLL clock (if permissible) */ |
4861 | factor = 21; | 4827 | factor = 21; |
4862 | if (is_lvds) { | 4828 | if (is_lvds) { |
@@ -4867,7 +4833,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4867 | } else if (is_sdvo && is_tv) | 4833 | } else if (is_sdvo && is_tv) |
4868 | factor = 20; | 4834 | factor = 20; |
4869 | 4835 | ||
4870 | if (clock.m < factor * clock.n) | 4836 | if (clock->m < factor * clock->n) |
4871 | fp |= FP_CB_TUNE; | 4837 | fp |= FP_CB_TUNE; |
4872 | 4838 | ||
4873 | dpll = 0; | 4839 | dpll = 0; |
@@ -4877,7 +4843,7 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4877 | else | 4843 | else |
4878 | dpll |= DPLLB_MODE_DAC_SERIAL; | 4844 | dpll |= DPLLB_MODE_DAC_SERIAL; |
4879 | if (is_sdvo) { | 4845 | if (is_sdvo) { |
4880 | int pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); | 4846 | pixel_multiplier = intel_mode_get_pixel_multiplier(adjusted_mode); |
4881 | if (pixel_multiplier > 1) { | 4847 | if (pixel_multiplier > 1) { |
4882 | dpll |= (pixel_multiplier - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; | 4848 | dpll |= (pixel_multiplier - 1) << PLL_REF_SDVO_HDMI_MULTIPLIER_SHIFT; |
4883 | } | 4849 | } |
@@ -4887,11 +4853,11 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4887 | dpll |= DPLL_DVO_HIGH_SPEED; | 4853 | dpll |= DPLL_DVO_HIGH_SPEED; |
4888 | 4854 | ||
4889 | /* compute bitmask from p1 value */ | 4855 | /* compute bitmask from p1 value */ |
4890 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; | 4856 | dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA01_P1_POST_DIV_SHIFT; |
4891 | /* also FPA1 */ | 4857 | /* also FPA1 */ |
4892 | dpll |= (1 << (clock.p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; | 4858 | dpll |= (1 << (clock->p1 - 1)) << DPLL_FPA1_P1_POST_DIV_SHIFT; |
4893 | 4859 | ||
4894 | switch (clock.p2) { | 4860 | switch (clock->p2) { |
4895 | case 5: | 4861 | case 5: |
4896 | dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5; | 4862 | dpll |= DPLL_DAC_SERIAL_P2_CLOCK_DIV_5; |
4897 | break; | 4863 | break; |
@@ -4917,6 +4883,85 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | |||
4917 | else | 4883 | else |
4918 | dpll |= PLL_REF_INPUT_DREFCLK; | 4884 | dpll |= PLL_REF_INPUT_DREFCLK; |
4919 | 4885 | ||
4886 | return dpll; | ||
4887 | } | ||
4888 | |||
4889 | static int ironlake_crtc_mode_set(struct drm_crtc *crtc, | ||
4890 | struct drm_display_mode *mode, | ||
4891 | struct drm_display_mode *adjusted_mode, | ||
4892 | int x, int y, | ||
4893 | struct drm_framebuffer *fb) | ||
4894 | { | ||
4895 | struct drm_device *dev = crtc->dev; | ||
4896 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
4897 | struct intel_crtc *intel_crtc = to_intel_crtc(crtc); | ||
4898 | int pipe = intel_crtc->pipe; | ||
4899 | int plane = intel_crtc->plane; | ||
4900 | int num_connectors = 0; | ||
4901 | intel_clock_t clock, reduced_clock; | ||
4902 | u32 dpll, fp = 0, fp2 = 0; | ||
4903 | bool ok, has_reduced_clock = false, is_sdvo = false; | ||
4904 | bool is_crt = false, is_lvds = false, is_tv = false, is_dp = false; | ||
4905 | struct intel_encoder *encoder; | ||
4906 | u32 temp; | ||
4907 | int ret; | ||
4908 | bool dither; | ||
4909 | bool is_cpu_edp = false, is_pch_edp = false; | ||
4910 | |||
4911 | for_each_encoder_on_crtc(dev, crtc, encoder) { | ||
4912 | switch (encoder->type) { | ||
4913 | case INTEL_OUTPUT_LVDS: | ||
4914 | is_lvds = true; | ||
4915 | break; | ||
4916 | case INTEL_OUTPUT_SDVO: | ||
4917 | case INTEL_OUTPUT_HDMI: | ||
4918 | is_sdvo = true; | ||
4919 | if (encoder->needs_tv_clock) | ||
4920 | is_tv = true; | ||
4921 | break; | ||
4922 | case INTEL_OUTPUT_TVOUT: | ||
4923 | is_tv = true; | ||
4924 | break; | ||
4925 | case INTEL_OUTPUT_ANALOG: | ||
4926 | is_crt = true; | ||
4927 | break; | ||
4928 | case INTEL_OUTPUT_DISPLAYPORT: | ||
4929 | is_dp = true; | ||
4930 | break; | ||
4931 | case INTEL_OUTPUT_EDP: | ||
4932 | is_dp = true; | ||
4933 | if (intel_encoder_is_pch_edp(&encoder->base)) | ||
4934 | is_pch_edp = true; | ||
4935 | else | ||
4936 | is_cpu_edp = true; | ||
4937 | break; | ||
4938 | } | ||
4939 | |||
4940 | num_connectors++; | ||
4941 | } | ||
4942 | |||
4943 | ok = ironlake_compute_clocks(crtc, adjusted_mode, &clock, | ||
4944 | &has_reduced_clock, &reduced_clock); | ||
4945 | if (!ok) { | ||
4946 | DRM_ERROR("Couldn't find PLL settings for mode!\n"); | ||
4947 | return -EINVAL; | ||
4948 | } | ||
4949 | |||
4950 | /* Ensure that the cursor is valid for the new mode before changing... */ | ||
4951 | intel_crtc_update_cursor(crtc, true); | ||
4952 | |||
4953 | /* determine panel color depth */ | ||
4954 | dither = intel_choose_pipe_bpp_dither(crtc, fb, &intel_crtc->bpp, mode); | ||
4955 | if (is_lvds && dev_priv->lvds_dither) | ||
4956 | dither = true; | ||
4957 | |||
4958 | fp = clock.n << 16 | clock.m1 << 8 | clock.m2; | ||
4959 | if (has_reduced_clock) | ||
4960 | fp2 = reduced_clock.n << 16 | reduced_clock.m1 << 8 | | ||
4961 | reduced_clock.m2; | ||
4962 | |||
4963 | dpll = ironlake_compute_dpll(intel_crtc, adjusted_mode, &clock, fp); | ||
4964 | |||
4920 | DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe); | 4965 | DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe); |
4921 | drm_mode_debug_printmodeline(mode); | 4966 | drm_mode_debug_printmodeline(mode); |
4922 | 4967 | ||