drm/i915: Update plane parameters for cursor plane
Subsystems (2)
PATCH 1/2 drm/i915: Update plane parameters for cursor plane
From: Sonika Jindal <[email protected]>
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.
--- drivers/gpu/drm/i915/intel_display.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
drivers/gpu/drm/i915/intel_display.c +27 -0
@@ -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 {
Signature · 1 line
1.7.10.4
PATCH 2/2 drm/i915: Add rotation support for cursor plane
From: Sonika Jindal <[email protected]>
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
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -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
drivers/gpu/drm/i915/intel_display.c +25 -1
@@ -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; }
Signature · 6 lines
1.7.10.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/1 drm/i915: Add rotation support for cursor plane
From: Ville Syrjälä <[email protected]>
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
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -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
drivers/gpu/drm/i915/intel_display.c +25 -1
@@ -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; }
Signature · 6 lines
1.7.10.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Add rotation support for cursor plane
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: [email protected]
Cc: Ville Syrjälä; Kamble, Sagar A; Jindal, Sonika
Subject: [PATCH] drm/i915: Add rotation support for cursor plane
From: Ville Syrjälä <[email protected]>
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
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -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
drivers/gpu/drm/i915/intel_display.c +11 -1
@@ -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
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH] drm/i915: Add rotation support for cursor plane
Quoted 6 lines · Sonika
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
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
Let me know if you want the rebased copies of the patches I used for testing.
Matt
Quoted 55 lines
-----Original Message-----
From: Jindal, Sonika
Sent: Monday, September 15, 2014 1:14 PM
To: [email protected]
Cc: Ville Syrjälä; Kamble, Sagar A; Jindal, Sonika
Subject: [PATCH] drm/i915: Add rotation support for cursor planeFrom: Ville Syrjälä <[email protected]>
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_crcCc Sagar Kamble <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Signed-off-by Sonika Jindal <[email protected]>--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 26 +++++++++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-)drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -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 0x70088drivers/gpu/drm/i915/intel_display.c +3
-0@@ -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));
drivers/gpu/drm/i915/intel_display.c static void intel_crtc_update_cursor(struct drm_crtc *crtc, · line 8308
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +1
-0@@ -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."
Quoted 10 lines
drivers/gpu/drm/i915/intel_display.c +6
-0+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
drivers/gpu/drm/i915/intel_display.c static int intel_crtc_cursor_set_obj(struct drm_crtc *crtc, · line 8456
Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +0
-1@@ -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?
Quoted 44 lines
drivers/gpu/drm/i915/intel_display.c +1
-0intel_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,drivers/gpu/drm/i915/intel_display.c +14
-1cursor->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
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Matt Roper Graphics Software Engineer IoTG Platform Enabling & Development Intel Corporation (916) 356-2795
Re: [PATCH] drm/i915: Add rotation support for cursor plane
Quoted 15 lines · Matt Roper
Quoted 6 lines · Sonika
Hi,
Did anybody get a chance to look at this patch?
Thanks,
SonikaLooks 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 <[email protected]>
Quoted 8 lines
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 <[email protected]>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
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/2 drm/i915: Update plane parameters for cursor plane (v2)
From: Sonika Jindal <[email protected]>
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.
Tested-by (IVB): Matt Roper <[email protected]>
--- drivers/gpu/drm/i915/intel_display.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/gpu/drm/i915/intel_display.c +12 -0
@@ -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);
Signature · 1 line
1.8.5.1
PATCH 2/2 drm/i915: Add rotation support for cursor plane (v5)
From: Ville Syrjälä <[email protected]>
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.
Tested-by (IVB): Matt Roper <[email protected]>
---
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(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -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
drivers/gpu/drm/i915/intel_display.c +25 -0
@@ -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; }
Signature · 6 lines
1.8.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Add rotation support for cursor plane (v5)
Quoted 24 lines · Matt Roper
From: Ville Syrjälä <[email protected]>
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 <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Signed-off-by Sonika Jindal <[email protected]>Reviewed-by Matt Roper <[email protected]>
Quoted 8 lines
Tested-by (IVB): Matt Roper <[email protected]>
Signed-off-by Matt Roper <[email protected]>---
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
Quoted 88 lines
drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_display.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -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 0x70088drivers/gpu/drm/i915/intel_display.c +25
-0@@ -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; }Signature · 6 lines
1.8.5.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch
PATCH 1/1 kms_rotation_crc: Add test for cursor rotation (v2)
In reply to Daniel VetterFrom: Sonika Jindal <[email protected]>
v2: Slight rebasing onto latest i-g-t codebase (Matt).
--- tests/kms_rotation_crc.c | 79 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 57 insertions(+), 22 deletions(-)
tests/kms_rotation_crc.c +57 -22
@@ -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); }
Signature · 1 line
1.8.5.1
Jani Nikula
maintainerPlease look into this first:
https://bugs.freedesktop.org/show_bug.cgi?id=83130
BR,
Jani.
Quoted 62 lines · On Mon, 15 Sep 2014, [email protected] wrote:
From: Sonika Jindal <[email protected]>
This allows the cursor plane to be updated the same way as primary and sprites, and same
set_propertyhandler is used for all of these planes.Signed-off-by Sonika Jindal <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/i915/intel_display.c +27
-0@@ -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 {Signature · 6 lines
1.7.10.4 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 1 line
Jani Nikula, Intel Open Source Technology Center
Ok, let me check this.
Regards,
Sonika
-----Original Message-----
From: Jani Nikula [mailto:[email protected]]
Sent: Monday, September 15, 2014 1:26 PM
To: Jindal, Sonika; [email protected]
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.
Quoted 60 lines · On Mon, 15 Sep 2014, [email protected] wrote:
From: Sonika Jindal <[email protected]>
This allows the cursor plane to be updated the same way as primary and sprites, and same
set_propertyhandler is used for all of these planes.Signed-off-by Sonika Jindal <[email protected]>--- drivers/gpu/drm/i915/intel_display.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)drivers/gpu/drm/i915/intel_display.c +27
-0@@ -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
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Jani Nikula, Intel Open Source Technology Center