From aafc760ef56b4f913b2d26e8774e1b030d83f2f4 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 22 Jan 2007 18:31:53 -0800 Subject: Restore VIDIOC_INT_[SG]_REGISTER calls From: Trent Piepho Add support for these ioctls to the video_ioctl2 system and the cx88 driver. Signed-off-by: Trent Piepho --- linux/drivers/media/video/videodev.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'linux/drivers/media/video/videodev.c') diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c index b0009fe0f..4789d7f2f 100644 --- a/linux/drivers/media/video/videodev.c +++ b/linux/drivers/media/video/videodev.c @@ -1477,6 +1477,22 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, ret=vfd->vidioc_log_status(file, fh); break; } +#ifdef CONFIG_VIDEO_ADV_DEBUG + case VIDIOC_INT_G_REGISTER: + { + struct v4l2_register *p=arg; + if (vfd->vidioc_g_register) + ret=vfd->vidioc_g_register(file, fh, p); + break; + } + case VIDIOC_INT_S_REGISTER: + { + struct v4l2_register *p=arg; + if (vfd->vidioc_s_register) + ret=vfd->vidioc_s_register(file, fh, p); + break; + } +#endif } /* switch */ if (vfd->debug & V4L2_DEBUG_IOCTL_ARG) { -- cgit v1.2.3 From 0f5b64e7c37c66e5cd7693eb7f9fc011e62eee33 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 23 Jan 2007 17:38:13 -0800 Subject: Make VIDIOC_INT_[SG]_REGISTER ioctls no longer internal only From: Trent Piepho The direct register access ioctls were defined as kernel internal only, but they are very useful for debugging hardware from userspace and are used as such. Officially export them. VIDIOC_INT_[SG]_REGISTER is renamed to VIDIOC_DBG_[SG]_REGISTER Definition of ioctl and struct v4l2_register is moved from v4l2-common.h to videodev2.h. Types used in struct v4l2_register are changed to the userspace exportable versions (u32 -> __u32, etc). Use of VIDIOC_DBG_S_REGISTER requires CAP_SYS_ADMIN permission, so move the check into the video_ioctl2() dispatcher so it doesn't need to be duplicated in each driver's call-back function. CAP_SYS_ADMIN check is added to pvrusb2 (which doesn't use video_ioctl2). Signed-off-by: Trent Piepho --- linux/drivers/media/video/videodev.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'linux/drivers/media/video/videodev.c') diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c index 4789d7f2f..476b3c143 100644 --- a/linux/drivers/media/video/videodev.c +++ b/linux/drivers/media/video/videodev.c @@ -1478,17 +1478,19 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, break; } #ifdef CONFIG_VIDEO_ADV_DEBUG - case VIDIOC_INT_G_REGISTER: + case VIDIOC_DBG_G_REGISTER: { struct v4l2_register *p=arg; if (vfd->vidioc_g_register) ret=vfd->vidioc_g_register(file, fh, p); break; } - case VIDIOC_INT_S_REGISTER: + case VIDIOC_DBG_S_REGISTER: { struct v4l2_register *p=arg; - if (vfd->vidioc_s_register) + if (!capable(CAP_SYS_ADMIN)) + ret=-EPERM; + else if (vfd->vidioc_s_register) ret=vfd->vidioc_s_register(file, fh, p); break; } -- cgit v1.2.3 From 0b945b64fba3381dfc97c66722fe76193f0008d3 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Tue, 30 Jan 2007 18:25:41 -0800 Subject: Add checks for CAP_SYS_ADMIN to VIDIOC_DBG_G_REGISTER From: Trent Piepho Before, root privileges were only needed to set hardware registers, not to read them. On some hardware, reading from the wrong place at the wrong time can hang the machine. So, to be consistent, root privileges are required to read registers on all hardware. Signed-off-by: Trent Piepho --- linux/drivers/media/video/videodev.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'linux/drivers/media/video/videodev.c') diff --git a/linux/drivers/media/video/videodev.c b/linux/drivers/media/video/videodev.c index 476b3c143..707757237 100644 --- a/linux/drivers/media/video/videodev.c +++ b/linux/drivers/media/video/videodev.c @@ -1481,7 +1481,9 @@ static int __video_do_ioctl(struct inode *inode, struct file *file, case VIDIOC_DBG_G_REGISTER: { struct v4l2_register *p=arg; - if (vfd->vidioc_g_register) + if (!capable(CAP_SYS_ADMIN)) + ret=-EPERM; + else if (vfd->vidioc_g_register) ret=vfd->vidioc_g_register(file, fh, p); break; } -- cgit v1.2.3