Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (4066): Vivi.c were ported to the newer videodev2 format.

Several common handling codes were removed. Maybe even more
stuff may be handled at common infrastructure.

Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>

+289 -345
+289 -345
drivers/media/video/vivi.c
··· 48 48 49 49 #include "font.h" 50 50 51 - MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board"); 52 - MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol"); 53 - MODULE_LICENSE("Dual BSD/GPL"); 54 - 55 51 #define VIVI_MAJOR_VERSION 0 56 52 #define VIVI_MINOR_VERSION 4 57 53 #define VIVI_RELEASE 0 58 54 #define VIVI_VERSION KERNEL_VERSION(VIVI_MAJOR_VERSION, VIVI_MINOR_VERSION, VIVI_RELEASE) 59 55 60 - static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ 61 - module_param(video_nr, int, 0); 62 - 63 - static int debug = 0; 64 - module_param(debug, int, 0); 65 - 66 - static unsigned int vid_limit = 16; 67 - module_param(vid_limit,int,0644); 68 - MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); 56 + /* Declare static vars that will be used as parameters */ 57 + static unsigned int vid_limit = 16; /* Video memory limit, in Mb */ 58 + static struct video_device vivi; /* Video device */ 59 + static int video_nr = -1; /* /dev/videoN, -1 for autodetect */ 69 60 70 61 /* supported controls */ 71 62 static struct v4l2_queryctrl vivi_qctrl[] = { ··· 110 119 111 120 static int qctl_regs[ARRAY_SIZE(vivi_qctrl)]; 112 121 113 - #define dprintk(level,fmt, arg...) \ 114 - do { \ 115 - if (debug >= (level)) \ 116 - printk(KERN_DEBUG "vivi: " fmt , ## arg); \ 122 + #define dprintk(level,fmt, arg...) \ 123 + do { \ 124 + if (vivi.debug >= (level)) \ 125 + printk(KERN_DEBUG "vivi: " fmt , ## arg); \ 117 126 } while (0) 118 127 119 128 /* ------------------------------------------------------------------ ··· 171 180 172 181 /* various device info */ 173 182 unsigned int resources; 174 - struct video_device video_dev; 183 + struct video_device vfd; 175 184 176 185 struct vivi_dmaqueue vidq; 177 186 ··· 821 830 IOCTL handling 822 831 ------------------------------------------------------------------*/ 823 832 824 - static int vivi_try_fmt(struct vivi_dev *dev, struct vivi_fh *fh, 833 + 834 + static int res_get(struct vivi_dev *dev, struct vivi_fh *fh) 835 + { 836 + /* is it free? */ 837 + down(&dev->lock); 838 + if (dev->resources) { 839 + /* no, someone else uses it */ 840 + up(&dev->lock); 841 + return 0; 842 + } 843 + /* it's free, grab it */ 844 + dev->resources =1; 845 + dprintk(1,"res: get\n"); 846 + up(&dev->lock); 847 + return 1; 848 + } 849 + 850 + static int res_locked(struct vivi_dev *dev) 851 + { 852 + return (dev->resources); 853 + } 854 + 855 + static void res_free(struct vivi_dev *dev, struct vivi_fh *fh) 856 + { 857 + down(&dev->lock); 858 + dev->resources = 0; 859 + dprintk(1,"res: put\n"); 860 + up(&dev->lock); 861 + } 862 + 863 + /* ------------------------------------------------------------------ 864 + IOCTL vidioc handling 865 + ------------------------------------------------------------------*/ 866 + static int vidioc_querycap (struct file *file, void *priv, 867 + struct v4l2_capability *cap) 868 + { 869 + strcpy(cap->driver, "vivi"); 870 + strcpy(cap->card, "vivi"); 871 + cap->version = VIVI_VERSION; 872 + cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | 873 + V4L2_CAP_STREAMING | 874 + V4L2_CAP_READWRITE; 875 + return 0; 876 + } 877 + 878 + static int vidioc_enum_fmt_cap (struct file *file, void *priv, 879 + struct v4l2_fmtdesc *f) 880 + { 881 + if (f->index > 0) 882 + return -EINVAL; 883 + 884 + strlcpy(f->description,format.name,sizeof(f->description)); 885 + f->pixelformat = format.fourcc; 886 + return 0; 887 + } 888 + 889 + static int vidioc_g_fmt_cap (struct file *file, void *priv, 890 + struct v4l2_format *f) 891 + { 892 + struct vivi_fh *fh=priv; 893 + 894 + f->fmt.pix.width = fh->width; 895 + f->fmt.pix.height = fh->height; 896 + f->fmt.pix.field = fh->vb_vidq.field; 897 + f->fmt.pix.pixelformat = fh->fmt->fourcc; 898 + f->fmt.pix.bytesperline = 899 + (f->fmt.pix.width * fh->fmt->depth) >> 3; 900 + f->fmt.pix.sizeimage = 901 + f->fmt.pix.height * f->fmt.pix.bytesperline; 902 + 903 + return (0); 904 + } 905 + 906 + static int vidioc_try_fmt_cap (struct file *file, void *priv, 825 907 struct v4l2_format *f) 826 908 { 827 909 struct vivi_fmt *fmt; ··· 902 838 unsigned int maxw, maxh; 903 839 904 840 if (format.fourcc != f->fmt.pix.pixelformat) { 905 - dprintk(1,"Fourcc format invalid.\n"); 841 + dprintk(1,"Fourcc format (0x%08x) invalid. Driver accepts " 842 + "only 0x%08x\n",f->fmt.pix.pixelformat,format.fourcc); 906 843 return -EINVAL; 907 844 } 908 845 fmt=&format; ··· 939 874 return 0; 940 875 } 941 876 942 - static int res_get(struct vivi_dev *dev, struct vivi_fh *fh) 877 + /*FIXME: This seems to be generic enough to be at videodev2 */ 878 + static int vidioc_s_fmt_cap (struct file *file, void *priv, 879 + struct v4l2_format *f) 943 880 { 944 - /* is it free? */ 945 - down(&dev->lock); 946 - if (dev->resources) { 947 - /* no, someone else uses it */ 948 - up(&dev->lock); 949 - return 0; 950 - } 951 - /* it's free, grab it */ 952 - dev->resources =1; 953 - dprintk(1,"res: get\n"); 954 - up(&dev->lock); 955 - return 1; 881 + struct vivi_fh *fh=priv; 882 + int ret = vidioc_try_fmt_cap(file,fh,f); 883 + if (ret < 0) 884 + return (ret); 885 + 886 + fh->fmt = &format; 887 + fh->width = f->fmt.pix.width; 888 + fh->height = f->fmt.pix.height; 889 + fh->vb_vidq.field = f->fmt.pix.field; 890 + fh->type = f->type; 891 + 892 + return (0); 956 893 } 957 894 958 - static int res_locked(struct vivi_dev *dev) 895 + static int vidioc_reqbufs (struct file *file, void *priv, struct v4l2_requestbuffers *p) 959 896 { 960 - return (dev->resources); 897 + struct vivi_fh *fh=priv; 898 + 899 + return (videobuf_reqbufs(&fh->vb_vidq, p)); 961 900 } 962 901 963 - static void res_free(struct vivi_dev *dev, struct vivi_fh *fh) 902 + static int vidioc_querybuf (struct file *file, void *priv, struct v4l2_buffer *p) 964 903 { 965 - down(&dev->lock); 966 - dev->resources = 0; 967 - dprintk(1,"res: put\n"); 968 - up(&dev->lock); 904 + struct vivi_fh *fh=priv; 905 + 906 + return (videobuf_querybuf(&fh->vb_vidq, p)); 969 907 } 970 908 971 - static int vivi_do_ioctl(struct inode *inode, struct file *file, unsigned int cmd, void *arg) 909 + static int vidioc_qbuf (struct file *file, void *priv, struct v4l2_buffer *p) 972 910 { 973 - struct vivi_fh *fh = file->private_data; 974 - struct vivi_dev *dev = fh->dev; 975 - int ret=0; 911 + struct vivi_fh *fh=priv; 976 912 977 - if (debug) { 978 - if (_IOC_DIR(cmd) & _IOC_WRITE) 979 - v4l_printk_ioctl_arg("vivi(w)",cmd, arg); 980 - else if (!_IOC_DIR(cmd) & _IOC_READ) { 981 - v4l_print_ioctl("vivi", cmd); 982 - } 983 - } 913 + return (videobuf_qbuf(&fh->vb_vidq, p)); 914 + } 984 915 985 - switch(cmd) { 986 - /* --- capabilities ------------------------------------------ */ 987 - case VIDIOC_QUERYCAP: 988 - { 989 - struct v4l2_capability *cap = (struct v4l2_capability*)arg; 916 + static int vidioc_dqbuf (struct file *file, void *priv, struct v4l2_buffer *p) 917 + { 918 + struct vivi_fh *fh=priv; 990 919 991 - memset(cap, 0, sizeof(*cap)); 920 + return (videobuf_dqbuf(&fh->vb_vidq, p, 921 + file->f_flags & O_NONBLOCK)); 922 + } 992 923 993 - strcpy(cap->driver, "vivi"); 994 - strcpy(cap->card, "vivi"); 995 - cap->version = VIVI_VERSION; 996 - cap->capabilities = 997 - V4L2_CAP_VIDEO_CAPTURE | 998 - V4L2_CAP_STREAMING | 999 - V4L2_CAP_READWRITE; 1000 - break; 1001 - } 1002 - /* --- capture ioctls ---------------------------------------- */ 1003 - case VIDIOC_ENUM_FMT: 1004 - { 1005 - struct v4l2_fmtdesc *f = arg; 1006 - enum v4l2_buf_type type; 1007 - unsigned int index; 1008 - 1009 - index = f->index; 1010 - type = f->type; 1011 - 1012 - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1013 - ret=-EINVAL; 1014 - break; 1015 - } 1016 - 1017 - switch (type) { 1018 - case V4L2_BUF_TYPE_VIDEO_CAPTURE: 1019 - if (index > 0){ 1020 - ret=-EINVAL; 1021 - break; 1022 - } 1023 - memset(f,0,sizeof(*f)); 1024 - 1025 - f->index = index; 1026 - f->type = type; 1027 - strlcpy(f->description,format.name,sizeof(f->description)); 1028 - f->pixelformat = format.fourcc; 1029 - break; 1030 - default: 1031 - ret=-EINVAL; 1032 - } 1033 - break; 1034 - } 1035 - case VIDIOC_G_FMT: 1036 - { 1037 - struct v4l2_format *f = (struct v4l2_format *)arg; 1038 - 1039 - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1040 - ret=-EINVAL; 1041 - break; 1042 - } 1043 - 1044 - memset(&f->fmt.pix,0,sizeof(f->fmt.pix)); 1045 - f->fmt.pix.width = fh->width; 1046 - f->fmt.pix.height = fh->height; 1047 - f->fmt.pix.field = fh->vb_vidq.field; 1048 - f->fmt.pix.pixelformat = fh->fmt->fourcc; 1049 - f->fmt.pix.bytesperline = 1050 - (f->fmt.pix.width * fh->fmt->depth) >> 3; 1051 - f->fmt.pix.sizeimage = 1052 - f->fmt.pix.height * f->fmt.pix.bytesperline; 1053 - break; 1054 - } 1055 - case VIDIOC_S_FMT: 1056 - { 1057 - struct v4l2_format *f = arg; 1058 - 1059 - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1060 - dprintk(1,"Only capture supported.\n"); 1061 - ret=-EINVAL; 1062 - break; 1063 - } 1064 - 1065 - ret = vivi_try_fmt(dev,fh,f); 1066 - if (ret < 0) 1067 - break; 1068 - 1069 - fh->fmt = &format; 1070 - fh->width = f->fmt.pix.width; 1071 - fh->height = f->fmt.pix.height; 1072 - fh->vb_vidq.field = f->fmt.pix.field; 1073 - fh->type = f->type; 1074 - 1075 - break; 1076 - } 1077 - case VIDIOC_TRY_FMT: 1078 - { 1079 - struct v4l2_format *f = arg; 1080 - if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1081 - ret=-EINVAL; 1082 - break; 1083 - } 1084 - 1085 - ret=vivi_try_fmt(dev,fh,f); 1086 - break; 1087 - } 1088 - case VIDIOC_REQBUFS: 1089 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1090 - ret=-EINVAL; 1091 - break; 1092 - } 1093 - ret=videobuf_reqbufs(&fh->vb_vidq, arg); 1094 - break; 1095 - case VIDIOC_QUERYBUF: 1096 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1097 - ret=-EINVAL; 1098 - break; 1099 - } 1100 - ret=videobuf_querybuf(&fh->vb_vidq, arg); 1101 - break; 1102 - case VIDIOC_QBUF: 1103 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1104 - ret=-EINVAL; 1105 - break; 1106 - } 1107 - ret=videobuf_qbuf(&fh->vb_vidq, arg); 1108 - break; 1109 - case VIDIOC_DQBUF: 1110 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1111 - ret=-EINVAL; 1112 - break; 1113 - } 1114 - ret=videobuf_dqbuf(&fh->vb_vidq, arg, 1115 - file->f_flags & O_NONBLOCK); 1116 - break; 1117 924 #ifdef HAVE_V4L1 1118 - /* --- streaming capture ------------------------------------- */ 1119 - case VIDIOCGMBUF: 1120 - { 1121 - struct video_mbuf *mbuf = arg; 1122 - struct videobuf_queue *q=&fh->vb_vidq; 1123 - struct v4l2_requestbuffers req; 1124 - unsigned int i; 925 + static int vidiocgmbuf (struct file *file, void *priv, struct video_mbuf *mbuf) 926 + { 927 + struct vivi_fh *fh=priv; 928 + struct videobuf_queue *q=&fh->vb_vidq; 929 + struct v4l2_requestbuffers req; 930 + unsigned int i, ret; 1125 931 1126 - memset(&req,0,sizeof(req)); 1127 - req.type = q->type; 1128 - req.count = 8; 1129 - req.memory = V4L2_MEMORY_MMAP; 1130 - ret = videobuf_reqbufs(q,&req); 1131 - if (ret < 0) 1132 - break; 1133 - memset(mbuf,0,sizeof(*mbuf)); 1134 - mbuf->frames = req.count; 1135 - mbuf->size = 0; 1136 - for (i = 0; i < mbuf->frames; i++) { 1137 - mbuf->offsets[i] = q->bufs[i]->boff; 1138 - mbuf->size += q->bufs[i]->bsize; 1139 - } 1140 - break; 932 + req.type = q->type; 933 + req.count = 8; 934 + req.memory = V4L2_MEMORY_MMAP; 935 + ret = videobuf_reqbufs(q,&req); 936 + if (ret < 0) 937 + return (ret); 938 + memset(mbuf,0,sizeof(*mbuf)); 939 + mbuf->frames = req.count; 940 + mbuf->size = 0; 941 + for (i = 0; i < mbuf->frames; i++) { 942 + mbuf->offsets[i] = q->bufs[i]->boff; 943 + mbuf->size += q->bufs[i]->bsize; 1141 944 } 945 + return (0); 946 + } 1142 947 #endif 1143 - case VIDIOC_STREAMON: 948 + 949 + int vidioc_streamon (struct file *file, void *priv, enum v4l2_buf_type i) 950 + { 951 + struct vivi_fh *fh=priv; 952 + struct vivi_dev *dev = fh->dev; 953 + 954 + if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 955 + return -EINVAL; 956 + if (i != fh->type) 957 + return -EINVAL; 958 + 959 + if (!res_get(dev,fh)) 960 + return -EBUSY; 961 + return (videobuf_streamon(&fh->vb_vidq)); 962 + } 963 + 964 + int vidioc_streamoff (struct file *file, void *priv, enum v4l2_buf_type i) 965 + { 966 + struct vivi_fh *fh=priv; 967 + struct vivi_dev *dev = fh->dev; 968 + 969 + if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 970 + return -EINVAL; 971 + if (i != fh->type) 972 + return -EINVAL; 973 + 974 + videobuf_streamoff(&fh->vb_vidq); 975 + res_free(dev,fh); 976 + 977 + return (0); 978 + } 979 + 980 + static struct v4l2_tvnorm tvnorms[] = { 1144 981 { 1145 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) 1146 - return -EINVAL; 1147 - if (!res_get(dev,fh)) 1148 - return -EBUSY; 1149 - ret=videobuf_streamon(&fh->vb_vidq); 1150 - break; 982 + .name = "NTSC-M", 983 + .id = V4L2_STD_NTSC_M, 1151 984 } 1152 - case VIDIOC_STREAMOFF: 1153 - { 1154 - if (fh->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1155 - ret=-EINVAL; 1156 - break; 1157 - } 1158 - ret = videobuf_streamoff(&fh->vb_vidq); 1159 - if (ret < 0) 1160 - break; 1161 - res_free(dev,fh); 1162 - break; 1163 - } 1164 - /* ---------- tv norms ---------- */ 1165 - case VIDIOC_ENUMSTD: 1166 - { 1167 - struct v4l2_standard *e = arg; 985 + }; 1168 986 1169 - if (e->index>0) { 1170 - ret=-EINVAL; 1171 - break; 1172 - } 1173 - ret = v4l2_video_std_construct(e, V4L2_STD_NTSC_M, "NTSC-M"); 987 + static int vidioc_s_std (struct file *file, void *priv, v4l2_std_id a) 988 + { 1174 989 1175 - /* Allows vivi to use different fps from video std */ 1176 - e->frameperiod.numerator = WAKE_NUMERATOR; 1177 - e->frameperiod.denominator = WAKE_DENOMINATOR; 990 + return 0; 991 + } 1178 992 1179 - break; 1180 - } 1181 - case VIDIOC_G_STD: 1182 - { 1183 - v4l2_std_id *id = arg; 993 + /* only one input in this sample driver */ 994 + static int vidioc_enum_input (struct file *file, void *priv, 995 + struct v4l2_input *inp) 996 + { 997 + if (inp->index != 0) 998 + return -EINVAL; 1184 999 1185 - *id = V4L2_STD_NTSC_M; 1186 - break; 1187 - } 1188 - case VIDIOC_S_STD: 1189 - { 1190 - break; 1191 - } 1192 - /* ------ input switching ---------- */ 1193 - case VIDIOC_ENUMINPUT: 1194 - { /* only one input in this sample driver */ 1195 - struct v4l2_input *inp = arg; 1000 + inp->type = V4L2_INPUT_TYPE_CAMERA; 1001 + inp->std = V4L2_STD_NTSC_M; 1002 + strcpy(inp->name,"Camera"); 1196 1003 1197 - if (inp->index != 0) { 1198 - ret=-EINVAL; 1199 - break; 1200 - } 1201 - memset(inp, 0, sizeof(*inp)); 1004 + return (0); 1005 + } 1202 1006 1203 - inp->index = 0; 1204 - inp->type = V4L2_INPUT_TYPE_CAMERA; 1205 - inp->std = V4L2_STD_NTSC_M; 1206 - strcpy(inp->name,"Camera"); 1207 - break; 1208 - } 1209 - case VIDIOC_G_INPUT: 1210 - { 1211 - unsigned int *i = arg; 1007 + static int vidioc_g_input (struct file *file, void *priv, unsigned int *i) 1008 + { 1009 + *i = 0; 1212 1010 1213 - *i = 0; 1214 - break; 1215 - } 1216 - case VIDIOC_S_INPUT: 1217 - { 1218 - unsigned int *i = arg; 1011 + return (0); 1012 + } 1013 + static int vidioc_s_input (struct file *file, void *priv, unsigned int i) 1014 + { 1015 + if (i > 0) 1016 + return -EINVAL; 1219 1017 1220 - if (*i > 0) 1221 - ret=-EINVAL; 1222 - break; 1223 - } 1018 + return (0); 1019 + } 1224 1020 1225 1021 /* --- controls ---------------------------------------------- */ 1226 - case VIDIOC_QUERYCTRL: 1227 - { 1228 - struct v4l2_queryctrl *qc = arg; 1229 - int i; 1022 + static int vidioc_queryctrl (struct file *file, void *priv, 1023 + struct v4l2_queryctrl *qc) 1024 + { 1025 + int i; 1230 1026 1231 - for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1232 - if (qc->id && qc->id == vivi_qctrl[i].id) { 1233 - memcpy(qc, &(vivi_qctrl[i]), 1234 - sizeof(*qc)); 1235 - break; 1236 - } 1027 + for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1028 + if (qc->id && qc->id == vivi_qctrl[i].id) { 1029 + memcpy(qc, &(vivi_qctrl[i]), 1030 + sizeof(*qc)); 1031 + return (0); 1032 + } 1237 1033 1238 - ret=-EINVAL; 1239 - break; 1240 - } 1241 - case VIDIOC_G_CTRL: 1242 - { 1243 - struct v4l2_control *ctrl = arg; 1244 - int i; 1245 - 1246 - for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1247 - if (ctrl->id == vivi_qctrl[i].id) { 1248 - ctrl->value=qctl_regs[i]; 1249 - break; 1250 - } 1251 - 1252 - ret=-EINVAL; 1253 - break; 1254 - } 1255 - case VIDIOC_S_CTRL: 1256 - { 1257 - struct v4l2_control *ctrl = arg; 1258 - int i; 1259 - for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1260 - if (ctrl->id == vivi_qctrl[i].id) { 1261 - if (ctrl->value < 1262 - vivi_qctrl[i].minimum 1263 - || ctrl->value > 1264 - vivi_qctrl[i].maximum) { 1265 - ret=-ERANGE; 1266 - break; 1267 - } 1268 - qctl_regs[i]=ctrl->value; 1269 - break; 1270 - } 1271 - ret=-EINVAL; 1272 - break; 1273 - } 1274 - default: 1275 - ret=v4l_compat_translate_ioctl(inode,file,cmd,arg,vivi_do_ioctl); 1276 - } 1277 - 1278 - if (debug) { 1279 - if (ret<0) { 1280 - v4l_print_ioctl("vivi(err)", cmd); 1281 - dprintk(1,"errcode=%d\n",ret); 1282 - } else if (_IOC_DIR(cmd) & _IOC_READ) 1283 - v4l_printk_ioctl_arg("vivi(r)",cmd, arg); 1284 - } 1285 - 1286 - return ret; 1034 + return -EINVAL; 1287 1035 } 1288 1036 1289 - static int vivi_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) 1037 + static int vidioc_g_ctrl (struct file *file, void *priv, 1038 + struct v4l2_control *ctrl) 1290 1039 { 1291 - return video_usercopy(inode, file, cmd, arg, vivi_do_ioctl); 1040 + int i; 1041 + 1042 + for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1043 + if (ctrl->id == vivi_qctrl[i].id) { 1044 + ctrl->value=qctl_regs[i]; 1045 + return (0); 1046 + } 1047 + 1048 + return -EINVAL; 1049 + } 1050 + static int vidioc_s_ctrl (struct file *file, void *priv, 1051 + struct v4l2_control *ctrl) 1052 + { 1053 + int i; 1054 + 1055 + for (i = 0; i < ARRAY_SIZE(vivi_qctrl); i++) 1056 + if (ctrl->id == vivi_qctrl[i].id) { 1057 + if (ctrl->value < 1058 + vivi_qctrl[i].minimum 1059 + || ctrl->value > 1060 + vivi_qctrl[i].maximum) { 1061 + return (-ERANGE); 1062 + } 1063 + qctl_regs[i]=ctrl->value; 1064 + return (0); 1065 + } 1066 + return -EINVAL; 1292 1067 } 1293 1068 1294 1069 /* ------------------------------------------------------------------ ··· 1150 1245 1151 1246 list_for_each(list,&vivi_devlist) { 1152 1247 h = list_entry(list, struct vivi_dev, vivi_devlist); 1153 - if (h->video_dev.minor == minor) { 1248 + if (h->vfd.minor == minor) { 1154 1249 dev = h; 1155 1250 type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1156 1251 } 1157 1252 } 1158 1253 if (NULL == dev) 1159 1254 return -ENODEV; 1255 + 1160 1256 1161 1257 1162 1258 /* If more than one user, mutex should be added */ ··· 1175 1269 1176 1270 file->private_data = fh; 1177 1271 fh->dev = dev; 1272 + 1178 1273 fh->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; 1179 1274 fh->fmt = &format; 1180 1275 fh->width = 640; ··· 1211 1304 static ssize_t 1212 1305 vivi_read(struct file *file, char __user *data, size_t count, loff_t *ppos) 1213 1306 { 1214 - struct vivi_fh *fh = file->private_data; 1307 + struct vivi_fh *fh = file->private_data; 1215 1308 1216 1309 if (fh->type==V4L2_BUF_TYPE_VIDEO_CAPTURE) { 1217 1310 if (res_locked(fh->dev)) ··· 1225 1318 static unsigned int 1226 1319 vivi_poll(struct file *file, struct poll_table_struct *wait) 1227 1320 { 1228 - struct vivi_fh *fh = file->private_data; 1229 - struct vivi_buffer *buf; 1321 + struct vivi_fh *fh = file->private_data; 1322 + struct vivi_buffer *buf; 1230 1323 1231 1324 dprintk(1,"%s\n",__FUNCTION__); 1232 1325 ··· 1255 1348 1256 1349 static int vivi_release(struct inode *inode, struct file *file) 1257 1350 { 1258 - struct vivi_fh *fh = file->private_data; 1259 - struct vivi_dev *dev = fh->dev; 1351 + struct vivi_fh *fh = file->private_data; 1352 + struct vivi_dev *dev = fh->dev; 1260 1353 struct vivi_dmaqueue *vidq = &dev->vidq; 1261 1354 1262 1355 int minor = iminor(inode); ··· 1276 1369 static int 1277 1370 vivi_mmap(struct file *file, struct vm_area_struct * vma) 1278 1371 { 1279 - struct vivi_fh *fh = file->private_data; 1372 + struct vivi_fh *fh = file->private_data; 1280 1373 int ret; 1281 1374 1282 1375 dprintk (1,"mmap called, vma=0x%08lx\n",(unsigned long)vma); ··· 1297 1390 .release = vivi_release, 1298 1391 .read = vivi_read, 1299 1392 .poll = vivi_poll, 1300 - .ioctl = vivi_ioctl, 1393 + .ioctl = video_ioctl2, /* V4L2 ioctl handler */ 1301 1394 .mmap = vivi_mmap, 1302 1395 .llseek = no_llseek, 1303 1396 }; 1304 1397 1305 1398 static struct video_device vivi = { 1306 - .name = "VTM Virtual Video Capture Board", 1399 + .name = "vivi", 1307 1400 .type = VID_TYPE_CAPTURE, 1308 1401 .hardware = 0, 1309 1402 .fops = &vivi_fops, 1310 1403 .minor = -1, 1311 1404 // .release = video_device_release, 1405 + 1406 + .vidioc_querycap = vidioc_querycap, 1407 + .vidioc_enum_fmt_cap = vidioc_enum_fmt_cap, 1408 + .vidioc_g_fmt_cap = vidioc_g_fmt_cap, 1409 + .vidioc_try_fmt_cap = vidioc_try_fmt_cap, 1410 + .vidioc_s_fmt_cap = vidioc_s_fmt_cap, 1411 + .vidioc_reqbufs = vidioc_reqbufs, 1412 + .vidioc_querybuf = vidioc_querybuf, 1413 + .vidioc_qbuf = vidioc_qbuf, 1414 + .vidioc_dqbuf = vidioc_dqbuf, 1415 + .vidioc_s_std = vidioc_s_std, 1416 + .vidioc_enum_input = vidioc_enum_input, 1417 + .vidioc_g_input = vidioc_g_input, 1418 + .vidioc_s_input = vidioc_s_input, 1419 + .vidioc_queryctrl = vidioc_queryctrl, 1420 + .vidioc_g_ctrl = vidioc_g_ctrl, 1421 + .vidioc_s_ctrl = vidioc_s_ctrl, 1422 + .vidioc_streamon = vidioc_streamon, 1423 + .vidioc_streamoff = vidioc_streamoff, 1424 + #ifdef HAVE_V4L1 1425 + .vidiocgmbuf = vidiocgmbuf, 1426 + #endif 1427 + .tvnorms = tvnorms, 1428 + .tvnormsize = ARRAY_SIZE(tvnorms), 1312 1429 }; 1313 - /* ------------------------------------------------------------------ 1430 + /* ----------------------------------------------------------------- 1314 1431 Initialization and module stuff 1315 1432 ------------------------------------------------------------------*/ 1316 1433 ··· 1378 1447 1379 1448 module_init(vivi_init); 1380 1449 module_exit(vivi_exit); 1450 + 1451 + MODULE_DESCRIPTION("Video Technology Magazine Virtual Video Capture Board"); 1452 + MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol"); 1453 + MODULE_LICENSE("Dual BSD/GPL"); 1454 + 1455 + module_param(video_nr, int, 0); 1456 + 1457 + module_param_named(debug,vivi.debug, int, 0644); 1458 + MODULE_PARM_DESC(debug,"activates debug info"); 1459 + 1460 + module_param(vid_limit,int,0644); 1461 + MODULE_PARM_DESC(vid_limit,"capture memory limit in megabytes"); 1462 +