diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-01-23 14:11:09 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@brturbo.com.br> | 2006-01-23 14:11:09 -0500 |
commit | 9aeb4b051b65c0248ea6589096950413c4da9d63 (patch) | |
tree | 81e14364b0cf1797a5bff9a66cfe2475abf336cd /drivers/media | |
parent | 2d50f847c62acbafa25dc690d0fe65b8b908a326 (diff) |
V4L/DVB (3423): CodingStyle fixes.
- CodingStyle fixes.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/em28xx/em28xx-video.c | 869 |
1 files changed, 427 insertions, 442 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c index d8d02c44c9d2..1b0e10d5edd4 100644 --- a/drivers/media/video/em28xx/em28xx-video.c +++ b/drivers/media/video/em28xx/em28xx-video.c | |||
@@ -1012,19 +1012,15 @@ static int em28xx_set_fmt(struct em28xx *dev, unsigned int cmd, struct v4l2_form | |||
1012 | width /= 2; | 1012 | width /= 2; |
1013 | } | 1013 | } |
1014 | 1014 | ||
1015 | if ((hscale = | 1015 | if ((hscale = (((unsigned long)maxw) << 12) / width - 4096L) >= 0x4000) |
1016 | (((unsigned long)maxw) << 12) / width - 4096L) >= | ||
1017 | 0x4000) | ||
1018 | hscale = 0x3fff; | 1016 | hscale = 0x3fff; |
1019 | width = | ||
1020 | (((unsigned long)maxw) << 12) / (hscale + 4096L); | ||
1021 | 1017 | ||
1022 | if ((vscale = | 1018 | width = (((unsigned long)maxw) << 12) / (hscale + 4096L); |
1023 | (((unsigned long)maxh) << 12) / height - 4096L) >= | 1019 | |
1024 | 0x4000) | 1020 | if ((vscale = (((unsigned long)maxh) << 12) / height - 4096L) >= 0x4000) |
1025 | vscale = 0x3fff; | 1021 | vscale = 0x3fff; |
1026 | height = | 1022 | |
1027 | (((unsigned long)maxh) << 12) / (vscale + 4096L); | 1023 | height = (((unsigned long)maxh) << 12) / (vscale + 4096L); |
1028 | 1024 | ||
1029 | format->fmt.pix.width = width; | 1025 | format->fmt.pix.width = width; |
1030 | format->fmt.pix.height = height; | 1026 | format->fmt.pix.height = height; |
@@ -1035,10 +1031,9 @@ static int em28xx_set_fmt(struct em28xx *dev, unsigned int cmd, struct v4l2_form | |||
1035 | format->fmt.pix.field = V4L2_FIELD_INTERLACED; | 1031 | format->fmt.pix.field = V4L2_FIELD_INTERLACED; |
1036 | 1032 | ||
1037 | em28xx_videodbg("%s: returned %dx%d (%d, %d)\n", | 1033 | em28xx_videodbg("%s: returned %dx%d (%d, %d)\n", |
1038 | cmd == | 1034 | cmd == VIDIOC_TRY_FMT ? |
1039 | VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" : | 1035 | "VIDIOC_TRY_FMT" :"VIDIOC_S_FMT", |
1040 | "VIDIOC_S_FMT", format->fmt.pix.width, | 1036 | format->fmt.pix.width, format->fmt.pix.height, hscale, vscale); |
1041 | format->fmt.pix.height, hscale, vscale); | ||
1042 | 1037 | ||
1043 | if (cmd == VIDIOC_TRY_FMT) | 1038 | if (cmd == VIDIOC_TRY_FMT) |
1044 | return 0; | 1039 | return 0; |
@@ -1064,7 +1059,7 @@ static int em28xx_set_fmt(struct em28xx *dev, unsigned int cmd, struct v4l2_form | |||
1064 | dev->width = width; | 1059 | dev->width = width; |
1065 | dev->height = height; | 1060 | dev->height = height; |
1066 | dev->frame_size = dev->width * dev->height * 2; | 1061 | dev->frame_size = dev->width * dev->height * 2; |
1067 | dev->field_size = dev->frame_size >> 1; /*both_fileds ? dev->frame_size>>1 : dev->frame_size; */ | 1062 | dev->field_size = dev->frame_size >> 1; |
1068 | dev->bytesperline = dev->width * 2; | 1063 | dev->bytesperline = dev->width * 2; |
1069 | dev->hscale = hscale; | 1064 | dev->hscale = hscale; |
1070 | dev->vscale = vscale; | 1065 | dev->vscale = vscale; |
@@ -1092,374 +1087,367 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp, | |||
1092 | switch (cmd) { | 1087 | switch (cmd) { |
1093 | /* ---------- tv norms ---------- */ | 1088 | /* ---------- tv norms ---------- */ |
1094 | case VIDIOC_ENUMSTD: | 1089 | case VIDIOC_ENUMSTD: |
1095 | { | 1090 | { |
1096 | struct v4l2_standard *e = arg; | 1091 | struct v4l2_standard *e = arg; |
1097 | unsigned int i; | 1092 | unsigned int i; |
1098 | 1093 | ||
1099 | i = e->index; | 1094 | i = e->index; |
1100 | if (i >= TVNORMS) | 1095 | if (i >= TVNORMS) |
1101 | return -EINVAL; | 1096 | return -EINVAL; |
1102 | ret = v4l2_video_std_construct(e, tvnorms[e->index].id, | 1097 | ret = v4l2_video_std_construct(e, tvnorms[e->index].id, |
1103 | tvnorms[e->index].name); | 1098 | tvnorms[e->index].name); |
1104 | e->index = i; | 1099 | e->index = i; |
1105 | if (ret < 0) | 1100 | if (ret < 0) |
1106 | return ret; | 1101 | return ret; |
1107 | return 0; | 1102 | return 0; |
1108 | } | 1103 | } |
1109 | case VIDIOC_G_STD: | 1104 | case VIDIOC_G_STD: |
1110 | { | 1105 | { |
1111 | v4l2_std_id *id = arg; | 1106 | v4l2_std_id *id = arg; |
1112 | 1107 | ||
1113 | *id = dev->tvnorm->id; | 1108 | *id = dev->tvnorm->id; |
1114 | return 0; | 1109 | return 0; |
1115 | } | 1110 | } |
1116 | case VIDIOC_S_STD: | 1111 | case VIDIOC_S_STD: |
1117 | { | 1112 | { |
1118 | v4l2_std_id *id = arg; | 1113 | v4l2_std_id *id = arg; |
1119 | unsigned int i; | 1114 | unsigned int i; |
1120 | 1115 | ||
1116 | for (i = 0; i < TVNORMS; i++) | ||
1117 | if (*id == tvnorms[i].id) | ||
1118 | break; | ||
1119 | if (i == TVNORMS) | ||
1121 | for (i = 0; i < TVNORMS; i++) | 1120 | for (i = 0; i < TVNORMS; i++) |
1122 | if (*id == tvnorms[i].id) | 1121 | if (*id & tvnorms[i].id) |
1123 | break; | 1122 | break; |
1124 | if (i == TVNORMS) | 1123 | if (i == TVNORMS) |
1125 | for (i = 0; i < TVNORMS; i++) | 1124 | return -EINVAL; |
1126 | if (*id & tvnorms[i].id) | ||
1127 | break; | ||
1128 | if (i == TVNORMS) | ||
1129 | return -EINVAL; | ||
1130 | 1125 | ||
1131 | down(&dev->lock); | 1126 | down(&dev->lock); |
1132 | dev->tvnorm = &tvnorms[i]; | 1127 | dev->tvnorm = &tvnorms[i]; |
1133 | 1128 | ||
1134 | em28xx_set_norm(dev, dev->width, dev->height); | 1129 | em28xx_set_norm(dev, dev->width, dev->height); |
1135 | 1130 | ||
1136 | em28xx_i2c_call_clients(dev, DECODER_SET_NORM, | 1131 | em28xx_i2c_call_clients(dev, DECODER_SET_NORM, |
1137 | &tvnorms[i].mode); | 1132 | &tvnorms[i].mode); |
1138 | em28xx_i2c_call_clients(dev, VIDIOC_S_STD, | 1133 | em28xx_i2c_call_clients(dev, VIDIOC_S_STD, |
1139 | &dev->tvnorm->id); | 1134 | &dev->tvnorm->id); |
1140 | 1135 | ||
1141 | up(&dev->lock); | 1136 | up(&dev->lock); |
1142 | 1137 | ||
1143 | return 0; | 1138 | return 0; |
1144 | } | 1139 | } |
1145 | 1140 | ||
1146 | /* ------ input switching ---------- */ | 1141 | /* ------ input switching ---------- */ |
1147 | case VIDIOC_ENUMINPUT: | 1142 | case VIDIOC_ENUMINPUT: |
1148 | { | 1143 | { |
1149 | struct v4l2_input *i = arg; | 1144 | struct v4l2_input *i = arg; |
1150 | unsigned int n; | 1145 | unsigned int n; |
1151 | static const char *iname[] = { | 1146 | static const char *iname[] = { |
1152 | [EM28XX_VMUX_COMPOSITE1] = "Composite1", | 1147 | [EM28XX_VMUX_COMPOSITE1] = "Composite1", |
1153 | [EM28XX_VMUX_COMPOSITE2] = "Composite2", | 1148 | [EM28XX_VMUX_COMPOSITE2] = "Composite2", |
1154 | [EM28XX_VMUX_COMPOSITE3] = "Composite3", | 1149 | [EM28XX_VMUX_COMPOSITE3] = "Composite3", |
1155 | [EM28XX_VMUX_COMPOSITE4] = "Composite4", | 1150 | [EM28XX_VMUX_COMPOSITE4] = "Composite4", |
1156 | [EM28XX_VMUX_SVIDEO] = "S-Video", | 1151 | [EM28XX_VMUX_SVIDEO] = "S-Video", |
1157 | [EM28XX_VMUX_TELEVISION] = "Television", | 1152 | [EM28XX_VMUX_TELEVISION] = "Television", |
1158 | [EM28XX_VMUX_CABLE] = "Cable TV", | 1153 | [EM28XX_VMUX_CABLE] = "Cable TV", |
1159 | [EM28XX_VMUX_DVB] = "DVB", | 1154 | [EM28XX_VMUX_DVB] = "DVB", |
1160 | [EM28XX_VMUX_DEBUG] = "for debug only", | 1155 | [EM28XX_VMUX_DEBUG] = "for debug only", |
1161 | }; | 1156 | }; |
1162 | 1157 | ||
1163 | n = i->index; | 1158 | n = i->index; |
1164 | if (n >= MAX_EM28XX_INPUT) | 1159 | if (n >= MAX_EM28XX_INPUT) |
1165 | return -EINVAL; | 1160 | return -EINVAL; |
1166 | if (0 == INPUT(n)->type) | 1161 | if (0 == INPUT(n)->type) |
1167 | return -EINVAL; | 1162 | return -EINVAL; |
1168 | memset(i, 0, sizeof(*i)); | 1163 | memset(i, 0, sizeof(*i)); |
1169 | i->index = n; | 1164 | i->index = n; |
1170 | i->type = V4L2_INPUT_TYPE_CAMERA; | 1165 | i->type = V4L2_INPUT_TYPE_CAMERA; |
1171 | strcpy(i->name, iname[INPUT(n)->type]); | 1166 | strcpy(i->name, iname[INPUT(n)->type]); |
1172 | if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) || | 1167 | if ((EM28XX_VMUX_TELEVISION == INPUT(n)->type) || |
1173 | (EM28XX_VMUX_CABLE == INPUT(n)->type)) | 1168 | (EM28XX_VMUX_CABLE == INPUT(n)->type)) |
1174 | i->type = V4L2_INPUT_TYPE_TUNER; | 1169 | i->type = V4L2_INPUT_TYPE_TUNER; |
1175 | for (n = 0; n < ARRAY_SIZE(tvnorms); n++) | 1170 | for (n = 0; n < ARRAY_SIZE(tvnorms); n++) |
1176 | i->std |= tvnorms[n].id; | 1171 | i->std |= tvnorms[n].id; |
1177 | return 0; | 1172 | return 0; |
1178 | } | 1173 | } |
1179 | |||
1180 | case VIDIOC_G_INPUT: | 1174 | case VIDIOC_G_INPUT: |
1181 | { | 1175 | { |
1182 | int *i = arg; | 1176 | int *i = arg; |
1183 | *i = dev->ctl_input; | 1177 | *i = dev->ctl_input; |
1184 | |||
1185 | return 0; | ||
1186 | } | ||
1187 | 1178 | ||
1179 | return 0; | ||
1180 | } | ||
1188 | case VIDIOC_S_INPUT: | 1181 | case VIDIOC_S_INPUT: |
1189 | { | 1182 | { |
1190 | int *index = arg; | 1183 | int *index = arg; |
1191 | |||
1192 | if (*index >= MAX_EM28XX_INPUT) | ||
1193 | return -EINVAL; | ||
1194 | if (0 == INPUT(*index)->type) | ||
1195 | return -EINVAL; | ||
1196 | 1184 | ||
1197 | down(&dev->lock); | 1185 | if (*index >= MAX_EM28XX_INPUT) |
1198 | video_mux(dev, *index); | 1186 | return -EINVAL; |
1199 | up(&dev->lock); | 1187 | if (0 == INPUT(*index)->type) |
1188 | return -EINVAL; | ||
1200 | 1189 | ||
1201 | return 0; | 1190 | down(&dev->lock); |
1202 | } | 1191 | video_mux(dev, *index); |
1192 | up(&dev->lock); | ||
1203 | 1193 | ||
1194 | return 0; | ||
1195 | } | ||
1204 | case VIDIOC_G_AUDIO: | 1196 | case VIDIOC_G_AUDIO: |
1205 | { | 1197 | { |
1206 | struct v4l2_audio *a = arg; | 1198 | struct v4l2_audio *a = arg; |
1207 | unsigned int index = a->index; | 1199 | unsigned int index = a->index; |
1208 | 1200 | ||
1209 | if (a->index > 1) | 1201 | if (a->index > 1) |
1210 | return -EINVAL; | 1202 | return -EINVAL; |
1211 | memset(a, 0, sizeof(*a)); | 1203 | memset(a, 0, sizeof(*a)); |
1212 | index = dev->ctl_ainput; | 1204 | index = dev->ctl_ainput; |
1213 | 1205 | ||
1214 | if (index == 0) { | 1206 | if (index == 0) { |
1215 | strcpy(a->name, "Television"); | 1207 | strcpy(a->name, "Television"); |
1216 | } else { | 1208 | } else { |
1217 | strcpy(a->name, "Line In"); | 1209 | strcpy(a->name, "Line In"); |
1218 | } | ||
1219 | a->capability = V4L2_AUDCAP_STEREO; | ||
1220 | a->index = index; | ||
1221 | return 0; | ||
1222 | } | 1210 | } |
1223 | 1211 | a->capability = V4L2_AUDCAP_STEREO; | |
1212 | a->index = index; | ||
1213 | return 0; | ||
1214 | } | ||
1224 | case VIDIOC_S_AUDIO: | 1215 | case VIDIOC_S_AUDIO: |
1225 | { | 1216 | { |
1226 | struct v4l2_audio *a = arg; | 1217 | struct v4l2_audio *a = arg; |
1227 | if (a->index != dev->ctl_ainput) | ||
1228 | return -EINVAL; | ||
1229 | 1218 | ||
1230 | return 0; | 1219 | if (a->index != dev->ctl_ainput) |
1231 | } | 1220 | return -EINVAL; |
1221 | |||
1222 | return 0; | ||
1223 | } | ||
1232 | 1224 | ||
1233 | /* --- controls ---------------------------------------------- */ | 1225 | /* --- controls ---------------------------------------------- */ |
1234 | case VIDIOC_QUERYCTRL: | 1226 | case VIDIOC_QUERYCTRL: |
1235 | { | 1227 | { |
1236 | struct v4l2_queryctrl *qc = arg; | 1228 | struct v4l2_queryctrl *qc = arg; |
1237 | int i, id=qc->id; | 1229 | int i, id=qc->id; |
1238 | 1230 | ||
1239 | memset(qc,0,sizeof(*qc)); | 1231 | memset(qc,0,sizeof(*qc)); |
1240 | qc->id=id; | 1232 | qc->id=id; |
1241 | 1233 | ||
1242 | if (!dev->has_msp34xx) { | 1234 | if (!dev->has_msp34xx) { |
1243 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { | 1235 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { |
1244 | if (qc->id && qc->id == em28xx_qctrl[i].id) { | 1236 | if (qc->id && qc->id == em28xx_qctrl[i].id) { |
1245 | memcpy(qc, &(em28xx_qctrl[i]), | 1237 | memcpy(qc, &(em28xx_qctrl[i]), |
1246 | sizeof(*qc)); | 1238 | sizeof(*qc)); |
1247 | return 0; | ||
1248 | } | ||
1249 | } | ||
1250 | } | ||
1251 | if (dev->decoder == EM28XX_TVP5150) { | ||
1252 | em28xx_i2c_call_clients(dev,cmd,qc); | ||
1253 | if (qc->type) | ||
1254 | return 0; | ||
1255 | else | ||
1256 | return -EINVAL; | ||
1257 | } | ||
1258 | for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { | ||
1259 | if (qc->id && qc->id == saa711x_qctrl[i].id) { | ||
1260 | memcpy(qc, &(saa711x_qctrl[i]), | ||
1261 | sizeof(*qc)); | ||
1262 | return 0; | 1239 | return 0; |
1263 | } | 1240 | } |
1264 | } | 1241 | } |
1265 | 1242 | } | |
1266 | return -EINVAL; | 1243 | if (dev->decoder == EM28XX_TVP5150) { |
1244 | em28xx_i2c_call_clients(dev,cmd,qc); | ||
1245 | if (qc->type) | ||
1246 | return 0; | ||
1247 | else | ||
1248 | return -EINVAL; | ||
1249 | } | ||
1250 | for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { | ||
1251 | if (qc->id && qc->id == saa711x_qctrl[i].id) { | ||
1252 | memcpy(qc, &(saa711x_qctrl[i]), | ||
1253 | sizeof(*qc)); | ||
1254 | return 0; | ||
1255 | } | ||
1267 | } | 1256 | } |
1268 | 1257 | ||
1258 | return -EINVAL; | ||
1259 | } | ||
1269 | case VIDIOC_G_CTRL: | 1260 | case VIDIOC_G_CTRL: |
1270 | { | 1261 | { |
1271 | struct v4l2_control *ctrl = arg; | 1262 | struct v4l2_control *ctrl = arg; |
1272 | int retval=-EINVAL; | 1263 | int retval=-EINVAL; |
1273 | |||
1274 | if (!dev->has_msp34xx) | ||
1275 | retval=em28xx_get_ctrl(dev, ctrl); | ||
1276 | if (retval==-EINVAL) { | ||
1277 | if (dev->decoder == EM28XX_TVP5150) { | ||
1278 | em28xx_i2c_call_clients(dev,cmd,arg); | ||
1279 | return 0; | ||
1280 | } | ||
1281 | 1264 | ||
1282 | return saa711x_get_ctrl(dev, ctrl); | 1265 | if (!dev->has_msp34xx) |
1283 | } else return retval; | 1266 | retval=em28xx_get_ctrl(dev, ctrl); |
1284 | } | 1267 | if (retval==-EINVAL) { |
1268 | if (dev->decoder == EM28XX_TVP5150) { | ||
1269 | em28xx_i2c_call_clients(dev,cmd,arg); | ||
1270 | return 0; | ||
1271 | } | ||
1285 | 1272 | ||
1273 | return saa711x_get_ctrl(dev, ctrl); | ||
1274 | } else return retval; | ||
1275 | } | ||
1286 | case VIDIOC_S_CTRL: | 1276 | case VIDIOC_S_CTRL: |
1287 | { | 1277 | { |
1288 | struct v4l2_control *ctrl = arg; | 1278 | struct v4l2_control *ctrl = arg; |
1289 | u8 i; | 1279 | u8 i; |
1290 | 1280 | ||
1291 | if (!dev->has_msp34xx){ | 1281 | if (!dev->has_msp34xx){ |
1292 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { | 1282 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { |
1293 | if (ctrl->id == em28xx_qctrl[i].id) { | 1283 | if (ctrl->id == em28xx_qctrl[i].id) { |
1294 | if (ctrl->value < | 1284 | if (ctrl->value < |
1295 | em28xx_qctrl[i].minimum | 1285 | em28xx_qctrl[i].minimum |
1296 | || ctrl->value > | 1286 | || ctrl->value > |
1297 | em28xx_qctrl[i].maximum) | 1287 | em28xx_qctrl[i].maximum) |
1298 | return -ERANGE; | 1288 | return -ERANGE; |
1299 | return em28xx_set_ctrl(dev, ctrl); | 1289 | return em28xx_set_ctrl(dev, ctrl); |
1300 | } | ||
1301 | } | 1290 | } |
1302 | } | 1291 | } |
1292 | } | ||
1303 | 1293 | ||
1304 | if (dev->decoder == EM28XX_TVP5150) { | 1294 | if (dev->decoder == EM28XX_TVP5150) { |
1305 | em28xx_i2c_call_clients(dev,cmd,arg); | 1295 | em28xx_i2c_call_clients(dev,cmd,arg); |
1306 | return 0; | 1296 | return 0; |
1307 | } else if (!dev->has_msp34xx) { | 1297 | } else if (!dev->has_msp34xx) { |
1308 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { | 1298 | for (i = 0; i < ARRAY_SIZE(em28xx_qctrl); i++) { |
1309 | if (ctrl->id == em28xx_qctrl[i].id) { | 1299 | if (ctrl->id == em28xx_qctrl[i].id) { |
1310 | if (ctrl->value < | 1300 | if (ctrl->value < |
1311 | em28xx_qctrl[i].minimum | 1301 | em28xx_qctrl[i].minimum |
1312 | || ctrl->value > | 1302 | || ctrl->value > |
1313 | em28xx_qctrl[i].maximum) | 1303 | em28xx_qctrl[i].maximum) |
1314 | return -ERANGE; | 1304 | return -ERANGE; |
1315 | return em28xx_set_ctrl(dev, ctrl); | 1305 | return em28xx_set_ctrl(dev, ctrl); |
1316 | } | ||
1317 | } | 1306 | } |
1318 | for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { | 1307 | } |
1319 | if (ctrl->id == saa711x_qctrl[i].id) { | 1308 | for (i = 0; i < ARRAY_SIZE(saa711x_qctrl); i++) { |
1320 | if (ctrl->value < | 1309 | if (ctrl->id == saa711x_qctrl[i].id) { |
1321 | saa711x_qctrl[i].minimum | 1310 | if (ctrl->value < |
1322 | || ctrl->value > | 1311 | saa711x_qctrl[i].minimum |
1323 | saa711x_qctrl[i].maximum) | 1312 | || ctrl->value > |
1324 | return -ERANGE; | 1313 | saa711x_qctrl[i].maximum) |
1325 | return saa711x_set_ctrl(dev, ctrl); | 1314 | return -ERANGE; |
1326 | } | 1315 | return saa711x_set_ctrl(dev, ctrl); |
1327 | } | 1316 | } |
1328 | } | 1317 | } |
1329 | |||
1330 | return -EINVAL; | ||
1331 | } | 1318 | } |
1332 | 1319 | ||
1333 | /* --- tuner ioctls ------------------------------------------ */ | 1320 | return -EINVAL; |
1321 | } | ||
1322 | /* --- tuner ioctls ------------------------------------------ */ | ||
1334 | case VIDIOC_G_TUNER: | 1323 | case VIDIOC_G_TUNER: |
1335 | { | 1324 | { |
1336 | struct v4l2_tuner *t = arg; | 1325 | struct v4l2_tuner *t = arg; |
1337 | int status = 0; | 1326 | int status = 0; |
1338 | 1327 | ||
1339 | if (0 != t->index) | 1328 | if (0 != t->index) |
1340 | return -EINVAL; | 1329 | return -EINVAL; |
1341 | 1330 | ||
1342 | memset(t, 0, sizeof(*t)); | 1331 | memset(t, 0, sizeof(*t)); |
1343 | strcpy(t->name, "Tuner"); | 1332 | strcpy(t->name, "Tuner"); |
1344 | t->type = V4L2_TUNER_ANALOG_TV; | 1333 | t->type = V4L2_TUNER_ANALOG_TV; |
1345 | t->capability = V4L2_TUNER_CAP_NORM; | 1334 | t->capability = V4L2_TUNER_CAP_NORM; |
1346 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ | 1335 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ |
1347 | /* t->signal = 0xffff;*/ | 1336 | /* t->signal = 0xffff;*/ |
1348 | /* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ | 1337 | /* em28xx_i2c_call_clients(dev,VIDIOC_G_TUNER,t);*/ |
1349 | /* No way to get signal strength? */ | 1338 | /* No way to get signal strength? */ |
1350 | down(&dev->lock); | 1339 | down(&dev->lock); |
1351 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, | 1340 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, |
1352 | &status); | 1341 | &status); |
1353 | up(&dev->lock); | 1342 | up(&dev->lock); |
1354 | t->signal = | 1343 | t->signal = |
1355 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; | 1344 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; |
1356 | 1345 | ||
1357 | em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal, | 1346 | em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal, |
1358 | t->afc); | 1347 | t->afc); |
1359 | return 0; | 1348 | return 0; |
1360 | } | 1349 | } |
1361 | case VIDIOC_S_TUNER: | 1350 | case VIDIOC_S_TUNER: |
1362 | { | 1351 | { |
1363 | struct v4l2_tuner *t = arg; | 1352 | struct v4l2_tuner *t = arg; |
1364 | int status = 0; | 1353 | int status = 0; |
1365 | 1354 | ||
1366 | if (0 != t->index) | 1355 | if (0 != t->index) |
1367 | return -EINVAL; | 1356 | return -EINVAL; |
1368 | memset(t, 0, sizeof(*t)); | 1357 | memset(t, 0, sizeof(*t)); |
1369 | strcpy(t->name, "Tuner"); | 1358 | strcpy(t->name, "Tuner"); |
1370 | t->type = V4L2_TUNER_ANALOG_TV; | 1359 | t->type = V4L2_TUNER_ANALOG_TV; |
1371 | t->capability = V4L2_TUNER_CAP_NORM; | 1360 | t->capability = V4L2_TUNER_CAP_NORM; |
1372 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ | 1361 | t->rangehigh = 0xffffffffUL; /* FIXME: set correct range */ |
1373 | /* t->signal = 0xffff; */ | 1362 | /* t->signal = 0xffff; */ |
1374 | /* No way to get signal strength? */ | 1363 | /* No way to get signal strength? */ |
1375 | down(&dev->lock); | 1364 | down(&dev->lock); |
1376 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, | 1365 | em28xx_i2c_call_clients(dev, DECODER_GET_STATUS, |
1377 | &status); | 1366 | &status); |
1378 | up(&dev->lock); | 1367 | up(&dev->lock); |
1379 | t->signal = | 1368 | t->signal = |
1380 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; | 1369 | (status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0; |
1381 | 1370 | ||
1382 | em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n", | 1371 | em28xx_videodbg("VIDIO_S_TUNER: signal=%x, afc=%x\n", |
1383 | t->signal, t->afc); | 1372 | t->signal, t->afc); |
1384 | return 0; | 1373 | return 0; |
1385 | } | 1374 | } |
1386 | case VIDIOC_G_FREQUENCY: | 1375 | case VIDIOC_G_FREQUENCY: |
1387 | { | 1376 | { |
1388 | struct v4l2_frequency *f = arg; | 1377 | struct v4l2_frequency *f = arg; |
1389 | 1378 | ||
1390 | memset(f, 0, sizeof(*f)); | 1379 | memset(f, 0, sizeof(*f)); |
1391 | f->type = V4L2_TUNER_ANALOG_TV; | 1380 | f->type = V4L2_TUNER_ANALOG_TV; |
1392 | f->frequency = dev->ctl_freq; | 1381 | f->frequency = dev->ctl_freq; |
1393 | 1382 | ||
1394 | return 0; | 1383 | return 0; |
1395 | } | 1384 | } |
1396 | case VIDIOC_S_FREQUENCY: | 1385 | case VIDIOC_S_FREQUENCY: |
1397 | { | 1386 | { |
1398 | struct v4l2_frequency *f = arg; | 1387 | struct v4l2_frequency *f = arg; |
1399 | |||
1400 | if (0 != f->tuner) | ||
1401 | return -EINVAL; | ||
1402 | 1388 | ||
1403 | if (V4L2_TUNER_ANALOG_TV != f->type) | 1389 | if (0 != f->tuner) |
1404 | return -EINVAL; | 1390 | return -EINVAL; |
1405 | 1391 | ||
1406 | down(&dev->lock); | 1392 | if (V4L2_TUNER_ANALOG_TV != f->type) |
1407 | dev->ctl_freq = f->frequency; | 1393 | return -EINVAL; |
1408 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); | ||
1409 | up(&dev->lock); | ||
1410 | return 0; | ||
1411 | } | ||
1412 | 1394 | ||
1395 | down(&dev->lock); | ||
1396 | dev->ctl_freq = f->frequency; | ||
1397 | em28xx_i2c_call_clients(dev, VIDIOC_S_FREQUENCY, f); | ||
1398 | up(&dev->lock); | ||
1399 | return 0; | ||
1400 | } | ||
1413 | case VIDIOC_CROPCAP: | 1401 | case VIDIOC_CROPCAP: |
1414 | { | 1402 | { |
1415 | struct v4l2_cropcap *cc = arg; | 1403 | struct v4l2_cropcap *cc = arg; |
1416 | 1404 | ||
1417 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 1405 | if (cc->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1418 | return -EINVAL; | 1406 | return -EINVAL; |
1419 | cc->bounds.left = 0; | 1407 | cc->bounds.left = 0; |
1420 | cc->bounds.top = 0; | 1408 | cc->bounds.top = 0; |
1421 | cc->bounds.width = dev->width; | 1409 | cc->bounds.width = dev->width; |
1422 | cc->bounds.height = dev->height; | 1410 | cc->bounds.height = dev->height; |
1423 | cc->defrect = cc->bounds; | 1411 | cc->defrect = cc->bounds; |
1424 | cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ | 1412 | cc->pixelaspect.numerator = 54; /* 4:3 FIXME: remove magic numbers */ |
1425 | cc->pixelaspect.denominator = 59; | 1413 | cc->pixelaspect.denominator = 59; |
1426 | return 0; | 1414 | return 0; |
1427 | } | 1415 | } |
1428 | case VIDIOC_STREAMON: | 1416 | case VIDIOC_STREAMON: |
1429 | { | 1417 | { |
1430 | int *type = arg; | 1418 | int *type = arg; |
1431 | 1419 | ||
1432 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE | 1420 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE |
1433 | || dev->io != IO_MMAP) | 1421 | || dev->io != IO_MMAP) |
1434 | return -EINVAL; | 1422 | return -EINVAL; |
1435 | 1423 | ||
1436 | if (list_empty(&dev->inqueue)) | 1424 | if (list_empty(&dev->inqueue)) |
1437 | return -EINVAL; | 1425 | return -EINVAL; |
1438 | 1426 | ||
1439 | dev->stream = STREAM_ON; /* FIXME: Start video capture here? */ | 1427 | dev->stream = STREAM_ON; /* FIXME: Start video capture here? */ |
1440 | 1428 | ||
1441 | em28xx_videodbg("VIDIOC_STREAMON: starting stream\n"); | 1429 | em28xx_videodbg("VIDIOC_STREAMON: starting stream\n"); |
1442 | 1430 | ||
1443 | return 0; | 1431 | return 0; |
1444 | } | 1432 | } |
1445 | case VIDIOC_STREAMOFF: | 1433 | case VIDIOC_STREAMOFF: |
1446 | { | 1434 | { |
1447 | int *type = arg; | 1435 | int *type = arg; |
1448 | int ret; | 1436 | int ret; |
1449 | |||
1450 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE | ||
1451 | || dev->io != IO_MMAP) | ||
1452 | return -EINVAL; | ||
1453 | 1437 | ||
1454 | if (dev->stream == STREAM_ON) { | 1438 | if (*type != V4L2_BUF_TYPE_VIDEO_CAPTURE |
1455 | em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream\n"); | 1439 | || dev->io != IO_MMAP) |
1456 | if ((ret = em28xx_stream_interrupt(dev))) | 1440 | return -EINVAL; |
1457 | return ret; | ||
1458 | } | ||
1459 | em28xx_empty_framequeues(dev); | ||
1460 | 1441 | ||
1461 | return 0; | 1442 | if (dev->stream == STREAM_ON) { |
1443 | em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream\n"); | ||
1444 | if ((ret = em28xx_stream_interrupt(dev))) | ||
1445 | return ret; | ||
1462 | } | 1446 | } |
1447 | em28xx_empty_framequeues(dev); | ||
1448 | |||
1449 | return 0; | ||
1450 | } | ||
1463 | default: | 1451 | default: |
1464 | return v4l_compat_translate_ioctl(inode, filp, cmd, arg, | 1452 | return v4l_compat_translate_ioctl(inode, filp, cmd, arg, |
1465 | driver_ioctl); | 1453 | driver_ioctl); |
@@ -1489,40 +1477,38 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp, | |||
1489 | /* --- capabilities ------------------------------------------ */ | 1477 | /* --- capabilities ------------------------------------------ */ |
1490 | case VIDIOC_QUERYCAP: | 1478 | case VIDIOC_QUERYCAP: |
1491 | { | 1479 | { |
1492 | struct v4l2_capability *cap = arg; | 1480 | struct v4l2_capability *cap = arg; |
1493 | 1481 | ||
1494 | memset(cap, 0, sizeof(*cap)); | 1482 | memset(cap, 0, sizeof(*cap)); |
1495 | strlcpy(cap->driver, "em28xx", sizeof(cap->driver)); | 1483 | strlcpy(cap->driver, "em28xx", sizeof(cap->driver)); |
1496 | strlcpy(cap->card, em28xx_boards[dev->model].name, | 1484 | strlcpy(cap->card, em28xx_boards[dev->model].name, |
1497 | sizeof(cap->card)); | 1485 | sizeof(cap->card)); |
1498 | strlcpy(cap->bus_info, dev->udev->dev.bus_id, | 1486 | strlcpy(cap->bus_info, dev->udev->dev.bus_id, |
1499 | sizeof(cap->bus_info)); | 1487 | sizeof(cap->bus_info)); |
1500 | cap->version = EM28XX_VERSION_CODE; | 1488 | cap->version = EM28XX_VERSION_CODE; |
1501 | cap->capabilities = | 1489 | cap->capabilities = |
1502 | V4L2_CAP_SLICED_VBI_CAPTURE | | 1490 | V4L2_CAP_SLICED_VBI_CAPTURE | |
1503 | V4L2_CAP_VIDEO_CAPTURE | | 1491 | V4L2_CAP_VIDEO_CAPTURE | |
1504 | V4L2_CAP_AUDIO | | 1492 | V4L2_CAP_AUDIO | |
1505 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; | 1493 | V4L2_CAP_READWRITE | V4L2_CAP_STREAMING; |
1506 | if (dev->has_tuner) | 1494 | if (dev->has_tuner) |
1507 | cap->capabilities |= V4L2_CAP_TUNER; | 1495 | cap->capabilities |= V4L2_CAP_TUNER; |
1508 | return 0; | 1496 | return 0; |
1509 | } | 1497 | } |
1510 | 1498 | /* --- capture ioctls ---------------------------------------- */ | |
1511 | /* --- capture ioctls ---------------------------------------- */ | ||
1512 | case VIDIOC_ENUM_FMT: | 1499 | case VIDIOC_ENUM_FMT: |
1513 | { | 1500 | { |
1514 | struct v4l2_fmtdesc *fmtd = arg; | 1501 | struct v4l2_fmtdesc *fmtd = arg; |
1515 | |||
1516 | if (fmtd->index != 0) | ||
1517 | return -EINVAL; | ||
1518 | memset(fmtd, 0, sizeof(*fmtd)); | ||
1519 | fmtd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1520 | strcpy(fmtd->description, "Packed YUY2"); | ||
1521 | fmtd->pixelformat = V4L2_PIX_FMT_YUYV; | ||
1522 | memset(fmtd->reserved, 0, sizeof(fmtd->reserved)); | ||
1523 | return 0; | ||
1524 | } | ||
1525 | 1502 | ||
1503 | if (fmtd->index != 0) | ||
1504 | return -EINVAL; | ||
1505 | memset(fmtd, 0, sizeof(*fmtd)); | ||
1506 | fmtd->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | ||
1507 | strcpy(fmtd->description, "Packed YUY2"); | ||
1508 | fmtd->pixelformat = V4L2_PIX_FMT_YUYV; | ||
1509 | memset(fmtd->reserved, 0, sizeof(fmtd->reserved)); | ||
1510 | return 0; | ||
1511 | } | ||
1526 | case VIDIOC_G_FMT: | 1512 | case VIDIOC_G_FMT: |
1527 | return em28xx_get_fmt(dev, (struct v4l2_format *) arg); | 1513 | return em28xx_get_fmt(dev, (struct v4l2_format *) arg); |
1528 | 1514 | ||
@@ -1531,131 +1517,130 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp, | |||
1531 | return em28xx_set_fmt(dev, cmd, (struct v4l2_format *)arg); | 1517 | return em28xx_set_fmt(dev, cmd, (struct v4l2_format *)arg); |
1532 | 1518 | ||
1533 | case VIDIOC_REQBUFS: | 1519 | case VIDIOC_REQBUFS: |
1534 | { | 1520 | { |
1535 | struct v4l2_requestbuffers *rb = arg; | 1521 | struct v4l2_requestbuffers *rb = arg; |
1536 | u32 i; | 1522 | u32 i; |
1537 | int ret; | 1523 | int ret; |
1538 | |||
1539 | if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | ||
1540 | rb->memory != V4L2_MEMORY_MMAP) | ||
1541 | return -EINVAL; | ||
1542 | 1524 | ||
1543 | if (dev->io == IO_READ) { | 1525 | if (rb->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1544 | em28xx_videodbg ("method is set to read;" | 1526 | rb->memory != V4L2_MEMORY_MMAP) |
1545 | " close and open the device again to" | 1527 | return -EINVAL; |
1546 | " choose the mmap I/O method\n"); | ||
1547 | return -EINVAL; | ||
1548 | } | ||
1549 | 1528 | ||
1550 | for (i = 0; i < dev->num_frames; i++) | 1529 | if (dev->io == IO_READ) { |
1551 | if (dev->frame[i].vma_use_count) { | 1530 | em28xx_videodbg ("method is set to read;" |
1552 | em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped\n"); | 1531 | " close and open the device again to" |
1553 | return -EINVAL; | 1532 | " choose the mmap I/O method\n"); |
1554 | } | 1533 | return -EINVAL; |
1534 | } | ||
1555 | 1535 | ||
1556 | if (dev->stream == STREAM_ON) { | 1536 | for (i = 0; i < dev->num_frames; i++) |
1557 | em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream\n"); | 1537 | if (dev->frame[i].vma_use_count) { |
1558 | if ((ret = em28xx_stream_interrupt(dev))) | 1538 | em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped\n"); |
1559 | return ret; | 1539 | return -EINVAL; |
1560 | } | 1540 | } |
1561 | 1541 | ||
1562 | em28xx_empty_framequeues(dev); | 1542 | if (dev->stream == STREAM_ON) { |
1543 | em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream\n"); | ||
1544 | if ((ret = em28xx_stream_interrupt(dev))) | ||
1545 | return ret; | ||
1546 | } | ||
1563 | 1547 | ||
1564 | em28xx_release_buffers(dev); | 1548 | em28xx_empty_framequeues(dev); |
1565 | if (rb->count) | ||
1566 | rb->count = | ||
1567 | em28xx_request_buffers(dev, rb->count); | ||
1568 | 1549 | ||
1569 | dev->frame_current = NULL; | 1550 | em28xx_release_buffers(dev); |
1551 | if (rb->count) | ||
1552 | rb->count = | ||
1553 | em28xx_request_buffers(dev, rb->count); | ||
1570 | 1554 | ||
1571 | em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i\n", | 1555 | dev->frame_current = NULL; |
1572 | rb->count); | ||
1573 | dev->io = rb->count ? IO_MMAP : IO_NONE; | ||
1574 | return 0; | ||
1575 | } | ||
1576 | 1556 | ||
1557 | em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i\n", | ||
1558 | rb->count); | ||
1559 | dev->io = rb->count ? IO_MMAP : IO_NONE; | ||
1560 | return 0; | ||
1561 | } | ||
1577 | case VIDIOC_QUERYBUF: | 1562 | case VIDIOC_QUERYBUF: |
1578 | { | 1563 | { |
1579 | struct v4l2_buffer *b = arg; | 1564 | struct v4l2_buffer *b = arg; |
1580 | 1565 | ||
1581 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1566 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1582 | b->index >= dev->num_frames || dev->io != IO_MMAP) | 1567 | b->index >= dev->num_frames || dev->io != IO_MMAP) |
1583 | return -EINVAL; | 1568 | return -EINVAL; |
1584 | 1569 | ||
1585 | memcpy(b, &dev->frame[b->index].buf, sizeof(*b)); | 1570 | memcpy(b, &dev->frame[b->index].buf, sizeof(*b)); |
1586 | 1571 | ||
1587 | if (dev->frame[b->index].vma_use_count) { | 1572 | if (dev->frame[b->index].vma_use_count) { |
1588 | b->flags |= V4L2_BUF_FLAG_MAPPED; | 1573 | b->flags |= V4L2_BUF_FLAG_MAPPED; |
1589 | } | ||
1590 | if (dev->frame[b->index].state == F_DONE) | ||
1591 | b->flags |= V4L2_BUF_FLAG_DONE; | ||
1592 | else if (dev->frame[b->index].state != F_UNUSED) | ||
1593 | b->flags |= V4L2_BUF_FLAG_QUEUED; | ||
1594 | return 0; | ||
1595 | } | 1574 | } |
1575 | if (dev->frame[b->index].state == F_DONE) | ||
1576 | b->flags |= V4L2_BUF_FLAG_DONE; | ||
1577 | else if (dev->frame[b->index].state != F_UNUSED) | ||
1578 | b->flags |= V4L2_BUF_FLAG_QUEUED; | ||
1579 | return 0; | ||
1580 | } | ||
1596 | case VIDIOC_QBUF: | 1581 | case VIDIOC_QBUF: |
1597 | { | 1582 | { |
1598 | struct v4l2_buffer *b = arg; | 1583 | struct v4l2_buffer *b = arg; |
1599 | unsigned long lock_flags; | 1584 | unsigned long lock_flags; |
1600 | 1585 | ||
1601 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1586 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1602 | b->index >= dev->num_frames || dev->io != IO_MMAP) { | 1587 | b->index >= dev->num_frames || dev->io != IO_MMAP) { |
1603 | return -EINVAL; | 1588 | return -EINVAL; |
1604 | } | 1589 | } |
1605 | 1590 | ||
1606 | if (dev->frame[b->index].state != F_UNUSED) { | 1591 | if (dev->frame[b->index].state != F_UNUSED) { |
1607 | return -EAGAIN; | 1592 | return -EAGAIN; |
1608 | } | 1593 | } |
1609 | dev->frame[b->index].state = F_QUEUED; | 1594 | dev->frame[b->index].state = F_QUEUED; |
1610 | 1595 | ||
1611 | /* add frame to fifo */ | 1596 | /* add frame to fifo */ |
1612 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | 1597 | spin_lock_irqsave(&dev->queue_lock, lock_flags); |
1613 | list_add_tail(&dev->frame[b->index].frame, | 1598 | list_add_tail(&dev->frame[b->index].frame, |
1614 | &dev->inqueue); | 1599 | &dev->inqueue); |
1615 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | 1600 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); |
1616 | 1601 | ||
1617 | return 0; | 1602 | return 0; |
1618 | } | 1603 | } |
1619 | case VIDIOC_DQBUF: | 1604 | case VIDIOC_DQBUF: |
1620 | { | 1605 | { |
1621 | struct v4l2_buffer *b = arg; | 1606 | struct v4l2_buffer *b = arg; |
1622 | struct em28xx_frame_t *f; | 1607 | struct em28xx_frame_t *f; |
1623 | unsigned long lock_flags; | 1608 | unsigned long lock_flags; |
1624 | int ret = 0; | 1609 | int ret = 0; |
1625 | 1610 | ||
1626 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE | 1611 | if (b->type != V4L2_BUF_TYPE_VIDEO_CAPTURE |
1627 | || dev->io != IO_MMAP) | 1612 | || dev->io != IO_MMAP) |
1628 | return -EINVAL; | 1613 | return -EINVAL; |
1629 | 1614 | ||
1630 | if (list_empty(&dev->outqueue)) { | 1615 | if (list_empty(&dev->outqueue)) { |
1631 | if (dev->stream == STREAM_OFF) | 1616 | if (dev->stream == STREAM_OFF) |
1632 | return -EINVAL; | 1617 | return -EINVAL; |
1633 | if (filp->f_flags & O_NONBLOCK) | 1618 | if (filp->f_flags & O_NONBLOCK) |
1634 | return -EAGAIN; | 1619 | return -EAGAIN; |
1635 | ret = wait_event_interruptible | 1620 | ret = wait_event_interruptible |
1636 | (dev->wait_frame, | 1621 | (dev->wait_frame, |
1637 | (!list_empty(&dev->outqueue)) || | 1622 | (!list_empty(&dev->outqueue)) || |
1638 | (dev->state & DEV_DISCONNECTED)); | 1623 | (dev->state & DEV_DISCONNECTED)); |
1639 | if (ret) | 1624 | if (ret) |
1640 | return ret; | 1625 | return ret; |
1641 | if (dev->state & DEV_DISCONNECTED) | 1626 | if (dev->state & DEV_DISCONNECTED) |
1642 | return -ENODEV; | 1627 | return -ENODEV; |
1643 | } | 1628 | } |
1644 | 1629 | ||
1645 | spin_lock_irqsave(&dev->queue_lock, lock_flags); | 1630 | spin_lock_irqsave(&dev->queue_lock, lock_flags); |
1646 | f = list_entry(dev->outqueue.next, | 1631 | f = list_entry(dev->outqueue.next, |
1647 | struct em28xx_frame_t, frame); | 1632 | struct em28xx_frame_t, frame); |
1648 | list_del(dev->outqueue.next); | 1633 | list_del(dev->outqueue.next); |
1649 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); | 1634 | spin_unlock_irqrestore(&dev->queue_lock, lock_flags); |
1650 | 1635 | ||
1651 | f->state = F_UNUSED; | 1636 | f->state = F_UNUSED; |
1652 | memcpy(b, &f->buf, sizeof(*b)); | 1637 | memcpy(b, &f->buf, sizeof(*b)); |
1653 | 1638 | ||
1654 | if (f->vma_use_count) | 1639 | if (f->vma_use_count) |
1655 | b->flags |= V4L2_BUF_FLAG_MAPPED; | 1640 | b->flags |= V4L2_BUF_FLAG_MAPPED; |
1656 | 1641 | ||
1657 | return 0; | 1642 | return 0; |
1658 | } | 1643 | } |
1659 | default: | 1644 | default: |
1660 | return em28xx_do_ioctl(inode, filp, dev, cmd, arg, | 1645 | return em28xx_do_ioctl(inode, filp, dev, cmd, arg, |
1661 | em28xx_video_do_ioctl); | 1646 | em28xx_video_do_ioctl); |