Skip to content

Commit

Permalink
V4L/DVB (12429): v4l2-ioctl: fix G_STD and G_PARM default handlers
Browse files Browse the repository at this point in the history
The v4l core supplies default handlers for G_STD and G_PARM. However, both
default handlers are buggy.

This patch fixes the following:

1) If no g_std is supplied and current_norm == 0, then this driver does not
   support TV video standards (e.g. a radio or webcam driver). Return
   -EINVAL. This ensures that there is no bogus VIDIOC_G_STD support for
   such drivers.

2) The default VIDIOC_G_PARM handler used current_norm instead of first
   checking if the driver supported g_std and calling that to get the norm.
   It also didn't check if current_norm was 0, since in that case the driver
   does not support TV standards (or no standard was set at all) and the
   default handler should return -EINVAL.

Note that I am very unhappy with these default handlers: I think they
basically behave like some very strange and unexpected side-effect.

Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Aug 13, 2009
1 parent 99362e1 commit 9bedc7f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions drivers/media/video/v4l2-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1081,8 +1081,10 @@ static long __video_do_ioctl(struct file *file,
/* Calls the specific handler */
if (ops->vidioc_g_std)
ret = ops->vidioc_g_std(file, fh, id);
else
else if (vfd->current_norm)
*id = vfd->current_norm;
else
ret = -EINVAL;

if (!ret)
dbgarg(cmd, "std=0x%08Lx\n", (long long unsigned)*id);
Expand Down Expand Up @@ -1553,12 +1555,19 @@ static long __video_do_ioctl(struct file *file,
break;
ret = ops->vidioc_g_parm(file, fh, p);
} else {
v4l2_std_id std = vfd->current_norm;

if (p->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;

v4l2_video_std_frame_period(vfd->current_norm,
&p->parm.capture.timeperframe);
ret = 0;
if (ops->vidioc_g_std)
ret = ops->vidioc_g_std(file, fh, &std);
else if (std == 0)
ret = -EINVAL;
if (ret == 0)
v4l2_video_std_frame_period(std,
&p->parm.capture.timeperframe);
}

dbgarg(cmd, "type=%d\n", p->type);
Expand Down

0 comments on commit 9bedc7f

Please sign in to comment.