[Intel-gfx] [PATCH 05/10] drm/i915: Refactor CURPOS calculation

ville.syrjala at linux.intel.com ville.syrjala at linux.intel.com
Tue Mar 7 15:27:04 UTC 2017


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

Move the CURPOS calculations to seprate function. This will allow
sharing the code between the 845/865 vs. others codepaths when we
otherwise split them apart.

Signed-off-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 38 ++++++++++++++++++++++--------------
 1 file changed, 23 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 191685a37200..b6786fc1d883 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -9175,6 +9175,28 @@ static u32 intel_cursor_base(struct intel_plane *plane,
 	return base;
 }
 
+static u32 intel_cursor_position(struct intel_plane *plane,
+				 const struct intel_plane_state *plane_state)
+{
+	int x = plane_state->base.crtc_x;
+	int y = plane_state->base.crtc_y;
+	u32 pos = 0;
+
+	if (x < 0) {
+		pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
+		x = -x;
+	}
+	pos |= x << CURSOR_X_SHIFT;
+
+	if (y < 0) {
+		pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
+		y = -y;
+	}
+	pos |= y << CURSOR_Y_SHIFT;
+
+	return pos;
+}
+
 static void i845_update_cursor(struct intel_plane *plane, u32 base,
 			       const struct intel_plane_state *plane_state)
 {
@@ -9291,22 +9313,8 @@ static void intel_crtc_update_cursor(struct intel_plane *plane,
 	u32 pos = 0, base = 0;
 
 	if (plane_state) {
-		int x = plane_state->base.crtc_x;
-		int y = plane_state->base.crtc_y;
-
-		if (x < 0) {
-			pos |= CURSOR_POS_SIGN << CURSOR_X_SHIFT;
-			x = -x;
-		}
-		pos |= x << CURSOR_X_SHIFT;
-
-		if (y < 0) {
-			pos |= CURSOR_POS_SIGN << CURSOR_Y_SHIFT;
-			y = -y;
-		}
-		pos |= y << CURSOR_Y_SHIFT;
-
 		base = intel_cursor_base(plane, plane_state);
+		pos = intel_cursor_position(plane, plane_state);
 	}
 
 	I915_WRITE(CURPOS(pipe), pos);
-- 
2.10.2



More information about the Intel-gfx mailing list