aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-04-02 17:42:31 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-04-03 05:29:26 -0400
commit03afc4a2618e579eab402d0b4e8b035bd873286a (patch)
tree8f93b54602b716c2174fa257b93528449be8160d /drivers/gpu/drm
parent6cf86a5e7acd8731fa90ce24e777f684335218dc (diff)
drm/i915: move dp_m_n computation to dp_encoder->compute_config
We need a flag to designate dp encoders and the dp link m_n parameters in the pipe config for that. And now that the pipe bpp computations have been moved up and stored in the pipe config, too, we can do this without losing our sanity. v2: Rebased on top of Takashi Iwai's fix to (again) fix the target clock handling for eDP. Luckily the new code is sane enough and just does the right thing! v3: Move ->has_dp_encoder to this patch (Jesse). Reviewed-by: Jesse Barnes <jbarnes@virtuousgeek.org> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r--drivers/gpu/drm/i915/intel_display.c30
-rw-r--r--drivers/gpu/drm/i915/intel_dp.c59
-rw-r--r--drivers/gpu/drm/i915/intel_drv.h6
3 files changed, 28 insertions, 67 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 06dacca8257c..21d8a20d9920 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4202,6 +4202,14 @@ static void i9xx_update_pll_dividers(struct drm_crtc *crtc,
4202 } 4202 }
4203} 4203}
4204 4204
4205static void intel_dp_set_m_n(struct intel_crtc *crtc)
4206{
4207 if (crtc->config.has_pch_encoder)
4208 intel_pch_transcoder_set_m_n(crtc, &crtc->config.dp_m_n);
4209 else
4210 intel_cpu_transcoder_set_m_n(crtc, &crtc->config.dp_m_n);
4211}
4212
4205static void vlv_update_pll(struct drm_crtc *crtc, 4213static void vlv_update_pll(struct drm_crtc *crtc,
4206 intel_clock_t *clock, intel_clock_t *reduced_clock, 4214 intel_clock_t *clock, intel_clock_t *reduced_clock,
4207 int num_connectors) 4215 int num_connectors)
@@ -4209,9 +4217,6 @@ static void vlv_update_pll(struct drm_crtc *crtc,
4209 struct drm_device *dev = crtc->dev; 4217 struct drm_device *dev = crtc->dev;
4210 struct drm_i915_private *dev_priv = dev->dev_private; 4218 struct drm_i915_private *dev_priv = dev->dev_private;
4211 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4219 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4212 struct drm_display_mode *adjusted_mode =
4213 &intel_crtc->config.adjusted_mode;
4214 struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
4215 int pipe = intel_crtc->pipe; 4220 int pipe = intel_crtc->pipe;
4216 u32 dpll, mdiv, pdiv; 4221 u32 dpll, mdiv, pdiv;
4217 u32 bestn, bestm1, bestm2, bestp1, bestp2; 4222 u32 bestn, bestm1, bestm2, bestp1, bestp2;
@@ -4267,8 +4272,8 @@ static void vlv_update_pll(struct drm_crtc *crtc,
4267 4272
4268 intel_dpio_write(dev_priv, DPIO_FASTCLK_DISABLE, 0x620); 4273 intel_dpio_write(dev_priv, DPIO_FASTCLK_DISABLE, 0x620);
4269 4274
4270 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) 4275 if (intel_crtc->config.has_dp_encoder)
4271 intel_dp_set_m_n(crtc, mode, adjusted_mode); 4276 intel_dp_set_m_n(intel_crtc);
4272 4277
4273 I915_WRITE(DPLL(pipe), dpll); 4278 I915_WRITE(DPLL(pipe), dpll);
4274 4279
@@ -4314,9 +4319,6 @@ static void i9xx_update_pll(struct drm_crtc *crtc,
4314 struct drm_device *dev = crtc->dev; 4319 struct drm_device *dev = crtc->dev;
4315 struct drm_i915_private *dev_priv = dev->dev_private; 4320 struct drm_i915_private *dev_priv = dev->dev_private;
4316 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4321 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4317 struct drm_display_mode *adjusted_mode =
4318 &intel_crtc->config.adjusted_mode;
4319 struct drm_display_mode *mode = &intel_crtc->config.requested_mode;
4320 struct intel_encoder *encoder; 4322 struct intel_encoder *encoder;
4321 int pipe = intel_crtc->pipe; 4323 int pipe = intel_crtc->pipe;
4322 u32 dpll; 4324 u32 dpll;
@@ -4391,8 +4393,8 @@ static void i9xx_update_pll(struct drm_crtc *crtc,
4391 if (encoder->pre_pll_enable) 4393 if (encoder->pre_pll_enable)
4392 encoder->pre_pll_enable(encoder); 4394 encoder->pre_pll_enable(encoder);
4393 4395
4394 if (intel_pipe_has_type(crtc, INTEL_OUTPUT_DISPLAYPORT)) 4396 if (intel_crtc->config.has_dp_encoder)
4395 intel_dp_set_m_n(crtc, mode, adjusted_mode); 4397 intel_dp_set_m_n(intel_crtc);
4396 4398
4397 I915_WRITE(DPLL(pipe), dpll); 4399 I915_WRITE(DPLL(pipe), dpll);
4398 4400
@@ -5647,8 +5649,8 @@ static int ironlake_crtc_mode_set(struct drm_crtc *crtc,
5647 } else 5649 } else
5648 intel_put_pch_pll(intel_crtc); 5650 intel_put_pch_pll(intel_crtc);
5649 5651
5650 if (is_dp) 5652 if (intel_crtc->config.has_dp_encoder)
5651 intel_dp_set_m_n(crtc, mode, adjusted_mode); 5653 intel_dp_set_m_n(intel_crtc);
5652 5654
5653 for_each_encoder_on_crtc(dev, crtc, encoder) 5655 for_each_encoder_on_crtc(dev, crtc, encoder)
5654 if (encoder->pre_pll_enable) 5656 if (encoder->pre_pll_enable)
@@ -5797,8 +5799,8 @@ static int haswell_crtc_mode_set(struct drm_crtc *crtc,
5797 DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe); 5799 DRM_DEBUG_KMS("Mode for pipe %d:\n", pipe);
5798 drm_mode_debug_printmodeline(mode); 5800 drm_mode_debug_printmodeline(mode);
5799 5801
5800 if (is_dp) 5802 if (intel_crtc->config.has_dp_encoder)
5801 intel_dp_set_m_n(crtc, mode, adjusted_mode); 5803 intel_dp_set_m_n(intel_crtc);
5802 5804
5803 intel_crtc->lowfreq_avail = false; 5805 intel_crtc->lowfreq_avail = false;
5804 5806
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 5a209626e9a1..70507081141b 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -193,6 +193,8 @@ intel_dp_mode_valid(struct drm_connector *connector,
193 193
194 if (mode->vdisplay > fixed_mode->vdisplay) 194 if (mode->vdisplay > fixed_mode->vdisplay)
195 return MODE_PANEL; 195 return MODE_PANEL;
196
197 target_clock = fixed_mode->clock;
196 } 198 }
197 199
198 max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp)); 200 max_link_clock = drm_dp_bw_code_to_link_rate(intel_dp_max_link_bw(intel_dp));
@@ -697,6 +699,8 @@ intel_dp_compute_config(struct intel_encoder *encoder,
697 if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev) && !is_cpu_edp(intel_dp)) 699 if (HAS_PCH_SPLIT(dev) && !HAS_DDI(dev) && !is_cpu_edp(intel_dp))
698 pipe_config->has_pch_encoder = true; 700 pipe_config->has_pch_encoder = true;
699 701
702 pipe_config->has_dp_encoder = true;
703
700 if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) { 704 if (is_edp(intel_dp) && intel_connector->panel.fixed_mode) {
701 intel_fixed_panel_mode(intel_connector->panel.fixed_mode, 705 intel_fixed_panel_mode(intel_connector->panel.fixed_mode,
702 adjusted_mode); 706 adjusted_mode);
@@ -716,7 +720,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
716 720
717 /* Walk through all bpp values. Luckily they're all nicely spaced with 2 721 /* Walk through all bpp values. Luckily they're all nicely spaced with 2
718 * bpc in between. */ 722 * bpc in between. */
719 bpp = 8*3; 723 bpp = min_t(int, 8*3, pipe_config->pipe_bpp);
720 if (is_edp(intel_dp) && dev_priv->edp.bpp) 724 if (is_edp(intel_dp) && dev_priv->edp.bpp)
721 bpp = min_t(int, bpp, dev_priv->edp.bpp); 725 bpp = min_t(int, bpp, dev_priv->edp.bpp);
722 726
@@ -765,56 +769,11 @@ found:
765 DRM_DEBUG_KMS("DP link bw required %i available %i\n", 769 DRM_DEBUG_KMS("DP link bw required %i available %i\n",
766 mode_rate, link_avail); 770 mode_rate, link_avail);
767 771
768 return true; 772 intel_link_compute_m_n(bpp, lane_count,
769} 773 target_clock, adjusted_mode->clock,
770 774 &pipe_config->dp_m_n);
771void
772intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
773 struct drm_display_mode *adjusted_mode)
774{
775 struct drm_device *dev = crtc->dev;
776 struct intel_encoder *intel_encoder;
777 struct intel_dp *intel_dp;
778 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
779 int lane_count = 4;
780 struct intel_link_m_n m_n;
781 int target_clock;
782
783 /*
784 * Find the lane count in the intel_encoder private
785 */
786 for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
787 intel_dp = enc_to_intel_dp(&intel_encoder->base);
788
789 if (intel_encoder->type == INTEL_OUTPUT_DISPLAYPORT ||
790 intel_encoder->type == INTEL_OUTPUT_EDP)
791 {
792 lane_count = intel_dp->lane_count;
793 break;
794 }
795 }
796
797 target_clock = mode->clock;
798 for_each_encoder_on_crtc(dev, crtc, intel_encoder) {
799 if (intel_encoder->type == INTEL_OUTPUT_EDP) {
800 target_clock = intel_edp_target_clock(intel_encoder,
801 mode);
802 break;
803 }
804 }
805
806 /*
807 * Compute the GMCH and Link ratios. The '3' here is
808 * the number of bytes_per_pixel post-LUT, which we always
809 * set up for 8-bits of R/G/B, or 3 bytes total.
810 */
811 intel_link_compute_m_n(intel_crtc->config.pipe_bpp, lane_count,
812 target_clock, adjusted_mode->clock, &m_n);
813 775
814 if (intel_crtc->config.has_pch_encoder) 776 return true;
815 intel_pch_transcoder_set_m_n(intel_crtc, &m_n);
816 else
817 intel_cpu_transcoder_set_m_n(intel_crtc, &m_n);
818} 777}
819 778
820void intel_dp_init_link_config(struct intel_dp *intel_dp) 779void intel_dp_init_link_config(struct intel_dp *intel_dp)
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index c2a7f84b609d..9a20607440e0 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -190,6 +190,9 @@ struct intel_crtc_config {
190 */ 190 */
191 bool limited_color_range; 191 bool limited_color_range;
192 192
193 /* DP has a bunch of special case unfortunately, so mark the pipe
194 * accordingly. */
195 bool has_dp_encoder;
193 bool dither; 196 bool dither;
194 int pipe_bpp; 197 int pipe_bpp;
195 struct intel_link_m_n dp_m_n; 198 struct intel_link_m_n dp_m_n;
@@ -469,9 +472,6 @@ extern void intel_dp_init(struct drm_device *dev, int output_reg,
469 enum port port); 472 enum port port);
470extern void intel_dp_init_connector(struct intel_digital_port *intel_dig_port, 473extern void intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
471 struct intel_connector *intel_connector); 474 struct intel_connector *intel_connector);
472void
473intel_dp_set_m_n(struct drm_crtc *crtc, struct drm_display_mode *mode,
474 struct drm_display_mode *adjusted_mode);
475extern void intel_dp_init_link_config(struct intel_dp *intel_dp); 475extern void intel_dp_init_link_config(struct intel_dp *intel_dp);
476extern void intel_dp_start_link_train(struct intel_dp *intel_dp); 476extern void intel_dp_start_link_train(struct intel_dp *intel_dp);
477extern void intel_dp_complete_link_train(struct intel_dp *intel_dp); 477extern void intel_dp_complete_link_train(struct intel_dp *intel_dp);