diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2014-08-29 06:08:07 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@osg.samsung.com> | 2014-11-03 08:34:33 -0200 |
commit | 078859a3230c123ed9cb798fb1cd7f89b4fde102 (patch) | |
tree | f22c40d2ecab1ec44986555b18642331ec369570 /drivers/media/pci | |
parent | fb37ab3e788c698bf889e70335d5d1ccb6de2373 (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.c | 8 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88-core.c | 7 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88-video.c | 14 | ||||
-rw-r--r-- | drivers/media/pci/cx88/cx88.h | 13 |
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, struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; + if (vb2_is_busy(&dev->vb2_mpegq)) + return -EBUSY; + if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || + vb2_is_busy(&core->v4ldev->vb2_vbiq))) + return -EBUSY; vidioc_try_fmt_vid_cap(file, priv, f); core->width = f->fmt.pix.width; core->height = f->fmt.pix.height; @@ -1002,8 +1007,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) struct cx8802_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - cx88_set_tvnorm(core, id); - return 0; + return cx88_set_tvnorm(core, id); } static 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) u32 bdelay,agcdelay,htotal; u32 cxiformat, cxoformat; + if (norm == core->tvnorm) + return 0; + if (core->v4ldev && (vb2_is_busy(&core->v4ldev->vb2_vidq) || + vb2_is_busy(&core->v4ldev->vb2_vbiq))) + return -EBUSY; + if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) + return -EBUSY; core->tvnorm = norm; fsc8 = norm_fsc8(norm); 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, if (0 != err) return err; + if (vb2_is_busy(&dev->vb2_vidq) || vb2_is_busy(&dev->vb2_vbiq)) + return -EBUSY; + if (core->dvbdev && vb2_is_busy(&core->dvbdev->vb2_mpegq)) + return -EBUSY; dev->fmt = format_by_fourcc(f->fmt.pix.pixelformat); core->width = f->fmt.pix.width; core->height = f->fmt.pix.height; @@ -864,9 +868,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) struct cx8800_dev *dev = video_drvdata(file); struct cx88_core *core = dev->core; - cx88_set_tvnorm(core, tvnorms); - - return 0; + return cx88_set_tvnorm(core, tvnorms); } /* only one input in this sample driver */ @@ -1442,6 +1444,9 @@ static int cx8800_initdev(struct pci_dev *pci_dev, dev->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); + /* Maintain a reference so cx88-blackbird can query the 8800 device. */ + core->v4ldev = dev; + /* initial device configuration */ mutex_lock(&core->lock); cx88_set_tvnorm(core, core->tvnorm); @@ -1544,6 +1549,7 @@ fail_unreg: free_irq(pci_dev->irq, dev); mutex_unlock(&core->lock); fail_core: + core->v4ldev = NULL; cx88_core_put(core,dev->pci); fail_free: kfree(dev); @@ -1572,6 +1578,8 @@ static void cx8800_finidev(struct pci_dev *pci_dev) free_irq(pci_dev->irq, dev); cx8800_unregister_video(dev); + core->v4ldev = NULL; + /* free memory */ cx88_core_put(core,dev->pci); 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 { u32 count; }; +struct cx8800_dev; +struct cx8802_dev; + struct cx88_core { struct list_head devlist; atomic_t refcount; @@ -401,8 +404,13 @@ struct cx88_core { /* various v4l controls */ u32 freq; - /* cx88-video needs to access cx8802 for hybrid tuner pll access. */ + /* + * cx88-video needs to access cx8802 for hybrid tuner pll access and + * for vb2_is_busy() checks. + */ struct cx8802_dev *dvbdev; + /* cx88-blackbird needs to access cx8800 for vb2_is_busy() checks */ + struct cx8800_dev *v4ldev; enum cx88_board_type active_type_id; int active_ref; int active_fe_id; @@ -456,9 +464,6 @@ static inline struct cx88_core *to_core(struct v4l2_device *v4l2_dev) val; \ }) -struct cx8800_dev; -struct cx8802_dev; - /* ----------------------------------------------------------- */ /* function 0: video stuff */ |