Skip to content

Commit

Permalink
media: common: saa7146: fix compliance problems with field handling
Browse files Browse the repository at this point in the history
The initial field value of the format is ANY, which isn't allowed.
Change to INTERLACED.

VIDIOC_TRY_FMT will overwrite vv->last_field, which is an
unwanted side-effect, so drop this.

And finally vidioc_s_fmt_vid_cap didn't initialize vv->last_field
correctly.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Apr 15, 2023
1 parent 0b6e30b commit e456180
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion drivers/media/common/saa7146/saa7146_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ int saa7146_vv_init(struct saa7146_dev* dev, struct saa7146_ext_vv *ext_vv)
fmt->width = 384;
fmt->height = 288;
fmt->pixelformat = V4L2_PIX_FMT_BGR24;
fmt->field = V4L2_FIELD_ANY;
fmt->field = V4L2_FIELD_INTERLACED;
fmt->colorspace = V4L2_COLORSPACE_SMPTE170M;
fmt->bytesperline = 3 * fmt->width;
fmt->sizeimage = fmt->bytesperline * fmt->height;
Expand Down
19 changes: 10 additions & 9 deletions drivers/media/common/saa7146/saa7146_video.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,13 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *fh, struct v4l2_forma
}
switch (field) {
case V4L2_FIELD_ALTERNATE:
vv->last_field = V4L2_FIELD_TOP;
maxh = maxh / 2;
break;
case V4L2_FIELD_TOP:
case V4L2_FIELD_BOTTOM:
vv->last_field = V4L2_FIELD_INTERLACED;
maxh = maxh / 2;
break;
case V4L2_FIELD_INTERLACED:
vv->last_field = V4L2_FIELD_INTERLACED;
break;
default:
DEB_D("no known field mode '%d'\n", field);
return -EINVAL;
field = V4L2_FIELD_INTERLACED;
break;
}

f->fmt.pix.field = field;
Expand Down Expand Up @@ -434,6 +427,14 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *fh, struct v4l2_format
err = vidioc_try_fmt_vid_cap(file, fh, f);
if (0 != err)
return err;
switch (f->fmt.pix.field) {
case V4L2_FIELD_ALTERNATE:
vv->last_field = V4L2_FIELD_TOP;
break;
default:
vv->last_field = V4L2_FIELD_INTERLACED;
break;
}
vv->video_fmt = f->fmt.pix;
DEB_EE("set to pixelformat '%4.4s'\n",
(char *)&vv->video_fmt.pixelformat);
Expand Down

0 comments on commit e456180

Please sign in to comment.