diff options
author | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2012-04-20 17:57:25 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-05-20 08:17:11 -0400 |
commit | 693f5c40825e91632478624bf0366e6ebf862a25 (patch) | |
tree | 3c948517fbdbffdde66c2b076a187aa31ca07100 /drivers/media/video/s5p-fimc/fimc-mdevice.c | |
parent | 97d974226575227ebafdf3ab009f0212d8a7e223 (diff) |
[media] s5p-fimc: Use v4l2_subdev internal ops to register video nodes
In order to be able to select only FIMC-LITE support, which is added
with subsequent patches, the regular FIMC support is now contained
only in fimc-core.c, fimc-m2m.c and fimc-capture.c files. The graph
and pipeline management is now solely handled in fimc-mdevice.[ch].
This means the FIMC driver can now be excluded with Kconfig option,
leaving only FIMC-LITE and allowing this driver to be reused in SoCs
that have only FIMC-LITE and no regular FIMC IP.
Signed-off-by: Sylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/s5p-fimc/fimc-mdevice.c')
-rw-r--r-- | drivers/media/video/s5p-fimc/fimc-mdevice.c | 89 |
1 files changed, 34 insertions, 55 deletions
diff --git a/drivers/media/video/s5p-fimc/fimc-mdevice.c b/drivers/media/video/s5p-fimc/fimc-mdevice.c index f97ac02b8677..c319842c762d 100644 --- a/drivers/media/video/s5p-fimc/fimc-mdevice.c +++ b/drivers/media/video/s5p-fimc/fimc-mdevice.c | |||
@@ -304,8 +304,9 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd) | |||
304 | static int fimc_register_callback(struct device *dev, void *p) | 304 | static int fimc_register_callback(struct device *dev, void *p) |
305 | { | 305 | { |
306 | struct fimc_dev *fimc = dev_get_drvdata(dev); | 306 | struct fimc_dev *fimc = dev_get_drvdata(dev); |
307 | struct v4l2_subdev *sd = &fimc->vid_cap.subdev; | ||
307 | struct fimc_md *fmd = p; | 308 | struct fimc_md *fmd = p; |
308 | int ret; | 309 | int ret = 0; |
309 | 310 | ||
310 | if (!fimc || !fimc->pdev) | 311 | if (!fimc || !fimc->pdev) |
311 | return 0; | 312 | return 0; |
@@ -313,12 +314,14 @@ static int fimc_register_callback(struct device *dev, void *p) | |||
313 | return 0; | 314 | return 0; |
314 | 315 | ||
315 | fmd->fimc[fimc->pdev->id] = fimc; | 316 | fmd->fimc[fimc->pdev->id] = fimc; |
316 | ret = fimc_register_m2m_device(fimc, &fmd->v4l2_dev); | 317 | sd->grp_id = FIMC_GROUP_ID; |
317 | if (ret) | 318 | |
318 | return ret; | 319 | ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); |
319 | ret = fimc_register_capture_device(fimc, &fmd->v4l2_dev); | 320 | if (ret) { |
320 | if (!ret) | 321 | v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", |
321 | fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; | 322 | fimc->id, ret); |
323 | } | ||
324 | |||
322 | return ret; | 325 | return ret; |
323 | } | 326 | } |
324 | 327 | ||
@@ -401,8 +404,7 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd) | |||
401 | for (i = 0; i < FIMC_MAX_DEVS; i++) { | 404 | for (i = 0; i < FIMC_MAX_DEVS; i++) { |
402 | if (fmd->fimc[i] == NULL) | 405 | if (fmd->fimc[i] == NULL) |
403 | continue; | 406 | continue; |
404 | fimc_unregister_m2m_device(fmd->fimc[i]); | 407 | v4l2_device_unregister_subdev(&fmd->fimc[i]->vid_cap.subdev); |
405 | fimc_unregister_capture_device(fmd->fimc[i]); | ||
406 | fmd->fimc[i] = NULL; | 408 | fmd->fimc[i] = NULL; |
407 | } | 409 | } |
408 | for (i = 0; i < CSIS_MAX_ENTITIES; i++) { | 410 | for (i = 0; i < CSIS_MAX_ENTITIES; i++) { |
@@ -420,35 +422,6 @@ static void fimc_md_unregister_entities(struct fimc_md *fmd) | |||
420 | } | 422 | } |
421 | } | 423 | } |
422 | 424 | ||
423 | static int fimc_md_register_video_nodes(struct fimc_md *fmd) | ||
424 | { | ||
425 | struct video_device *vdev; | ||
426 | int i, ret = 0; | ||
427 | |||
428 | for (i = 0; i < FIMC_MAX_DEVS && !ret; i++) { | ||
429 | if (!fmd->fimc[i]) | ||
430 | continue; | ||
431 | |||
432 | vdev = fmd->fimc[i]->m2m.vfd; | ||
433 | if (vdev) { | ||
434 | ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); | ||
435 | if (ret) | ||
436 | break; | ||
437 | v4l2_info(&fmd->v4l2_dev, "Registered %s as /dev/%s\n", | ||
438 | vdev->name, video_device_node_name(vdev)); | ||
439 | } | ||
440 | |||
441 | vdev = fmd->fimc[i]->vid_cap.vfd; | ||
442 | if (vdev == NULL) | ||
443 | continue; | ||
444 | ret = video_register_device(vdev, VFL_TYPE_GRABBER, -1); | ||
445 | v4l2_info(&fmd->v4l2_dev, "Registered %s as /dev/%s\n", | ||
446 | vdev->name, video_device_node_name(vdev)); | ||
447 | } | ||
448 | |||
449 | return ret; | ||
450 | } | ||
451 | |||
452 | /** | 425 | /** |
453 | * __fimc_md_create_fimc_links - create links to all FIMC entities | 426 | * __fimc_md_create_fimc_links - create links to all FIMC entities |
454 | * @fmd: fimc media device | 427 | * @fmd: fimc media device |
@@ -479,7 +452,7 @@ static int __fimc_md_create_fimc_links(struct fimc_md *fmd, | |||
479 | continue; | 452 | continue; |
480 | 453 | ||
481 | flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; | 454 | flags = (i == fimc_id) ? MEDIA_LNK_FL_ENABLED : 0; |
482 | sink = &fmd->fimc[i]->vid_cap.subdev->entity; | 455 | sink = &fmd->fimc[i]->vid_cap.subdev.entity; |
483 | ret = media_entity_create_link(source, pad, sink, | 456 | ret = media_entity_create_link(source, pad, sink, |
484 | FIMC_SD_PAD_SINK, flags); | 457 | FIMC_SD_PAD_SINK, flags); |
485 | if (ret) | 458 | if (ret) |
@@ -588,7 +561,7 @@ static int fimc_md_create_links(struct fimc_md *fmd) | |||
588 | for (i = 0; i < FIMC_MAX_DEVS; i++) { | 561 | for (i = 0; i < FIMC_MAX_DEVS; i++) { |
589 | if (!fmd->fimc[i]) | 562 | if (!fmd->fimc[i]) |
590 | continue; | 563 | continue; |
591 | source = &fmd->fimc[i]->vid_cap.subdev->entity; | 564 | source = &fmd->fimc[i]->vid_cap.subdev.entity; |
592 | sink = &fmd->fimc[i]->vid_cap.vfd->entity; | 565 | sink = &fmd->fimc[i]->vid_cap.vfd->entity; |
593 | ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE, | 566 | ret = media_entity_create_link(source, FIMC_SD_PAD_SOURCE, |
594 | sink, 0, flags); | 567 | sink, 0, flags); |
@@ -817,42 +790,48 @@ static int fimc_md_probe(struct platform_device *pdev) | |||
817 | ret = media_device_register(&fmd->media_dev); | 790 | ret = media_device_register(&fmd->media_dev); |
818 | if (ret < 0) { | 791 | if (ret < 0) { |
819 | v4l2_err(v4l2_dev, "Failed to register media device: %d\n", ret); | 792 | v4l2_err(v4l2_dev, "Failed to register media device: %d\n", ret); |
820 | goto err2; | 793 | goto err_md; |
821 | } | 794 | } |
822 | ret = fimc_md_get_clocks(fmd); | 795 | ret = fimc_md_get_clocks(fmd); |
823 | if (ret) | 796 | if (ret) |
824 | goto err3; | 797 | goto err_clk; |
825 | 798 | ||
826 | fmd->user_subdev_api = false; | 799 | fmd->user_subdev_api = false; |
800 | |||
801 | /* Protect the media graph while we're registering entities */ | ||
802 | mutex_lock(&fmd->media_dev.graph_mutex); | ||
803 | |||
827 | ret = fimc_md_register_platform_entities(fmd); | 804 | ret = fimc_md_register_platform_entities(fmd); |
828 | if (ret) | 805 | if (ret) |
829 | goto err3; | 806 | goto err_unlock; |
830 | 807 | ||
831 | if (pdev->dev.platform_data) { | 808 | if (pdev->dev.platform_data) { |
832 | ret = fimc_md_register_sensor_entities(fmd); | 809 | ret = fimc_md_register_sensor_entities(fmd); |
833 | if (ret) | 810 | if (ret) |
834 | goto err3; | 811 | goto err_unlock; |
835 | } | 812 | } |
836 | ret = fimc_md_create_links(fmd); | 813 | ret = fimc_md_create_links(fmd); |
837 | if (ret) | 814 | if (ret) |
838 | goto err3; | 815 | goto err_unlock; |
839 | ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); | 816 | ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); |
840 | if (ret) | 817 | if (ret) |
841 | goto err3; | 818 | goto err_unlock; |
842 | ret = fimc_md_register_video_nodes(fmd); | ||
843 | if (ret) | ||
844 | goto err3; | ||
845 | 819 | ||
846 | ret = device_create_file(&pdev->dev, &dev_attr_subdev_conf_mode); | 820 | ret = device_create_file(&pdev->dev, &dev_attr_subdev_conf_mode); |
847 | if (!ret) { | 821 | if (ret) |
848 | platform_set_drvdata(pdev, fmd); | 822 | goto err_unlock; |
849 | return 0; | 823 | |
850 | } | 824 | platform_set_drvdata(pdev, fmd); |
851 | err3: | 825 | mutex_unlock(&fmd->media_dev.graph_mutex); |
826 | return 0; | ||
827 | |||
828 | err_unlock: | ||
829 | mutex_unlock(&fmd->media_dev.graph_mutex); | ||
830 | err_clk: | ||
852 | media_device_unregister(&fmd->media_dev); | 831 | media_device_unregister(&fmd->media_dev); |
853 | fimc_md_put_clocks(fmd); | 832 | fimc_md_put_clocks(fmd); |
854 | fimc_md_unregister_entities(fmd); | 833 | fimc_md_unregister_entities(fmd); |
855 | err2: | 834 | err_md: |
856 | v4l2_device_unregister(&fmd->v4l2_dev); | 835 | v4l2_device_unregister(&fmd->v4l2_dev); |
857 | return ret; | 836 | return ret; |
858 | } | 837 | } |