Lines Matching full:vdev
49 struct video_device *vdev = to_video_device(cd); in index_show() local
51 return sprintf(buf, "%i\n", vdev->index); in index_show()
58 struct video_device *vdev = to_video_device(cd); in dev_debug_show() local
60 return sprintf(buf, "%i\n", vdev->dev_debug); in dev_debug_show()
66 struct video_device *vdev = to_video_device(cd); in dev_debug_store() local
74 vdev->dev_debug = value; in dev_debug_store()
82 struct video_device *vdev = to_video_device(cd); in name_show() local
84 return sprintf(buf, "%.*s\n", (int)sizeof(vdev->name), vdev->name); in name_show()
127 /* Mark device node number vdev->num as used */
128 static inline void devnode_set(struct video_device *vdev) in devnode_set() argument
130 set_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_set()
133 /* Mark device node number vdev->num as unused */
134 static inline void devnode_clear(struct video_device *vdev) in devnode_clear() argument
136 clear_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_clear()
140 static inline int devnode_find(struct video_device *vdev, int from, int to) in devnode_find() argument
142 return find_next_zero_bit(devnode_bits(vdev->vfl_type), to, from); in devnode_find()
151 void video_device_release(struct video_device *vdev) in video_device_release() argument
153 kfree(vdev); in video_device_release()
157 void video_device_release_empty(struct video_device *vdev) in video_device_release_empty() argument
164 static inline void video_get(struct video_device *vdev) in video_get() argument
166 get_device(&vdev->dev); in video_get()
169 static inline void video_put(struct video_device *vdev) in video_put() argument
171 put_device(&vdev->dev); in video_put()
177 struct video_device *vdev = to_video_device(cd); in v4l2_device_release() local
178 struct v4l2_device *v4l2_dev = vdev->v4l2_dev; in v4l2_device_release()
181 if (WARN_ON(video_devices[vdev->minor] != vdev)) { in v4l2_device_release()
188 video_devices[vdev->minor] = NULL; in v4l2_device_release()
191 cdev_del(vdev->cdev); in v4l2_device_release()
194 vdev->cdev = NULL; in v4l2_device_release()
197 devnode_clear(vdev); in v4l2_device_release()
202 if (v4l2_dev->mdev && vdev->vfl_dir != VFL_DIR_M2M) { in v4l2_device_release()
204 media_devnode_remove(vdev->intf_devnode); in v4l2_device_release()
205 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) in v4l2_device_release()
206 media_device_unregister_entity(&vdev->entity); in v4l2_device_release()
223 vdev->release(vdev); in v4l2_device_release()
308 struct video_device *vdev = video_devdata(filp); in v4l2_read() local
311 if (!vdev->fops->read) in v4l2_read()
313 if (video_is_registered(vdev)) in v4l2_read()
314 ret = vdev->fops->read(filp, buf, sz, off); in v4l2_read()
315 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_read()
316 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_read()
318 video_device_node_name(vdev), sz, ret); in v4l2_read()
325 struct video_device *vdev = video_devdata(filp); in v4l2_write() local
328 if (!vdev->fops->write) in v4l2_write()
330 if (video_is_registered(vdev)) in v4l2_write()
331 ret = vdev->fops->write(filp, buf, sz, off); in v4l2_write()
332 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_write()
333 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_write()
335 video_device_node_name(vdev), sz, ret); in v4l2_write()
341 struct video_device *vdev = video_devdata(filp); in v4l2_poll() local
344 if (video_is_registered(vdev)) { in v4l2_poll()
345 if (!vdev->fops->poll) in v4l2_poll()
348 res = vdev->fops->poll(filp, poll); in v4l2_poll()
350 if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL) in v4l2_poll()
352 video_device_node_name(vdev), res, in v4l2_poll()
359 struct video_device *vdev = video_devdata(filp); in v4l2_ioctl() local
362 if (vdev->fops->unlocked_ioctl) { in v4l2_ioctl()
363 if (video_is_registered(vdev)) in v4l2_ioctl()
364 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); in v4l2_ioctl()
378 struct video_device *vdev = video_devdata(filp); in v4l2_get_unmapped_area() local
381 if (!vdev->fops->get_unmapped_area) in v4l2_get_unmapped_area()
383 if (!video_is_registered(vdev)) in v4l2_get_unmapped_area()
385 ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); in v4l2_get_unmapped_area()
386 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_get_unmapped_area()
388 video_device_node_name(vdev), ret); in v4l2_get_unmapped_area()
395 struct video_device *vdev = video_devdata(filp); in v4l2_mmap() local
398 if (!vdev->fops->mmap) in v4l2_mmap()
400 if (video_is_registered(vdev)) in v4l2_mmap()
401 ret = vdev->fops->mmap(filp, vm); in v4l2_mmap()
402 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_mmap()
404 video_device_node_name(vdev), ret); in v4l2_mmap()
411 struct video_device *vdev; in v4l2_open() local
416 vdev = video_devdata(filp); in v4l2_open()
418 if (vdev == NULL || !video_is_registered(vdev)) { in v4l2_open()
423 video_get(vdev); in v4l2_open()
425 if (vdev->fops->open) { in v4l2_open()
426 if (video_is_registered(vdev)) in v4l2_open()
427 ret = vdev->fops->open(filp); in v4l2_open()
432 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_open()
434 video_device_node_name(vdev), ret); in v4l2_open()
437 video_put(vdev); in v4l2_open()
444 struct video_device *vdev = video_devdata(filp); in v4l2_release() local
453 if (vdev->fops->release) { in v4l2_release()
454 if (v4l2_device_supports_requests(vdev->v4l2_dev)) { in v4l2_release()
455 mutex_lock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
456 ret = vdev->fops->release(filp); in v4l2_release()
457 mutex_unlock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
459 ret = vdev->fops->release(filp); in v4l2_release()
463 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_release()
465 video_device_node_name(vdev)); in v4l2_release()
469 video_put(vdev); in v4l2_release()
490 * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned
501 static int get_index(struct video_device *vdev) in get_index() argument
512 video_devices[i]->v4l2_dev == vdev->v4l2_dev) { in get_index()
528 vdev->valid_ioctls. If an ioctl is marked as 1 when this function is
534 vdev->valid_ioctls = valid_ioctls & ~(vdev->valid_ioctls)
536 static void determine_valid_ioctls(struct video_device *vdev) in determine_valid_ioctls() argument
546 const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; in determine_valid_ioctls()
547 bool is_vid = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
548 (vdev->device_caps & vid_caps); in determine_valid_ioctls()
549 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; in determine_valid_ioctls()
550 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; in determine_valid_ioctls()
551 bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR; in determine_valid_ioctls()
552 bool is_tch = vdev->vfl_type == VFL_TYPE_TOUCH; in determine_valid_ioctls()
553 bool is_meta = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
554 (vdev->device_caps & meta_caps); in determine_valid_ioctls()
555 bool is_rx = vdev->vfl_dir != VFL_DIR_TX; in determine_valid_ioctls()
556 bool is_tx = vdev->vfl_dir != VFL_DIR_RX; in determine_valid_ioctls()
557 bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC; in determine_valid_ioctls()
558 bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING; in determine_valid_ioctls()
559 bool is_edid = vdev->device_caps & V4L2_CAP_EDID; in determine_valid_ioctls()
573 if (vdev->ctrl_handler || ops->vidioc_queryctrl) in determine_valid_ioctls()
575 if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl) in determine_valid_ioctls()
577 if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
579 if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
581 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
583 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
585 if (vdev->ctrl_handler || ops->vidioc_try_ext_ctrls) in determine_valid_ioctls()
587 if (vdev->ctrl_handler || ops->vidioc_querymenu) in determine_valid_ioctls()
646 !test_bit(_IOC_NR(VIDIOC_G_SELECTION), vdev->valid_ioctls)) { in determine_valid_ioctls()
651 !test_bit(_IOC_NR(VIDIOC_S_SELECTION), vdev->valid_ioctls)) in determine_valid_ioctls()
802 bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, in determine_valid_ioctls()
806 static int video_register_media_controller(struct video_device *vdev) in video_register_media_controller() argument
815 if (!vdev->v4l2_dev->mdev || vdev->vfl_dir == VFL_DIR_M2M) in video_register_media_controller()
818 vdev->entity.obj_type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE; in video_register_media_controller()
819 vdev->entity.function = MEDIA_ENT_F_UNKNOWN; in video_register_media_controller()
821 switch (vdev->vfl_type) { in video_register_media_controller()
824 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
828 vdev->entity.function = MEDIA_ENT_F_IO_VBI; in video_register_media_controller()
832 vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO; in video_register_media_controller()
836 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
854 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
855 vdev->entity.name = vdev->name; in video_register_media_controller()
858 vdev->entity.info.dev.major = VIDEO_MAJOR; in video_register_media_controller()
859 vdev->entity.info.dev.minor = vdev->minor; in video_register_media_controller()
861 ret = media_device_register_entity(vdev->v4l2_dev->mdev, in video_register_media_controller()
862 &vdev->entity); in video_register_media_controller()
870 vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev, in video_register_media_controller()
873 vdev->minor); in video_register_media_controller()
874 if (!vdev->intf_devnode) { in video_register_media_controller()
875 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
879 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
882 link = media_create_intf_link(&vdev->entity, in video_register_media_controller()
883 &vdev->intf_devnode->intf, in video_register_media_controller()
887 media_devnode_remove(vdev->intf_devnode); in video_register_media_controller()
888 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
899 int __video_register_device(struct video_device *vdev, in __video_register_device() argument
912 vdev->minor = -1; in __video_register_device()
915 if (WARN_ON(!vdev->release)) in __video_register_device()
918 if (WARN_ON(!vdev->v4l2_dev)) in __video_register_device()
921 if (WARN_ON(type != VFL_TYPE_SUBDEV && !vdev->device_caps)) in __video_register_device()
925 spin_lock_init(&vdev->fh_lock); in __video_register_device()
926 INIT_LIST_HEAD(&vdev->fh_list); in __video_register_device()
955 vdev->vfl_type = type; in __video_register_device()
956 vdev->cdev = NULL; in __video_register_device()
957 if (vdev->dev_parent == NULL) in __video_register_device()
958 vdev->dev_parent = vdev->v4l2_dev->dev; in __video_register_device()
959 if (vdev->ctrl_handler == NULL) in __video_register_device()
960 vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; in __video_register_device()
963 if (vdev->prio == NULL) in __video_register_device()
964 vdev->prio = &vdev->v4l2_dev->prio; in __video_register_device()
995 nr = devnode_find(vdev, nr == -1 ? 0 : nr, minor_cnt); in __video_register_device()
997 nr = devnode_find(vdev, 0, minor_cnt); in __video_register_device()
1018 vdev->minor = i + minor_offset; in __video_register_device()
1019 vdev->num = nr; in __video_register_device()
1022 if (WARN_ON(video_devices[vdev->minor])) { in __video_register_device()
1027 devnode_set(vdev); in __video_register_device()
1028 vdev->index = get_index(vdev); in __video_register_device()
1029 video_devices[vdev->minor] = vdev; in __video_register_device()
1032 if (vdev->ioctl_ops) in __video_register_device()
1033 determine_valid_ioctls(vdev); in __video_register_device()
1036 vdev->cdev = cdev_alloc(); in __video_register_device()
1037 if (vdev->cdev == NULL) { in __video_register_device()
1041 vdev->cdev->ops = &v4l2_fops; in __video_register_device()
1042 vdev->cdev->owner = owner; in __video_register_device()
1043 ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1); in __video_register_device()
1046 kfree(vdev->cdev); in __video_register_device()
1047 vdev->cdev = NULL; in __video_register_device()
1052 vdev->dev.class = &video_class; in __video_register_device()
1053 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); in __video_register_device()
1054 vdev->dev.parent = vdev->dev_parent; in __video_register_device()
1055 dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); in __video_register_device()
1057 ret = device_register(&vdev->dev); in __video_register_device()
1065 vdev->dev.release = v4l2_device_release; in __video_register_device()
1067 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) in __video_register_device()
1069 name_base, nr, video_device_node_name(vdev)); in __video_register_device()
1072 v4l2_device_get(vdev->v4l2_dev); in __video_register_device()
1075 ret = video_register_media_controller(vdev); in __video_register_device()
1078 set_bit(V4L2_FL_REGISTERED, &vdev->flags); in __video_register_device()
1085 if (vdev->cdev) in __video_register_device()
1086 cdev_del(vdev->cdev); in __video_register_device()
1087 video_devices[vdev->minor] = NULL; in __video_register_device()
1088 devnode_clear(vdev); in __video_register_device()
1091 vdev->minor = -1; in __video_register_device()
1098 * @vdev: the device to unregister
1103 void video_unregister_device(struct video_device *vdev) in video_unregister_device() argument
1105 /* Check if vdev was ever registered at all */ in video_unregister_device()
1106 if (!vdev || !video_is_registered(vdev)) in video_unregister_device()
1113 clear_bit(V4L2_FL_REGISTERED, &vdev->flags); in video_unregister_device()
1115 if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags)) in video_unregister_device()
1116 v4l2_event_wake_all(vdev); in video_unregister_device()
1117 device_unregister(&vdev->dev); in video_unregister_device()
1123 __must_check int video_device_pipeline_start(struct video_device *vdev, in video_device_pipeline_start() argument
1126 struct media_entity *entity = &vdev->entity; in video_device_pipeline_start()
1135 __must_check int __video_device_pipeline_start(struct video_device *vdev, in __video_device_pipeline_start() argument
1138 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_start()
1147 void video_device_pipeline_stop(struct video_device *vdev) in video_device_pipeline_stop() argument
1149 struct media_entity *entity = &vdev->entity; in video_device_pipeline_stop()
1158 void __video_device_pipeline_stop(struct video_device *vdev) in __video_device_pipeline_stop() argument
1160 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_stop()
1169 __must_check int video_device_pipeline_alloc_start(struct video_device *vdev) in video_device_pipeline_alloc_start() argument
1171 struct media_entity *entity = &vdev->entity; in video_device_pipeline_alloc_start()
1180 struct media_pipeline *video_device_pipeline(struct video_device *vdev) in video_device_pipeline() argument
1182 struct media_entity *entity = &vdev->entity; in video_device_pipeline()