hwc/overlay: MDSS driver requires 4-aligned crop.h for interlaced

MDSS driver requires the crop height to be multiple of 4 to
de-interlace the interlaced Yuv content.

CRs-Fixed: 491488
Change-Id: I9a95392a71cca217e2890c9736f1450fd8aa4a59
diff --git a/libhwcomposer/hwc_utils.cpp b/libhwcomposer/hwc_utils.cpp
index 16c2c8f..b598d0b 100644
--- a/libhwcomposer/hwc_utils.cpp
+++ b/libhwcomposer/hwc_utils.cpp
@@ -763,6 +763,9 @@
         if (ovutils::isYuv(whf.format)) {
             ovutils::normalizeCrop((uint32_t&)crop.left, crop_w);
             ovutils::normalizeCrop((uint32_t&)crop.top, crop_h);
+            // For interlaced, crop.h should be 4-aligned
+            if ((mdpFlags & ovutils::OV_MDP_DEINTERLACE) && (crop_h % 4))
+                crop_h = ovutils::aligndown(crop_h, 4);
             crop.right = crop.left + crop_w;
             crop.bottom = crop.top + crop_h;
         }
diff --git a/liboverlay/overlayMdp.cpp b/liboverlay/overlayMdp.cpp
index 4c77f2e..e5d7d98 100644
--- a/liboverlay/overlayMdp.cpp
+++ b/liboverlay/overlayMdp.cpp
@@ -180,6 +180,11 @@
         if(mdpVersion < MDSS_V5) {
             utils::even_floor(mOVInfo.dst_rect.w);
             utils::even_floor(mOVInfo.dst_rect.h);
+        } else if (mOVInfo.flags & MDP_DEINTERLACE) {
+            // For interlaced, crop.h should be 4-aligned
+            if (!(mOVInfo.flags & MDP_SOURCE_ROTATED_90) &&
+                (mOVInfo.src_rect.h % 4))
+                mOVInfo.src_rect.h = utils::aligndown(mOVInfo.src_rect.h, 4);
         }
     }