Fix PXP stuck issue on some cases

When output height is eight, yscale of ps engine will be over two,
it is not support by pxp.
According to pxp doc, a factor greater than 2 is not supported with
the bilinear filter. so correct it when this case happens in order to
ensure that pxp will not hang up.

Bug: 65864256, Bug: 74214035
Test: android.view.cts.SurfaceViewSyncTest#testSurfaceViewSmallScale
Change-Id: I36b954f4d34c539a807b2cc40f146218ffbaed38
Signed-off-by: fang hui <hui.fang@nxp.com>
diff --git a/drivers/dma/pxp/pxp_dma_v3.c b/drivers/dma/pxp/pxp_dma_v3.c
index c23201d..4fbd437 100644
--- a/drivers/dma/pxp/pxp_dma_v3.c
+++ b/drivers/dma/pxp/pxp_dma_v3.c
@@ -2123,6 +2123,17 @@
 		}
 		scale.xscale = input->crop.width * 0x1000 /
 				(output->crop.width * decx);
+
+		/* A factor greater than 2 is not supported
+		 * with the bilinear filter, so correct it in
+		 * driver
+		 */
+		if (((scale.xscale >> BP_PXP_PS_SCALE_OFFSET) & 0x3) > 2) {
+			scale.xscale &= (~(0x3 << BP_PXP_PS_SCALE_OFFSET));
+			scale.xscale |= (0x2 << BP_PXP_PS_SCALE_OFFSET);
+			pr_warn("%s not support scale width: %d\n",
+							__func__, output->crop.width);
+		}
 	} else {
 		if (!is_yuv(input->format) ||
 		    (is_yuv(input->format) == is_yuv(output->format)) ||
@@ -2160,6 +2171,17 @@
 		}
 		scale.yscale = input->crop.height * 0x1000 /
 				(output->crop.height * decy);
+
+		/* A factor greater than 2 is not supported
+		 * with the bilinear filter, so correct it in
+		 * driver
+		 */
+		if (((scale.yscale >> BP_PXP_PS_SCALE_OFFSET) & 0x3) > 2) {
+			scale.yscale &= (~(0x3 << BP_PXP_PS_SCALE_OFFSET));
+			scale.yscale |= (0x2 << BP_PXP_PS_SCALE_OFFSET);
+			pr_warn("%s not support scale height: %d\n",
+							__func__, output->crop.height);
+		}
 	} else {
 		if ((input->crop.height > 1) && (output->crop.height > 1))
 			scale.yscale = (input->crop.height - 1) * 0x1000 /
diff --git a/drivers/dma/pxp/regs-pxp_v3.h b/drivers/dma/pxp/regs-pxp_v3.h
index 15a4811..401527a 100644
--- a/drivers/dma/pxp/regs-pxp_v3.h
+++ b/drivers/dma/pxp/regs-pxp_v3.h
@@ -1,7 +1,8 @@
 /*
  * Freescale PXP Register Definitions
  *
- * Copyright 2014-2015 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2014-2016 Freescale Semiconductor, Inc. All Rights Reserved.
+ * Copyright 2017-2018 NXP
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -456,6 +457,8 @@
 #define BF_PXP_PS_SCALE_XSCALE(v)  \
         (((v) << 0) & BM_PXP_PS_SCALE_XSCALE)
 
+#define BP_PXP_PS_SCALE_OFFSET 12
+
 #define HW_PXP_PS_OFFSET	(0x00000120)
 
 #define BP_PXP_PS_OFFSET_RSVD2      28