All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 10/10] drm/i915: Support variable cursor height on ivb+
Date: Tue,  7 Mar 2017 17:27:09 +0200	[thread overview]
Message-ID: <20170307152709.31957-11-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20170307152709.31957-1-ville.syrjala@linux.intel.com>

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. CUR_FBC_CTL can't be used when the cursor
is rotated.

Commandeer the otherwise unused cursor->cursor.size to track the
current value of CUR_FBC_CTL to optimize away redundant CUR_FBC_CTL
writes, and to notice when we need to arm the update via CURBASE if
just CUR_FBC_CTL changes.

v2: Reverse the gen check to make it sane
v3: Only enable CUR_FBC_CTL when cursor is enabled, adapt to
    earlier code changes which means we now actually turn off
    the cursor when we're supposed to unlike v2
v4: Add a comment about rotation vs. CUR_FBC_CTL,
    rebase due to 'dirty' (Chris)
v5: Rebase to the atomic world
    Handle 180 degree rotation
    Add HAS_CUR_FBC()
v6: Rebase

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

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b7ec6636e2a0..c96b667d6e6e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2900,6 +2900,7 @@ intel_info(const struct drm_i915_private *dev_priv)
 #define HAS_FW_BLC(dev_priv) 	(INTEL_GEN(dev_priv) > 2)
 #define HAS_PIPE_CXSR(dev_priv) ((dev_priv)->info.has_pipe_cxsr)
 #define HAS_FBC(dev_priv)	((dev_priv)->info.has_fbc)
