aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/intel_display.c
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2014-08-08 14:51:10 -0400
committerDaniel Vetter <daniel.vetter@ffwll.ch>2014-08-08 14:53:37 -0400
commitf45651bae2ee73ae551699d481f76aa6ad92138f (patch)
treef649e40089135c23572ddcf6c7a622ccd99e24ce /drivers/gpu/drm/i915/intel_display.c
parent4fa790421c10e5c9c62406655c06d97a94555d54 (diff)
drm/i915: Eliminate rmw from .update_primary_plane()
Move the entire DSPCNTR register setup into the .update_primary_plane() functions. That's where it belongs anyway and it'll also help 830M which has the extra problem that plane registers reads will return the value latched at the last vblank, not the value that was last written. Also move DSPPOS and DSPSIZE setup there. v2: Don't move variable initialization to avoid churn later Reviewed-by: Matt Roper <matthew.d.roper@intel.com> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.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.c100
1 files changed, 32 insertions, 68 deletions
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 24295694e493..041fd76a2ded 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2388,12 +2388,26 @@ static void i9xx_update_primary_plane(struct drm_crtc *crtc,
2388 int plane = intel_crtc->plane; 2388 int plane = intel_crtc->plane;
2389 unsigned long linear_offset; 2389 unsigned long linear_offset;
2390 u32 dspcntr; 2390 u32 dspcntr;
2391 u32 reg; 2391 u32 reg = DSPCNTR(plane);
2392
2393 dspcntr = DISPPLANE_GAMMA_ENABLE;
2394
2395 if (intel_crtc->primary_enabled)
2396 dspcntr |= DISPLAY_PLANE_ENABLE;
2397
2398 if (INTEL_INFO(dev)->gen < 4) {
2399 if (intel_crtc->pipe == PIPE_B)
2400 dspcntr |= DISPPLANE_SEL_PIPE_B;
2401
2402 /* pipesrc and dspsize control the size that is scaled from,
2403 * which should always be the user's requested size.
2404 */
2405 I915_WRITE(DSPSIZE(plane),
2406 ((intel_crtc->config.pipe_src_h - 1) << 16) |
2407 (intel_crtc->config.pipe_src_w - 1));
2408 I915_WRITE(DSPPOS(plane), 0);
2409 }
2392 2410
2393 reg = DSPCNTR(plane);
2394 dspcntr = I915_READ(reg);
2395 /* Mask out pixel format bits in case we change it */
2396 dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
2397 switch (fb->pixel_format) { 2411 switch (fb->pixel_format) {
2398 case DRM_FORMAT_C8: 2412 case DRM_FORMAT_C8:
2399 dspcntr |= DISPPLANE_8BPP; 2413 dspcntr |= DISPPLANE_8BPP;
@@ -2425,12 +2439,9 @@ static void i9xx_update_primary_plane(struct drm_crtc *crtc,
2425 BUG(); 2439 BUG();
2426 } 2440 }
2427 2441
2428 if (INTEL_INFO(dev)->gen >= 4) { 2442 if (INTEL_INFO(dev)->gen >= 4 &&
2429 if (obj->tiling_mode != I915_TILING_NONE) 2443 obj->tiling_mode != I915_TILING_NONE)
2430 dspcntr |= DISPPLANE_TILED; 2444 dspcntr |= DISPPLANE_TILED;
2431 else
2432 dspcntr &= ~DISPPLANE_TILED;
2433 }
2434 2445
2435 if (IS_G4X(dev)) 2446 if (IS_G4X(dev))
2436 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; 2447 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
@@ -2474,12 +2485,16 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,
2474 int plane = intel_crtc->plane; 2485 int plane = intel_crtc->plane;
2475 unsigned long linear_offset; 2486 unsigned long linear_offset;
2476 u32 dspcntr; 2487 u32 dspcntr;
2477 u32 reg; 2488 u32 reg = DSPCNTR(plane);
2489
2490 dspcntr = DISPPLANE_GAMMA_ENABLE;
2491
2492 if (intel_crtc->primary_enabled)
2493 dspcntr |= DISPLAY_PLANE_ENABLE;
2494
2495 if (IS_HASWELL(dev) || IS_BROADWELL(dev))
2496 dspcntr |= DISPPLANE_PIPE_CSC_ENABLE;
2478 2497
2479 reg = DSPCNTR(plane);
2480 dspcntr = I915_READ(reg);
2481 /* Mask out pixel format bits in case we change it */
2482 dspcntr &= ~DISPPLANE_PIXFORMAT_MASK;
2483 switch (fb->pixel_format) { 2498 switch (fb->pixel_format) {
2484 case DRM_FORMAT_C8: 2499 case DRM_FORMAT_C8:
2485 dspcntr |= DISPPLANE_8BPP; 2500 dspcntr |= DISPPLANE_8BPP;
@@ -2509,12 +2524,8 @@ static void ironlake_update_primary_plane(struct drm_crtc *crtc,
2509 2524
2510 if (obj->tiling_mode != I915_TILING_NONE) 2525 if (obj->tiling_mode != I915_TILING_NONE)
2511 dspcntr |= DISPPLANE_TILED; 2526 dspcntr |= DISPPLANE_TILED;
2512 else
2513 dspcntr &= ~DISPPLANE_TILED;
2514 2527
2515 if (IS_HASWELL(dev) || IS_BROADWELL(dev)) 2528 if (!IS_HASWELL(dev) && !IS_BROADWELL(dev))
2516 dspcntr &= ~DISPPLANE_TRICKLE_FEED_DISABLE;
2517 else
2518 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE; 2529 dspcntr |= DISPPLANE_TRICKLE_FEED_DISABLE;
2519 2530
2520 I915_WRITE(reg, dspcntr); 2531 I915_WRITE(reg, dspcntr);
@@ -3936,7 +3947,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
3936 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 3947 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
3937 struct intel_encoder *encoder; 3948 struct intel_encoder *encoder;
3938 int pipe = intel_crtc->pipe; 3949 int pipe = intel_crtc->pipe;
3939 enum plane plane = intel_crtc->plane;
3940 3950
3941 WARN_ON(!crtc->enabled); 3951 WARN_ON(!crtc->enabled);
3942 3952
@@ -3958,10 +3968,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
3958 3968
3959 ironlake_set_pipeconf(crtc); 3969 ironlake_set_pipeconf(crtc);
3960 3970
3961 /* Set up the display plane register */
3962 I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE);
3963 POSTING_READ(DSPCNTR(plane));
3964
3965 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, 3971 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb,
3966 crtc->x, crtc->y); 3972 crtc->x, crtc->y);
3967 3973
@@ -4049,7 +4055,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
4049 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4055 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4050 struct intel_encoder *encoder; 4056 struct intel_encoder *encoder;
4051 int pipe = intel_crtc->pipe; 4057 int pipe = intel_crtc->pipe;
4052 enum plane plane = intel_crtc->plane;
4053 4058
4054 WARN_ON(!crtc->enabled); 4059 WARN_ON(!crtc->enabled);
4055 4060
@@ -4073,10 +4078,6 @@ static void haswell_crtc_enable(struct drm_crtc *crtc)
4073 4078
4074 intel_set_pipe_csc(crtc); 4079 intel_set_pipe_csc(crtc);
4075 4080
4076 /* Set up the display plane register */
4077 I915_WRITE(DSPCNTR(plane), DISPPLANE_GAMMA_ENABLE | DISPPLANE_PIPE_CSC_ENABLE);
4078 POSTING_READ(DSPCNTR(plane));
4079
4080 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, 4081 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb,
4081 crtc->x, crtc->y); 4082 crtc->x, crtc->y);
4082 4083
@@ -4632,9 +4633,7 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
4632 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4633 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4633 struct intel_encoder *encoder; 4634 struct intel_encoder *encoder;
4634 int pipe = intel_crtc->pipe; 4635 int pipe = intel_crtc->pipe;
4635 int plane = intel_crtc->plane;
4636 bool is_dsi; 4636 bool is_dsi;
4637 u32 dspcntr;
4638 4637
4639 WARN_ON(!crtc->enabled); 4638 WARN_ON(!crtc->enabled);
4640 4639
@@ -4650,27 +4649,13 @@ static void valleyview_crtc_enable(struct drm_crtc *crtc)
4650 vlv_prepare_pll(intel_crtc); 4649 vlv_prepare_pll(intel_crtc);
4651 } 4650 }
4652 4651
4653 /* Set up the display plane register */
4654 dspcntr = DISPPLANE_GAMMA_ENABLE;
4655
4656 if (intel_crtc->config.has_dp_encoder) 4652 if (intel_crtc->config.has_dp_encoder)
4657 intel_dp_set_m_n(intel_crtc); 4653 intel_dp_set_m_n(intel_crtc);
4658 4654
4659 intel_set_pipe_timings(intel_crtc); 4655 intel_set_pipe_timings(intel_crtc);
4660 4656
4661 /* pipesrc and dspsize control the size that is scaled from,
4662 * which should always be the user's requested size.
4663 */
4664 I915_WRITE(DSPSIZE(plane),
4665 ((intel_crtc->config.pipe_src_h - 1) << 16) |
4666 (intel_crtc->config.pipe_src_w - 1));
4667 I915_WRITE(DSPPOS(plane), 0);
4668
4669 i9xx_set_pipeconf(intel_crtc); 4657 i9xx_set_pipeconf(intel_crtc);
4670 4658
4671 I915_WRITE(DSPCNTR(plane), dspcntr);
4672 POSTING_READ(DSPCNTR(plane));
4673
4674 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, 4659 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb,
4675 crtc->x, crtc->y); 4660 crtc->x, crtc->y);
4676 4661
@@ -4725,8 +4710,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
4725 struct intel_crtc *intel_crtc = to_intel_crtc(crtc); 4710 struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
4726 struct intel_encoder *encoder; 4711 struct intel_encoder *encoder;
4727 int pipe = intel_crtc->pipe; 4712 int pipe = intel_crtc->pipe;
4728 int plane = intel_crtc->plane;
4729 u32 dspcntr;
4730 4713
4731 WARN_ON(!crtc->enabled); 4714 WARN_ON(!crtc->enabled);
4732 4715
@@ -4735,32 +4718,13 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
4735 4718
4736 i9xx_set_pll_dividers(intel_crtc); 4719 i9xx_set_pll_dividers(intel_crtc);
4737 4720
4738 /* Set up the display plane register */
4739 dspcntr = DISPPLANE_GAMMA_ENABLE;
4740
4741 if (pipe == 0)
4742 dspcntr &= ~DISPPLANE_SEL_PIPE_MASK;
4743 else
4744 dspcntr |= DISPPLANE_SEL_PIPE_B;
4745
4746 if (intel_crtc->config.has_dp_encoder) 4721 if (intel_crtc->config.has_dp_encoder)
4747 intel_dp_set_m_n(intel_crtc); 4722 intel_dp_set_m_n(intel_crtc);
4748 4723
4749 intel_set_pipe_timings(intel_crtc); 4724 intel_set_pipe_timings(intel_crtc);
4750 4725
4751 /* pipesrc and dspsize control the size that is scaled from,
4752 * which should always be the user's requested size.
4753 */
4754 I915_WRITE(DSPSIZE(plane),
4755 ((intel_crtc->config.pipe_src_h - 1) << 16) |
4756 (intel_crtc->config.pipe_src_w - 1));
4757 I915_WRITE(DSPPOS(plane), 0);
4758
4759 i9xx_set_pipeconf(intel_crtc); 4726 i9xx_set_pipeconf(intel_crtc);
4760 4727
4761 I915_WRITE(DSPCNTR(plane), dspcntr);
4762 POSTING_READ(DSPCNTR(plane));
4763
4764 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb, 4728 dev_priv->display.update_primary_plane(crtc, crtc->primary->fb,
4765 crtc->x, crtc->y); 4729 crtc->x, crtc->y);
4766 4730