From c5e1b445fbf1072ddaeda9747941da0fb4029ffd Mon Sep 17 00:00:00 2001 From: Liu Ying Date: Sun, 22 Sep 2013 12:37:39 +0800 Subject: [PATCH] ENGR00280663-2 IPUv3 device: check downsize ratio overflow IPUv3 IC task downsize scaling ratio cannot exceed or be equal to 8:1. This patch makes the code return error code if the ratio overflows. Signed-off-by: Liu Ying --- drivers/mxc/ipu3/ipu_device.c | 16 ++++++++++++++++ include/uapi/linux/ipu.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/drivers/mxc/ipu3/ipu_device.c b/drivers/mxc/ipu3/ipu_device.c index 5814adb55837..6781582a47c7 100644 --- a/drivers/mxc/ipu3/ipu_device.c +++ b/drivers/mxc/ipu3/ipu_device.c @@ -665,6 +665,12 @@ static void dump_check_err(struct device *dev, int err) case IPU_CHECK_ERR_SPLIT_WITH_ROT: dev_err(dev, "not support split mode with rotation\n"); break; + case IPU_CHECK_ERR_W_DOWNSIZE_OVER: + dev_err(dev, "horizontal downsizing ratio overflow\n"); + break; + case IPU_CHECK_ERR_H_DOWNSIZE_OVER: + dev_err(dev, "vertical downsizing ratio overflow\n"); + break; default: break; } @@ -966,6 +972,16 @@ static int check_task(struct ipu_task_entry *t) &t->set.o_off, &t->set.o_uoff, &t->set.o_voff, &t->set.ostride); + if (t->output.crop.w * 8 <= t->input.crop.w) { + ret = IPU_CHECK_ERR_W_DOWNSIZE_OVER; + goto done; + } + + if (t->output.crop.h * 8 <= t->input.crop.h) { + ret = IPU_CHECK_ERR_H_DOWNSIZE_OVER; + goto done; + } + if ((IPU_PIX_FMT_TILED_NV12 == t->input.format) || (IPU_PIX_FMT_TILED_NV12F == t->input.format)) { if ((t->input.crop.w > soc_max_in_width(1)) || diff --git a/include/uapi/linux/ipu.h b/include/uapi/linux/ipu.h index 866d2b639d21..b2083288a057 100644 --- a/include/uapi/linux/ipu.h +++ b/include/uapi/linux/ipu.h @@ -269,6 +269,8 @@ enum { IPU_CHECK_ERR_SPLIT_WITH_ROT, IPU_CHECK_ERR_NOT_SUPPORT, IPU_CHECK_ERR_NOT16ALIGN, + IPU_CHECK_ERR_W_DOWNSIZE_OVER, + IPU_CHECK_ERR_H_DOWNSIZE_OVER, }; /* IOCTL commands */ -- 2.39.5