Skip to content

Commit 5aa9599

Browse files
Hans VerkuilMauro Carvalho Chehab
authored andcommitted
[media] cx231xx-417: fix g/try_fmt compliance problems
Colorspace, field and priv were not set, and sizeimage was calculated using the wrong values (dev->ts1.ts_packet_size and dev->ts1.ts_packet_count can be 0 at module load). Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
1 parent bc08734 commit 5aa9599

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

drivers/media/usb/cx231xx/cx231xx-417.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,7 @@ static int bb_buf_setup(struct videobuf_queue *q,
12231223

12241224
return 0;
12251225
}
1226+
12261227
static void free_buffer(struct videobuf_queue *vq, struct cx231xx_buffer *buf)
12271228
{
12281229
struct cx231xx_fh *fh = vq->priv_data;
@@ -1645,17 +1646,18 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
16451646
{
16461647
struct cx231xx_fh *fh = file->private_data;
16471648
struct cx231xx *dev = fh->dev;
1649+
16481650
dprintk(3, "enter vidioc_g_fmt_vid_cap()\n");
1649-
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1651+
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
16501652
f->fmt.pix.bytesperline = 0;
1651-
f->fmt.pix.sizeimage =
1652-
dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1653-
f->fmt.pix.colorspace = 0;
1654-
f->fmt.pix.width = dev->ts1.width;
1655-
f->fmt.pix.height = dev->ts1.height;
1656-
f->fmt.pix.field = fh->vidq.field;
1657-
dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
1658-
dev->ts1.width, dev->ts1.height, fh->vidq.field);
1653+
f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
1654+
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1655+
f->fmt.pix.width = dev->ts1.width;
1656+
f->fmt.pix.height = dev->ts1.height;
1657+
f->fmt.pix.field = V4L2_FIELD_INTERLACED;
1658+
f->fmt.pix.priv = 0;
1659+
dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d\n",
1660+
dev->ts1.width, dev->ts1.height);
16591661
dprintk(3, "exit vidioc_g_fmt_vid_cap()\n");
16601662
return 0;
16611663
}
@@ -1665,14 +1667,16 @@ static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
16651667
{
16661668
struct cx231xx_fh *fh = file->private_data;
16671669
struct cx231xx *dev = fh->dev;
1670+
16681671
dprintk(3, "enter vidioc_try_fmt_vid_cap()\n");
1669-
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1672+
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
16701673
f->fmt.pix.bytesperline = 0;
1671-
f->fmt.pix.sizeimage =
1672-
dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1673-
f->fmt.pix.colorspace = 0;
1674-
dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
1675-
dev->ts1.width, dev->ts1.height, fh->vidq.field);
1674+
f->fmt.pix.sizeimage = mpeglines * mpeglinesize;
1675+
f->fmt.pix.field = V4L2_FIELD_INTERLACED;
1676+
f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
1677+
f->fmt.pix.priv = 0;
1678+
dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d\n",
1679+
dev->ts1.width, dev->ts1.height);
16761680
dprintk(3, "exit vidioc_try_fmt_vid_cap()\n");
16771681
return 0;
16781682
}

0 commit comments

Comments
 (0)