public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Jesse Barnes <jbarnes@virtuousgeek.org>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/3] drm/i915: track sprite coverage and disable primary plane if possible
Date: Tue,  8 Nov 2011 13:19:46 -0800	[thread overview]
Message-ID: <1320787186-5508-3-git-send-email-jbarnes@virtuousgeek.org> (raw)
In-Reply-To: <1320787186-5508-1-git-send-email-jbarnes@virtuousgeek.org>

To save power when the sprite is full screen, we can disable the primary
plane on the same pipe.  Track the sprite status and enable/disable the
primary opportunistically.

Signed-off-by: Jesse Barnes
---
 drivers/gpu/drm/i915/intel_drv.h    |    3 ++
 drivers/gpu/drm/i915/intel_sprite.c |   67 +++++++++++++++++++++++++++++++++++
 2 files changed, 70 insertions(+), 0 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b0081d2..d534e1e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -180,6 +180,7 @@ struct intel_plane {
 	struct drm_plane base;
 	enum pipe pipe;
 	struct drm_i915_gem_object *obj;
+	bool primary_disabled;
 	int max_downscale;
 	u32 lut_r[1024], lut_g[1024], lut_b[1024];
 	void (*update_plane)(struct drm_plane *plane,
@@ -191,6 +192,8 @@ struct intel_plane {
 	void (*disable_plane)(struct drm_plane *plane);
 	int (*update_destkey)(struct drm_plane *plane, u32 value);
 	u32 (*get_destkey)(struct drm_plane *plane);
+	void (*enable_primary)(struct drm_crtc *crtc);
+	void (*disable_primary)(struct drm_crtc *crtc);
 };
 
 #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 7c6c6c7..384a4a7 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -48,6 +48,28 @@
  */
 
 static void
+ivb_enable_primary(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int reg = DSPCNTR(intel_crtc->plane);
+
+	I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE);
+}
+
+static void
+ivb_disable_primary(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int reg = DSPCNTR(intel_crtc->plane);
+
+	I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE);
+}
+
+static void
 ivb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 		 unsigned long start, int crtc_x, int crtc_y,
 		 unsigned int crtc_w, unsigned int crtc_h,
@@ -180,6 +202,28 @@ ivb_get_destkey(struct drm_plane *plane)
 }
 
 static void
+snb_enable_primary(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int reg = DSPCNTR(intel_crtc->plane);
+
+	I915_WRITE(reg, I915_READ(reg) | DISPLAY_PLANE_ENABLE);
+}
+
+static void
+snb_disable_primary(struct drm_crtc *crtc)
+{
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	int reg = DSPCNTR(intel_crtc->plane);
+
+	I915_WRITE(reg, I915_READ(reg) & ~DISPLAY_PLANE_ENABLE);
+}
+
+static void
 snb_update_plane(struct drm_plane *plane, struct drm_framebuffer *fb,
 		 unsigned long start, int crtc_x, int crtc_y,
 		 unsigned int crtc_w, unsigned int crtc_h,
@@ -395,9 +439,23 @@ intel_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	start = obj->gtt_offset;
 
+	/*
+	 * Be sure to re-enable the primary before the sprite is no longer
+	 * covering it fully.
+	 */
+	if (!disable_primary && intel_plane->primary_disabled) {
+		intel_plane->enable_primary(crtc);
+		intel_plane->primary_disabled = false;
+	}
+
 	intel_plane->update_plane(plane, fb, start, crtc_x, crtc_y,
 				  crtc_w, crtc_h, x, y, src_w, src_h);
 
+	if (disable_primary) {
+		intel_plane->disable_primary(crtc);
+		intel_plane->primary_disabled = true;
+	}
+
 	/* Unpin old obj after new one is active to avoid ugliness */
 	if (old_obj) {
 		/*
@@ -427,6 +485,11 @@ intel_disable_plane(struct drm_plane *plane)
 
 	mutex_lock(&dev->struct_mutex);
 
+	if (intel_plane->primary_disabled) {
+		intel_plane->enable_primary(plane->crtc);
+		intel_plane->primary_disabled = false;
+	}
+
 	intel_plane->disable_plane(plane);
 
 	if (!intel_plane->obj)
@@ -556,12 +619,16 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe)
 		intel_plane->disable_plane = snb_disable_plane;
 		intel_plane->update_destkey = snb_update_destkey;
 		intel_plane->get_destkey = snb_get_destkey;
+		intel_plane->enable_primary = ivb_enable_primary;
+		intel_plane->disable_primary = ivb_disable_primary;
 	} else if (IS_GEN7(dev)) {
 		intel_plane->max_downscale = 2;
 		intel_plane->update_plane = ivb_update_plane;
 		intel_plane->disable_plane = ivb_disable_plane;
 		intel_plane->update_destkey = ivb_update_destkey;
 		intel_plane->get_destkey = ivb_get_destkey;
+		intel_plane->enable_primary = snb_enable_primary;
+		intel_plane->disable_primary = snb_disable_primary;
 	}
 
 	intel_plane->pipe = pipe;
-- 
1.7.4.1

  parent reply	other threads:[~2011-11-08 21:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-08 21:19 [PATCH 1/3] drm/i915: add SNB and IVB video sprite support Jesse Barnes
2011-11-08 21:19 ` [PATCH 2/3] drm/i915: add destination color key support Jesse Barnes
2011-11-08 21:19 ` Jesse Barnes [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-11-14 19:47 [PATCH 1/3] drm/i915: add SNB and IVB video sprite support v2 Jesse Barnes
2011-11-14 19:47 ` [PATCH 3/3] drm/i915: track sprite coverage and disable primary plane if possible Jesse Barnes
2011-11-14 20:22 [PATCH 1/3] drm/i915: add SNB and IVB video sprite support v2 Jesse Barnes
2011-11-14 20:22 ` [PATCH 3/3] drm/i915: track sprite coverage and disable primary plane if possible Jesse Barnes
2011-11-16 16:05   ` Daniel Vetter
2011-11-16 16:46     ` Jesse Barnes
2011-12-07 20:29 Plane support for SNB and IVB Jesse Barnes
2011-12-07 20:29 ` [PATCH 3/3] drm/i915: track sprite coverage and disable primary plane if possible Jesse Barnes
2011-12-12 22:17   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320787186-5508-3-git-send-email-jbarnes@virtuousgeek.org \
    --to=jbarnes@virtuousgeek.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox