aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2012-08-28 19:29:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-11-28 07:29:07 -0500
commit0550513c7a559b4933c5e1d47fbd15d15f6078d5 (patch)
tree923eee429a958c8c765db34008d9b83a47776f0e /drivers
parent69d11262a3ff4c07e071523e6768ec15ccc147c1 (diff)
[media] uvcvideo: Add VIDIOC_[GS]_PRIORITY support
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/usb/uvc/uvc_driver.c3
-rw-r--r--drivers/media/usb/uvc/uvc_v4l2.c45
-rw-r--r--drivers/media/usb/uvc/uvcvideo.h1
3 files changed, 49 insertions, 0 deletions
diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c
index ae24f7d70b03..22f14d286fbb 100644
--- a/drivers/media/usb/uvc/uvc_driver.c
+++ b/drivers/media/usb/uvc/uvc_driver.c
@@ -1562,6 +1562,7 @@ static int uvc_scan_device(struct uvc_device *dev)
1562 INIT_LIST_HEAD(&chain->entities); 1562 INIT_LIST_HEAD(&chain->entities);
1563 mutex_init(&chain->ctrl_mutex); 1563 mutex_init(&chain->ctrl_mutex);
1564 chain->dev = dev; 1564 chain->dev = dev;
1565 v4l2_prio_init(&chain->prio);
1565 1566
1566 if (uvc_scan_chain(chain, term) < 0) { 1567 if (uvc_scan_chain(chain, term) < 0) {
1567 kfree(chain); 1568 kfree(chain);
@@ -1722,6 +1723,8 @@ static int uvc_register_video(struct uvc_device *dev,
1722 vdev->v4l2_dev = &dev->vdev; 1723 vdev->v4l2_dev = &dev->vdev;
1723 vdev->fops = &uvc_fops; 1724 vdev->fops = &uvc_fops;
1724 vdev->release = uvc_release; 1725 vdev->release = uvc_release;
1726 vdev->prio = &stream->chain->prio;
1727 set_bit(V4L2_FL_USE_FH_PRIO, &vdev->flags);
1725 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) 1728 if (stream->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
1726 vdev->vfl_dir = VFL_DIR_TX; 1729 vdev->vfl_dir = VFL_DIR_TX;
1727 strlcpy(vdev->name, dev->name, sizeof vdev->name); 1730 strlcpy(vdev->name, dev->name, sizeof vdev->name);
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c
index bf9d07393139..8e056046bc20 100644
--- a/drivers/media/usb/uvc/uvc_v4l2.c
+++ b/drivers/media/usb/uvc/uvc_v4l2.c
@@ -576,6 +576,19 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
576 break; 576 break;
577 } 577 }
578 578
579 /* Priority */
580 case VIDIOC_G_PRIORITY:
581 *(u32 *)arg = v4l2_prio_max(vdev->prio);
582 break;
583
584 case VIDIOC_S_PRIORITY:
585 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
586 if (ret < 0)
587 return ret;
588
589 return v4l2_prio_change(vdev->prio, &handle->vfh.prio,
590 *(u32 *)arg);
591
579 /* Get, Set & Query control */ 592 /* Get, Set & Query control */
580 case VIDIOC_QUERYCTRL: 593 case VIDIOC_QUERYCTRL:
581 return uvc_query_v4l2_ctrl(chain, arg); 594 return uvc_query_v4l2_ctrl(chain, arg);
@@ -606,6 +619,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
606 struct v4l2_control *ctrl = arg; 619 struct v4l2_control *ctrl = arg;
607 struct v4l2_ext_control xctrl; 620 struct v4l2_ext_control xctrl;
608 621
622 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
623 if (ret < 0)
624 return ret;
625
609 memset(&xctrl, 0, sizeof xctrl); 626 memset(&xctrl, 0, sizeof xctrl);
610 xctrl.id = ctrl->id; 627 xctrl.id = ctrl->id;
611 xctrl.value = ctrl->value; 628 xctrl.value = ctrl->value;
@@ -653,6 +670,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
653 } 670 }
654 671
655 case VIDIOC_S_EXT_CTRLS: 672 case VIDIOC_S_EXT_CTRLS:
673 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
674 if (ret < 0)
675 return ret;
676 /* Fall through */
656 case VIDIOC_TRY_EXT_CTRLS: 677 case VIDIOC_TRY_EXT_CTRLS:
657 { 678 {
658 struct v4l2_ext_controls *ctrls = arg; 679 struct v4l2_ext_controls *ctrls = arg;
@@ -747,6 +768,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
747 { 768 {
748 u32 input = *(u32 *)arg + 1; 769 u32 input = *(u32 *)arg + 1;
749 770
771 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
772 if (ret < 0)
773 return ret;
774
750 if ((ret = uvc_acquire_privileges(handle)) < 0) 775 if ((ret = uvc_acquire_privileges(handle)) < 0)
751 return ret; 776 return ret;
752 777
@@ -800,6 +825,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
800 } 825 }
801 826
802 case VIDIOC_S_FMT: 827 case VIDIOC_S_FMT:
828 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
829 if (ret < 0)
830 return ret;
831
803 if ((ret = uvc_acquire_privileges(handle)) < 0) 832 if ((ret = uvc_acquire_privileges(handle)) < 0)
804 return ret; 833 return ret;
805 834
@@ -902,6 +931,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
902 return uvc_v4l2_get_streamparm(stream, arg); 931 return uvc_v4l2_get_streamparm(stream, arg);
903 932
904 case VIDIOC_S_PARM: 933 case VIDIOC_S_PARM:
934 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
935 if (ret < 0)
936 return ret;
937
905 if ((ret = uvc_acquire_privileges(handle)) < 0) 938 if ((ret = uvc_acquire_privileges(handle)) < 0)
906 return ret; 939 return ret;
907 940
@@ -936,6 +969,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
936 969
937 /* Buffers & streaming */ 970 /* Buffers & streaming */
938 case VIDIOC_REQBUFS: 971 case VIDIOC_REQBUFS:
972 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
973 if (ret < 0)
974 return ret;
975
939 if ((ret = uvc_acquire_privileges(handle)) < 0) 976 if ((ret = uvc_acquire_privileges(handle)) < 0)
940 return ret; 977 return ret;
941 978
@@ -981,6 +1018,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
981 if (*type != stream->type) 1018 if (*type != stream->type)
982 return -EINVAL; 1019 return -EINVAL;
983 1020
1021 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
1022 if (ret < 0)
1023 return ret;
1024
984 if (!uvc_has_privileges(handle)) 1025 if (!uvc_has_privileges(handle))
985 return -EBUSY; 1026 return -EBUSY;
986 1027
@@ -999,6 +1040,10 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)
999 if (*type != stream->type) 1040 if (*type != stream->type)
1000 return -EINVAL; 1041 return -EINVAL;
1001 1042
1043 ret = v4l2_prio_check(vdev->prio, handle->vfh.prio);
1044 if (ret < 0)
1045 return ret;
1046
1002 if (!uvc_has_privileges(handle)) 1047 if (!uvc_has_privileges(handle))
1003 return -EBUSY; 1048 return -EBUSY;
1004 1049
diff --git a/drivers/media/usb/uvc/uvcvideo.h b/drivers/media/usb/uvc/uvcvideo.h
index a6c561f631a0..006ae274d22e 100644
--- a/drivers/media/usb/uvc/uvcvideo.h
+++ b/drivers/media/usb/uvc/uvcvideo.h
@@ -372,6 +372,7 @@ struct uvc_video_chain {
372 372
373 struct mutex ctrl_mutex; /* Protects ctrl.info */ 373 struct mutex ctrl_mutex; /* Protects ctrl.info */
374 374
375 struct v4l2_prio_state prio; /* V4L2 priority state */
375 u32 caps; /* V4L2 chain-wide caps */ 376 u32 caps; /* V4L2 chain-wide caps */
376}; 377};
377 378