All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] drm/i915: Update plane parameters for cursor plane
@ 2014-09-15  7:35 sonika.jindal
  2014-09-15  7:35 ` [PATCH 2/2] drm/i915: Add rotation support " sonika.jindal
  2014-09-15  7:55 ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane Jani Nikula
  0 siblings, 2 replies; 12+ messages in thread
From: sonika.jindal @ 2014-09-15  7:35 UTC (permalink / raw)
  To: intel-gfx

From: Sonika Jindal <sonika.jindal@intel.com>

This allows the cursor plane to be updated the same way as primary and sprites,
and same set_property handler is used for all of these planes.

Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c |   27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 842a5e1..122ac6e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12019,6 +12019,22 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 		.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0,
 		.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0,
 	};
+	const struct {
+		int crtc_x, crtc_y;
+		unsigned int crtc_w, crtc_h;
+		uint32_t src_x, src_y, src_w, src_h;
+	} orig = {
+		.crtc_x = crtc_x,
+		.crtc_y = crtc_y,
+		.crtc_w = crtc_w,
+		.crtc_h = crtc_h,
+		.src_x = src_x,
+		.src_y = src_y,
+		.src_w = src_w,
+		.src_h = src_h,
+	};
+	struct intel_plane *intel_plane = to_intel_plane(plane);
+
 	bool visible;
 	int ret;
 
@@ -12032,6 +12048,17 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
 
 	crtc->cursor_x = crtc_x;
 	crtc->cursor_y = crtc_y;
+
+	intel_plane->crtc_x = orig.crtc_x;
+	intel_plane->crtc_y = orig.crtc_y;
+	intel_plane->crtc_w = orig.crtc_w;
+	intel_plane->crtc_h = orig.crtc_h;
+	intel_plane->src_x = orig.src_x;
+	intel_plane->src_y = orig.src_y;
+	intel_plane->src_w = orig.src_w;
+	intel_plane->src_h = orig.src_h;
+	intel_plane->obj = obj;
+
 	if (fb != crtc->cursor->fb) {
 		return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h);
 	} else {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] drm/i915: Add rotation support for cursor plane
  2014-09-15  7:35 [PATCH 1/2] drm/i915: Update plane parameters for cursor plane sonika.jindal
@ 2014-09-15  7:35 ` sonika.jindal
  2014-09-15  7:43   ` [PATCH] " sonika.jindal
  2014-09-15  7:55 ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane Jani Nikula
  1 sibling, 1 reply; 12+ messages in thread
From: sonika.jindal @ 2014-09-15  7:35 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble

From: Sonika Jindal <sonika.jindal@intel.com>

The cursor plane also supports 180 degree rotation. Add a new
"cursor-rotation" property on the crtc which controls this.

Unlike sprites, the cursor has a fixed size, so if you have a small
cursor image with the rest of the bo filled by transparent pixels,
simply flipping the rotation property will cause the visible part
of the cursor to shift. This is something to keep in mind when
using cursor rotation.

v2: Fix gen4/vlv by offsetting the base address appropriately

v3: Removing cursor-rotation property and using rotation property on cursor
plane.

Testcase: kms_rotation_crc

Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |   26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 15c0eaa..5a9fab9 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4162,6 +4162,7 @@ enum punit_power_well {
 #define   MCURSOR_PIPE_A	0x00
 #define   MCURSOR_PIPE_B	(1 << 28)
 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
+#define   CURSOR_ROTATE_180	(1<<15)
 #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
 #define _CURABASE		0x70084
 #define _CURAPOS		0x70088
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 122ac6e..8c83bcc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8247,6 +8247,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		cntl |= CURSOR_PIPE_CSC_ENABLE;
 
+	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
+		cntl |= CURSOR_ROTATE_180;
+
 	if (intel_crtc->cursor_cntl != cntl) {
 		I915_WRITE(CURCNTR(pipe), cntl);
 		POSTING_READ(CURCNTR(pipe));
@@ -8302,6 +8305,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 
 	I915_WRITE(CURPOS(pipe), pos);
 
+	/* ILK+ do this automagically */
+	if (HAS_GMCH_DISPLAY(dev) &&
+		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
+		base += (intel_crtc->cursor_height *
+			intel_crtc->cursor_width - 1) * 4;
+	}
+
 	if (IS_845G(dev) || IS_I865G(dev))
 		i845_update_cursor(crtc, base);
 	else
@@ -8453,7 +8463,6 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
 	mutex_unlock(&dev->struct_mutex);
 
 	old_width = intel_crtc->cursor_width;
-
 	intel_crtc->cursor_addr = addr;
 	intel_crtc->cursor_bo = obj;
 	intel_crtc->cursor_width = width;
@@ -12074,6 +12083,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.update_plane = intel_cursor_plane_update,
 	.disable_plane = intel_cursor_plane_disable,
 	.destroy = intel_plane_destroy,
+	.set_property = intel_plane_set_property,
 };
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
@@ -12089,12 +12099,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
 	cursor->plane = pipe;
+	cursor->rotation = BIT(DRM_ROTATE_0);
 
 	drm_universal_plane_init(dev, &cursor->base, 0,
 				 &intel_cursor_plane_funcs,
 				 intel_cursor_formats,
 				 ARRAY_SIZE(intel_cursor_formats),
 				 DRM_PLANE_TYPE_CURSOR);
+
+	if (INTEL_INFO(dev)->gen >= 4) {
+		if (!dev->mode_config.rotation_property)
+			dev->mode_config.rotation_property =
+				drm_mode_create_rotation_property(dev,
+							BIT(DRM_ROTATE_0) |
+							BIT(DRM_ROTATE_180));
+		if (dev->mode_config.rotation_property)
+			drm_object_attach_property(&cursor->base.base,
+				dev->mode_config.rotation_property,
+				cursor->rotation);
+	}
+
 	return &cursor->base;
 }
 
-- 
1.7.10.4

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH] drm/i915: Add rotation support for cursor plane
  2014-09-15  7:35 ` [PATCH 2/2] drm/i915: Add rotation support " sonika.jindal
