diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-06-25 05:54:05 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-20 06:12:33 -0400 |
commit | 6264c80661eaa2df793dd71d4956f371be955aa2 (patch) | |
tree | 6602871594f2b6c3ed5f9d5afe694a77a46cf71f | |
parent | c5588b5c473c3d496a2f94b80ea8254110866506 (diff) |
V4L/DVB (8116): videodev: allow PRIVATE_BASE controls when called through VIDIOC_G/S_CTRL.
V4L2_CID_PRIVATE_BASE controls are not allowed when called from
VIDIOC_S/G_EXT_CTRL as extended controls use a better mechanism
for private controls. But still allow it when called from the
VIDIOC_G/S_CTRL to extended control conversion in video_ioctl2()
for backwards compatibility.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | drivers/media/video/videodev.c | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/drivers/media/video/videodev.c b/drivers/media/video/videodev.c index 5bf2256fedeb..d54ca6c802db 100644 --- a/drivers/media/video/videodev.c +++ b/drivers/media/video/videodev.c | |||
@@ -710,7 +710,7 @@ static inline void v4l_print_ext_ctrls(unsigned int cmd, | |||
710 | printk(KERN_CONT "\n"); | 710 | printk(KERN_CONT "\n"); |
711 | }; | 711 | }; |
712 | 712 | ||
713 | static inline int check_ext_ctrls(struct v4l2_ext_controls *c) | 713 | static inline int check_ext_ctrls(struct v4l2_ext_controls *c, int allow_priv) |
714 | { | 714 | { |
715 | __u32 i; | 715 | __u32 i; |
716 | 716 | ||
@@ -721,8 +721,11 @@ static inline int check_ext_ctrls(struct v4l2_ext_controls *c) | |||
721 | c->controls[i].reserved2[1] = 0; | 721 | c->controls[i].reserved2[1] = 0; |
722 | } | 722 | } |
723 | /* V4L2_CID_PRIVATE_BASE cannot be used as control class | 723 | /* V4L2_CID_PRIVATE_BASE cannot be used as control class |
724 | * when using extended controls. */ | 724 | when using extended controls. |
725 | if (c->ctrl_class == V4L2_CID_PRIVATE_BASE) | 725 | Only when passed in through VIDIOC_G_CTRL and VIDIOC_S_CTRL |
726 | is it allowed for backwards compatibility. | ||
727 | */ | ||
728 | if (!allow_priv && c->ctrl_class == V4L2_CID_PRIVATE_BASE) | ||
726 | return 0; | 729 | return 0; |
727 | /* Check that all controls are from the same control class. */ | 730 | /* Check that all controls are from the same control class. */ |
728 | for (i = 0; i < c->count; i++) { | 731 | for (i = 0; i < c->count; i++) { |
@@ -1426,7 +1429,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1426 | ctrls.controls = &ctrl; | 1429 | ctrls.controls = &ctrl; |
1427 | ctrl.id = p->id; | 1430 | ctrl.id = p->id; |
1428 | ctrl.value = p->value; | 1431 | ctrl.value = p->value; |
1429 | if (check_ext_ctrls(&ctrls)) { | 1432 | if (check_ext_ctrls(&ctrls, 1)) { |
1430 | ret = vfd->vidioc_g_ext_ctrls(file, fh, &ctrls); | 1433 | ret = vfd->vidioc_g_ext_ctrls(file, fh, &ctrls); |
1431 | if (ret == 0) | 1434 | if (ret == 0) |
1432 | p->value = ctrl.value; | 1435 | p->value = ctrl.value; |
@@ -1462,7 +1465,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1462 | ctrls.controls = &ctrl; | 1465 | ctrls.controls = &ctrl; |
1463 | ctrl.id = p->id; | 1466 | ctrl.id = p->id; |
1464 | ctrl.value = p->value; | 1467 | ctrl.value = p->value; |
1465 | if (check_ext_ctrls(&ctrls)) | 1468 | if (check_ext_ctrls(&ctrls, 1)) |
1466 | ret = vfd->vidioc_s_ext_ctrls(file, fh, &ctrls); | 1469 | ret = vfd->vidioc_s_ext_ctrls(file, fh, &ctrls); |
1467 | break; | 1470 | break; |
1468 | } | 1471 | } |
@@ -1473,7 +1476,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1473 | p->error_idx = p->count; | 1476 | p->error_idx = p->count; |
1474 | if (!vfd->vidioc_g_ext_ctrls) | 1477 | if (!vfd->vidioc_g_ext_ctrls) |
1475 | break; | 1478 | break; |
1476 | if (check_ext_ctrls(p)) | 1479 | if (check_ext_ctrls(p, 0)) |
1477 | ret = vfd->vidioc_g_ext_ctrls(file, fh, p); | 1480 | ret = vfd->vidioc_g_ext_ctrls(file, fh, p); |
1478 | v4l_print_ext_ctrls(cmd, vfd, p, !ret); | 1481 | v4l_print_ext_ctrls(cmd, vfd, p, !ret); |
1479 | break; | 1482 | break; |
@@ -1486,7 +1489,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1486 | if (!vfd->vidioc_s_ext_ctrls) | 1489 | if (!vfd->vidioc_s_ext_ctrls) |
1487 | break; | 1490 | break; |
1488 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | 1491 | v4l_print_ext_ctrls(cmd, vfd, p, 1); |
1489 | if (check_ext_ctrls(p)) | 1492 | if (check_ext_ctrls(p, 0)) |
1490 | ret = vfd->vidioc_s_ext_ctrls(file, fh, p); | 1493 | ret = vfd->vidioc_s_ext_ctrls(file, fh, p); |
1491 | break; | 1494 | break; |
1492 | } | 1495 | } |
@@ -1498,7 +1501,7 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, | |||
1498 | if (!vfd->vidioc_try_ext_ctrls) | 1501 | if (!vfd->vidioc_try_ext_ctrls) |
1499 | break; | 1502 | break; |
1500 | v4l_print_ext_ctrls(cmd, vfd, p, 1); | 1503 | v4l_print_ext_ctrls(cmd, vfd, p, 1); |
1501 | if (check_ext_ctrls(p)) | 1504 | if (check_ext_ctrls(p, 0)) |
1502 | ret = vfd->vidioc_try_ext_ctrls(file, fh, p); | 1505 | ret = vfd->vidioc_try_ext_ctrls(file, fh, p); |
1503 | break; | 1506 | break; |
1504 | } | 1507 | } |