aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShobhit Kumar <shobhit.kumar@intel.com>2014-07-30 11:02:37 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-07 05:07:17 -0400
commitf573de5a8474ae2cfc28424423c5a68c780a904b (patch)
tree98e80e5cb9a6b3802e5dc8caab768bdff40e1de9
parentaba86890a1785d787bfe7a741f910a472280540a (diff)
drm/i915: Add correct hw/sw config check for DSI encoder
Check in vlv_crtc_clock_get if DPLL is enabled before calling dpio read. It will not be enabled for DSI and avoid dpio read WARN dumps. Absence of ->get_config was causing other WARN dumps as well. Update dpll_hw_state as well correctly v2: Address review comments by Daniel - Check if DPLL is enabled rather than checking pipe output type - set adjusted_mode->flags to 0 in compute_config rather than using pipe_config->quirks - Add helper function in intel_dsi_pll.c and use that in intel_dsi.c - updated dpll_hw_state correctly - Updated commit message and title v3: Address review comments by Imre - Proper masking of P1, M1 fields while computing divisors - assert in case of bpp mismatch - guard for divide by 0 while computing pclk - Use ARRAY_SIZE instead of direct calculation Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com> Reviewed-by: Imre Deak <imre.deak@intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r--drivers/gpu/drm/i915/intel_display.c4
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.c21
-rw-r--r--drivers/gpu/drm/i915/intel_dsi.h1
-rw-r--r--drivers/gpu/drm/i915/intel_dsi_pll.c81
4 files changed, 106 insertions, 1 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 99eb7cad62a8..018fb7222f60 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6161,6 +6161,10 @@ static void vlv_crtc_clock_get(struct intel_crtc *crtc,
6161 u32 mdiv; 6161 u32 mdiv;
6162 int refclk = 100000; 6162 int refclk = 100000;
6163 6163
6164 /* In case of MIPI DPLL will not even be used */
6165 if (!(pipe_config->dpll_hw_state.dpll & DPLL_VCO_ENABLE))
6166 return;
6167
6164 mutex_lock(&dev_priv->dpio_lock); 6168 mutex_lock(&dev_priv->dpio_lock);
6165 mdiv = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW3(pipe)); 6169 mdiv = vlv_dpio_read(dev_priv, pipe, VLV_PLL_DW3(pipe));
6166 mutex_unlock(&dev_priv->dpio_lock); 6170 mutex_unlock(&dev_priv->dpio_lock);
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c
index 09e1cafe3e87..670c29a7b5dd 100644
--- a/drivers/gpu/drm/i915/intel_dsi.c
+++ b/drivers/gpu/drm/i915/intel_dsi.c
@@ -92,6 +92,9 @@ static bool intel_dsi_compute_config(struct intel_encoder *encoder,
92 if (fixed_mode) 92 if (fixed_mode)
93 intel_fixed_panel_mode(fixed_mode, adjusted_mode); 93 intel_fixed_panel_mode(fixed_mode, adjusted_mode);
94 94
95 /* DSI uses short packets for sync events, so clear mode flags for DSI */
96 adjusted_mode->flags = 0;
97
95 if (intel_dsi->dev.dev_ops->mode_fixup) 98 if (intel_dsi->dev.dev_ops->mode_fixup)
96 return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev, 99 return intel_dsi->dev.dev_ops->mode_fixup(&intel_dsi->dev,
97 mode, adjusted_mode); 100 mode, adjusted_mode);
@@ -179,6 +182,10 @@ static void intel_dsi_pre_enable(struct intel_encoder *encoder)
179 tmp |= DPLL_REFA_CLK_ENABLE_VLV; 182 tmp |= DPLL_REFA_CLK_ENABLE_VLV;
180 I915_WRITE(DPLL(pipe), tmp); 183 I915_WRITE(DPLL(pipe), tmp);
181 184
185 /* update the hw state for DPLL */
186 intel_crtc->config.dpll_hw_state.dpll = DPLL_INTEGRATED_CLOCK_VLV |
187 DPLL_REFA_CLK_ENABLE_VLV;
188
182 tmp = I915_READ(DSPCLK_GATE_D); 189 tmp = I915_READ(DSPCLK_GATE_D);
183 tmp |= DPOUNIT_CLOCK_GATE_DISABLE; 190 tmp |= DPOUNIT_CLOCK_GATE_DISABLE;
184 I915_WRITE(DSPCLK_GATE_D, tmp); 191 I915_WRITE(DSPCLK_GATE_D, tmp);
@@ -359,9 +366,21 @@ static bool intel_dsi_get_hw_state(struct intel_encoder *encoder,
359static void intel_dsi_get_config(struct intel_encoder *encoder, 366static void intel_dsi_get_config(struct intel_encoder *encoder,
360 struct intel_crtc_config *pipe_config) 367 struct intel_crtc_config *pipe_config)
361{ 368{
369 u32 pclk;
362 DRM_DEBUG_KMS("\n"); 370 DRM_DEBUG_KMS("\n");
363 371
364 /* XXX: read flags, set to adjusted_mode */ 372 /*
373 * DPLL_MD is not used in case of DSI, reading will get some default value
374 * set dpll_md = 0
375 */
376 pipe_config->dpll_hw_state.dpll_md = 0;
377
378 pclk = vlv_get_dsi_pclk(encoder, pipe_config->pipe_bpp);
379 if (!pclk)
380 return;
381
382 pipe_config->adjusted_mode.crtc_clock = pclk;
383 pipe_config->port_clock = pclk;
365} 384}
366 385
367static enum drm_mode_status 386static enum drm_mode_status
diff --git a/drivers/gpu/drm/i915/intel_dsi.h b/drivers/gpu/drm/i915/intel_dsi.h
index 31db33d3e5cc..fd51867fd0d3 100644
--- a/drivers/gpu/drm/i915/intel_dsi.h
+++ b/drivers/gpu/drm/i915/intel_dsi.h
@@ -132,6 +132,7 @@ static inline struct intel_dsi *enc_to_intel_dsi(struct drm_encoder *encoder)
132 132
133extern void vlv_enable_dsi_pll(struct intel_encoder *encoder); 133extern void vlv_enable_dsi_pll(struct intel_encoder *encoder);
134extern void vlv_disable_dsi_pll(struct intel_encoder *encoder); 134extern void vlv_disable_dsi_pll(struct intel_encoder *encoder);
135extern u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp);
135 136
136extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops; 137extern struct intel_dsi_dev_ops vbt_generic_dsi_display_ops;
137 138
diff --git a/drivers/gpu/drm/i915/intel_dsi_pll.c b/drivers/gpu/drm/i915/intel_dsi_pll.c
index ba79ec19da3b..d8bb1ea2f0da 100644
--- a/drivers/gpu/drm/i915/intel_dsi_pll.c
+++ b/drivers/gpu/drm/i915/intel_dsi_pll.c
@@ -298,3 +298,84 @@ void vlv_disable_dsi_pll(struct intel_encoder *encoder)
298 298
299 mutex_unlock(&dev_priv->dpio_lock); 299 mutex_unlock(&dev_priv->dpio_lock);
300} 300}
301
302static void assert_bpp_mismatch(int pixel_format, int pipe_bpp)
303{
304 int bpp;
305
306 switch (pixel_format) {
307 default:
308 case VID_MODE_FORMAT_RGB888:
309 case VID_MODE_FORMAT_RGB666_LOOSE:
310 bpp = 24;
311 break;
312 case VID_MODE_FORMAT_RGB666:
313 bpp = 18;
314 break;
315 case VID_MODE_FORMAT_RGB565:
316 bpp = 16;
317 break;
318 }
319
320 WARN(bpp != pipe_bpp,
321 "bpp match assertion failure (expected %d, current %d)\n",
322 bpp, pipe_bpp);
323}
324
325u32 vlv_get_dsi_pclk(struct intel_encoder *encoder, int pipe_bpp)
326{
327 struct drm_i915_private *dev_priv = encoder->base.dev->dev_private;
328 struct intel_dsi *intel_dsi = enc_to_intel_dsi(&encoder->base);
329 u32 dsi_clock, pclk;
330 u32 pll_ctl, pll_div;
331 u32 m = 0, p = 0;
332 int refclk = 25000;
333 int i;
334
335 DRM_DEBUG_KMS("\n");
336
337 mutex_lock(&dev_priv->dpio_lock);
338 pll_ctl = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_CONTROL);
339 pll_div = vlv_cck_read(dev_priv, CCK_REG_DSI_PLL_DIVIDER);
340 mutex_unlock(&dev_priv->dpio_lock);
341
342 /* mask out other bits and extract the P1 divisor */
343 pll_ctl &= DSI_PLL_P1_POST_DIV_MASK;
344 pll_ctl = pll_ctl >> (DSI_PLL_P1_POST_DIV_SHIFT - 2);
345
346 /* mask out the other bits and extract the M1 divisor */
347 pll_div &= DSI_PLL_M1_DIV_MASK;
348 pll_div = pll_div >> DSI_PLL_M1_DIV_SHIFT;
349
350 while (pll_ctl) {
351 pll_ctl = pll_ctl >> 1;
352 p++;
353 }
354 p--;
355
356 if (!p) {
357 DRM_ERROR("wrong P1 divisor\n");
358 return 0;
359 }
360
361 for (i = 0; i < ARRAY_SIZE(lfsr_converts); i++) {
362 if (lfsr_converts[i] == pll_div)
363 break;
364 }
365
366 if (i == ARRAY_SIZE(lfsr_converts)) {
367 DRM_ERROR("wrong m_seed programmed\n");
368 return 0;
369 }
370
371 m = i + 62;
372
373 dsi_clock = (m * refclk) / p;
374
375 /* pixel_format and pipe_bpp should agree */
376 assert_bpp_mismatch(intel_dsi->pixel_format, pipe_bpp);
377
378 pclk = DIV_ROUND_CLOSEST(dsi_clock * intel_dsi->lane_count, pipe_bpp);
379
380 return pclk;
381}