diff options
author | Hans Verkuil <hans.verkuil@cisco.com> | 2012-06-22 04:53:02 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-07-06 16:33:14 -0400 |
commit | f2ba5a0b469952328b03e239acacd77858f19fb3 (patch) | |
tree | 6f0313cc0ddee2b0cddda959666e57d3b0fc2278 /drivers | |
parent | 70bd97ae5f12299b152d4220cfc77d8078b21d35 (diff) |
[media] vivi: use vb2 helper functions
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/video/vivi.c | 150 |
1 files changed, 12 insertions, 138 deletions
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 1e4da5e43a32..f6d7c6e3390e 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -790,27 +790,6 @@ static int queue_setup(struct vb2_queue *vq, const struct v4l2_format *fmt, | |||
790 | return 0; | 790 | return 0; |
791 | } | 791 | } |
792 | 792 | ||
793 | static int buffer_init(struct vb2_buffer *vb) | ||
794 | { | ||
795 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
796 | |||
797 | BUG_ON(NULL == dev->fmt); | ||
798 | |||
799 | /* | ||
800 | * This callback is called once per buffer, after its allocation. | ||
801 | * | ||
802 | * Vivi does not allow changing format during streaming, but it is | ||
803 | * possible to do so when streaming is paused (i.e. in streamoff state). | ||
804 | * Buffers however are not freed when going into streamoff and so | ||
805 | * buffer size verification has to be done in buffer_prepare, on each | ||
806 | * qbuf. | ||
807 | * It would be best to move verification code here to buf_init and | ||
808 | * s_fmt though. | ||
809 | */ | ||
810 | |||
811 | return 0; | ||
812 | } | ||
813 | |||
814 | static int buffer_prepare(struct vb2_buffer *vb) | 793 | static int buffer_prepare(struct vb2_buffer *vb) |
815 | { | 794 | { |
816 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | 795 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); |
@@ -848,20 +827,6 @@ static int buffer_prepare(struct vb2_buffer *vb) | |||
848 | return 0; | 827 | return 0; |
849 | } | 828 | } |
850 | 829 | ||
851 | static int buffer_finish(struct vb2_buffer *vb) | ||
852 | { | ||
853 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
854 | dprintk(dev, 1, "%s\n", __func__); | ||
855 | return 0; | ||
856 | } | ||
857 | |||
858 | static void buffer_cleanup(struct vb2_buffer *vb) | ||
859 | { | ||
860 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | ||
861 | dprintk(dev, 1, "%s\n", __func__); | ||
862 | |||
863 | } | ||
864 | |||
865 | static void buffer_queue(struct vb2_buffer *vb) | 830 | static void buffer_queue(struct vb2_buffer *vb) |
866 | { | 831 | { |
867 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); | 832 | struct vivi_dev *dev = vb2_get_drv_priv(vb->vb2_queue); |
@@ -907,10 +872,7 @@ static void vivi_unlock(struct vb2_queue *vq) | |||
907 | 872 | ||
908 | static struct vb2_ops vivi_video_qops = { | 873 | static struct vb2_ops vivi_video_qops = { |
909 | .queue_setup = queue_setup, | 874 | .queue_setup = queue_setup, |
910 | .buf_init = buffer_init, | ||
911 | .buf_prepare = buffer_prepare, | 875 | .buf_prepare = buffer_prepare, |
912 | .buf_finish = buffer_finish, | ||
913 | .buf_cleanup = buffer_cleanup, | ||
914 | .buf_queue = buffer_queue, | 876 | .buf_queue = buffer_queue, |
915 | .start_streaming = start_streaming, | 877 | .start_streaming = start_streaming, |
916 | .stop_streaming = stop_streaming, | 878 | .stop_streaming = stop_streaming, |
@@ -1019,7 +981,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1019 | if (ret < 0) | 981 | if (ret < 0) |
1020 | return ret; | 982 | return ret; |
1021 | 983 | ||
1022 | if (vb2_is_streaming(q)) { | 984 | if (vb2_is_busy(q)) { |
1023 | dprintk(dev, 1, "%s device busy\n", __func__); | 985 | dprintk(dev, 1, "%s device busy\n", __func__); |
1024 | return -EBUSY; | 986 | return -EBUSY; |
1025 | } | 987 | } |
@@ -1033,43 +995,6 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, | |||
1033 | return 0; | 995 | return 0; |
1034 | } | 996 | } |
1035 | 997 | ||
1036 | static int vidioc_reqbufs(struct file *file, void *priv, | ||
1037 | struct v4l2_requestbuffers *p) | ||
1038 | { | ||
1039 | struct vivi_dev *dev = video_drvdata(file); | ||
1040 | return vb2_reqbufs(&dev->vb_vidq, p); | ||
1041 | } | ||
1042 | |||
1043 | static int vidioc_querybuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1044 | { | ||
1045 | struct vivi_dev *dev = video_drvdata(file); | ||
1046 | return vb2_querybuf(&dev->vb_vidq, p); | ||
1047 | } | ||
1048 | |||
1049 | static int vidioc_qbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1050 | { | ||
1051 | struct vivi_dev *dev = video_drvdata(file); | ||
1052 | return vb2_qbuf(&dev->vb_vidq, p); | ||
1053 | } | ||
1054 | |||
1055 | static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *p) | ||
1056 | { | ||
1057 | struct vivi_dev *dev = video_drvdata(file); | ||
1058 | return vb2_dqbuf(&dev->vb_vidq, p, file->f_flags & O_NONBLOCK); | ||
1059 | } | ||
1060 | |||
1061 | static int vidioc_streamon(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1062 | { | ||
1063 | struct vivi_dev *dev = video_drvdata(file); | ||
1064 | return vb2_streamon(&dev->vb_vidq, i); | ||
1065 | } | ||
1066 | |||
1067 | static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i) | ||
1068 | { | ||
1069 | struct vivi_dev *dev = video_drvdata(file); | ||
1070 | return vb2_streamoff(&dev->vb_vidq, i); | ||
1071 | } | ||
1072 | |||
1073 | /* only one input in this sample driver */ | 998 | /* only one input in this sample driver */ |
1074 | static int vidioc_enum_input(struct file *file, void *priv, | 999 | static int vidioc_enum_input(struct file *file, void *priv, |
1075 | struct v4l2_input *inp) | 1000 | struct v4l2_input *inp) |
@@ -1137,58 +1062,6 @@ static int vivi_s_ctrl(struct v4l2_ctrl *ctrl) | |||
1137 | File operations for the device | 1062 | File operations for the device |
1138 | ------------------------------------------------------------------*/ | 1063 | ------------------------------------------------------------------*/ |
1139 | 1064 | ||
1140 | static ssize_t | ||
1141 | vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) | ||
1142 | { | ||
1143 | struct vivi_dev *dev = video_drvdata(file); | ||
1144 | int err; | ||
1145 | |||
1146 | dprintk(dev, 1, "read called\n"); | ||
1147 | mutex_lock(&dev->mutex); | ||
1148 | err = vb2_read(&dev->vb_vidq, data, count, ppos, | ||
1149 | file->f_flags & O_NONBLOCK); | ||
1150 | mutex_unlock(&dev->mutex); | ||
1151 | return err; | ||
1152 | } | ||
1153 | |||
1154 | static unsigned int | ||
1155 | vivi_poll(struct file *file, struct poll_table_struct *wait) | ||
1156 | { | ||
1157 | struct vivi_dev *dev = video_drvdata(file); | ||
1158 | struct vb2_queue *q = &dev->vb_vidq; | ||
1159 | |||
1160 | dprintk(dev, 1, "%s\n", __func__); | ||
1161 | return vb2_poll(q, file, wait); | ||
1162 | } | ||
1163 | |||
1164 | static int vivi_close(struct file *file) | ||
1165 | { | ||
1166 | struct video_device *vdev = video_devdata(file); | ||
1167 | struct vivi_dev *dev = video_drvdata(file); | ||
1168 | |||
1169 | dprintk(dev, 1, "close called (dev=%s), file %p\n", | ||
1170 | video_device_node_name(vdev), file); | ||
1171 | |||
1172 | if (v4l2_fh_is_singular_file(file)) | ||
1173 | vb2_queue_release(&dev->vb_vidq); | ||
1174 | return v4l2_fh_release(file); | ||
1175 | } | ||
1176 | |||
1177 | static int vivi_mmap(struct file *file, struct vm_area_struct *vma) | ||
1178 | { | ||
1179 | struct vivi_dev *dev = video_drvdata(file); | ||
1180 | int ret; | ||
1181 | |||
1182 | dprintk(dev, 1, "mmap called, vma=0x%08lx\n", (unsigned long)vma); | ||
1183 | |||
1184 | ret = vb2_mmap(&dev->vb_vidq, vma); | ||
1185 | dprintk(dev, 1, "vma start=0x%08lx, size=%ld, ret=%d\n", | ||
1186 | (unsigned long)vma->vm_start, | ||
1187 | (unsigned long)vma->vm_end - (unsigned long)vma->vm_start, | ||
1188 | ret); | ||
1189 | return ret; | ||
1190 | } | ||
1191 | |||
1192 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { | 1065 | static const struct v4l2_ctrl_ops vivi_ctrl_ops = { |
1193 | .g_volatile_ctrl = vivi_g_volatile_ctrl, | 1066 | .g_volatile_ctrl = vivi_g_volatile_ctrl, |
1194 | .s_ctrl = vivi_s_ctrl, | 1067 | .s_ctrl = vivi_s_ctrl, |
@@ -1293,11 +1166,11 @@ static const struct v4l2_ctrl_config vivi_ctrl_int_menu = { | |||
1293 | static const struct v4l2_file_operations vivi_fops = { | 1166 | static const struct v4l2_file_operations vivi_fops = { |
1294 | .owner = THIS_MODULE, | 1167 | .owner = THIS_MODULE, |
1295 | .open = v4l2_fh_open, | 1168 | .open = v4l2_fh_open, |
1296 | .release = vivi_close, | 1169 | .release = vb2_fop_release, |
1297 | .read = vivi_read, | 1170 | .read = vb2_fop_read, |
1298 | .poll = vivi_poll, | 1171 | .poll = vb2_fop_poll, |
1299 | .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ | 1172 | .unlocked_ioctl = video_ioctl2, /* V4L2 ioctl handler */ |
1300 | .mmap = vivi_mmap, | 1173 | .mmap = vb2_fop_mmap, |
1301 | }; | 1174 | }; |
1302 | 1175 | ||
1303 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { | 1176 | static const struct v4l2_ioctl_ops vivi_ioctl_ops = { |
@@ -1306,15 +1179,15 @@ static const struct v4l2_ioctl_ops vivi_ioctl_ops = { | |||
1306 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, | 1179 | .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap, |
1307 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, | 1180 | .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap, |
1308 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, | 1181 | .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap, |
1309 | .vidioc_reqbufs = vidioc_reqbufs, | 1182 | .vidioc_reqbufs = vb2_ioctl_reqbufs, |
1310 | .vidioc_querybuf = vidioc_querybuf, | 1183 | .vidioc_querybuf = vb2_ioctl_querybuf, |
1311 | .vidioc_qbuf = vidioc_qbuf, | 1184 | .vidioc_qbuf = vb2_ioctl_qbuf, |
1312 | .vidioc_dqbuf = vidioc_dqbuf, | 1185 | .vidioc_dqbuf = vb2_ioctl_dqbuf, |
1313 | .vidioc_enum_input = vidioc_enum_input, | 1186 | .vidioc_enum_input = vidioc_enum_input, |
1314 | .vidioc_g_input = vidioc_g_input, | 1187 | .vidioc_g_input = vidioc_g_input, |
1315 | .vidioc_s_input = vidioc_s_input, | 1188 | .vidioc_s_input = vidioc_s_input, |
1316 | .vidioc_streamon = vidioc_streamon, | 1189 | .vidioc_streamon = vb2_ioctl_streamon, |
1317 | .vidioc_streamoff = vidioc_streamoff, | 1190 | .vidioc_streamoff = vb2_ioctl_streamoff, |
1318 | .vidioc_log_status = v4l2_ctrl_log_status, | 1191 | .vidioc_log_status = v4l2_ctrl_log_status, |
1319 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, | 1192 | .vidioc_subscribe_event = v4l2_ctrl_subscribe_event, |
1320 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, | 1193 | .vidioc_unsubscribe_event = v4l2_event_unsubscribe, |
@@ -1432,6 +1305,7 @@ static int __init vivi_create_instance(int inst) | |||
1432 | *vfd = vivi_template; | 1305 | *vfd = vivi_template; |
1433 | vfd->debug = debug; | 1306 | vfd->debug = debug; |
1434 | vfd->v4l2_dev = &dev->v4l2_dev; | 1307 | vfd->v4l2_dev = &dev->v4l2_dev; |
1308 | vfd->queue = q; | ||
1435 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | 1309 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); |
1436 | 1310 | ||
1437 | /* | 1311 | /* |