aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/v4l2-core
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2012-09-14 05:45:43 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-09-26 08:48:59 -0400
commita5338190efc7cfa8c99a6856342a77d21c9a05cf (patch)
treee7eb5dd17262a01a9986e6184447cd8e70fea47b /drivers/media/v4l2-core
parent663dc7f3a02712e22ef81f4c7b7b1caecceb8e4f (diff)
[media] v4l2-core: tvnorms may be 0 for a given input, handle that case
Currently the core code looks at tvnorms to see whether ENUMSTD or G_PARM should be enabled. This is not a good check for drivers that support the STD API on one input and the DV Timings API on another. In that case tvnorms may be 0. Instead check whether s_std is present (for ENUMSTD) or whether g_std or current_norm is present for g_parm. Also, in the enumstd core function return ENODATA if tvnorms is 0, because in that case the current input does not support the STD API and ENUMSTD should return ENODATA for that. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Reviewed-by: Sakari Ailus <sakari.ailus@iki.fi> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/v4l2-core')
-rw-r--r--drivers/media/v4l2-core/v4l2-dev.c4
-rw-r--r--drivers/media/v4l2-core/v4l2-ioctl.c5
2 files changed, 7 insertions, 2 deletions
diff --git a/drivers/media/v4l2-core/v4l2-dev.c b/drivers/media/v4l2-core/v4l2-dev.c
index 95f92ea4dbd5..498049fa43e4 100644
--- a/drivers/media/v4l2-core/v4l2-dev.c
+++ b/drivers/media/v4l2-core/v4l2-dev.c
@@ -609,7 +609,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
609 SET_VALID_IOCTL(ops, VIDIOC_S_FBUF, vidioc_s_fbuf); 609 SET_VALID_IOCTL(ops, VIDIOC_S_FBUF, vidioc_s_fbuf);
610 SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon); 610 SET_VALID_IOCTL(ops, VIDIOC_STREAMON, vidioc_streamon);
611 SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff); 611 SET_VALID_IOCTL(ops, VIDIOC_STREAMOFF, vidioc_streamoff);
612 if (vdev->tvnorms) 612 if (ops->vidioc_s_std)
613 set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls); 613 set_bit(_IOC_NR(VIDIOC_ENUMSTD), valid_ioctls);
614 if (ops->vidioc_g_std || vdev->current_norm) 614 if (ops->vidioc_g_std || vdev->current_norm)
615 set_bit(_IOC_NR(VIDIOC_G_STD), valid_ioctls); 615 set_bit(_IOC_NR(VIDIOC_G_STD), valid_ioctls);
@@ -663,7 +663,7 @@ static void determine_valid_ioctls(struct video_device *vdev)
663 SET_VALID_IOCTL(ops, VIDIOC_DECODER_CMD, vidioc_decoder_cmd); 663 SET_VALID_IOCTL(ops, VIDIOC_DECODER_CMD, vidioc_decoder_cmd);
664 SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd); 664 SET_VALID_IOCTL(ops, VIDIOC_TRY_DECODER_CMD, vidioc_try_decoder_cmd);
665 if (ops->vidioc_g_parm || (vdev->vfl_type == VFL_TYPE_GRABBER && 665 if (ops->vidioc_g_parm || (vdev->vfl_type == VFL_TYPE_GRABBER &&
666 (ops->vidioc_g_std || vdev->tvnorms))) 666 (ops->vidioc_g_std || vdev->current_norm)))
667 set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls); 667 set_bit(_IOC_NR(VIDIOC_G_PARM), valid_ioctls);
668 SET_VALID_IOCTL(ops, VIDIOC_S_PARM, vidioc_s_parm); 668 SET_VALID_IOCTL(ops, VIDIOC_S_PARM, vidioc_s_parm);
669 SET_VALID_IOCTL(ops, VIDIOC_G_TUNER, vidioc_g_tuner); 669 SET_VALID_IOCTL(ops, VIDIOC_G_TUNER, vidioc_g_tuner);
diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
index 2f26e9496a3b..f3ced2513b2f 100644
--- a/drivers/media/v4l2-core/v4l2-ioctl.c
+++ b/drivers/media/v4l2-core/v4l2-ioctl.c
@@ -1304,6 +1304,11 @@ static int v4l_enumstd(const struct v4l2_ioctl_ops *ops,
1304 unsigned int index = p->index, i, j = 0; 1304 unsigned int index = p->index, i, j = 0;
1305 const char *descr = ""; 1305 const char *descr = "";
1306 1306
1307 /* Return -ENODATA if the tvnorms for the current input
1308 or output is 0, meaning that it doesn't support this API. */
1309 if (id == 0)
1310 return -ENODATA;
1311
1307 /* Return norm array in a canonical way */ 1312 /* Return norm array in a canonical way */
1308 for (i = 0; i <= index && id; i++) { 1313 for (i = 0; i <= index && id; i++) {
1309 /* last std value in the standards array is 0, so this 1314 /* last std value in the standards array is 0, so this