All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/i915: Support variable cursor height on ivb+
Date: Fri, 12 Sep 2014 16:48:11 +0300	[thread overview]
Message-ID: <1410529691-2498-1-git-send-email-ville.syrjala@linux.intel.com> (raw)

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

IVB introduced the CUR_FBC_CTL register which allows reducing the cursor
height down to 8 lines from the otherwise square cursor dimensions.
Implement support for it.

Commandeer the otherwise unused intel_crtc->cursor_size to track the
current value of CUR_FBC_CTL so that we can avoid duplicating the
complicated device type checks in i9xx_update_cursor().

One caveat to note is that CUR_FBC_CTL can't be used with 180 degree
rotation, so when cursor rotation gets introduced some extra checks are
needed.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h      |  5 ++++-
 drivers/gpu/drm/i915/intel_display.c | 25 ++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 15c0eaa..572001b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4169,7 +4169,9 @@ enum punit_power_well {
 #define   CURSOR_POS_SIGN       0x8000
 #define   CURSOR_X_SHIFT        0
 #define   CURSOR_Y_SHIFT        16
-#define CURSIZE			0x700a0
+#define CURSIZE			0x700a0 /* 845/865 */
+#define _CUR_FBC_CTL_A		0x700a0 /* ivb+ */
+#define   CUR_FBC_CTL_EN	(1 << 31)
 #define _CURBCNTR		0x700c0
 #define _CURBBASE		0x700c4
 #define _CURBPOS		0x700c8
@@ -4185,6 +4187,7 @@ enum punit_power_well {
 #define CURCNTR(pipe) _CURSOR2(pipe, _CURACNTR)
 #define CURBASE(pipe) _CURSOR2(pipe, _CURABASE)
 #define CURPOS(pipe) _CURSOR2(pipe, _CURAPOS)
+#define CUR_FBC_CTL(pipe) _CURSOR2(pipe, _CUR_FBC_CTL_A)
 
 #define CURSOR_A_OFFSET 0x70080
 #define CURSOR_B_OFFSET 0x700c0
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ca729e5..9c000fb 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8197,6 +8197,7 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
 	uint32_t cntl;
+	uint32_t fbc_ctl = 0;
 
 	cntl = 0;
 	if (base) {
@@ -8217,6 +8218,16 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 		}
 		cntl |= pipe << 28; /* Connect to correct pipe */
 	}
+
+	if (intel_crtc->cursor_height != intel_crtc->cursor_width)
+		fbc_ctl = CUR_FBC_CTL_EN | (intel_crtc->cursor_height - 1);
+
+	if (intel_crtc->cursor_size != fbc_ctl) {
+		I915_WRITE(CUR_FBC_CTL(pipe), fbc_ctl);
+		intel_crtc->cursor_size = fbc_ctl;
+		intel_crtc->cursor_cntl = 0;
+	}
+
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		cntl |= CURSOR_PIPE_CSC_ENABLE;
 
@@ -8293,6 +8304,8 @@ static bool cursor_size_ok(struct drm_device *dev,
 	 * the width of their cursors, the height is arbitrary up to
 	 * the precision of the register. Everything else requires
 	 * square cursors, limited to a few power-of-two sizes.
+	 * ivb+ have CUR_FBC_CTL which allows reducing the cursor
+	 * height down to a minimum of 8 lines.
 	 */
 	if (IS_845G(dev) || IS_I865G(dev)) {
 		if ((width & 63) != 0)
@@ -8304,7 +8317,7 @@ static bool cursor_size_ok(struct drm_device *dev,
 		if (height > 1023)
 			return false;
 	} else {
-		switch (width | height) {
+		switch (width) {
 		case 256:
 		case 128:
 			if (IS_GEN2(dev))
@@ -8314,6 +8327,16 @@ static bool cursor_size_ok(struct drm_device *dev,
 		default:
 			return false;
 		}
+
+		if (IS_IVYBRIDGE(dev) ||
+		    IS_HASWELL(dev) || IS_BROADWELL(dev) ||
+		    INTEL_INFO(dev)->gen >= 9) {
+			if (height < 8 || height > width)
+				return false;
+		} else {
+			if (height != width)
+				return false;
+		}
 	}
 
 	return true;
-- 
1.8.5.5

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

             reply	other threads:[~2014-09-12 13:48 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-12 13:48 ville.syrjala [this message]
2014-09-12 14:00 ` [PATCH v2] drm/i915: Support variable cursor height on ivb+ ville.syrjala
2014-09-12 17:53   ` [PATCH v3 1/4] drm/i915: Move the cursor_base setup to i{845, 9xx}_update_cursor() ville.syrjala
2014-09-12 17:53     ` [PATCH v3 2/4] drm/i915: Only set CURSOR_PIPE_CSC_ENABLE when cursor is enabled ville.syrjala
2014-09-13 16:17       ` Chris Wilson
2014-09-15  9:12         ` Daniel Vetter
2014-09-12 17:53     ` [PATCH v3 3/4] drm/i915: Skip CURBASE write when nothing changed ville.syrjala
2014-09-13 16:20       ` Chris Wilson
2014-09-15 13:36         ` Ville Syrjälä
2014-09-15 13:46           ` Chris Wilson
2014-09-12 17:53     ` [PATCH v3 4/4] drm/i915: Support variable cursor height on ivb+ ville.syrjala
2014-09-13 16:23       ` Chris Wilson
2014-09-15 13:31         ` Ville Syrjälä
2014-09-13 16:15     ` [PATCH v3 1/4] drm/i915: Move the cursor_base setup to i{845, 9xx}_update_cursor() Chris Wilson

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=1410529691-2498-1-git-send-email-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.