Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 1 | /* |
| 2 | * ioctl32.c: Conversion between 32bit and 64bit native ioctls. |
| 3 | * Separated from fs stuff by Arnd Bergmann <arnd@arndb.de> |
| 4 | * |
| 5 | * Copyright (C) 1997-2000 Jakub Jelinek (jakub@redhat.com) |
| 6 | * Copyright (C) 1998 Eddie C. Dost (ecd@skynet.be) |
| 7 | * Copyright (C) 2001,2002 Andi Kleen, SuSE Labs |
Pavel Machek | a253129 | 2010-07-18 14:27:13 +0200 | [diff] [blame] | 8 | * Copyright (C) 2003 Pavel Machek (pavel@ucw.cz) |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 9 | * Copyright (C) 2005 Philippe De Muyter (phdm@macqel.be) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 10 | * Copyright (C) 2008 Hans Verkuil <hverkuil@xs4all.nl> |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 11 | * |
| 12 | * These routines maintain argument size conversion between 32bit and 64bit |
| 13 | * ioctls. |
| 14 | */ |
| 15 | |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 16 | #include <linux/compat.h> |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 17 | #include <linux/videodev2.h> |
Nickolay V. Shmyrev | 133b735 | 2006-01-09 15:24:58 -0200 | [diff] [blame] | 18 | #include <linux/module.h> |
Mauro Carvalho Chehab | 2864462 | 2008-07-20 20:26:54 -0300 | [diff] [blame] | 19 | #include <media/v4l2-ioctl.h> |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 20 | |
| 21 | #ifdef CONFIG_COMPAT |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 22 | |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 23 | static long native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 24 | { |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 25 | long ret = -ENOIOCTLCMD; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 26 | |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 27 | if (file->f_op->unlocked_ioctl) |
| 28 | ret = file->f_op->unlocked_ioctl(file, cmd, arg); |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 29 | |
| 30 | return ret; |
| 31 | } |
| 32 | |
| 33 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 34 | struct v4l2_clip32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 35 | struct v4l2_rect c; |
| 36 | compat_caddr_t next; |
| 37 | }; |
| 38 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 39 | struct v4l2_window32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 40 | struct v4l2_rect w; |
| 41 | enum v4l2_field field; |
| 42 | __u32 chromakey; |
| 43 | compat_caddr_t clips; /* actually struct v4l2_clip32 * */ |
| 44 | __u32 clipcount; |
| 45 | compat_caddr_t bitmap; |
| 46 | }; |
| 47 | |
| 48 | static int get_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) |
| 49 | { |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 50 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_window32)) || |
| 51 | copy_from_user(&kp->w, &up->w, sizeof(up->w)) || |
| 52 | get_user(kp->field, &up->field) || |
| 53 | get_user(kp->chromakey, &up->chromakey) || |
| 54 | get_user(kp->clipcount, &up->clipcount)) |
| 55 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 56 | if (kp->clipcount > 2048) |
| 57 | return -EINVAL; |
| 58 | if (kp->clipcount) { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 59 | struct v4l2_clip32 __user *uclips; |
| 60 | struct v4l2_clip __user *kclips; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 61 | int n = kp->clipcount; |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 62 | compat_caddr_t p; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 63 | |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 64 | if (get_user(p, &up->clips)) |
| 65 | return -EFAULT; |
| 66 | uclips = compat_ptr(p); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 67 | kclips = compat_alloc_user_space(n * sizeof(struct v4l2_clip)); |
| 68 | kp->clips = kclips; |
| 69 | while (--n >= 0) { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 70 | if (copy_in_user(&kclips->c, &uclips->c, sizeof(uclips->c))) |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 71 | return -EFAULT; |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 72 | if (put_user(n ? kclips + 1 : NULL, &kclips->next)) |
| 73 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 74 | uclips += 1; |
| 75 | kclips += 1; |
| 76 | } |
| 77 | } else |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 78 | kp->clips = NULL; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | static int put_v4l2_window32(struct v4l2_window *kp, struct v4l2_window32 __user *up) |
| 83 | { |
Roel Kluin | f2e6c6a | 2009-12-16 11:35:45 -0300 | [diff] [blame] | 84 | if (copy_to_user(&up->w, &kp->w, sizeof(kp->w)) || |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 85 | put_user(kp->field, &up->field) || |
| 86 | put_user(kp->chromakey, &up->chromakey) || |
| 87 | put_user(kp->clipcount, &up->clipcount)) |
| 88 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 89 | return 0; |
| 90 | } |
| 91 | |
| 92 | static inline int get_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) |
| 93 | { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 94 | if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format))) |
| 95 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 96 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 97 | } |
| 98 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 99 | static inline int get_v4l2_pix_format_mplane(struct v4l2_pix_format_mplane *kp, |
| 100 | struct v4l2_pix_format_mplane __user *up) |
| 101 | { |
| 102 | if (copy_from_user(kp, up, sizeof(struct v4l2_pix_format_mplane))) |
| 103 | return -EFAULT; |
| 104 | return 0; |
| 105 | } |
| 106 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 107 | static inline int put_v4l2_pix_format(struct v4l2_pix_format *kp, struct v4l2_pix_format __user *up) |
| 108 | { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 109 | if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format))) |
| 110 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 111 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 112 | } |
| 113 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 114 | static inline int put_v4l2_pix_format_mplane(struct v4l2_pix_format_mplane *kp, |
| 115 | struct v4l2_pix_format_mplane __user *up) |
| 116 | { |
| 117 | if (copy_to_user(up, kp, sizeof(struct v4l2_pix_format_mplane))) |
| 118 | return -EFAULT; |
| 119 | return 0; |
| 120 | } |
| 121 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 122 | static inline int get_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) |
| 123 | { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 124 | if (copy_from_user(kp, up, sizeof(struct v4l2_vbi_format))) |
| 125 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 126 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static inline int put_v4l2_vbi_format(struct v4l2_vbi_format *kp, struct v4l2_vbi_format __user *up) |
| 130 | { |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 131 | if (copy_to_user(up, kp, sizeof(struct v4l2_vbi_format))) |
| 132 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 133 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 134 | } |
| 135 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 136 | static inline int get_v4l2_sliced_vbi_format(struct v4l2_sliced_vbi_format *kp, struct v4l2_sliced_vbi_format __user *up) |
| 137 | { |
| 138 | if (copy_from_user(kp, up, sizeof(struct v4l2_sliced_vbi_format))) |
| 139 | return -EFAULT; |
| 140 | return 0; |
| 141 | } |
| 142 | |
| 143 | static inline int put_v4l2_sliced_vbi_format(struct v4l2_sliced_vbi_format *kp, struct v4l2_sliced_vbi_format __user *up) |
| 144 | { |
| 145 | if (copy_to_user(up, kp, sizeof(struct v4l2_sliced_vbi_format))) |
| 146 | return -EFAULT; |
| 147 | return 0; |
| 148 | } |
| 149 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 150 | struct v4l2_format32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 151 | enum v4l2_buf_type type; |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 152 | union { |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 153 | struct v4l2_pix_format pix; |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 154 | struct v4l2_pix_format_mplane pix_mp; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 155 | struct v4l2_window32 win; |
| 156 | struct v4l2_vbi_format vbi; |
| 157 | struct v4l2_sliced_vbi_format sliced; |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 158 | __u8 raw_data[200]; /* user-defined */ |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 159 | } fmt; |
| 160 | }; |
| 161 | |
| 162 | static int get_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) |
| 163 | { |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 164 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_format32)) || |
| 165 | get_user(kp->type, &up->type)) |
| 166 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 167 | switch (kp->type) { |
| 168 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 169 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 170 | return get_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix); |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 171 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
| 172 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
| 173 | return get_v4l2_pix_format_mplane(&kp->fmt.pix_mp, |
| 174 | &up->fmt.pix_mp); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 175 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 176 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 177 | return get_v4l2_window32(&kp->fmt.win, &up->fmt.win); |
| 178 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 179 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 180 | return get_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi); |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 181 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
| 182 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
| 183 | return get_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced); |
| 184 | case V4L2_BUF_TYPE_PRIVATE: |
| 185 | if (copy_from_user(kp, up, sizeof(kp->fmt.raw_data))) |
| 186 | return -EFAULT; |
| 187 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 188 | default: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 189 | printk(KERN_INFO "compat_ioctl32: unexpected VIDIOC_FMT type %d\n", |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 190 | kp->type); |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 191 | return -EINVAL; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 192 | } |
| 193 | } |
| 194 | |
| 195 | static int put_v4l2_format32(struct v4l2_format *kp, struct v4l2_format32 __user *up) |
| 196 | { |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 197 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_format32)) || |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 198 | put_user(kp->type, &up->type)) |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 199 | return -EFAULT; |
| 200 | switch (kp->type) { |
| 201 | case V4L2_BUF_TYPE_VIDEO_CAPTURE: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 202 | case V4L2_BUF_TYPE_VIDEO_OUTPUT: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 203 | return put_v4l2_pix_format(&kp->fmt.pix, &up->fmt.pix); |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 204 | case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: |
| 205 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: |
| 206 | return put_v4l2_pix_format_mplane(&kp->fmt.pix_mp, |
| 207 | &up->fmt.pix_mp); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 208 | case V4L2_BUF_TYPE_VIDEO_OVERLAY: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 209 | case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 210 | return put_v4l2_window32(&kp->fmt.win, &up->fmt.win); |
| 211 | case V4L2_BUF_TYPE_VBI_CAPTURE: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 212 | case V4L2_BUF_TYPE_VBI_OUTPUT: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 213 | return put_v4l2_vbi_format(&kp->fmt.vbi, &up->fmt.vbi); |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 214 | case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: |
| 215 | case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: |
| 216 | return put_v4l2_sliced_vbi_format(&kp->fmt.sliced, &up->fmt.sliced); |
| 217 | case V4L2_BUF_TYPE_PRIVATE: |
| 218 | if (copy_to_user(up, kp, sizeof(up->fmt.raw_data))) |
| 219 | return -EFAULT; |
| 220 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 221 | default: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 222 | printk(KERN_INFO "compat_ioctl32: unexpected VIDIOC_FMT type %d\n", |
| 223 | kp->type); |
| 224 | return -EINVAL; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 225 | } |
| 226 | } |
| 227 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 228 | struct v4l2_standard32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 229 | __u32 index; |
| 230 | __u32 id[2]; /* __u64 would get the alignment wrong */ |
| 231 | __u8 name[24]; |
| 232 | struct v4l2_fract frameperiod; /* Frames, not fields */ |
| 233 | __u32 framelines; |
| 234 | __u32 reserved[4]; |
| 235 | }; |
| 236 | |
| 237 | static int get_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) |
| 238 | { |
| 239 | /* other fields are not set by the user, nor used by the driver */ |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 240 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_standard32)) || |
| 241 | get_user(kp->index, &up->index)) |
| 242 | return -EFAULT; |
| 243 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | static int put_v4l2_standard32(struct v4l2_standard *kp, struct v4l2_standard32 __user *up) |
| 247 | { |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 248 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_standard32)) || |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 249 | put_user(kp->index, &up->index) || |
| 250 | copy_to_user(up->id, &kp->id, sizeof(__u64)) || |
| 251 | copy_to_user(up->name, kp->name, 24) || |
| 252 | copy_to_user(&up->frameperiod, &kp->frameperiod, sizeof(kp->frameperiod)) || |
| 253 | put_user(kp->framelines, &up->framelines) || |
| 254 | copy_to_user(up->reserved, kp->reserved, 4 * sizeof(__u32))) |
| 255 | return -EFAULT; |
| 256 | return 0; |
| 257 | } |
| 258 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 259 | struct v4l2_plane32 { |
| 260 | __u32 bytesused; |
| 261 | __u32 length; |
| 262 | union { |
| 263 | __u32 mem_offset; |
| 264 | compat_long_t userptr; |
| 265 | } m; |
| 266 | __u32 data_offset; |
| 267 | __u32 reserved[11]; |
| 268 | }; |
| 269 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 270 | struct v4l2_buffer32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 271 | __u32 index; |
| 272 | enum v4l2_buf_type type; |
| 273 | __u32 bytesused; |
| 274 | __u32 flags; |
| 275 | enum v4l2_field field; |
| 276 | struct compat_timeval timestamp; |
| 277 | struct v4l2_timecode timecode; |
| 278 | __u32 sequence; |
| 279 | |
| 280 | /* memory location */ |
| 281 | enum v4l2_memory memory; |
| 282 | union { |
| 283 | __u32 offset; |
| 284 | compat_long_t userptr; |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 285 | compat_caddr_t planes; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 286 | } m; |
| 287 | __u32 length; |
| 288 | __u32 input; |
| 289 | __u32 reserved; |
| 290 | }; |
| 291 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 292 | static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32, |
| 293 | enum v4l2_memory memory) |
| 294 | { |
| 295 | void __user *up_pln; |
| 296 | compat_long_t p; |
| 297 | |
| 298 | if (copy_in_user(up, up32, 2 * sizeof(__u32)) || |
| 299 | copy_in_user(&up->data_offset, &up32->data_offset, |
| 300 | sizeof(__u32))) |
| 301 | return -EFAULT; |
| 302 | |
| 303 | if (memory == V4L2_MEMORY_USERPTR) { |
| 304 | if (get_user(p, &up32->m.userptr)) |
| 305 | return -EFAULT; |
| 306 | up_pln = compat_ptr(p); |
| 307 | if (put_user((unsigned long)up_pln, &up->m.userptr)) |
| 308 | return -EFAULT; |
| 309 | } else { |
| 310 | if (copy_in_user(&up->m.mem_offset, &up32->m.mem_offset, |
| 311 | sizeof(__u32))) |
| 312 | return -EFAULT; |
| 313 | } |
| 314 | |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32, |
| 319 | enum v4l2_memory memory) |
| 320 | { |
| 321 | if (copy_in_user(up32, up, 2 * sizeof(__u32)) || |
| 322 | copy_in_user(&up32->data_offset, &up->data_offset, |
| 323 | sizeof(__u32))) |
| 324 | return -EFAULT; |
| 325 | |
| 326 | /* For MMAP, driver might've set up the offset, so copy it back. |
| 327 | * USERPTR stays the same (was userspace-provided), so no copying. */ |
| 328 | if (memory == V4L2_MEMORY_MMAP) |
| 329 | if (copy_in_user(&up32->m.mem_offset, &up->m.mem_offset, |
| 330 | sizeof(__u32))) |
| 331 | return -EFAULT; |
| 332 | |
| 333 | return 0; |
| 334 | } |
| 335 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 336 | static int get_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) |
| 337 | { |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 338 | struct v4l2_plane32 __user *uplane32; |
| 339 | struct v4l2_plane __user *uplane; |
| 340 | compat_caddr_t p; |
| 341 | int num_planes; |
| 342 | int ret; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 343 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 344 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_buffer32)) || |
| 345 | get_user(kp->index, &up->index) || |
| 346 | get_user(kp->type, &up->type) || |
| 347 | get_user(kp->flags, &up->flags) || |
| 348 | get_user(kp->memory, &up->memory) || |
| 349 | get_user(kp->input, &up->input)) |
| 350 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 351 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 352 | if (V4L2_TYPE_IS_OUTPUT(kp->type)) |
| 353 | if (get_user(kp->bytesused, &up->bytesused) || |
| 354 | get_user(kp->field, &up->field) || |
| 355 | get_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) || |
| 356 | get_user(kp->timestamp.tv_usec, |
| 357 | &up->timestamp.tv_usec)) |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 358 | return -EFAULT; |
| 359 | |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 360 | if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) { |
| 361 | if (get_user(kp->length, &up->length)) |
| 362 | return -EFAULT; |
| 363 | |
| 364 | num_planes = kp->length; |
| 365 | if (num_planes == 0) { |
| 366 | kp->m.planes = NULL; |
| 367 | /* num_planes == 0 is legal, e.g. when userspace doesn't |
| 368 | * need planes array on DQBUF*/ |
| 369 | return 0; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 370 | } |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 371 | |
| 372 | if (get_user(p, &up->m.planes)) |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 373 | return -EFAULT; |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 374 | |
| 375 | uplane32 = compat_ptr(p); |
| 376 | if (!access_ok(VERIFY_READ, uplane32, |
| 377 | num_planes * sizeof(struct v4l2_plane32))) |
| 378 | return -EFAULT; |
| 379 | |
| 380 | /* We don't really care if userspace decides to kill itself |
| 381 | * by passing a very big num_planes value */ |
| 382 | uplane = compat_alloc_user_space(num_planes * |
| 383 | sizeof(struct v4l2_plane)); |
| 384 | kp->m.planes = uplane; |
| 385 | |
| 386 | while (--num_planes >= 0) { |
| 387 | ret = get_v4l2_plane32(uplane, uplane32, kp->memory); |
| 388 | if (ret) |
| 389 | return ret; |
| 390 | ++uplane; |
| 391 | ++uplane32; |
| 392 | } |
| 393 | } else { |
| 394 | switch (kp->memory) { |
| 395 | case V4L2_MEMORY_MMAP: |
| 396 | if (get_user(kp->length, &up->length) || |
| 397 | get_user(kp->m.offset, &up->m.offset)) |
| 398 | return -EFAULT; |
| 399 | break; |
| 400 | case V4L2_MEMORY_USERPTR: |
| 401 | { |
| 402 | compat_long_t tmp; |
| 403 | |
| 404 | if (get_user(kp->length, &up->length) || |
| 405 | get_user(tmp, &up->m.userptr)) |
| 406 | return -EFAULT; |
| 407 | |
| 408 | kp->m.userptr = (unsigned long)compat_ptr(tmp); |
| 409 | } |
| 410 | break; |
| 411 | case V4L2_MEMORY_OVERLAY: |
| 412 | if (get_user(kp->m.offset, &up->m.offset)) |
| 413 | return -EFAULT; |
| 414 | break; |
| 415 | } |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 416 | } |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 417 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 418 | return 0; |
| 419 | } |
| 420 | |
| 421 | static int put_v4l2_buffer32(struct v4l2_buffer *kp, struct v4l2_buffer32 __user *up) |
| 422 | { |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 423 | struct v4l2_plane32 __user *uplane32; |
| 424 | struct v4l2_plane __user *uplane; |
| 425 | compat_caddr_t p; |
| 426 | int num_planes; |
| 427 | int ret; |
| 428 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 429 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_buffer32)) || |
| 430 | put_user(kp->index, &up->index) || |
| 431 | put_user(kp->type, &up->type) || |
| 432 | put_user(kp->flags, &up->flags) || |
| 433 | put_user(kp->memory, &up->memory) || |
| 434 | put_user(kp->input, &up->input)) |
| 435 | return -EFAULT; |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 436 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 437 | if (put_user(kp->bytesused, &up->bytesused) || |
| 438 | put_user(kp->field, &up->field) || |
| 439 | put_user(kp->timestamp.tv_sec, &up->timestamp.tv_sec) || |
| 440 | put_user(kp->timestamp.tv_usec, &up->timestamp.tv_usec) || |
| 441 | copy_to_user(&up->timecode, &kp->timecode, sizeof(struct v4l2_timecode)) || |
| 442 | put_user(kp->sequence, &up->sequence) || |
| 443 | put_user(kp->reserved, &up->reserved)) |
| 444 | return -EFAULT; |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 445 | |
| 446 | if (V4L2_TYPE_IS_MULTIPLANAR(kp->type)) { |
| 447 | num_planes = kp->length; |
| 448 | if (num_planes == 0) |
| 449 | return 0; |
| 450 | |
| 451 | uplane = kp->m.planes; |
| 452 | if (get_user(p, &up->m.planes)) |
| 453 | return -EFAULT; |
| 454 | uplane32 = compat_ptr(p); |
| 455 | |
| 456 | while (--num_planes >= 0) { |
| 457 | ret = put_v4l2_plane32(uplane, uplane32, kp->memory); |
| 458 | if (ret) |
| 459 | return ret; |
| 460 | ++uplane; |
| 461 | ++uplane32; |
| 462 | } |
| 463 | } else { |
| 464 | switch (kp->memory) { |
| 465 | case V4L2_MEMORY_MMAP: |
| 466 | if (put_user(kp->length, &up->length) || |
| 467 | put_user(kp->m.offset, &up->m.offset)) |
| 468 | return -EFAULT; |
| 469 | break; |
| 470 | case V4L2_MEMORY_USERPTR: |
| 471 | if (put_user(kp->length, &up->length) || |
| 472 | put_user(kp->m.userptr, &up->m.userptr)) |
| 473 | return -EFAULT; |
| 474 | break; |
| 475 | case V4L2_MEMORY_OVERLAY: |
| 476 | if (put_user(kp->m.offset, &up->m.offset)) |
| 477 | return -EFAULT; |
| 478 | break; |
| 479 | } |
| 480 | } |
| 481 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 482 | return 0; |
| 483 | } |
| 484 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 485 | struct v4l2_framebuffer32 { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 486 | __u32 capability; |
| 487 | __u32 flags; |
| 488 | compat_caddr_t base; |
| 489 | struct v4l2_pix_format fmt; |
| 490 | }; |
| 491 | |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 492 | static int get_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up) |
| 493 | { |
| 494 | u32 tmp; |
| 495 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 496 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_framebuffer32)) || |
| 497 | get_user(tmp, &up->base) || |
| 498 | get_user(kp->capability, &up->capability) || |
| 499 | get_user(kp->flags, &up->flags)) |
| 500 | return -EFAULT; |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 501 | kp->base = compat_ptr(tmp); |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 502 | get_v4l2_pix_format(&kp->fmt, &up->fmt); |
| 503 | return 0; |
| 504 | } |
| 505 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 506 | static int put_v4l2_framebuffer32(struct v4l2_framebuffer *kp, struct v4l2_framebuffer32 __user *up) |
| 507 | { |
| 508 | u32 tmp = (u32)((unsigned long)kp->base); |
| 509 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 510 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_framebuffer32)) || |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 511 | put_user(tmp, &up->base) || |
| 512 | put_user(kp->capability, &up->capability) || |
| 513 | put_user(kp->flags, &up->flags)) |
| 514 | return -EFAULT; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 515 | put_v4l2_pix_format(&kp->fmt, &up->fmt); |
| 516 | return 0; |
| 517 | } |
| 518 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 519 | struct v4l2_input32 { |
| 520 | __u32 index; /* Which input */ |
| 521 | __u8 name[32]; /* Label */ |
| 522 | __u32 type; /* Type of input */ |
| 523 | __u32 audioset; /* Associated audios (bitfield) */ |
| 524 | __u32 tuner; /* Associated tuner */ |
| 525 | v4l2_std_id std; |
| 526 | __u32 status; |
| 527 | __u32 reserved[4]; |
| 528 | } __attribute__ ((packed)); |
| 529 | |
| 530 | /* The 64-bit v4l2_input struct has extra padding at the end of the struct. |
| 531 | Otherwise it is identical to the 32-bit version. */ |
| 532 | static inline int get_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __user *up) |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 533 | { |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 534 | if (copy_from_user(kp, up, sizeof(struct v4l2_input32))) |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 535 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 536 | return 0; |
| 537 | } |
| 538 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 539 | static inline int put_v4l2_input32(struct v4l2_input *kp, struct v4l2_input32 __user *up) |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 540 | { |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 541 | if (copy_to_user(up, kp, sizeof(struct v4l2_input32))) |
Al Viro | 5b1a43d | 2006-02-01 05:24:20 -0500 | [diff] [blame] | 542 | return -EFAULT; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 543 | return 0; |
| 544 | } |
| 545 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 546 | struct v4l2_ext_controls32 { |
| 547 | __u32 ctrl_class; |
| 548 | __u32 count; |
| 549 | __u32 error_idx; |
| 550 | __u32 reserved[2]; |
| 551 | compat_caddr_t controls; /* actually struct v4l2_ext_control32 * */ |
Mauro Carvalho Chehab | eb4eecc | 2006-07-21 18:53:23 -0300 | [diff] [blame] | 552 | }; |
| 553 | |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 554 | struct v4l2_ext_control32 { |
| 555 | __u32 id; |
| 556 | __u32 size; |
| 557 | __u32 reserved2[1]; |
| 558 | union { |
| 559 | __s32 value; |
| 560 | __s64 value64; |
| 561 | compat_caddr_t string; /* actually char * */ |
| 562 | }; |
| 563 | } __attribute__ ((packed)); |
| 564 | |
| 565 | /* The following function really belong in v4l2-common, but that causes |
| 566 | a circular dependency between modules. We need to think about this, but |
| 567 | for now this will do. */ |
| 568 | |
| 569 | /* Return non-zero if this control is a pointer type. Currently only |
Eduardo Valentin | fdf82dc | 2009-08-11 18:49:12 -0300 | [diff] [blame] | 570 | type STRING is a pointer type. */ |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 571 | static inline int ctrl_is_pointer(u32 id) |
| 572 | { |
Eduardo Valentin | fdf82dc | 2009-08-11 18:49:12 -0300 | [diff] [blame] | 573 | switch (id) { |
| 574 | case V4L2_CID_RDS_TX_PS_NAME: |
| 575 | case V4L2_CID_RDS_TX_RADIO_TEXT: |
| 576 | return 1; |
| 577 | default: |
| 578 | return 0; |
| 579 | } |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 580 | } |
| 581 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 582 | static int get_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up) |
Mauro Carvalho Chehab | eb4eecc | 2006-07-21 18:53:23 -0300 | [diff] [blame] | 583 | { |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 584 | struct v4l2_ext_control32 __user *ucontrols; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 585 | struct v4l2_ext_control __user *kcontrols; |
| 586 | int n; |
| 587 | compat_caddr_t p; |
| 588 | |
| 589 | if (!access_ok(VERIFY_READ, up, sizeof(struct v4l2_ext_controls32)) || |
| 590 | get_user(kp->ctrl_class, &up->ctrl_class) || |
| 591 | get_user(kp->count, &up->count) || |
| 592 | get_user(kp->error_idx, &up->error_idx) || |
| 593 | copy_from_user(kp->reserved, up->reserved, sizeof(kp->reserved))) |
Mauro Carvalho Chehab | eb4eecc | 2006-07-21 18:53:23 -0300 | [diff] [blame] | 594 | return -EFAULT; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 595 | n = kp->count; |
| 596 | if (n == 0) { |
| 597 | kp->controls = NULL; |
| 598 | return 0; |
| 599 | } |
| 600 | if (get_user(p, &up->controls)) |
| 601 | return -EFAULT; |
| 602 | ucontrols = compat_ptr(p); |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 603 | if (!access_ok(VERIFY_READ, ucontrols, |
| 604 | n * sizeof(struct v4l2_ext_control32))) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 605 | return -EFAULT; |
| 606 | kcontrols = compat_alloc_user_space(n * sizeof(struct v4l2_ext_control)); |
| 607 | kp->controls = kcontrols; |
| 608 | while (--n >= 0) { |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 609 | if (copy_in_user(kcontrols, ucontrols, sizeof(*ucontrols))) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 610 | return -EFAULT; |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 611 | if (ctrl_is_pointer(kcontrols->id)) { |
| 612 | void __user *s; |
| 613 | |
| 614 | if (get_user(p, &ucontrols->string)) |
| 615 | return -EFAULT; |
| 616 | s = compat_ptr(p); |
| 617 | if (put_user(s, &kcontrols->string)) |
| 618 | return -EFAULT; |
| 619 | } |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 620 | ucontrols++; |
| 621 | kcontrols++; |
| 622 | } |
Mauro Carvalho Chehab | eb4eecc | 2006-07-21 18:53:23 -0300 | [diff] [blame] | 623 | return 0; |
| 624 | } |
| 625 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 626 | static int put_v4l2_ext_controls32(struct v4l2_ext_controls *kp, struct v4l2_ext_controls32 __user *up) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 627 | { |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 628 | struct v4l2_ext_control32 __user *ucontrols; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 629 | struct v4l2_ext_control __user *kcontrols = kp->controls; |
| 630 | int n = kp->count; |
| 631 | compat_caddr_t p; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 632 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 633 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_ext_controls32)) || |
| 634 | put_user(kp->ctrl_class, &up->ctrl_class) || |
| 635 | put_user(kp->count, &up->count) || |
| 636 | put_user(kp->error_idx, &up->error_idx) || |
| 637 | copy_to_user(up->reserved, kp->reserved, sizeof(up->reserved))) |
| 638 | return -EFAULT; |
| 639 | if (!kp->count) |
| 640 | return 0; |
| 641 | |
| 642 | if (get_user(p, &up->controls)) |
| 643 | return -EFAULT; |
| 644 | ucontrols = compat_ptr(p); |
Pawel Osciak | 52a3082 | 2010-07-29 14:56:47 -0300 | [diff] [blame] | 645 | if (!access_ok(VERIFY_WRITE, ucontrols, |
| 646 | n * sizeof(struct v4l2_ext_control32))) |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 647 | return -EFAULT; |
| 648 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 649 | while (--n >= 0) { |
Hans Verkuil | 6b5a949 | 2009-08-11 18:47:18 -0300 | [diff] [blame] | 650 | unsigned size = sizeof(*ucontrols); |
| 651 | |
| 652 | /* Do not modify the pointer when copying a pointer control. |
| 653 | The contents of the pointer was changed, not the pointer |
| 654 | itself. */ |
| 655 | if (ctrl_is_pointer(kcontrols->id)) |
| 656 | size -= sizeof(ucontrols->value64); |
| 657 | if (copy_in_user(ucontrols, kcontrols, size)) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 658 | return -EFAULT; |
| 659 | ucontrols++; |
| 660 | kcontrols++; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 661 | } |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 662 | return 0; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 663 | } |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 664 | |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 665 | struct v4l2_event32 { |
| 666 | __u32 type; |
| 667 | union { |
| 668 | __u8 data[64]; |
| 669 | } u; |
| 670 | __u32 pending; |
| 671 | __u32 sequence; |
| 672 | struct compat_timespec timestamp; |
| 673 | __u32 id; |
| 674 | __u32 reserved[8]; |
| 675 | }; |
| 676 | |
| 677 | static int put_v4l2_event32(struct v4l2_event *kp, struct v4l2_event32 __user *up) |
| 678 | { |
| 679 | if (!access_ok(VERIFY_WRITE, up, sizeof(struct v4l2_event32)) || |
| 680 | put_user(kp->type, &up->type) || |
| 681 | copy_to_user(&up->u, &kp->u, sizeof(kp->u)) || |
| 682 | put_user(kp->pending, &up->pending) || |
| 683 | put_user(kp->sequence, &up->sequence) || |
| 684 | put_compat_timespec(&kp->timestamp, &up->timestamp) || |
| 685 | put_user(kp->id, &up->id) || |
| 686 | copy_to_user(up->reserved, kp->reserved, 8 * sizeof(__u32))) |
| 687 | return -EFAULT; |
| 688 | return 0; |
| 689 | } |
| 690 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 691 | #define VIDIOC_G_FMT32 _IOWR('V', 4, struct v4l2_format32) |
| 692 | #define VIDIOC_S_FMT32 _IOWR('V', 5, struct v4l2_format32) |
| 693 | #define VIDIOC_QUERYBUF32 _IOWR('V', 9, struct v4l2_buffer32) |
| 694 | #define VIDIOC_G_FBUF32 _IOR ('V', 10, struct v4l2_framebuffer32) |
| 695 | #define VIDIOC_S_FBUF32 _IOW ('V', 11, struct v4l2_framebuffer32) |
| 696 | #define VIDIOC_QBUF32 _IOWR('V', 15, struct v4l2_buffer32) |
| 697 | #define VIDIOC_DQBUF32 _IOWR('V', 17, struct v4l2_buffer32) |
| 698 | #define VIDIOC_ENUMSTD32 _IOWR('V', 25, struct v4l2_standard32) |
| 699 | #define VIDIOC_ENUMINPUT32 _IOWR('V', 26, struct v4l2_input32) |
| 700 | #define VIDIOC_TRY_FMT32 _IOWR('V', 64, struct v4l2_format32) |
| 701 | #define VIDIOC_G_EXT_CTRLS32 _IOWR('V', 71, struct v4l2_ext_controls32) |
| 702 | #define VIDIOC_S_EXT_CTRLS32 _IOWR('V', 72, struct v4l2_ext_controls32) |
| 703 | #define VIDIOC_TRY_EXT_CTRLS32 _IOWR('V', 73, struct v4l2_ext_controls32) |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 704 | #define VIDIOC_DQEVENT32 _IOR ('V', 89, struct v4l2_event32) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 705 | |
| 706 | #define VIDIOC_OVERLAY32 _IOW ('V', 14, s32) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 707 | #define VIDIOC_STREAMON32 _IOW ('V', 18, s32) |
| 708 | #define VIDIOC_STREAMOFF32 _IOW ('V', 19, s32) |
| 709 | #define VIDIOC_G_INPUT32 _IOR ('V', 38, s32) |
| 710 | #define VIDIOC_S_INPUT32 _IOWR('V', 39, s32) |
| 711 | #define VIDIOC_G_OUTPUT32 _IOR ('V', 46, s32) |
| 712 | #define VIDIOC_S_OUTPUT32 _IOWR('V', 47, s32) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 713 | |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 714 | static long do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 715 | { |
| 716 | union { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 717 | struct v4l2_format v2f; |
| 718 | struct v4l2_buffer v2b; |
| 719 | struct v4l2_framebuffer v2fb; |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 720 | struct v4l2_input v2i; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 721 | struct v4l2_standard v2s; |
| 722 | struct v4l2_ext_controls v2ecs; |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 723 | struct v4l2_event v2ev; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 724 | unsigned long vx; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 725 | int vi; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 726 | } karg; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 727 | void __user *up = compat_ptr(arg); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 728 | int compatible_arg = 1; |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 729 | long err = 0; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 730 | |
| 731 | /* First, convert the command. */ |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 732 | switch (cmd) { |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 733 | case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; |
| 734 | case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; |
| 735 | case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; |
| 736 | case VIDIOC_G_FBUF32: cmd = VIDIOC_G_FBUF; break; |
| 737 | case VIDIOC_S_FBUF32: cmd = VIDIOC_S_FBUF; break; |
| 738 | case VIDIOC_QBUF32: cmd = VIDIOC_QBUF; break; |
| 739 | case VIDIOC_DQBUF32: cmd = VIDIOC_DQBUF; break; |
| 740 | case VIDIOC_ENUMSTD32: cmd = VIDIOC_ENUMSTD; break; |
| 741 | case VIDIOC_ENUMINPUT32: cmd = VIDIOC_ENUMINPUT; break; |
| 742 | case VIDIOC_TRY_FMT32: cmd = VIDIOC_TRY_FMT; break; |
| 743 | case VIDIOC_G_EXT_CTRLS32: cmd = VIDIOC_G_EXT_CTRLS; break; |
| 744 | case VIDIOC_S_EXT_CTRLS32: cmd = VIDIOC_S_EXT_CTRLS; break; |
| 745 | case VIDIOC_TRY_EXT_CTRLS32: cmd = VIDIOC_TRY_EXT_CTRLS; break; |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 746 | case VIDIOC_DQEVENT32: cmd = VIDIOC_DQEVENT; break; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 747 | case VIDIOC_OVERLAY32: cmd = VIDIOC_OVERLAY; break; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 748 | case VIDIOC_STREAMON32: cmd = VIDIOC_STREAMON; break; |
| 749 | case VIDIOC_STREAMOFF32: cmd = VIDIOC_STREAMOFF; break; |
| 750 | case VIDIOC_G_INPUT32: cmd = VIDIOC_G_INPUT; break; |
| 751 | case VIDIOC_S_INPUT32: cmd = VIDIOC_S_INPUT; break; |
| 752 | case VIDIOC_G_OUTPUT32: cmd = VIDIOC_G_OUTPUT; break; |
| 753 | case VIDIOC_S_OUTPUT32: cmd = VIDIOC_S_OUTPUT; break; |
| 754 | } |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 755 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 756 | switch (cmd) { |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 757 | case VIDIOC_OVERLAY: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 758 | case VIDIOC_STREAMON: |
| 759 | case VIDIOC_STREAMOFF: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 760 | case VIDIOC_S_INPUT: |
| 761 | case VIDIOC_S_OUTPUT: |
| 762 | err = get_user(karg.vi, (s32 __user *)up); |
| 763 | compatible_arg = 0; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 764 | break; |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 765 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 766 | case VIDIOC_G_INPUT: |
| 767 | case VIDIOC_G_OUTPUT: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 768 | compatible_arg = 0; |
| 769 | break; |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 770 | |
| 771 | case VIDIOC_G_FMT: |
| 772 | case VIDIOC_S_FMT: |
| 773 | case VIDIOC_TRY_FMT: |
| 774 | err = get_v4l2_format32(&karg.v2f, up); |
| 775 | compatible_arg = 0; |
| 776 | break; |
| 777 | |
| 778 | case VIDIOC_QUERYBUF: |
| 779 | case VIDIOC_QBUF: |
| 780 | case VIDIOC_DQBUF: |
| 781 | err = get_v4l2_buffer32(&karg.v2b, up); |
| 782 | compatible_arg = 0; |
| 783 | break; |
| 784 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 785 | case VIDIOC_S_FBUF: |
| 786 | err = get_v4l2_framebuffer32(&karg.v2fb, up); |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 787 | compatible_arg = 0; |
| 788 | break; |
| 789 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 790 | case VIDIOC_G_FBUF: |
| 791 | compatible_arg = 0; |
| 792 | break; |
| 793 | |
| 794 | case VIDIOC_ENUMSTD: |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 795 | err = get_v4l2_standard32(&karg.v2s, up); |
| 796 | compatible_arg = 0; |
| 797 | break; |
| 798 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 799 | case VIDIOC_ENUMINPUT: |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 800 | err = get_v4l2_input32(&karg.v2i, up); |
| 801 | compatible_arg = 0; |
| 802 | break; |
| 803 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 804 | case VIDIOC_G_EXT_CTRLS: |
| 805 | case VIDIOC_S_EXT_CTRLS: |
| 806 | case VIDIOC_TRY_EXT_CTRLS: |
| 807 | err = get_v4l2_ext_controls32(&karg.v2ecs, up); |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 808 | compatible_arg = 0; |
| 809 | break; |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 810 | case VIDIOC_DQEVENT: |
| 811 | compatible_arg = 0; |
| 812 | break; |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 813 | } |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 814 | if (err) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 815 | return err; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 816 | |
Hans Verkuil | d1f81da | 2008-10-22 00:04:45 -0300 | [diff] [blame] | 817 | if (compatible_arg) |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 818 | err = native_ioctl(file, cmd, (unsigned long)up); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 819 | else { |
| 820 | mm_segment_t old_fs = get_fs(); |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 821 | |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 822 | set_fs(KERNEL_DS); |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 823 | err = native_ioctl(file, cmd, (unsigned long)&karg); |
Philippe De Muyter | cf664a6 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 824 | set_fs(old_fs); |
| 825 | } |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 826 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 827 | /* Special case: even after an error we need to put the |
| 828 | results back for these ioctls since the error_idx will |
| 829 | contain information on which control failed. */ |
| 830 | switch (cmd) { |
| 831 | case VIDIOC_G_EXT_CTRLS: |
| 832 | case VIDIOC_S_EXT_CTRLS: |
| 833 | case VIDIOC_TRY_EXT_CTRLS: |
| 834 | if (put_v4l2_ext_controls32(&karg.v2ecs, up)) |
| 835 | err = -EFAULT; |
| 836 | break; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 837 | } |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 838 | if (err) |
| 839 | return err; |
| 840 | |
| 841 | switch (cmd) { |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 842 | case VIDIOC_S_INPUT: |
| 843 | case VIDIOC_S_OUTPUT: |
| 844 | case VIDIOC_G_INPUT: |
| 845 | case VIDIOC_G_OUTPUT: |
| 846 | err = put_user(((s32)karg.vi), (s32 __user *)up); |
| 847 | break; |
| 848 | |
| 849 | case VIDIOC_G_FBUF: |
| 850 | err = put_v4l2_framebuffer32(&karg.v2fb, up); |
| 851 | break; |
| 852 | |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 853 | case VIDIOC_DQEVENT: |
| 854 | err = put_v4l2_event32(&karg.v2ev, up); |
| 855 | break; |
| 856 | |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 857 | case VIDIOC_G_FMT: |
| 858 | case VIDIOC_S_FMT: |
| 859 | case VIDIOC_TRY_FMT: |
| 860 | err = put_v4l2_format32(&karg.v2f, up); |
| 861 | break; |
| 862 | |
| 863 | case VIDIOC_QUERYBUF: |
| 864 | case VIDIOC_QBUF: |
| 865 | case VIDIOC_DQBUF: |
| 866 | err = put_v4l2_buffer32(&karg.v2b, up); |
| 867 | break; |
| 868 | |
| 869 | case VIDIOC_ENUMSTD: |
| 870 | err = put_v4l2_standard32(&karg.v2s, up); |
| 871 | break; |
| 872 | |
| 873 | case VIDIOC_ENUMINPUT: |
| 874 | err = put_v4l2_input32(&karg.v2i, up); |
| 875 | break; |
| 876 | } |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 877 | return err; |
| 878 | } |
| 879 | |
Hans Verkuil | 9bb7cde | 2008-12-30 06:42:40 -0300 | [diff] [blame] | 880 | long v4l2_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 881 | { |
Hans Verkuil | 069b747 | 2008-12-30 07:04:34 -0300 | [diff] [blame] | 882 | long ret = -ENOIOCTLCMD; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 883 | |
Frederic Weisbecker | c6d7ba8 | 2010-08-13 22:29:03 +0200 | [diff] [blame] | 884 | if (!file->f_op->unlocked_ioctl) |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 885 | return ret; |
| 886 | |
| 887 | switch (cmd) { |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 888 | case VIDIOC_QUERYCAP: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 889 | case VIDIOC_RESERVED: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 890 | case VIDIOC_ENUM_FMT: |
| 891 | case VIDIOC_G_FMT32: |
| 892 | case VIDIOC_S_FMT32: |
| 893 | case VIDIOC_REQBUFS: |
| 894 | case VIDIOC_QUERYBUF32: |
| 895 | case VIDIOC_G_FBUF32: |
| 896 | case VIDIOC_S_FBUF32: |
| 897 | case VIDIOC_OVERLAY32: |
| 898 | case VIDIOC_QBUF32: |
| 899 | case VIDIOC_DQBUF32: |
| 900 | case VIDIOC_STREAMON32: |
| 901 | case VIDIOC_STREAMOFF32: |
| 902 | case VIDIOC_G_PARM: |
Gregor Jasny | c7f09db | 2008-10-23 09:55:22 -0300 | [diff] [blame] | 903 | case VIDIOC_S_PARM: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 904 | case VIDIOC_G_STD: |
| 905 | case VIDIOC_S_STD: |
| 906 | case VIDIOC_ENUMSTD32: |
| 907 | case VIDIOC_ENUMINPUT32: |
| 908 | case VIDIOC_G_CTRL: |
Steven Walter | 7963fa4 | 2007-08-09 11:36:35 -0300 | [diff] [blame] | 909 | case VIDIOC_S_CTRL: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 910 | case VIDIOC_G_TUNER: |
| 911 | case VIDIOC_S_TUNER: |
| 912 | case VIDIOC_G_AUDIO: |
| 913 | case VIDIOC_S_AUDIO: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 914 | case VIDIOC_QUERYCTRL: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 915 | case VIDIOC_QUERYMENU: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 916 | case VIDIOC_G_INPUT32: |
| 917 | case VIDIOC_S_INPUT32: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 918 | case VIDIOC_G_OUTPUT32: |
| 919 | case VIDIOC_S_OUTPUT32: |
| 920 | case VIDIOC_ENUMOUTPUT: |
| 921 | case VIDIOC_G_AUDOUT: |
| 922 | case VIDIOC_S_AUDOUT: |
| 923 | case VIDIOC_G_MODULATOR: |
| 924 | case VIDIOC_S_MODULATOR: |
| 925 | case VIDIOC_S_FREQUENCY: |
| 926 | case VIDIOC_G_FREQUENCY: |
| 927 | case VIDIOC_CROPCAP: |
| 928 | case VIDIOC_G_CROP: |
| 929 | case VIDIOC_S_CROP: |
| 930 | case VIDIOC_G_JPEGCOMP: |
| 931 | case VIDIOC_S_JPEGCOMP: |
| 932 | case VIDIOC_QUERYSTD: |
Philippe De Muyter | 13d133b | 2006-01-09 15:25:00 -0200 | [diff] [blame] | 933 | case VIDIOC_TRY_FMT32: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 934 | case VIDIOC_ENUMAUDIO: |
| 935 | case VIDIOC_ENUMAUDOUT: |
| 936 | case VIDIOC_G_PRIORITY: |
| 937 | case VIDIOC_S_PRIORITY: |
| 938 | case VIDIOC_G_SLICED_VBI_CAP: |
| 939 | case VIDIOC_LOG_STATUS: |
| 940 | case VIDIOC_G_EXT_CTRLS32: |
| 941 | case VIDIOC_S_EXT_CTRLS32: |
| 942 | case VIDIOC_TRY_EXT_CTRLS32: |
Gregor Jasny | c7f09db | 2008-10-23 09:55:22 -0300 | [diff] [blame] | 943 | case VIDIOC_ENUM_FRAMESIZES: |
| 944 | case VIDIOC_ENUM_FRAMEINTERVALS: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 945 | case VIDIOC_G_ENC_INDEX: |
| 946 | case VIDIOC_ENCODER_CMD: |
| 947 | case VIDIOC_TRY_ENCODER_CMD: |
| 948 | case VIDIOC_DBG_S_REGISTER: |
| 949 | case VIDIOC_DBG_G_REGISTER: |
Hans Verkuil | aecde8b | 2008-12-30 07:14:19 -0300 | [diff] [blame] | 950 | case VIDIOC_DBG_G_CHIP_IDENT: |
Hans Verkuil | 92f45ba | 2008-12-21 10:35:25 -0300 | [diff] [blame] | 951 | case VIDIOC_S_HW_FREQ_SEEK: |
Muralidharan Karicheri | b6456c0 | 2009-11-19 12:00:31 -0300 | [diff] [blame] | 952 | case VIDIOC_ENUM_DV_PRESETS: |
| 953 | case VIDIOC_S_DV_PRESET: |
| 954 | case VIDIOC_G_DV_PRESET: |
| 955 | case VIDIOC_QUERY_DV_PRESET: |
| 956 | case VIDIOC_S_DV_TIMINGS: |
| 957 | case VIDIOC_G_DV_TIMINGS: |
Sakari Ailus | fda1021 | 2010-02-24 19:19:05 -0300 | [diff] [blame] | 958 | case VIDIOC_DQEVENT: |
Hans Verkuil | 2330fb8 | 2011-06-07 11:43:57 -0300 | [diff] [blame] | 959 | case VIDIOC_DQEVENT32: |
Sakari Ailus | fda1021 | 2010-02-24 19:19:05 -0300 | [diff] [blame] | 960 | case VIDIOC_SUBSCRIBE_EVENT: |
| 961 | case VIDIOC_UNSUBSCRIBE_EVENT: |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 962 | ret = do_video_ioctl(file, cmd, arg); |
| 963 | break; |
| 964 | |
Guy Martin | a113bc7 | 2006-01-11 23:40:51 -0200 | [diff] [blame] | 965 | default: |
Hans Verkuil | 7943ecf | 2008-12-23 14:37:43 -0300 | [diff] [blame] | 966 | printk(KERN_WARNING "compat_ioctl32: " |
| 967 | "unknown ioctl '%c', dir=%d, #%d (0x%08x)\n", |
| 968 | _IOC_TYPE(cmd), _IOC_DIR(cmd), _IOC_NR(cmd), cmd); |
Hans Verkuil | 7d4f0b8 | 2008-12-15 07:19:20 -0300 | [diff] [blame] | 969 | break; |
MishalĂ… Pytasz | 97e2a01 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 970 | } |
Hans Verkuil | e8efb71 | 2006-01-09 15:24:59 -0200 | [diff] [blame] | 971 | return ret; |
Arnd Bergmann | 0d0fbf8 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 972 | } |
Hans Verkuil | 9bb7cde | 2008-12-30 06:42:40 -0300 | [diff] [blame] | 973 | EXPORT_SYMBOL_GPL(v4l2_compat_ioctl32); |
Hans Verkuil | bec4366 | 2008-12-30 06:58:20 -0300 | [diff] [blame] | 974 | #endif |
Ricardo Cerqueira | 925e699 | 2006-01-09 15:24:57 -0200 | [diff] [blame] | 975 | |
| 976 | MODULE_LICENSE("GPL"); |