diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2012-07-25 10:48:53 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-30 20:09:46 -0400 |
commit | cd779254f92f30cef8d43d0c4345cfeebfc94db8 (patch) | |
tree | fb17252f30bdd239f2bcebbbe6aade8a8ab6f169 /drivers/media | |
parent | e53a99eb154d1ab6a7ddcaa960b4bddc701c7c2d (diff) |
[media] vivi: fix a few format-related compliance issues
This patch will always set the field to INTERLACED (this fixes a bug were a driver should
never return FIELD_ANY), and will default to YUYV pixelformat if an unknown pixelformat
was specified.
This way S/TRY_FMT will always return a valid format struct.
Regards,
Hans
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/vivi.c | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 679e329ffa15..a05494b71b20 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -230,7 +230,6 @@ struct vivi_dev { | |||
230 | struct vivi_fmt *fmt; | 230 | struct vivi_fmt *fmt; |
231 | unsigned int width, height; | 231 | unsigned int width, height; |
232 | struct vb2_queue vb_vidq; | 232 | struct vb2_queue vb_vidq; |
233 | enum v4l2_field field; | ||
234 | unsigned int field_count; | 233 | unsigned int field_count; |
235 | 234 | ||
236 | u8 bars[9][3]; | 235 | u8 bars[9][3]; |
@@ -623,7 +622,7 @@ static void vivi_fillbuff(struct vivi_dev *dev, struct vivi_buffer *buf) | |||
623 | 622 | ||
624 | dev->mv_count += 2; | 623 | dev->mv_count += 2; |
625 | 624 | ||
626 | buf->vb.v4l2_buf.field = dev->field; | 625 | buf->vb.v4l2_buf.field = V4L2_FIELD_INTERLACED; |
627 | dev->field_count++; | 626 | dev->field_count++; |
628 | buf->vb.v4l2_buf.sequence = dev->field_count >> 1; | 627 | buf->vb.v4l2_buf.sequence = dev->field_count >> 1; |
629 | do_gettimeofday(&ts); | 628 | do_gettimeofday(&ts); |
@@ -925,7 +924,7 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, | |||
925 | 924 | ||
926 | f->fmt.pix.width = dev->width; | 925 | f->fmt.pix.width = dev->width; |
927 | f->fmt.pix.height = dev->height; | 926 | f->fmt.pix.height = dev->height; |
928 | f->fmt.pix.field = dev->field; | 927 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; |
929 | f->fmt.pix.pixelformat = dev->fmt->fourcc; | 928 | f->fmt.pix.pixelformat = dev->fmt->fourcc; |
930 | f->fmt.pix.bytesperline = | 929 | f->fmt.pix.bytesperline = |
931 | (f->fmt.pix.width * dev->fmt->depth) >> 3; | 930 | (f->fmt.pix.width * dev->fmt->depth) >> 3; |
@@ -944,25 +943,16 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv, | |||
944 | { | 943 | { |
945 | struct vivi_dev *dev = video_drvdata(file); | 944 | struct vivi_dev *dev = video_drvdata(file); |
946 | struct vivi_fmt *fmt; | 945 | struct vivi_fmt *fmt; |
947 | enum v4l2_field field; | ||
948 | 946 | ||
949 | fmt = get_format(f); | 947 | fmt = get_format(f); |
950 | if (!fmt) { | 948 | if (!fmt) { |
951 | dprintk(dev, 1, "Fourcc format (0x%08x) invalid.\n", | 949 | dprintk(dev, 1, "Fourcc format (0x%08x) unknown.\n", |
952 | f->fmt.pix.pixelformat); | 950 | f->fmt.pix.pixelformat); |
953 | return -EINVAL; | 951 | f->fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV; |
954 | } | 952 | fmt = get_format(f); |
955 | |||
956 | field = f->fmt.pix.field; | ||
957 | |||
958 | if (field == V4L2_FIELD_ANY) { | ||
959 | field = V4L2_FIELD_INTERLACED; | ||
960 | } else if (V4L2_FIELD_INTERLACED != field) { | ||
961 | dprintk(dev, 1, "Field type invalid.\n"); | ||
962 | return -EINVAL; | ||
963 | } | 953 | } |
964 | 954 | ||
965 | f->fmt.pix.field = field; | 955 | f->fmt.pix.field = V4L2_FIELD_INTERLACED; |
966 | v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2, | 956 | v4l_bound_align_image(&f->fmt.pix.width, 48, MAX_WIDTH, 2, |
967 | &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0); | 957 | &f->fmt.pix.height, 32, MAX_HEIGHT, 0, 0); |
968 | f->fmt.pix.bytesperline = | 958 | f->fmt.pix.bytesperline = |
@@ -996,7 +986,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
996 | dev->pixelsize = dev->fmt->depth / 8; | 986 | dev->pixelsize = dev->fmt->depth / 8; |
997 | dev->width = f->fmt.pix.width; | 987 | dev->width = f->fmt.pix.width; |
998 | dev->height = f->fmt.pix.height; | 988 | dev->height = f->fmt.pix.height; |
999 | dev->field = f->fmt.pix.field; | ||
1000 | 989 | ||
1001 | return 0; | 990 | return 0; |
1002 | } | 991 | } |