aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorDouglas Schilling Landgraf <dougsland@gmail.com>2008-06-27 03:15:38 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-07-20 06:12:43 -0400
commit305519c924d8f2f2f85c390c6d456dc41dbe0284 (patch)
treeba124dce26b2c34ad2ae778409c7dfc8f34c896d /drivers/media
parent9c7ecaf5ace4dba94b4c75afa395440acfb2e36c (diff)
V4L/DVB (8120): cx23885-417: Replace cx23885_do_ioctl to use video_ioctl2
Convert cx23885-417 to use video_ioctl2 Signed-off-by: Douglas Schilling Landgraf <dougsland@gmail.com> Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/video/cx23885/cx23885-417.c699
1 files changed, 375 insertions, 324 deletions
diff --git a/drivers/media/video/cx23885/cx23885-417.c b/drivers/media/video/cx23885/cx23885-417.c
index 0f50c377aa7c..e7ef093265af 100644
--- a/drivers/media/video/cx23885/cx23885-417.c
+++ b/drivers/media/video/cx23885/cx23885-417.c
@@ -1176,376 +1176,401 @@ static int cx23885_querymenu(struct cx23885_dev *dev,
1176 cx2341x_ctrl_get_menu(&dev->mpeg_params, qmenu->id)); 1176 cx2341x_ctrl_get_menu(&dev->mpeg_params, qmenu->id));
1177} 1177}
1178 1178
1179int cx23885_do_ioctl(struct inode *inode, struct file *file, int radio, 1179static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *id)
1180 struct cx23885_dev *dev, unsigned int cmd, void *arg,
1181 v4l2_kioctl driver_ioctl)
1182{ 1180{
1183 int err; 1181 struct cx23885_fh *fh = file->private_data;
1182 struct cx23885_dev *dev = fh->dev;
1183 unsigned int i;
1184 1184
1185 switch (cmd) { 1185 for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++)
1186 /* ---------- tv norms ---------- */ 1186 if (*id & cx23885_tvnorms[i].id)
1187 case VIDIOC_ENUMSTD: 1187 break;
1188 { 1188 if (i == ARRAY_SIZE(cx23885_tvnorms))
1189 struct v4l2_standard *e = arg; 1189 return -EINVAL;
1190 unsigned int i; 1190 dev->encodernorm = cx23885_tvnorms[i];
1191 1191 return 0;
1192 i = e->index; 1192}
1193 if (i >= ARRAY_SIZE(cx23885_tvnorms))
1194 return -EINVAL;
1195 err = v4l2_video_std_construct(e,
1196 cx23885_tvnorms[e->index].id,
1197 cx23885_tvnorms[e->index].name);
1198 e->index = i;
1199 if (err < 0)
1200 return err;
1201 return 0;
1202 }
1203 case VIDIOC_G_STD:
1204 {
1205 v4l2_std_id *id = arg;
1206 1193
1207 *id = dev->encodernorm.id; 1194static int vidioc_enum_input(struct file *file, void *priv,
1208 return 0; 1195 struct v4l2_input *i)
1209 } 1196{
1210 case VIDIOC_S_STD: 1197 struct cx23885_fh *fh = file->private_data;
1211 { 1198 struct cx23885_dev *dev = fh->dev;
1212 v4l2_std_id *id = arg; 1199 struct cx23885_input *input;
1213 unsigned int i; 1200 unsigned int n;
1214 1201
1215 for (i = 0; i < ARRAY_SIZE(cx23885_tvnorms); i++) 1202 n = i->index;
1216 if (*id & cx23885_tvnorms[i].id)
1217 break;
1218 if (i == ARRAY_SIZE(cx23885_tvnorms))
1219 return -EINVAL;
1220 dev->encodernorm = cx23885_tvnorms[i];
1221 1203
1222 return 0; 1204 if (n >= 4)
1223 } 1205 return -EINVAL;
1224 1206
1225 /* ------ input switching ---------- */ 1207 input = &cx23885_boards[dev->board].input[n];
1226 case VIDIOC_ENUMINPUT:
1227 {
1228 struct cx23885_input *input;
1229 struct v4l2_input *i = arg;
1230 unsigned int n;
1231
1232 n = i->index;
1233 if (n >= 4)
1234 return -EINVAL;
1235 input = &cx23885_boards[dev->board].input[n];
1236 if (input->type == 0)
1237 return -EINVAL;
1238 memset(i, 0, sizeof(*i));
1239 i->index = n;
1240 /* FIXME
1241 * strcpy(i->name, input->name); */
1242 strcpy(i->name, "unset");
1243 if (input->type == CX23885_VMUX_TELEVISION ||
1244 input->type == CX23885_VMUX_CABLE)
1245 i->type = V4L2_INPUT_TYPE_TUNER;
1246 else
1247 i->type = V4L2_INPUT_TYPE_CAMERA;
1248 1208
1249 for (n = 0; n < ARRAY_SIZE(cx23885_tvnorms); n++) 1209 if (input->type == 0)
1250 i->std |= cx23885_tvnorms[n].id; 1210 return -EINVAL;
1251 return 0;
1252 }
1253 case VIDIOC_G_INPUT:
1254 {
1255 unsigned int *i = arg;
1256 1211
1257 *i = dev->input; 1212 memset(i, 0, sizeof(*i));
1258 return 0; 1213 i->index = n;
1259 }
1260 case VIDIOC_S_INPUT:
1261 {
1262 unsigned int *i = arg;
1263 1214
1264 if (*i >= 4) 1215 /* FIXME
1265 return -EINVAL; 1216 * strcpy(i->name, input->name); */
1217 strcpy(i->name, "unset");
1266 1218
1267 return 0; 1219 if (input->type == CX23885_VMUX_TELEVISION ||
1268 } 1220 input->type == CX23885_VMUX_CABLE)
1221 i->type = V4L2_INPUT_TYPE_TUNER;
1222 else
1223 i->type = V4L2_INPUT_TYPE_CAMERA;
1269 1224
1270 /* --- tuner ioctls ------------------------------------------ */ 1225 for (n = 0; n < ARRAY_SIZE(cx23885_tvnorms); n++)
1271 case VIDIOC_G_TUNER: 1226 i->std |= cx23885_tvnorms[n].id;
1272 { 1227 return 0;
1273 struct v4l2_tuner *t = arg; 1228}
1274 1229
1275 if (UNSET == dev->tuner_type) 1230static int vidioc_g_input(struct file *file, void *priv, unsigned int *i)
1276 return -EINVAL; 1231{
1277 if (0 != t->index) 1232 struct cx23885_fh *fh = file->private_data;
1278 return -EINVAL; 1233 struct cx23885_dev *dev = fh->dev;
1279 memset(t, 0, sizeof(*t));
1280 strcpy(t->name, "Television");
1281 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
1282 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
1283 1234
1284 dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type); 1235 *i = dev->input;
1236 return 0;
1237}
1285 1238
1286 return 0; 1239static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
1287 } 1240{
1288 case VIDIOC_S_TUNER: 1241 if (i >= 4)
1289 { 1242 return -EINVAL;
1290 struct v4l2_tuner *t = arg;
1291 1243
1292 if (UNSET == dev->tuner_type) 1244 return 0;
1293 return -EINVAL; 1245}
1294 1246
1295 /* Update the A/V core */ 1247static int vidioc_g_tuner(struct file *file, void *priv,
1296 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t); 1248 struct v4l2_tuner *t)
1249{
1250 struct cx23885_fh *fh = file->private_data;
1251 struct cx23885_dev *dev = fh->dev;
1297 1252
1298 return 0; 1253 if (UNSET == dev->tuner_type)
1299 } 1254 return -EINVAL;
1300 case VIDIOC_G_FREQUENCY: 1255 if (0 != t->index)
1301 { 1256 return -EINVAL;
1302 struct v4l2_frequency *f = arg; 1257 memset(t, 0, sizeof(*t));
1258 strcpy(t->name, "Television");
1259 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_G_TUNER, t);
1260 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_TUNER, t);
1303 1261
1304 memset(f, 0, sizeof(*f)); 1262 dprintk(1, "VIDIOC_G_TUNER: tuner type %d\n", t->type);
1305 if (UNSET == dev->tuner_type)
1306 return -EINVAL;
1307 f->type = V4L2_TUNER_ANALOG_TV;
1308 f->frequency = dev->freq;
1309 1263
1310 /* Assumption that tuner is always on bus 1 */ 1264 return 0;
1311 cx23885_call_i2c_clients(&dev->i2c_bus[1], 1265}
1312 VIDIOC_G_FREQUENCY, f);
1313 1266
1314 return 0; 1267static int vidioc_s_tuner(struct file *file, void *priv,
1315 } 1268 struct v4l2_tuner *t)
1316 case VIDIOC_S_FREQUENCY: 1269{
1317 { 1270 struct cx23885_fh *fh = file->private_data;
1318 struct v4l2_frequency *f = arg; 1271 struct cx23885_dev *dev = fh->dev;
1319 1272
1320 dprintk(1, "VIDIOC_S_FREQUENCY: dev type %d, f\n", 1273 if (UNSET == dev->tuner_type)
1321 dev->tuner_type); 1274 return -EINVAL;
1322 dprintk(1, "VIDIOC_S_FREQUENCY: f tuner %d, f type %d\n", 1275
1323 f->tuner, f->type); 1276 /* Update the A/V core */
1324 if (UNSET == dev->tuner_type) 1277 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_TUNER, t);
1325 return -EINVAL; 1278
1326 if (f->tuner != 0) 1279 return 0;
1327 return -EINVAL; 1280}
1328 if (f->type != V4L2_TUNER_ANALOG_TV) 1281
1329 return -EINVAL; 1282static int vidioc_g_frequency(struct file *file, void *priv,
1330 dev->freq = f->frequency; 1283 struct v4l2_frequency *f)
1331 1284{
1332 /* Assumption that tuner is always on bus 1 */ 1285 struct cx23885_fh *fh = file->private_data;
1333 cx23885_call_i2c_clients(&dev->i2c_bus[1], 1286 struct cx23885_dev *dev = fh->dev;
1334 VIDIOC_S_FREQUENCY, f); 1287
1335 return 0; 1288 memset(f, 0, sizeof(*f));
1336 } 1289 if (UNSET == dev->tuner_type)
1337 case VIDIOC_S_CTRL: 1290 return -EINVAL;
1338 { 1291 f->type = V4L2_TUNER_ANALOG_TV;
1339 /* Update the A/V core */ 1292 f->frequency = dev->freq;
1340 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, arg); 1293
1341 return 0; 1294 /* Assumption that tuner is always on bus 1 */
1342 } 1295 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_G_FREQUENCY, f);
1343 default: 1296
1344 /* Convert V4L ioctl to V4L2 and call mpeg_do_ioctl 1297 return 0;
1345 * (driver_ioctl) */ 1298}
1346 return v4l_compat_translate_ioctl(inode, file, cmd, arg, 1299
1347 driver_ioctl); 1300static int vidioc_s_frequency(struct file *file, void *priv,
1348 } 1301 struct v4l2_frequency *f)
1302{
1303 struct cx23885_fh *fh = file->private_data;
1304 struct cx23885_dev *dev = fh->dev;
1305
1306 cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1307 CX23885_END_NOW, CX23885_MPEG_CAPTURE,
1308 CX23885_RAW_BITS_NONE);
1309
1310 dprintk(1, "VIDIOC_S_FREQUENCY: dev type %d, f\n",
1311 dev->tuner_type);
1312 dprintk(1, "VIDIOC_S_FREQUENCY: f tuner %d, f type %d\n",
1313 f->tuner, f->type);
1314 if (UNSET == dev->tuner_type)
1315 return -EINVAL;
1316 if (f->tuner != 0)
1317 return -EINVAL;
1318 if (f->type != V4L2_TUNER_ANALOG_TV)
1319 return -EINVAL;
1320 dev->freq = f->frequency;
1321
1322 /* Assumption that tuner is always on bus 1 */
1323 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_S_FREQUENCY, f);
1324
1325 cx23885_initialize_codec(dev);
1349 1326
1350 return 0; 1327 return 0;
1351} 1328}
1352 1329
1353static int mpeg_do_ioctl(struct inode *inode, struct file *file, 1330static int vidioc_s_ctrl(struct file *file, void *priv,
1354 unsigned int cmd, void *arg) 1331 struct v4l2_control *ctl)
1332{
1333 struct cx23885_fh *fh = file->private_data;
1334 struct cx23885_dev *dev = fh->dev;
1335
1336 /* Update the A/V core */
1337 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_S_CTRL, ctl);
1338 return 0;
1339}
1340
1341static int vidioc_querycap(struct file *file, void *priv,
1342 struct v4l2_capability *cap)
1355{ 1343{
1356 struct cx23885_fh *fh = file->private_data; 1344 struct cx23885_fh *fh = file->private_data;
1357 struct cx23885_dev *dev = fh->dev; 1345 struct cx23885_dev *dev = fh->dev;
1358 struct cx23885_tsport *tsport = &dev->ts1; 1346 struct cx23885_tsport *tsport = &dev->ts1;
1359 1347
1360 if (v4l_debug > 1) 1348 memset(cap, 0, sizeof(*cap));
1361 v4l_print_ioctl(dev->name, cmd); 1349 strcpy(cap->driver, dev->name);
1350 strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
1351 sizeof(cap->card));
1352 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
1353 cap->version = CX23885_VERSION_CODE;
1354 cap->capabilities =
1355 V4L2_CAP_VIDEO_CAPTURE |
1356 V4L2_CAP_READWRITE |
1357 V4L2_CAP_STREAMING |
1358 0;
1359 if (UNSET != dev->tuner_type)
1360 cap->capabilities |= V4L2_CAP_TUNER;
1362 1361
1363 switch (cmd) { 1362 return 0;
1363}
1364 1364
1365 /* --- capabilities ------------------------------------------ */ 1365static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv,
1366 case VIDIOC_QUERYCAP: 1366 struct v4l2_fmtdesc *f)
1367 { 1367{
1368 struct v4l2_capability *cap = arg; 1368 int index;
1369
1370 memset(cap, 0, sizeof(*cap));
1371 strcpy(cap->driver, dev->name);
1372 strlcpy(cap->card, cx23885_boards[tsport->dev->board].name,
1373 sizeof(cap->card));
1374 sprintf(cap->bus_info, "PCI:%s", pci_name(dev->pci));
1375 cap->version = CX23885_VERSION_CODE;
1376 cap->capabilities =
1377 V4L2_CAP_VIDEO_CAPTURE |
1378 V4L2_CAP_READWRITE |
1379 V4L2_CAP_STREAMING |
1380 0;
1381 if (UNSET != dev->tuner_type)
1382 cap->capabilities |= V4L2_CAP_TUNER;
1383
1384 return 0;
1385 }
1386 1369
1387 /* --- capture ioctls ---------------------------------------- */ 1370 index = f->index;
1388 case VIDIOC_ENUM_FMT: 1371 if (index != 0)
1389 { 1372 return -EINVAL;
1390 struct v4l2_fmtdesc *f = arg;
1391 int index;
1392
1393 index = f->index;
1394 if (index != 0)
1395 return -EINVAL;
1396
1397 memset(f, 0, sizeof(*f));
1398 f->index = index;
1399 strlcpy(f->description, "MPEG", sizeof(f->description));
1400 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1401 f->pixelformat = V4L2_PIX_FMT_MPEG;
1402 return 0;
1403 }
1404 case VIDIOC_G_FMT:
1405 {
1406 struct v4l2_format *f = arg;
1407
1408 memset(f, 0, sizeof(*f));
1409 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1410 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1411 f->fmt.pix.bytesperline = 0;
1412 f->fmt.pix.sizeimage =
1413 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1414 f->fmt.pix.colorspace = 0;
1415 f->fmt.pix.width = dev->ts1.width;
1416 f->fmt.pix.height = dev->ts1.height;
1417 f->fmt.pix.field = fh->mpegq.field;
1418 dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
1419 dev->ts1.width, dev->ts1.height, fh->mpegq.field);
1420 return 0;
1421 }
1422 case VIDIOC_TRY_FMT:
1423 {
1424 struct v4l2_format *f = arg;
1425
1426 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1427 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1428 f->fmt.pix.bytesperline = 0;
1429 f->fmt.pix.sizeimage =
1430 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1431 f->fmt.pix.sizeimage =
1432 f->fmt.pix.colorspace = 0;
1433 dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
1434 dev->ts1.width, dev->ts1.height, fh->mpegq.field);
1435 return 0;
1436 }
1437 case VIDIOC_S_FMT:
1438 {
1439 struct v4l2_format *f = arg;
1440
1441 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1442 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1443 f->fmt.pix.bytesperline = 0;
1444 f->fmt.pix.sizeimage =
1445 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1446 f->fmt.pix.colorspace = 0;
1447 dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
1448 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
1449 return 0;
1450 }
1451 1373
1452 /* --- streaming capture ------------------------------------- */ 1374 memset(f, 0, sizeof(*f));
1453 case VIDIOC_REQBUFS: 1375 f->index = index;
1454 return videobuf_reqbufs(&fh->mpegq, arg); 1376 strlcpy(f->description, "MPEG", sizeof(f->description));
1377 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1378 f->pixelformat = V4L2_PIX_FMT_MPEG;
1455 1379
1456 case VIDIOC_QUERYBUF: 1380 return 0;
1457 return videobuf_querybuf(&fh->mpegq, arg); 1381}
1458 1382
1459 case VIDIOC_QBUF: 1383static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
1460 return videobuf_qbuf(&fh->mpegq, arg); 1384 struct v4l2_format *f)
1385{
1386 struct cx23885_fh *fh = file->private_data;
1387 struct cx23885_dev *dev = fh->dev;
1461 1388
1462 case VIDIOC_DQBUF: 1389 memset(f, 0, sizeof(*f));
1463 return videobuf_dqbuf(&fh->mpegq, arg, 1390 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1464 file->f_flags & O_NONBLOCK); 1391 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1392 f->fmt.pix.bytesperline = 0;
1393 f->fmt.pix.sizeimage =
1394 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1395 f->fmt.pix.colorspace = 0;
1396 f->fmt.pix.width = dev->ts1.width;
1397 f->fmt.pix.height = dev->ts1.height;
1398 f->fmt.pix.field = fh->mpegq.field;
1399 dprintk(1, "VIDIOC_G_FMT: w: %d, h: %d, f: %d\n",
1400 dev->ts1.width, dev->ts1.height, fh->mpegq.field);
1401 return 0;
1402}
1465 1403
1466 case VIDIOC_STREAMON: 1404static int vidioc_try_fmt_vid_cap(struct file *file, void *priv,
1467 return videobuf_streamon(&fh->mpegq); 1405 struct v4l2_format *f)
1406{
1407 struct cx23885_fh *fh = file->private_data;
1408 struct cx23885_dev *dev = fh->dev;
1468 1409
1469 case VIDIOC_STREAMOFF: 1410 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1470 return videobuf_streamoff(&fh->mpegq); 1411 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1412 f->fmt.pix.bytesperline = 0;
1413 f->fmt.pix.sizeimage =
1414 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1415 f->fmt.pix.sizeimage =
1416 f->fmt.pix.colorspace = 0;
1417 dprintk(1, "VIDIOC_TRY_FMT: w: %d, h: %d, f: %d\n",
1418 dev->ts1.width, dev->ts1.height, fh->mpegq.field);
1419 return 0;
1420}
1471 1421
1472 case VIDIOC_G_EXT_CTRLS: 1422static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
1473 { 1423 struct v4l2_format *f)
1474 struct v4l2_ext_controls *f = arg; 1424{
1425 struct cx23885_fh *fh = file->private_data;
1426 struct cx23885_dev *dev = fh->dev;
1475 1427
1476 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG) 1428 f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
1477 return -EINVAL; 1429 f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
1478 return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, cmd); 1430 f->fmt.pix.bytesperline = 0;
1479 } 1431 f->fmt.pix.sizeimage =
1480 case VIDIOC_S_EXT_CTRLS: 1432 dev->ts1.ts_packet_size * dev->ts1.ts_packet_count;
1481 case VIDIOC_TRY_EXT_CTRLS: 1433 f->fmt.pix.colorspace = 0;
1482 { 1434 dprintk(1, "VIDIOC_S_FMT: w: %d, h: %d, f: %d\n",
1483 struct v4l2_ext_controls *f = arg; 1435 f->fmt.pix.width, f->fmt.pix.height, f->fmt.pix.field);
1484 struct cx2341x_mpeg_params p; 1436 return 0;
1485 int err; 1437}
1486
1487 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
1488 return -EINVAL;
1489 p = dev->mpeg_params;
1490 err = cx2341x_ext_ctrls(&p, 0, f, cmd);
1491 if (err == 0 && cmd == VIDIOC_S_EXT_CTRLS) {
1492 err = cx2341x_update(dev, cx23885_mbox_func,
1493 &dev->mpeg_params, &p);
1494 dev->mpeg_params = p;
1495 }
1496 return err;
1497 }
1498 case VIDIOC_S_FREQUENCY:
1499 {
1500 cx23885_api_cmd(fh->dev, CX2341X_ENC_STOP_CAPTURE, 3, 0,
1501 CX23885_END_NOW, CX23885_MPEG_CAPTURE,
1502 CX23885_RAW_BITS_NONE);
1503 cx23885_do_ioctl(inode, file, 0, dev, cmd, arg,
1504 mpeg_do_ioctl);
1505 cx23885_initialize_codec(dev);
1506
1507 return 0;
1508 }
1509 case VIDIOC_LOG_STATUS:
1510 {
1511 char name[32 + 2];
1512
1513 snprintf(name, sizeof(name), "%s/2", dev->name);
1514 printk(KERN_INFO
1515 "%s/2: ============ START LOG STATUS ============\n",
1516 dev->name);
1517 cx23885_call_i2c_clients(&dev->i2c_bus[0], VIDIOC_LOG_STATUS,
1518 NULL);
1519 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_LOG_STATUS,
1520 NULL);
1521 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_LOG_STATUS,
1522 NULL);
1523 cx2341x_log_status(&dev->mpeg_params, name);
1524 printk(KERN_INFO
1525 "%s/2: ============= END LOG STATUS =============\n",
1526 dev->name);
1527 return 0;
1528 }
1529 case VIDIOC_QUERYMENU:
1530 return cx23885_querymenu(dev, arg);
1531 case VIDIOC_QUERYCTRL:
1532 {
1533 struct v4l2_queryctrl *c = arg;
1534 1438
1535 return cx23885_queryctrl(dev, c); 1439static int vidioc_reqbufs(struct file *file, void *priv,
1536 } 1440 struct v4l2_requestbuffers *p)
1441{
1442 struct cx23885_fh *fh = file->private_data;
1537 1443
1538 default: 1444 return videobuf_reqbufs(&fh->mpegq, p);
1539 return cx23885_do_ioctl(inode, file, 0, dev, cmd, arg, 1445}
1540 mpeg_do_ioctl); 1446
1447static int vidioc_querybuf(struct file *file, void *priv,
1448 struct v4l2_buffer *p)
1449{
1450 struct cx23885_fh *fh = file->private_data;
1451
1452 return videobuf_querybuf(&fh->mpegq, p);
1453}
1454
1455static int vidioc_qbuf(struct file *file, void *priv,
1456 struct v4l2_buffer *p)
1457{
1458 struct cx23885_fh *fh = file->private_data;
1459
1460 return videobuf_qbuf(&fh->mpegq, p);
1461}
1462
1463static int vidioc_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
1464{
1465 struct cx23885_fh *fh = priv;
1466
1467 return videobuf_dqbuf(&fh->mpegq, b, file->f_flags & O_NONBLOCK);
1468}
1469
1470
1471static int vidioc_streamon(struct file *file, void *priv,
1472 enum v4l2_buf_type i)
1473{
1474 struct cx23885_fh *fh = file->private_data;
1475
1476 return videobuf_streamon(&fh->mpegq);
1477}
1478
1479static int vidioc_streamoff(struct file *file, void *priv, enum v4l2_buf_type i)
1480{
1481 struct cx23885_fh *fh = file->private_data;
1482
1483 return videobuf_streamoff(&fh->mpegq);
1484}
1485
1486static int vidioc_g_ext_ctrls(struct file *file, void *priv,
1487 struct v4l2_ext_controls *f)
1488{
1489 struct cx23885_fh *fh = priv;
1490 struct cx23885_dev *dev = fh->dev;
1491
1492 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
1493 return -EINVAL;
1494 return cx2341x_ext_ctrls(&dev->mpeg_params, 0, f, VIDIOC_G_EXT_CTRLS);
1495}
1496
1497static int vidioc_s_ext_ctrls(struct file *file, void *priv,
1498 struct v4l2_ext_controls *f)
1499{
1500 struct cx23885_fh *fh = priv;
1501 struct cx23885_dev *dev = fh->dev;
1502 struct cx2341x_mpeg_params p;
1503 int err;
1504
1505 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
1506 return -EINVAL;
1507
1508 p = dev->mpeg_params;
1509 err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_S_EXT_CTRLS);
1510
1511 if (err == 0) {
1512 err = cx2341x_update(dev, cx23885_mbox_func,
1513 &dev->mpeg_params, &p);
1514 dev->mpeg_params = p;
1541 } 1515 }
1516 return err;
1517}
1518
1519static int vidioc_try_ext_ctrls(struct file *file, void *priv,
1520 struct v4l2_ext_controls *f)
1521{
1522 struct cx23885_fh *fh = priv;
1523 struct cx23885_dev *dev = fh->dev;
1524 struct cx2341x_mpeg_params p;
1525 int err;
1526
1527 if (f->ctrl_class != V4L2_CTRL_CLASS_MPEG)
1528 return -EINVAL;
1529
1530 p = dev->mpeg_params;
1531 err = cx2341x_ext_ctrls(&p, 0, f, VIDIOC_TRY_EXT_CTRLS);
1532 return err;
1533}
1534
1535static int vidioc_log_status(struct file *file, void *priv)
1536{
1537 struct cx23885_fh *fh = priv;
1538 struct cx23885_dev *dev = fh->dev;
1539 char name[32 + 2];
1540
1541 snprintf(name, sizeof(name), "%s/2", dev->name);
1542 printk(KERN_INFO
1543 "%s/2: ============ START LOG STATUS ============\n",
1544 dev->name);
1545 cx23885_call_i2c_clients(&dev->i2c_bus[0], VIDIOC_LOG_STATUS,
1546 NULL);
1547 cx23885_call_i2c_clients(&dev->i2c_bus[1], VIDIOC_LOG_STATUS,
1548 NULL);
1549 cx23885_call_i2c_clients(&dev->i2c_bus[2], VIDIOC_LOG_STATUS,
1550 NULL);
1551 cx2341x_log_status(&dev->mpeg_params, name);
1552 printk(KERN_INFO
1553 "%s/2: ============= END LOG STATUS =============\n",
1554 dev->name);
1542 return 0; 1555 return 0;
1543} 1556}
1544 1557
1545static int mpeg_ioctl(struct inode *inode, struct file *file, 1558static int vidioc_querymenu(struct file *file, void *priv,
1546 unsigned int cmd, unsigned long arg) 1559 struct v4l2_querymenu *a)
1560{
1561 struct cx23885_fh *fh = priv;
1562 struct cx23885_dev *dev = fh->dev;
1563
1564 return cx23885_querymenu(dev, a);
1565}
1566
1567static int vidioc_queryctrl(struct file *file, void *priv,
1568 struct v4l2_queryctrl *c)
1547{ 1569{
1548 return video_usercopy(inode, file, cmd, arg, mpeg_do_ioctl); 1570 struct cx23885_fh *fh = priv;
1571 struct cx23885_dev *dev = fh->dev;
1572
1573 return cx23885_queryctrl(dev, c);
1549} 1574}
1550 1575
1551static int mpeg_open(struct inode *inode, struct file *file) 1576static int mpeg_open(struct inode *inode, struct file *file)
@@ -1670,7 +1695,7 @@ static struct file_operations mpeg_fops = {
1670 .read = mpeg_read, 1695 .read = mpeg_read,
1671 .poll = mpeg_poll, 1696 .poll = mpeg_poll,
1672 .mmap = mpeg_mmap, 1697 .mmap = mpeg_mmap,
1673 .ioctl = mpeg_ioctl, 1698 .ioctl = video_ioctl2,
1674 .llseek = no_llseek, 1699 .llseek = no_llseek,
1675}; 1700};
1676 1701
@@ -1682,6 +1707,32 @@ static struct video_device cx23885_mpeg_template = {
1682 VID_TYPE_MPEG_ENCODER, 1707 VID_TYPE_MPEG_ENCODER,
1683 .fops = &mpeg_fops, 1708 .fops = &mpeg_fops,
1684 .minor = -1, 1709 .minor = -1,
1710 .vidioc_s_std = vidioc_s_std,
1711 .vidioc_enum_input = vidioc_enum_input,
1712 .vidioc_g_input = vidioc_g_input,
1713 .vidioc_s_input = vidioc_s_input,
1714 .vidioc_g_tuner = vidioc_g_tuner,
1715 .vidioc_s_tuner = vidioc_s_tuner,
1716 .vidioc_g_frequency = vidioc_g_frequency,
1717 .vidioc_s_frequency = vidioc_s_frequency,
1718 .vidioc_s_ctrl = vidioc_s_ctrl,
1719 .vidioc_querycap = vidioc_querycap,
1720 .vidioc_enum_fmt_vid_cap = vidioc_enum_fmt_vid_cap,
1721 .vidioc_g_fmt_vid_cap = vidioc_g_fmt_vid_cap,
1722 .vidioc_try_fmt_vid_cap = vidioc_try_fmt_vid_cap,
1723 .vidioc_s_fmt_vid_cap = vidioc_s_fmt_vid_cap,
1724 .vidioc_reqbufs = vidioc_reqbufs,
1725 .vidioc_querybuf = vidioc_querybuf,
1726 .vidioc_qbuf = vidioc_qbuf,
1727 .vidioc_dqbuf = vidioc_dqbuf,
1728 .vidioc_streamon = vidioc_streamon,
1729 .vidioc_streamoff = vidioc_streamoff,
1730 .vidioc_g_ext_ctrls = vidioc_g_ext_ctrls,
1731 .vidioc_s_ext_ctrls = vidioc_s_ext_ctrls,
1732 .vidioc_try_ext_ctrls = vidioc_try_ext_ctrls,
1733 .vidioc_log_status = vidioc_log_status,
1734 .vidioc_querymenu = vidioc_querymenu,
1735 .vidioc_queryctrl = vidioc_queryctrl,
1685}; 1736};
1686 1737
1687void cx23885_417_unregister(struct cx23885_dev *dev) 1738void cx23885_417_unregister(struct cx23885_dev *dev)