diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2011-01-05 11:35:45 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-01-19 08:28:21 -0500 |
commit | 9bfaae24f991ff5255de17cd05838d1cd131727c (patch) | |
tree | 5010bf90ece9a21a9656ece24919f6aaaa9c2e00 | |
parent | 46656afa8a9a410b7939b248712e4e48921929da (diff) |
[media] davinci: convert vpif_display to core-assisted locking
vpif_display 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_display.c | 98 |
1 files changed, 20 insertions, 78 deletions
diff --git a/drivers/media/video/davinci/vpif_display.c b/drivers/media/video/davinci/vpif_display.c index 7cb70d916f4b..cdf659abdc2a 100644 --- a/drivers/media/video/davinci/vpif_display.c +++ b/drivers/media/video/davinci/vpif_display.c | |||
@@ -652,9 +652,6 @@ static int vpif_release(struct file *filep) | |||
652 | struct channel_obj *ch = fh->channel; | 652 | struct channel_obj *ch = fh->channel; |
653 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 653 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
654 | 654 | ||
655 | if (mutex_lock_interruptible(&common->lock)) | ||
656 | return -ERESTARTSYS; | ||
657 | |||
658 | /* if this instance is doing IO */ | 655 | /* if this instance is doing IO */ |
659 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { | 656 | if (fh->io_allowed[VPIF_VIDEO_INDEX]) { |
660 | /* Reset io_usrs member of channel object */ | 657 | /* Reset io_usrs member of channel object */ |
@@ -677,8 +674,6 @@ static int vpif_release(struct file *filep) | |||
677 | config_params.numbuffers[ch->channel_id]; | 674 | config_params.numbuffers[ch->channel_id]; |
678 | } | 675 | } |
679 | 676 | ||
680 | mutex_unlock(&common->lock); | ||
681 | |||
682 | /* Decrement channel usrs counter */ | 677 | /* Decrement channel usrs counter */ |
683 | atomic_dec(&ch->usrs); | 678 | atomic_dec(&ch->usrs); |
684 | /* If this file handle has initialize encoder device, reset it */ | 679 | /* If this file handle has initialize encoder device, reset it */ |
@@ -737,24 +732,15 @@ static int vpif_g_fmt_vid_out(struct file *file, void *priv, | |||
737 | struct vpif_fh *fh = priv; | 732 | struct vpif_fh *fh = priv; |
738 | struct channel_obj *ch = fh->channel; | 733 | struct channel_obj *ch = fh->channel; |
739 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 734 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
740 | int ret = 0; | ||
741 | 735 | ||
742 | /* Check the validity of the buffer type */ | 736 | /* Check the validity of the buffer type */ |
743 | if (common->fmt.type != fmt->type) | 737 | if (common->fmt.type != fmt->type) |
744 | return -EINVAL; | 738 | return -EINVAL; |
745 | 739 | ||
746 | /* Fill in the information about format */ | ||
747 | if (mutex_lock_interruptible(&common->lock)) | ||
748 | return -ERESTARTSYS; | ||
749 | |||
750 | if (vpif_update_resolution(ch)) | 740 | if (vpif_update_resolution(ch)) |
751 | ret = -EINVAL; | 741 | return -EINVAL; |
752 | else | 742 | *fmt = common->fmt; |
753 | *fmt = common->fmt; | 743 | return 0; |
754 | |||
755 | mutex_unlock(&common->lock); | ||
756 | |||
757 | return ret; | ||
758 | } | 744 | } |
759 | 745 | ||
760 | static int vpif_s_fmt_vid_out(struct file *file, void *priv, | 746 | static int vpif_s_fmt_vid_out(struct file *file, void *priv, |
@@ -794,12 +780,7 @@ static int vpif_s_fmt_vid_out(struct file *file, void *priv, | |||
794 | /* store the pix format in the channel object */ | 780 | /* store the pix format in the channel object */ |
795 | common->fmt.fmt.pix = *pixfmt; | 781 | common->fmt.fmt.pix = *pixfmt; |
796 | /* store the format in the channel object */ | 782 | /* store the format in the channel object */ |
797 | if (mutex_lock_interruptible(&common->lock)) | ||
798 | return -ERESTARTSYS; | ||
799 | |||
800 | common->fmt = *fmt; | 783 | common->fmt = *fmt; |
801 | mutex_unlock(&common->lock); | ||
802 | |||
803 | return 0; | 784 | return 0; |
804 | } | 785 | } |
805 | 786 | ||
@@ -829,7 +810,6 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
829 | struct common_obj *common; | 810 | struct common_obj *common; |
830 | enum v4l2_field field; | 811 | enum v4l2_field field; |
831 | u8 index = 0; | 812 | u8 index = 0; |
832 | int ret = 0; | ||
833 | 813 | ||
834 | /* This file handle has not initialized the channel, | 814 | /* This file handle has not initialized the channel, |
835 | It is not allowed to do settings */ | 815 | It is not allowed to do settings */ |
@@ -847,18 +827,12 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
847 | index = VPIF_VIDEO_INDEX; | 827 | index = VPIF_VIDEO_INDEX; |
848 | 828 | ||
849 | common = &ch->common[index]; | 829 | common = &ch->common[index]; |
850 | if (mutex_lock_interruptible(&common->lock)) | ||
851 | return -ERESTARTSYS; | ||
852 | 830 | ||
853 | if (common->fmt.type != reqbuf->type) { | 831 | if (common->fmt.type != reqbuf->type) |
854 | ret = -EINVAL; | 832 | return -EINVAL; |
855 | goto reqbuf_exit; | ||
856 | } | ||
857 | 833 | ||
858 | if (0 != common->io_usrs) { | 834 | if (0 != common->io_usrs) |
859 | ret = -EBUSY; | 835 | return -EBUSY; |
860 | goto reqbuf_exit; | ||
861 | } | ||
862 | 836 | ||
863 | if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 837 | if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
864 | if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY) | 838 | if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY) |
@@ -875,7 +849,7 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
875 | &common->irqlock, | 849 | &common->irqlock, |
876 | reqbuf->type, field, | 850 | reqbuf->type, field, |
877 | sizeof(struct videobuf_buffer), fh, | 851 | sizeof(struct videobuf_buffer), fh, |
878 | NULL); | 852 | &common->lock); |
879 | 853 | ||
880 | /* Set io allowed member of file handle to TRUE */ | 854 | /* Set io allowed member of file handle to TRUE */ |
881 | fh->io_allowed[index] = 1; | 855 | fh->io_allowed[index] = 1; |
@@ -886,11 +860,7 @@ static int vpif_reqbufs(struct file *file, void *priv, | |||
886 | INIT_LIST_HEAD(&common->dma_queue); | 860 | INIT_LIST_HEAD(&common->dma_queue); |
887 | 861 | ||
888 | /* Allocate buffers */ | 862 | /* Allocate buffers */ |
889 | ret = videobuf_reqbufs(&common->buffer_queue, reqbuf); | 863 | return videobuf_reqbufs(&common->buffer_queue, reqbuf); |
890 | |||
891 | reqbuf_exit: | ||
892 | mutex_unlock(&common->lock); | ||
893 | return ret; | ||
894 | } | 864 | } |
895 | 865 | ||
896 | static int vpif_querybuf(struct file *file, void *priv, | 866 | static int vpif_querybuf(struct file *file, void *priv, |
@@ -1011,25 +981,19 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id) | |||
1011 | } | 981 | } |
1012 | 982 | ||
1013 | /* Call encoder subdevice function to set the standard */ | 983 | /* Call encoder subdevice function to set the standard */ |
1014 | if (mutex_lock_interruptible(&common->lock)) | ||
1015 | return -ERESTARTSYS; | ||
1016 | |||
1017 | ch->video.stdid = *std_id; | 984 | ch->video.stdid = *std_id; |
1018 | ch->video.dv_preset = V4L2_DV_INVALID; | 985 | ch->video.dv_preset = V4L2_DV_INVALID; |
1019 | memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); | 986 | memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings)); |
1020 | 987 | ||
1021 | /* Get the information about the standard */ | 988 | /* Get the information about the standard */ |
1022 | if (vpif_update_resolution(ch)) { | 989 | if (vpif_update_resolution(ch)) |
1023 | ret = -EINVAL; | 990 | return -EINVAL; |
1024 | goto s_std_exit; | ||
1025 | } | ||
1026 | 991 | ||
1027 | if ((ch->vpifparams.std_info.width * | 992 | if ((ch->vpifparams.std_info.width * |
1028 | ch->vpifparams.std_info.height * 2) > | 993 | ch->vpifparams.std_info.height * 2) > |
1029 | config_params.channel_bufsize[ch->channel_id]) { | 994 | config_params.channel_bufsize[ch->channel_id]) { |
1030 | vpif_err("invalid std for this size\n"); | 995 | vpif_err("invalid std for this size\n"); |
1031 | ret = -EINVAL; | 996 | return -EINVAL; |
1032 | goto s_std_exit; | ||
1033 | } | 997 | } |
1034 | 998 | ||
1035 | common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width; | 999 | common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width; |
@@ -1040,16 +1004,13 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id) | |||
1040 | s_std_output, *std_id); | 1004 | s_std_output, *std_id); |
1041 | if (ret < 0) { | 1005 | if (ret < 0) { |
1042 | vpif_err("Failed to set output standard\n"); | 1006 | vpif_err("Failed to set output standard\n"); |
1043 | goto s_std_exit; | 1007 | return ret; |
1044 | } | 1008 | } |
1045 | 1009 | ||
1046 | ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core, | 1010 | ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core, |
1047 | s_std, *std_id); | 1011 | s_std, *std_id); |
1048 | if (ret < 0) | 1012 | if (ret < 0) |
1049 | vpif_err("Failed to set standard for sub devices\n"); | 1013 | vpif_err("Failed to set standard for sub devices\n"); |
1050 | |||
1051 | s_std_exit: | ||
1052 | mutex_unlock(&common->lock); | ||
1053 | return ret; | 1014 | return ret; |
1054 | } | 1015 | } |
1055 | 1016 | ||
@@ -1121,14 +1082,10 @@ static int vpif_streamon(struct file *file, void *priv, | |||
1121 | return ret; | 1082 | return ret; |
1122 | } | 1083 | } |
1123 | 1084 | ||
1124 | if (mutex_lock_interruptible(&common->lock)) | ||
1125 | return -ERESTARTSYS; | ||
1126 | |||
1127 | /* If buffer queue is empty, return error */ | 1085 | /* If buffer queue is empty, return error */ |
1128 | if (list_empty(&common->dma_queue)) { | 1086 | if (list_empty(&common->dma_queue)) { |
1129 | vpif_err("buffer queue is empty\n"); | 1087 | vpif_err("buffer queue is empty\n"); |
1130 | ret = -EIO; | 1088 | return -EIO; |
1131 | goto streamon_exit; | ||
1132 | } | 1089 | } |
1133 | 1090 | ||
1134 | /* Get the next frame from the buffer queue */ | 1091 | /* Get the next frame from the buffer queue */ |
@@ -1154,8 +1111,7 @@ static int vpif_streamon(struct file *file, void *priv, | |||
1154 | || (!ch->vpifparams.std_info.frm_fmt | 1111 | || (!ch->vpifparams.std_info.frm_fmt |
1155 | && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) { | 1112 | && (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) { |
1156 | vpif_err("conflict in field format and std format\n"); | 1113 | vpif_err("conflict in field format and std format\n"); |
1157 | ret = -EINVAL; | 1114 | return -EINVAL; |
1158 | goto streamon_exit; | ||
1159 | } | 1115 | } |
1160 | 1116 | ||
1161 | /* clock settings */ | 1117 | /* clock settings */ |
@@ -1164,13 +1120,13 @@ static int vpif_streamon(struct file *file, void *priv, | |||
1164 | ch->vpifparams.std_info.hd_sd); | 1120 | ch->vpifparams.std_info.hd_sd); |
1165 | if (ret < 0) { | 1121 | if (ret < 0) { |
1166 | vpif_err("can't set clock\n"); | 1122 | vpif_err("can't set clock\n"); |
1167 | goto streamon_exit; | 1123 | return ret; |
1168 | } | 1124 | } |
1169 | 1125 | ||
1170 | /* set the parameters and addresses */ | 1126 | /* set the parameters and addresses */ |
1171 | ret = vpif_set_video_params(vpif, ch->channel_id + 2); | 1127 | ret = vpif_set_video_params(vpif, ch->channel_id + 2); |
1172 | if (ret < 0) | 1128 | if (ret < 0) |
1173 | goto streamon_exit; | 1129 | return ret; |
1174 | 1130 | ||
1175 | common->started = ret; | 1131 | common->started = ret; |
1176 | vpif_config_addr(ch, ret); | 1132 | vpif_config_addr(ch, ret); |
@@ -1195,9 +1151,6 @@ static int vpif_streamon(struct file *file, void *priv, | |||
1195 | } | 1151 | } |
1196 | channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; | 1152 | channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1; |
1197 | } | 1153 | } |
1198 | |||
1199 | streamon_exit: | ||
1200 | mutex_unlock(&common->lock); | ||
1201 | return ret; | 1154 | return ret; |
1202 | } | 1155 | } |
1203 | 1156 | ||
@@ -1223,9 +1176,6 @@ static int vpif_streamoff(struct file *file, void *priv, | |||
1223 | return -EINVAL; | 1176 | return -EINVAL; |
1224 | } | 1177 | } |
1225 | 1178 | ||
1226 | if (mutex_lock_interruptible(&common->lock)) | ||
1227 | return -ERESTARTSYS; | ||
1228 | |||
1229 | if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) { | 1179 | if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) { |
1230 | /* disable channel */ | 1180 | /* disable channel */ |
1231 | if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { | 1181 | if (VPIF_CHANNEL2_VIDEO == ch->channel_id) { |
@@ -1240,8 +1190,6 @@ static int vpif_streamoff(struct file *file, void *priv, | |||
1240 | } | 1190 | } |
1241 | 1191 | ||
1242 | common->started = 0; | 1192 | common->started = 0; |
1243 | mutex_unlock(&common->lock); | ||
1244 | |||
1245 | return videobuf_streamoff(&common->buffer_queue); | 1193 | return videobuf_streamoff(&common->buffer_queue); |
1246 | } | 1194 | } |
1247 | 1195 | ||
@@ -1288,13 +1236,9 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i) | |||
1288 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; | 1236 | struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX]; |
1289 | int ret = 0; | 1237 | int ret = 0; |
1290 | 1238 | ||
1291 | if (mutex_lock_interruptible(&common->lock)) | ||
1292 | return -ERESTARTSYS; | ||
1293 | |||
1294 | if (common->started) { | 1239 | if (common->started) { |
1295 | vpif_err("Streaming in progress\n"); | 1240 | vpif_err("Streaming in progress\n"); |
1296 | ret = -EBUSY; | 1241 | return -EBUSY; |
1297 | goto s_output_exit; | ||
1298 | } | 1242 | } |
1299 | 1243 | ||
1300 | ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video, | 1244 | ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video, |
@@ -1304,9 +1248,6 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i) | |||
1304 | vpif_err("Failed to set output standard\n"); | 1248 | vpif_err("Failed to set output standard\n"); |
1305 | 1249 | ||
1306 | vid_ch->output_id = i; | 1250 | vid_ch->output_id = i; |
1307 | |||
1308 | s_output_exit: | ||
1309 | mutex_unlock(&common->lock); | ||
1310 | return ret; | 1251 | return ret; |
1311 | } | 1252 | } |
1312 | 1253 | ||
@@ -1658,7 +1599,7 @@ static const struct v4l2_file_operations vpif_fops = { | |||
1658 | .owner = THIS_MODULE, | 1599 | .owner = THIS_MODULE, |
1659 | .open = vpif_open, | 1600 | .open = vpif_open, |
1660 | .release = vpif_release, | 1601 | .release = vpif_release, |
1661 | .ioctl = video_ioctl2, | 1602 | .unlocked_ioctl = video_ioctl2, |
1662 | .mmap = vpif_mmap, | 1603 | .mmap = vpif_mmap, |
1663 | .poll = vpif_poll | 1604 | .poll = vpif_poll |
1664 | }; | 1605 | }; |
@@ -1842,6 +1783,7 @@ static __init int vpif_probe(struct platform_device *pdev) | |||
1842 | v4l2_prio_init(&ch->prio); | 1783 | v4l2_prio_init(&ch->prio); |
1843 | ch->common[VPIF_VIDEO_INDEX].fmt.type = | 1784 | ch->common[VPIF_VIDEO_INDEX].fmt.type = |
1844 | V4L2_BUF_TYPE_VIDEO_OUTPUT; | 1785 | V4L2_BUF_TYPE_VIDEO_OUTPUT; |
1786 | ch->video_dev->lock = &common->lock; | ||
1845 | 1787 | ||
1846 | /* register video device */ | 1788 | /* register video device */ |
1847 | vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", | 1789 | vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n", |