aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2011-01-04 04:51:35 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-01-19 08:28:20 -0500
commit46656afa8a9a410b7939b248712e4e48921929da (patch)
treedd5e7b248e30590d0aa598b84bbcce5680260c80
parent2c0ddd17741383009c53cf557d6526848c8bb917 (diff)
[media] davinci: convert vpif_capture to core-assisted locking
Now uses .unlocked_ioctl instead of .ioctl. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Manjunath Hadli <manjunath.hadli@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/davinci/vpif_capture.c90
1 files changed, 14 insertions, 76 deletions
diff --git a/drivers/media/video/davinci/vpif_capture.c b/drivers/media/video/davinci/vpif_capture.c
index f8e65909dc37..d93ad74a34c5 100644
--- a/drivers/media/video/davinci/vpif_capture.c
+++ b/drivers/media/video/davinci/vpif_capture.c
@@ -752,7 +752,7 @@ static int vpif_open(struct file *filep)
752 struct video_obj *vid_ch; 752 struct video_obj *vid_ch;
753 struct channel_obj *ch; 753 struct channel_obj *ch;
754 struct vpif_fh *fh; 754 struct vpif_fh *fh;
755 int i, ret = 0; 755 int i;
756 756
757 vpif_dbg(2, debug, "vpif_open\n"); 757 vpif_dbg(2, debug, "vpif_open\n");
758 758
@@ -761,9 +761,6 @@ static int vpif_open(struct file *filep)
761 vid_ch = &ch->video; 761 vid_ch = &ch->video;
762 common = &ch->common[VPIF_VIDEO_INDEX]; 762 common = &ch->common[VPIF_VIDEO_INDEX];
763 763
764 if (mutex_lock_interruptible(&common->lock))
765 return -ERESTARTSYS;
766
767 if (NULL == ch->curr_subdev_info) { 764 if (NULL == ch->curr_subdev_info) {
768 /** 765 /**
769 * search through the sub device to see a registered 766 * search through the sub device to see a registered
@@ -780,8 +777,7 @@ static int vpif_open(struct file *filep)
780 } 777 }
781 if (i == config->subdev_count) { 778 if (i == config->subdev_count) {
782 vpif_err("No sub device registered\n"); 779 vpif_err("No sub device registered\n");
783 ret = -ENOENT; 780 return -ENOENT;
784 goto exit;
785 } 781 }
786 } 782 }
787 783
@@ -789,8 +785,7 @@ static int vpif_open(struct file *filep)
789 fh = kzalloc(sizeof(struct vpif_fh), GFP_KERNEL); 785 fh = kzalloc(sizeof(struct vpif_fh), GFP_KERNEL);
790 if (NULL == fh) { 786 if (NULL == fh) {
791 vpif_err("unable to allocate memory for file handle object\n"); 787 vpif_err("unable to allocate memory for file handle object\n");
792 ret = -ENOMEM; 788 return -ENOMEM;
793 goto exit;
794 } 789 }
795 790
796 /* store pointer to fh in private_data member of filep */ 791 /* store pointer to fh in private_data member of filep */
@@ -810,9 +805,7 @@ static int vpif_open(struct file *filep)
810 /* Initialize priority of this instance to default priority */ 805 /* Initialize priority of this instance to default priority */
811 fh->prio = V4L2_PRIORITY_UNSET; 806 fh->prio = V4L2_PRIORITY_UNSET;
812 v4l2_prio_open(&ch->prio, &fh->prio); 807 v4l2_prio_open(&ch->prio, &fh->prio);
813exit: 808 return 0;
814 mutex_unlock(&common->lock);
815 return ret;
816} 809}
817 810
818/** 811/**
@@ -832,9 +825,6 @@ static int vpif_release(struct file *filep)
832 825
833 common = &ch->common[VPIF_VIDEO_INDEX]; 826 common = &ch->common[VPIF_VIDEO_INDEX];
834 827
835 if (mutex_lock_interruptible(&common->lock))
836 return -ERESTARTSYS;
837
838 /* if this instance is doing IO */ 828 /* if this instance is doing IO */
839 if (fh->io_allowed[VPIF_VIDEO_INDEX]) { 829 if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
840 /* Reset io_usrs member of channel object */ 830 /* Reset io_usrs member of channel object */
@@ -858,9 +848,6 @@ static int vpif_release(struct file *filep)
858 /* Decrement channel usrs counter */ 848 /* Decrement channel usrs counter */
859 ch->usrs--; 849 ch->usrs--;
860 850
861 /* unlock mutex on channel object */
862 mutex_unlock(&common->lock);
863
864 /* Close the priority */ 851 /* Close the priority */
865 v4l2_prio_close(&ch->prio, fh->prio); 852 v4l2_prio_close(&ch->prio, fh->prio);
866 853
@@ -885,7 +872,6 @@ static int vpif_reqbufs(struct file *file, void *priv,
885 struct channel_obj *ch = fh->channel; 872 struct channel_obj *ch = fh->channel;
886 struct common_obj *common; 873 struct common_obj *common;
887 u8 index = 0; 874 u8 index = 0;
888 int ret = 0;
889 875
890 vpif_dbg(2, debug, "vpif_reqbufs\n"); 876 vpif_dbg(2, debug, "vpif_reqbufs\n");
891 877
@@ -908,13 +894,8 @@ static int vpif_reqbufs(struct file *file, void *priv,
908 894
909 common = &ch->common[index]; 895 common = &ch->common[index];
910 896
911 if (mutex_lock_interruptible(&common->lock)) 897 if (0 != common->io_usrs)
912 return -ERESTARTSYS; 898 return -EBUSY;
913
914 if (0 != common->io_usrs) {
915 ret = -EBUSY;
916 goto reqbuf_exit;
917 }
918 899
919 /* Initialize videobuf queue as per the buffer type */ 900 /* Initialize videobuf queue as per the buffer type */
920 videobuf_queue_dma_contig_init(&common->buffer_queue, 901 videobuf_queue_dma_contig_init(&common->buffer_queue,
@@ -923,7 +904,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
923 reqbuf->type, 904 reqbuf->type,
924 common->fmt.fmt.pix.field, 905 common->fmt.fmt.pix.field,
925 sizeof(struct videobuf_buffer), fh, 906 sizeof(struct videobuf_buffer), fh,
926 NULL); 907 &common->lock);
927 908
928 /* Set io allowed member of file handle to TRUE */ 909 /* Set io allowed member of file handle to TRUE */
929 fh->io_allowed[index] = 1; 910 fh->io_allowed[index] = 1;
@@ -934,11 +915,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
934 INIT_LIST_HEAD(&common->dma_queue); 915 INIT_LIST_HEAD(&common->dma_queue);
935 916
936 /* Allocate buffers */ 917 /* Allocate buffers */
937 ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); 918 return videobuf_reqbufs(&common->buffer_queue, reqbuf);
938
939reqbuf_exit:
940 mutex_unlock(&common->lock);
941 return ret;
942} 919}
943 920
944/** 921/**
@@ -1152,11 +1129,6 @@ static int vpif_streamon(struct file *file, void *priv,
1152 return ret; 1129 return ret;
1153 } 1130 }
1154 1131
1155 if (mutex_lock_interruptible(&common->lock)) {
1156 ret = -ERESTARTSYS;
1157 goto streamoff_exit;
1158 }
1159
1160 /* If buffer queue is empty, return error */ 1132 /* If buffer queue is empty, return error */
1161 if (list_empty(&common->dma_queue)) { 1133 if (list_empty(&common->dma_queue)) {
1162 vpif_dbg(1, debug, "buffer queue is empty\n"); 1134 vpif_dbg(1, debug, "buffer queue is empty\n");
@@ -1235,13 +1207,10 @@ static int vpif_streamon(struct file *file, void *priv,
1235 enable_channel1(1); 1207 enable_channel1(1);
1236 } 1208 }
1237 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; 1209 channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1;
1238 mutex_unlock(&common->lock);
1239 return ret; 1210 return ret;
1240 1211
1241exit: 1212exit:
1242 mutex_unlock(&common->lock); 1213 videobuf_streamoff(&common->buffer_queue);
1243streamoff_exit:
1244 ret = videobuf_streamoff(&common->buffer_queue);
1245 return ret; 1214 return ret;
1246} 1215}
1247 1216
@@ -1279,9 +1248,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1279 return -EINVAL; 1248 return -EINVAL;
1280 } 1249 }
1281 1250
1282 if (mutex_lock_interruptible(&common->lock))
1283 return -ERESTARTSYS;
1284
1285 /* disable channel */ 1251 /* disable channel */
1286 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) { 1252 if (VPIF_CHANNEL0_VIDEO == ch->channel_id) {
1287 enable_channel0(0); 1253 enable_channel0(0);
@@ -1299,8 +1265,6 @@ static int vpif_streamoff(struct file *file, void *priv,
1299 if (ret && (ret != -ENOIOCTLCMD)) 1265 if (ret && (ret != -ENOIOCTLCMD))
1300 vpif_dbg(1, debug, "stream off failed in subdev\n"); 1266 vpif_dbg(1, debug, "stream off failed in subdev\n");
1301 1267
1302 mutex_unlock(&common->lock);
1303
1304 return videobuf_streamoff(&common->buffer_queue); 1268 return videobuf_streamoff(&common->buffer_queue);
1305} 1269}
1306 1270
@@ -1376,21 +1340,16 @@ static int vpif_querystd(struct file *file, void *priv, v4l2_std_id *std_id)
1376{ 1340{
1377 struct vpif_fh *fh = priv; 1341 struct vpif_fh *fh = priv;
1378 struct channel_obj *ch = fh->channel; 1342 struct channel_obj *ch = fh->channel;
1379 struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
1380 int ret = 0; 1343 int ret = 0;
1381 1344
1382 vpif_dbg(2, debug, "vpif_querystd\n"); 1345 vpif_dbg(2, debug, "vpif_querystd\n");
1383 1346
1384 if (mutex_lock_interruptible(&common->lock))
1385 return -ERESTARTSYS;
1386
1387 /* Call querystd function of decoder device */ 1347 /* Call querystd function of decoder device */
1388 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], video, 1348 ret = v4l2_subdev_call(vpif_obj.sd[ch->curr_sd_index], video,
1389 querystd, std_id); 1349 querystd, std_id);
1390 if (ret < 0) 1350 if (ret < 0)
1391 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1351 vpif_dbg(1, debug, "Failed to set standard for sub devices\n");
1392 1352
1393 mutex_unlock(&common->lock);
1394 return ret; 1353 return ret;
1395} 1354}
1396 1355
@@ -1446,18 +1405,14 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1446 fh->initialized = 1; 1405 fh->initialized = 1;
1447 1406
1448 /* Call encoder subdevice function to set the standard */ 1407 /* Call encoder subdevice function to set the standard */
1449 if (mutex_lock_interruptible(&common->lock))
1450 return -ERESTARTSYS;
1451
1452 ch->video.stdid = *std_id; 1408 ch->video.stdid = *std_id;
1453 ch->video.dv_preset = V4L2_DV_INVALID; 1409 ch->video.dv_preset = V4L2_DV_INVALID;
1454 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); 1410 memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
1455 1411
1456 /* Get the information about the standard */ 1412 /* Get the information about the standard */
1457 if (vpif_update_std_info(ch)) { 1413 if (vpif_update_std_info(ch)) {
1458 ret = -EINVAL;
1459 vpif_err("Error getting the standard info\n"); 1414 vpif_err("Error getting the standard info\n");
1460 goto s_std_exit; 1415 return -EINVAL;
1461 } 1416 }
1462 1417
1463 /* Configure the default format information */ 1418 /* Configure the default format information */
@@ -1468,9 +1423,6 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
1468 s_std, *std_id); 1423 s_std, *std_id);
1469 if (ret < 0) 1424 if (ret < 0)
1470 vpif_dbg(1, debug, "Failed to set standard for sub devices\n"); 1425 vpif_dbg(1, debug, "Failed to set standard for sub devices\n");
1471
1472s_std_exit:
1473 mutex_unlock(&common->lock);
1474 return ret; 1426 return ret;
1475} 1427}
1476 1428
@@ -1564,9 +1516,6 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1564 return -EINVAL; 1516 return -EINVAL;
1565 } 1517 }
1566 1518
1567 if (mutex_lock_interruptible(&common->lock))
1568 return -ERESTARTSYS;
1569
1570 /* first setup input path from sub device to vpif */ 1519 /* first setup input path from sub device to vpif */
1571 if (config->setup_input_path) { 1520 if (config->setup_input_path) {
1572 ret = config->setup_input_path(ch->channel_id, 1521 ret = config->setup_input_path(ch->channel_id,
@@ -1575,7 +1524,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1575 vpif_dbg(1, debug, "couldn't setup input path for the" 1524 vpif_dbg(1, debug, "couldn't setup input path for the"
1576 " sub device %s, for input index %d\n", 1525 " sub device %s, for input index %d\n",
1577 subdev_info->name, index); 1526 subdev_info->name, index);
1578 goto exit; 1527 return ret;
1579 } 1528 }
1580 } 1529 }
1581 1530
@@ -1586,7 +1535,7 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1586 input, output, 0); 1535 input, output, 0);
1587 if (ret < 0) { 1536 if (ret < 0) {
1588 vpif_dbg(1, debug, "Failed to set input\n"); 1537 vpif_dbg(1, debug, "Failed to set input\n");
1589 goto exit; 1538 return ret;
1590 } 1539 }
1591 } 1540 }
1592 vid_ch->input_idx = index; 1541 vid_ch->input_idx = index;
@@ -1597,9 +1546,6 @@ static int vpif_s_input(struct file *file, void *priv, unsigned int index)
1597 1546
1598 /* update tvnorms from the sub device input info */ 1547 /* update tvnorms from the sub device input info */
1599 ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std; 1548 ch->video_dev->tvnorms = chan_cfg->inputs[index].input.std;
1600
1601exit:
1602 mutex_unlock(&common->lock);
1603 return ret; 1549 return ret;
1604} 1550}
1605 1551
@@ -1668,11 +1614,7 @@ static int vpif_g_fmt_vid_cap(struct file *file, void *priv,
1668 return -EINVAL; 1614 return -EINVAL;
1669 1615
1670 /* Fill in the information about format */ 1616 /* Fill in the information about format */
1671 if (mutex_lock_interruptible(&common->lock))
1672 return -ERESTARTSYS;
1673
1674 *fmt = common->fmt; 1617 *fmt = common->fmt;
1675 mutex_unlock(&common->lock);
1676 return 0; 1618 return 0;
1677} 1619}
1678 1620
@@ -1720,12 +1662,7 @@ static int vpif_s_fmt_vid_cap(struct file *file, void *priv,
1720 if (ret) 1662 if (ret)
1721 return ret; 1663 return ret;
1722 /* store the format in the channel object */ 1664 /* store the format in the channel object */
1723 if (mutex_lock_interruptible(&common->lock))
1724 return -ERESTARTSYS;
1725
1726 common->fmt = *fmt; 1665 common->fmt = *fmt;
1727 mutex_unlock(&common->lock);
1728
1729 return 0; 1666 return 0;
1730} 1667}
1731 1668
@@ -2145,7 +2082,7 @@ static struct v4l2_file_operations vpif_fops = {
2145 .owner = THIS_MODULE, 2082 .owner = THIS_MODULE,
2146 .open = vpif_open, 2083 .open = vpif_open,
2147 .release = vpif_release, 2084 .release = vpif_release,
2148 .ioctl = video_ioctl2, 2085 .unlocked_ioctl = video_ioctl2,
2149 .mmap = vpif_mmap, 2086 .mmap = vpif_mmap,
2150 .poll = vpif_poll 2087 .poll = vpif_poll
2151}; 2088};
@@ -2288,6 +2225,7 @@ static __init int vpif_probe(struct platform_device *pdev)
2288 common = &(ch->common[VPIF_VIDEO_INDEX]); 2225 common = &(ch->common[VPIF_VIDEO_INDEX]);
2289 spin_lock_init(&common->irqlock); 2226 spin_lock_init(&common->irqlock);
2290 mutex_init(&common->lock); 2227 mutex_init(&common->lock);
2228 ch->video_dev->lock = &common->lock;
2291 /* Initialize prio member of channel object */ 2229 /* Initialize prio member of channel object */
2292 v4l2_prio_init(&ch->prio); 2230 v4l2_prio_init(&ch->prio);
2293 err = video_register_device(ch->video_dev, 2231 err = video_register_device(ch->video_dev,