summaryrefslogtreecommitdiff
path: root/drivers/media
diff options
context:
space:
mode:
authorGuennadi Liakhovetski <g.liakhovetski@gmx.de>2011-03-21 12:33:25 +0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-03-23 01:41:56 +0300
commitd366d4a08a4e5e1fddc2cc820302be8e7a8143d4 (patch)
tree075deadb65cca98c621b6d9cea246752b3ed7031 /drivers/media
parent0e4c180d3e2cc11e248f29d4c604b6194739d05a (diff)
downloadlinux-d366d4a08a4e5e1fddc2cc820302be8e7a8143d4.tar.xz
[media] V4L: soc-camera: explicitly require V4L2_BUF_TYPE_VIDEO_CAPTURE
The soc-camera core accesses the "pix" member of the struct v4l2_format::fmt union, which is only valid for V4L2_BUF_TYPE_VIDEO_CAPTURE streams. This patch adds explicit checks for this to {g,s,try}_fmt methods. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/soc_camera.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c
index 07525e74c4b4..46284489e4eb 100644
--- a/drivers/media/video/soc_camera.c
+++ b/drivers/media/video/soc_camera.c
@@ -144,6 +144,10 @@ static int soc_camera_try_fmt_vid_cap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
+ /* Only single-plane capture is supported so far */
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ return -EINVAL;
+
/* limit format to hardware capabilities */
return ici->ops->try_fmt(icd, f);
}
@@ -396,10 +400,6 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd,
if (ici->ops->init_videobuf)
icd->vb_vidq.field = pix->field;
- if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
- dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n",
- f->type);
-
dev_dbg(&icd->dev, "set width: %d height: %d\n",
icd->user_width, icd->user_height);
@@ -618,6 +618,11 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) {
+ dev_warn(&icd->dev, "Wrong buf-type %d\n", f->type);
+ return -EINVAL;
+ }
+
if (icd->streamer && icd->streamer != file)
return -EBUSY;
@@ -661,6 +666,9 @@ static int soc_camera_g_fmt_vid_cap(struct file *file, void *priv,
WARN_ON(priv != file->private_data);
+ if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
+ return -EINVAL;
+
pix->width = icd->user_width;
pix->height = icd->user_height;
pix->bytesperline = icd->bytesperline;