diff options
Diffstat (limited to 'drivers/media/media-device.c')
-rw-r--r-- | drivers/media/media-device.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/drivers/media/media-device.c b/drivers/media/media-device.c index 3bae24b15eaa..4dd2b1dae03d 100644 --- a/drivers/media/media-device.c +++ b/drivers/media/media-device.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include <media/media-device.h> | 30 | #include <media/media-device.h> |
31 | #include <media/media-devnode.h> | 31 | #include <media/media-devnode.h> |
32 | #include <media/media-entity.h> | 32 | #include <media/media-entity.h> |
33 | #include <media/media-request.h> | ||
33 | 34 | ||
34 | #ifdef CONFIG_MEDIA_CONTROLLER | 35 | #ifdef CONFIG_MEDIA_CONTROLLER |
35 | 36 | ||
@@ -377,10 +378,19 @@ static long media_device_get_topology(struct media_device *mdev, void *arg) | |||
377 | return ret; | 378 | return ret; |
378 | } | 379 | } |
379 | 380 | ||
381 | static long media_device_request_alloc(struct media_device *mdev, | ||
382 | int *alloc_fd) | ||
383 | { | ||
384 | if (!mdev->ops || !mdev->ops->req_validate || !mdev->ops->req_queue) | ||
385 | return -ENOTTY; | ||
386 | |||
387 | return media_request_alloc(mdev, alloc_fd); | ||
388 | } | ||
389 | |||
380 | static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd) | 390 | static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd) |
381 | { | 391 | { |
382 | /* All media IOCTLs are _IOWR() */ | 392 | if ((_IOC_DIR(cmd) & _IOC_WRITE) && |
383 | if (copy_from_user(karg, uarg, _IOC_SIZE(cmd))) | 393 | copy_from_user(karg, uarg, _IOC_SIZE(cmd))) |
384 | return -EFAULT; | 394 | return -EFAULT; |
385 | 395 | ||
386 | return 0; | 396 | return 0; |
@@ -388,8 +398,8 @@ static long copy_arg_from_user(void *karg, void __user *uarg, unsigned int cmd) | |||
388 | 398 | ||
389 | static long copy_arg_to_user(void __user *uarg, void *karg, unsigned int cmd) | 399 | static long copy_arg_to_user(void __user *uarg, void *karg, unsigned int cmd) |
390 | { | 400 | { |
391 | /* All media IOCTLs are _IOWR() */ | 401 | if ((_IOC_DIR(cmd) & _IOC_READ) && |
392 | if (copy_to_user(uarg, karg, _IOC_SIZE(cmd))) | 402 | copy_to_user(uarg, karg, _IOC_SIZE(cmd))) |
393 | return -EFAULT; | 403 | return -EFAULT; |
394 | 404 | ||
395 | return 0; | 405 | return 0; |
@@ -425,6 +435,7 @@ static const struct media_ioctl_info ioctl_info[] = { | |||
425 | MEDIA_IOC(ENUM_LINKS, media_device_enum_links, MEDIA_IOC_FL_GRAPH_MUTEX), | 435 | MEDIA_IOC(ENUM_LINKS, media_device_enum_links, MEDIA_IOC_FL_GRAPH_MUTEX), |
426 | MEDIA_IOC(SETUP_LINK, media_device_setup_link, MEDIA_IOC_FL_GRAPH_MUTEX), | 436 | MEDIA_IOC(SETUP_LINK, media_device_setup_link, MEDIA_IOC_FL_GRAPH_MUTEX), |
427 | MEDIA_IOC(G_TOPOLOGY, media_device_get_topology, MEDIA_IOC_FL_GRAPH_MUTEX), | 437 | MEDIA_IOC(G_TOPOLOGY, media_device_get_topology, MEDIA_IOC_FL_GRAPH_MUTEX), |
438 | MEDIA_IOC(REQUEST_ALLOC, media_device_request_alloc, 0), | ||
428 | }; | 439 | }; |
429 | 440 | ||
430 | static long media_device_ioctl(struct file *filp, unsigned int cmd, | 441 | static long media_device_ioctl(struct file *filp, unsigned int cmd, |
@@ -691,9 +702,13 @@ void media_device_init(struct media_device *mdev) | |||
691 | INIT_LIST_HEAD(&mdev->pads); | 702 | INIT_LIST_HEAD(&mdev->pads); |
692 | INIT_LIST_HEAD(&mdev->links); | 703 | INIT_LIST_HEAD(&mdev->links); |
693 | INIT_LIST_HEAD(&mdev->entity_notify); | 704 | INIT_LIST_HEAD(&mdev->entity_notify); |
705 | |||
706 | mutex_init(&mdev->req_queue_mutex); | ||
694 | mutex_init(&mdev->graph_mutex); | 707 | mutex_init(&mdev->graph_mutex); |
695 | ida_init(&mdev->entity_internal_idx); | 708 | ida_init(&mdev->entity_internal_idx); |
696 | 709 | ||
710 | atomic_set(&mdev->request_id, 0); | ||
711 | |||
697 | dev_dbg(mdev->dev, "Media device initialized\n"); | 712 | dev_dbg(mdev->dev, "Media device initialized\n"); |
698 | } | 713 | } |
699 | EXPORT_SYMBOL_GPL(media_device_init); | 714 | EXPORT_SYMBOL_GPL(media_device_init); |
@@ -704,6 +719,7 @@ void media_device_cleanup(struct media_device *mdev) | |||
704 | mdev->entity_internal_idx_max = 0; | 719 | mdev->entity_internal_idx_max = 0; |
705 | media_graph_walk_cleanup(&mdev->pm_count_walk); | 720 | media_graph_walk_cleanup(&mdev->pm_count_walk); |
706 | mutex_destroy(&mdev->graph_mutex); | 721 | mutex_destroy(&mdev->graph_mutex); |
722 | mutex_destroy(&mdev->req_queue_mutex); | ||
707 | } | 723 | } |
708 | EXPORT_SYMBOL_GPL(media_device_cleanup); | 724 | EXPORT_SYMBOL_GPL(media_device_cleanup); |
709 | 725 | ||