Lines Matching refs:vdev
44 struct video_device *vdev = to_video_device(cd); in index_show() local
46 return sprintf(buf, "%i\n", vdev->index); in index_show()
53 struct video_device *vdev = to_video_device(cd); in dev_debug_show() local
55 return sprintf(buf, "%i\n", vdev->dev_debug); in dev_debug_show()
61 struct video_device *vdev = to_video_device(cd); in dev_debug_store() local
69 vdev->dev_debug = value; in dev_debug_store()
77 struct video_device *vdev = to_video_device(cd); in name_show() local
79 return sprintf(buf, "%.*s\n", (int)sizeof(vdev->name), vdev->name); in name_show()
123 static inline void devnode_set(struct video_device *vdev) in devnode_set() argument
125 set_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_set()
129 static inline void devnode_clear(struct video_device *vdev) in devnode_clear() argument
131 clear_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_clear()
135 static inline int devnode_find(struct video_device *vdev, int from, int to) in devnode_find() argument
137 return find_next_zero_bit(devnode_bits(vdev->vfl_type), to, from); in devnode_find()
146 void video_device_release(struct video_device *vdev) in video_device_release() argument
148 kfree(vdev); in video_device_release()
152 void video_device_release_empty(struct video_device *vdev) in video_device_release_empty() argument
159 static inline void video_get(struct video_device *vdev) in video_get() argument
161 get_device(&vdev->dev); in video_get()
164 static inline void video_put(struct video_device *vdev) in video_put() argument
166 put_device(&vdev->dev); in video_put()
172 struct video_device *vdev = to_video_device(cd); in v4l2_device_release() local
173 struct v4l2_device *v4l2_dev = vdev->v4l2_dev; in v4l2_device_release()
176 if (WARN_ON(video_device[vdev->minor] != vdev)) { in v4l2_device_release()
183 video_device[vdev->minor] = NULL; in v4l2_device_release()
186 cdev_del(vdev->cdev); in v4l2_device_release()
189 vdev->cdev = NULL; in v4l2_device_release()
192 devnode_clear(vdev); in v4l2_device_release()
198 vdev->vfl_type != VFL_TYPE_SUBDEV) in v4l2_device_release()
199 media_device_unregister_entity(&vdev->entity); in v4l2_device_release()
215 vdev->release(vdev); in v4l2_device_release()
300 struct video_device *vdev = video_devdata(filp); in v4l2_read() local
303 if (!vdev->fops->read) in v4l2_read()
305 if (video_is_registered(vdev)) in v4l2_read()
306 ret = vdev->fops->read(filp, buf, sz, off); in v4l2_read()
307 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_read()
308 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_read()
310 video_device_node_name(vdev), sz, ret); in v4l2_read()
317 struct video_device *vdev = video_devdata(filp); in v4l2_write() local
320 if (!vdev->fops->write) in v4l2_write()
322 if (video_is_registered(vdev)) in v4l2_write()
323 ret = vdev->fops->write(filp, buf, sz, off); in v4l2_write()
324 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_write()
325 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_write()
327 video_device_node_name(vdev), sz, ret); in v4l2_write()
333 struct video_device *vdev = video_devdata(filp); in v4l2_poll() local
336 if (!vdev->fops->poll) in v4l2_poll()
338 if (video_is_registered(vdev)) in v4l2_poll()
339 res = vdev->fops->poll(filp, poll); in v4l2_poll()
340 if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL) in v4l2_poll()
342 video_device_node_name(vdev), res); in v4l2_poll()
348 struct video_device *vdev = video_devdata(filp); in v4l2_ioctl() local
351 if (vdev->fops->unlocked_ioctl) { in v4l2_ioctl()
352 struct mutex *lock = v4l2_ioctl_get_lock(vdev, cmd); in v4l2_ioctl()
356 if (video_is_registered(vdev)) in v4l2_ioctl()
357 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); in v4l2_ioctl()
373 struct video_device *vdev = video_devdata(filp); in v4l2_get_unmapped_area() local
376 if (!vdev->fops->get_unmapped_area) in v4l2_get_unmapped_area()
378 if (!video_is_registered(vdev)) in v4l2_get_unmapped_area()
380 ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); in v4l2_get_unmapped_area()
381 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_get_unmapped_area()
383 video_device_node_name(vdev), ret); in v4l2_get_unmapped_area()
390 struct video_device *vdev = video_devdata(filp); in v4l2_mmap() local
393 if (!vdev->fops->mmap) in v4l2_mmap()
395 if (video_is_registered(vdev)) in v4l2_mmap()
396 ret = vdev->fops->mmap(filp, vm); in v4l2_mmap()
397 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_mmap()
399 video_device_node_name(vdev), ret); in v4l2_mmap()
406 struct video_device *vdev; in v4l2_open() local
411 vdev = video_devdata(filp); in v4l2_open()
413 if (vdev == NULL || !video_is_registered(vdev)) { in v4l2_open()
418 video_get(vdev); in v4l2_open()
420 if (vdev->fops->open) { in v4l2_open()
421 if (video_is_registered(vdev)) in v4l2_open()
422 ret = vdev->fops->open(filp); in v4l2_open()
427 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_open()
429 video_device_node_name(vdev), ret); in v4l2_open()
432 video_put(vdev); in v4l2_open()
439 struct video_device *vdev = video_devdata(filp); in v4l2_release() local
442 if (vdev->fops->release) in v4l2_release()
443 ret = vdev->fops->release(filp); in v4l2_release()
444 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_release()
446 video_device_node_name(vdev)); in v4l2_release()
450 video_put(vdev); in v4l2_release()
483 static int get_index(struct video_device *vdev) in get_index() argument
494 video_device[i]->v4l2_dev == vdev->v4l2_dev) { in get_index()
519 static void determine_valid_ioctls(struct video_device *vdev) in determine_valid_ioctls() argument
522 const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; in determine_valid_ioctls()
523 bool is_vid = vdev->vfl_type == VFL_TYPE_GRABBER; in determine_valid_ioctls()
524 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; in determine_valid_ioctls()
525 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; in determine_valid_ioctls()
526 bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR; in determine_valid_ioctls()
527 bool is_rx = vdev->vfl_dir != VFL_DIR_TX; in determine_valid_ioctls()
528 bool is_tx = vdev->vfl_dir != VFL_DIR_RX; in determine_valid_ioctls()
542 if (vdev->ctrl_handler || ops->vidioc_queryctrl) in determine_valid_ioctls()
544 if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl) in determine_valid_ioctls()
546 if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
548 if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
550 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
552 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
554 if (vdev->ctrl_handler || ops->vidioc_try_ext_ctrls) in determine_valid_ioctls()
556 if (vdev->ctrl_handler || ops->vidioc_querymenu) in determine_valid_ioctls()
690 if (ops->vidioc_g_parm || (vdev->vfl_type == VFL_TYPE_GRABBER && in determine_valid_ioctls()
712 bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, in determine_valid_ioctls()
750 int __video_register_device(struct video_device *vdev, int type, int nr, in __video_register_device() argument
761 vdev->minor = -1; in __video_register_device()
764 if (WARN_ON(!vdev->release)) in __video_register_device()
767 if (WARN_ON(!vdev->v4l2_dev)) in __video_register_device()
771 spin_lock_init(&vdev->fh_lock); in __video_register_device()
772 INIT_LIST_HEAD(&vdev->fh_list); in __video_register_device()
798 vdev->vfl_type = type; in __video_register_device()
799 vdev->cdev = NULL; in __video_register_device()
800 if (vdev->dev_parent == NULL) in __video_register_device()
801 vdev->dev_parent = vdev->v4l2_dev->dev; in __video_register_device()
802 if (vdev->ctrl_handler == NULL) in __video_register_device()
803 vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; in __video_register_device()
806 if (vdev->prio == NULL) in __video_register_device()
807 vdev->prio = &vdev->v4l2_dev->prio; in __video_register_device()
838 nr = devnode_find(vdev, nr == -1 ? 0 : nr, minor_cnt); in __video_register_device()
840 nr = devnode_find(vdev, 0, minor_cnt); in __video_register_device()
861 vdev->minor = i + minor_offset; in __video_register_device()
862 vdev->num = nr; in __video_register_device()
863 devnode_set(vdev); in __video_register_device()
866 WARN_ON(video_device[vdev->minor] != NULL); in __video_register_device()
867 vdev->index = get_index(vdev); in __video_register_device()
868 video_device[vdev->minor] = vdev; in __video_register_device()
871 if (vdev->ioctl_ops) in __video_register_device()
872 determine_valid_ioctls(vdev); in __video_register_device()
875 vdev->cdev = cdev_alloc(); in __video_register_device()
876 if (vdev->cdev == NULL) { in __video_register_device()
880 vdev->cdev->ops = &v4l2_fops; in __video_register_device()
881 vdev->cdev->owner = owner; in __video_register_device()
882 ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1); in __video_register_device()
885 kfree(vdev->cdev); in __video_register_device()
886 vdev->cdev = NULL; in __video_register_device()
891 vdev->dev.class = &video_class; in __video_register_device()
892 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); in __video_register_device()
893 vdev->dev.parent = vdev->dev_parent; in __video_register_device()
894 dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); in __video_register_device()
895 ret = device_register(&vdev->dev); in __video_register_device()
902 vdev->dev.release = v4l2_device_release; in __video_register_device()
904 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) in __video_register_device()
906 name_base, nr, video_device_node_name(vdev)); in __video_register_device()
909 v4l2_device_get(vdev->v4l2_dev); in __video_register_device()
913 if (vdev->v4l2_dev->mdev && in __video_register_device()
914 vdev->vfl_type != VFL_TYPE_SUBDEV) { in __video_register_device()
915 vdev->entity.type = MEDIA_ENT_T_DEVNODE_V4L; in __video_register_device()
916 vdev->entity.name = vdev->name; in __video_register_device()
917 vdev->entity.info.dev.major = VIDEO_MAJOR; in __video_register_device()
918 vdev->entity.info.dev.minor = vdev->minor; in __video_register_device()
919 ret = media_device_register_entity(vdev->v4l2_dev->mdev, in __video_register_device()
920 &vdev->entity); in __video_register_device()
928 set_bit(V4L2_FL_REGISTERED, &vdev->flags); in __video_register_device()
934 if (vdev->cdev) in __video_register_device()
935 cdev_del(vdev->cdev); in __video_register_device()
936 video_device[vdev->minor] = NULL; in __video_register_device()
937 devnode_clear(vdev); in __video_register_device()
940 vdev->minor = -1; in __video_register_device()
952 void video_unregister_device(struct video_device *vdev) in video_unregister_device() argument
955 if (!vdev || !video_is_registered(vdev)) in video_unregister_device()
962 clear_bit(V4L2_FL_REGISTERED, &vdev->flags); in video_unregister_device()
964 device_unregister(&vdev->dev); in video_unregister_device()