drm: Deal with rotation in drm_plane_helper_check_update()
Subsystems (8)
PATCH 1/1 drm: Deal with rotation in drm_plane_helper_check_update()
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update() needs to account for the plane rotation for correct clipping/scaling calculations. Do so.
There was an earlier attempt [1] to add this into intel_check_primary_plane() but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.
[1] https://patchwork.freedesktop.org/patch/65177/
--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)
drivers/gpu/drm/armada/armada_overlay.c +1 -0
@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;
drivers/gpu/drm/drm_plane_helper.c +18 -10
@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it
@@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;
@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);
@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this
@@ -265,6 +272,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -14029,6 +14029,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);
@@ -14192,6 +14193,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -0
@@ -583,6 +583,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);
include/drm/drm_plane_helper.h +1 -0
@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,
Signature · 6 lines
2.4.10 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 93 lines · On Fri, Jan 15, 2016 at 08:51:06PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update()needs to account for the plane rotation for correct clipping/scaling calculations. Do so.There was an earlier attempt [1] to add this into
intel_check_primary_plane()but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.[1] https://patchwork.freedesktop.org/patch/65177/
Cc Nabendu Maiti <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)drivers/gpu/drm/armada/armada_overlay.c +1
-0@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;drivers/gpu/drm/drm_plane_helper.c +17
-10@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this
drivers/gpu/drm/drm_plane_helper.c int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, · line 278
Quoted 7 lines
drivers/gpu/drm/drm_plane_helper.c +1
-0@@ -265,6 +272,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);
With this rotation is essentially unsupported on legacy setups. Shouldn't we instead wrap this up into an atomic helper which just takes state structs and fishes out everything it needs on its own? Then there's no need to change existing drivers all that much, and atomic ones would be simpler ...
Or do I miss something?
-Daniel
Quoted 51 lines
drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14029,6 +14029,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);@@ -14192,6 +14193,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-0@@ -583,6 +583,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);include/drm/drm_plane_helper.h +1
-0@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,Signature · 6 lines
2.4.10 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 108 lines · Daniel Vetter
Quoted 93 lines · On Fri, Jan 15, 2016 at 08:51:06PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update()needs to account for the plane rotation for correct clipping/scaling calculations. Do so.There was an earlier attempt [1] to add this into
intel_check_primary_plane()but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.[1] https://patchwork.freedesktop.org/patch/65177/
Cc Nabendu Maiti <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)drivers/gpu/drm/armada/armada_overlay.c +1
-0@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;drivers/gpu/drm/drm_plane_helper.c +17
-10@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this drivers/gpu/drm/drm_plane_helper.c int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, · line 278
Quoted 7 lines
drivers/gpu/drm/drm_plane_helper.c +1
-0@@ -265,6 +272,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);With this rotation is essentially unsupported on legacy setups. Shouldn't we instead wrap this up into an atomic helper which just takes state structs and fishes out everything it needs on its own? Then there's no need to change existing drivers all that much, and atomic ones would be simpler ...
Quoted 1 line
Or do I miss something?
We'd need to move the various drm_rects to live under drm_plane_state. Right now they live in intel_plane_state. No objection to doing that from me, but requires someone to actually write the patch.
Quoted 58 lines
-Daniel
Quoted 51 lines
drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14029,6 +14029,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);@@ -14192,6 +14193,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-0@@ -583,6 +583,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);include/drm/drm_plane_helper.h +1
-0@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,Signature · 6 lines
2.4.10 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-develSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 9 lines · On Fri, Jan 15, 2016 at 08:51:06PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update()needs to account for the plane rotation for correct clipping/scaling calculations. Do so.There was an earlier attempt [1] to add this into
intel_check_primary_plane()but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.
Ping. Anyone interested in rotation actually working with drm_plane_helper_check_update() ?
Quoted 137 lines
[1] https://patchwork.freedesktop.org/patch/65177/
Cc Nabendu Maiti <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)drivers/gpu/drm/armada/armada_overlay.c +1
-0@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;drivers/gpu/drm/drm_plane_helper.c +18
-10@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this @@ -265,6 +272,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14029,6 +14029,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);@@ -14192,6 +14193,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-0@@ -583,6 +583,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);include/drm/drm_plane_helper.h +1
-0@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,Signature · 1 line
2.4.10
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patrik Jakobsson
Reviewed-byQuoted 6 lines · Ville Syrjälä
Quoted 5 lines · On Fri, Jan 15, 2016 at 08:51:06PM +0200, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update()needs to account for the plane rotation for correct clipping/scaling calculations. Do so.
Quoted 8 lines
Quoted 4 lines
There was an earlier attempt [1] to add this into
intel_check_primary_plane()but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.Ping. Anyone interested in rotation actually working with
drm_plane_helper_check_update()?
Passing state structs sounds better but since that patch doesn't exist I'd go for this one.
There are now more users of drm_plane_helper_check_update() so needs fixing.
With that done;
Quoted 138 lines
Quoted 136 lines
[1] https://patchwork.freedesktop.org/patch/65177/
Cc Nabendu Maiti <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 5 files changed, 23 insertions(+), 10 deletions(-)drivers/gpu/drm/armada/armada_overlay.c +1
-0@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;drivers/gpu/drm/drm_plane_helper.c +18
-10@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this @@ -265,6 +272,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14029,6 +14029,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);@@ -14192,6 +14193,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-0@@ -583,6 +583,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);include/drm/drm_plane_helper.h +1
-1@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position, --Quoted 1 line
2.4.10
Quoted 7 lines
--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/1 drm: Deal with rotation in drm_plane_helper_check_update()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update() needs to account for the plane rotation for correct clipping/scaling calculations. Do so.
There was an earlier attempt [1] to add this into intel_check_primary_plane() but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.
v2: Deal with new drm_plane_helper_check_update() callers
[1] https://patchwork.freedesktop.org/patch/65177/
--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/drm_simple_kms_helper.c | 1 + drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 7 files changed, 25 insertions(+), 10 deletions(-)
drivers/gpu/drm/armada/armada_overlay.c +1 -0
@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;
drivers/gpu/drm/drm_plane_helper.c +18 -10
@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it
@@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;
@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);
@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this
@@ -267,6 +274,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);
drivers/gpu/drm/drm_simple_kms_helper.c +1 -0
@@ -105,6 +105,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, &pipe->crtc, plane_state->fb, &src, &dest, &clip, + plane_state->rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, true, &visible);
drivers/gpu/drm/i915/intel_display.c +2 -0
@@ -14184,6 +14184,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);
@@ -14375,6 +14376,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);
drivers/gpu/drm/mediatek/mtk_drm_plane.c +1 -0
@@ -170,6 +170,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,return drm_plane_helper_check_update (plane, state->crtc, fb, &src, &dest, &clip, + state->rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &visible);
drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1 -0
@@ -626,6 +626,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);
include/drm/drm_plane_helper.h +1 -0
@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,
Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Daniel Vetter
AppliedQuoted 12 lines · On Fri, Jun 17, 2016 at 05:13:10PM +0300, [email protected] wrote:
From: Ville Syrjälä <[email protected]>
drm_plane_helper_check_update()needs to account for the plane rotation for correct clipping/scaling calculations. Do so.There was an earlier attempt [1] to add this into
intel_check_primary_plane()but I requested that it'd be put into the helper instead. An updated patch never materialized AFAICS, so I went ahead and cooked one up myself.v2: Deal with new
drm_plane_helper_check_update()callers
Quoted 8 lines
[1] https://patchwork.freedesktop.org/patch/65177/
Cc Nabendu Maiti <[email protected]>Cc Noralf Trønnes <[email protected]>Cc CK Hu <[email protected]>Cc Mark Yao <[email protected]>Cc Russell King <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>Reviewed-by Patrik Jakobsson <[email protected]>
Applied to drm-misc, thanks.
-Daniel
Quoted 164 lines
--- drivers/gpu/drm/armada/armada_overlay.c | 1 + drivers/gpu/drm/drm_plane_helper.c | 28 ++++++++++++++++++---------- drivers/gpu/drm/drm_simple_kms_helper.c | 1 + drivers/gpu/drm/i915/intel_display.c | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 1 + drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 1 + include/drm/drm_plane_helper.h | 1 + 7 files changed, 25 insertions(+), 10 deletions(-)drivers/gpu/drm/armada/armada_overlay.c +1
-0@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct drm_crtc *crtc,int ret; ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),0 ,INT_MAX , true, false, &visible);if (ret)return ret;drivers/gpu/drm/drm_plane_helper.c +18
-10@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* @src: source coordinates in 16.16 fixed point * @dest: integer destination coordinates * @clip: integer clipping coordinates +* @rotation: plane rotation * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point * @can_position: is it legal to position the plane such that it @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,* Zero if update appears valid, error code on failure */ int drm_plane_helper_check_update (struct drm_plane *plane, -struct drm_crtc *crtc, -struct drm_framebuffer *fb, -struct drm_rect *src, -struct drm_rect *dest, -const struct drm_rect *clip, -int min_scale, -int max_scale, -bool can_position, -bool can_update_disabled, -bool *visible) +struct drm_crtc *crtc, +struct drm_framebuffer *fb, +struct drm_rect *src, +struct drm_rect *dest, +const struct drm_rect *clip, +unsigned int rotation, +int min_scale, +int max_scale, +bool can_position, +bool can_update_disabled, +bool *visible) {int hscale, vscale;@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,return -EINVAL ; } +drm_rect_rotate (src, fb->width <<16 , fb->height <<16 , rotation); +/* Check scaling */ hscale =drm_rect_calc_hscale (src, dest, min_scale, max_scale); vscale =drm_rect_calc_vscale (src, dest, min_scale, max_scale);@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane, } *visible =drm_rect_clip_scaled (src, dest, clip, hscale, vscale); + +drm_rect_rotate_inv (src, fb->width <<16 , fb->height <<16 , rotation); +if (!*visible)/* * Plane isn't visible; some drivers can handle this @@ -267,6 +274,7 @@ int drm_primary_helper_update(struct drm_plane *plane, struct drm_crtc *crtc, ret =drm_plane_helper_check_update (plane, crtc, fb, &src, &dest, &clip, +BIT (DRM_ROTATE_0 ),DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, false, &visible);drivers/gpu/drm/drm_simple_kms_helper.c +1
-0@@ -105,6 +105,7 @@ static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, &pipe->crtc, plane_state->fb, &src, &dest, &clip, + plane_state->rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , false, true, &visible);drivers/gpu/drm/i915/intel_display.c +2
-0@@ -14184,6 +14184,7 @@ intel_check_primary_plane(struct drm_plane *plane,return drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation, min_scale, max_scale, can_position, true, &state->visible);@@ -14375,6 +14376,7 @@ intel_check_cursor_plane(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, fb, &state->src, &state->dst, &state->clip, + state->base.rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &state->visible);drivers/gpu/drm/mediatek/mtk_drm_plane.c +1
-0@@ -170,6 +170,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,return drm_plane_helper_check_update (plane, state->crtc, fb, &src, &dest, &clip, + state->rotation,DRM_PLANE_HELPER_NO_SCALING ,DRM_PLANE_HELPER_NO_SCALING , true, true, &visible);drivers/gpu/drm/rockchip/rockchip_drm_vop.c +1
-0@@ -626,6 +626,7 @@ static int vop_plane_atomic_check(struct drm_plane *plane, ret =drm_plane_helper_check_update (plane, crtc, state->fb, src, dest, &clip, + state->rotation, min_scale, max_scale, true, true, &visible);include/drm/drm_plane_helper.h +1
-0@@ -46,6 +46,7 @@ int drm_plane_helper_check_update(struct drm_plane *plane,struct drm_rect *src, struct drm_rect *dest, const struct drm_rect *clip, + unsigned int rotation, int min_scale, int max_scale, bool can_position,Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel