aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-12-14 06:28:25 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-01-07 04:18:41 -0500
commitb93a18d56057a6f8ccb79c5cd085dd31395331ff (patch)
tree20e898daee44d2a0f1db3ba50a606db850c932a8
parent718bde1aa9e03fd49d69816c4facea55d69a4737 (diff)
[media] saa7134: cleanup radio/video/empress ioctl handling
The video and empress nodes can share various ioctls. Drop the input/std ioctls from the radio node (out of spec). 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/saa7134/saa7134-empress.c79
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c108
-rw-r--r--drivers/media/pci/saa7134/saa7134.h16
3 files changed, 61 insertions, 142 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c
index 7c24f44c98bd..8617757604b1 100644
--- a/drivers/media/pci/saa7134/saa7134-empress.c
+++ b/drivers/media/pci/saa7134/saa7134-empress.c
@@ -156,54 +156,6 @@ ts_mmap(struct file *file, struct vm_area_struct * vma)
156 return videobuf_mmap_mapper(&dev->empress_tsq, vma); 156 return videobuf_mmap_mapper(&dev->empress_tsq, vma);
157} 157}
158 158
159/*
160 * This function is _not_ called directly, but from
161 * video_generic_ioctl (and maybe others). userspace
162 * copying is done already, arg is a kernel pointer.
163 */
164
165static int empress_querycap(struct file *file, void *priv,
166 struct v4l2_capability *cap)
167{
168 struct saa7134_dev *dev = file->private_data;
169
170 strcpy(cap->driver, "saa7134");
171 strlcpy(cap->card, saa7134_boards[dev->board].name,
172 sizeof(cap->card));
173 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
174 cap->capabilities =
175 V4L2_CAP_VIDEO_CAPTURE |
176 V4L2_CAP_READWRITE |
177 V4L2_CAP_STREAMING;
178 return 0;
179}
180
181static int empress_enum_input(struct file *file, void *priv,
182 struct v4l2_input *i)
183{
184 if (i->index != 0)
185 return -EINVAL;
186
187 i->type = V4L2_INPUT_TYPE_CAMERA;
188 strcpy(i->name, "CCIR656");
189
190 return 0;
191}
192
193static int empress_g_input(struct file *file, void *priv, unsigned int *i)
194{
195 *i = 0;
196 return 0;
197}
198
199static int empress_s_input(struct file *file, void *priv, unsigned int i)
200{
201 if (i != 0)
202 return -EINVAL;
203
204 return 0;
205}
206
207static int empress_enum_fmt_vid_cap(struct file *file, void *priv, 159static int empress_enum_fmt_vid_cap(struct file *file, void *priv,
208 struct v4l2_fmtdesc *f) 160 struct v4l2_fmtdesc *f)
209{ 161{
@@ -316,21 +268,6 @@ static int empress_streamoff(struct file *file, void *priv,
316 return videobuf_streamoff(&dev->empress_tsq); 268 return videobuf_streamoff(&dev->empress_tsq);
317} 269}
318 270
319static int empress_s_std(struct file *file, void *priv, v4l2_std_id id)
320{
321 struct saa7134_dev *dev = file->private_data;
322
323 return saa7134_s_std_internal(dev, NULL, id);
324}
325
326static int empress_g_std(struct file *file, void *priv, v4l2_std_id *id)
327{
328 struct saa7134_dev *dev = file->private_data;
329
330 *id = dev->tvnorm->id;
331 return 0;
332}
333
334static const struct v4l2_file_operations ts_fops = 271static const struct v4l2_file_operations ts_fops =
335{ 272{
336 .owner = THIS_MODULE, 273 .owner = THIS_MODULE,
@@ -343,7 +280,7 @@ static const struct v4l2_file_operations ts_fops =
343}; 280};
344 281
345static const struct v4l2_ioctl_ops ts_ioctl_ops = { 282static const struct v4l2_ioctl_ops ts_ioctl_ops = {
346 .vidioc_querycap = empress_querycap, 283 .vidioc_querycap = saa7134_querycap,
347 .vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap, 284 .vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap,
348 .vidioc_try_fmt_vid_cap = empress_try_fmt_vid_cap, 285 .vidioc_try_fmt_vid_cap = empress_try_fmt_vid_cap,
349 .vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap, 286 .vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap,
@@ -354,11 +291,15 @@ static const struct v4l2_ioctl_ops ts_ioctl_ops = {
354 .vidioc_dqbuf = empress_dqbuf, 291 .vidioc_dqbuf = empress_dqbuf,
355 .vidioc_streamon = empress_streamon, 292 .vidioc_streamon = empress_streamon,
356 .vidioc_streamoff = empress_streamoff, 293 .vidioc_streamoff = empress_streamoff,
357 .vidioc_enum_input = empress_enum_input, 294 .vidioc_g_frequency = saa7134_g_frequency,
358 .vidioc_g_input = empress_g_input, 295 .vidioc_s_frequency = saa7134_s_frequency,
359 .vidioc_s_input = empress_s_input, 296 .vidioc_g_tuner = saa7134_g_tuner,
360 .vidioc_s_std = empress_s_std, 297 .vidioc_s_tuner = saa7134_s_tuner,
361 .vidioc_g_std = empress_g_std, 298 .vidioc_enum_input = saa7134_enum_input,
299 .vidioc_g_input = saa7134_g_input,
300 .vidioc_s_input = saa7134_s_input,
301 .vidioc_s_std = saa7134_s_std,
302 .vidioc_g_std = saa7134_g_std,
362}; 303};
363 304
364/* ----------------------------------------------------------- */ 305/* ----------------------------------------------------------- */
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index 7a52259b803d..4f85662cec9b 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1512,11 +1512,9 @@ static int saa7134_s_fmt_vid_overlay(struct file *file, void *priv,
1512 return 0; 1512 return 0;
1513} 1513}
1514 1514
1515static int saa7134_enum_input(struct file *file, void *priv, 1515int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i)
1516 struct v4l2_input *i)
1517{ 1516{
1518 struct saa7134_fh *fh = priv; 1517 struct saa7134_dev *dev = video_drvdata(file);
1519 struct saa7134_dev *dev = fh->dev;
1520 unsigned int n; 1518 unsigned int n;
1521 1519
1522 n = i->index; 1520 n = i->index;
@@ -1543,20 +1541,20 @@ static int saa7134_enum_input(struct file *file, void *priv,
1543 i->std = SAA7134_NORMS; 1541 i->std = SAA7134_NORMS;
1544 return 0; 1542 return 0;
1545} 1543}
1544EXPORT_SYMBOL_GPL(saa7134_enum_input);
1546 1545
1547static int saa7134_g_input(struct file *file, void *priv, unsigned int *i) 1546int saa7134_g_input(struct file *file, void *priv, unsigned int *i)
1548{ 1547{
1549 struct saa7134_fh *fh = priv; 1548 struct saa7134_dev *dev = video_drvdata(file);
1550 struct saa7134_dev *dev = fh->dev;
1551 1549
1552 *i = dev->ctl_input; 1550 *i = dev->ctl_input;
1553 return 0; 1551 return 0;
1554} 1552}
1553EXPORT_SYMBOL_GPL(saa7134_g_input);
1555 1554
1556static int saa7134_s_input(struct file *file, void *priv, unsigned int i) 1555int saa7134_s_input(struct file *file, void *priv, unsigned int i)
1557{ 1556{
1558 struct saa7134_fh *fh = priv; 1557 struct saa7134_dev *dev = video_drvdata(file);
1559 struct saa7134_dev *dev = fh->dev;
1560 1558
1561 if (i >= SAA7134_INPUT_MAX) 1559 if (i >= SAA7134_INPUT_MAX)
1562 return -EINVAL; 1560 return -EINVAL;
@@ -1567,12 +1565,12 @@ static int saa7134_s_input(struct file *file, void *priv, unsigned int i)
1567 mutex_unlock(&dev->lock); 1565 mutex_unlock(&dev->lock);
1568 return 0; 1566 return 0;
1569} 1567}
1568EXPORT_SYMBOL_GPL(saa7134_s_input);
1570 1569
1571static int saa7134_querycap(struct file *file, void *priv, 1570int saa7134_querycap(struct file *file, void *priv,
1572 struct v4l2_capability *cap) 1571 struct v4l2_capability *cap)
1573{ 1572{
1574 struct saa7134_fh *fh = priv; 1573 struct saa7134_dev *dev = video_drvdata(file);
1575 struct saa7134_dev *dev = fh->dev;
1576 struct video_device *vdev = video_devdata(file); 1574 struct video_device *vdev = video_devdata(file);
1577 u32 radio_caps, video_caps, vbi_caps; 1575 u32 radio_caps, video_caps, vbi_caps;
1578 1576
@@ -1592,7 +1590,8 @@ static int saa7134_querycap(struct file *file, void *priv,
1592 radio_caps |= V4L2_CAP_RDS_CAPTURE; 1590 radio_caps |= V4L2_CAP_RDS_CAPTURE;
1593 1591
1594 video_caps = V4L2_CAP_VIDEO_CAPTURE; 1592 video_caps = V4L2_CAP_VIDEO_CAPTURE;
1595 if (saa7134_no_overlay <= 0) 1593 /* For the empress video node priv == dev */
1594 if (saa7134_no_overlay <= 0 && priv != dev)
1596 video_caps |= V4L2_CAP_VIDEO_OVERLAY; 1595 video_caps |= V4L2_CAP_VIDEO_OVERLAY;
1597 1596
1598 vbi_caps = V4L2_CAP_VBI_CAPTURE; 1597 vbi_caps = V4L2_CAP_VBI_CAPTURE;
@@ -1618,14 +1617,18 @@ static int saa7134_querycap(struct file *file, void *priv,
1618 1617
1619 return 0; 1618 return 0;
1620} 1619}
1620EXPORT_SYMBOL_GPL(saa7134_querycap);
1621 1621
1622int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_std_id id) 1622int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id)
1623{ 1623{
1624 struct saa7134_dev *dev = video_drvdata(file);
1625 /* For the empress video node priv == dev */
1626 bool is_empress = priv == dev;
1624 unsigned long flags; 1627 unsigned long flags;
1625 unsigned int i; 1628 unsigned int i;
1626 v4l2_std_id fixup; 1629 v4l2_std_id fixup;
1627 1630
1628 if (!fh && res_locked(dev, RESOURCE_OVERLAY)) { 1631 if (is_empress && res_locked(dev, RESOURCE_OVERLAY)) {
1629 /* Don't change the std from the mpeg device 1632 /* Don't change the std from the mpeg device
1630 if overlay is active. */ 1633 if overlay is active. */
1631 return -EBUSY; 1634 return -EBUSY;
@@ -1665,7 +1668,7 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
1665 id = tvnorms[i].id; 1668 id = tvnorms[i].id;
1666 1669
1667 mutex_lock(&dev->lock); 1670 mutex_lock(&dev->lock);
1668 if (fh && res_check(fh, RESOURCE_OVERLAY)) { 1671 if (!is_empress && res_check(priv, RESOURCE_OVERLAY)) {
1669 spin_lock_irqsave(&dev->slock, flags); 1672 spin_lock_irqsave(&dev->slock, flags);
1670 stop_preview(dev); 1673 stop_preview(dev);
1671 spin_unlock_irqrestore(&dev->slock, flags); 1674 spin_unlock_irqrestore(&dev->slock, flags);
@@ -1682,23 +1685,16 @@ int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_
1682 mutex_unlock(&dev->lock); 1685 mutex_unlock(&dev->lock);
1683 return 0; 1686 return 0;
1684} 1687}
1685EXPORT_SYMBOL_GPL(saa7134_s_std_internal); 1688EXPORT_SYMBOL_GPL(saa7134_s_std);
1686 1689
1687static int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id) 1690int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id)
1688{ 1691{
1689 struct saa7134_fh *fh = priv; 1692 struct saa7134_dev *dev = video_drvdata(file);
1690
1691 return saa7134_s_std_internal(fh->dev, fh, id);
1692}
1693
1694static int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id)
1695{
1696 struct saa7134_fh *fh = priv;
1697 struct saa7134_dev *dev = fh->dev;
1698 1693
1699 *id = dev->tvnorm->id; 1694 *id = dev->tvnorm->id;
1700 return 0; 1695 return 0;
1701} 1696}
1697EXPORT_SYMBOL_GPL(saa7134_g_std);
1702 1698
1703static int saa7134_cropcap(struct file *file, void *priv, 1699static int saa7134_cropcap(struct file *file, void *priv,
1704 struct v4l2_cropcap *cap) 1700 struct v4l2_cropcap *cap)
@@ -1773,11 +1769,10 @@ static int saa7134_s_crop(struct file *file, void *f, const struct v4l2_crop *cr
1773 return 0; 1769 return 0;
1774} 1770}
1775 1771
1776static int saa7134_g_tuner(struct file *file, void *priv, 1772int saa7134_g_tuner(struct file *file, void *priv,
1777 struct v4l2_tuner *t) 1773 struct v4l2_tuner *t)
1778{ 1774{
1779 struct saa7134_fh *fh = priv; 1775 struct saa7134_dev *dev = video_drvdata(file);
1780 struct saa7134_dev *dev = fh->dev;
1781 int n; 1776 int n;
1782 1777
1783 if (0 != t->index) 1778 if (0 != t->index)
@@ -1804,12 +1799,12 @@ static int saa7134_g_tuner(struct file *file, void *priv,
1804 t->signal = 0xffff; 1799 t->signal = 0xffff;
1805 return 0; 1800 return 0;
1806} 1801}
1802EXPORT_SYMBOL_GPL(saa7134_g_tuner);
1807 1803
1808static int saa7134_s_tuner(struct file *file, void *priv, 1804int saa7134_s_tuner(struct file *file, void *priv,
1809 const struct v4l2_tuner *t) 1805 const struct v4l2_tuner *t)
1810{ 1806{
1811 struct saa7134_fh *fh = priv; 1807 struct saa7134_dev *dev = video_drvdata(file);
1812 struct saa7134_dev *dev = fh->dev;
1813 int rx, mode; 1808 int rx, mode;
1814 1809
1815 if (0 != t->index) 1810 if (0 != t->index)
@@ -1825,12 +1820,12 @@ static int saa7134_s_tuner(struct file *file, void *priv,
1825 1820
1826 return 0; 1821 return 0;
1827} 1822}
1823EXPORT_SYMBOL_GPL(saa7134_s_tuner);
1828 1824
1829static int saa7134_g_frequency(struct file *file, void *priv, 1825int saa7134_g_frequency(struct file *file, void *priv,
1830 struct v4l2_frequency *f) 1826 struct v4l2_frequency *f)
1831{ 1827{
1832 struct saa7134_fh *fh = priv; 1828 struct saa7134_dev *dev = video_drvdata(file);
1833 struct saa7134_dev *dev = fh->dev;
1834 1829
1835 if (0 != f->tuner) 1830 if (0 != f->tuner)
1836 return -EINVAL; 1831 return -EINVAL;
@@ -1839,12 +1834,12 @@ static int saa7134_g_frequency(struct file *file, void *priv,
1839 1834
1840 return 0; 1835 return 0;
1841} 1836}
1837EXPORT_SYMBOL_GPL(saa7134_g_frequency);
1842 1838
1843static int saa7134_s_frequency(struct file *file, void *priv, 1839int saa7134_s_frequency(struct file *file, void *priv,
1844 const struct v4l2_frequency *f) 1840 const struct v4l2_frequency *f)
1845{ 1841{
1846 struct saa7134_fh *fh = priv; 1842 struct saa7134_dev *dev = video_drvdata(file);
1847 struct saa7134_dev *dev = fh->dev;
1848 1843
1849 if (0 != f->tuner) 1844 if (0 != f->tuner)
1850 return -EINVAL; 1845 return -EINVAL;
@@ -1856,6 +1851,7 @@ static int saa7134_s_frequency(struct file *file, void *priv,
1856 mutex_unlock(&dev->lock); 1851 mutex_unlock(&dev->lock);
1857 return 0; 1852 return 0;
1858} 1853}
1854EXPORT_SYMBOL_GPL(saa7134_s_frequency);
1859 1855
1860static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv, 1856static int saa7134_enum_fmt_vid_cap(struct file *file, void *priv,
1861 struct v4l2_fmtdesc *f) 1857 struct v4l2_fmtdesc *f)
@@ -2076,34 +2072,6 @@ static int radio_s_tuner(struct file *file, void *priv,
2076 return 0; 2072 return 0;
2077} 2073}
2078 2074
2079static int radio_enum_input(struct file *file, void *priv,
2080 struct v4l2_input *i)
2081{
2082 if (i->index != 0)
2083 return -EINVAL;
2084
2085 strcpy(i->name, "Radio");
2086 i->type = V4L2_INPUT_TYPE_TUNER;
2087
2088 return 0;
2089}
2090
2091static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
2092{
2093 *i = 0;
2094 return 0;
2095}
2096
2097static int radio_s_input(struct file *filp, void *priv, unsigned int i)
2098{
2099 return 0;
2100}
2101
2102static int radio_s_std(struct file *file, void *fh, v4l2_std_id norm)
2103{
2104 return 0;
2105}
2106
2107static const struct v4l2_file_operations video_fops = 2075static const struct v4l2_file_operations video_fops =
2108{ 2076{
2109 .owner = THIS_MODULE, 2077 .owner = THIS_MODULE,
@@ -2167,11 +2135,7 @@ static const struct v4l2_file_operations radio_fops = {
2167static const struct v4l2_ioctl_ops radio_ioctl_ops = { 2135static const struct v4l2_ioctl_ops radio_ioctl_ops = {
2168 .vidioc_querycap = saa7134_querycap, 2136 .vidioc_querycap = saa7134_querycap,
2169 .vidioc_g_tuner = radio_g_tuner, 2137 .vidioc_g_tuner = radio_g_tuner,
2170 .vidioc_enum_input = radio_enum_input,
2171 .vidioc_s_tuner = radio_s_tuner, 2138 .vidioc_s_tuner = radio_s_tuner,
2172 .vidioc_s_input = radio_s_input,
2173 .vidioc_s_std = radio_s_std,
2174 .vidioc_g_input = radio_g_input,
2175 .vidioc_g_frequency = saa7134_g_frequency, 2139 .vidioc_g_frequency = saa7134_g_frequency,
2176 .vidioc_s_frequency = saa7134_s_frequency, 2140 .vidioc_s_frequency = saa7134_s_frequency,
2177}; 2141};
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index e0e5c70fb660..3573aa2f258f 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -767,7 +767,21 @@ extern unsigned int video_debug;
767extern struct video_device saa7134_video_template; 767extern struct video_device saa7134_video_template;
768extern struct video_device saa7134_radio_template; 768extern struct video_device saa7134_radio_template;
769 769
770int saa7134_s_std_internal(struct saa7134_dev *dev, struct saa7134_fh *fh, v4l2_std_id id); 770int saa7134_s_std(struct file *file, void *priv, v4l2_std_id id);
771int saa7134_g_std(struct file *file, void *priv, v4l2_std_id *id);
772int saa7134_enum_input(struct file *file, void *priv, struct v4l2_input *i);
773int saa7134_g_input(struct file *file, void *priv, unsigned int *i);
774int saa7134_s_input(struct file *file, void *priv, unsigned int i);
775int saa7134_querycap(struct file *file, void *priv,
776 struct v4l2_capability *cap);
777int saa7134_g_tuner(struct file *file, void *priv,
778 struct v4l2_tuner *t);
779int saa7134_s_tuner(struct file *file, void *priv,
780 const struct v4l2_tuner *t);
781int saa7134_g_frequency(struct file *file, void *priv,
782 struct v4l2_frequency *f);
783int saa7134_s_frequency(struct file *file, void *priv,
784 const struct v4l2_frequency *f);
771 785
772int saa7134_videoport_init(struct saa7134_dev *dev); 786int saa7134_videoport_init(struct saa7134_dev *dev);
773void saa7134_set_tvnorm_hw(struct saa7134_dev *dev); 787void saa7134_set_tvnorm_hw(struct saa7134_dev *dev);