summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLajos Molnar <lajos@ti.com>2012-05-21 14:30:02 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2012-05-21 14:30:02 -0700
commitaca35afd1da95e99a3b66c8a4864f9c70b2f7e70 (patch)
treea9aab1b86cd8aecb97e8e501b0f775e9452705fc
parent7a7d4c25c7362c011397219180c9b7e9afa9ce9c (diff)
parent16b7f6c4b06ac7350c30309d0559a466097d8ae7 (diff)
downloadhardware_ti_omap4xxx-aca35afd1da95e99a3b66c8a4864f9c70b2f7e70.zip
hardware_ti_omap4xxx-aca35afd1da95e99a3b66c8a4864f9c70b2f7e70.tar.gz
hardware_ti_omap4xxx-aca35afd1da95e99a3b66c8a4864f9c70b2f7e70.tar.bz2
am 16b7f6c4: hwc: Fix truncation errors in scaling decision
* commit '16b7f6c4b06ac7350c30309d0559a466097d8ae7': hwc: Fix truncation errors in scaling decision
-rw-r--r--hwc/hwc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/hwc/hwc.c b/hwc/hwc.c
index b5b80ec..d6c28f7 100644
--- a/hwc/hwc.c
+++ b/hwc/hwc.c
@@ -46,6 +46,8 @@
#define WIDTH(rect) ((rect).right - (rect).left)
#define HEIGHT(rect) ((rect).bottom - (rect).top)
+#define DIV_ROUND_UP(a, b) (((a) + (b) - 1) / (b))
+
#include <video/dsscomp.h>
#include "hal_public.h"
@@ -716,6 +718,8 @@ static int omap4_hwc_can_scale(__u32 src_w, __u32 src_h, __u32 dst_w, __u32 dst_
__u32 pclk)
{
__u32 fclk = limits->fclk / 1000;
+ __u32 min_src_w = DIV_ROUND_UP(src_w, is_2d ? limits->max_xdecim_2d : limits->max_xdecim_1d);
+ __u32 min_src_h = DIV_ROUND_UP(src_h, is_2d ? limits->max_ydecim_2d : limits->max_ydecim_1d);
/* ERRATAs */
/* cannot render 1-width layers on DSI video mode panels - we just disallow all 1-width LCD layers */
@@ -729,15 +733,15 @@ static int omap4_hwc_can_scale(__u32 src_w, __u32 src_h, __u32 dst_w, __u32 dst_
return 0;
/* max downscale */
- if (dst_h < src_h / limits->max_downscale / (is_2d ? limits->max_ydecim_2d : limits->max_ydecim_1d))
+ if (dst_h * limits->max_downscale < min_src_h)
return 0;
/* for manual panels pclk is 0, and there are no pclk based scaling limits */
if (!pclk)
- return (dst_w < src_w / limits->max_downscale / (is_2d ? limits->max_xdecim_2d : limits->max_xdecim_1d));
+ return !(dst_w * limits->max_downscale < min_src_w);
/* :HACK: limit horizontal downscale well below theoretical limit as we saw display artifacts */
- if (dst_w < src_w / 4)
+ if (dst_w * 4 < src_w)
return 0;
/* max horizontal downscale is 4, or the fclk/pixclk */
@@ -746,7 +750,7 @@ static int omap4_hwc_can_scale(__u32 src_w, __u32 src_h, __u32 dst_w, __u32 dst_
/* for small parts, we need to use integer fclk/pixclk */
if (src_w < limits->integer_scale_ratio_limit)
fclk = fclk / pclk * pclk;
- if ((__u32) dst_w < src_w * pclk / fclk / (is_2d ? limits->max_xdecim_2d : limits->max_xdecim_1d))
+ if ((__u32) dst_w * fclk < min_src_w * pclk)
return 0;
return 1;