diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-08-14 05:43:36 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-09-08 09:01:01 -0400 |
commit | f1b6a735328b507810d2436891ee977fb8cd62d7 (patch) | |
tree | b4cd086ba308e37c37e762d4f37de66e8fbb9ca6 | |
parent | 4d63a25c4523b5d18e5307897d56aff785f43bf5 (diff) |
[media] cx23885: Add busy checks before changing formats
Before you can change the standard or the capture format, make sure the
various vb2_queues aren't in use since you cannot change the buffer size from
underneath a a busy vb2_queue.
Also make sure that the return code of cx23885_set_tvnorm is returned
correctly, otherwise the -EBUSY will be lost.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-417.c | 10 | ||||
-rw-r--r-- | drivers/media/pci/cx23885/cx23885-video.c | 15 |
2 files changed, 17 insertions, 8 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c index f1ef9017e2a7..6973055f0814 100644 --- a/drivers/media/pci/cx23885/cx23885-417.c +++ b/drivers/media/pci/cx23885/cx23885-417.c | |||
@@ -1248,18 +1248,18 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) | |||
1248 | { | 1248 | { |
1249 | struct cx23885_dev *dev = video_drvdata(file); | 1249 | struct cx23885_dev *dev = video_drvdata(file); |
1250 | unsigned int i; | 1250 | unsigned int i; |
1251 | int ret; | ||
1251 | 1252 | ||
1252 | for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++) | 1253 | for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++) |
1253 | if (id & cx23885_tvnorms[i].id) | 1254 | if (id & cx23885_tvnorms[i].id) |
1254 | break; | 1255 | break; |
1255 | if (i == ARRAY_SIZE(cx23885_tvnorms)) | 1256 | if (i == ARRAY_SIZE(cx23885_tvnorms)) |
1256 | return -EINVAL; | 1257 | return -EINVAL; |
1257 | dev->encodernorm = cx23885_tvnorms[i]; | ||
1258 | |||
1259 | /* Have the drier core notify the subdevices */ | ||
1260 | cx23885_set_tvnorm(dev, id); | ||
1261 | 1258 | ||
1262 | return 0; | 1259 | ret = cx23885_set_tvnorm(dev, id); |
1260 | if (!ret) | ||
1261 | dev->encodernorm = cx23885_tvnorms[i]; | ||
1262 | return ret; | ||
1263 | } | 1263 | } |
1264 | 1264 | ||
1265 | static int vidioc_enum_input(struct file *file, void *priv, | 1265 | static int vidioc_enum_input(struct file *file, void *priv, |
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c index defdf7486eda..f0ea904d4669 100644 --- a/drivers/media/pci/cx23885/cx23885-video.c +++ b/drivers/media/pci/cx23885/cx23885-video.c | |||
@@ -119,6 +119,12 @@ int cx23885_set_tvnorm(struct cx23885_dev *dev, v4l2_std_id norm) | |||
119 | (unsigned int)norm, | 119 | (unsigned int)norm, |
120 | v4l2_norm_to_name(norm)); | 120 | v4l2_norm_to_name(norm)); |
121 | 121 | ||
122 | if (dev->tvnorm != norm) { | ||
123 | if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || | ||
124 | vb2_is_busy(&dev->vb2_mpegq)) | ||
125 | return -EBUSY; | ||
126 | } | ||
127 | |||
122 | dev->tvnorm = norm; | 128 | dev->tvnorm = norm; |
123 | 129 | ||
124 | call_all(dev, video, s_std, norm); | 130 | call_all(dev, video, s_std, norm); |
@@ -591,6 +597,11 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
591 | 597 | ||
592 | if (0 != err) | 598 | if (0 != err) |
593 | return err; | 599 | return err; |
600 | |||
601 | if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq) || | ||
602 | vb2_is_busy(&dev->vb2_mpegq)) | ||
603 | return -EBUSY; | ||
604 | |||
594 | dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); | 605 | dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); |
595 | dev->width = f->fmt.pix.width; | 606 | dev->width = f->fmt.pix.width; |
596 | dev->height = f->fmt.pix.height; | 607 | dev->height = f->fmt.pix.height; |
@@ -654,9 +665,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) | |||
654 | struct cx23885_dev *dev = video_drvdata(file); | 665 | struct cx23885_dev *dev = video_drvdata(file); |
655 | dprintk(1, "%s()\n", __func__); | 666 | dprintk(1, "%s()\n", __func__); |
656 | 667 | ||
657 | cx23885_set_tvnorm(dev, tvnorms); | 668 | return cx23885_set_tvnorm(dev, tvnorms); |
658 | |||
659 | return 0; | ||
660 | } | 669 | } |
661 | 670 | ||
662 | int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i) | 671 | int cx23885_enum_input(struct cx23885_dev *dev, struct v4l2_input *i) |