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()
129 /* Mark device node number vdev->num as used */
130 static inline void devnode_set(struct video_device *vdev) in devnode_set() argument
132 set_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_set()
135 /* Mark device node number vdev->num as unused */
136 static inline void devnode_clear(struct video_device *vdev) in devnode_clear() argument
138 clear_bit(vdev->num, devnode_bits(vdev->vfl_type)); in devnode_clear()
142 static inline int devnode_find(struct video_device *vdev, int from, int to) in devnode_find() argument
144 return find_next_zero_bit(devnode_bits(vdev->vfl_type), to, from); in devnode_find()
153 void video_device_release(struct video_device *vdev) in video_device_release() argument
155 kfree(vdev); in video_device_release()
159 void video_device_release_empty(struct video_device *vdev) in video_device_release_empty() argument
166 static inline void video_get(struct video_device *vdev) in video_get() argument
168 get_device(&vdev->dev); in video_get()
171 static inline void video_put(struct video_device *vdev) in video_put() argument
173 put_device(&vdev->dev); in video_put()
179 struct video_device *vdev = to_video_device(cd); in v4l2_device_release() local
180 struct v4l2_device *v4l2_dev = vdev->v4l2_dev; in v4l2_device_release()
183 if (WARN_ON(video_devices[vdev->minor] != vdev)) { in v4l2_device_release()
190 video_devices[vdev->minor] = NULL; in v4l2_device_release()
193 cdev_del(vdev->cdev); in v4l2_device_release()
196 vdev->cdev = NULL; in v4l2_device_release()
199 devnode_clear(vdev); in v4l2_device_release()
204 if (v4l2_dev->mdev && vdev->vfl_dir != VFL_DIR_M2M) { in v4l2_device_release()
206 media_devnode_remove(vdev->intf_devnode); in v4l2_device_release()
207 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) in v4l2_device_release()
208 media_device_unregister_entity(&vdev->entity); in v4l2_device_release()
225 vdev->release(vdev); in v4l2_device_release()
310 struct video_device *vdev = video_devdata(filp); in v4l2_read() local
313 if (!vdev->fops->read) in v4l2_read()
315 if (video_is_registered(vdev)) in v4l2_read()
316 ret = vdev->fops->read(filp, buf, sz, off); in v4l2_read()
317 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_read()
318 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_read()
320 video_device_node_name(vdev), sz, ret); in v4l2_read()
327 struct video_device *vdev = video_devdata(filp); in v4l2_write() local
330 if (!vdev->fops->write) in v4l2_write()
332 if (video_is_registered(vdev)) in v4l2_write()
333 ret = vdev->fops->write(filp, buf, sz, off); in v4l2_write()
334 if ((vdev->dev_debug & V4L2_DEV_DEBUG_FOP) && in v4l2_write()
335 (vdev->dev_debug & V4L2_DEV_DEBUG_STREAMING)) in v4l2_write()
337 video_device_node_name(vdev), sz, ret); in v4l2_write()
343 struct video_device *vdev = video_devdata(filp); in v4l2_poll() local
346 if (video_is_registered(vdev)) { in v4l2_poll()
347 if (!vdev->fops->poll) in v4l2_poll()
350 res = vdev->fops->poll(filp, poll); in v4l2_poll()
352 if (vdev->dev_debug & V4L2_DEV_DEBUG_POLL) in v4l2_poll()
354 video_device_node_name(vdev), res, in v4l2_poll()
361 struct video_device *vdev = video_devdata(filp); in v4l2_ioctl() local
364 if (vdev->fops->unlocked_ioctl) { in v4l2_ioctl()
365 if (video_is_registered(vdev)) in v4l2_ioctl()
366 ret = vdev->fops->unlocked_ioctl(filp, cmd, arg); in v4l2_ioctl()
380 struct video_device *vdev = video_devdata(filp); in v4l2_get_unmapped_area() local
383 if (!vdev->fops->get_unmapped_area) in v4l2_get_unmapped_area()
385 if (!video_is_registered(vdev)) in v4l2_get_unmapped_area()
387 ret = vdev->fops->get_unmapped_area(filp, addr, len, pgoff, flags); in v4l2_get_unmapped_area()
388 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_get_unmapped_area()
390 video_device_node_name(vdev), ret); in v4l2_get_unmapped_area()
397 struct video_device *vdev = video_devdata(filp); in v4l2_mmap() local
400 if (!vdev->fops->mmap) in v4l2_mmap()
402 if (video_is_registered(vdev)) in v4l2_mmap()
403 ret = vdev->fops->mmap(filp, vm); in v4l2_mmap()
404 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_mmap()
406 video_device_node_name(vdev), ret); in v4l2_mmap()
413 struct video_device *vdev; in v4l2_open() local
418 vdev = video_devdata(filp); in v4l2_open()
420 if (vdev == NULL || !video_is_registered(vdev)) { in v4l2_open()
425 video_get(vdev); in v4l2_open()
427 if (vdev->fops->open) { in v4l2_open()
428 if (video_is_registered(vdev)) in v4l2_open()
429 ret = vdev->fops->open(filp); in v4l2_open()
434 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_open()
436 video_device_node_name(vdev), ret); in v4l2_open()
439 video_put(vdev); in v4l2_open()
446 struct video_device *vdev = video_devdata(filp); in v4l2_release() local
455 if (vdev->fops->release) { in v4l2_release()
456 if (v4l2_device_supports_requests(vdev->v4l2_dev)) { in v4l2_release()
457 mutex_lock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
458 ret = vdev->fops->release(filp); in v4l2_release()
459 mutex_unlock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
461 ret = vdev->fops->release(filp); in v4l2_release()
465 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_release()
467 video_device_node_name(vdev)); in v4l2_release()
471 video_put(vdev); in v4l2_release()
492 * @vdev: video_device to assign index number to, vdev->v4l2_dev should be assigned
503 static int get_index(struct video_device *vdev) in get_index() argument
514 video_devices[i]->v4l2_dev == vdev->v4l2_dev) { in get_index()
530 vdev->valid_ioctls. If an ioctl is marked as 1 when this function is
536 vdev->valid_ioctls = valid_ioctls & ~(vdev->valid_ioctls)
538 static void determine_valid_ioctls(struct video_device *vdev) in determine_valid_ioctls() argument
548 const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; in determine_valid_ioctls()
549 bool is_vid = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
550 (vdev->device_caps & vid_caps); in determine_valid_ioctls()
551 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; in determine_valid_ioctls()
552 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; in determine_valid_ioctls()
553 bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR; in determine_valid_ioctls()
554 bool is_tch = vdev->vfl_type == VFL_TYPE_TOUCH; in determine_valid_ioctls()
555 bool is_meta = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
556 (vdev->device_caps & meta_caps); in determine_valid_ioctls()
557 bool is_rx = vdev->vfl_dir != VFL_DIR_TX; in determine_valid_ioctls()
558 bool is_tx = vdev->vfl_dir != VFL_DIR_RX; in determine_valid_ioctls()
559 bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC; in determine_valid_ioctls()
560 bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING; in determine_valid_ioctls()
561 bool is_edid = vdev->device_caps & V4L2_CAP_EDID; in determine_valid_ioctls()
575 if (vdev->ctrl_handler || ops->vidioc_queryctrl) in determine_valid_ioctls()
577 if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl) in determine_valid_ioctls()
579 if (vdev->ctrl_handler || ops->vidioc_g_ctrl || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
581 if (vdev->ctrl_handler || ops->vidioc_s_ctrl || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
583 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
585 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
587 if (vdev->ctrl_handler || ops->vidioc_try_ext_ctrls) in determine_valid_ioctls()
589 if (vdev->ctrl_handler || ops->vidioc_querymenu) in determine_valid_ioctls()
648 !test_bit(_IOC_NR(VIDIOC_G_SELECTION), vdev->valid_ioctls)) { in determine_valid_ioctls()
653 !test_bit(_IOC_NR(VIDIOC_S_SELECTION), vdev->valid_ioctls)) in determine_valid_ioctls()
804 bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, in determine_valid_ioctls()
808 static int video_register_media_controller(struct video_device *vdev) in video_register_media_controller() argument
817 if (!vdev->v4l2_dev->mdev || vdev->vfl_dir == VFL_DIR_M2M) in video_register_media_controller()
820 vdev->entity.obj_type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE; in video_register_media_controller()
821 vdev->entity.function = MEDIA_ENT_F_UNKNOWN; in video_register_media_controller()
823 switch (vdev->vfl_type) { in video_register_media_controller()
826 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
830 vdev->entity.function = MEDIA_ENT_F_IO_VBI; in video_register_media_controller()
834 vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO; in video_register_media_controller()
838 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
856 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
857 vdev->entity.name = vdev->name; in video_register_media_controller()
860 vdev->entity.info.dev.major = VIDEO_MAJOR; in video_register_media_controller()
861 vdev->entity.info.dev.minor = vdev->minor; in video_register_media_controller()
863 ret = media_device_register_entity(vdev->v4l2_dev->mdev, in video_register_media_controller()
864 &vdev->entity); in video_register_media_controller()
872 vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev, in video_register_media_controller()
875 vdev->minor); in video_register_media_controller()
876 if (!vdev->intf_devnode) { in video_register_media_controller()
877 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
881 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
884 link = media_create_intf_link(&vdev->entity, in video_register_media_controller()
885 &vdev->intf_devnode->intf, in video_register_media_controller()
889 media_devnode_remove(vdev->intf_devnode); in video_register_media_controller()
890 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
901 int __video_register_device(struct video_device *vdev, in __video_register_device() argument
914 vdev->minor = -1; in __video_register_device()
917 if (WARN_ON(!vdev->release)) in __video_register_device()
920 if (WARN_ON(!vdev->v4l2_dev)) in __video_register_device()
923 if (WARN_ON(type != VFL_TYPE_SUBDEV && !vdev->device_caps)) in __video_register_device()
927 spin_lock_init(&vdev->fh_lock); in __video_register_device()
928 INIT_LIST_HEAD(&vdev->fh_list); in __video_register_device()
957 vdev->vfl_type = type; in __video_register_device()
958 vdev->cdev = NULL; in __video_register_device()
959 if (vdev->dev_parent == NULL) in __video_register_device()
960 vdev->dev_parent = vdev->v4l2_dev->dev; in __video_register_device()
961 if (vdev->ctrl_handler == NULL) in __video_register_device()
962 vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; in __video_register_device()
965 if (vdev->prio == NULL) in __video_register_device()
966 vdev->prio = &vdev->v4l2_dev->prio; in __video_register_device()
997 nr = devnode_find(vdev, nr == -1 ? 0 : nr, minor_cnt); in __video_register_device()
999 nr = devnode_find(vdev, 0, minor_cnt); in __video_register_device()
1020 vdev->minor = i + minor_offset; in __video_register_device()
1021 vdev->num = nr; in __video_register_device()
1024 if (WARN_ON(video_devices[vdev->minor])) { in __video_register_device()
1029 devnode_set(vdev); in __video_register_device()
1030 vdev->index = get_index(vdev); in __video_register_device()
1031 video_devices[vdev->minor] = vdev; in __video_register_device()
1034 if (vdev->ioctl_ops) in __video_register_device()
1035 determine_valid_ioctls(vdev); in __video_register_device()
1038 vdev->cdev = cdev_alloc(); in __video_register_device()
1039 if (vdev->cdev == NULL) { in __video_register_device()
1043 vdev->cdev->ops = &v4l2_fops; in __video_register_device()
1044 vdev->cdev->owner = owner; in __video_register_device()
1045 ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1); in __video_register_device()
1048 kfree(vdev->cdev); in __video_register_device()
1049 vdev->cdev = NULL; in __video_register_device()
1054 vdev->dev.class = &video_class; in __video_register_device()
1055 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); in __video_register_device()
1056 vdev->dev.parent = vdev->dev_parent; in __video_register_device()
1057 dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); in __video_register_device()
1059 ret = device_register(&vdev->dev); in __video_register_device()
1067 vdev->dev.release = v4l2_device_release; in __video_register_device()
1069 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) in __video_register_device()
1071 name_base, nr, video_device_node_name(vdev)); in __video_register_device()
1074 v4l2_device_get(vdev->v4l2_dev); in __video_register_device()
1077 ret = video_register_media_controller(vdev); in __video_register_device()
1080 set_bit(V4L2_FL_REGISTERED, &vdev->flags); in __video_register_device()
1087 if (vdev->cdev) in __video_register_device()
1088 cdev_del(vdev->cdev); in __video_register_device()
1089 video_devices[vdev->minor] = NULL; in __video_register_device()
1090 devnode_clear(vdev); in __video_register_device()
1093 vdev->minor = -1; in __video_register_device()
1100 * @vdev: the device to unregister
1105 void video_unregister_device(struct video_device *vdev) in video_unregister_device() argument
1107 /* Check if vdev was ever registered at all */ in video_unregister_device()
1108 if (!vdev || !video_is_registered(vdev)) in video_unregister_device()
1115 clear_bit(V4L2_FL_REGISTERED, &vdev->flags); in video_unregister_device()
1117 if (test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags)) in video_unregister_device()
1118 v4l2_event_wake_all(vdev); in video_unregister_device()
1119 device_unregister(&vdev->dev); in video_unregister_device()
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 __must_check int __video_device_pipeline_start(struct video_device *vdev, in __video_device_pipeline_start() argument
1150 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_start()
1159 void video_device_pipeline_stop(struct video_device *vdev) in video_device_pipeline_stop() argument
1161 struct media_entity *entity = &vdev->entity; in video_device_pipeline_stop()
1170 void __video_device_pipeline_stop(struct video_device *vdev) in __video_device_pipeline_stop() argument
1172 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_stop()
1181 __must_check int video_device_pipeline_alloc_start(struct video_device *vdev) in video_device_pipeline_alloc_start() argument
1183 struct media_entity *entity = &vdev->entity; in video_device_pipeline_alloc_start()
1192 struct media_pipeline *video_device_pipeline(struct video_device *vdev) in video_device_pipeline() argument
1194 struct media_entity *entity = &vdev->entity; in video_device_pipeline()