diff options
| author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2011-03-21 05:33:25 -0400 |
|---|---|---|
| committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-22 18:41:56 -0400 |
| commit | d366d4a08a4e5e1fddc2cc820302be8e7a8143d4 (patch) | |
| tree | 075deadb65cca98c621b6d9cea246752b3ed7031 | |
| parent | 0e4c180d3e2cc11e248f29d4c604b6194739d05a (diff) | |
[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>
| -rw-r--r-- | drivers/media/video/soc_camera.c | 16 |
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, | |||
| 144 | 144 | ||
| 145 | WARN_ON(priv != file->private_data); | 145 | WARN_ON(priv != file->private_data); |
| 146 | 146 | ||
| 147 | /* Only single-plane capture is supported so far */ | ||
| 148 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 149 | return -EINVAL; | ||
| 150 | |||
| 147 | /* limit format to hardware capabilities */ | 151 | /* limit format to hardware capabilities */ |
| 148 | return ici->ops->try_fmt(icd, f); | 152 | return ici->ops->try_fmt(icd, f); |
| 149 | } | 153 | } |
| @@ -396,10 +400,6 @@ static int soc_camera_set_fmt(struct soc_camera_device *icd, | |||
| 396 | if (ici->ops->init_videobuf) | 400 | if (ici->ops->init_videobuf) |
| 397 | icd->vb_vidq.field = pix->field; | 401 | icd->vb_vidq.field = pix->field; |
| 398 | 402 | ||
| 399 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 400 | dev_warn(&icd->dev, "Attention! Wrong buf-type %d\n", | ||
| 401 | f->type); | ||
| 402 | |||
| 403 | dev_dbg(&icd->dev, "set width: %d height: %d\n", | 403 | dev_dbg(&icd->dev, "set width: %d height: %d\n", |
| 404 | icd->user_width, icd->user_height); | 404 | icd->user_width, icd->user_height); |
| 405 | 405 | ||
| @@ -618,6 +618,11 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, | |||
| 618 | 618 | ||
| 619 | WARN_ON(priv != file->private_data); | 619 | WARN_ON(priv != file->private_data); |
| 620 | 620 | ||
| 621 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { | ||
| 622 | dev_warn(&icd->dev, "Wrong buf-type %d\n", f->type); | ||
| 623 | return -EINVAL; | ||
| 624 | } | ||
| 625 | |||
| 621 | if (icd->streamer && icd->streamer != file) | 626 | if (icd->streamer && icd->streamer != file) |
| 622 | return -EBUSY; | 627 | return -EBUSY; |
| 623 | 628 | ||
| @@ -661,6 +666,9 @@ static int soc_camera_g_fmt_vid_cap(struct file *file, void *priv, | |||
| 661 | 666 | ||
| 662 | WARN_ON(priv != file->private_data); | 667 | WARN_ON(priv != file->private_data); |
| 663 | 668 | ||
| 669 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
| 670 | return -EINVAL; | ||
| 671 | |||
| 664 | pix->width = icd->user_width; | 672 | pix->width = icd->user_width; |
| 665 | pix->height = icd->user_height; | 673 | pix->height = icd->user_height; |
| 666 | pix->bytesperline = icd->bytesperline; | 674 | pix->bytesperline = icd->bytesperline; |
