aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/saa7134/saa7134-video.c348
1 files changed, 174 insertions, 174 deletions
diff --git a/drivers/media/video/saa7134/saa7134-video.c b/drivers/media/video/saa7134/saa7134-video.c
index 954542e5c99f..76b841dd7ec0 100644
--- a/drivers/media/video/saa7134/saa7134-video.c
+++ b/drivers/media/video/saa7134/saa7134-video.c
@@ -1670,30 +1670,6 @@ static int vidioc_s_fmt_cap(struct file *file, void *priv,
1670 } 1670 }
1671} 1671}
1672 1672
1673static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1674{
1675 struct saa7134_fh *fh = priv;
1676 struct saa7134_dev *dev = fh->dev;
1677
1678 *i = dev->ctl_input;
1679 return 0;
1680}
1681
1682static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1683{
1684 struct saa7134_fh *fh = priv;
1685 struct saa7134_dev *dev = fh->dev;
1686
1687 if (i < 0 || i >= SAA7134_INPUT_MAX)
1688 return -EINVAL;
1689 if (NULL == card_in(dev, i).name)
1690 return -EINVAL;
1691 mutex_lock(&dev->lock);
1692 video_mux(dev, i);
1693 mutex_unlock(&dev->lock);
1694 return 0;
1695}
1696
1697static int vidioc_queryctrl(struct file *file, void *priv, 1673static int vidioc_queryctrl(struct file *file, void *priv,
1698 struct v4l2_queryctrl *c) 1674 struct v4l2_queryctrl *c)
1699{ 1675{
@@ -1744,6 +1720,30 @@ static int vidioc_enum_input(struct file *file, void *priv,
1744 return 0; 1720 return 0;
1745} 1721}
1746 1722
1723static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1724{
1725 struct saa7134_fh *fh = priv;
1726 struct saa7134_dev *dev = fh->dev;
1727
1728 *i = dev->ctl_input;
1729 return 0;
1730}
1731
1732static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1733{
1734 struct saa7134_fh *fh = priv;
1735 struct saa7134_dev *dev = fh->dev;
1736
1737 if (i < 0 || i >= SAA7134_INPUT_MAX)
1738 return -EINVAL;
1739 if (NULL == card_in(dev, i).name)
1740 return -EINVAL;
1741 mutex_lock(&dev->lock);
1742 video_mux(dev, i);
1743 mutex_unlock(&dev->lock);
1744 return 0;
1745}
1746
1747static int vidioc_querycap(struct file *file, void *priv, 1747static int vidioc_querycap(struct file *file, void *priv,
1748 struct v4l2_capability *cap) 1748 struct v4l2_capability *cap)
1749{ 1749{
@@ -1847,6 +1847,55 @@ static int vidioc_cropcap(struct file *file, void *priv,
1847 return 0; 1847 return 0;
1848} 1848}
1849 1849
1850static int vidioc_g_crop(struct file *file, void *f, struct v4l2_crop *crop)
1851{
1852 struct saa7134_fh *fh = f;
1853 struct saa7134_dev *dev = fh->dev;
1854
1855 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1856 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
1857 return -EINVAL;
1858 crop->c = dev->crop_current;
1859 return 0;
1860}
1861
1862static int vidioc_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
1863{
1864 struct saa7134_fh *fh = f;
1865 struct saa7134_dev *dev = fh->dev;
1866 struct v4l2_rect *b = &dev->crop_bounds;
1867
1868 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1869 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
1870 return -EINVAL;
1871 if (crop->c.height < 0)
1872 return -EINVAL;
1873 if (crop->c.width < 0)
1874 return -EINVAL;
1875
1876 if (res_locked(fh->dev, RESOURCE_OVERLAY))
1877 return -EBUSY;
1878 if (res_locked(fh->dev, RESOURCE_VIDEO))
1879 return -EBUSY;
1880
1881 if (crop->c.top < b->top)
1882 crop->c.top = b->top;
1883 if (crop->c.top > b->top + b->height)
1884 crop->c.top = b->top + b->height;
1885 if (crop->c.height > b->top - crop->c.top + b->height)
1886 crop->c.height = b->top - crop->c.top + b->height;
1887
1888 if (crop->c.left < b->left)
1889 crop->c.left = b->left;
1890 if (crop->c.left > b->left + b->width)
1891 crop->c.left = b->left + b->width;
1892 if (crop->c.width > b->left - crop->c.left + b->width)
1893 crop->c.width = b->left - crop->c.left + b->width;
1894
1895 dev->crop_current = crop->c;
1896 return 0;
1897}
1898
1850static int vidioc_g_tuner(struct file *file, void *priv, 1899static int vidioc_g_tuner(struct file *file, void *priv,
1851 struct v4l2_tuner *t) 1900 struct v4l2_tuner *t)
1852{ 1901{
@@ -1939,113 +1988,64 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
1939 return 0; 1988 return 0;
1940} 1989}
1941 1990
1942static int vidioc_streamon(struct file *file, void *priv, 1991static int vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p)
1943 enum v4l2_buf_type type)
1944{
1945 struct saa7134_fh *fh = priv;
1946 struct saa7134_dev *dev = fh->dev;
1947 int res = saa7134_resource(fh);
1948
1949 if (!res_get(dev, fh, res))
1950 return -EBUSY;
1951
1952 return videobuf_streamon(saa7134_queue(fh));
1953}
1954
1955static int vidioc_streamoff(struct file *file, void *priv,
1956 enum v4l2_buf_type type)
1957{
1958 int err;
1959 struct saa7134_fh *fh = priv;
1960 struct saa7134_dev *dev = fh->dev;
1961 int res = saa7134_resource(fh);
1962
1963 err = videobuf_streamoff(saa7134_queue(fh));
1964 if (err < 0)
1965 return err;
1966 res_free(dev, fh, res);
1967 return 0;
1968}
1969
1970static int vidioc_reqbufs(struct file *file, void *priv,
1971 struct v4l2_requestbuffers *p)
1972{
1973 struct saa7134_fh *fh = priv;
1974 return videobuf_reqbufs(saa7134_queue(fh), p);
1975}
1976
1977static int vidioc_s_crop(struct file *file, void *f, struct v4l2_crop *crop)
1978{ 1992{
1979 struct saa7134_fh *fh = f; 1993 struct saa7134_fh *fh = f;
1980 struct saa7134_dev *dev = fh->dev; 1994 struct saa7134_dev *dev = fh->dev;
1981 struct v4l2_rect *b = &dev->crop_bounds;
1982
1983 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE &&
1984 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
1985 return -EINVAL;
1986 if (crop->c.height < 0)
1987 return -EINVAL;
1988 if (crop->c.width < 0)
1989 return -EINVAL;
1990
1991 if (res_locked(fh->dev, RESOURCE_OVERLAY))
1992 return -EBUSY;
1993 if (res_locked(fh->dev, RESOURCE_VIDEO))
1994 return -EBUSY;
1995 1995
1996 if (crop->c.top < b->top) 1996 *p = v4l2_prio_max(&dev->prio);
1997 crop->c.top = b->top;
1998 if (crop->c.top > b->top + b->height)
1999 crop->c.top = b->top + b->height;
2000 if (crop->c.height > b->top - crop->c.top + b->height)
2001 crop->c.height = b->top - crop->c.top + b->height;
2002
2003 if (crop->c.left < b->left)
2004 crop->c.left = b->left;
2005 if (crop->c.left > b->left + b->width)
2006 crop->c.left = b->left + b->width;
2007 if (crop->c.width > b->left - crop->c.left + b->width)
2008 crop->c.width = b->left - crop->c.left + b->width;
2009
2010 dev->crop_current = crop->c;
2011 return 0; 1997 return 0;
2012} 1998}
2013 1999
2014static int vidioc_g_crop(struct file *file, void *f, struct v4l2_crop *crop) 2000static int vidioc_s_priority(struct file *file, void *f,
2001 enum v4l2_priority prio)
2015{ 2002{
2016 struct saa7134_fh *fh = f; 2003 struct saa7134_fh *fh = f;
2017 struct saa7134_dev *dev = fh->dev; 2004 struct saa7134_dev *dev = fh->dev;
2018 2005
2019 if (crop->type != V4L2_BUF_TYPE_VIDEO_CAPTURE && 2006 return v4l2_prio_change(&dev->prio, &fh->prio, prio);
2020 crop->type != V4L2_BUF_TYPE_VIDEO_OVERLAY)
2021 return -EINVAL;
2022 crop->c = dev->crop_current;
2023 return 0;
2024}
2025
2026static int vidioc_g_parm(struct file *file, void *fh,
2027 struct v4l2_streamparm *parm)
2028{
2029 memset(parm, 0, sizeof(*parm));
2030 return 0;
2031} 2007}
2032 2008
2033static int vidioc_g_priority(struct file *file, void *f, enum v4l2_priority *p) 2009static int vidioc_enum_fmt_cap(struct file *file, void *priv,
2010 struct v4l2_fmtdesc *f)
2034{ 2011{
2035 struct saa7134_fh *fh = f; 2012 enum v4l2_buf_type type;
2036 struct saa7134_dev *dev = fh->dev; 2013 unsigned int index;
2037 2014
2038 *p = v4l2_prio_max(&dev->prio); 2015 index = f->index;
2039 return 0; 2016 type = f->type;
2040} 2017 switch (type) {
2018 case V4L2_BUF_TYPE_VIDEO_CAPTURE:
2019 case V4L2_BUF_TYPE_VIDEO_OVERLAY:
2020 if (saa7134_no_overlay > 0)
2021 return -EINVAL;
2041 2022
2042static int vidioc_s_priority(struct file *file, void *f, 2023 if (index >= FORMATS)
2043 enum v4l2_priority prio) 2024 return -EINVAL;
2044{
2045 struct saa7134_fh *fh = f;
2046 struct saa7134_dev *dev = fh->dev;
2047 2025
2048 return v4l2_prio_change(&dev->prio, &fh->prio, prio); 2026 if (f->type == V4L2_BUF_TYPE_VIDEO_OVERLAY &&
2027 formats[index].planar)
2028 return -EINVAL;
2029 memset(f, 0, sizeof(*f));
2030 f->index = index;
2031 f->type = type;
2032 strlcpy(f->description, formats[index].name,
2033 sizeof(f->description));
2034 f->pixelformat = formats[index].fourcc;
2035 break;
2036 case V4L2_BUF_TYPE_VBI_CAPTURE:
2037 if (0 != index)
2038 return -EINVAL;
2039 memset(f, 0, sizeof(*f));
2040 f->index = index;
2041 f->type = type;
2042 f->pixelformat = V4L2_PIX_FMT_GREY;
2043 strcpy(f->description, "vbi data");
2044 break;
2045 default:
2046 return -EINVAL;
2047 }
2048 return 0;
2049} 2049}
2050 2050
2051static int vidioc_g_fbuf(struct file *file, void *f, 2051static int vidioc_g_fbuf(struct file *file, void *f,
@@ -2085,26 +2085,6 @@ static int vidioc_s_fbuf(struct file *file, void *f,
2085 return 0; 2085 return 0;
2086} 2086}
2087 2087
2088static int vidioc_querybuf(struct file *file, void *priv,
2089 struct v4l2_buffer *b)
2090{
2091 struct saa7134_fh *fh = priv;
2092 return videobuf_querybuf(saa7134_queue(fh), b);
2093}
2094
2095static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2096{
2097 struct saa7134_fh *fh = priv;
2098 return videobuf_qbuf(saa7134_queue(fh), b);
2099}
2100
2101static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2102{
2103 struct saa7134_fh *fh = priv;
2104 return videobuf_dqbuf(saa7134_queue(fh), b,
2105 file->f_flags & O_NONBLOCK);
2106}
2107
2108static int vidioc_overlay(struct file *file, void *f, unsigned int on) 2088static int vidioc_overlay(struct file *file, void *f, unsigned int on)
2109{ 2089{
2110 struct saa7134_fh *fh = f; 2090 struct saa7134_fh *fh = f;
@@ -2134,55 +2114,75 @@ static int vidioc_overlay(struct file *file, void *f, unsigned int on)
2134 return 0; 2114 return 0;
2135} 2115}
2136 2116
2137static int vidioc_enum_fmt_cap(struct file *file, void *priv, 2117#ifdef CONFIG_VIDEO_V4L1_COMPAT
2138 struct v4l2_fmtdesc *f) 2118static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf)
2139{ 2119{
2140 enum v4l2_buf_type type; 2120 struct saa7134_fh *fh = file->private_data;
2141 unsigned int index; 2121 return videobuf_cgmbuf(saa7134_queue(fh), mbuf, 8);
2122}
2123#endif
2142 2124
2143 index = f->index; 2125static int vidioc_reqbufs(struct file *file, void *priv,
2144 type = f->type; 2126 struct v4l2_requestbuffers *p)
2145 switch (type) { 2127{
2146 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 2128 struct saa7134_fh *fh = priv;
2147 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 2129 return videobuf_reqbufs(saa7134_queue(fh), p);
2148 if (saa7134_no_overlay > 0) 2130}
2149 return -EINVAL;
2150 2131
2151 if (index >= FORMATS) 2132static int vidioc_querybuf(struct file *file, void *priv,
2152 return -EINVAL; 2133 struct v4l2_buffer *b)
2134{
2135 struct saa7134_fh *fh = priv;
2136 return videobuf_querybuf(saa7134_queue(fh), b);
2137}
2153 2138
2154 if (f->type == V4L2_BUF_TYPE_VIDEO_OVERLAY && 2139static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2155 formats[index].planar) 2140{
2156 return -EINVAL; 2141 struct saa7134_fh *fh = priv;
2157 memset(f, 0, sizeof(*f)); 2142 return videobuf_qbuf(saa7134_queue(fh), b);
2158 f->index = index; 2143}
2159 f->type = type; 2144
2160 strlcpy(f->description, formats[index].name, 2145static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2161 sizeof(f->description)); 2146{
2162 f->pixelformat = formats[index].fourcc; 2147 struct saa7134_fh *fh = priv;
2163 break; 2148 return videobuf_dqbuf(saa7134_queue(fh), b,
2164 case V4L2_BUF_TYPE_VBI_CAPTURE: 2149 file->f_flags & O_NONBLOCK);
2165 if (0 != index) 2150}
2166 return -EINVAL; 2151
2167 memset(f, 0, sizeof(*f)); 2152static int vidioc_streamon(struct file *file, void *priv,
2168 f->index = index; 2153 enum v4l2_buf_type type)
2169 f->type = type; 2154{
2170 f->pixelformat = V4L2_PIX_FMT_GREY; 2155 struct saa7134_fh *fh = priv;
2171 strcpy(f->description, "vbi data"); 2156 struct saa7134_dev *dev = fh->dev;
2172 break; 2157 int res = saa7134_resource(fh);
2173 default: 2158
2174 return -EINVAL; 2159 if (!res_get(dev, fh, res))
2175 } 2160 return -EBUSY;
2161
2162 return videobuf_streamon(saa7134_queue(fh));
2163}
2164
2165static int vidioc_streamoff(struct file *file, void *priv,
2166 enum v4l2_buf_type type)
2167{
2168 int err;
2169 struct saa7134_fh *fh = priv;
2170 struct saa7134_dev *dev = fh->dev;
2171 int res = saa7134_resource(fh);
2172
2173 err = videobuf_streamoff(saa7134_queue(fh));
2174 if (err < 0)
2175 return err;
2176 res_free(dev, fh, res);
2176 return 0; 2177 return 0;
2177} 2178}
2178 2179
2179#ifdef CONFIG_VIDEO_V4L1_COMPAT 2180static int vidioc_g_parm(struct file *file, void *fh,
2180static int vidiocgmbuf(struct file *file, void *priv, struct video_mbuf *mbuf) 2181 struct v4l2_streamparm *parm)
2181{ 2182{
2182 struct saa7134_fh *fh = file->private_data; 2183 memset(parm, 0, sizeof(*parm));
2183 return videobuf_cgmbuf(saa7134_queue(fh), mbuf, 8); 2184 return 0;
2184} 2185}
2185#endif
2186 2186
2187static int radio_querycap(struct file *file, void *priv, 2187static int radio_querycap(struct file *file, void *priv,
2188 struct v4l2_capability *cap) 2188 struct v4l2_capability *cap)