All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 03/15] drm/i915: Refactor CURBASE calculation
Date: Mon, 27 Mar 2017 21:55:34 +0300	[thread overview]
Message-ID: <20170327185546.2977-4-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20170327185546.2977-1-ville.syrjala@linux.intel.com>

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

The remaining cursor base address calculations are spread
around into several different locations. Just pull it all
into one place.

v2: Don't pass intel_plane as we don't really need it

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_display.c | 49 +++++++++++++++++++++---------------
 1 file changed, 29 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index f737a743bdf6..5e04f64a0f76 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9126,6 +9126,31 @@ static bool haswell_get_pipe_config(struct intel_crtc *crtc,
 	return active;
 }
 
+static u32 intel_cursor_base(struct intel_crtc *crtc,
+			     const struct intel_plane_state *plane_state)
+{
+	struct drm_i915_private *dev_priv =
+		to_i915(plane_state->base.plane->dev);
+	const struct drm_framebuffer *fb = plane_state->base.fb;
+	const struct drm_i915_gem_object *obj = intel_fb_obj(fb);
+	u32 base;
+
+	if (INTEL_INFO(dev_priv)->cursor_needs_physical)
+		base = obj->phys_handle->busaddr;
+	else
+		base = intel_plane_ggtt_offset(plane_state);
+
+	crtc->cursor_addr = base;
+
+	/* ILK+ do this automagically */
+	if (HAS_GMCH_DISPLAY(dev_priv) &&
+	    plane_state->base.rotation & DRM_ROTATE_180)
+		base += (plane_state->base.crtc_h *
+			 plane_state->base.crtc_w - 1) * fb->format->cpp[0];
+
+	return base;
+}
+
 static u32 i845_cursor_ctl(const struct intel_crtc_state *crtc_state,
 			   const struct intel_plane_state *plane_state)
 {
@@ -9265,9 +9290,8 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	int pipe = intel_crtc->pipe;
-	u32 base = intel_crtc->cursor_addr;
+	u32 pos = 0, base = 0;
 	unsigned long irqflags;
-	u32 pos = 0;
 
 	if (plane_state) {
 		int x = plane_state->base.crtc_x;
@@ -9285,12 +9309,9 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 		}
 		pos |= y << CURSOR_Y_SHIFT;
 
-		/* ILK+ do this automagically */
-		if (HAS_GMCH_DISPLAY(dev_priv) &&
-		    plane_state->base.rotation & DRM_ROTATE_180) {
-			base += (plane_state->base.crtc_h *
-				 plane_state->base.crtc_w - 1) * 4;
-		}
+		base = intel_cursor_base(intel_crtc, plane_state);
+	} else {
+		intel_crtc->cursor_addr = 0;
 	}
 
 	spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
@@ -13735,7 +13756,6 @@ static void
 intel_disable_cursor_plane(struct intel_plane *plane,
 			   struct intel_crtc *crtc)
 {
-	crtc->cursor_addr = 0;
 	intel_crtc_update_cursor(&crtc->base, NULL);
 }
 
@@ -13744,19 +13764,8 @@ intel_update_cursor_plane(struct intel_plane *plane,
 			  const struct intel_crtc_state *crtc_state,
 			  const struct intel_plane_state *state)
 {
-	struct drm_i915_private *dev_priv = to_i915(plane->base.dev);
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->base.crtc);
-	struct drm_i915_gem_object *obj = intel_fb_obj(state->base.fb);
-	uint32_t addr;
-
-	if (!obj)
-		addr = 0;
-	else if (!INTEL_INFO(dev_priv)->cursor_needs_physical)
-		addr = intel_plane_ggtt_offset(state);
-	else
-		addr = obj->phys_handle->busaddr;
 
-	crtc->cursor_addr = addr;
 	intel_crtc_update_cursor(&crtc->base, state);
 }
 
-- 
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-27 18:55 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-27 18:55 [PATCH v2 00/15] drm/i915: Cursor code cleanup and cursor "FBC" support for IVB+ (v2) ville.syrjala
2017-03-27 18:55 ` [PATCH 01/15] drm/i915: Parametrize cursor/primary pipe select bits ville.syrjala
2017-03-27 18:55 ` [PATCH 02/15] drm/i915: Pass intel_plane and intel_crtc to plane hooks ville.syrjala
2017-03-27 18:55 ` ville.syrjala [this message]
2017-03-27 18:55 ` [PATCH 04/15] drm/i915: Clean up cursor junk from intel_crtc ville.syrjala
2017-05-04 19:42   ` Imre Deak
2017-03-27 18:55 ` [PATCH v2 05/15] drm/i915: Refactor CURPOS calculation ville.syrjala
2017-03-27 18:55 ` [PATCH v2 06/15] drm/i915: Move cursor position and base handling into the platform specific functions ville.syrjala
2017-03-27 18:55 ` [PATCH v2 07/15] drm/i915: Drop useless posting reads from cursor commit ville.syrjala
2017-03-27 18:55 ` [PATCH v2 08/15] drm/i915: Split cursor check_plane into i845 and i9xx variants ville.syrjala
2017-03-27 18:55 ` [PATCH 09/15] drm/i915: Generalize cursor size checks a bit ville.syrjala
2017-05-05 13:57   ` Imre Deak
2017-03-27 18:55 ` [PATCH v2 10/15] drm/i915: Use fb->pitches[0] in cursor code ville.syrjala
2017-03-27 18:55 ` [PATCH v7 11/15] drm/i915: Support variable cursor height on ivb+ ville.syrjala
2017-05-05 15:42   ` Imre Deak
2017-03-27 18:55 ` [PATCH 12/15] drm/i915: Fix gen3 physical cursor alignment requirements ville.syrjala
2017-05-05 17:48   ` Imre Deak
2017-03-27 18:55 ` [PATCH 13/15] drm/i915: Handle fb offset and src coordinates for cursors ville.syrjala
2017-05-05 20:53   ` Imre Deak
2017-03-27 18:55 ` [PATCH 14/15] drm/i915: Relax 845/865 CURBASE alignemnt requirement to 32 bytes ville.syrjala
2017-05-05 21:17   ` Imre Deak
2017-03-27 18:55 ` [PATCH 15/15] drm/i915: Simplify cursor register write sequence ville.syrjala
2017-05-05 21:31   ` Imre Deak
2017-05-10 16:38     ` Ville Syrjälä
2017-03-27 19:14 ` ✓ Fi.CI.BAT: success for drm/i915: Cursor code cleanup and cursor "FBC" support for IVB+ (rev2) 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=20170327185546.2977-4-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.