17 #include <linux/module.h>
18 #include <linux/videodev2.h>
23 static long native_ioctl(
struct file *
file,
unsigned int cmd,
unsigned long arg)
27 if (file->
f_op->unlocked_ioctl)
28 ret = file->
f_op->unlocked_ioctl(file, cmd, arg);
66 uclips = compat_ptr(p);
184 return get_v4l2_pix_format(&kp->
fmt.
pix, &up->fmt.pix);
187 return get_v4l2_pix_format_mplane(&kp->
fmt.
pix_mp,
191 return get_v4l2_window32(&kp->
fmt.
win, &up->fmt.win);
194 return get_v4l2_vbi_format(&kp->
fmt.
vbi, &up->fmt.vbi);
197 return get_v4l2_sliced_vbi_format(&kp->
fmt.
sliced, &up->fmt.sliced);
210 return __get_v4l2_format32(kp, up);
218 return __get_v4l2_format32(&kp->
format, &up->format);
226 return put_v4l2_pix_format(&kp->
fmt.
pix, &up->fmt.pix);
229 return put_v4l2_pix_format_mplane(&kp->
fmt.
pix_mp,
233 return put_v4l2_window32(&kp->
fmt.
win, &up->fmt.win);
236 return put_v4l2_vbi_format(&kp->
fmt.
vbi, &up->fmt.vbi);
239 return put_v4l2_sliced_vbi_format(&kp->
fmt.
sliced, &up->fmt.sliced);
252 return __put_v4l2_format32(kp, up);
260 return __put_v4l2_format32(&kp->
format, &up->format);
341 up_pln = compat_ptr(p);
391 &up->timestamp.tv_usec))
399 if (num_planes == 0) {
409 uplane32 = compat_ptr(p);
420 while (--num_planes >= 0) {
421 ret = get_v4l2_plane32(uplane, uplane32, kp->
memory);
488 uplane32 = compat_ptr(p);
490 while (--num_planes >= 0) {
491 ret = put_v4l2_plane32(uplane, uplane32, kp->
memory);
535 kp->
base = compat_ptr(tmp);
536 get_v4l2_pix_format(&kp->
fmt, &up->fmt);
549 put_v4l2_pix_format(&kp->
fmt, &up->fmt);
605 static inline int ctrl_is_pointer(
u32 id)
636 ucontrols = compat_ptr(p);
643 if (
copy_in_user(kcontrols, ucontrols,
sizeof(*ucontrols)))
645 if (ctrl_is_pointer(kcontrols->
id)) {
678 ucontrols = compat_ptr(p);
684 unsigned size =
sizeof(*ucontrols);
689 if (ctrl_is_pointer(kcontrols->
id))
690 size -=
sizeof(ucontrols->
value64);
733 static int get_v4l2_subdev_edid32(
struct v4l2_subdev_edid *kp,
struct v4l2_subdev_edid32 __user *up)
739 get_user(kp->start_block, &up->start_block) ||
740 get_user(kp->blocks, &up->blocks) ||
744 kp->edid = compat_ptr(tmp);
748 static int put_v4l2_subdev_edid32(
struct v4l2_subdev_edid *kp,
struct v4l2_subdev_edid32 __user *up)
750 u32 tmp = (
u32)((
unsigned long)kp->edid);
754 put_user(kp->start_block, &up->start_block) ||
755 put_user(kp->blocks, &up->blocks) ||
757 copy_to_user(kp->reserved, up->reserved,
sizeof(kp->reserved)))
763 #define VIDIOC_G_FMT32 _IOWR('V', 4, struct v4l2_format32)
764 #define VIDIOC_S_FMT32 _IOWR('V', 5, struct v4l2_format32)
765 #define VIDIOC_QUERYBUF32 _IOWR('V', 9, struct v4l2_buffer32)
766 #define VIDIOC_G_FBUF32 _IOR ('V', 10, struct v4l2_framebuffer32)
767 #define VIDIOC_S_FBUF32 _IOW ('V', 11, struct v4l2_framebuffer32)
768 #define VIDIOC_QBUF32 _IOWR('V', 15, struct v4l2_buffer32)
769 #define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32)
770 #define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32)
771 #define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32)
772 #define VIDIOC_SUBDEV_G_EDID32 _IOWR('V', 63, struct v4l2_subdev_edid32)
773 #define VIDIOC_SUBDEV_S_EDID32 _IOWR('V', 64, struct v4l2_subdev_edid32)
774 #define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32)
775 #define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32)
776 #define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32)
777 #define VIDIOC_TRY_EXT_CTRLS32 _IOWR('V', 73, struct v4l2_ext_controls32)
778 #define VIDIOC_DQEVENT32 _IOR ('V', 89, struct v4l2_event32)
779 #define VIDIOC_CREATE_BUFS32 _IOWR('V', 92, struct v4l2_create_buffers32)
780 #define VIDIOC_PREPARE_BUF32 _IOWR('V', 93, struct v4l2_buffer32)
782 #define VIDIOC_OVERLAY32 _IOW ('V', 14, s32)
783 #define VIDIOC_STREAMON32 _IOW ('V', 18, s32)
784 #define VIDIOC_STREAMOFF32 _IOW ('V', 19, s32)
785 #define VIDIOC_G_INPUT32 _IOR ('V', 38, s32)
786 #define VIDIOC_S_INPUT32 _IOWR('V', 39, s32)
787 #define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32)
788 #define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32)
790 static long do_video_ioctl(
struct file *file,
unsigned int cmd,
unsigned long arg)
801 struct v4l2_subdev_edid v2edid;
805 void __user *up = compat_ptr(arg);
806 int compatible_arg = 1;
855 err = get_v4l2_subdev_edid32(&karg.v2edid, up);
862 err = get_v4l2_format32(&karg.v2f, up);
867 err = get_v4l2_create32(&karg.v2crt, up);
875 err = get_v4l2_buffer32(&karg.v2b, up);
880 err = get_v4l2_framebuffer32(&karg.v2fb, up);
889 err = get_v4l2_standard32(&karg.v2s, up);
894 err = get_v4l2_input32(&karg.v2i, up);
901 err = get_v4l2_ext_controls32(&karg.v2ecs, up);
912 err = native_ioctl(file, cmd, (
unsigned long)up);
917 err = native_ioctl(file, cmd, (
unsigned long)&karg);
928 if (put_v4l2_ext_controls32(&karg.v2ecs, up))
944 err = put_v4l2_framebuffer32(&karg.v2fb, up);
948 err = put_v4l2_event32(&karg.v2ev, up);
953 err = put_v4l2_subdev_edid32(&karg.v2edid, up);
959 err = put_v4l2_format32(&karg.v2f, up);
963 err = put_v4l2_create32(&karg.v2crt, up);
969 err = put_v4l2_buffer32(&karg.v2b, up);
973 err = put_v4l2_standard32(&karg.v2s, up);
977 err = put_v4l2_input32(&karg.v2i, up);
988 if (!file->
f_op->unlocked_ioctl)
1078 ret = do_video_ioctl(file, cmd, arg);
1082 if (vdev->
fops->compat_ioctl32)
1083 ret = vdev->
fops->compat_ioctl32(file, cmd, arg);
1087 "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n",