aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-08-29 05:08:07 -0400
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>2014-11-03 05:34:33 -0500
commit078859a3230c123ed9cb798fb1cd7f89b4fde102 (patch)
treef22c40d2ecab1ec44986555b18642331ec369570 /drivers/media/pci
parentfb37ab3e788c698bf889e70335d5d1ccb6de2373 (diff)
[media] cx88: don't allow changes while vb2_is_busy
Make sure that changing the standard or format is not allowed while one or more of the video, vbi or mpeg vb2 queues are busy. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/cx88/cx88-blackbird.c8
-rw-r--r--drivers/media/pci/cx88/cx88-core.c7
-rw-r--r--drivers/media/pci/cx88/cx88-video.c14
-rw-r--r--drivers/media/pci/cx88/cx88.h13
4 files changed, 33 insertions, 9 deletions
diff --git a/drivers/media/pci/cx88/cx88-blackbird.c b/drivers/media/pci/cx88/cx88-blackbird.c
index 13b8ed322693..ff7978212e9d 100644
--- a/drivers/media/pci/cx88/cx88-blackbird.c
+++ b/drivers/media/pci/cx88/cx88-blackbird.c
@@ -855,6 +855,11 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
855 struct cx8802_dev *dev = video_drvdata(file); 855 struct cx8802_dev *dev = video_drvdata(file);
856 struct cx88_core *core = dev->core; 856 struct cx88_core *core = dev->core;
857 857
858 if (vb2_is_busy(&dev->vb2_mpegq))
859 return -EBUSY;
860 if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) ||
861 vb2_is_busy(&core->v4ldev->vb2_vbiq)))
862 return -EBUSY;
858 vidioc_try_fmt_vid_cap(file, priv, f); 863 vidioc_try_fmt_vid_cap(file, priv, f);
859 core->width = f->fmt.pix.width; 864 core->width = f->fmt.pix.width;
860 core->height = f->fmt.pix.height; 865 core->height = f->fmt.pix.height;
@@ -1002,8 +1007,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
1002 struct cx8802_dev *dev = video_drvdata(file); 1007 struct cx8802_dev *dev = video_drvdata(file);
1003 struct cx88_core *core = dev->core; 1008 struct cx88_core *core = dev->core;
1004 1009
1005 cx88_set_tvnorm(core, id); 1010 return cx88_set_tvnorm(core, id);
1006 return 0;
1007} 1011}
1008 1012
1009static const struct v4l2_file_operations mpeg_fops = 1013static const struct v4l2_file_operations mpeg_fops =
diff --git a/drivers/media/pci/cx88/cx88-core.c b/drivers/media/pci/cx88/cx88-core.c
index bbdbb58576ef..9fa4acbdcab8 100644
--- a/drivers/media/pci/cx88/cx88-core.c
+++ b/drivers/media/pci/cx88/cx88-core.c
@@ -864,6 +864,13 @@ int cx88_set_tvnorm(struct cx88_core *core, v4l2_std_id norm)
864 u32 bdelay,agcdelay,htotal; 864 u32 bdelay,agcdelay,htotal;
865 u32 cxiformat, cxoformat; 865 u32 cxiformat, cxoformat;
866 866
867 if (norm == core->tvnorm)
868 return 0;
869 if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) ||
870 vb2_is_busy(&core->v4ldev->vb2_vbiq)))
871 return -EBUSY;
872 if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq))
873 return -EBUSY;
867 core->tvnorm = norm; 874 core->tvnorm = norm;
868 fsc8 = norm_fsc8(norm); 875 fsc8 = norm_fsc8(norm);
869 adc_clock = xtal; 876 adc_clock = xtal;
diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
index eadceebfed8e..64d6a722654c 100644
--- a/drivers/media/pci/cx88/cx88-video.c
+++ b/drivers/media/pci/cx88/cx88-video.c
@@ -792,6 +792,10 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
792 792
793 if (0 != err) 793 if (0 != err)
794 return err; 794 return err;
795 if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq))
796 return -EBUSY;
797 if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq))
798 return -EBUSY;
795 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); 799 dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat);
796 core->width = f->fmt.pix.width; 800 core->width = f->fmt.pix.width;
797 core->height = f->fmt.pix.height; 801 core->height = f->fmt.pix.height;
@@ -864,9 +868,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
864 struct cx8800_dev *dev = video_drvdata(file); 868 struct cx8800_dev *dev = video_drvdata(file);
865 struct cx88_core *core = dev->core; 869 struct cx88_core *core = dev->core;
866 870
867 cx88_set_tvnorm(core, tvnorms); 871 return cx88_set_tvnorm(core, tvnorms);
868
869 return 0;
870} 872}
871 873
872/* only one input in this sample driver */ 874/* only one input in this sample driver */
@@ -1442,6 +1444,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev,
1442 1444
1443 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 1445 dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
1444 1446
1447 /* Maintain a reference so cx88-blackbird can query the 8800 device. */
1448 core->v4ldev = dev;
1449
1445 /* initial device configuration */ 1450 /* initial device configuration */
1446 mutex_lock(&core->lock); 1451 mutex_lock(&core->lock);
1447 cx88_set_tvnorm(core, core->tvnorm); 1452 cx88_set_tvnorm(core, core->tvnorm);
@@ -1544,6 +1549,7 @@ fail_unreg:
1544 free_irq(pci_dev->irq, dev); 1549 free_irq(pci_dev->irq, dev);
1545 mutex_unlock(&core->lock); 1550 mutex_unlock(&core->lock);
1546fail_core: 1551fail_core:
1552 core->v4ldev = NULL;
1547 cx88_core_put(core,dev->pci); 1553 cx88_core_put(core,dev->pci);
1548fail_free: 1554fail_free:
1549 kfree(dev); 1555 kfree(dev);
@@ -1572,6 +1578,8 @@ static void cx8800_finidev(struct pci_dev *pci_dev)
1572 free_irq(pci_dev->irq, dev); 1578 free_irq(pci_dev->irq, dev);
1573 cx8800_unregister_video(dev); 1579 cx8800_unregister_video(dev);
1574 1580
1581 core->v4ldev = NULL;
1582
1575 /* free memory */ 1583 /* free memory */
1576 cx88_core_put(core,dev->pci); 1584 cx88_core_put(core,dev->pci);
1577 kfree(dev); 1585 kfree(dev);
diff --git a/drivers/media/pci/cx88/cx88.h b/drivers/media/pci/cx88/cx88.h
index 93bc7cf7d39b..2fa4aa93e503 100644
--- a/drivers/media/pci/cx88/cx88.h
+++ b/drivers/media/pci/cx88/cx88.h
@@ -334,6 +334,9 @@ struct cx88_dmaqueue {
334 u32 count; 334 u32 count;
335}; 335};
336 336
337struct cx8800_dev;
338struct cx8802_dev;
339
337struct cx88_core { 340struct cx88_core {
338 struct list_head devlist; 341 struct list_head devlist;
339 atomic_t refcount; 342 atomic_t refcount;
@@ -401,8 +404,13 @@ struct cx88_core {
401 /* various v4l controls */ 404 /* various v4l controls */
402 u32 freq; 405 u32 freq;
403 406
404 /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ 407 /*
408 * cx88-video needs to access cx8802 for hybrid tuner pll access and
409 * for vb2_is_busy() checks.
410 */
405 struct cx8802_dev *dvbdev; 411 struct cx8802_dev *dvbdev;
412 /* cx88-blackbird needs to access cx8800 for vb2_is_busy() checks */
413 struct cx8800_dev *v4ldev;
406 enum cx88_board_type active_type_id; 414 enum cx88_board_type active_type_id;
407 int active_ref; 415 int active_ref;
408 int active_fe_id; 416 int active_fe_id;
@@ -456,9 +464,6 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev)
456 val; \ 464 val; \
457 }) 465 })
458 466
459struct cx8800_dev;
460struct cx8802_dev;
461
462/* ----------------------------------------------------------- */ 467/* ----------------------------------------------------------- */
463/* function 0: video stuff */ 468/* function 0: video stuff */
464 469