drm/i915: Add skl_check_nv12_surface for NV12
authorMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Fri, 11 May 2018 21:33:14 +0000 (03:03 +0530)
committerMaarten Lankhorst <maarten.lankhorst@linux.intel.com>
Fri, 11 May 2018 08:19:48 +0000 (10:19 +0200)
We skip src trunction/adjustments for
NV12 case and handle the sizes directly.
Without this, pipe fifo underruns are seen on APL/KBL.

v2: For NV12, making the src coordinates multiplier of 4

v3: Moving all the src coords handling code for NV12
to skl_check_nv12_surface

v4: Added RB from Mika

v5: Rebased the series. Removed checks of mult of 4 in
skl_update_scaler, Added NV12 condition in intel_check_sprite_plane
where src x/w is being checked for mult of 2 for yuv planes.

v6: Made changes to skl_check_nv12_surface as per WA#1106

Reviewed-by: Mika Kahola <mika.kahola@intel.com>
Signed-off-by: Vidya Srinivas <vidya.srinivas@intel.com>
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1526074397-10457-4-git-send-email-vidya.srinivas@intel.com
drivers/gpu/drm/i915/intel_display.c
drivers/gpu/drm/i915/intel_sprite.c

index 941895310625a52babb6647c36e8df860bf76067..c8ff4b705fff82f72907a7a4d3dc29c4d6811948 100644 (file)
@@ -3102,6 +3102,29 @@ static int skl_check_main_surface(const struct intel_crtc_state *crtc_state,
        return 0;
 }
 
+static int
+skl_check_nv12_surface(const struct intel_crtc_state *crtc_state,
+                      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;
@@ -3185,6 +3208,9 @@ int skl_check_plane_surface(const struct intel_crtc_state *crtc_state,
         * the main surface setup depends on it.
         */
        if (fb->format->format == DRM_FORMAT_NV12) {
+               ret = skl_check_nv12_surface(crtc_state, plane_state);
+               if (ret)
+                       return ret;
                ret = skl_check_nv12_aux_surface(plane_state);
                if (ret)
                        return ret;
@@ -4806,8 +4832,7 @@ skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
        }
 
        if (plane_scaler_check && pixel_format == DRM_FORMAT_NV12 &&
-           (src_h < SKL_MIN_YUV_420_SRC_H || (src_w % 4) != 0 ||
-            (src_h % 4) != 0)) {
+           (src_h < SKL_MIN_YUV_420_SRC_H || src_w < SKL_MIN_YUV_420_SRC_W)) {
                DRM_DEBUG_KMS("NV12: src dimensions not met\n");
                return -EINVAL;
        }
index 9cd4be02084073b9da68952ce1d00ba173e1716f..26de04445aca025fc9a1acc4e9440edb8c108218 100644 (file)
@@ -1060,7 +1060,8 @@ intel_check_sprite_plane(struct intel_plane *plane,
                src_y = src->y1 >> 16;
                src_h = drm_rect_height(src) >> 16;
 
-               if (intel_format_is_yuv(fb->format->format)) {
+               if (intel_format_is_yuv(fb->format->format) &&
+                   fb->format->format != DRM_FORMAT_NV12) {
                        src_x &= ~1;
                        src_w &= ~1;