Skip to contentSkip to conversation

drm/i915: Fix sprite offset on HSW

PATCH In review Damien Lespiau 3 participants 4 messages Oct 26, 2012 – Oct 29, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/i915: Fix sprite offset on HSW

From: Damien Lespiau <[email protected]>

HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET register.

v2: Remove a useless level of indentation (Paulo Zanoni)

---
 drivers/gpu/drm/i915/i915_reg.h     | 3 +++
 drivers/gpu/drm/i915/intel_sprite.c | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 1c20df2..9995209 100644
@@ -3223,6 +3223,7 @@
 #define _SPRA_SURF		0x7029c
 #define _SPRA_KEYMAX		0x702a0
 #define _SPRA_TILEOFF		0x702a4
+#define _SPRA_OFFSET		0x702a4
 #define _SPRA_SCALE		0x70304
 #define   SPRITE_SCALE_ENABLE	(1<<31)
 #define   SPRITE_FILTER_MASK	(3<<29)
@@ -3243,6 +3244,7 @@
 #define _SPRB_SURF		0x7129c
 #define _SPRB_KEYMAX		0x712a0
 #define _SPRB_TILEOFF		0x712a4
+#define _SPRB_OFFSET		0x712a4
 #define _SPRB_SCALE		0x71304
 #define _SPRB_GAMC		0x71400
 
@@ -3256,6 +3258,7 @@
 #define SPRSURF(pipe) _PIPE(pipe, _SPRA_SURF, _SPRB_SURF)
 #define SPRKEYMAX(pipe) _PIPE(pipe, _SPRA_KEYMAX, _SPRB_KEYMAX)
 #define SPRTILEOFF(pipe) _PIPE(pipe, _SPRA_TILEOFF, _SPRB_TILEOFF)
+#define SPROFFSET(pipe) _PIPE(pipe, _SPRA_OFFSET, _SPRB_OFFSET)
 #define SPRSCALE(pipe) _PIPE(pipe, _SPRA_SCALE, _SPRB_SCALE)
 #define SPRGAMC(pipe) _PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC)
 
drivers/gpu/drm/i915/intel_sprite.c +7 -1
index fa68e2a..1cb8ac2 100644
@@ -127,7 +127,12 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 
 	I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]);
 	I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
-	if (obj->tiling_mode != I915_TILING_NONE) {
+
+	if (IS_HASWELL(dev)) {
+		/* HSW consolidates SPRTILEOFF and SPRLINOFF into a single
+		 * SPROFFSET register */
+		I915_WRITE(SPROFFSET(pipe), (y << 16) | x);
+	} else if (obj->tiling_mode != I915_TILING_NONE) {
 		I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x);
 	} else {
 		unsigned long offset;
@@ -135,6 +140,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 		offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
 		I915_WRITE(SPRLINOFF(pipe), offset);
 	}
+
 	I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w);
 	if (intel_plane->can_scale)
 		I915_WRITE(SPRSCALE(pipe), sprscale);
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 2/2 drm/i915: adjust sprite base address

From: Damien Lespiau <[email protected]>

Just like in:

commit c2c75131244507c93f812862fdbd4f3a37139401

Author: Daniel Vetter <[email protected]>
Date:   Thu Jul 5 12:17:30 2012 +0200

drm/i915: adjust framebuffer base address on gen4+

but this time, for the sprite planes. This ensures that the sprite offset are always inside the supported hardware limits since it becomes the offset into a page and we adjust the base address to a page boundary.

---
 drivers/gpu/drm/i915/intel_display.c | 18 +++++++-------
 drivers/gpu/drm/i915/intel_drv.h     |  4 ++++
 drivers/gpu/drm/i915/intel_sprite.c  | 46 ++++++++++++++++++++++--------------
 3 files changed, 41 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/intel_display.c +9 -9
index b1c19b2..f3fc1ff 100644
@@ -1941,9 +1941,9 @@ void intel_unpin_fb_obj(struct drm_i915_gem_object *obj)
 
 /* Computes the linear offset to the base tile and adjusts x, y. bytes per pixel
  * is assumed to be a power-of-two. */
