drm/i915: Relocate SKL+ NV12 src width w/a
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 18 Oct 2018 19:59:20 +0000 (22:59 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Tue, 23 Oct 2018 15:25:47 +0000 (18:25 +0300)
The SKL+ NV12 src width alignment w/a is still living in an odd place.
Everything else was already relocated closer to the main plane check
function. Move this workaround as well.

As a bonus we avoid the funky rotated vs. not mess with the src
coordinates as this now gets checked before we rotate the coordinates.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20181018195921.9898-1-ville.syrjala@linux.intel.com
Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_sprite.c

index 139488e..52e4d7a 100644 (file)
@@ -3049,28 +3049,6 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state)
        return 0;
 }
 
-static int
-skl_check_nv12_surface(struct intel_plane_state *plane_state)
-{
-       /* Display WA #1106 */
-       if (plane_state->base.rotation !=
-           (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_90) &&
-           plane_state->base.rotation != DRM_MODE_ROTATE_270)
-               return 0;
-
-       /*
-        * src coordinates are rotated here.
-        * We check height but report it as width
-        */
-       if (((drm_rect_height(&plane_state->base.src) >> 16) % 4) != 0) {
-               DRM_DEBUG_KMS("src width must be multiple "
-                             "of 4 for rotated NV12\n");
-               return -EINVAL;
-       }
-
-       return 0;
-}
-
 static int skl_check_nv12_aux_surface(struct intel_plane_state *plane_state)
 {
        const struct drm_framebuffer *fb = plane_state->base.fb;
@@ -3153,9 +3131,6 @@ int skl_check_plane_surface(struct intel_plane_state *plane_state)
         * the main surface setup depends on it.
         */
        if (fb->format->format == DRM_FORMAT_NV12) {
-               ret = skl_check_nv12_surface(plane_state);
-               if (ret)
-                       return ret;
                ret = skl_check_nv12_aux_surface(plane_state);
                if (ret)
                        return ret;
index 7cd59ee..0fe6c66 100644 (file)
@@ -1342,6 +1342,23 @@ static int skl_plane_check_dst_coordinates(const struct intel_crtc_state *crtc_s
        return 0;
 }
 
+static int skl_plane_check_nv12_rotation(const struct intel_plane_state *plane_state)
+{
+       const struct drm_framebuffer *fb = plane_state->base.fb;
+       unsigned int rotation = plane_state->base.rotation;
+       int src_w = drm_rect_width(&plane_state->base.src) >> 16;
+
+       /* Display WA #1106 */
+       if (fb->format->format == DRM_FORMAT_NV12 && src_w & 3 &&
+           (rotation == DRM_MODE_ROTATE_270 ||
+            rotation == (DRM_MODE_REFLECT_X | DRM_MODE_ROTATE_90))) {
+               DRM_DEBUG_KMS("src width must be multiple of 4 for rotated NV12\n");
+               return -EINVAL;
+       }
+
+       return 0;
+}
+
 static int skl_plane_check(struct intel_crtc_state *crtc_state,
                           struct intel_plane_state *plane_state)
 {
@@ -1380,6 +1397,10 @@ static int skl_plane_check(struct intel_crtc_state *crtc_state,
        if (ret)
                return ret;
 
+       ret = skl_plane_check_nv12_rotation(plane_state);
+       if (ret)
+               return ret;
+
        ret = skl_check_plane_surface(plane_state);
        if (ret)
                return ret;