drm/i915: Fix sprite_scaling_enabled for multiple sprites
Subsystems (2)
PATCH 1/1 drm/i915: Fix sprite_scaling_enabled for multiple sprites
From: Ville Syrjälä <[email protected]>
We have more than one sprite, so a boolean simply won't cut it. Turn sprite_scaling_enabled into a bitmask and track the state of sprite scaler for each sprite independently.
Also don't re-enable LP watermarks until the sprite registers have actually been written, and thus sprite scaling has really been disabled.
--- drivers/gpu/drm/i915/i915_drv.h | 2 +- drivers/gpu/drm/i915/intel_sprite.c | 27 ++++++++++++++++----------- 2 files changed, 17 insertions(+), 12 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -1
@@ -925,7 +925,7 @@ typedef struct drm_i915_private {/* overlay */ struct intel_overlay *overlay; -bool sprite_scaling_enabled; +unsigned int sprite_scaling_enabled;/* LVDS info */ int backlight_level;/* restore backlight to this value */
drivers/gpu/drm/i915/intel_sprite.c +16 -11
@@ -50,6 +50,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,u32 sprctl, sprscale =0 ;unsigned long sprsurf_offset, linear_offset;int pixel_size =drm_format_plane_cpp (fb->pixel_format,0 ); +bool scaling_was_enabled = dev_priv->sprite_scaling_enabled; sprctl =I915_READ (SPRCTL (pipe));
@@ -103,19 +104,15 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,* when scaling is disabled. */ if (crtc_w != src_w || crtc_h != src_h) { -if (!dev_priv->sprite_scaling_enabled) { - dev_priv->sprite_scaling_enabled = true; + dev_priv->sprite_scaling_enabled |=1 << pipe; + +if (!scaling_was_enabled) {intel_update_watermarks (dev);intel_wait_for_vblank (dev, pipe); } sprscale =SPRITE_SCALE_ENABLE | (src_w <<16 ) | src_h; - }else { -if (dev_priv->sprite_scaling_enabled) { - dev_priv->sprite_scaling_enabled = false; -/* potentially re-enable LP watermarks */ -intel_update_watermarks (dev); - } - } + }else + dev_priv->sprite_scaling_enabled &= ~(1 << pipe);I915_WRITE (SPRSTRIDE (pipe), fb->pitches[0 ]);I915_WRITE (SPRPOS (pipe), (crtc_y <<16 ) | crtc_x);
@@ -141,6 +138,10 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,I915_WRITE (SPRCTL (pipe), sprctl);I915_MODIFY_DISPBASE (SPRSURF (pipe), obj->gtt_offset + sprsurf_offset);POSTING_READ (SPRSURF (pipe)); + +/* potentially re-enable LP watermarks */ +if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled) +intel_update_watermarks (dev); } static void
@@ -150,6 +151,7 @@ ivb_disable_plane(struct drm_plane *plane)struct drm_i915_private *dev_priv = dev->dev_private;struct intel_plane *intel_plane =to_intel_plane (plane);int pipe = intel_plane->pipe; +bool scaling_was_enabled = dev_priv->sprite_scaling_enabled;I915_WRITE (SPRCTL (pipe),I915_READ (SPRCTL (pipe)) & ~SPRITE_ENABLE );/* Can't leave the scaler enabled... */
@@ -159,8 +161,11 @@ ivb_disable_plane(struct drm_plane *plane)I915_MODIFY_DISPBASE (SPRSURF (pipe),0 );POSTING_READ (SPRSURF (pipe)); - dev_priv->sprite_scaling_enabled = false; -intel_update_watermarks (dev); + dev_priv->sprite_scaling_enabled &= ~(1 << pipe); + +/* potentially re-enable LP watermarks */ +if (scaling_was_enabled && !dev_priv->sprite_scaling_enabled) +intel_update_watermarks (dev); } static int
Signature · 6 lines
1.7.12.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · On Fri, Feb 08, 2013 at 11:13:35PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
We have more than one sprite, so a boolean simply won't cut it. Turn
sprite_scaling_enabledinto a bitmask and track the state of sprite scaler for each sprite independently.Also don't re-enable LP watermarks until the sprite registers have actually been written, and thus sprite scaling has really been disabled.
I would emphasize this, since this fix is worthy of Cc: stable@
Quoted 1 line
Signed-off-by Ville Syrjälä <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Daniel Vetter
AppliedQuoted 6 lines · Chris Wilson
Quoted 5 lines · On Fri, Feb 08, 2013 at 11:13:35PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
We have more than one sprite, so a boolean simply won't cut it. Turn
sprite_scaling_enabledinto a bitmask and track the state of sprite scaler for each sprite independently.
I'm not sure whether keeping that in dev_priv is right, probably should move into a crtc flag. Otoh we have a few funny issues around watermark changes anyway already, so better fix those all up before creating havoc
...
Quoted 8 lines
Quoted 3 lines
Also don't re-enable LP watermarks until the sprite registers have actually been written, and thus sprite scaling has really been disabled.
I would emphasize this, since this fix is worthy of Cc: stable@
Quoted 1 line
Signed-off-by Ville Syrjälä <[email protected]>Reviewed-by Chris Wilson <[email protected]>
Queued for -next, thanks for the patch.
-Daniel
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch