Skip to contentSkip to conversation

drm/i915: Add sprite watermark programming for VLV and CHV

PATCH Superseded Gajanan Bhat 2 participants 4 messages Aug 5, 2014 – Aug 7, 2014 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 drm/i915: Add sprite watermark programming for VLV and CHV

Program DDL register as part of sprite watermark programming for CHV and VLV.

v2: Rename DRAIN_LATENCY_MAX by DRAIN_LATENCY_MASK

---
 drivers/gpu/drm/i915/intel_pm.c |   44 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +44 -0
index 5e81c49..9126295 100644
@@ -1416,6 +1416,48 @@ static void valleyview_update_wm(struct drm_crtc *crtc)
 		intel_set_memory_cxsr(dev_priv, true);
 }
 
+static void valleyview_update_sprite_wm(struct drm_plane *plane,
+					struct drm_crtc *crtc,
+					uint32_t sprite_width,
+					uint32_t sprite_height,
+					int pixel_size,
+					bool enabled, bool scaled)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int pipe = to_intel_plane(plane)->pipe;
+	int drain_latency;
+	int plane_prec;
+	int sprite_dl;
+	int prec_mult;
+
+	if (to_intel_plane(plane)->plane == 0)
+		sprite_dl = I915_READ(VLV_DDL(pipe)) & ~DDL_SPRITE0_PRECISION_64 &
+			    ~(DRAIN_LATENCY_MASK << DDL_SPRITE0_SHIFT);
+	else
+		sprite_dl = I915_READ(VLV_DDL(pipe)) & ~DDL_SPRITE1_PRECISION_64 &
+			    ~(DRAIN_LATENCY_MASK << DDL_SPRITE1_SHIFT);
+
+	if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult,
+						 &drain_latency)) {
+		if (to_intel_plane(plane)->plane == 0) {
+			plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+						   DDL_SPRITE0_PRECISION_64 :
+						   DDL_SPRITE0_PRECISION_32;
+			sprite_dl = sprite_dl | plane_prec |
+				    drain_latency << DDL_SPRITE0_SHIFT;
+		} else {
+			plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+						   DDL_SPRITE1_PRECISION_64 :
+						   DDL_SPRITE1_PRECISION_32;
+			sprite_dl = sprite_dl | plane_prec |
+				    drain_latency << DDL_SPRITE1_SHIFT;
+		}
+	}
+
+	I915_WRITE(VLV_DDL(pipe), sprite_dl);
+}
+
 static void g4x_update_wm(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -7134,10 +7176,12 @@ void intel_init_pm(struct drm_device *dev)
 			dev_priv->display.init_clock_gating = gen8_init_clock_gating;
 	} else if (IS_CHERRYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			cherryview_init_clock_gating;
 	} else if (IS_VALLEYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			valleyview_init_clock_gating;
 	} else if (IS_PINEVIEW(dev)) {
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 28 lines · Gajanan Bhat

Program DDL register as part of sprite watermark programming for CHV and VLV.

v2: Rename DRAIN_LATENCY_MAX by DRAIN_LATENCY_MASK

---
 drivers/gpu/drm/i915/intel_pm.c |   44 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
drivers/gpu/drm/i915/intel_pm.c +11 -0
index 5e81c49..9126295 100644
@@ -1416,6 +1416,48 @@ static void valleyview_update_wm(struct drm_crtc *crtc)
 		intel_set_memory_cxsr(dev_priv, true);
 }
 
+static void valleyview_update_sprite_wm(struct drm_plane *plane,
+					struct drm_crtc *crtc,
+					uint32_t sprite_width,
+					uint32_t sprite_height,
+					int pixel_size,
+					bool enabled, bool scaled)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int pipe = to_intel_plane(plane)->pipe;
+	int drain_latency;

drivers/gpu/drm/i915/intel_pm.c static void valleyview_update_wm(struct drm_crtc *crtc) · line 1439

Quoted 10 lines
drivers/gpu/drm/i915/intel_pm.c +10 -0
+	int plane_prec;
+	int sprite_dl;
+	int prec_mult;
+
+	if (to_intel_plane(plane)->plane == 0)
+		sprite_dl = I915_READ(VLV_DDL(pipe)) & ~DDL_SPRITE0_PRECISION_64 &
+			    ~(DRAIN_LATENCY_MASK << DDL_SPRITE0_SHIFT);
+	else
+		sprite_dl = I915_READ(VLV_DDL(pipe)) & ~DDL_SPRITE1_PRECISION_64 &
+			    ~(DRAIN_LATENCY_MASK << DDL_SPRITE1_SHIFT);

I was thinking we migth want to parametrize the DDL_SPRITE bits to avoid these if-else things. So something like this:

#define DDL_SPRITE_PRECISION_64(sprite) (1<<(15+8*(sprite)))
#define DDL_SPRITE_PRECISION_32(sprite) (0<<(15+8*(sprite)))
#define DDL_SPRITE_SHIFT(sprite) (8+8*(sprite))

Also you should again use the more customary form for masking the bits:
I915_READ() & ~(DDL_SPRITE_PRECISION_64 |

		(DRAIN_LATENCY_MASK << DDL_SPRITE_SHIFT));
Quoted 44 lines
drivers/gpu/drm/i915/intel_pm.c +23 -0
+
+	if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult,
+						 &drain_latency)) {
+		if (to_intel_plane(plane)->plane == 0) {
+			plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+						   DDL_SPRITE0_PRECISION_64 :
+						   DDL_SPRITE0_PRECISION_32;
+			sprite_dl = sprite_dl | plane_prec |
+				    drain_latency << DDL_SPRITE0_SHIFT;
+		} else {
+			plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+						   DDL_SPRITE1_PRECISION_64 :
+						   DDL_SPRITE1_PRECISION_32;
+			sprite_dl = sprite_dl | plane_prec |
+				    drain_latency << DDL_SPRITE1_SHIFT;
+		}
+	}
+
+	I915_WRITE(VLV_DDL(pipe), sprite_dl);
+}
+
 static void g4x_update_wm(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -7134,10 +7176,12 @@ void intel_init_pm(struct drm_device *dev)
 			dev_priv->display.init_clock_gating = gen8_init_clock_gating;
 	} else if (IS_CHERRYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			cherryview_init_clock_gating;
 	} else if (IS_VALLEYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			valleyview_init_clock_gating;
 	} else if (IS_PINEVIEW(dev)) {
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
#3 lore raw

PATCH v3 1/1 drm/i915: Add sprite watermark programming for VLV and CHV

Program DDL register as part of sprite watermark programming for CHV and VLV.

v2: Rename DRAIN_LATENCY_MAX by DRAIN_LATENCY_MASK

v3: Addressed review comments by Ville
- Changed Sprite DDL definitions to more generic to avoid multiple if-else
- Changed bit masking to customary form
- Changed to bitwise shorthand operator for sprite_dl assignment

---
 drivers/gpu/drm/i915/i915_reg.h |    9 +++------
 drivers/gpu/drm/i915/intel_pm.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +3 -6
index 08916df..f8aaf0b 100644
@@ -4000,12 +4000,9 @@ enum punit_power_well {
 #define DDL_CURSOR_PRECISION_64		(1<<31)
 #define DDL_CURSOR_PRECISION_32		(0<<31)
 #define DDL_CURSOR_SHIFT		24
-#define DDL_SPRITE1_PRECISION_64	(1<<23)
-#define DDL_SPRITE1_PRECISION_32	(0<<23)
-#define DDL_SPRITE1_SHIFT		16
-#define DDL_SPRITE0_PRECISION_64	(1<<15)
-#define DDL_SPRITE0_PRECISION_32	(0<<15)
-#define DDL_SPRITE0_SHIFT		8
+#define DDL_SPRITE_PRECISION_64(sprite)	(1<<(15+8*(sprite)))
+#define DDL_SPRITE_PRECISION_32(sprite)	(0<<(15+8*(sprite)))
+#define DDL_SPRITE_SHIFT(sprite)	(8+8*(sprite))
 #define DDL_PLANE_PRECISION_64		(1<<7)
 #define DDL_PLANE_PRECISION_32		(0<<7)
 #define DDL_PLANE_SHIFT			0
drivers/gpu/drm/i915/intel_pm.c +33 -0
index 86d6048..974aeea 100644
@@ -1500,6 +1500,37 @@ static void cherryview_update_wm(struct drm_crtc *crtc)
 		intel_set_memory_cxsr(dev_priv, true);
 }
 
+static void valleyview_update_sprite_wm(struct drm_plane *plane,
+					struct drm_crtc *crtc,
+					uint32_t sprite_width,
+					uint32_t sprite_height,
+					int pixel_size,
+					bool enabled, bool scaled)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int pipe = to_intel_plane(plane)->pipe;
+	int sprite = to_intel_plane(plane)->plane;
+	int drain_latency;
+	int plane_prec;
+	int sprite_dl;
+	int prec_mult;
+
+	sprite_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_SPRITE_PRECISION_64(sprite) |
+		    (DRAIN_LATENCY_MASK << DDL_SPRITE_SHIFT(sprite)));
+
+	if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult,
+						 &drain_latency)) {
+		plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+					   DDL_SPRITE_PRECISION_64(sprite) :
+					   DDL_SPRITE_PRECISION_32(sprite);
+		sprite_dl |= plane_prec |
+			     (drain_latency << DDL_SPRITE_SHIFT(sprite));
+	}
+
+	I915_WRITE(VLV_DDL(pipe), sprite_dl);
+}
+
 static void g4x_update_wm(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -7231,10 +7262,12 @@ void intel_init_pm(struct drm_device *dev)
 			dev_priv->display.init_clock_gating = gen8_init_clock_gating;
 	} else if (IS_CHERRYVIEW(dev)) {
 		dev_priv->display.update_wm = cherryview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			cherryview_init_clock_gating;
 	} else if (IS_VALLEYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			valleyview_init_clock_gating;
 	} else if (IS_PINEVIEW(dev)) {
Signature · 1 line
1.7.9.5
Reviewed-by on v3 1/1
#4 lore raw
Quoted 10 lines · Gajanan Bhat

Program DDL register as part of sprite watermark programming for CHV and VLV.

v2: Rename DRAIN_LATENCY_MAX by DRAIN_LATENCY_MASK

v3: Addressed review comments by Ville
- Changed Sprite DDL definitions to more generic to avoid multiple if-else
- Changed bit masking to customary form
- Changed to bitwise shorthand operator for sprite_dl assignment

Looks good.

Quoted 87 lines
---
 drivers/gpu/drm/i915/i915_reg.h |    9 +++------
 drivers/gpu/drm/i915/intel_pm.c |   33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 6 deletions(-)
drivers/gpu/drm/i915/i915_reg.h +3 -6
index 08916df..f8aaf0b 100644
@@ -4000,12 +4000,9 @@ enum punit_power_well {
 #define DDL_CURSOR_PRECISION_64		(1<<31)
 #define DDL_CURSOR_PRECISION_32		(0<<31)
 #define DDL_CURSOR_SHIFT		24
-#define DDL_SPRITE1_PRECISION_64	(1<<23)
-#define DDL_SPRITE1_PRECISION_32	(0<<23)
-#define DDL_SPRITE1_SHIFT		16
-#define DDL_SPRITE0_PRECISION_64	(1<<15)
-#define DDL_SPRITE0_PRECISION_32	(0<<15)
-#define DDL_SPRITE0_SHIFT		8
+#define DDL_SPRITE_PRECISION_64(sprite)	(1<<(15+8*(sprite)))
+#define DDL_SPRITE_PRECISION_32(sprite)	(0<<(15+8*(sprite)))
+#define DDL_SPRITE_SHIFT(sprite)	(8+8*(sprite))
 #define DDL_PLANE_PRECISION_64		(1<<7)
 #define DDL_PLANE_PRECISION_32		(0<<7)
 #define DDL_PLANE_SHIFT			0
drivers/gpu/drm/i915/intel_pm.c +33 -0
index 86d6048..974aeea 100644
@@ -1500,6 +1500,37 @@ static void cherryview_update_wm(struct drm_crtc *crtc)
 		intel_set_memory_cxsr(dev_priv, true);
 }
 
+static void valleyview_update_sprite_wm(struct drm_plane *plane,
+					struct drm_crtc *crtc,
+					uint32_t sprite_width,
+					uint32_t sprite_height,
+					int pixel_size,
+					bool enabled, bool scaled)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int pipe = to_intel_plane(plane)->pipe;
+	int sprite = to_intel_plane(plane)->plane;
+	int drain_latency;
+	int plane_prec;
+	int sprite_dl;
+	int prec_mult;
+
+	sprite_dl = I915_READ(VLV_DDL(pipe)) & ~(DDL_SPRITE_PRECISION_64(sprite) |
+		    (DRAIN_LATENCY_MASK << DDL_SPRITE_SHIFT(sprite)));
+
+	if (enabled && vlv_compute_drain_latency(crtc, pixel_size, &prec_mult,
+						 &drain_latency)) {
+		plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
+					   DDL_SPRITE_PRECISION_64(sprite) :
+					   DDL_SPRITE_PRECISION_32(sprite);
+		sprite_dl |= plane_prec |
+			     (drain_latency << DDL_SPRITE_SHIFT(sprite));
+	}
+
+	I915_WRITE(VLV_DDL(pipe), sprite_dl);
+}
+
 static void g4x_update_wm(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -7231,10 +7262,12 @@ void intel_init_pm(struct drm_device *dev)
 			dev_priv->display.init_clock_gating = gen8_init_clock_gating;
 	} else if (IS_CHERRYVIEW(dev)) {
 		dev_priv->display.update_wm = cherryview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			cherryview_init_clock_gating;
 	} else if (IS_VALLEYVIEW(dev)) {
 		dev_priv->display.update_wm = valleyview_update_wm;
+		dev_priv->display.update_sprite_wm = valleyview_update_sprite_wm;
 		dev_priv->display.init_clock_gating =
 			valleyview_init_clock_gating;
 	} else if (IS_PINEVIEW(dev)) {
Signature · 6 lines
1.7.9.5

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC