Lines Matching refs: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()
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()
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()
428 if (!video_is_registered(vdev)) { in v4l2_open()
433 ret = vdev->fops->open(filp); in v4l2_open()
438 if (WARN_ON(!test_bit(V4L2_FL_USES_V4L2_FH, &vdev->flags))) { in v4l2_open()
439 vdev->fops->release(filp); in v4l2_open()
444 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_open()
446 video_device_node_name(vdev), ret); in v4l2_open()
450 video_put(vdev); in v4l2_open()
457 struct video_device *vdev = video_devdata(filp); in v4l2_release() local
466 if (v4l2_device_supports_requests(vdev->v4l2_dev)) { in v4l2_release()
467 mutex_lock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
468 ret = vdev->fops->release(filp); in v4l2_release()
469 mutex_unlock(&vdev->v4l2_dev->mdev->req_queue_mutex); in v4l2_release()
471 ret = vdev->fops->release(filp); in v4l2_release()
474 if (vdev->dev_debug & V4L2_DEV_DEBUG_FOP) in v4l2_release()
476 video_device_node_name(vdev)); in v4l2_release()
480 video_put(vdev); in v4l2_release()
512 static int get_index(struct video_device *vdev) in get_index() argument
523 video_devices[i]->v4l2_dev == vdev->v4l2_dev) { in get_index()
547 static void determine_valid_ioctls(struct video_device *vdev) in determine_valid_ioctls() argument
557 const struct v4l2_ioctl_ops *ops = vdev->ioctl_ops; in determine_valid_ioctls()
558 bool is_vid = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
559 (vdev->device_caps & vid_caps); in determine_valid_ioctls()
560 bool is_vbi = vdev->vfl_type == VFL_TYPE_VBI; in determine_valid_ioctls()
561 bool is_radio = vdev->vfl_type == VFL_TYPE_RADIO; in determine_valid_ioctls()
562 bool is_sdr = vdev->vfl_type == VFL_TYPE_SDR; in determine_valid_ioctls()
563 bool is_tch = vdev->vfl_type == VFL_TYPE_TOUCH; in determine_valid_ioctls()
564 bool is_meta = vdev->vfl_type == VFL_TYPE_VIDEO && in determine_valid_ioctls()
565 (vdev->device_caps & meta_caps); in determine_valid_ioctls()
566 bool is_rx = vdev->vfl_dir != VFL_DIR_TX; in determine_valid_ioctls()
567 bool is_tx = vdev->vfl_dir != VFL_DIR_RX; in determine_valid_ioctls()
568 bool is_io_mc = vdev->device_caps & V4L2_CAP_IO_MC; in determine_valid_ioctls()
569 bool has_streaming = vdev->device_caps & V4L2_CAP_STREAMING; in determine_valid_ioctls()
570 bool is_edid = vdev->device_caps & V4L2_CAP_EDID; in determine_valid_ioctls()
584 if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl) in determine_valid_ioctls()
586 if (vdev->ctrl_handler || ops->vidioc_query_ext_ctrl) in determine_valid_ioctls()
588 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
590 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
592 if (vdev->ctrl_handler || ops->vidioc_g_ext_ctrls) in determine_valid_ioctls()
594 if (vdev->ctrl_handler || ops->vidioc_s_ext_ctrls) in determine_valid_ioctls()
596 if (vdev->ctrl_handler || ops->vidioc_try_ext_ctrls) in determine_valid_ioctls()
598 if (vdev->ctrl_handler || ops->vidioc_querymenu) in determine_valid_ioctls()
657 !test_bit(_IOC_NR(VIDIOC_G_SELECTION), vdev->valid_ioctls)) { in determine_valid_ioctls()
662 !test_bit(_IOC_NR(VIDIOC_S_SELECTION), vdev->valid_ioctls)) in determine_valid_ioctls()
813 bitmap_andnot(vdev->valid_ioctls, valid_ioctls, vdev->valid_ioctls, in determine_valid_ioctls()
817 static int video_register_media_controller(struct video_device *vdev) in video_register_media_controller() argument
826 if (!vdev->v4l2_dev->mdev || vdev->vfl_dir == VFL_DIR_M2M) in video_register_media_controller()
829 vdev->entity.obj_type = MEDIA_ENTITY_TYPE_VIDEO_DEVICE; in video_register_media_controller()
830 vdev->entity.function = MEDIA_ENT_F_UNKNOWN; in video_register_media_controller()
832 switch (vdev->vfl_type) { in video_register_media_controller()
835 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
839 vdev->entity.function = MEDIA_ENT_F_IO_VBI; in video_register_media_controller()
843 vdev->entity.function = MEDIA_ENT_F_IO_SWRADIO; in video_register_media_controller()
847 vdev->entity.function = MEDIA_ENT_F_IO_V4L; in video_register_media_controller()
865 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
866 vdev->entity.name = vdev->name; in video_register_media_controller()
869 vdev->entity.info.dev.major = VIDEO_MAJOR; in video_register_media_controller()
870 vdev->entity.info.dev.minor = vdev->minor; in video_register_media_controller()
872 ret = media_device_register_entity(vdev->v4l2_dev->mdev, in video_register_media_controller()
873 &vdev->entity); in video_register_media_controller()
881 vdev->intf_devnode = media_devnode_create(vdev->v4l2_dev->mdev, in video_register_media_controller()
884 vdev->minor); in video_register_media_controller()
885 if (!vdev->intf_devnode) { in video_register_media_controller()
886 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
890 if (vdev->entity.function != MEDIA_ENT_F_UNKNOWN) { in video_register_media_controller()
893 link = media_create_intf_link(&vdev->entity, in video_register_media_controller()
894 &vdev->intf_devnode->intf, in video_register_media_controller()
898 media_devnode_remove(vdev->intf_devnode); in video_register_media_controller()
899 media_device_unregister_entity(&vdev->entity); in video_register_media_controller()
910 int __video_register_device(struct video_device *vdev, in __video_register_device() argument
923 vdev->minor = -1; in __video_register_device()
926 if (WARN_ON(!vdev->release)) in __video_register_device()
929 if (WARN_ON(!vdev->v4l2_dev)) in __video_register_device()
932 if (WARN_ON(type != VFL_TYPE_SUBDEV && !vdev->device_caps)) in __video_register_device()
935 if (WARN_ON(!vdev->fops || !vdev->fops->open || !vdev->fops->release)) in __video_register_device()
939 spin_lock_init(&vdev->fh_lock); in __video_register_device()
940 INIT_LIST_HEAD(&vdev->fh_list); in __video_register_device()
969 vdev->vfl_type = type; in __video_register_device()
970 vdev->cdev = NULL; in __video_register_device()
971 if (vdev->dev_parent == NULL) in __video_register_device()
972 vdev->dev_parent = vdev->v4l2_dev->dev; in __video_register_device()
973 if (vdev->ctrl_handler == NULL) in __video_register_device()
974 vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; in __video_register_device()
977 if (vdev->prio == NULL) in __video_register_device()
978 vdev->prio = &vdev->v4l2_dev->prio; in __video_register_device()
1009 nr = devnode_find(vdev, nr == -1 ? 0 : nr, minor_cnt); in __video_register_device()
1011 nr = devnode_find(vdev, 0, minor_cnt); in __video_register_device()
1032 vdev->minor = i + minor_offset; in __video_register_device()
1033 vdev->num = nr; in __video_register_device()
1036 if (WARN_ON(video_devices[vdev->minor])) { in __video_register_device()
1041 devnode_set(vdev); in __video_register_device()
1042 vdev->index = get_index(vdev); in __video_register_device()
1043 video_devices[vdev->minor] = vdev; in __video_register_device()
1046 if (vdev->ioctl_ops) in __video_register_device()
1047 determine_valid_ioctls(vdev); in __video_register_device()
1050 vdev->cdev = cdev_alloc(); in __video_register_device()
1051 if (vdev->cdev == NULL) { in __video_register_device()
1055 vdev->cdev->ops = &v4l2_fops; in __video_register_device()
1056 vdev->cdev->owner = owner; in __video_register_device()
1057 ret = cdev_add(vdev->cdev, MKDEV(VIDEO_MAJOR, vdev->minor), 1); in __video_register_device()
1060 kfree(vdev->cdev); in __video_register_device()
1061 vdev->cdev = NULL; in __video_register_device()
1066 vdev->dev.class = &video_class; in __video_register_device()
1067 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); in __video_register_device()
1068 vdev->dev.parent = vdev->dev_parent; in __video_register_device()
1069 vdev->dev.release = v4l2_device_release; in __video_register_device()
1070 dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num); in __video_register_device()
1073 v4l2_device_get(vdev->v4l2_dev); in __video_register_device()
1076 ret = device_register(&vdev->dev); in __video_register_device()
1080 put_device(&vdev->dev); in __video_register_device()
1084 if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) in __video_register_device()
1086 name_base, nr, video_device_node_name(vdev)); in __video_register_device()
1089 ret = video_register_media_controller(vdev); in __video_register_device()
1092 set_bit(V4L2_FL_REGISTERED, &vdev->flags); in __video_register_device()
1099 if (vdev->cdev) in __video_register_device()
1100 cdev_del(vdev->cdev); in __video_register_device()
1101 video_devices[vdev->minor] = NULL; in __video_register_device()
1102 devnode_clear(vdev); in __video_register_device()
1105 vdev->minor = -1; in __video_register_device()
1117 void video_unregister_device(struct video_device *vdev) in video_unregister_device() argument
1120 if (!vdev || !video_is_registered(vdev)) in video_unregister_device()
1127 clear_bit(V4L2_FL_REGISTERED, &vdev->flags); in video_unregister_device()
1129 v4l2_event_wake_all(vdev); in video_unregister_device()
1130 device_unregister(&vdev->dev); in video_unregister_device()
1146 __must_check int video_device_pipeline_start(struct video_device *vdev, in video_device_pipeline_start() argument
1149 struct media_entity *entity = &vdev->entity; in video_device_pipeline_start()
1158 __must_check int __video_device_pipeline_start(struct video_device *vdev, in __video_device_pipeline_start() argument
1161 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_start()
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 void __video_device_pipeline_stop(struct video_device *vdev) in __video_device_pipeline_stop() argument
1183 struct media_entity *entity = &vdev->entity; in __video_device_pipeline_stop()
1192 __must_check int video_device_pipeline_alloc_start(struct video_device *vdev) in video_device_pipeline_alloc_start() argument
1194 struct media_entity *entity = &vdev->entity; in video_device_pipeline_alloc_start()
1203 struct media_pipeline *video_device_pipeline(struct video_device *vdev) in video_device_pipeline() argument
1205 struct media_entity *entity = &vdev->entity; in video_device_pipeline()