aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/saa7134
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2013-02-01 18:01:16 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-04-14 17:59:34 -0400
commit3bbaa3a60175ed120c8ab8937c21425fd744c7b7 (patch)
treef58fd4912057a4ee8ab79d3674fe56629f9bf2a1 /drivers/media/pci/saa7134
parent82456708389d6d9eb81a4479d54efa0bf7dd8bf3 (diff)
[media] saa7134: v4l2-compliance: use v4l2_fh to fix priority handling
Make saa7134 driver more V4L2 compliant: remove broken priority handling and use v4l2_fh instead Signed-off-by: Ondrej Zary <linux@rainbow-software.org> [hans.verkuil@cisco.com: fixed a merge conflict in saa7134.h] Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci/saa7134')
-rw-r--r--drivers/media/pci/saa7134/saa7134-core.c3
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c61
-rw-r--r--drivers/media/pci/saa7134/saa7134.h4
3 files changed, 10 insertions, 58 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-core.c b/drivers/media/pci/saa7134/saa7134-core.c
index 8fd24e7c9403..45f0aca597ae 100644
--- a/drivers/media/pci/saa7134/saa7134-core.c
+++ b/drivers/media/pci/saa7134/saa7134-core.c
@@ -805,6 +805,7 @@ static struct video_device *vdev_init(struct saa7134_dev *dev,
805 vfd->debug = video_debug; 805 vfd->debug = video_debug;
806 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)", 806 snprintf(vfd->name, sizeof(vfd->name), "%s %s (%s)",
807 dev->name, type, saa7134_boards[dev->board].name); 807 dev->name, type, saa7134_boards[dev->board].name);
808 set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
808 video_set_drvdata(vfd, dev); 809 video_set_drvdata(vfd, dev);
809 return vfd; 810 return vfd;
810} 811}
@@ -1028,8 +1029,6 @@ static int saa7134_initdev(struct pci_dev *pci_dev,
1028 } 1029 }
1029 } 1030 }
1030 1031
1031 v4l2_prio_init(&dev->prio);
1032
1033 mutex_lock(&saa7134_devlist_lock); 1032 mutex_lock(&saa7134_devlist_lock);
1034 list_for_each_entry(mops, &mops_list, next) 1033 list_for_each_entry(mops, &mops_list, next)
1035 mpeg_ops_attach(mops, dev); 1034 mpeg_ops_attach(mops, dev);
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 0f2d3bd4896a..941e2ebab41d 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1176,14 +1176,6 @@ int saa7134_s_ctrl_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, str
1176 int restart_overlay = 0; 1176 int restart_overlay = 0;
1177 int err; 1177 int err;
1178 1178
1179 /* When called from the empress code fh == NULL.
1180 That needs to be fixed somehow, but for now this is
1181 good enough. */
1182 if (fh) {
1183 err = v4l2_prio_check(&dev->prio, fh->prio);
1184 if (0 != err)
1185 return err;
1186 }
1187 err = -EINVAL; 1179 err = -EINVAL;
1188 1180
1189 mutex_lock(&dev->lock); 1181 mutex_lock(&dev->lock);
@@ -1352,6 +1344,7 @@ static int video_open(struct file *file)
1352 if (NULL == fh) 1344 if (NULL == fh)
1353 return -ENOMEM; 1345 return -ENOMEM;
1354 1346
1347 v4l2_fh_init(&fh->fh, vdev);
1355 file->private_data = fh; 1348 file->private_data = fh;
1356 fh->dev = dev; 1349 fh->dev = dev;
1357 fh->radio = radio; 1350 fh->radio = radio;
@@ -1359,7 +1352,6 @@ static int video_open(struct file *file)
1359 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 1352 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
1360 fh->width = 720; 1353 fh->width = 720;
1361 fh->height = 576; 1354 fh->height = 576;
1362 v4l2_prio_open(&dev->prio, &fh->prio);
1363 1355
1364 videobuf_queue_sg_init(&fh->cap, &video_qops, 1356 videobuf_queue_sg_init(&fh->cap, &video_qops,
1365 &dev->pci->dev, &dev->slock, 1357 &dev->pci->dev, &dev->slock,
@@ -1384,6 +1376,8 @@ static int video_open(struct file *file)
1384 /* switch to video/vbi mode */ 1376 /* switch to video/vbi mode */
1385 video_mux(dev,dev->ctl_input); 1377 video_mux(dev,dev->ctl_input);
1386 } 1378 }
1379 v4l2_fh_add(&fh->fh);
1380
1387 return 0; 1381 return 0;
1388} 1382}
1389 1383
@@ -1504,7 +1498,8 @@ static int video_release(struct file *file)
1504 saa7134_pgtable_free(dev->pci,&fh->pt_cap); 1498 saa7134_pgtable_free(dev->pci,&fh->pt_cap);
1505 saa7134_pgtable_free(dev->pci,&fh->pt_vbi); 1499 saa7134_pgtable_free(dev->pci,&fh->pt_vbi);
1506 1500
1507 v4l2_prio_close(&dev->prio, fh->prio); 1501 v4l2_fh_del(&fh->fh);
1502 v4l2_fh_exit(&fh->fh);
1508 file->private_data = NULL; 1503 file->private_data = NULL;
1509 kfree(fh); 1504 kfree(fh);
1510 return 0; 1505 return 0;
@@ -1784,11 +1779,6 @@ static int saa7134_s_input(struct file *file, void *priv, unsigned int i)
1784{ 1779{
1785 struct saa7134_fh *fh = priv; 1780 struct saa7134_fh *fh = priv;
1786 struct saa7134_dev *dev = fh->dev; 1781 struct saa7134_dev *dev = fh->dev;
1787 int err;
1788
1789 err = v4l2_prio_check(&dev->prio, fh->prio);
1790 if (0 != err)
1791 return err;
1792 1782
1793 if (i >= SAA7134_INPUT_MAX) 1783 if (i >= SAA7134_INPUT_MAX)
1794 return -EINVAL; 1784 return -EINVAL;
@@ -1856,16 +1846,8 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
1856 unsigned long flags; 1846 unsigned long flags;
1857 unsigned int i; 1847 unsigned int i;
1858 v4l2_std_id fixup; 1848 v4l2_std_id fixup;
1859 int err;
1860 1849
1861 /* When called from the empress code fh == NULL. 1850 if (!fh && res_locked(dev, RESOURCE_OVERLAY)) {
1862 That needs to be fixed somehow, but for now this is
1863 good enough. */
1864 if (fh) {
1865 err = v4l2_prio_check(&dev->prio, fh->prio);
1866 if (0 != err)
1867 return err;
1868 } else if (res_locked(dev, RESOURCE_OVERLAY)) {
1869 /* Don't change the std from the mpeg device 1851 /* Don't change the std from the mpeg device
1870 if overlay is active. */ 1852 if overlay is active. */
1871 return -EBUSY; 1853 return -EBUSY;
@@ -2050,11 +2032,7 @@ static int saa7134_s_tuner(struct file *file, void *priv,
2050{ 2032{
2051 struct saa7134_fh *fh = priv; 2033 struct saa7134_fh *fh = priv;
2052 struct saa7134_dev *dev = fh->dev; 2034 struct saa7134_dev *dev = fh->dev;
2053 int rx, mode, err; 2035 int rx, mode;
2054
2055 err = v4l2_prio_check(&dev->prio, fh->prio);
2056 if (0 != err)
2057 return err;
2058 2036
2059 mode = dev->thread.mode; 2037 mode = dev->thread.mode;
2060 if (UNSET == mode) { 2038 if (UNSET == mode) {
@@ -2084,11 +2062,6 @@ static int saa7134_s_frequency(struct file *file, void *priv,
2084{ 2062{
2085 struct saa7134_fh *fh = priv; 2063 struct saa7134_fh *fh = priv;
2086 struct saa7134_dev *dev = fh->dev; 2064 struct saa7134_dev *dev = fh->dev;
2087 int err;
2088
2089 err = v4l2_prio_check(&dev->prio, fh->prio);
2090 if (0 != err)
2091 return err;
2092 2065
2093 if (0 != f->tuner) 2066 if (0 != f->tuner)
2094 return -EINVAL; 2067 return -EINVAL;
@@ -2117,24 +2090,6 @@ static int saa7134_s_audio(struct file *file, void *priv, const struct v4l2_audi
2117 return 0; 2090 return 0;
2118} 2091}
2119 2092
2120static int saa7134_g_priority(struct file *file, void *f, enum v4l2_priority *p)
2121{
2122 struct saa7134_fh *fh = f;
2123 struct saa7134_dev *dev = fh->dev;
2124
2125 *p = v4l2_prio_max(&dev->prio);
2126 return 0;
2127}
2128
2129static int saa7134_s_priority(struct file *file, void *f,
2130 enum v4l2_priority prio)
2131{
2132 struct saa7134_fh *fh = f;
2133 struct saa7134_dev *dev = fh->dev;
2134
2135 return v4l2_prio_change(&dev->prio, &fh->prio, prio);
2136}
2137
2138static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv, 2093static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv,
2139 struct v4l2_fmtdesc *f) 2094 struct v4l2_fmtdesc *f)
2140{ 2095{
@@ -2476,8 +2431,6 @@ static const struct v4l2_ioctl_ops video_ioctl_ops = {
2476 .vidioc_g_fbuf = saa7134_g_fbuf, 2431 .vidioc_g_fbuf = saa7134_g_fbuf,
2477 .vidioc_s_fbuf = saa7134_s_fbuf, 2432 .vidioc_s_fbuf = saa7134_s_fbuf,
2478 .vidioc_overlay = saa7134_overlay, 2433 .vidioc_overlay = saa7134_overlay,
2479 .vidioc_g_priority = saa7134_g_priority,
2480 .vidioc_s_priority = saa7134_s_priority,
2481 .vidioc_g_parm = saa7134_g_parm, 2434 .vidioc_g_parm = saa7134_g_parm,
2482 .vidioc_g_frequency = saa7134_g_frequency, 2435 .vidioc_g_frequency = saa7134_g_frequency,
2483 .vidioc_s_frequency = saa7134_s_frequency, 2436 .vidioc_s_frequency = saa7134_s_frequency,
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index 1f6c41ed2a07..fc07b19ed536 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -36,6 +36,7 @@
36#include <media/v4l2-common.h> 36#include <media/v4l2-common.h>
37#include <media/v4l2-ioctl.h> 37#include <media/v4l2-ioctl.h>
38#include <media/v4l2-device.h> 38#include <media/v4l2-device.h>
39#include <media/v4l2-fh.h>
39#include <media/tuner.h> 40#include <media/tuner.h>
40#include <media/rc-core.h> 41#include <media/rc-core.h>
41#include <media/ir-kbd-i2c.h> 42#include <media/ir-kbd-i2c.h>
@@ -468,11 +469,11 @@ struct saa7134_dmaqueue {
468 469
469/* video filehandle status */ 470/* video filehandle status */
470struct saa7134_fh { 471struct saa7134_fh {
472 struct v4l2_fh fh;
471 struct saa7134_dev *dev; 473 struct saa7134_dev *dev;
472 unsigned int radio; 474 unsigned int radio;
473 enum v4l2_buf_type type; 475 enum v4l2_buf_type type;
474 unsigned int resources; 476 unsigned int resources;
475 enum v4l2_priority prio;
476 struct pm_qos_request qos_request; 477 struct pm_qos_request qos_request;
477 478
478 /* video overlay */ 479 /* video overlay */
@@ -544,7 +545,6 @@ struct saa7134_dev {
544 struct list_head devlist; 545 struct list_head devlist;
545 struct mutex lock; 546 struct mutex lock;
546 spinlock_t slock; 547 spinlock_t slock;
547 struct v4l2_prio_state prio;
548 struct v4l2_device v4l2_dev; 548 struct v4l2_device v4l2_dev;
549 /* workstruct for loading modules */ 549 /* workstruct for loading modules */
550 struct work_struct request_module_wk; 550 struct work_struct request_module_wk;