diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2010-12-25 15:40:26 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-12-30 19:29:26 -0500 |
commit | b6a633c18ba83c0c8e96759a31d356bfb77e2b5f (patch) | |
tree | 28e006e9006142d80b512fdd1c4290c43543c45e /drivers/media | |
parent | c85bb69af09988f728aca825c11267c9d06ba32e (diff) |
[media] v4l: soc-camera: switch to .unlocked_ioctl
Use the V4L mutex infrastructure in soc-camera core and drivers and switch to
.unlocked_ioctl.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/video/mx1_camera.c | 7 | ||||
-rw-r--r-- | drivers/media/video/mx2_camera.c | 3 | ||||
-rw-r--r-- | drivers/media/video/mx3_camera.c | 2 | ||||
-rw-r--r-- | drivers/media/video/omap1_camera.c | 4 | ||||
-rw-r--r-- | drivers/media/video/pxa_camera.c | 2 | ||||
-rw-r--r-- | drivers/media/video/sh_mobile_ceu_camera.c | 2 | ||||
-rw-r--r-- | drivers/media/video/soc_camera.c | 47 |
7 files changed, 19 insertions, 48 deletions
diff --git a/drivers/media/video/mx1_camera.c b/drivers/media/video/mx1_camera.c index 5e486a88ad7c..bc0c23a1009c 100644 --- a/drivers/media/video/mx1_camera.c +++ b/drivers/media/video/mx1_camera.c | |||
@@ -382,10 +382,9 @@ static void mx1_camera_init_videobuf(struct videobuf_queue *q, | |||
382 | struct mx1_camera_dev *pcdev = ici->priv; | 382 | struct mx1_camera_dev *pcdev = ici->priv; |
383 | 383 | ||
384 | videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, icd->dev.parent, | 384 | videobuf_queue_dma_contig_init(q, &mx1_videobuf_ops, icd->dev.parent, |
385 | &pcdev->lock, | 385 | &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
386 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 386 | V4L2_FIELD_NONE, |
387 | V4L2_FIELD_NONE, | 387 | sizeof(struct mx1_buffer), icd, &icd->video_lock); |
388 | sizeof(struct mx1_buffer), icd, NULL); | ||
389 | } | 388 | } |
390 | 389 | ||
391 | static int mclk_get_divisor(struct mx1_camera_dev *pcdev) | 390 | static int mclk_get_divisor(struct mx1_camera_dev *pcdev) |
diff --git a/drivers/media/video/mx2_camera.c b/drivers/media/video/mx2_camera.c index 13565cba237d..4eab1c620318 100644 --- a/drivers/media/video/mx2_camera.c +++ b/drivers/media/video/mx2_camera.c | |||
@@ -683,7 +683,8 @@ static void mx2_camera_init_videobuf(struct videobuf_queue *q, | |||
683 | 683 | ||
684 | videobuf_queue_dma_contig_init(q, &mx2_videobuf_ops, pcdev->dev, | 684 | videobuf_queue_dma_contig_init(q, &mx2_videobuf_ops, pcdev->dev, |
685 | &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, | 685 | &pcdev->lock, V4L2_BUF_TYPE_VIDEO_CAPTURE, |
686 | V4L2_FIELD_NONE, sizeof(struct mx2_buffer), icd, NULL); | 686 | V4L2_FIELD_NONE, sizeof(struct mx2_buffer), |
687 | icd, &icd->video_lock); | ||
687 | } | 688 | } |
688 | 689 | ||
689 | #define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \ | 690 | #define MX2_BUS_FLAGS (SOCAM_DATAWIDTH_8 | \ |
diff --git a/drivers/media/video/mx3_camera.c b/drivers/media/video/mx3_camera.c index 330d42e15498..b9cb4a436959 100644 --- a/drivers/media/video/mx3_camera.c +++ b/drivers/media/video/mx3_camera.c | |||
@@ -443,7 +443,7 @@ static void mx3_camera_init_videobuf(struct videobuf_queue *q, | |||
443 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 443 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
444 | V4L2_FIELD_NONE, | 444 | V4L2_FIELD_NONE, |
445 | sizeof(struct mx3_camera_buffer), icd, | 445 | sizeof(struct mx3_camera_buffer), icd, |
446 | NULL); | 446 | &icd->video_lock); |
447 | } | 447 | } |
448 | 448 | ||
449 | /* First part of ipu_csi_init_interface() */ | 449 | /* First part of ipu_csi_init_interface() */ |
diff --git a/drivers/media/video/omap1_camera.c b/drivers/media/video/omap1_camera.c index cbfd07f2d9da..0a2fb2bfdbfb 100644 --- a/drivers/media/video/omap1_camera.c +++ b/drivers/media/video/omap1_camera.c | |||
@@ -1365,12 +1365,12 @@ static void omap1_cam_init_videobuf(struct videobuf_queue *q, | |||
1365 | videobuf_queue_dma_contig_init(q, &omap1_videobuf_ops, | 1365 | videobuf_queue_dma_contig_init(q, &omap1_videobuf_ops, |
1366 | icd->dev.parent, &pcdev->lock, | 1366 | icd->dev.parent, &pcdev->lock, |
1367 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, | 1367 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, |
1368 | sizeof(struct omap1_cam_buf), icd, NULL); | 1368 | sizeof(struct omap1_cam_buf), icd, &icd->video_lock); |
1369 | else | 1369 | else |
1370 | videobuf_queue_sg_init(q, &omap1_videobuf_ops, | 1370 | videobuf_queue_sg_init(q, &omap1_videobuf_ops, |
1371 | icd->dev.parent, &pcdev->lock, | 1371 | icd->dev.parent, &pcdev->lock, |
1372 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, | 1372 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, |
1373 | sizeof(struct omap1_cam_buf), icd, NULL); | 1373 | sizeof(struct omap1_cam_buf), icd, &icd->video_lock); |
1374 | 1374 | ||
1375 | /* use videobuf mode (auto)selected with the module parameter */ | 1375 | /* use videobuf mode (auto)selected with the module parameter */ |
1376 | pcdev->vb_mode = sg_mode ? OMAP1_CAM_DMA_SG : OMAP1_CAM_DMA_CONTIG; | 1376 | pcdev->vb_mode = sg_mode ? OMAP1_CAM_DMA_SG : OMAP1_CAM_DMA_CONTIG; |
diff --git a/drivers/media/video/pxa_camera.c b/drivers/media/video/pxa_camera.c index c143ed0a5270..02686771740d 100644 --- a/drivers/media/video/pxa_camera.c +++ b/drivers/media/video/pxa_camera.c | |||
@@ -852,7 +852,7 @@ static void pxa_camera_init_videobuf(struct videobuf_queue *q, | |||
852 | */ | 852 | */ |
853 | videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock, | 853 | videobuf_queue_sg_init(q, &pxa_videobuf_ops, NULL, &pcdev->lock, |
854 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, | 854 | V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, |
855 | sizeof(struct pxa_buffer), icd, NULL); | 855 | sizeof(struct pxa_buffer), icd, &icd->video_lock); |
856 | } | 856 | } |
857 | 857 | ||
858 | static u32 mclk_get_divisor(struct platform_device *pdev, | 858 | static u32 mclk_get_divisor(struct platform_device *pdev, |
diff --git a/drivers/media/video/sh_mobile_ceu_camera.c b/drivers/media/video/sh_mobile_ceu_camera.c index 2486520582f2..954222bc3458 100644 --- a/drivers/media/video/sh_mobile_ceu_camera.c +++ b/drivers/media/video/sh_mobile_ceu_camera.c | |||
@@ -1786,7 +1786,7 @@ static void sh_mobile_ceu_init_videobuf(struct videobuf_queue *q, | |||
1786 | V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1786 | V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1787 | pcdev->field, | 1787 | pcdev->field, |
1788 | sizeof(struct sh_mobile_ceu_buffer), | 1788 | sizeof(struct sh_mobile_ceu_buffer), |
1789 | icd, NULL); | 1789 | icd, &icd->video_lock); |
1790 | } | 1790 | } |
1791 | 1791 | ||
1792 | static int sh_mobile_ceu_get_ctrl(struct soc_camera_device *icd, | 1792 | static int sh_mobile_ceu_get_ctrl(struct soc_camera_device *icd, |
diff --git a/drivers/media/video/soc_camera.c b/drivers/media/video/soc_camera.c index 052bd6dfa5a7..aba4ce92a86b 100644 --- a/drivers/media/video/soc_camera.c +++ b/drivers/media/video/soc_camera.c | |||
@@ -352,12 +352,6 @@ static int soc_camera_open(struct file *file) | |||
352 | return -EINVAL; | 352 | return -EINVAL; |
353 | } | 353 | } |
354 | 354 | ||
355 | /* | ||
356 | * Protect against icd->ops->remove() until we module_get() both | ||
357 | * drivers. | ||
358 | */ | ||
359 | mutex_lock(&icd->video_lock); | ||
360 | |||
361 | icd->use_count++; | 355 | icd->use_count++; |
362 | 356 | ||
363 | /* Now we really have to activate the camera */ | 357 | /* Now we really have to activate the camera */ |
@@ -412,8 +406,6 @@ static int soc_camera_open(struct file *file) | |||
412 | file->private_data = icd; | 406 | file->private_data = icd; |
413 | dev_dbg(&icd->dev, "camera device open\n"); | 407 | dev_dbg(&icd->dev, "camera device open\n"); |
414 | 408 | ||
415 | mutex_unlock(&icd->video_lock); | ||
416 | |||
417 | return 0; | 409 | return 0; |
418 | 410 | ||
419 | /* | 411 | /* |
@@ -429,7 +421,6 @@ eiciadd: | |||
429 | icl->power(icd->pdev, 0); | 421 | icl->power(icd->pdev, 0); |
430 | epower: | 422 | epower: |
431 | icd->use_count--; | 423 | icd->use_count--; |
432 | mutex_unlock(&icd->video_lock); | ||
433 | module_put(ici->ops->owner); | 424 | module_put(ici->ops->owner); |
434 | 425 | ||
435 | return ret; | 426 | return ret; |
@@ -440,7 +431,6 @@ static int soc_camera_close(struct file *file) | |||
440 | struct soc_camera_device *icd = file->private_data; | 431 | struct soc_camera_device *icd = file->private_data; |
441 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 432 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
442 | 433 | ||
443 | mutex_lock(&icd->video_lock); | ||
444 | icd->use_count--; | 434 | icd->use_count--; |
445 | if (!icd->use_count) { | 435 | if (!icd->use_count) { |
446 | struct soc_camera_link *icl = to_soc_camera_link(icd); | 436 | struct soc_camera_link *icl = to_soc_camera_link(icd); |
@@ -457,8 +447,6 @@ static int soc_camera_close(struct file *file) | |||
457 | if (icd->streamer == file) | 447 | if (icd->streamer == file) |
458 | icd->streamer = NULL; | 448 | icd->streamer = NULL; |
459 | 449 | ||
460 | mutex_unlock(&icd->video_lock); | ||
461 | |||
462 | module_put(ici->ops->owner); | 450 | module_put(ici->ops->owner); |
463 | 451 | ||
464 | dev_dbg(&icd->dev, "camera device close\n"); | 452 | dev_dbg(&icd->dev, "camera device close\n"); |
@@ -517,7 +505,7 @@ static struct v4l2_file_operations soc_camera_fops = { | |||
517 | .owner = THIS_MODULE, | 505 | .owner = THIS_MODULE, |
518 | .open = soc_camera_open, | 506 | .open = soc_camera_open, |
519 | .release = soc_camera_close, | 507 | .release = soc_camera_close, |
520 | .ioctl = video_ioctl2, | 508 | .unlocked_ioctl = video_ioctl2, |
521 | .read = soc_camera_read, | 509 | .read = soc_camera_read, |
522 | .mmap = soc_camera_mmap, | 510 | .mmap = soc_camera_mmap, |
523 | .poll = soc_camera_poll, | 511 | .poll = soc_camera_poll, |
@@ -534,12 +522,9 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, | |||
534 | if (icd->streamer && icd->streamer != file) | 522 | if (icd->streamer && icd->streamer != file) |
535 | return -EBUSY; | 523 | return -EBUSY; |
536 | 524 | ||
537 | mutex_lock(&icd->vb_vidq.vb_lock); | ||
538 | |||
539 | if (icd->vb_vidq.bufs[0]) { | 525 | if (icd->vb_vidq.bufs[0]) { |
540 | dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); | 526 | dev_err(&icd->dev, "S_FMT denied: queue initialised\n"); |
541 | ret = -EBUSY; | 527 | return -EBUSY; |
542 | goto unlock; | ||
543 | } | 528 | } |
544 | 529 | ||
545 | ret = soc_camera_set_fmt(icd, f); | 530 | ret = soc_camera_set_fmt(icd, f); |
@@ -547,9 +532,6 @@ static int soc_camera_s_fmt_vid_cap(struct file *file, void *priv, | |||
547 | if (!ret && !icd->streamer) | 532 | if (!ret && !icd->streamer) |
548 | icd->streamer = file; | 533 | icd->streamer = file; |
549 | 534 | ||
550 | unlock: | ||
551 | mutex_unlock(&icd->vb_vidq.vb_lock); | ||
552 | |||
553 | return ret; | 535 | return ret; |
554 | } | 536 | } |
555 | 537 | ||
@@ -622,15 +604,11 @@ static int soc_camera_streamon(struct file *file, void *priv, | |||
622 | if (icd->streamer != file) | 604 | if (icd->streamer != file) |
623 | return -EBUSY; | 605 | return -EBUSY; |
624 | 606 | ||
625 | mutex_lock(&icd->video_lock); | ||
626 | |||
627 | v4l2_subdev_call(sd, video, s_stream, 1); | 607 | v4l2_subdev_call(sd, video, s_stream, 1); |
628 | 608 | ||
629 | /* This calls buf_queue from host driver's videobuf_queue_ops */ | 609 | /* This calls buf_queue from host driver's videobuf_queue_ops */ |
630 | ret = videobuf_streamon(&icd->vb_vidq); | 610 | ret = videobuf_streamon(&icd->vb_vidq); |
631 | 611 | ||
632 | mutex_unlock(&icd->video_lock); | ||
633 | |||
634 | return ret; | 612 | return ret; |
635 | } | 613 | } |
636 | 614 | ||
@@ -648,8 +626,6 @@ static int soc_camera_streamoff(struct file *file, void *priv, | |||
648 | if (icd->streamer != file) | 626 | if (icd->streamer != file) |
649 | return -EBUSY; | 627 | return -EBUSY; |
650 | 628 | ||
651 | mutex_lock(&icd->video_lock); | ||
652 | |||
653 | /* | 629 | /* |
654 | * This calls buf_release from host driver's videobuf_queue_ops for all | 630 | * This calls buf_release from host driver's videobuf_queue_ops for all |
655 | * remaining buffers. When the last buffer is freed, stop capture | 631 | * remaining buffers. When the last buffer is freed, stop capture |
@@ -658,8 +634,6 @@ static int soc_camera_streamoff(struct file *file, void *priv, | |||
658 | 634 | ||
659 | v4l2_subdev_call(sd, video, s_stream, 0); | 635 | v4l2_subdev_call(sd, video, s_stream, 0); |
660 | 636 | ||
661 | mutex_unlock(&icd->video_lock); | ||
662 | |||
663 | return 0; | 637 | return 0; |
664 | } | 638 | } |
665 | 639 | ||
@@ -748,9 +722,7 @@ static int soc_camera_g_crop(struct file *file, void *fh, | |||
748 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); | 722 | struct soc_camera_host *ici = to_soc_camera_host(icd->dev.parent); |
749 | int ret; | 723 | int ret; |
750 | 724 | ||
751 | mutex_lock(&icd->vb_vidq.vb_lock); | ||
752 | ret = ici->ops->get_crop(icd, a); | 725 | ret = ici->ops->get_crop(icd, a); |
753 | mutex_unlock(&icd->vb_vidq.vb_lock); | ||
754 | 726 | ||
755 | return ret; | 727 | return ret; |
756 | } | 728 | } |
@@ -775,9 +747,6 @@ static int soc_camera_s_crop(struct file *file, void *fh, | |||
775 | dev_dbg(&icd->dev, "S_CROP(%ux%u@%u:%u)\n", | 747 | dev_dbg(&icd->dev, "S_CROP(%ux%u@%u:%u)\n", |
776 | rect->width, rect->height, rect->left, rect->top); | 748 | rect->width, rect->height, rect->left, rect->top); |
777 | 749 | ||
778 | /* Cropping is allowed during a running capture, guard consistency */ | ||
779 | mutex_lock(&icd->vb_vidq.vb_lock); | ||
780 | |||
781 | /* If get_crop fails, we'll let host and / or client drivers decide */ | 750 | /* If get_crop fails, we'll let host and / or client drivers decide */ |
782 | ret = ici->ops->get_crop(icd, ¤t_crop); | 751 | ret = ici->ops->get_crop(icd, ¤t_crop); |
783 | 752 | ||
@@ -795,8 +764,6 @@ static int soc_camera_s_crop(struct file *file, void *fh, | |||
795 | ret = ici->ops->set_crop(icd, a); | 764 | ret = ici->ops->set_crop(icd, a); |
796 | } | 765 | } |
797 | 766 | ||
798 | mutex_unlock(&icd->vb_vidq.vb_lock); | ||
799 | |||
800 | return ret; | 767 | return ret; |
801 | } | 768 | } |
802 | 769 | ||
@@ -998,7 +965,13 @@ static int soc_camera_probe(struct device *dev) | |||
998 | 965 | ||
999 | icd->field = V4L2_FIELD_ANY; | 966 | icd->field = V4L2_FIELD_ANY; |
1000 | 967 | ||
1001 | /* ..._video_start() will create a device node, so we have to protect */ | 968 | icd->vdev->lock = &icd->video_lock; |
969 | |||
970 | /* | ||
971 | * ..._video_start() will create a device node, video_register_device() | ||
972 | * itself is protected against concurrent open() calls, but we also have | ||
973 | * to protect our data. | ||
974 | */ | ||
1002 | mutex_lock(&icd->video_lock); | 975 | mutex_lock(&icd->video_lock); |
1003 | 976 | ||
1004 | ret = soc_camera_video_start(icd); | 977 | ret = soc_camera_video_start(icd); |
@@ -1063,10 +1036,8 @@ static int soc_camera_remove(struct device *dev) | |||
1063 | BUG_ON(!dev->parent); | 1036 | BUG_ON(!dev->parent); |
1064 | 1037 | ||
1065 | if (vdev) { | 1038 | if (vdev) { |
1066 | mutex_lock(&icd->video_lock); | ||
1067 | video_unregister_device(vdev); | 1039 | video_unregister_device(vdev); |
1068 | icd->vdev = NULL; | 1040 | icd->vdev = NULL; |
1069 | mutex_unlock(&icd->video_lock); | ||
1070 | } | 1041 | } |
1071 | 1042 | ||
1072 | if (icl->board_info) { | 1043 | if (icl->board_info) { |