diff options
author | Arnd Bergmann <arnd@arndb.de> | 2006-01-09 12:24:57 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-09 12:24:57 -0500 |
commit | 0d0fbf8152fb3bb4393be11e8df7f70e1fbbd738 (patch) | |
tree | 98ef8850e6b769da7391665716e4e2348de21ec1 /fs | |
parent | 5367f2d67c7d0bf1faae90e6e7b4e2ac3c9b5e0f (diff) |
V4L (926_2): Moves compat32 functions from fs to v4l subsystem
This moves the 32 bit ioctl compatibility handlers for
Video4Linux into a new file and adds explicit calls to them
to each v4l device driver.
Unfortunately, there does not seem to be any code handling
the v4l2 ioctls, so quite often the code goes through two
separate conversions, first from 32 bit v4l to 64 bit v4l,
and from there to 64 bit v4l2. My patch does not change
that, so there is still much room for improvement.
Also, some drivers have additional ioctl numbers, for
which the conversion should be handled internally to
that driver.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/compat_ioctl.c | 246 |
1 files changed, 0 insertions, 246 deletions
diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index 43a2508ac69..55d9a3a954c 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c | |||
@@ -207,244 +207,6 @@ static int do_ext3_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | |||
207 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); | 207 | return sys_ioctl(fd, cmd, (unsigned long)compat_ptr(arg)); |
208 | } | 208 | } |
209 | 209 | ||
210 | struct video_tuner32 { | ||
211 | compat_int_t tuner; | ||
212 | char name[32]; | ||
213 | compat_ulong_t rangelow, rangehigh; | ||
214 | u32 flags; /* It is really u32 in videodev.h */ | ||
215 | u16 mode, signal; | ||
216 | }; | ||
217 | |||
218 | static int get_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) | ||
219 | { | ||
220 | int i; | ||
221 | |||
222 | if(get_user(kp->tuner, &up->tuner)) | ||
223 | return -EFAULT; | ||
224 | for(i = 0; i < 32; i++) | ||
225 | __get_user(kp->name[i], &up->name[i]); | ||
226 | __get_user(kp->rangelow, &up->rangelow); | ||
227 | __get_user(kp->rangehigh, &up->rangehigh); | ||
228 | __get_user(kp->flags, &up->flags); | ||
229 | __get_user(kp->mode, &up->mode); | ||
230 | __get_user(kp->signal, &up->signal); | ||
231 | return 0; | ||
232 | } | ||
233 | |||
234 | static int put_video_tuner32(struct video_tuner *kp, struct video_tuner32 __user *up) | ||
235 | { | ||
236 | int i; | ||
237 | |||
238 | if(put_user(kp->tuner, &up->tuner)) | ||
239 | return -EFAULT; | ||
240 | for(i = 0; i < 32; i++) | ||
241 | __put_user(kp->name[i], &up->name[i]); | ||
242 | __put_user(kp->rangelow, &up->rangelow); | ||
243 | __put_user(kp->rangehigh, &up->rangehigh); | ||
244 | __put_user(kp->flags, &up->flags); | ||
245 | __put_user(kp->mode, &up->mode); | ||
246 | __put_user(kp->signal, &up->signal); | ||
247 | return 0; | ||
248 | } | ||
249 | |||
250 | struct video_buffer32 { | ||
251 | compat_caddr_t base; | ||
252 | compat_int_t height, width, depth, bytesperline; | ||
253 | }; | ||
254 | |||
255 | static int get_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) | ||
256 | { | ||
257 | u32 tmp; | ||
258 | |||
259 | if (get_user(tmp, &up->base)) | ||
260 | return -EFAULT; | ||
261 | |||
262 | /* This is actually a physical address stored | ||
263 | * as a void pointer. | ||
264 | */ | ||
265 | kp->base = (void *)(unsigned long) tmp; | ||
266 | |||
267 | __get_user(kp->height, &up->height); | ||
268 | __get_user(kp->width, &up->width); | ||
269 | __get_user(kp->depth, &up->depth); | ||
270 | __get_user(kp->bytesperline, &up->bytesperline); | ||
271 | return 0; | ||
272 | } | ||
273 | |||
274 | static int put_video_buffer32(struct video_buffer *kp, struct video_buffer32 __user *up) | ||
275 | { | ||
276 | u32 tmp = (u32)((unsigned long)kp->base); | ||
277 | |||
278 | if(put_user(tmp, &up->base)) | ||
279 | return -EFAULT; | ||
280 | __put_user(kp->height, &up->height); | ||
281 | __put_user(kp->width, &up->width); | ||
282 | __put_user(kp->depth, &up->depth); | ||
283 | __put_user(kp->bytesperline, &up->bytesperline); | ||
284 | return 0; | ||
285 | } | ||
286 | |||
287 | struct video_clip32 { | ||
288 | s32 x, y, width, height; /* Its really s32 in videodev.h */ | ||
289 | compat_caddr_t next; | ||
290 | }; | ||
291 | |||
292 | struct video_window32 { | ||
293 | u32 x, y, width, height, chromakey, flags; | ||
294 | compat_caddr_t clips; | ||
295 | compat_int_t clipcount; | ||
296 | }; | ||
297 | |||
298 | /* You get back everything except the clips... */ | ||
299 | static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) | ||
300 | { | ||
301 | if(put_user(kp->x, &up->x)) | ||
302 | return -EFAULT; | ||
303 | __put_user(kp->y, &up->y); | ||
304 | __put_user(kp->width, &up->width); | ||
305 | __put_user(kp->height, &up->height); | ||
306 | __put_user(kp->chromakey, &up->chromakey); | ||
307 | __put_user(kp->flags, &up->flags); | ||
308 | __put_user(kp->clipcount, &up->clipcount); | ||
309 | return 0; | ||
310 | } | ||
311 | |||
312 | #define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) | ||
313 | #define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) | ||
314 | #define VIDIOCGWIN32 _IOR('v',9, struct video_window32) | ||
315 | #define VIDIOCSWIN32 _IOW('v',10, struct video_window32) | ||
316 | #define VIDIOCGFBUF32 _IOR('v',11, struct video_buffer32) | ||
317 | #define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32) | ||
318 | #define VIDIOCGFREQ32 _IOR('v',14, u32) | ||
319 | #define VIDIOCSFREQ32 _IOW('v',15, u32) | ||
320 | |||
321 | enum { | ||
322 | MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip) | ||
323 | }; | ||
324 | |||
325 | static int do_set_window(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
326 | { | ||
327 | struct video_window32 __user *up = compat_ptr(arg); | ||
328 | struct video_window __user *vw; | ||
329 | struct video_clip __user *p; | ||
330 | int nclips; | ||
331 | u32 n; | ||
332 | |||
333 | if (get_user(nclips, &up->clipcount)) | ||
334 | return -EFAULT; | ||
335 | |||
336 | /* Peculiar interface... */ | ||
337 | if (nclips < 0) | ||
338 | nclips = VIDEO_CLIPMAP_SIZE; | ||
339 | |||
340 | if (nclips > MaxClips) | ||
341 | return -ENOMEM; | ||
342 | |||
343 | vw = compat_alloc_user_space(sizeof(struct video_window) + | ||
344 | nclips * sizeof(struct video_clip)); | ||
345 | |||
346 | p = nclips ? (struct video_clip __user *)(vw + 1) : NULL; | ||
347 | |||
348 | if (get_user(n, &up->x) || put_user(n, &vw->x) || | ||
349 | get_user(n, &up->y) || put_user(n, &vw->y) || | ||
350 | get_user(n, &up->width) || put_user(n, &vw->width) || | ||
351 | get_user(n, &up->height) || put_user(n, &vw->height) || | ||
352 | get_user(n, &up->chromakey) || put_user(n, &vw->chromakey) || | ||
353 | get_user(n, &up->flags) || put_user(n, &vw->flags) || | ||
354 | get_user(n, &up->clipcount) || put_user(n, &vw->clipcount) || | ||
355 | get_user(n, &up->clips) || put_user(p, &vw->clips)) | ||
356 | return -EFAULT; | ||
357 | |||
358 | if (nclips) { | ||
359 | struct video_clip32 __user *u = compat_ptr(n); | ||
360 | int i; | ||
361 | if (!u) | ||
362 | return -EINVAL; | ||
363 | for (i = 0; i < nclips; i++, u++, p++) { | ||
364 | s32 v; | ||
365 | if (get_user(v, &u->x) || | ||
366 | put_user(v, &p->x) || | ||
367 | get_user(v, &u->y) || | ||
368 | put_user(v, &p->y) || | ||
369 | get_user(v, &u->width) || | ||
370 | put_user(v, &p->width) || | ||
371 | get_user(v, &u->height) || | ||
372 | put_user(v, &p->height) || | ||
373 | put_user(NULL, &p->next)) | ||
374 | return -EFAULT; | ||
375 | } | ||
376 | } | ||
377 | |||
378 | return sys_ioctl(fd, VIDIOCSWIN, (unsigned long)p); | ||
379 | } | ||
380 | |||
381 | static int do_video_ioctl(unsigned int fd, unsigned int cmd, unsigned long arg) | ||
382 | { | ||
383 | union { | ||
384 | struct video_tuner vt; | ||
385 | struct video_buffer vb; | ||
386 | struct video_window vw; | ||
387 | unsigned long vx; | ||
388 | } karg; | ||
389 | mm_segment_t old_fs = get_fs(); | ||
390 | void __user *up = compat_ptr(arg); | ||
391 | int err = 0; | ||
392 | |||
393 | /* First, convert the command. */ | ||
394 | switch(cmd) { | ||
395 | case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; | ||
396 | case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; | ||
397 | case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; | ||
398 | case VIDIOCGFBUF32: cmd = VIDIOCGFBUF; break; | ||
399 | case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; | ||
400 | case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; | ||
401 | case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; | ||
402 | }; | ||
403 | |||
404 | switch(cmd) { | ||
405 | case VIDIOCSTUNER: | ||
406 | case VIDIOCGTUNER: | ||
407 | err = get_video_tuner32(&karg.vt, up); | ||
408 | break; | ||
409 | |||
410 | case VIDIOCSFBUF: | ||
411 | err = get_video_buffer32(&karg.vb, up); | ||
412 | break; | ||
413 | |||
414 | case VIDIOCSFREQ: | ||
415 | err = get_user(karg.vx, (u32 __user *)up); | ||
416 | break; | ||
417 | }; | ||
418 | if(err) | ||
419 | goto out; | ||
420 | |||
421 | set_fs(KERNEL_DS); | ||
422 | err = sys_ioctl(fd, cmd, (unsigned long)&karg); | ||
423 | set_fs(old_fs); | ||
424 | |||
425 | if(err == 0) { | ||
426 | switch(cmd) { | ||
427 | case VIDIOCGTUNER: | ||
428 | err = put_video_tuner32(&karg.vt, up); | ||
429 | break; | ||
430 | |||
431 | case VIDIOCGWIN: | ||
432 | err = put_video_window32(&karg.vw, up); | ||
433 | break; | ||
434 | |||
435 | case VIDIOCGFBUF: | ||
436 | err = put_video_buffer32(&karg.vb, up); | ||
437 | break; | ||
438 | |||
439 | case VIDIOCGFREQ: | ||
440 | err = put_user(((u32)karg.vx), (u32 __user *)up); | ||
441 | break; | ||
442 | }; | ||
443 | } | ||
444 | out: | ||
445 | return err; | ||
446 | } | ||
447 | |||
448 | struct compat_dmx_event { | 210 | struct compat_dmx_event { |
449 | dmx_event_t event; | 211 | dmx_event_t event; |
450 | compat_time_t timeStamp; | 212 | compat_time_t timeStamp; |
@@ -3015,14 +2777,6 @@ COMPATIBLE_IOCTL(EXT3_IOC_GROUP_ADD) | |||
3015 | #ifdef CONFIG_JBD_DEBUG | 2777 | #ifdef CONFIG_JBD_DEBUG |
3016 | HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl) | 2778 | HANDLE_IOCTL(EXT3_IOC32_WAIT_FOR_READONLY, do_ext3_ioctl) |
3017 | #endif | 2779 | #endif |
3018 | HANDLE_IOCTL(VIDIOCGTUNER32, do_video_ioctl) | ||
3019 | HANDLE_IOCTL(VIDIOCSTUNER32, do_video_ioctl) | ||
3020 | HANDLE_IOCTL(VIDIOCGWIN32, do_video_ioctl) | ||
3021 | HANDLE_IOCTL(VIDIOCSWIN32, do_set_window) | ||
3022 | HANDLE_IOCTL(VIDIOCGFBUF32, do_video_ioctl) | ||
3023 | HANDLE_IOCTL(VIDIOCSFBUF32, do_video_ioctl) | ||
3024 | HANDLE_IOCTL(VIDIOCGFREQ32, do_video_ioctl) | ||
3025 | HANDLE_IOCTL(VIDIOCSFREQ32, do_video_ioctl) | ||
3026 | /* One SMB ioctl needs translations. */ | 2780 | /* One SMB ioctl needs translations. */ |
3027 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) | 2781 | #define SMB_IOC_GETMOUNTUID_32 _IOR('u', 1, compat_uid_t) |
3028 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) | 2782 | HANDLE_IOCTL(SMB_IOC_GETMOUNTUID_32, do_smb_getmountuid) |