diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2011-01-22 04:36:02 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-03-21 19:31:51 -0400 |
commit | cbfb3daa66bc43f4e2d4f2063db7472a8b2837f5 (patch) | |
tree | 79b37f21d21613ba030e5d9e4b939108c00ee7b0 /drivers/media/video/cpia2 | |
parent | afa38521614dcdfe12c765ff76d4c137a056e905 (diff) |
[media] cpia2: convert to video_ioctl2
Unable to test this due to lack of hardware.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/cpia2')
-rw-r--r-- | drivers/media/video/cpia2/cpia2_v4l.c | 373 |
1 files changed, 126 insertions, 247 deletions
diff --git a/drivers/media/video/cpia2/cpia2_v4l.c b/drivers/media/video/cpia2/cpia2_v4l.c index 9bad39842936..363fe098b748 100644 --- a/drivers/media/video/cpia2/cpia2_v4l.c +++ b/drivers/media/video/cpia2/cpia2_v4l.c | |||
@@ -395,10 +395,14 @@ static int sync(struct camera_data *cam, int frame_nr) | |||
395 | * | 395 | * |
396 | *****************************************************************************/ | 396 | *****************************************************************************/ |
397 | 397 | ||
398 | static int ioctl_set_gpio(void *arg, struct camera_data *cam) | 398 | static long cpia2_default(struct file *file, void *fh, int cmd, void *arg) |
399 | { | 399 | { |
400 | struct camera_data *cam = video_drvdata(file); | ||
400 | __u32 gpio_val; | 401 | __u32 gpio_val; |
401 | 402 | ||
403 | if (cmd != CPIA2_CID_GPIO) | ||
404 | return -EINVAL; | ||
405 | |||
402 | gpio_val = *(__u32*) arg; | 406 | gpio_val = *(__u32*) arg; |
403 | 407 | ||
404 | if (gpio_val &~ 0xFFU) | 408 | if (gpio_val &~ 0xFFU) |
@@ -415,11 +419,10 @@ static int ioctl_set_gpio(void *arg, struct camera_data *cam) | |||
415 | * | 419 | * |
416 | *****************************************************************************/ | 420 | *****************************************************************************/ |
417 | 421 | ||
418 | static int ioctl_querycap(void *arg, struct camera_data *cam) | 422 | static int cpia2_querycap(struct file *file, void *fh, struct v4l2_capability *vc) |
419 | { | 423 | { |
420 | struct v4l2_capability *vc = arg; | 424 | struct camera_data *cam = video_drvdata(file); |
421 | 425 | ||
422 | memset(vc, 0, sizeof(*vc)); | ||
423 | strcpy(vc->driver, "cpia2"); | 426 | strcpy(vc->driver, "cpia2"); |
424 | 427 | ||
425 | if (cam->params.pnp_id.product == 0x151) | 428 | if (cam->params.pnp_id.product == 0x151) |
@@ -479,22 +482,26 @@ static int ioctl_querycap(void *arg, struct camera_data *cam) | |||
479 | * | 482 | * |
480 | *****************************************************************************/ | 483 | *****************************************************************************/ |
481 | 484 | ||
482 | static int ioctl_input(unsigned int ioclt_nr,void *arg,struct camera_data *cam) | 485 | static int cpia2_enum_input(struct file *file, void *fh, struct v4l2_input *i) |
483 | { | 486 | { |
484 | struct v4l2_input *i = arg; | 487 | if (i->index) |
485 | 488 | return -EINVAL; | |
486 | if(ioclt_nr != VIDIOC_G_INPUT) { | ||
487 | if (i->index != 0) | ||
488 | return -EINVAL; | ||
489 | } | ||
490 | |||
491 | memset(i, 0, sizeof(*i)); | ||
492 | strcpy(i->name, "Camera"); | 489 | strcpy(i->name, "Camera"); |
493 | i->type = V4L2_INPUT_TYPE_CAMERA; | 490 | i->type = V4L2_INPUT_TYPE_CAMERA; |
491 | return 0; | ||
492 | } | ||
494 | 493 | ||
494 | static int cpia2_g_input(struct file *file, void *fh, unsigned int *i) | ||
495 | { | ||
496 | *i = 0; | ||
495 | return 0; | 497 | return 0; |
496 | } | 498 | } |
497 | 499 | ||
500 | static int cpia2_s_input(struct file *file, void *fh, unsigned int i) | ||
501 | { | ||
502 | return i ? -EINVAL : 0; | ||
503 | } | ||
504 | |||
498 | /****************************************************************************** | 505 | /****************************************************************************** |
499 | * | 506 | * |
500 | * ioctl_enum_fmt | 507 | * ioctl_enum_fmt |
@@ -503,9 +510,9 @@ static int ioctl_input(unsigned int ioclt_nr,void *arg,struct camera_data *cam) | |||
503 | * | 510 | * |
504 | *****************************************************************************/ | 511 | *****************************************************************************/ |
505 | 512 | ||
506 | static int ioctl_enum_fmt(void *arg,struct camera_data *cam) | 513 | static int cpia2_enum_fmt_vid_cap(struct file *file, void *fh, |
514 | struct v4l2_fmtdesc *f) | ||
507 | { | 515 | { |
508 | struct v4l2_fmtdesc *f = arg; | ||
509 | int index = f->index; | 516 | int index = f->index; |
510 | 517 | ||
511 | if (index < 0 || index > 1) | 518 | if (index < 0 || index > 1) |
@@ -539,12 +546,10 @@ static int ioctl_enum_fmt(void *arg,struct camera_data *cam) | |||
539 | * | 546 | * |
540 | *****************************************************************************/ | 547 | *****************************************************************************/ |
541 | 548 | ||
542 | static int ioctl_try_fmt(void *arg,struct camera_data *cam) | 549 | static int cpia2_try_fmt_vid_cap(struct file *file, void *fh, |
550 | struct v4l2_format *f) | ||
543 | { | 551 | { |
544 | struct v4l2_format *f = arg; | 552 | struct camera_data *cam = video_drvdata(file); |
545 | |||
546 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
547 | return -EINVAL; | ||
548 | 553 | ||
549 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG && | 554 | if (f->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG && |
550 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) | 555 | f->fmt.pix.pixelformat != V4L2_PIX_FMT_JPEG) |
@@ -603,12 +608,17 @@ static int ioctl_try_fmt(void *arg,struct camera_data *cam) | |||
603 | * | 608 | * |
604 | *****************************************************************************/ | 609 | *****************************************************************************/ |
605 | 610 | ||
606 | static int ioctl_set_fmt(void *arg,struct camera_data *cam, struct cpia2_fh *fh) | 611 | static int cpia2_s_fmt_vid_cap(struct file *file, void *_fh, |
612 | struct v4l2_format *f) | ||
607 | { | 613 | { |
608 | struct v4l2_format *f = arg; | 614 | struct camera_data *cam = video_drvdata(file); |
615 | struct cpia2_fh *fh = _fh; | ||
609 | int err, frame; | 616 | int err, frame; |
610 | 617 | ||
611 | err = ioctl_try_fmt(arg, cam); | 618 | err = v4l2_prio_check(&cam->prio, fh->prio); |
619 | if (err) | ||
620 | return err; | ||
621 | err = cpia2_try_fmt_vid_cap(file, _fh, f); | ||
612 | if(err != 0) | 622 | if(err != 0) |
613 | return err; | 623 | return err; |
614 | 624 | ||
@@ -658,12 +668,10 @@ static int ioctl_set_fmt(void *arg,struct camera_data *cam, struct cpia2_fh *fh) | |||
658 | * | 668 | * |
659 | *****************************************************************************/ | 669 | *****************************************************************************/ |
660 | 670 | ||
661 | static int ioctl_get_fmt(void *arg,struct camera_data *cam) | 671 | static int cpia2_g_fmt_vid_cap(struct file *file, void *fh, |
672 | struct v4l2_format *f) | ||
662 | { | 673 | { |
663 | struct v4l2_format *f = arg; | 674 | struct camera_data *cam = video_drvdata(file); |
664 | |||
665 | if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
666 | return -EINVAL; | ||
667 | 675 | ||
668 | f->fmt.pix.width = cam->width; | 676 | f->fmt.pix.width = cam->width; |
669 | f->fmt.pix.height = cam->height; | 677 | f->fmt.pix.height = cam->height; |
@@ -686,9 +694,9 @@ static int ioctl_get_fmt(void *arg,struct camera_data *cam) | |||
686 | * | 694 | * |
687 | *****************************************************************************/ | 695 | *****************************************************************************/ |
688 | 696 | ||
689 | static int ioctl_cropcap(void *arg,struct camera_data *cam) | 697 | static int cpia2_cropcap(struct file *file, void *fh, struct v4l2_cropcap *c) |
690 | { | 698 | { |
691 | struct v4l2_cropcap *c = arg; | 699 | struct camera_data *cam = video_drvdata(file); |
692 | 700 | ||
693 | if (c->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | 701 | if (c->type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
694 | return -EINVAL; | 702 | return -EINVAL; |
@@ -715,9 +723,9 @@ static int ioctl_cropcap(void *arg,struct camera_data *cam) | |||
715 | * | 723 | * |
716 | *****************************************************************************/ | 724 | *****************************************************************************/ |
717 | 725 | ||
718 | static int ioctl_queryctrl(void *arg,struct camera_data *cam) | 726 | static int cpia2_queryctrl(struct file *file, void *fh, struct v4l2_queryctrl *c) |
719 | { | 727 | { |
720 | struct v4l2_queryctrl *c = arg; | 728 | struct camera_data *cam = video_drvdata(file); |
721 | int i; | 729 | int i; |
722 | 730 | ||
723 | for(i=0; i<NUM_CONTROLS; ++i) { | 731 | for(i=0; i<NUM_CONTROLS; ++i) { |
@@ -783,12 +791,9 @@ static int ioctl_queryctrl(void *arg,struct camera_data *cam) | |||
783 | * | 791 | * |
784 | *****************************************************************************/ | 792 | *****************************************************************************/ |
785 | 793 | ||
786 | static int ioctl_querymenu(void *arg,struct camera_data *cam) | 794 | static int cpia2_querymenu(struct file *file, void *fh, struct v4l2_querymenu *m) |
787 | { | 795 | { |
788 | struct v4l2_querymenu *m = arg; | 796 | struct camera_data *cam = video_drvdata(file); |
789 | |||
790 | memset(m->name, 0, sizeof(m->name)); | ||
791 | m->reserved = 0; | ||
792 | 797 | ||
793 | switch(m->id) { | 798 | switch(m->id) { |
794 | case CPIA2_CID_FLICKER_MODE: | 799 | case CPIA2_CID_FLICKER_MODE: |
@@ -837,9 +842,9 @@ static int ioctl_querymenu(void *arg,struct camera_data *cam) | |||
837 | * | 842 | * |
838 | *****************************************************************************/ | 843 | *****************************************************************************/ |
839 | 844 | ||
840 | static int ioctl_g_ctrl(void *arg,struct camera_data *cam) | 845 | static int cpia2_g_ctrl(struct file *file, void *fh, struct v4l2_control *c) |
841 | { | 846 | { |
842 | struct v4l2_control *c = arg; | 847 | struct camera_data *cam = video_drvdata(file); |
843 | 848 | ||
844 | switch(c->id) { | 849 | switch(c->id) { |
845 | case V4L2_CID_BRIGHTNESS: | 850 | case V4L2_CID_BRIGHTNESS: |
@@ -955,9 +960,9 @@ static int ioctl_g_ctrl(void *arg,struct camera_data *cam) | |||
955 | * | 960 | * |
956 | *****************************************************************************/ | 961 | *****************************************************************************/ |
957 | 962 | ||
958 | static int ioctl_s_ctrl(void *arg,struct camera_data *cam) | 963 | static int cpia2_s_ctrl(struct file *file, void *fh, struct v4l2_control *c) |
959 | { | 964 | { |
960 | struct v4l2_control *c = arg; | 965 | struct camera_data *cam = video_drvdata(file); |
961 | int i; | 966 | int i; |
962 | int retval = 0; | 967 | int retval = 0; |
963 | 968 | ||
@@ -1031,9 +1036,9 @@ static int ioctl_s_ctrl(void *arg,struct camera_data *cam) | |||
1031 | * | 1036 | * |
1032 | *****************************************************************************/ | 1037 | *****************************************************************************/ |
1033 | 1038 | ||
1034 | static int ioctl_g_jpegcomp(void *arg,struct camera_data *cam) | 1039 | static int cpia2_g_jpegcomp(struct file *file, void *fh, struct v4l2_jpegcompression *parms) |
1035 | { | 1040 | { |
1036 | struct v4l2_jpegcompression *parms = arg; | 1041 | struct camera_data *cam = video_drvdata(file); |
1037 | 1042 | ||
1038 | memset(parms, 0, sizeof(*parms)); | 1043 | memset(parms, 0, sizeof(*parms)); |
1039 | 1044 | ||
@@ -1072,9 +1077,9 @@ static int ioctl_g_jpegcomp(void *arg,struct camera_data *cam) | |||
1072 | * | 1077 | * |
1073 | *****************************************************************************/ | 1078 | *****************************************************************************/ |
1074 | 1079 | ||
1075 | static int ioctl_s_jpegcomp(void *arg,struct camera_data *cam) | 1080 | static int cpia2_s_jpegcomp(struct file *file, void *fh, struct v4l2_jpegcompression *parms) |
1076 | { | 1081 | { |
1077 | struct v4l2_jpegcompression *parms = arg; | 1082 | struct camera_data *cam = video_drvdata(file); |
1078 | 1083 | ||
1079 | DBG("S_JPEGCOMP APP_len:%d COM_len:%d\n", | 1084 | DBG("S_JPEGCOMP APP_len:%d COM_len:%d\n", |
1080 | parms->APP_len, parms->COM_len); | 1085 | parms->APP_len, parms->COM_len); |
@@ -1121,9 +1126,9 @@ static int ioctl_s_jpegcomp(void *arg,struct camera_data *cam) | |||
1121 | * | 1126 | * |
1122 | *****************************************************************************/ | 1127 | *****************************************************************************/ |
1123 | 1128 | ||
1124 | static int ioctl_reqbufs(void *arg,struct camera_data *cam) | 1129 | static int cpia2_reqbufs(struct file *file, void *fh, struct v4l2_requestbuffers *req) |
1125 | { | 1130 | { |
1126 | struct v4l2_requestbuffers *req = arg; | 1131 | struct camera_data *cam = video_drvdata(file); |
1127 | 1132 | ||
1128 | if(req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1133 | if(req->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1129 | req->memory != V4L2_MEMORY_MMAP) | 1134 | req->memory != V4L2_MEMORY_MMAP) |
@@ -1144,9 +1149,9 @@ static int ioctl_reqbufs(void *arg,struct camera_data *cam) | |||
1144 | * | 1149 | * |
1145 | *****************************************************************************/ | 1150 | *****************************************************************************/ |
1146 | 1151 | ||
1147 | static int ioctl_querybuf(void *arg,struct camera_data *cam) | 1152 | static int cpia2_querybuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
1148 | { | 1153 | { |
1149 | struct v4l2_buffer *buf = arg; | 1154 | struct camera_data *cam = video_drvdata(file); |
1150 | 1155 | ||
1151 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1156 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1152 | buf->index > cam->num_frames) | 1157 | buf->index > cam->num_frames) |
@@ -1192,9 +1197,9 @@ static int ioctl_querybuf(void *arg,struct camera_data *cam) | |||
1192 | * | 1197 | * |
1193 | *****************************************************************************/ | 1198 | *****************************************************************************/ |
1194 | 1199 | ||
1195 | static int ioctl_qbuf(void *arg,struct camera_data *cam) | 1200 | static int cpia2_qbuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
1196 | { | 1201 | { |
1197 | struct v4l2_buffer *buf = arg; | 1202 | struct camera_data *cam = video_drvdata(file); |
1198 | 1203 | ||
1199 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1204 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
1200 | buf->memory != V4L2_MEMORY_MMAP || | 1205 | buf->memory != V4L2_MEMORY_MMAP || |
@@ -1248,9 +1253,9 @@ static int find_earliest_filled_buffer(struct camera_data *cam) | |||
1248 | * | 1253 | * |
1249 | *****************************************************************************/ | 1254 | *****************************************************************************/ |
1250 | 1255 | ||
1251 | static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file) | 1256 | static int cpia2_dqbuf(struct file *file, void *fh, struct v4l2_buffer *buf) |
1252 | { | 1257 | { |
1253 | struct v4l2_buffer *buf = arg; | 1258 | struct camera_data *cam = video_drvdata(file); |
1254 | int frame; | 1259 | int frame; |
1255 | 1260 | ||
1256 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || | 1261 | if(buf->type != V4L2_BUF_TYPE_VIDEO_CAPTURE || |
@@ -1296,210 +1301,56 @@ static int ioctl_dqbuf(void *arg,struct camera_data *cam, struct file *file) | |||
1296 | return 0; | 1301 | return 0; |
1297 | } | 1302 | } |
1298 | 1303 | ||
1299 | /****************************************************************************** | 1304 | static int cpia2_g_priority(struct file *file, void *_fh, enum v4l2_priority *p) |
1300 | * | ||
1301 | * cpia2_ioctl | ||
1302 | * | ||
1303 | *****************************************************************************/ | ||
1304 | static long cpia2_do_ioctl(struct file *file, unsigned int cmd, void *arg) | ||
1305 | { | 1305 | { |
1306 | struct camera_data *cam = video_drvdata(file); | 1306 | struct cpia2_fh *fh = _fh; |
1307 | long retval = 0; | ||
1308 | |||
1309 | if (!cam) | ||
1310 | return -ENOTTY; | ||
1311 | |||
1312 | if (!cam->present) | ||
1313 | return -ENODEV; | ||
1314 | |||
1315 | /* Priority check */ | ||
1316 | switch (cmd) { | ||
1317 | case VIDIOC_S_FMT: | ||
1318 | { | ||
1319 | struct cpia2_fh *fh = file->private_data; | ||
1320 | retval = v4l2_prio_check(&cam->prio, fh->prio); | ||
1321 | if (retval) | ||
1322 | return retval; | ||
1323 | break; | ||
1324 | } | ||
1325 | default: | ||
1326 | break; | ||
1327 | } | ||
1328 | |||
1329 | switch (cmd) { | ||
1330 | /* CPIA2 extension to Video4Linux API */ | ||
1331 | case CPIA2_IOC_SET_GPIO: | ||
1332 | retval = ioctl_set_gpio(arg, cam); | ||
1333 | break; | ||
1334 | case VIDIOC_QUERYCAP: | ||
1335 | retval = ioctl_querycap(arg,cam); | ||
1336 | break; | ||
1337 | |||
1338 | case VIDIOC_ENUMINPUT: | ||
1339 | case VIDIOC_G_INPUT: | ||
1340 | case VIDIOC_S_INPUT: | ||
1341 | retval = ioctl_input(cmd, arg, cam); | ||
1342 | break; | ||
1343 | |||
1344 | case VIDIOC_ENUM_FMT: | ||
1345 | retval = ioctl_enum_fmt(arg,cam); | ||
1346 | break; | ||
1347 | case VIDIOC_TRY_FMT: | ||
1348 | retval = ioctl_try_fmt(arg,cam); | ||
1349 | break; | ||
1350 | case VIDIOC_G_FMT: | ||
1351 | retval = ioctl_get_fmt(arg,cam); | ||
1352 | break; | ||
1353 | case VIDIOC_S_FMT: | ||
1354 | retval = ioctl_set_fmt(arg,cam,file->private_data); | ||
1355 | break; | ||
1356 | 1307 | ||
1357 | case VIDIOC_CROPCAP: | 1308 | *p = fh->prio; |
1358 | retval = ioctl_cropcap(arg,cam); | 1309 | return 0; |
1359 | break; | 1310 | } |
1360 | case VIDIOC_G_CROP: | ||
1361 | case VIDIOC_S_CROP: | ||
1362 | // TODO: I think cropping can be implemented - SJB | ||
1363 | retval = -EINVAL; | ||
1364 | break; | ||
1365 | |||
1366 | case VIDIOC_QUERYCTRL: | ||
1367 | retval = ioctl_queryctrl(arg,cam); | ||
1368 | break; | ||
1369 | case VIDIOC_QUERYMENU: | ||
1370 | retval = ioctl_querymenu(arg,cam); | ||
1371 | break; | ||
1372 | case VIDIOC_G_CTRL: | ||
1373 | retval = ioctl_g_ctrl(arg,cam); | ||
1374 | break; | ||
1375 | case VIDIOC_S_CTRL: | ||
1376 | retval = ioctl_s_ctrl(arg,cam); | ||
1377 | break; | ||
1378 | |||
1379 | case VIDIOC_G_JPEGCOMP: | ||
1380 | retval = ioctl_g_jpegcomp(arg,cam); | ||
1381 | break; | ||
1382 | case VIDIOC_S_JPEGCOMP: | ||
1383 | retval = ioctl_s_jpegcomp(arg,cam); | ||
1384 | break; | ||
1385 | |||
1386 | case VIDIOC_G_PRIORITY: | ||
1387 | { | ||
1388 | struct cpia2_fh *fh = file->private_data; | ||
1389 | *(enum v4l2_priority*)arg = fh->prio; | ||
1390 | break; | ||
1391 | } | ||
1392 | case VIDIOC_S_PRIORITY: | ||
1393 | { | ||
1394 | struct cpia2_fh *fh = file->private_data; | ||
1395 | enum v4l2_priority prio; | ||
1396 | prio = *(enum v4l2_priority*)arg; | ||
1397 | if(cam->streaming && | ||
1398 | prio != fh->prio && | ||
1399 | fh->prio == V4L2_PRIORITY_RECORD) { | ||
1400 | /* Can't drop record priority while streaming */ | ||
1401 | retval = -EBUSY; | ||
1402 | } else if(prio == V4L2_PRIORITY_RECORD && | ||
1403 | prio != fh->prio && | ||
1404 | v4l2_prio_max(&cam->prio) == V4L2_PRIORITY_RECORD) { | ||
1405 | /* Only one program can record at a time */ | ||
1406 | retval = -EBUSY; | ||
1407 | } else { | ||
1408 | retval = v4l2_prio_change(&cam->prio, &fh->prio, prio); | ||
1409 | } | ||
1410 | break; | ||
1411 | } | ||
1412 | |||
1413 | case VIDIOC_REQBUFS: | ||
1414 | retval = ioctl_reqbufs(arg,cam); | ||
1415 | break; | ||
1416 | case VIDIOC_QUERYBUF: | ||
1417 | retval = ioctl_querybuf(arg,cam); | ||
1418 | break; | ||
1419 | case VIDIOC_QBUF: | ||
1420 | retval = ioctl_qbuf(arg,cam); | ||
1421 | break; | ||
1422 | case VIDIOC_DQBUF: | ||
1423 | retval = ioctl_dqbuf(arg,cam,file); | ||
1424 | break; | ||
1425 | case VIDIOC_STREAMON: | ||
1426 | { | ||
1427 | int type; | ||
1428 | DBG("VIDIOC_STREAMON, streaming=%d\n", cam->streaming); | ||
1429 | type = *(int*)arg; | ||
1430 | if(!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1431 | retval = -EINVAL; | ||
1432 | |||
1433 | if(!cam->streaming) { | ||
1434 | retval = cpia2_usb_stream_start(cam, | ||
1435 | cam->params.camera_state.stream_mode); | ||
1436 | } else { | ||
1437 | retval = -EINVAL; | ||
1438 | } | ||
1439 | |||
1440 | break; | ||
1441 | } | ||
1442 | case VIDIOC_STREAMOFF: | ||
1443 | { | ||
1444 | int type; | ||
1445 | DBG("VIDIOC_STREAMOFF, streaming=%d\n", cam->streaming); | ||
1446 | type = *(int*)arg; | ||
1447 | if(!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1448 | retval = -EINVAL; | ||
1449 | |||
1450 | if(cam->streaming) { | ||
1451 | retval = cpia2_usb_stream_stop(cam); | ||
1452 | } else { | ||
1453 | retval = -EINVAL; | ||
1454 | } | ||
1455 | |||
1456 | break; | ||
1457 | } | ||
1458 | |||
1459 | case VIDIOC_ENUMOUTPUT: | ||
1460 | case VIDIOC_G_OUTPUT: | ||
1461 | case VIDIOC_S_OUTPUT: | ||
1462 | case VIDIOC_G_MODULATOR: | ||
1463 | case VIDIOC_S_MODULATOR: | ||
1464 | |||
1465 | case VIDIOC_ENUMAUDIO: | ||
1466 | case VIDIOC_G_AUDIO: | ||
1467 | case VIDIOC_S_AUDIO: | ||
1468 | 1311 | ||
1469 | case VIDIOC_ENUMAUDOUT: | 1312 | static int cpia2_s_priority(struct file *file, void *_fh, enum v4l2_priority prio) |
1470 | case VIDIOC_G_AUDOUT: | 1313 | { |
1471 | case VIDIOC_S_AUDOUT: | 1314 | struct camera_data *cam = video_drvdata(file); |
1315 | struct cpia2_fh *fh = fh; | ||
1472 | 1316 | ||
1473 | case VIDIOC_ENUMSTD: | 1317 | if (cam->streaming && prio != fh->prio && |
1474 | case VIDIOC_QUERYSTD: | 1318 | fh->prio == V4L2_PRIORITY_RECORD) |
1475 | case VIDIOC_G_STD: | 1319 | /* Can't drop record priority while streaming */ |
1476 | case VIDIOC_S_STD: | 1320 | return -EBUSY; |
1477 | 1321 | ||
1478 | case VIDIOC_G_TUNER: | 1322 | if (prio == V4L2_PRIORITY_RECORD && prio != fh->prio && |
1479 | case VIDIOC_S_TUNER: | 1323 | v4l2_prio_max(&cam->prio) == V4L2_PRIORITY_RECORD) |
1480 | case VIDIOC_G_FREQUENCY: | 1324 | /* Only one program can record at a time */ |
1481 | case VIDIOC_S_FREQUENCY: | 1325 | return -EBUSY; |
1326 | return v4l2_prio_change(&cam->prio, &fh->prio, prio); | ||
1327 | } | ||
1482 | 1328 | ||
1483 | case VIDIOC_OVERLAY: | 1329 | static int cpia2_streamon(struct file *file, void *fh, enum v4l2_buf_type type) |
1484 | case VIDIOC_G_FBUF: | 1330 | { |
1485 | case VIDIOC_S_FBUF: | 1331 | struct camera_data *cam = video_drvdata(file); |
1486 | 1332 | ||
1487 | case VIDIOC_G_PARM: | 1333 | DBG("VIDIOC_STREAMON, streaming=%d\n", cam->streaming); |
1488 | case VIDIOC_S_PARM: | 1334 | if (!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) |
1489 | retval = -EINVAL; | 1335 | return -EINVAL; |
1490 | break; | ||
1491 | default: | ||
1492 | retval = -ENOIOCTLCMD; | ||
1493 | break; | ||
1494 | } | ||
1495 | 1336 | ||
1496 | return retval; | 1337 | if (!cam->streaming) |
1338 | return cpia2_usb_stream_start(cam, | ||
1339 | cam->params.camera_state.stream_mode); | ||
1340 | return -EINVAL; | ||
1497 | } | 1341 | } |
1498 | 1342 | ||
1499 | static long cpia2_ioctl(struct file *file, | 1343 | static int cpia2_streamoff(struct file *file, void *fh, enum v4l2_buf_type type) |
1500 | unsigned int cmd, unsigned long arg) | ||
1501 | { | 1344 | { |
1502 | return video_usercopy(file, cmd, arg, cpia2_do_ioctl); | 1345 | struct camera_data *cam = video_drvdata(file); |
1346 | |||
1347 | DBG("VIDIOC_STREAMOFF, streaming=%d\n", cam->streaming); | ||
1348 | if (!cam->mmapped || type != V4L2_BUF_TYPE_VIDEO_CAPTURE) | ||
1349 | return -EINVAL; | ||
1350 | |||
1351 | if (cam->streaming) | ||
1352 | return cpia2_usb_stream_stop(cam); | ||
1353 | return -EINVAL; | ||
1503 | } | 1354 | } |
1504 | 1355 | ||
1505 | /****************************************************************************** | 1356 | /****************************************************************************** |
@@ -1550,6 +1401,33 @@ static void reset_camera_struct_v4l(struct camera_data *cam) | |||
1550 | v4l2_prio_init(&cam->prio); | 1401 | v4l2_prio_init(&cam->prio); |
1551 | } | 1402 | } |
1552 | 1403 | ||
1404 | static const struct v4l2_ioctl_ops cpia2_ioctl_ops = { | ||
1405 | .vidioc_querycap = cpia2_querycap, | ||
1406 | .vidioc_enum_input = cpia2_enum_input, | ||
1407 | .vidioc_g_input = cpia2_g_input, | ||
1408 | .vidioc_s_input = cpia2_s_input, | ||
1409 | .vidioc_enum_fmt_vid_cap = cpia2_enum_fmt_vid_cap, | ||
1410 | .vidioc_g_fmt_vid_cap = cpia2_g_fmt_vid_cap, | ||
1411 | .vidioc_s_fmt_vid_cap = cpia2_s_fmt_vid_cap, | ||
1412 | .vidioc_try_fmt_vid_cap = cpia2_try_fmt_vid_cap, | ||
1413 | .vidioc_queryctrl = cpia2_queryctrl, | ||
1414 | .vidioc_querymenu = cpia2_querymenu, | ||
1415 | .vidioc_g_ctrl = cpia2_g_ctrl, | ||
1416 | .vidioc_s_ctrl = cpia2_s_ctrl, | ||
1417 | .vidioc_g_jpegcomp = cpia2_g_jpegcomp, | ||
1418 | .vidioc_s_jpegcomp = cpia2_s_jpegcomp, | ||
1419 | .vidioc_cropcap = cpia2_cropcap, | ||
1420 | .vidioc_reqbufs = cpia2_reqbufs, | ||
1421 | .vidioc_querybuf = cpia2_querybuf, | ||
1422 | .vidioc_qbuf = cpia2_qbuf, | ||
1423 | .vidioc_dqbuf = cpia2_dqbuf, | ||
1424 | .vidioc_streamon = cpia2_streamon, | ||
1425 | .vidioc_streamoff = cpia2_streamoff, | ||
1426 | .vidioc_g_priority = cpia2_g_priority, | ||
1427 | .vidioc_s_priority = cpia2_s_priority, | ||
1428 | .vidioc_default = cpia2_default, | ||
1429 | }; | ||
1430 | |||
1553 | /*** | 1431 | /*** |
1554 | * The v4l video device structure initialized for this device | 1432 | * The v4l video device structure initialized for this device |
1555 | ***/ | 1433 | ***/ |
@@ -1559,7 +1437,7 @@ static const struct v4l2_file_operations cpia2_fops = { | |||
1559 | .release = cpia2_close, | 1437 | .release = cpia2_close, |
1560 | .read = cpia2_v4l_read, | 1438 | .read = cpia2_v4l_read, |
1561 | .poll = cpia2_v4l_poll, | 1439 | .poll = cpia2_v4l_poll, |
1562 | .unlocked_ioctl = cpia2_ioctl, | 1440 | .unlocked_ioctl = video_ioctl2, |
1563 | .mmap = cpia2_mmap, | 1441 | .mmap = cpia2_mmap, |
1564 | }; | 1442 | }; |
1565 | 1443 | ||
@@ -1567,6 +1445,7 @@ static struct video_device cpia2_template = { | |||
1567 | /* I could not find any place for the old .initialize initializer?? */ | 1445 | /* I could not find any place for the old .initialize initializer?? */ |
1568 | .name = "CPiA2 Camera", | 1446 | .name = "CPiA2 Camera", |
1569 | .fops = &cpia2_fops, | 1447 | .fops = &cpia2_fops, |
1448 | .ioctl_ops = &cpia2_ioctl_ops, | ||
1570 | .release = video_device_release, | 1449 | .release = video_device_release, |
1571 | }; | 1450 | }; |
1572 | 1451 | ||