aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-05-31 06:57:10 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-06-17 09:07:21 -0400
commit8fcd4769de1528cd058590b17d783050a53819da (patch)
treee1a12c019ab631b24d30d998578d9f1a33fce36a /drivers/media/pci
parent8460d519bc5a7145166f8954f08dde5ee75db85a (diff)
[media] saa7134: remove radio/type field from saa7134_fh
This information is already available in vfl_type in video_device. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/saa7134/saa7134-video.c89
-rw-r--r--drivers/media/pci/saa7134/saa7134.h2
2 files changed, 32 insertions, 59 deletions
diff --git a/drivers/media/pci/saa7134/saa7134-video.c b/drivers/media/pci/saa7134/saa7134-video.c
index b78d515068a7..aa1a73ed75a4 100644
--- a/drivers/media/pci/saa7134/saa7134-video.c
+++ b/drivers/media/pci/saa7134/saa7134-video.c
@@ -1287,15 +1287,17 @@ static int saa7134_s_ctrl(struct file *file, void *f, struct v4l2_control *c)
1287 1287
1288/* ------------------------------------------------------------------ */ 1288/* ------------------------------------------------------------------ */
1289 1289
1290static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh) 1290static struct videobuf_queue *saa7134_queue(struct file *file)
1291{ 1291{
1292 struct videobuf_queue* q = NULL; 1292 struct video_device *vdev = video_devdata(file);
1293 struct saa7134_fh *fh = file->private_data;
1294 struct videobuf_queue *q = NULL;
1293 1295
1294 switch (fh->type) { 1296 switch (vdev->vfl_type) {
1295 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1297 case VFL_TYPE_GRABBER:
1296 q = &fh->cap; 1298 q = &fh->cap;
1297 break; 1299 break;
1298 case V4L2_BUF_TYPE_VBI_CAPTURE: 1300 case VFL_TYPE_VBI:
1299 q = &fh->vbi; 1301 q = &fh->vbi;
1300 break; 1302 break;
1301 default: 1303 default:
@@ -1304,12 +1306,14 @@ static struct videobuf_queue* saa7134_queue(struct saa7134_fh *fh)
1304 return q; 1306 return q;
1305} 1307}
1306 1308
1307static int saa7134_resource(struct saa7134_fh *fh) 1309static int saa7134_resource(struct file *file)
1308{ 1310{
1309 if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) 1311 struct video_device *vdev = video_devdata(file);
1312
1313 if (vdev->vfl_type == VFL_TYPE_GRABBER)
1310 return RESOURCE_VIDEO; 1314 return RESOURCE_VIDEO;
1311 1315
1312 if (fh->type == V4L2_BUF_TYPE_VBI_CAPTURE) 1316 if (vdev->vfl_type == VFL_TYPE_VBI)
1313 return RESOURCE_VBI; 1317 return RESOURCE_VBI;
1314 1318
1315 BUG(); 1319 BUG();
@@ -1321,23 +1325,6 @@ static int video_open(struct file *file)
1321 struct video_device *vdev = video_devdata(file); 1325 struct video_device *vdev = video_devdata(file);
1322 struct saa7134_dev *dev = video_drvdata(file); 1326 struct saa7134_dev *dev = video_drvdata(file);
1323 struct saa7134_fh *fh; 1327 struct saa7134_fh *fh;
1324 enum v4l2_buf_type type = 0;
1325 int radio = 0;
1326
1327 switch (vdev->vfl_type) {
1328 case VFL_TYPE_GRABBER:
1329 type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1330 break;
1331 case VFL_TYPE_VBI:
1332 type = V4L2_BUF_TYPE_VBI_CAPTURE;
1333 break;
1334 case VFL_TYPE_RADIO:
1335 radio = 1;
1336 break;
1337 }
1338
1339 dprintk("open dev=%s radio=%d type=%s\n", video_device_node_name(vdev),
1340 radio, v4l2_type_names[type]);
1341 1328
1342 /* allocate + initialize per filehandle data */ 1329 /* allocate + initialize per filehandle data */
1343 fh = kzalloc(sizeof(*fh),GFP_KERNEL); 1330 fh = kzalloc(sizeof(*fh),GFP_KERNEL);
@@ -1347,8 +1334,6 @@ static int video_open(struct file *file)
1347 v4l2_fh_init(&fh->fh, vdev); 1334 v4l2_fh_init(&fh->fh, vdev);
1348 file->private_data = fh; 1335 file->private_data = fh;
1349 fh->dev = dev; 1336 fh->dev = dev;
1350 fh->radio = radio;
1351 fh->type = type;
1352 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 1337 fh->fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
1353 fh->width = 720; 1338 fh->width = 720;
1354 fh->height = 576; 1339 fh->height = 576;
@@ -1368,7 +1353,7 @@ static int video_open(struct file *file)
1368 saa7134_pgtable_alloc(dev->pci,&fh->pt_cap); 1353 saa7134_pgtable_alloc(dev->pci,&fh->pt_cap);
1369 saa7134_pgtable_alloc(dev->pci,&fh->pt_vbi); 1354 saa7134_pgtable_alloc(dev->pci,&fh->pt_vbi);
1370 1355
1371 if (fh->radio) { 1356 if (vdev->vfl_type == VFL_TYPE_RADIO) {
1372 /* switch to radio mode */ 1357 /* switch to radio mode */
1373 saa7134_tvaudio_setinput(dev,&card(dev).radio); 1358 saa7134_tvaudio_setinput(dev,&card(dev).radio);
1374 saa_call_all(dev, tuner, s_radio); 1359 saa_call_all(dev, tuner, s_radio);
@@ -1384,19 +1369,20 @@ static int video_open(struct file *file)
1384static ssize_t 1369static ssize_t
1385video_read(struct file *file, char __user *data, size_t count, loff_t *ppos) 1370video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1386{ 1371{
1372 struct video_device *vdev = video_devdata(file);
1387 struct saa7134_fh *fh = file->private_data; 1373 struct saa7134_fh *fh = file->private_data;
1388 1374
1389 switch (fh->type) { 1375 switch (vdev->vfl_type) {
1390 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1376 case VFL_TYPE_GRABBER:
1391 if (res_locked(fh->dev,RESOURCE_VIDEO)) 1377 if (res_locked(fh->dev,RESOURCE_VIDEO))
1392 return -EBUSY; 1378 return -EBUSY;
1393 return videobuf_read_one(saa7134_queue(fh), 1379 return videobuf_read_one(saa7134_queue(file),
1394 data, count, ppos, 1380 data, count, ppos,
1395 file->f_flags & O_NONBLOCK); 1381 file->f_flags & O_NONBLOCK);
1396 case V4L2_BUF_TYPE_VBI_CAPTURE: 1382 case VFL_TYPE_VBI:
1397 if (!res_get(fh->dev,fh,RESOURCE_VBI)) 1383 if (!res_get(fh->dev,fh,RESOURCE_VBI))
1398 return -EBUSY; 1384 return -EBUSY;
1399 return videobuf_read_stream(saa7134_queue(fh), 1385 return videobuf_read_stream(saa7134_queue(file),
1400 data, count, ppos, 1, 1386 data, count, ppos, 1,
1401 file->f_flags & O_NONBLOCK); 1387 file->f_flags & O_NONBLOCK);
1402 break; 1388 break;
@@ -1409,11 +1395,12 @@ video_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
1409static unsigned int 1395static unsigned int
1410video_poll(struct file *file, struct poll_table_struct *wait) 1396video_poll(struct file *file, struct poll_table_struct *wait)
1411{ 1397{
1398 struct video_device *vdev = video_devdata(file);
1412 struct saa7134_fh *fh = file->private_data; 1399 struct saa7134_fh *fh = file->private_data;
1413 struct videobuf_buffer *buf = NULL; 1400 struct videobuf_buffer *buf = NULL;
1414 unsigned int rc = 0; 1401 unsigned int rc = 0;
1415 1402
1416 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) 1403 if (vdev->vfl_type == VFL_TYPE_VBI)
1417 return videobuf_poll_stream(file, &fh->vbi, wait); 1404 return videobuf_poll_stream(file, &fh->vbi, wait);
1418 1405
1419 if (res_check(fh,RESOURCE_VIDEO)) { 1406 if (res_check(fh,RESOURCE_VIDEO)) {
@@ -1451,6 +1438,7 @@ err:
1451 1438
1452static int video_release(struct file *file) 1439static int video_release(struct file *file)
1453{ 1440{
1441 struct video_device *vdev = video_devdata(file);
1454 struct saa7134_fh *fh = file->private_data; 1442 struct saa7134_fh *fh = file->private_data;
1455 struct saa7134_dev *dev = fh->dev; 1443 struct saa7134_dev *dev = fh->dev;
1456 struct saa6588_command cmd; 1444 struct saa6588_command cmd;
@@ -1489,7 +1477,7 @@ static int video_release(struct file *file)
1489 saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0); 1477 saa_andorb(SAA7134_OFMT_DATA_B, 0x1f, 0);
1490 1478
1491 saa_call_all(dev, core, s_power, 0); 1479 saa_call_all(dev, core, s_power, 0);
1492 if (fh->radio) 1480 if (vdev->vfl_type == VFL_TYPE_RADIO)
1493 saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd); 1481 saa_call_all(dev, core, ioctl, SAA6588_CMD_CLOSE, &cmd);
1494 1482
1495 /* free stuff */ 1483 /* free stuff */
@@ -1507,9 +1495,7 @@ static int video_release(struct file *file)
1507 1495
1508static int video_mmap(struct file *file, struct vm_area_struct * vma) 1496static int video_mmap(struct file *file, struct vm_area_struct * vma)
1509{ 1497{
1510 struct saa7134_fh *fh = file->private_data; 1498 return videobuf_mmap_mapper(saa7134_queue(file), vma);
1511
1512 return videobuf_mmap_mapper(saa7134_queue(fh), vma);
1513} 1499}
1514 1500
1515static ssize_t radio_read(struct file *file, char __user *data, 1501static ssize_t radio_read(struct file *file, char __user *data,
@@ -2057,7 +2043,6 @@ static int saa7134_g_frequency(struct file *file, void *priv,
2057 if (0 != f->tuner) 2043 if (0 != f->tuner)
2058 return -EINVAL; 2044 return -EINVAL;
2059 2045
2060 f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
2061 saa_call_all(dev, tuner, g_frequency, f); 2046 saa_call_all(dev, tuner, g_frequency, f);
2062 2047
2063 return 0; 2048 return 0;
@@ -2071,10 +2056,6 @@ static int saa7134_s_frequency(struct file *file, void *priv,
2071 2056
2072 if (0 != f->tuner) 2057 if (0 != f->tuner)
2073 return -EINVAL; 2058 return -EINVAL;
2074 if (0 == fh->radio && V4L2_TUNER_ANALOG_TV != f->type)
2075 return -EINVAL;
2076 if (1 == fh->radio && V4L2_TUNER_RADIO != f->type)
2077 return -EINVAL;
2078 mutex_lock(&dev->lock); 2059 mutex_lock(&dev->lock);
2079 2060
2080 saa_call_all(dev, tuner, s_frequency, f); 2061 saa_call_all(dev, tuner, s_frequency, f);
@@ -2186,27 +2167,23 @@ static int saa7134_overlay(struct file *file, void *f, unsigned int on)
2186static int saa7134_reqbufs(struct file *file, void *priv, 2167static int saa7134_reqbufs(struct file *file, void *priv,
2187 struct v4l2_requestbuffers *p) 2168 struct v4l2_requestbuffers *p)
2188{ 2169{
2189 struct saa7134_fh *fh = priv; 2170 return videobuf_reqbufs(saa7134_queue(file), p);
2190 return videobuf_reqbufs(saa7134_queue(fh), p);
2191} 2171}
2192 2172
2193static int saa7134_querybuf(struct file *file, void *priv, 2173static int saa7134_querybuf(struct file *file, void *priv,
2194 struct v4l2_buffer *b) 2174 struct v4l2_buffer *b)
2195{ 2175{
2196 struct saa7134_fh *fh = priv; 2176 return videobuf_querybuf(saa7134_queue(file), b);
2197 return videobuf_querybuf(saa7134_queue(fh), b);
2198} 2177}
2199 2178
2200static int saa7134_qbuf(struct file *file, void *priv, struct v4l2_buffer *b) 2179static int saa7134_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2201{ 2180{
2202 struct saa7134_fh *fh = priv; 2181 return videobuf_qbuf(saa7134_queue(file), b);
2203 return videobuf_qbuf(saa7134_queue(fh), b);
2204} 2182}
2205 2183
2206static int saa7134_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b) 2184static int saa7134_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
2207{ 2185{
2208 struct saa7134_fh *fh = priv; 2186 return videobuf_dqbuf(saa7134_queue(file), b,
2209 return videobuf_dqbuf(saa7134_queue(fh), b,
2210 file->f_flags & O_NONBLOCK); 2187 file->f_flags & O_NONBLOCK);
2211} 2188}
2212 2189
@@ -2215,7 +2192,7 @@ static int saa7134_streamon(struct file *file, void *priv,
2215{ 2192{
2216 struct saa7134_fh *fh = priv; 2193 struct saa7134_fh *fh = priv;
2217 struct saa7134_dev *dev = fh->dev; 2194 struct saa7134_dev *dev = fh->dev;
2218 int res = saa7134_resource(fh); 2195 int res = saa7134_resource(file);
2219 2196
2220 if (!res_get(dev, fh, res)) 2197 if (!res_get(dev, fh, res))
2221 return -EBUSY; 2198 return -EBUSY;
@@ -2231,7 +2208,7 @@ static int saa7134_streamon(struct file *file, void *priv,
2231 PM_QOS_CPU_DMA_LATENCY, 2208 PM_QOS_CPU_DMA_LATENCY,
2232 20); 2209 20);
2233 2210
2234 return videobuf_streamon(saa7134_queue(fh)); 2211 return videobuf_streamon(saa7134_queue(file));
2235} 2212}
2236 2213
2237static int saa7134_streamoff(struct file *file, void *priv, 2214static int saa7134_streamoff(struct file *file, void *priv,
@@ -2240,11 +2217,11 @@ static int saa7134_streamoff(struct file *file, void *priv,
2240 int err; 2217 int err;
2241 struct saa7134_fh *fh = priv; 2218 struct saa7134_fh *fh = priv;
2242 struct saa7134_dev *dev = fh->dev; 2219 struct saa7134_dev *dev = fh->dev;
2243 int res = saa7134_resource(fh); 2220 int res = saa7134_resource(file);
2244 2221
2245 pm_qos_remove_request(&fh->qos_request); 2222 pm_qos_remove_request(&fh->qos_request);
2246 2223
2247 err = videobuf_streamoff(saa7134_queue(fh)); 2224 err = videobuf_streamoff(saa7134_queue(file));
2248 if (err < 0) 2225 if (err < 0)
2249 return err; 2226 return err;
2250 res_free(dev, fh, res); 2227 res_free(dev, fh, res);
@@ -2283,9 +2260,7 @@ static int radio_g_tuner(struct file *file, void *priv,
2283 if (0 != t->index) 2260 if (0 != t->index)
2284 return -EINVAL; 2261 return -EINVAL;
2285 2262
2286 memset(t, 0, sizeof(*t));
2287 strcpy(t->name, "Radio"); 2263 strcpy(t->name, "Radio");
2288 t->type = V4L2_TUNER_RADIO;
2289 2264
2290 saa_call_all(dev, tuner, g_tuner, t); 2265 saa_call_all(dev, tuner, g_tuner, t);
2291 t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO; 2266 t->audmode &= V4L2_TUNER_MODE_MONO | V4L2_TUNER_MODE_STEREO;
diff --git a/drivers/media/pci/saa7134/saa7134.h b/drivers/media/pci/saa7134/saa7134.h
index d2ad16c1569a..a103678cd499 100644
--- a/drivers/media/pci/saa7134/saa7134.h
+++ b/drivers/media/pci/saa7134/saa7134.h
@@ -471,8 +471,6 @@ struct saa7134_dmaqueue {
471struct saa7134_fh { 471struct saa7134_fh {
472 struct v4l2_fh fh; 472 struct v4l2_fh fh;
473 struct saa7134_dev *dev; 473 struct saa7134_dev *dev;
474 unsigned int radio;
475 enum v4l2_buf_type type;
476 unsigned int resources; 474 unsigned int resources;
477 struct pm_qos_request qos_request; 475 struct pm_qos_request qos_request;
478 476