@ 2014-09-15  7:43   ` sonika.jindal
  2014-10-07  8:43     ` Jindal, Sonika
  0 siblings, 1 reply; 12+ messages in thread
From: sonika.jindal @ 2014-09-15  7:43 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble

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

The cursor plane also supports 180 degree rotation. Add a new
"cursor-rotation" property on the crtc which controls this.

Unlike sprites, the cursor has a fixed size, so if you have a small
cursor image with the rest of the bo filled by transparent pixels,
simply flipping the rotation property will cause the visible part
of the cursor to shift. This is something to keep in mind when
using cursor rotation.

v2: Fix gen4/vlv by offsetting the base address appropriately

v3: Removing cursor-rotation property and using rotation property on cursor
plane.
v4: Changing the author name back to Ville.

Testcase: kms_rotation_crc

Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |   26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 15c0eaa..5a9fab9 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4162,6 +4162,7 @@ enum punit_power_well {
 #define   MCURSOR_PIPE_A	0x00
 #define   MCURSOR_PIPE_B	(1 << 28)
 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
+#define   CURSOR_ROTATE_180	(1<<15)
 #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
 #define _CURABASE		0x70084
 #define _CURAPOS		0x70088
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 122ac6e..8c83bcc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8247,6 +8247,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		cntl |= CURSOR_PIPE_CSC_ENABLE;
 
+	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
+		cntl |= CURSOR_ROTATE_180;
+
 	if (intel_crtc->cursor_cntl != cntl) {
 		I915_WRITE(CURCNTR(pipe), cntl);
 		POSTING_READ(CURCNTR(pipe));
@@ -8302,6 +8305,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 
 	I915_WRITE(CURPOS(pipe), pos);
 
+	/* ILK+ do this automagically */
+	if (HAS_GMCH_DISPLAY(dev) &&
+		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
+		base += (intel_crtc->cursor_height *
+			intel_crtc->cursor_width - 1) * 4;
+	}
+
 	if (IS_845G(dev) || IS_I865G(dev))
 		i845_update_cursor(crtc, base);
 	else
@@ -8453,7 +8463,6 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
 	mutex_unlock(&dev->struct_mutex);
 
 	old_width = intel_crtc->cursor_width;
-
 	intel_crtc->cursor_addr = addr;
 	intel_crtc->cursor_bo = obj;
 	intel_crtc->cursor_width = width;
@@ -12074,6 +12083,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.update_plane = intel_cursor_plane_update,
 	.disable_plane = intel_cursor_plane_disable,
 	.destroy = intel_plane_destroy,
+	.set_property = intel_plane_set_property,
 };
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
@@ -12089,12 +12099,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
 	cursor->plane = pipe;
+	cursor->rotation = BIT(DRM_ROTATE_0);
 
 	drm_universal_plane_init(dev, &cursor->base, 0,
 				 &intel_cursor_plane_funcs,
 				 intel_cursor_formats,
 				 ARRAY_SIZE(intel_cursor_formats),
 				 DRM_PLANE_TYPE_CURSOR);
+
+	if (INTEL_INFO(dev)->gen >= 4) {
+		if (!dev->mode_config.rotation_property)
+			dev->mode_config.rotation_property =
+				drm_mode_create_rotation_property(dev,
+							BIT(DRM_ROTATE_0) |
+							BIT(DRM_ROTATE_180));
+		if (dev->mode_config.rotation_property)
+			drm_object_attach_property(&cursor->base.base,
+				dev->mode_config.rotation_property,
+				cursor->rotation);
+	}
+
 	return &cursor->base;
 }
 
-- 
1.7.10.4

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] drm/i915: Update plane parameters for cursor plane
  2014-09-15  7:35 [PATCH 1/2] drm/i915: Update plane parameters for cursor plane sonika.jindal
  2014-09-15  7:35 ` [PATCH 2/2] drm/i915: Add rotation support " sonika.jindal
@ 2014-09-15  7:55 ` Jani Nikula
  2014-09-15 10:43   ` Jindal, Sonika
  1 sibling, 1 reply; 12+ messages in thread
From: Jani Nikula @ 2014-09-15  7:55 UTC (permalink / raw)
  To: sonika.jindal, intel-gfx


Please look into this first:
https://bugs.freedesktop.org/show_bug.cgi?id=83130

BR,
Jani.


On Mon, 15 Sep 2014, sonika.jindal@intel.com wrote:
> From: Sonika Jindal <sonika.jindal@intel.com>
>
> This allows the cursor plane to be updated the same way as primary and sprites,
> and same set_property handler is used for all of these planes.
>
> Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c |   27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 842a5e1..122ac6e 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12019,6 +12019,22 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
>  		.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0,
>  		.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0,
>  	};
> +	const struct {
> +		int crtc_x, crtc_y;
> +		unsigned int crtc_w, crtc_h;
> +		uint32_t src_x, src_y, src_w, src_h;
> +	} orig = {
> +		.crtc_x = crtc_x,
> +		.crtc_y = crtc_y,
> +		.crtc_w = crtc_w,
> +		.crtc_h = crtc_h,
> +		.src_x = src_x,
> +		.src_y = src_y,
> +		.src_w = src_w,
> +		.src_h = src_h,
> +	};
> +	struct intel_plane *intel_plane = to_intel_plane(plane);
> +
>  	bool visible;
>  	int ret;
>  
> @@ -12032,6 +12048,17 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
>  
>  	crtc->cursor_x = crtc_x;
>  	crtc->cursor_y = crtc_y;
> +
> +	intel_plane->crtc_x = orig.crtc_x;
> +	intel_plane->crtc_y = orig.crtc_y;
> +	intel_plane->crtc_w = orig.crtc_w;
> +	intel_plane->crtc_h = orig.crtc_h;
> +	intel_plane->src_x = orig.src_x;
> +	intel_plane->src_y = orig.src_y;
> +	intel_plane->src_w = orig.src_w;
> +	intel_plane->src_h = orig.src_h;
> +	intel_plane->obj = obj;
> +
>  	if (fb != crtc->cursor->fb) {
>  		return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h);
>  	} else {
> -- 
> 1.7.10.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH 1/2] drm/i915: Update plane parameters for cursor plane
  2014-09-15  7:55 ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane Jani Nikula
@ 2014-09-15 10:43   ` Jindal, Sonika
  0 siblings, 0 replies; 12+ messages in thread
