summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoji Matsuoka <koji.matsuoka.xm@renesas.com>2017-02-27 07:23:34 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2017-03-23 14:45:59 -0300
commit8bc4793bd083158bd266157e85ea4762577a5be6 (patch)
tree88fe7d4ab12ed99145d73040c2ecbe2aa11557c9
parent6713c88fd04733eb34438e78118c42bc5c7e0e05 (diff)
downloadop-kernel-dev-8bc4793bd083158bd266157e85ea4762577a5be6.zip
op-kernel-dev-8bc4793bd083158bd266157e85ea4762577a5be6.tar.gz
[media] soc-camera: fix rectangle adjustment in cropping
update_subrect() adjusts the sub-rectangle to be inside a base area. It checks width and height to not exceed those of the area, then it checks the low border (left or top) to lie within the area, then the high border (right or bottom) to lie there too. This latter check has a bug, which is fixed by this patch. Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com> [g.liakhovetski@gmx.de: dropped supposedly wrong hunks] Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
-rw-r--r--drivers/media/platform/soc_camera/soc_scale_crop.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/media/platform/soc_camera/soc_scale_crop.c b/drivers/media/platform/soc_camera/soc_scale_crop.c
index f77252d..0116097 100644
--- a/drivers/media/platform/soc_camera/soc_scale_crop.c
+++ b/drivers/media/platform/soc_camera/soc_scale_crop.c
@@ -62,7 +62,8 @@ int soc_camera_client_g_rect(struct v4l2_subdev *sd, struct v4l2_rect *rect)
EXPORT_SYMBOL(soc_camera_client_g_rect);
/* Client crop has changed, update our sub-rectangle to remain within the area */
-static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect)
+static void move_and_crop_subrect(struct v4l2_rect *rect,
+ struct v4l2_rect *subrect)
{
if (rect->width < subrect->width)
subrect->width = rect->width;
@@ -72,14 +73,14 @@ static void update_subrect(struct v4l2_rect *rect, struct v4l2_rect *subrect)
if (rect->left > subrect->left)
subrect->left = rect->left;
- else if (rect->left + rect->width >
+ else if (rect->left + rect->width <
subrect->left + subrect->width)
subrect->left = rect->left + rect->width -
subrect->width;
if (rect->top > subrect->top)
subrect->top = rect->top;
- else if (rect->top + rect->height >
+ else if (rect->top + rect->height <
subrect->top + subrect->height)
subrect->top = rect->top + rect->height -
subrect->height;
@@ -216,7 +217,7 @@ int soc_camera_client_s_selection(struct v4l2_subdev *sd,
if (!ret) {
*target_rect = *cam_rect;
- update_subrect(target_rect, subrect);
+ move_and_crop_subrect(target_rect, subrect);
}
return ret;
@@ -299,7 +300,7 @@ update_cache:
if (host_1to1)
*subrect = *rect;
else
- update_subrect(rect, subrect);
+ move_and_crop_subrect(rect, subrect);
return 0;
}
OpenPOWER on IntegriCloud