+#define HAS_CUR_FBC(dev_priv)	(!HAS_GMCH_DISPLAY(dev_priv) && INTEL_INFO(dev_priv)->gen >= 7)
 
 #define HAS_IPS(dev_priv)	(IS_HSW_ULT(dev_priv) || IS_BROADWELL(dev_priv))
 
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 07cae03e8727..cfcb139e5952 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -5449,7 +5449,9 @@ enum {
 #define   CURSOR_POS_SIGN       0x8000
 #define   CURSOR_X_SHIFT        0
 #define   CURSOR_Y_SHIFT        16
-#define CURSIZE			_MMIO(0x700a0)
+#define CURSIZE			_MMIO(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
@@ -5465,6 +5467,7 @@ enum {
 #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 17362dc9f438..13b31e929631 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9347,7 +9347,7 @@ static void i9xx_update_cursor(struct intel_plane *plane,
 {
 	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
 	enum pipe pipe = plane->pipe;
-	u32 cntl = 0, base = 0, pos = 0;
+	u32 cntl = 0, base = 0, pos = 0, size = 0;
 
 	if (plane_state && plane_state->base.visible) {
 		cntl = MCURSOR_GAMMA_ENABLE;
@@ -9376,15 +9376,22 @@ static void i9xx_update_cursor(struct intel_plane *plane,
 
 		base = intel_cursor_base(plane, plane_state);
 		pos = intel_cursor_position(plane, plane_state);
+
+		if (plane_state->base.crtc_h != plane_state->base.crtc_w)
+			size = CUR_FBC_CTL_EN | (plane_state->base.crtc_h - 1);
 	}
 
 	if (plane->cursor.cntl != cntl)
 		I915_WRITE(CURCNTR(pipe), cntl);
 
+	if (plane->cursor.size != size)
+		I915_WRITE(CUR_FBC_CTL(pipe), size);
+
 	if (cntl)
 		I915_WRITE(CURPOS(pipe), pos);
 
 	if (plane->cursor.cntl != cntl ||
+	    plane->cursor.size != size ||
 	    plane->cursor.base != base)
 		I915_WRITE(CURBASE(pipe), base);
 
@@ -9392,6 +9399,7 @@ static void i9xx_update_cursor(struct intel_plane *plane,
 
 	plane->cursor.cntl = cntl;
 	plane->cursor.base = base;
+	plane->cursor.size = size;
 }
 
 static void i9xx_disable_cursor(struct intel_plane *plane,
@@ -9410,11 +9418,8 @@ static bool i9xx_cursor_size_ok(const struct intel_plane_state *plane_state)
 	if (width == 0 || height == 0)
 		return false;
 
-	/*
-	 * Cursors are limited to a few power-of-two
-	 * sizes, and they must be square.
-	 */
-	switch (width | height) {
+	/* Cursor width is limited to a few power-of-two sizes */
+	switch (width) {
 	case 256:
 	case 128:
 		if (IS_GEN2(dev_priv))
@@ -9425,6 +9430,21 @@ static bool i9xx_cursor_size_ok(const struct intel_plane_state *plane_state)
 		return false;
 	}
 
+	/*
+	 * IVB+ have CUR_FBC_CTL which allows an arbitrary cursor
+	 * height from 8 lines up to the cursor width, when the
+	 * cursor is not rotated. Everything else requires square
+	 * cursors.
+	 */
+	if (HAS_CUR_FBC(dev_priv) &&
+	    plane_state->base.rotation & DRM_ROTATE_0) {
+		if (height < 8 || height > width)
+			return false;
+	} else {
+		if (height != width)
+			return false;
+	}
+
 	return true;
 }
 
@@ -13833,7 +13853,9 @@ intel_cursor_plane_create(struct drm_i915_private *dev_priv,
 
 	cursor->cursor.base = ~0;
 	cursor->cursor.cntl = ~0;
-	cursor->cursor.size = ~0;
+
+	if (IS_I845G(dev_priv) || IS_I865G(dev_priv) || HAS_CUR_FBC(dev_priv))
+		cursor->cursor.size = ~0;
 
 	ret = drm_universal_plane_init(&dev_priv->drm, &cursor->base,
 				       0, &intel_cursor_plane_funcs,
-- 
2.10.2

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

  parent reply	other threads:[~2017-03-07 15:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 15:26 [PATCH 00/10] drm/i915: Cursor code cleanup and cursor "FBC" support for IVB+ ville.syrjala
2017-03-07 15:27 ` [PATCH 01/10] drm/i915: Parametrize cursor/primary pipe select bits ville.syrjala
2017-03-07 21:51   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 02/10] drm/i915: Pass intel_plane and intel_crtc to plane hooks ville.syrjala
2017-03-07 21:50   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 03/10] drm/i915: Refactor CURBASE calculation ville.syrjala
2017-03-07 21:56   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 04/10] drm/i915: Clean up cursor junk from intel_crtc ville.syrjala
2017-03-07 22:33   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 05/10] drm/i915: Refactor CURPOS calculation ville.syrjala
2017-03-07 21:49   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 06/10] drm/i915: Move cursor position and base handling into the platform specific functions ville.syrjala
2017-03-07 22:35   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 07/10] drm/i915: Drop useless posting reads from cursor commit ville.syrjala
2017-03-07 22:00   ` Chris Wilson
2017-03-07 15:27 ` [PATCH 08/10] drm/i915: Split cursor check_plane into i845 and i9xx variants ville.syrjala
2017-03-07 22:24   ` Chris Wilson
2017-03-08 10:52     ` Ville Syrjälä
2017-03-07 15:27 ` [PATCH 09/10] drm/i915: Use fb->pitches[0] in cursor code ville.syrjala
2017-03-07 22:25   ` Chris Wilson
2017-03-07 15:27 ` ville.syrjala [this message]
2017-03-07 22:32   ` [PATCH 10/10] drm/i915: Support variable cursor height on ivb+ Chris Wilson
2017-03-08 10:40     ` Ville Syrjälä
2017-03-08 11:00       ` Chris Wilson
2017-03-08 10:45     ` Daniel Vetter
2017-03-07 16:18 ` ✓ Fi.CI.BAT: success for drm/i915: Cursor code cleanup and cursor "FBC" support for IVB+ Patchwork

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=20170307152709.31957-11-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.