drm: Deal with rotation in drm_plane_helper_check_update()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 17 Jun 2016 14:13:10 +0000 (17:13 +0300)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 17 Jun 2016 14:41:25 +0000 (16:41 +0200)
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/
Cc: Nabendu Maiti <nabendu.bikash.maiti@intel.com>
Cc: Noralf Trønnes <noralf@tronnes.org>
Cc: CK Hu <ck.hu@mediatek.com>
Cc: Mark Yao <mark.yao@rock-chips.com>
Cc: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Patrik Jakobsson <patrik.r.jakobsson@gmail.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1466172790-10025-1-git-send-email-ville.syrjala@linux.intel.com
drivers/gpu/drm/armada/armada_overlay.c
drivers/gpu/drm/drm_plane_helper.c
drivers/gpu/drm/drm_simple_kms_helper.c
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/mediatek/mtk_drm_plane.c
drivers/gpu/drm/rockchip/rockchip_drm_vop.c
include/drm/drm_plane_helper.h

index 148e8a42b2c690858a7688f881f50d208338cb96..1ee707ef6b8d0d0b51033903dbe3a189de700f80 100644 (file)
@@ -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;
index fc51306fe3652f6b153308ac684bdf89ffcea730..16c4a7bd7465800c5cbcd3435d6823829cb41daf 100644 (file)
@@ -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);
index b2071d495ada8661be30e799387e64c62a68ab7a..0db36d27e90b009292e38d57221d2f173574720a 100644 (file)
@@ -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);
index 49322f6cfa2b630a9298837663e1ade4f6627ab2..2bf6c58508da81f98e4baa134aa0179aea1dabf9 100644 (file)
@@ -14102,6 +14102,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);
@@ -14293,6 +14294,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);
index 51bc8988fc26f08b861397b4cd32c95d827ed49a..3995765a90dcd868d124b3248f6fa28cd4554afc 100644 (file)
@@ -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);
index 8cd840f602b788b227aa4123d59aabba38d89763..6255e5bcd9540abcd65a7fa27df2a36587921805 100644 (file)
@@ -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);
index 4421f3f4ca8d9f44772d7e9a2a2163bb245e1326..0e0c3573cce0552ea8a9b1b7d82c33c8079d5f9e 100644 (file)
@@ -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,