summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFancy Fang <chen.fang@freescale.com>2015-04-21 16:17:36 +0800
committerJason Liu <r64343@freescale.com>2015-05-08 17:24:57 +0800
commite8a10662cd1e32f0eb6746534a41dd855b050fe3 (patch)
treee1a0565cdefb4bf6e84c33ca64d7c0c4323eab84
parent1cbb9918bec58fbc45cd7b7e48e959e02674e94c (diff)
MLK-10696 media: pxp-v4l2: refine the bounds sanity check logic
The output image area bounds check should be moved to where the 'l', 't', 'w' and 'h' are finalized to avoid the drect area beyond the maximum fb display area which may cause overflow issue when calculating the PXP PS LRC or ULC. Signed-off-by: Fancy Fang <chen.fang@freescale.com>
-rw-r--r--drivers/media/platform/mxc/output/mxc_pxp_v4l2.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/drivers/media/platform/mxc/output/mxc_pxp_v4l2.c b/drivers/media/platform/mxc/output/mxc_pxp_v4l2.c
index 780e228a5c7f..9a4bd44b60bd 100644
--- a/drivers/media/platform/mxc/output/mxc_pxp_v4l2.c
+++ b/drivers/media/platform/mxc/output/mxc_pxp_v4l2.c
@@ -1034,10 +1034,6 @@ static int pxp_s_crop(struct file *file, void *fh,
w = max(w, PXP_MIN_PIX);
h = min(h, fbh);
h = max(h, PXP_MIN_PIX);
- if ((l + w) > fbw)
- l = 0;
- if ((t + h) > fbh)
- t = 0;
/* Round up values to PxP pixel block */
l = roundup(l, PXP_MIN_PIX);
@@ -1045,6 +1041,11 @@ static int pxp_s_crop(struct file *file, void *fh,
w = roundup(w, PXP_MIN_PIX);
h = roundup(h, PXP_MIN_PIX);
+ if ((l + w) > fbw)
+ l = 0;
+ if ((t + h) > fbh)
+ t = 0;
+
pxp->pxp_conf.proc_data.drect.left = l;
pxp->pxp_conf.proc_data.drect.top = t;
pxp->pxp_conf.proc_data.drect.width = w;