From: Jindal, Sonika @ 2014-09-15 10:43 UTC (permalink / raw)
  To: Jani Nikula, intel-gfx

Ok, let me check this.

Regards,
Sonika

-----Original Message-----
From: Jani Nikula [mailto:jani.nikula@linux.intel.com] 
Sent: Monday, September 15, 2014 1:26 PM
To: Jindal, Sonika; intel-gfx@lists.freedesktop.org
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915: Update plane parameters for cursor plane


Please look into this first:
https://bugs.freedesktop.org/show_bug.cgi?id=83130

BR,
Jani.


On Mon, 15 Sep 2014, sonika.jindal@intel.com wrote:
> From: Sonika Jindal <sonika.jindal@intel.com>
>
> This allows the cursor plane to be updated the same way as primary and 
> sprites, and same set_property handler is used for all of these planes.
>
> Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c |   27 +++++++++++++++++++++++++++
>  1 file changed, 27 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_display.c 
> b/drivers/gpu/drm/i915/intel_display.c
> index 842a5e1..122ac6e 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -12019,6 +12019,22 @@ intel_cursor_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,
>  		.x2 = intel_crtc->active ? intel_crtc->config.pipe_src_w : 0,
>  		.y2 = intel_crtc->active ? intel_crtc->config.pipe_src_h : 0,
>  	};
> +	const struct {
> +		int crtc_x, crtc_y;
> +		unsigned int crtc_w, crtc_h;
> +		uint32_t src_x, src_y, src_w, src_h;
> +	} orig = {
> +		.crtc_x = crtc_x,
> +		.crtc_y = crtc_y,
> +		.crtc_w = crtc_w,
> +		.crtc_h = crtc_h,
> +		.src_x = src_x,
> +		.src_y = src_y,
> +		.src_w = src_w,
> +		.src_h = src_h,
> +	};
> +	struct intel_plane *intel_plane = to_intel_plane(plane);
> +
>  	bool visible;
>  	int ret;
>  
> @@ -12032,6 +12048,17 @@ intel_cursor_plane_update(struct drm_plane 
> *plane, struct drm_crtc *crtc,
>  
>  	crtc->cursor_x = crtc_x;
>  	crtc->cursor_y = crtc_y;
> +
> +	intel_plane->crtc_x = orig.crtc_x;
> +	intel_plane->crtc_y = orig.crtc_y;
> +	intel_plane->crtc_w = orig.crtc_w;
> +	intel_plane->crtc_h = orig.crtc_h;
> +	intel_plane->src_x = orig.src_x;
> +	intel_plane->src_y = orig.src_y;
> +	intel_plane->src_w = orig.src_w;
> +	intel_plane->src_h = orig.src_h;
> +	intel_plane->obj = obj;
> +
>  	if (fb != crtc->cursor->fb) {
>  		return intel_crtc_cursor_set_obj(crtc, obj, crtc_w, crtc_h);
>  	} else {
> --
> 1.7.10.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Jani Nikula, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/i915: Add rotation support for cursor plane
  2014-09-15  7:43   ` [PATCH] " sonika.jindal
@ 2014-10-07  8:43     ` Jindal, Sonika
  2014-10-23  0:29       ` Matt Roper
  0 siblings, 1 reply; 12+ messages in thread
From: Jindal, Sonika @ 2014-10-07  8:43 UTC (permalink / raw)
  To: intel-gfx; +Cc: Kamble, Sagar A

Hi,

Did anybody get a chance to look at this patch?

Thanks,
Sonika

-----Original Message-----
From: Jindal, Sonika 
Sent: Monday, September 15, 2014 1:14 PM
To: intel-gfx@lists.freedesktop.org
Cc: Ville Syrjälä; Kamble, Sagar A; Jindal, Sonika
Subject: [PATCH] drm/i915: Add rotation support for cursor plane

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

The cursor plane also supports 180 degree rotation. Add a new "cursor-rotation" property on the crtc which controls this.

Unlike sprites, the cursor has a fixed size, so if you have a small cursor image with the rest of the bo filled by transparent pixels, simply flipping the rotation property will cause the visible part of the cursor to shift. This is something to keep in mind when using cursor rotation.

v2: Fix gen4/vlv by offsetting the base address appropriately

v3: Removing cursor-rotation property and using rotation property on cursor plane.
v4: Changing the author name back to Ville.

Testcase: kms_rotation_crc

Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
---
 drivers/gpu/drm/i915/i915_reg.h      |    1 +
 drivers/gpu/drm/i915/intel_display.c |   26 +++++++++++++++++++++++++-
 2 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 15c0eaa..5a9fab9 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4162,6 +4162,7 @@ enum punit_power_well {
 #define   MCURSOR_PIPE_A	0x00
 #define   MCURSOR_PIPE_B	(1 << 28)
 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
+#define   CURSOR_ROTATE_180	(1<<15)
 #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
 #define _CURABASE		0x70084
 #define _CURAPOS		0x70088
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 122ac6e..8c83bcc 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8247,6 +8247,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		cntl |= CURSOR_PIPE_CSC_ENABLE;
 
+	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
+		cntl |= CURSOR_ROTATE_180;
+
 	if (intel_crtc->cursor_cntl != cntl) {
 		I915_WRITE(CURCNTR(pipe), cntl);
 		POSTING_READ(CURCNTR(pipe));
@@ -8302,6 +8305,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 
 	I915_WRITE(CURPOS(pipe), pos);
 
+	/* ILK+ do this automagically */
+	if (HAS_GMCH_DISPLAY(dev) &&
+		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
+		base += (intel_crtc->cursor_height *
+			intel_crtc->cursor_width - 1) * 4;
+	}
+
 	if (IS_845G(dev) || IS_I865G(dev))
 		i845_update_cursor(crtc, base);
 	else
@@ -8453,7 +8463,6 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
 	mutex_unlock(&dev->struct_mutex);
 
 	old_width = intel_crtc->cursor_width;
-
 	intel_crtc->cursor_addr = addr;
 	intel_crtc->cursor_bo = obj;
 	intel_crtc->cursor_width = width;
@@ -12074,6 +12083,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.update_plane = intel_cursor_plane_update,
 	.disable_plane = intel_cursor_plane_disable,
 	.destroy = intel_plane_destroy,
+	.set_property = intel_plane_set_property,
 };
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, @@ -12089,12 +12099,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
 	cursor->plane = pipe;
+	cursor->rotation = BIT(DRM_ROTATE_0);
 
 	drm_universal_plane_init(dev, &cursor->base, 0,
 				 &intel_cursor_plane_funcs,
 				 intel_cursor_formats,
 				 ARRAY_SIZE(intel_cursor_formats),
 				 DRM_PLANE_TYPE_CURSOR);
+
+	if (INTEL_INFO(dev)->gen >= 4) {
+		if (!dev->mode_config.rotation_property)
+			dev->mode_config.rotation_property =
+				drm_mode_create_rotation_property(dev,
+							BIT(DRM_ROTATE_0) |
+							BIT(DRM_ROTATE_180));
+		if (dev->mode_config.rotation_property)
+			drm_object_attach_property(&cursor->base.base,
+				dev->mode_config.rotation_property,
+				cursor->rotation);
+	}
+
 	return &cursor->base;
 }
 
--
1.7.10.4

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/i915: Add rotation support for cursor plane
  2014-10-07  8:43     ` Jindal, Sonika
@ 2014-10-23  0:29       ` Matt Roper
  2014-10-23  8:49         ` Daniel Vetter
  0 siblings, 1 reply; 12+ messages in thread
From: Matt Roper @ 2014-10-23  0:29 UTC (permalink / raw)
  To: Jindal, Sonika; +Cc: intel-gfx, Kamble, Sagar A

On Tue, Oct 07, 2014 at 08:43:46AM +0000, Jindal, Sonika wrote:
> Hi,
> 
> Did anybody get a chance to look at this patch?
> 
> Thanks,
> Sonika

Looks like we waited a bit too long and the codebase has evolved, so I
needed to make some tweaks to your patches to get them to apply cleanly
on the latest di-nightly.  However the overall changes here look good to
me, and we don't seem to be missing any details from the bspec, so

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>

After tweaking your patches to apply against the latest di-nightly, your
i-g-t test runs properly for me on IVB, as well as another simple test I
wrote myself, so you can also put

Tested-by: Matt Roper <matthew.d.roper@intel.com>

Let me know if you want the rebased copies of the patches I used for
testing.


Matt

> 
> -----Original Message-----
> From: Jindal, Sonika 
> Sent: Monday, September 15, 2014 1:14 PM
> To: intel-gfx@lists.freedesktop.org
> Cc: Ville Syrjälä; Kamble, Sagar A; Jindal, Sonika
> Subject: [PATCH] drm/i915: Add rotation support for cursor plane
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The cursor plane also supports 180 degree rotation. Add a new "cursor-rotation" property on the crtc which controls this.
> 
> Unlike sprites, the cursor has a fixed size, so if you have a small cursor image with the rest of the bo filled by transparent pixels, simply flipping the rotation property will cause the visible part of the cursor to shift. This is something to keep in mind when using cursor rotation.
> 
> v2: Fix gen4/vlv by offsetting the base address appropriately
> 
> v3: Removing cursor-rotation property and using rotation property on cursor plane.
> v4: Changing the author name back to Ville.
> 
> Testcase: kms_rotation_crc
> 
> Cc: Sagar Kamble <sagar.a.kamble@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h      |    1 +
>  drivers/gpu/drm/i915/intel_display.c |   26 +++++++++++++++++++++++++-
>  2 files changed, 26 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index 15c0eaa..5a9fab9 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -4162,6 +4162,7 @@ enum punit_power_well {
>  #define   MCURSOR_PIPE_A	0x00
>  #define   MCURSOR_PIPE_B	(1 << 28)
>  #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
> +#define   CURSOR_ROTATE_180	(1<<15)
>  #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
>  #define _CURABASE		0x70084
>  #define _CURAPOS		0x70088
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 122ac6e..8c83bcc 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -8247,6 +8247,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
>  	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
>  		cntl |= CURSOR_PIPE_CSC_ENABLE;
>  
> +	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
> +		cntl |= CURSOR_ROTATE_180;
> +
>  	if (intel_crtc->cursor_cntl != cntl) {
>  		I915_WRITE(CURCNTR(pipe), cntl);
>  		POSTING_READ(CURCNTR(pipe));
> @@ -8302,6 +8305,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
>  
>  	I915_WRITE(CURPOS(pipe), pos);
>  
> +	/* ILK+ do this automagically */

Minor note, but it might be nice to clarify this with a little more
detail.  Something like "Gen4 and Valley View expect the address to
point to the lower right corner for 180-rotated cursors.  Other
platforms expect the address to point to the top-left corner regardless
of rotation."


> +	if (HAS_GMCH_DISPLAY(dev) &&
> +		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
> +		base += (intel_crtc->cursor_height *
> +			intel_crtc->cursor_width - 1) * 4;
> +	}
> +
>  	if (IS_845G(dev) || IS_I865G(dev))
>  		i845_update_cursor(crtc, base);
>  	else
> @@ -8453,7 +8463,6 @@ static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc,
>  	mutex_unlock(&dev->struct_mutex);
>  
>  	old_width = intel_crtc->cursor_width;
> -

Unintentional whitespace change?

>  	intel_crtc->cursor_addr = addr;
>  	intel_crtc->cursor_bo = obj;
>  	intel_crtc->cursor_width = width;
> @@ -12074,6 +12083,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
>  	.update_plane = intel_cursor_plane_update,
>  	.disable_plane = intel_cursor_plane_disable,
>  	.destroy = intel_plane_destroy,
> +	.set_property = intel_plane_set_property,
>  };
>  
>  static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev, @@ -12089,12 +12099,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
>  	cursor->max_downscale = 1;
>  	cursor->pipe = pipe;
>  	cursor->plane = pipe;
> +	cursor->rotation = BIT(DRM_ROTATE_0);
>  
>  	drm_universal_plane_init(dev, &cursor->base, 0,
>  				 &intel_cursor_plane_funcs,
>  				 intel_cursor_formats,
>  				 ARRAY_SIZE(intel_cursor_formats),
>  				 DRM_PLANE_TYPE_CURSOR);
> +
> +	if (INTEL_INFO(dev)->gen >= 4) {
> +		if (!dev->mode_config.rotation_property)
> +			dev->mode_config.rotation_property =
> +				drm_mode_create_rotation_property(dev,
> +							BIT(DRM_ROTATE_0) |
> +							BIT(DRM_ROTATE_180));
> +		if (dev->mode_config.rotation_property)
> +			drm_object_attach_property(&cursor->base.base,
> +				dev->mode_config.rotation_property,
> +				cursor->rotation);
> +	}
> +
>  	return &cursor->base;
>  }
>  
> --
> 1.7.10.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH] drm/i915: Add rotation support for cursor plane
  2014-10-23  0:29       ` Matt Roper
@ 2014-10-23  8:49         ` Daniel Vetter
  2014-10-23 14:41           ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane (v2) Matt Roper
  2014-10-23 15:48           ` [PATCH i-g-t] kms_rotation_crc: Add test for cursor rotation (v2) Matt Roper
  0 siblings, 2 replies; 12+ messages in thread
From: Daniel Vetter @ 2014-10-23  8:49 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx, Kamble, Sagar A

On Wed, Oct 22, 2014 at 05:29:24PM -0700, Matt Roper wrote:
> On Tue, Oct 07, 2014 at 08:43:46AM +0000, Jindal, Sonika wrote:
> > Hi,
> > 
> > Did anybody get a chance to look at this patch?
> > 
> > Thanks,
> > Sonika
> 
> Looks like we waited a bit too long and the codebase has evolved, so I
> needed to make some tweaks to your patches to get them to apply cleanly
> on the latest di-nightly.  However the overall changes here look good to
> me, and we don't seem to be missing any details from the bspec, so
> 
> Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> 
> After tweaking your patches to apply against the latest di-nightly, your
> i-g-t test runs properly for me on IVB, as well as another simple test I
> wrote myself, so you can also put
> 
> Tested-by: Matt Roper <matthew.d.roper@intel.com>
> 
> Let me know if you want the rebased copies of the patches I used for
> testing.

Lazy maintainer here. That would be awesome ;-) Since you've frobbed the
patches a bit pls also put your sob onto them.

Thanks, Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 1/2] drm/i915: Update plane parameters for cursor plane (v2)
  2014-10-23  8:49         ` Daniel Vetter
@ 2014-10-23 14:41           ` Matt Roper
  2014-10-23 14:41             ` [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5) Matt Roper
  2014-10-23 15:48           ` [PATCH i-g-t] kms_rotation_crc: Add test for cursor rotation (v2) Matt Roper
  1 sibling, 1 reply; 12+ messages in thread
From: Matt Roper @ 2014-10-23 14:41 UTC (permalink / raw)
  To: intel-gfx

From: Sonika Jindal <sonika.jindal@intel.com>

This allows the cursor plane to be updated the same way as primary and sprites,
and same set_property handler is used for all of these planes.

v2 (by Matt Roper): Rework to apply to latest di-nightly codebase.  The
        switch to split check/commit plane programming changed the code
        flow enough that the original patch could no longer be applied.

Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Tested-by (IVB): Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index fb9a434..0529462 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11945,12 +11945,24 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	struct drm_crtc *crtc = state->crtc;
 	struct drm_framebuffer *fb = state->fb;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct intel_framebuffer *intel_fb = to_intel_framebuffer(fb);
 	struct drm_i915_gem_object *obj = intel_fb->obj;
 	int crtc_w, crtc_h;
 
 	crtc->cursor_x = state->orig_dst.x1;
 	crtc->cursor_y = state->orig_dst.y1;
+
+	intel_plane->crtc_x = state->orig_dst.x1;
+	intel_plane->crtc_y = state->orig_dst.y1;
+	intel_plane->crtc_w = drm_rect_width(&state->orig_dst);
+	intel_plane->crtc_h = drm_rect_height(&state->orig_dst);
+	intel_plane->src_x = state->orig_src.x1;
+	intel_plane->src_y = state->orig_src.y1;
+	intel_plane->src_w = drm_rect_width(&state->orig_src);
+	intel_plane->src_h = drm_rect_height(&state->orig_src);
+	intel_plane->obj = obj;
+
 	if (fb != crtc->cursor->fb) {
 		crtc_w = drm_rect_width(&state->orig_dst);
 		crtc_h = drm_rect_height(&state->orig_dst);
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5)
  2014-10-23 14:41           ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane (v2) Matt Roper
@ 2014-10-23 14:41             ` Matt Roper
  2014-10-23 15:36               ` Daniel Vetter
  0 siblings, 1 reply; 12+ messages in thread
From: Matt Roper @ 2014-10-23 14:41 UTC (permalink / raw)
  To: intel-gfx; +Cc: Sagar Kamble

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

The cursor plane also supports 180 degree rotation. Add a new
"cursor-rotation" property on the crtc which controls this.

Unlike sprites, the cursor has a fixed size, so if you have a small
cursor image with the rest of the bo filled by transparent pixels,
simply flipping the rotation property will cause the visible part
of the cursor to shift. This is something to keep in mind when
using cursor rotation.

v2: Fix gen4/vlv by offsetting the base address appropriately

v3: Removing cursor-rotation property and using rotation property on cursor
plane.
v4: Changing the author name back to Ville.

v5 (by Matt Roper): Slight tweaking to apply against latest di-nightly
codebase.

Cc: Sagar Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Tested-by (IVB): Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---

This is the tweaked version of the patch I used for my review/testing.  My only
review comment was about a comment that I thought could use some clarification,
so I'll leave it up to Sonika whether she wants to incorporate my suggestion or
not; either way this patch has my r-b tag.


 drivers/gpu/drm/i915/i915_reg.h      |  1 +
 drivers/gpu/drm/i915/intel_display.c | 25 +++++++++++++++++++++++++
 2 files changed, 26 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 345293c..7e7002b 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -4207,6 +4207,7 @@ enum punit_power_well {
 #define   MCURSOR_PIPE_A	0x00
 #define   MCURSOR_PIPE_B	(1 << 28)
 #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
+#define   CURSOR_ROTATE_180	(1<<15)
 #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
 #define _CURABASE		0x70084
 #define _CURAPOS		0x70088
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 0529462..910e8a4 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -8343,6 +8343,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
 			cntl |= CURSOR_PIPE_CSC_ENABLE;
 	}
 
+	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
+		cntl |= CURSOR_ROTATE_180;
+
 	if (intel_crtc->cursor_cntl != cntl) {
 		I915_WRITE(CURCNTR(pipe), cntl);
 		POSTING_READ(CURCNTR(pipe));
@@ -8400,6 +8403,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
 
 	I915_WRITE(CURPOS(pipe), pos);
 
+	/* ILK+ do this automagically */
+	if (HAS_GMCH_DISPLAY(dev) &&
+		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
+		base += (intel_crtc->cursor_height *
+			intel_crtc->cursor_width - 1) * 4;
+	}
+
 	if (IS_845G(dev) || IS_I865G(dev))
 		i845_update_cursor(crtc, base);
 	else
@@ -12022,6 +12032,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
 	.update_plane = intel_cursor_plane_update,
 	.disable_plane = intel_cursor_plane_disable,
 	.destroy = intel_plane_destroy,
+	.set_property = intel_plane_set_property,
 };
 
 static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
@@ -12037,12 +12048,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
 	cursor->max_downscale = 1;
 	cursor->pipe = pipe;
 	cursor->plane = pipe;
+	cursor->rotation = BIT(DRM_ROTATE_0);
 
 	drm_universal_plane_init(dev, &cursor->base, 0,
 				 &intel_cursor_plane_funcs,
 				 intel_cursor_formats,
 				 ARRAY_SIZE(intel_cursor_formats),
 				 DRM_PLANE_TYPE_CURSOR);
+
+	if (INTEL_INFO(dev)->gen >= 4) {
+		if (!dev->mode_config.rotation_property)
+			dev->mode_config.rotation_property =
+				drm_mode_create_rotation_property(dev,
+							BIT(DRM_ROTATE_0) |
+							BIT(DRM_ROTATE_180));
+		if (dev->mode_config.rotation_property)
+			drm_object_attach_property(&cursor->base.base,
+				dev->mode_config.rotation_property,
+				cursor->rotation);
+	}
+
 	return &cursor->base;
 }
 
-- 
1.8.5.1

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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5)
  2014-10-23 14:41             ` [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5) Matt Roper
@ 2014-10-23 15:36               ` Daniel Vetter
  0 siblings, 0 replies; 12+ messages in thread
From: Daniel Vetter @ 2014-10-23 15:36 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx, Sagar Kamble

On Thu, Oct 23, 2014 at 07:41:34AM -0700, Matt Roper wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> The cursor plane also supports 180 degree rotation. Add a new
> "cursor-rotation" property on the crtc which controls this.
> 
> Unlike sprites, the cursor has a fixed size, so if you have a small
> cursor image with the rest of the bo filled by transparent pixels,
> simply flipping the rotation property will cause the visible part
> of the cursor to shift. This is something to keep in mind when
> using cursor rotation.
> 
> v2: Fix gen4/vlv by offsetting the base address appropriately
> 
> v3: Removing cursor-rotation property and using rotation property on cursor
> plane.
> v4: Changing the author name back to Ville.
> 
> v5 (by Matt Roper): Slight tweaking to apply against latest di-nightly
> codebase.
> 
> Cc: Sagar Kamble <sagar.a.kamble@intel.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
> Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> Tested-by (IVB): Matt Roper <matthew.d.roper@intel.com>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
> ---
> 
> This is the tweaked version of the patch I used for my review/testing.  My only
> review comment was about a comment that I thought could use some clarification,
> so I'll leave it up to Sonika whether she wants to incorporate my suggestion or
> not; either way this patch has my r-b tag.

I think together with the HAS_GMCH_DISPLAY check the comment is clear.
Queued for -next, thanks for the patch.
-Daniel

> 
> 
>  drivers/gpu/drm/i915/i915_reg.h      |  1 +
>  drivers/gpu/drm/i915/intel_display.c | 25 +++++++++++++++++++++++++
>  2 files changed, 26 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index 345293c..7e7002b 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -4207,6 +4207,7 @@ enum punit_power_well {
>  #define   MCURSOR_PIPE_A	0x00
>  #define   MCURSOR_PIPE_B	(1 << 28)
>  #define   MCURSOR_GAMMA_ENABLE  (1 << 26)
> +#define   CURSOR_ROTATE_180	(1<<15)
>  #define   CURSOR_TRICKLE_FEED_DISABLE	(1 << 14)
>  #define _CURABASE		0x70084
>  #define _CURAPOS		0x70088
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 0529462..910e8a4 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -8343,6 +8343,9 @@ static void i9xx_update_cursor(struct drm_crtc *crtc, u32 base)
>  			cntl |= CURSOR_PIPE_CSC_ENABLE;
>  	}
>  
> +	if (to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180))
> +		cntl |= CURSOR_ROTATE_180;
> +
>  	if (intel_crtc->cursor_cntl != cntl) {
>  		I915_WRITE(CURCNTR(pipe), cntl);
>  		POSTING_READ(CURCNTR(pipe));
> @@ -8400,6 +8403,13 @@ static void intel_crtc_update_cursor(struct drm_crtc *crtc,
>  
>  	I915_WRITE(CURPOS(pipe), pos);
>  
> +	/* ILK+ do this automagically */
> +	if (HAS_GMCH_DISPLAY(dev) &&
> +		to_intel_plane(crtc->cursor)->rotation == BIT(DRM_ROTATE_180)) {
> +		base += (intel_crtc->cursor_height *
> +			intel_crtc->cursor_width - 1) * 4;
> +	}
> +
>  	if (IS_845G(dev) || IS_I865G(dev))
>  		i845_update_cursor(crtc, base);
>  	else
> @@ -12022,6 +12032,7 @@ static const struct drm_plane_funcs intel_cursor_plane_funcs = {
>  	.update_plane = intel_cursor_plane_update,
>  	.disable_plane = intel_cursor_plane_disable,
>  	.destroy = intel_plane_destroy,
> +	.set_property = intel_plane_set_property,
>  };
>  
>  static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
> @@ -12037,12 +12048,26 @@ static struct drm_plane *intel_cursor_plane_create(struct drm_device *dev,
>  	cursor->max_downscale = 1;
>  	cursor->pipe = pipe;
>  	cursor->plane = pipe;
> +	cursor->rotation = BIT(DRM_ROTATE_0);
>  
>  	drm_universal_plane_init(dev, &cursor->base, 0,
>  				 &intel_cursor_plane_funcs,
>  				 intel_cursor_formats,
>  				 ARRAY_SIZE(intel_cursor_formats),
>  				 DRM_PLANE_TYPE_CURSOR);
> +
> +	if (INTEL_INFO(dev)->gen >= 4) {
> +		if (!dev->mode_config.rotation_property)
> +			dev->mode_config.rotation_property =
> +				drm_mode_create_rotation_property(dev,
> +							BIT(DRM_ROTATE_0) |
> +							BIT(DRM_ROTATE_180));
> +		if (dev->mode_config.rotation_property)
> +			drm_object_attach_property(&cursor->base.base,
> +				dev->mode_config.rotation_property,
> +				cursor->rotation);
> +	}
> +
>  	return &cursor->base;
>  }
>  
> -- 
> 1.8.5.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH i-g-t] kms_rotation_crc: Add test for cursor rotation (v2)
  2014-10-23  8:49         ` Daniel Vetter
  2014-10-23 14:41           ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane (v2) Matt Roper
@ 2014-10-23 15:48           ` Matt Roper
  1 sibling, 0 replies; 12+ messages in thread
From: Matt Roper @ 2014-10-23 15:48 UTC (permalink / raw)
  To: intel-gfx

From: Sonika Jindal <sonika.jindal@intel.com>

v2: Slight rebasing onto latest i-g-t codebase (Matt).

Signed-off-by: Sonika Jindal <sonika.jindal@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 tests/kms_rotation_crc.c | 79 ++++++++++++++++++++++++++++++++++--------------
 1 file changed, 57 insertions(+), 22 deletions(-)

diff --git a/tests/kms_rotation_crc.c b/tests/kms_rotation_crc.c
index f45bc9d..41e9912 100644
--- a/tests/kms_rotation_crc.c
+++ b/tests/kms_rotation_crc.c
@@ -33,33 +33,49 @@ typedef struct {
 	int gfx_fd;
 	igt_display_t display;
 	struct igt_fb fb;
+	struct igt_fb fb_cursor;
 	igt_crc_t ref_crc;
 	igt_pipe_crc_t *pipe_crc;
 } data_t;
 
 static void
 paint_squares(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode,
-	      igt_rotation_t rotation)
+	      igt_rotation_t rotation, igt_plane_t *plane)
 {
 	cairo_t *cr;
 	int w, h;
 
-	w = mode->hdisplay;
-	h = mode->vdisplay;
+	if (plane->is_cursor) {
+		w = 128;
+		h = 128;
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb_cursor);
 
-	cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb);
+		if (rotation == IGT_ROTATION_180) {
+			cairo_translate(cr, w, h);
+			cairo_rotate(cr, M_PI);
+		}
 
-	if (rotation == IGT_ROTATION_180) {
-		cairo_translate(cr, w, h);
-		cairo_rotate(cr, M_PI);
-	}
+		igt_paint_color(cr, 0, 0, w / 2, h / 2, .75, 0.5, 0.5);
+		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.5, .75, 0.5);
+		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.5, 0.5, .75);
+		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, .75, .75, .75);
+	} else {
+		w = mode->hdisplay;
+		h = mode->vdisplay;
+
+		cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb);
 
-	/* Paint with 4 squares of Red, Green, White, Blue Clockwise */
-	igt_paint_color(cr, 0, 0, w / 2, h / 2, 1.0, 0.0, 0.0);
-	igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, 1.0, 0.0);
-	igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
-	igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
+		if (rotation == IGT_ROTATION_180) {
+			cairo_translate(cr, w, h);
+			cairo_rotate(cr, M_PI);
+		}
 
+		/* Paint with 4 squares of Red, Green, White, Blue Clockwise */
+		igt_paint_color(cr, 0, 0, w / 2, h / 2, 1.0, 0.0, 0.0);
+		igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.0, 1.0, 0.0);
+		igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
+		igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
+	}
 	cairo_destroy(cr);
 }
 
@@ -68,7 +84,7 @@ static bool prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 {
 	drmModeModeInfo *mode;
 	igt_display_t *display = &data->display;
-	int fb_id;
+	int fb_id, fb_cursor_id;
 
 	igt_output_set_pipe(output, pipe);
 
@@ -90,9 +106,14 @@ static bool prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 			&data->fb);
 	igt_assert(fb_id);
 
-	/* Step 1: create a reference CRC for a software-rotated fb */
+	fb_cursor_id = igt_create_fb(data->gfx_fd,
+				     128, 128,
+				     DRM_FORMAT_ARGB8888,
+				     false, /* tiled */
+				     &data->fb_cursor);
+	igt_assert(fb_cursor_id);
 
-	paint_squares(data, &data->fb, mode, IGT_ROTATION_180);
+	/* Step 1: create a reference CRC for a software-rotated fb */
 
 	/*
 	 * XXX: We always set the primary plane to actually enable the pipe as
@@ -103,21 +124,32 @@ static bool prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 		igt_plane_t *primary;
 
 		primary = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
+		paint_squares(data, &data->fb, mode, IGT_ROTATION_180, primary);
 		igt_plane_set_fb(primary, &data->fb);
 	}
 
-	igt_plane_set_fb(plane, &data->fb);
+	if (plane->is_cursor) {
+		paint_squares(data, &data->fb_cursor, mode, IGT_ROTATION_180, plane);
+		igt_plane_set_fb(plane, &data->fb_cursor);
+	} else {
+		paint_squares(data, &data->fb, mode, IGT_ROTATION_180, plane);
+		igt_plane_set_fb(plane, &data->fb);
+	}
 	igt_display_commit(display);
-
 	igt_pipe_crc_collect_crc(data->pipe_crc, &data->ref_crc);
 
 	/*
 	 * Step 2: prepare the plane with an non-rotated fb let the hw
 	 * rotate it.
 	 */
-	paint_squares(data, &data->fb, mode, IGT_ROTATION_0);
+	if (plane->is_cursor) {
+		paint_squares(data, &data->fb_cursor, mode, IGT_ROTATION_0, plane);
+		igt_plane_set_fb(plane, &data->fb_cursor);
+	} else {
+		paint_squares(data, &data->fb, mode, IGT_ROTATION_0, plane);
+		igt_plane_set_fb(plane, &data->fb);
+	}
 
-	igt_plane_set_fb(plane, &data->fb);
 	return true;
 }
 
@@ -129,6 +161,7 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
 	data->pipe_crc = NULL;
 
 	igt_remove_fb(data->gfx_fd, &data->fb);
+	igt_remove_fb(data->gfx_fd, &data->fb_cursor);
 
 	/* XXX: see the note in prepare_crtc() */
 	if (!plane->is_primary) {
@@ -153,7 +186,7 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 	igt_crc_t crc_output, crc_unrotated;
 	enum igt_commit_style commit = COMMIT_LEGACY;
 
-	if (plane_type == IGT_PLANE_PRIMARY) {
+	if (plane_type == IGT_PLANE_PRIMARY || plane_type == IGT_PLANE_CURSOR) {
 		igt_require(data->display.has_universal_planes);
 		commit = COMMIT_UNIVERSAL;
 	}
@@ -172,7 +205,6 @@ static void test_plane_rotation(data_t *data, enum igt_plane plane_type)
 			igt_display_commit2(display, commit);
 
 			/* collect unrotated CRC */
-			igt_display_commit2(display, commit);
 			igt_pipe_crc_collect_crc(data->pipe_crc, &crc_unrotated);
 
 			igt_plane_set_rotation(plane, IGT_ROTATION_180);
@@ -219,6 +251,9 @@ igt_main
 	igt_subtest_f("sprite-rotation")
 		test_plane_rotation(&data, IGT_PLANE_2);
 
+	igt_subtest_f("cursor-rotation")
+		test_plane_rotation(&data, IGT_PLANE_CURSOR);
+
 	igt_fixture {
 		igt_display_fini(&data.display);
 	}
-- 
1.8.5.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2014-10-23 15:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15  7:35 [PATCH 1/2] drm/i915: Update plane parameters for cursor plane sonika.jindal
2014-09-15  7:35 ` [PATCH 2/2] drm/i915: Add rotation support " sonika.jindal
2014-09-15  7:43   ` [PATCH] " sonika.jindal
2014-10-07  8:43     ` Jindal, Sonika
2014-10-23  0:29       ` Matt Roper
2014-10-23  8:49         ` Daniel Vetter
2014-10-23 14:41           ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane (v2) Matt Roper
2014-10-23 14:41             ` [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5) Matt Roper
2014-10-23 15:36               ` Daniel Vetter
2014-10-23 15:48           ` [PATCH i-g-t] kms_rotation_crc: Add test for cursor rotation (v2) Matt Roper
2014-09-15  7:55 ` [PATCH 1/2] drm/i915: Update plane parameters for cursor plane Jani Nikula
2014-09-15 10:43   ` Jindal, Sonika

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.