aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/compat_ioctl32.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/video/compat_ioctl32.c')
-rw-r--r--drivers/media/video/compat_ioctl32.c54
1 files changed, 51 insertions, 3 deletions
diff --git a/drivers/media/video/compat_ioctl32.c b/drivers/media/video/compat_ioctl32.c
index 353d02b67c33..b69ee1194815 100644
--- a/drivers/media/video/compat_ioctl32.c
+++ b/drivers/media/video/compat_ioctl32.c
@@ -21,7 +21,7 @@
21 21
22#ifdef CONFIG_COMPAT 22#ifdef CONFIG_COMPAT
23 23
24 24#ifdef CONFIG_VIDEO_V4L1_COMPAT
25struct video_tuner32 { 25struct video_tuner32 {
26 compat_int_t tuner; 26 compat_int_t tuner;
27 char name[32]; 27 char name[32];
@@ -107,6 +107,7 @@ struct video_window32 {
107 compat_caddr_t clips; 107 compat_caddr_t clips;
108 compat_int_t clipcount; 108 compat_int_t clipcount;
109}; 109};
110#endif
110 111
111static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 112static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
112{ 113{
@@ -124,6 +125,7 @@ static int native_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
124} 125}
125 126
126 127
128#ifdef CONFIG_VIDEO_V4L1_COMPAT
127/* You get back everything except the clips... */ 129/* You get back everything except the clips... */
128static int put_video_window32(struct video_window *kp, struct video_window32 __user *up) 130static int put_video_window32(struct video_window *kp, struct video_window32 __user *up)
129{ 131{
@@ -138,6 +140,7 @@ static int put_video_window32(struct video_window *kp, struct video_window32 __u
138 return -EFAULT; 140 return -EFAULT;
139 return 0; 141 return 0;
140} 142}
143#endif
141 144
142struct v4l2_clip32 145struct v4l2_clip32
143{ 146{
@@ -490,6 +493,24 @@ static inline int put_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user
490 return 0; 493 return 0;
491} 494}
492 495
496#ifdef CONFIG_VIDEO_V4L1_COMPAT
497struct video_code32
498{
499 char loadwhat[16]; /* name or tag of file being passed */
500 compat_int_t datasize;
501 unsigned char *data;
502};
503
504static inline int microcode32(struct video_code *kp, struct video_code32 __user *up)
505{
506 if(!access_ok(VERIFY_READ, up, sizeof(struct video_code32)) ||
507 copy_from_user(kp->loadwhat, up->loadwhat, sizeof (up->loadwhat)) ||
508 get_user(kp->datasize, &up->datasize) ||
509 copy_from_user(kp->data, up->data, up->datasize))
510 return -EFAULT;
511 return 0;
512}
513
493#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32) 514#define VIDIOCGTUNER32 _IOWR('v',4, struct video_tuner32)
494#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32) 515#define VIDIOCSTUNER32 _IOW('v',5, struct video_tuner32)
495#define VIDIOCGWIN32 _IOR('v',9, struct video_window32) 516#define VIDIOCGWIN32 _IOR('v',9, struct video_window32)
@@ -498,6 +519,9 @@ static inline int put_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user
498#define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32) 519#define VIDIOCSFBUF32 _IOW('v',12, struct video_buffer32)
499#define VIDIOCGFREQ32 _IOR('v',14, u32) 520#define VIDIOCGFREQ32 _IOR('v',14, u32)
500#define VIDIOCSFREQ32 _IOW('v',15, u32) 521#define VIDIOCSFREQ32 _IOW('v',15, u32)
522#define VIDIOCSMICROCODE32 _IOW('v',27, struct video_code32)
523
524#endif
501 525
502/* VIDIOC_ENUMINPUT32 is VIDIOC_ENUMINPUT minus 4 bytes of padding alignement */ 526/* VIDIOC_ENUMINPUT32 is VIDIOC_ENUMINPUT minus 4 bytes of padding alignement */
503#define VIDIOC_ENUMINPUT32 VIDIOC_ENUMINPUT - _IOC(0, 0, 0, 4) 527#define VIDIOC_ENUMINPUT32 VIDIOC_ENUMINPUT - _IOC(0, 0, 0, 4)
@@ -519,6 +543,7 @@ static inline int put_v4l2_input(struct v4l2_input *kp, struct v4l2_input __user
519#define VIDIOC_S_INPUT32 _IOWR ('V', 39, compat_int_t) 543#define VIDIOC_S_INPUT32 _IOWR ('V', 39, compat_int_t)
520#define VIDIOC_TRY_FMT32 _IOWR ('V', 64, struct v4l2_format32) 544#define VIDIOC_TRY_FMT32 _IOWR ('V', 64, struct v4l2_format32)
521 545
546#ifdef CONFIG_VIDEO_V4L1_COMPAT
522enum { 547enum {
523 MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip) 548 MaxClips = (~0U-sizeof(struct video_window))/sizeof(struct video_clip)
524}; 549};
@@ -583,13 +608,17 @@ static int do_set_window(struct file *file, unsigned int cmd, unsigned long arg)
583 608
584 return native_ioctl(file, VIDIOCSWIN, (unsigned long)vw); 609 return native_ioctl(file, VIDIOCSWIN, (unsigned long)vw);
585} 610}
611#endif
586 612
587static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 613static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
588{ 614{
589 union { 615 union {
616#ifdef CONFIG_VIDEO_V4L1_COMPAT
590 struct video_tuner vt; 617 struct video_tuner vt;
591 struct video_buffer vb; 618 struct video_buffer vb;
592 struct video_window vw; 619 struct video_window vw;
620 struct video_code vc;
621#endif
593 struct v4l2_format v2f; 622 struct v4l2_format v2f;
594 struct v4l2_buffer v2b; 623 struct v4l2_buffer v2b;
595 struct v4l2_framebuffer v2fb; 624 struct v4l2_framebuffer v2fb;
@@ -605,6 +634,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
605 634
606 /* First, convert the command. */ 635 /* First, convert the command. */
607 switch(cmd) { 636 switch(cmd) {
637#ifdef CONFIG_VIDEO_V4L1_COMPAT
608 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break; 638 case VIDIOCGTUNER32: cmd = VIDIOCGTUNER; break;
609 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break; 639 case VIDIOCSTUNER32: cmd = VIDIOCSTUNER; break;
610 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break; 640 case VIDIOCGWIN32: cmd = VIDIOCGWIN; break;
@@ -612,6 +642,8 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
612 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break; 642 case VIDIOCSFBUF32: cmd = VIDIOCSFBUF; break;
613 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break; 643 case VIDIOCGFREQ32: cmd = VIDIOCGFREQ; break;
614 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break; 644 case VIDIOCSFREQ32: cmd = VIDIOCSFREQ; break;
645 case VIDIOCSMICROCODE32: cmd = VIDIOCSMICROCODE; break;
646#endif
615 case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break; 647 case VIDIOC_G_FMT32: cmd = VIDIOC_G_FMT; break;
616 case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break; 648 case VIDIOC_S_FMT32: cmd = VIDIOC_S_FMT; break;
617 case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break; 649 case VIDIOC_QUERYBUF32: cmd = VIDIOC_QUERYBUF; break;
@@ -631,6 +663,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
631 }; 663 };
632 664
633 switch(cmd) { 665 switch(cmd) {
666#ifdef CONFIG_VIDEO_V4L1_COMPAT
634 case VIDIOCSTUNER: 667 case VIDIOCSTUNER:
635 case VIDIOCGTUNER: 668 case VIDIOCGTUNER:
636 err = get_video_tuner32(&karg.vt, up); 669 err = get_video_tuner32(&karg.vt, up);
@@ -644,6 +677,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
644 break; 677 break;
645 678
646 case VIDIOCSFREQ: 679 case VIDIOCSFREQ:
680#endif
647 case VIDIOC_S_INPUT: 681 case VIDIOC_S_INPUT:
648 case VIDIOC_OVERLAY: 682 case VIDIOC_OVERLAY:
649 case VIDIOC_STREAMON: 683 case VIDIOC_STREAMON:
@@ -697,14 +731,21 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
697 compatible_arg = 0; 731 compatible_arg = 0;
698 break; 732 break;
699 733
734#ifdef CONFIG_VIDEO_V4L1_COMPAT
700 case VIDIOCGWIN: 735 case VIDIOCGWIN:
701 case VIDIOCGFBUF: 736 case VIDIOCGFBUF:
702 case VIDIOCGFREQ: 737 case VIDIOCGFREQ:
738#endif
703 case VIDIOC_G_FBUF: 739 case VIDIOC_G_FBUF:
704 case VIDIOC_G_INPUT: 740 case VIDIOC_G_INPUT:
705 compatible_arg = 0; 741 compatible_arg = 0;
742#ifdef CONFIG_VIDEO_V4L1_COMPAT
743 case VIDIOCSMICROCODE:
744 err = microcode32(&karg.vc, up);
745 compatible_arg = 0;
746 break;
747#endif
706 }; 748 };
707
708 if(err) 749 if(err)
709 goto out; 750 goto out;
710 751
@@ -719,6 +760,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
719 } 760 }
720 if(err == 0) { 761 if(err == 0) {
721 switch(cmd) { 762 switch(cmd) {
763#ifdef CONFIG_VIDEO_V4L1_COMPAT
722 case VIDIOCGTUNER: 764 case VIDIOCGTUNER:
723 err = put_video_tuner32(&karg.vt, up); 765 err = put_video_tuner32(&karg.vt, up);
724 break; 766 break;
@@ -730,7 +772,7 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
730 case VIDIOCGFBUF: 772 case VIDIOCGFBUF:
731 err = put_video_buffer32(&karg.vb, up); 773 err = put_video_buffer32(&karg.vb, up);
732 break; 774 break;
733 775#endif
734 case VIDIOC_G_FBUF: 776 case VIDIOC_G_FBUF:
735 err = put_v4l2_framebuffer32(&karg.v2fb, up); 777 err = put_v4l2_framebuffer32(&karg.v2fb, up);
736 break; 778 break;
@@ -768,7 +810,9 @@ static int do_video_ioctl(struct file *file, unsigned int cmd, unsigned long arg
768 err = put_v4l2_input32(&karg.v2i, up); 810 err = put_v4l2_input32(&karg.v2i, up);
769 break; 811 break;
770 812
813#ifdef CONFIG_VIDEO_V4L1_COMPAT
771 case VIDIOCGFREQ: 814 case VIDIOCGFREQ:
815#endif
772 case VIDIOC_G_INPUT: 816 case VIDIOC_G_INPUT:
773 err = put_user(((u32)karg.vx), (u32 __user *)up); 817 err = put_user(((u32)karg.vx), (u32 __user *)up);
774 break; 818 break;
@@ -786,6 +830,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
786 return ret; 830 return ret;
787 831
788 switch (cmd) { 832 switch (cmd) {
833#ifdef CONFIG_VIDEO_V4L1_COMPAT
789 case VIDIOCSWIN32: 834 case VIDIOCSWIN32:
790 ret = do_set_window(file, cmd, arg); 835 ret = do_set_window(file, cmd, arg);
791 break; 836 break;
@@ -796,6 +841,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
796 case VIDIOCSFBUF32: 841 case VIDIOCSFBUF32:
797 case VIDIOCGFREQ32: 842 case VIDIOCGFREQ32:
798 case VIDIOCSFREQ32: 843 case VIDIOCSFREQ32:
844#endif
799 case VIDIOC_QUERYCAP: 845 case VIDIOC_QUERYCAP:
800 case VIDIOC_ENUM_FMT: 846 case VIDIOC_ENUM_FMT:
801 case VIDIOC_G_FMT32: 847 case VIDIOC_G_FMT32:
@@ -827,6 +873,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
827 ret = do_video_ioctl(file, cmd, arg); 873 ret = do_video_ioctl(file, cmd, arg);
828 break; 874 break;
829 875
876#ifdef CONFIG_VIDEO_V4L1_COMPAT
830 /* Little v, the video4linux ioctls (conflict?) */ 877 /* Little v, the video4linux ioctls (conflict?) */
831 case VIDIOCGCAP: 878 case VIDIOCGCAP:
832 case VIDIOCGCHAN: 879 case VIDIOCGCHAN:
@@ -855,6 +902,7 @@ long v4l_compat_ioctl32(struct file *file, unsigned int cmd, unsigned long arg)
855 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int): 902 case _IOR('v' , BASE_VIDIOCPRIVATE+7, int):
856 ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg)); 903 ret = native_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
857 break; 904 break;
905#endif
858 default: 906 default:
859 v4l_print_ioctl("compat_ioctl32", cmd); 907 v4l_print_ioctl("compat_ioctl32", cmd);
860 } 908 }