drm: Add drm_rotation_90_or_270()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 26 Sep 2016 16:30:46 +0000 (19:30 +0300)
committerJianxin Pan <jianxin.pan@amlogic.com>
Tue, 14 Aug 2018 13:22:27 +0000 (06:22 -0700)
We have intel_rotation_90_or_270() in i915 to check if the rotation is
90 or 270 degrees. Similar checks are elsewhere in drm, so let's move
the helper into a central place and use it everwhere.

v2: Drop the BIT()
    Convert all new intel_rotation_90_or_270() calls
    Deal with superfluous code shuffling

Change-Id: I84d48ebfa010f7c28fad6e492fdda2bddd305ccf
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> (v1)
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1474907460-10717-2-git-send-email-ville.syrjala@linux.intel.com
drivers/gpu/drm/atmel-hlcdc/atmel_hlcdc_plane.c
drivers/gpu/drm/drm_atomic_helper.c
drivers/gpu/drm/drm_crtc.c
include/drm/drm_blend.h

index 9d4c030..b380179 100644 (file)
@@ -393,7 +393,7 @@ static void atmel_hlcdc_plane_update_format(struct atmel_hlcdc_plane *plane,
 
        if ((state->base.fb->pixel_format == DRM_FORMAT_YUV422 ||
             state->base.fb->pixel_format == DRM_FORMAT_NV61) &&
-           (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)))
+           drm_rotation_90_or_270(state->base.rotation))
                cfg |= ATMEL_HLCDC_YUV422ROT;
 
        atmel_hlcdc_layer_update_cfg(&plane->layer,
@@ -628,7 +628,7 @@ static int atmel_hlcdc_plane_atomic_check(struct drm_plane *p,
        /*
         * Swap width and size in case of 90 or 270 degrees rotation
         */
-       if (state->base.rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
+       if (drm_rotation_90_or_270(state->base.rotation)) {
                tmp = state->crtc_w;
                state->crtc_w = state->crtc_h;
                state->crtc_h = tmp;
index f34b4e8..88c8430 100644 (file)
@@ -2421,7 +2421,7 @@ int __drm_atomic_helper_set_config(struct drm_mode_set *set,
        primary_state->crtc_h = vdisplay;
        primary_state->src_x = set->x << 16;
        primary_state->src_y = set->y << 16;
-       if (primary_state->rotation & (DRM_ROTATE_90 | DRM_ROTATE_270)) {
+       if (drm_rotation_90_or_270(primary_state->rotation)) {
                primary_state->src_w = vdisplay << 16;
                primary_state->src_h = hdisplay << 16;
        } else {
index 79b3d52..ff21bfa 100644 (file)
@@ -763,8 +763,7 @@ int drm_crtc_check_viewport(const struct drm_crtc *crtc,
        drm_crtc_get_hv_timing(mode, &hdisplay, &vdisplay);
 
        if (crtc->state &&
-           crtc->primary->state->rotation & (DRM_ROTATE_90 |
-                                             DRM_ROTATE_270))
+           drm_rotation_90_or_270(crtc->primary->state->rotation))
                swap(hdisplay, vdisplay);
 
        return drm_framebuffer_check_src_coords(x << 16, y << 16,
index 36baa17..bb49341 100644 (file)
@@ -47,6 +47,11 @@ struct drm_atomic_state;
 #define DRM_REFLECT_Y  BIT(5)
 #define DRM_REFLECT_MASK (DRM_REFLECT_X | DRM_REFLECT_Y)
 
+static inline bool drm_rotation_90_or_270(unsigned int rotation)
+{
+       return rotation & (DRM_ROTATE_90 | DRM_ROTATE_270);
+}
+
 struct drm_property *drm_mode_create_rotation_property(struct drm_device *dev,
                                                       unsigned int supported_rotations);
 unsigned int drm_rotation_simplify(unsigned int rotation,