summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/soc_camera.c
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 16:46:52 +0200
committerGuennadi Liakhovetski <g.liakhovetski@gmx.de>2009-08-25 16:46:52 +0200
commit4325d71881ee891f6b5313cdb76c08c1d95d2091 (patch)
treed547f7ed5c98e2e9e3c68e9bd5d9541e48ae6f35 /linux/drivers/media/video/soc_camera.c
parent0b4b46ce45c942a26e9a5b68cd826cbbcfb39d8f (diff)
downloadmediapointer-dvb-s2-4325d71881ee891f6b5313cdb76c08c1d95d2091.tar.gz
mediapointer-dvb-s2-4325d71881ee891f6b5313cdb76c08c1d95d2091.tar.bz2
soc-camera: S_CROP V4L2 API compliance fix
From: Guennadi Liakhovetski <g.liakhovetski@gmx.de> V4L2 API mandates, that drivers do not update the argument of the S_CROP ioctl() with the actual geometry. Comply. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Priority: low --- drivers/media/video/soc_camera.c | 39 ++++++++++++++++++++++--------------- 1 files changed, 23 insertions(+), 16 deletions(-)
Diffstat (limited to 'linux/drivers/media/video/soc_camera.c')
-rw-r--r--linux/drivers/media/video/soc_camera.c39
1 files changed, 23 insertions, 16 deletions
diff --git a/linux/drivers/media/video/soc_camera.c b/linux/drivers/media/video/soc_camera.c
index 104496141..e4740359d 100644
--- a/linux/drivers/media/video/soc_camera.c
+++ b/linux/drivers/media/video/soc_camera.c
@@ -748,12 +748,19 @@ static int soc_camera_g_crop(struct file *file, void *fh,
return 0;
}
+/*
+ * According to the V4L2 API, drivers shall not update the struct v4l2_crop
+ * argument with the actual geometry, instead, the user shall use G_CROP to
+ * retrieve it. However, we expect camera host and client drivers to update
+ * the argument, which we then use internally, but do not return to the user.
+ */
static int soc_camera_s_crop(struct file *file, void *fh,
struct v4l2_crop *a)
{
struct soc_camera_file *icf = file->private_data;
struct soc_camera_device *icd = icf->icd;
struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent);
+ struct v4l2_rect rect = a->c;
int ret;
if (a->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
@@ -762,29 +769,29 @@ static int soc_camera_s_crop(struct file *file, void *fh,
/* Cropping is allowed during a running capture, guard consistency */
mutex_lock(&icf->vb_vidq.vb_lock);
- if (a->c.width > icd->rect_max.width)
- a->c.width = icd->rect_max.width;
+ if (rect.width > icd->rect_max.width)
+ rect.width = icd->rect_max.width;
- if (a->c.width < icd->width_min)
- a->c.width = icd->width_min;
+ if (rect.width < icd->width_min)
+ rect.width = icd->width_min;
- if (a->c.height > icd->rect_max.height)
- a->c.height = icd->rect_max.height;
+ if (rect.height > icd->rect_max.height)
+ rect.height = icd->rect_max.height;
- if (a->c.height < icd->height_min)
- a->c.height = icd->height_min;
+ if (rect.height < icd->height_min)
+ rect.height = icd->height_min;
- if (a->c.width + a->c.left > icd->rect_max.width + icd->rect_max.left)
- a->c.left = icd->rect_max.width + icd->rect_max.left -
- a->c.width;
+ if (rect.width + rect.left > icd->rect_max.width + icd->rect_max.left)
+ rect.left = icd->rect_max.width + icd->rect_max.left -
+ rect.width;
- if (a->c.height + a->c.top > icd->rect_max.height + icd->rect_max.top)
- a->c.top = icd->rect_max.height + icd->rect_max.top -
- a->c.height;
+ if (rect.height + rect.top > icd->rect_max.height + icd->rect_max.top)
+ rect.top = icd->rect_max.height + icd->rect_max.top -
+ rect.height;
- ret = ici->ops->set_crop(icd, &a->c);
+ ret = ici->ops->set_crop(icd, &rect);
if (!ret)
- icd->rect_current = a->c;
+ icd->rect_current = rect;
mutex_unlock(&icf->vb_vidq.vb_lock);