aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-capture.c3
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-core.h2
-rw-r--r--drivers/media/platform/s5p-fimc/fimc-m2m.c40
3 files changed, 17 insertions, 28 deletions
diff --git a/drivers/media/platform/s5p-fimc/fimc-capture.c b/drivers/media/platform/s5p-fimc/fimc-capture.c
index 5d3a70f5c5ca..40923885977a 100644
--- a/drivers/media/platform/s5p-fimc/fimc-capture.c
+++ b/drivers/media/platform/s5p-fimc/fimc-capture.c
@@ -1663,6 +1663,9 @@ static int fimc_capture_subdev_registered(struct v4l2_subdev *sd)
1663 struct fimc_dev *fimc = v4l2_get_subdevdata(sd); 1663 struct fimc_dev *fimc = v4l2_get_subdevdata(sd);
1664 int ret; 1664 int ret;
1665 1665
1666 if (fimc == NULL)
1667 return -ENXIO;
1668
1666 ret = fimc_register_m2m_device(fimc, sd->v4l2_dev); 1669 ret = fimc_register_m2m_device(fimc, sd->v4l2_dev);
1667 if (ret) 1670 if (ret)
1668 return ret; 1671 return ret;
diff --git a/drivers/media/platform/s5p-fimc/fimc-core.h b/drivers/media/platform/s5p-fimc/fimc-core.h
index 30f93f2f2434..d3a3a00321c3 100644
--- a/drivers/media/platform/s5p-fimc/fimc-core.h
+++ b/drivers/media/platform/s5p-fimc/fimc-core.h
@@ -287,7 +287,7 @@ struct fimc_frame {
287 * @refcnt: the reference counter 287 * @refcnt: the reference counter
288 */ 288 */
289struct fimc_m2m_device { 289struct fimc_m2m_device {
290 struct video_device *vfd; 290 struct video_device vfd;
291 struct v4l2_m2m_dev *m2m_dev; 291 struct v4l2_m2m_dev *m2m_dev;
292 struct fimc_ctx *ctx; 292 struct fimc_ctx *ctx;
293 int refcnt; 293 int refcnt;
diff --git a/drivers/media/platform/s5p-fimc/fimc-m2m.c b/drivers/media/platform/s5p-fimc/fimc-m2m.c
index 9237e53cf6df..51fc04c2f27c 100644
--- a/drivers/media/platform/s5p-fimc/fimc-m2m.c
+++ b/drivers/media/platform/s5p-fimc/fimc-m2m.c
@@ -370,7 +370,7 @@ static int fimc_m2m_s_fmt_mplane(struct file *file, void *fh,
370 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type); 370 vq = v4l2_m2m_get_vq(ctx->m2m_ctx, f->type);
371 371
372 if (vb2_is_busy(vq)) { 372 if (vb2_is_busy(vq)) {
373 v4l2_err(fimc->m2m.vfd, "queue (%d) busy\n", f->type); 373 v4l2_err(&fimc->m2m.vfd, "queue (%d) busy\n", f->type);
374 return -EBUSY; 374 return -EBUSY;
375 } 375 }
376 376
@@ -507,7 +507,7 @@ static int fimc_m2m_try_crop(struct fimc_ctx *ctx, struct v4l2_crop *cr)
507 int i; 507 int i;
508 508
509 if (cr->c.top < 0 || cr->c.left < 0) { 509 if (cr->c.top < 0 || cr->c.left < 0) {
510 v4l2_err(fimc->m2m.vfd, 510 v4l2_err(&fimc->m2m.vfd,
511 "doesn't support negative values for top & left\n"); 511 "doesn't support negative values for top & left\n");
512 return -EINVAL; 512 return -EINVAL;
513 } 513 }
@@ -577,7 +577,7 @@ static int fimc_m2m_s_crop(struct file *file, void *fh, const struct v4l2_crop *
577 cr->c.height, ctx->rotation); 577 cr->c.height, ctx->rotation);
578 } 578 }
579 if (ret) { 579 if (ret) {
580 v4l2_err(fimc->m2m.vfd, "Out of scaler range\n"); 580 v4l2_err(&fimc->m2m.vfd, "Out of scaler range\n");
581 return -EINVAL; 581 return -EINVAL;
582 } 582 }
583 } 583 }
@@ -664,7 +664,7 @@ static int fimc_m2m_open(struct file *file)
664 ret = -ENOMEM; 664 ret = -ENOMEM;
665 goto unlock; 665 goto unlock;
666 } 666 }
667 v4l2_fh_init(&ctx->fh, fimc->m2m.vfd); 667 v4l2_fh_init(&ctx->fh, &fimc->m2m.vfd);
668 ctx->fimc_dev = fimc; 668 ctx->fimc_dev = fimc;
669 669
670 /* Default color format */ 670 /* Default color format */
@@ -782,39 +782,27 @@ static struct v4l2_m2m_ops m2m_ops = {
782int fimc_register_m2m_device(struct fimc_dev *fimc, 782int fimc_register_m2m_device(struct fimc_dev *fimc,
783 struct v4l2_device *v4l2_dev) 783 struct v4l2_device *v4l2_dev)
784{ 784{
785 struct video_device *vfd; 785 struct video_device *vfd = &fimc->m2m.vfd;
786 struct platform_device *pdev; 786 int ret;
787 int ret = 0;
788
789 if (!fimc)
790 return -ENODEV;
791 787
792 pdev = fimc->pdev;
793 fimc->v4l2_dev = v4l2_dev; 788 fimc->v4l2_dev = v4l2_dev;
794 789
795 vfd = video_device_alloc(); 790 memset(vfd, 0, sizeof(*vfd));
796 if (!vfd) {
797 v4l2_err(v4l2_dev, "Failed to allocate video device\n");
798 return -ENOMEM;
799 }
800
801 vfd->fops = &fimc_m2m_fops; 791 vfd->fops = &fimc_m2m_fops;
802 vfd->ioctl_ops = &fimc_m2m_ioctl_ops; 792 vfd->ioctl_ops = &fimc_m2m_ioctl_ops;
803 vfd->v4l2_dev = v4l2_dev; 793 vfd->v4l2_dev = v4l2_dev;
804 vfd->minor = -1; 794 vfd->minor = -1;
805 vfd->release = video_device_release; 795 vfd->release = video_device_release_empty;
806 vfd->lock = &fimc->lock; 796 vfd->lock = &fimc->lock;
807 vfd->vfl_dir = VFL_DIR_M2M; 797 vfd->vfl_dir = VFL_DIR_M2M;
808 798
809 snprintf(vfd->name, sizeof(vfd->name), "fimc.%d.m2m", fimc->id); 799 snprintf(vfd->name, sizeof(vfd->name), "fimc.%d.m2m", fimc->id);
810 video_set_drvdata(vfd, fimc); 800 video_set_drvdata(vfd, fimc);
811 801
812 fimc->m2m.vfd = vfd;
813 fimc->m2m.m2m_dev = v4l2_m2m_init(&m2m_ops); 802 fimc->m2m.m2m_dev = v4l2_m2m_init(&m2m_ops);
814 if (IS_ERR(fimc->m2m.m2m_dev)) { 803 if (IS_ERR(fimc->m2m.m2m_dev)) {
815 v4l2_err(v4l2_dev, "failed to initialize v4l2-m2m device\n"); 804 v4l2_err(v4l2_dev, "failed to initialize v4l2-m2m device\n");
816 ret = PTR_ERR(fimc->m2m.m2m_dev); 805 return PTR_ERR(fimc->m2m.m2m_dev);
817 goto err_init;
818 } 806 }
819 807
820 ret = media_entity_init(&vfd->entity, 0, NULL, 0); 808 ret = media_entity_init(&vfd->entity, 0, NULL, 0);
@@ -833,8 +821,6 @@ err_vd:
833 media_entity_cleanup(&vfd->entity); 821 media_entity_cleanup(&vfd->entity);
834err_me: 822err_me:
835 v4l2_m2m_release(fimc->m2m.m2m_dev); 823 v4l2_m2m_release(fimc->m2m.m2m_dev);
836err_init:
837 video_device_release(fimc->m2m.vfd);
838 return ret; 824 return ret;
839} 825}
840 826
@@ -845,9 +831,9 @@ void fimc_unregister_m2m_device(struct fimc_dev *fimc)
845 831
846 if (fimc->m2m.m2m_dev) 832 if (fimc->m2m.m2m_dev)
847 v4l2_m2m_release(fimc->m2m.m2m_dev); 833 v4l2_m2m_release(fimc->m2m.m2m_dev);
848 if (fimc->m2m.vfd) { 834
849 media_entity_cleanup(&fimc->m2m.vfd->entity); 835 if (video_is_registered(&fimc->m2m.vfd)) {
850 /* Can also be called if video device wasn't registered */ 836 video_unregister_device(&fimc->m2m.vfd);
851 video_unregister_device(fimc->m2m.vfd); 837 media_entity_cleanup(&fimc->m2m.vfd.entity);
852 } 838 }
853} 839}