diff options
-rw-r--r-- | Documentation/video4linux/v4l2-framework.txt | 7 | ||||
-rw-r--r-- | drivers/media/video/cx18/cx18-streams.c | 1 | ||||
-rw-r--r-- | drivers/media/video/ivtv/ivtv-streams.c | 1 | ||||
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 8 | ||||
-rw-r--r-- | drivers/media/video/v4l2-fh.c | 7 | ||||
-rw-r--r-- | drivers/media/video/v4l2-ioctl.c | 13 | ||||
-rw-r--r-- | drivers/media/video/vivi.c | 1 | ||||
-rw-r--r-- | include/media/v4l2-dev.h | 3 |
8 files changed, 27 insertions, 14 deletions
diff --git a/Documentation/video4linux/v4l2-framework.txt b/Documentation/video4linux/v4l2-framework.txt index 7d09114af00b..3b15608ee070 100644 --- a/Documentation/video4linux/v4l2-framework.txt +++ b/Documentation/video4linux/v4l2-framework.txt | |||
@@ -577,6 +577,10 @@ You should also set these fields: | |||
577 | (cx8802). Since the v4l2_device cannot be associated with a particular | 577 | (cx8802). Since the v4l2_device cannot be associated with a particular |
578 | PCI device it is setup without a parent device. But when the struct | 578 | PCI device it is setup without a parent device. But when the struct |
579 | video_device is setup you do know which parent PCI device to use. | 579 | video_device is setup you do know which parent PCI device to use. |
580 | - flags: optional. Set to V4L2_FL_USE_FH_PRIO if you want to let the framework | ||
581 | handle the VIDIOC_G/S_PRIORITY ioctls. This requires that you use struct | ||
582 | v4l2_fh. Eventually this flag will disappear once all drivers use the core | ||
583 | priority handling. But for now it has to be set explicitly. | ||
580 | 584 | ||
581 | If you use v4l2_ioctl_ops, then you should set .unlocked_ioctl to video_ioctl2 | 585 | If you use v4l2_ioctl_ops, then you should set .unlocked_ioctl to video_ioctl2 |
582 | in your v4l2_file_operations struct. | 586 | in your v4l2_file_operations struct. |
@@ -775,7 +779,8 @@ struct v4l2_fh | |||
775 | 779 | ||
776 | struct v4l2_fh provides a way to easily keep file handle specific data | 780 | struct v4l2_fh provides a way to easily keep file handle specific data |
777 | that is used by the V4L2 framework. New drivers must use struct v4l2_fh | 781 | that is used by the V4L2 framework. New drivers must use struct v4l2_fh |
778 | since it is also used to implement priority handling (VIDIOC_G/S_PRIORITY). | 782 | since it is also used to implement priority handling (VIDIOC_G/S_PRIORITY) |
783 | if the video_device flag V4L2_FL_USE_FH_PRIO is also set. | ||
779 | 784 | ||
780 | The users of v4l2_fh (in the V4L2 framework, not the driver) know | 785 | The users of v4l2_fh (in the V4L2 framework, not the driver) know |
781 | whether a driver uses v4l2_fh as its file->private_data pointer by | 786 | whether a driver uses v4l2_fh as its file->private_data pointer by |
diff --git a/drivers/media/video/cx18/cx18-streams.c b/drivers/media/video/cx18/cx18-streams.c index 2d248560770e..c6e2ca3b1149 100644 --- a/drivers/media/video/cx18/cx18-streams.c +++ b/drivers/media/video/cx18/cx18-streams.c | |||
@@ -207,6 +207,7 @@ static int cx18_prep_dev(struct cx18 *cx, int type) | |||
207 | s->video_dev->fops = &cx18_v4l2_enc_fops; | 207 | s->video_dev->fops = &cx18_v4l2_enc_fops; |
208 | s->video_dev->release = video_device_release; | 208 | s->video_dev->release = video_device_release; |
209 | s->video_dev->tvnorms = V4L2_STD_ALL; | 209 | s->video_dev->tvnorms = V4L2_STD_ALL; |
210 | set_bit(V4L2_FL_USE_FH_PRIO, &s->video_dev->flags); | ||
210 | cx18_set_funcs(s->video_dev); | 211 | cx18_set_funcs(s->video_dev); |
211 | return 0; | 212 | return 0; |
212 | } | 213 | } |
diff --git a/drivers/media/video/ivtv/ivtv-streams.c b/drivers/media/video/ivtv/ivtv-streams.c index 512607e0cda3..942683336555 100644 --- a/drivers/media/video/ivtv/ivtv-streams.c +++ b/drivers/media/video/ivtv/ivtv-streams.c | |||
@@ -214,6 +214,7 @@ static int ivtv_prep_dev(struct ivtv *itv, int type) | |||
214 | s->vdev->fops = ivtv_stream_info[type].fops; | 214 | s->vdev->fops = ivtv_stream_info[type].fops; |
215 | s->vdev->release = video_device_release; | 215 | s->vdev->release = video_device_release; |
216 | s->vdev->tvnorms = V4L2_STD_ALL; | 216 | s->vdev->tvnorms = V4L2_STD_ALL; |
217 | set_bit(V4L2_FL_USE_FH_PRIO, &s->vdev->flags); | ||
217 | ivtv_set_funcs(s->vdev); | 218 | ivtv_set_funcs(s->vdev); |
218 | return 0; | 219 | return 0; |
219 | } | 220 | } |
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 1898099ec65a..498e6742579e 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -578,11 +578,9 @@ int __video_register_device(struct video_device *vdev, int type, int nr, | |||
578 | vdev->parent = vdev->v4l2_dev->dev; | 578 | vdev->parent = vdev->v4l2_dev->dev; |
579 | if (vdev->ctrl_handler == NULL) | 579 | if (vdev->ctrl_handler == NULL) |
580 | vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; | 580 | vdev->ctrl_handler = vdev->v4l2_dev->ctrl_handler; |
581 | /* If the prio state pointer is NULL, and if the driver doesn't | 581 | /* If the prio state pointer is NULL, then use the v4l2_device |
582 | handle priorities itself, then use the v4l2_device prio | 582 | prio state. */ |
583 | state. */ | 583 | if (vdev->prio == NULL) |
584 | if (vdev->prio == NULL && vdev->ioctl_ops && | ||
585 | vdev->ioctl_ops->vidioc_s_priority == NULL) | ||
586 | vdev->prio = &vdev->v4l2_dev->prio; | 584 | vdev->prio = &vdev->v4l2_dev->prio; |
587 | } | 585 | } |
588 | 586 | ||
diff --git a/drivers/media/video/v4l2-fh.c b/drivers/media/video/v4l2-fh.c index 543b3fe6784e..717f71e6370e 100644 --- a/drivers/media/video/v4l2-fh.c +++ b/drivers/media/video/v4l2-fh.c | |||
@@ -35,7 +35,6 @@ int v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev) | |||
35 | INIT_LIST_HEAD(&fh->list); | 35 | INIT_LIST_HEAD(&fh->list); |
36 | set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags); | 36 | set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags); |
37 | fh->prio = V4L2_PRIORITY_UNSET; | 37 | fh->prio = V4L2_PRIORITY_UNSET; |
38 | BUG_ON(vdev->prio == NULL); | ||
39 | 38 | ||
40 | /* | 39 | /* |
41 | * fh->events only needs to be initialized if the driver | 40 | * fh->events only needs to be initialized if the driver |
@@ -54,7 +53,8 @@ void v4l2_fh_add(struct v4l2_fh *fh) | |||
54 | { | 53 | { |
55 | unsigned long flags; | 54 | unsigned long flags; |
56 | 55 | ||
57 | v4l2_prio_open(fh->vdev->prio, &fh->prio); | 56 | if (test_bit(V4L2_FL_USE_FH_PRIO, &fh->vdev->flags)) |
57 | v4l2_prio_open(fh->vdev->prio, &fh->prio); | ||
58 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); | 58 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
59 | list_add(&fh->list, &fh->vdev->fh_list); | 59 | list_add(&fh->list, &fh->vdev->fh_list); |
60 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); | 60 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); |
@@ -82,7 +82,8 @@ void v4l2_fh_del(struct v4l2_fh *fh) | |||
82 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); | 82 | spin_lock_irqsave(&fh->vdev->fh_lock, flags); |
83 | list_del_init(&fh->list); | 83 | list_del_init(&fh->list); |
84 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); | 84 | spin_unlock_irqrestore(&fh->vdev->fh_lock, flags); |
85 | v4l2_prio_close(fh->vdev->prio, fh->prio); | 85 | if (test_bit(V4L2_FL_USE_FH_PRIO, &fh->vdev->flags)) |
86 | v4l2_prio_close(fh->vdev->prio, fh->prio); | ||
86 | } | 87 | } |
87 | EXPORT_SYMBOL_GPL(v4l2_fh_del); | 88 | EXPORT_SYMBOL_GPL(v4l2_fh_del); |
88 | 89 | ||
diff --git a/drivers/media/video/v4l2-ioctl.c b/drivers/media/video/v4l2-ioctl.c index 3e6b6fa5771a..a01ed39e6c16 100644 --- a/drivers/media/video/v4l2-ioctl.c +++ b/drivers/media/video/v4l2-ioctl.c | |||
@@ -541,6 +541,7 @@ static long __video_do_ioctl(struct file *file, | |||
541 | void *fh = file->private_data; | 541 | void *fh = file->private_data; |
542 | struct v4l2_fh *vfh = NULL; | 542 | struct v4l2_fh *vfh = NULL; |
543 | struct v4l2_format f_copy; | 543 | struct v4l2_format f_copy; |
544 | int use_fh_prio = 0; | ||
544 | long ret = -EINVAL; | 545 | long ret = -EINVAL; |
545 | 546 | ||
546 | if (ops == NULL) { | 547 | if (ops == NULL) { |
@@ -555,10 +556,12 @@ static long __video_do_ioctl(struct file *file, | |||
555 | printk(KERN_CONT "\n"); | 556 | printk(KERN_CONT "\n"); |
556 | } | 557 | } |
557 | 558 | ||
558 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) | 559 | if (test_bit(V4L2_FL_USES_V4L2_FH, &vfd->flags)) { |
559 | vfh = file->private_data; | 560 | vfh = file->private_data; |
561 | use_fh_prio = test_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
562 | } | ||
560 | 563 | ||
561 | if (vfh && !ops->vidioc_s_priority) { | 564 | if (use_fh_prio) { |
562 | switch (cmd) { | 565 | switch (cmd) { |
563 | case VIDIOC_S_CTRL: | 566 | case VIDIOC_S_CTRL: |
564 | case VIDIOC_S_STD: | 567 | case VIDIOC_S_STD: |
@@ -620,7 +623,7 @@ static long __video_do_ioctl(struct file *file, | |||
620 | 623 | ||
621 | if (ops->vidioc_g_priority) { | 624 | if (ops->vidioc_g_priority) { |
622 | ret = ops->vidioc_g_priority(file, fh, p); | 625 | ret = ops->vidioc_g_priority(file, fh, p); |
623 | } else if (vfh) { | 626 | } else if (use_fh_prio) { |
624 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); | 627 | *p = v4l2_prio_max(&vfd->v4l2_dev->prio); |
625 | ret = 0; | 628 | ret = 0; |
626 | } | 629 | } |
@@ -632,7 +635,7 @@ static long __video_do_ioctl(struct file *file, | |||
632 | { | 635 | { |
633 | enum v4l2_priority *p = arg; | 636 | enum v4l2_priority *p = arg; |
634 | 637 | ||
635 | if (!ops->vidioc_s_priority && vfh == NULL) | 638 | if (!ops->vidioc_s_priority && !use_fh_prio) |
636 | break; | 639 | break; |
637 | dbgarg(cmd, "setting priority to %d\n", *p); | 640 | dbgarg(cmd, "setting priority to %d\n", *p); |
638 | if (ops->vidioc_s_priority) | 641 | if (ops->vidioc_s_priority) |
@@ -2187,7 +2190,7 @@ static long __video_do_ioctl(struct file *file, | |||
2187 | 2190 | ||
2188 | if (!ops->vidioc_default) | 2191 | if (!ops->vidioc_default) |
2189 | break; | 2192 | break; |
2190 | if (vfh && !ops->vidioc_s_priority) | 2193 | if (use_fh_prio) |
2191 | valid_prio = v4l2_prio_check(vfd->prio, vfh->prio) >= 0; | 2194 | valid_prio = v4l2_prio_check(vfd->prio, vfh->prio) >= 0; |
2192 | ret = ops->vidioc_default(file, fh, valid_prio, cmd, arg); | 2195 | ret = ops->vidioc_default(file, fh, valid_prio, cmd, arg); |
2193 | break; | 2196 | break; |
diff --git a/drivers/media/video/vivi.c b/drivers/media/video/vivi.c index 42500bf03a9c..2238a613d664 100644 --- a/drivers/media/video/vivi.c +++ b/drivers/media/video/vivi.c | |||
@@ -1254,6 +1254,7 @@ static int __init vivi_create_instance(int inst) | |||
1254 | *vfd = vivi_template; | 1254 | *vfd = vivi_template; |
1255 | vfd->debug = debug; | 1255 | vfd->debug = debug; |
1256 | vfd->v4l2_dev = &dev->v4l2_dev; | 1256 | vfd->v4l2_dev = &dev->v4l2_dev; |
1257 | set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags); | ||
1257 | 1258 | ||
1258 | /* | 1259 | /* |
1259 | * Provide a mutex to v4l2 core. It will be used to protect | 1260 | * Provide a mutex to v4l2 core. It will be used to protect |
diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h index 3700127ba299..8266d5ade2ff 100644 --- a/include/media/v4l2-dev.h +++ b/include/media/v4l2-dev.h | |||
@@ -35,7 +35,10 @@ struct v4l2_ctrl_handler; | |||
35 | Drivers can clear this flag if they want to block all future | 35 | Drivers can clear this flag if they want to block all future |
36 | device access. It is cleared by video_unregister_device. */ | 36 | device access. It is cleared by video_unregister_device. */ |
37 | #define V4L2_FL_REGISTERED (0) | 37 | #define V4L2_FL_REGISTERED (0) |
38 | /* file->private_data points to struct v4l2_fh */ | ||
38 | #define V4L2_FL_USES_V4L2_FH (1) | 39 | #define V4L2_FL_USES_V4L2_FH (1) |
40 | /* Use the prio field of v4l2_fh for core priority checking */ | ||
41 | #define V4L2_FL_USE_FH_PRIO (2) | ||
39 | 42 | ||
40 | /* Priority helper functions */ | 43 | /* Priority helper functions */ |
41 | 44 | ||