-static unsigned long gen4_compute_dspaddr_offset_xtiled(int *x, int *y,
-							unsigned int bpp,
-							unsigned int pitch)
+unsigned long intel_gen4_compute_offset_xtiled(int *x, int *y,
+					       unsigned int bpp,
+					       unsigned int pitch)
 {
 	int tile_rows, tiles;
 
@@ -2015,9 +2015,9 @@ static int i9xx_update_plane(struct drm_crtc *crtc, struct drm_framebuffer *fb,
 
 	if (INTEL_INFO(dev)->gen >= 4) {
 		intel_crtc->dspaddr_offset =
-			gen4_compute_dspaddr_offset_xtiled(&x, &y,
-							   fb->bits_per_pixel / 8,
-							   fb->pitches[0]);
+			intel_gen4_compute_offset_xtiled(&x, &y,
+							 fb->bits_per_pixel / 8,
+							 fb->pitches[0]);
 		linear_offset -= intel_crtc->dspaddr_offset;
 	} else {
 		intel_crtc->dspaddr_offset = linear_offset;
@@ -2104,9 +2104,9 @@ static int ironlake_update_plane(struct drm_crtc *crtc,
 
 	linear_offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
 	intel_crtc->dspaddr_offset =
-		gen4_compute_dspaddr_offset_xtiled(&x, &y,
-						   fb->bits_per_pixel / 8,
-						   fb->pitches[0]);
+		intel_gen4_compute_offset_xtiled(&x, &y,
+						 fb->bits_per_pixel / 8,
+						 fb->pitches[0]);
 	linear_offset -= intel_crtc->dspaddr_offset;
 
 	DRM_DEBUG_KMS("Writing base %08X %08lX %d %d %d\n",
drivers/gpu/drm/i915/intel_drv.h +4 -0
index 97c714d..e3f6bf3 100644
@@ -620,6 +620,10 @@ extern void intel_update_sprite_watermarks(struct drm_device *dev, int pipe,
 extern void intel_update_linetime_watermarks(struct drm_device *dev, int pipe,
 			 struct drm_display_mode *mode);
 
+extern unsigned long intel_gen4_compute_offset_xtiled(int *x, int *y,
+						      unsigned int bpp,
+						      unsigned int pitch);
+
 extern int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 				     struct drm_file *file_priv);
 extern int intel_sprite_get_colorkey(struct drm_device *dev, void *data,
drivers/gpu/drm/i915/intel_sprite.c +28 -18

82 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#2 lore raw

Re: [PATCH 2/2] drm/i915: adjust sprite base address

Quoted 8 lines · Damien Lespiau

From: Damien Lespiau <[email protected]>

Just like in:

commit c2c75131244507c93f812862fdbd4f3a37139401

Author: Daniel Vetter <[email protected]>
Date:   Thu Jul 5 12:17:30 2012 +0200
Quoted 8 lines

drm/i915: adjust framebuffer base address on gen4+

but this time, for the sprite planes. This ensures that the sprite offset are always inside the supported hardware limits since it becomes the offset into a page and we adjust the base address to a page boundary.

Both patches slurped in, thanks.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#3 lore raw
In reply to Damien Lespiau

2012/10/26 Damien Lespiau <[email protected]>:

Quoted 9 lines

From: Damien Lespiau <[email protected]>

HSW consolidates SPRTILEOFF and SPRLINOFF into a single SPROFFSET register.

v2: Remove a useless level of indentation (Paulo Zanoni)

Reviewed-by tag still applies to v2.

Quoted 66 lines
---
 drivers/gpu/drm/i915/i915_reg.h     | 3 +++
 drivers/gpu/drm/i915/intel_sprite.c | 8 +++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +3 -0
index 1c20df2..9995209 100644
@@ -3223,6 +3223,7 @@
 #define _SPRA_SURF             0x7029c
 #define _SPRA_KEYMAX           0x702a0
 #define _SPRA_TILEOFF          0x702a4
+#define _SPRA_OFFSET           0x702a4
 #define _SPRA_SCALE            0x70304
 #define   SPRITE_SCALE_ENABLE  (1<<31)
 #define   SPRITE_FILTER_MASK   (3<<29)
@@ -3243,6 +3244,7 @@
 #define _SPRB_SURF             0x7129c
 #define _SPRB_KEYMAX           0x712a0
 #define _SPRB_TILEOFF          0x712a4
+#define _SPRB_OFFSET           0x712a4
 #define _SPRB_SCALE            0x71304
 #define _SPRB_GAMC             0x71400
 
@@ -3256,6 +3258,7 @@
 #define SPRSURF(pipe) _PIPE(pipe, _SPRA_SURF, _SPRB_SURF)
 #define SPRKEYMAX(pipe) _PIPE(pipe, _SPRA_KEYMAX, _SPRB_KEYMAX)
 #define SPRTILEOFF(pipe) _PIPE(pipe, _SPRA_TILEOFF, _SPRB_TILEOFF)
+#define SPROFFSET(pipe) _PIPE(pipe, _SPRA_OFFSET, _SPRB_OFFSET)
 #define SPRSCALE(pipe) _PIPE(pipe, _SPRA_SCALE, _SPRB_SCALE)
 #define SPRGAMC(pipe) _PIPE(pipe, _SPRA_GAMC, _SPRB_GAMC)
 
drivers/gpu/drm/i915/intel_sprite.c +7 -2
index fa68e2a..1cb8ac2 100644
@@ -127,7 +127,12 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 
        I915_WRITE(SPRSTRIDE(pipe), fb->pitches[0]);
        I915_WRITE(SPRPOS(pipe), (crtc_y << 16) | crtc_x);
-       if (obj->tiling_mode != I915_TILING_NONE) {
+
+       if (IS_HASWELL(dev)) {
+               /* HSW consolidates SPRTILEOFF and SPRLINOFF into a single
+                * SPROFFSET register */
+               I915_WRITE(SPROFFSET(pipe), (y << 16) | x);
+       } else if (obj->tiling_mode != I915_TILING_NONE) {
                I915_WRITE(SPRTILEOFF(pipe), (y << 16) | x);
        } else {
                unsigned long offset;
@@ -135,6 +140,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
                offset = y * fb->pitches[0] + x * (fb->bits_per_pixel / 8);
                I915_WRITE(SPRLINOFF(pipe), offset);
        }
+
        I915_WRITE(SPRSIZE(pipe), (crtc_h << 16) | crtc_w);
        if (intel_plane->can_scale)
                I915_WRITE(SPRSCALE(pipe), sprscale);
--

1.7.11.7

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 1 line
Paulo Zanoni