Commit 96a85742 authored by Sylwester Nawrocki's avatar Sylwester Nawrocki Committed by Mauro Carvalho Chehab

[media] s5p-fimc: Remove registration of video nodes from probe()

Do not register video nodes during FIMC device probe. Also make
fimc_register_m2m_device() public for use by the media device driver.
The video nodes are to be registered during the media device driver
initialization, altogether with the subdev devnodes. The video
capture nodes need to be registered as last ones when the remaining
pipeline elements are already initialized.
Signed-off-by: default avatarSylwester Nawrocki <s.nawrocki@samsung.com>
Signed-off-by: default avatarKyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 574e1717
...@@ -905,19 +905,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc) ...@@ -905,19 +905,8 @@ int fimc_register_capture_device(struct fimc_dev *fimc)
if (ret) if (ret)
goto err_ent; goto err_ent;
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(v4l2_dev, "Failed to register video device\n");
goto err_vd_reg;
}
v4l2_info(v4l2_dev,
"FIMC capture driver registered as /dev/video%d\n",
vfd->num);
return 0; return 0;
err_vd_reg:
media_entity_cleanup(&vfd->entity);
err_ent: err_ent:
video_device_release(vfd); video_device_release(vfd);
err_v4l2_reg: err_v4l2_reg:
...@@ -934,7 +923,10 @@ void fimc_unregister_capture_device(struct fimc_dev *fimc) ...@@ -934,7 +923,10 @@ void fimc_unregister_capture_device(struct fimc_dev *fimc)
if (vfd) { if (vfd) {
media_entity_cleanup(&vfd->entity); media_entity_cleanup(&vfd->entity);
/* Can also be called if video device was
not registered */
video_unregister_device(vfd); video_unregister_device(vfd);
} }
kfree(fimc->vid_cap.ctx); kfree(fimc->vid_cap.ctx);
fimc->vid_cap.ctx = NULL;
} }
...@@ -1494,7 +1494,7 @@ static struct v4l2_m2m_ops m2m_ops = { ...@@ -1494,7 +1494,7 @@ static struct v4l2_m2m_ops m2m_ops = {
.job_abort = fimc_job_abort, .job_abort = fimc_job_abort,
}; };
static int fimc_register_m2m_device(struct fimc_dev *fimc) int fimc_register_m2m_device(struct fimc_dev *fimc)
{ {
struct video_device *vfd; struct video_device *vfd;
struct platform_device *pdev; struct platform_device *pdev;
...@@ -1541,22 +1541,9 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1541,22 +1541,9 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
} }
ret = media_entity_init(&vfd->entity, 0, NULL, 0); ret = media_entity_init(&vfd->entity, 0, NULL, 0);
if (ret) if (!ret)
goto err_m2m_r3; return 0;
ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1);
if (ret) {
v4l2_err(v4l2_dev,
"%s(): failed to register video device\n", __func__);
goto err_m2m_r4;
}
v4l2_info(v4l2_dev,
"FIMC m2m driver registered as /dev/video%d\n", vfd->num);
return 0;
err_m2m_r4:
media_entity_cleanup(&vfd->entity);
err_m2m_r3:
v4l2_m2m_release(fimc->m2m.m2m_dev); v4l2_m2m_release(fimc->m2m.m2m_dev);
err_m2m_r2: err_m2m_r2:
video_device_release(fimc->m2m.vfd); video_device_release(fimc->m2m.vfd);
...@@ -1566,15 +1553,19 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc) ...@@ -1566,15 +1553,19 @@ static int fimc_register_m2m_device(struct fimc_dev *fimc)
return ret; return ret;
} }
static void fimc_unregister_m2m_device(struct fimc_dev *fimc) void fimc_unregister_m2m_device(struct fimc_dev *fimc)
{ {
if (fimc == NULL) if (!fimc)
return; return;
v4l2_m2m_release(fimc->m2m.m2m_dev); if (fimc->m2m.m2m_dev)
v4l2_m2m_release(fimc->m2m.m2m_dev);
v4l2_device_unregister(&fimc->m2m.v4l2_dev); v4l2_device_unregister(&fimc->m2m.v4l2_dev);
media_entity_cleanup(&fimc->m2m.vfd->entity); if (fimc->m2m.vfd) {
video_unregister_device(fimc->m2m.vfd); media_entity_cleanup(&fimc->m2m.vfd->entity);
/* Can also be called if video device wasn't registered */
video_unregister_device(fimc->m2m.vfd);
}
} }
static void fimc_clk_put(struct fimc_dev *fimc) static void fimc_clk_put(struct fimc_dev *fimc)
...@@ -1739,27 +1730,11 @@ static int fimc_probe(struct platform_device *pdev) ...@@ -1739,27 +1730,11 @@ static int fimc_probe(struct platform_device *pdev)
goto err_pm; goto err_pm;
} }
ret = fimc_register_m2m_device(fimc); dev_dbg(&pdev->dev, "FIMC.%d registered successfully\n", fimc->id);
if (ret)
goto err_alloc;
/* At least one camera sensor is required to register capture node */
if (cap_input_index >= 0) {
ret = fimc_register_capture_device(fimc);
if (ret)
goto err_m2m;
}
dev_dbg(&pdev->dev, "%s(): fimc-%d registered successfully\n",
__func__, fimc->id);
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
return 0; return 0;
err_m2m:
fimc_unregister_m2m_device(fimc);
err_alloc:
vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
err_pm: err_pm:
pm_runtime_put(&pdev->dev); pm_runtime_put(&pdev->dev);
err_irq: err_irq:
...@@ -1773,7 +1748,6 @@ static int fimc_probe(struct platform_device *pdev) ...@@ -1773,7 +1748,6 @@ static int fimc_probe(struct platform_device *pdev)
kfree(fimc->regs_res); kfree(fimc->regs_res);
err_info: err_info:
kfree(fimc); kfree(fimc);
return ret; return ret;
} }
...@@ -1862,9 +1836,6 @@ static int __devexit fimc_remove(struct platform_device *pdev) ...@@ -1862,9 +1836,6 @@ static int __devexit fimc_remove(struct platform_device *pdev)
fimc_runtime_suspend(&pdev->dev); fimc_runtime_suspend(&pdev->dev);
pm_runtime_set_suspended(&pdev->dev); pm_runtime_set_suspended(&pdev->dev);
fimc_unregister_m2m_device(fimc);
fimc_unregister_capture_device(fimc);
vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx); vb2_dma_contig_cleanup_ctx(fimc->alloc_ctx);
clk_disable(fimc->clock[CLK_BUS]); clk_disable(fimc->clock[CLK_BUS]);
......
...@@ -644,6 +644,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx); ...@@ -644,6 +644,7 @@ int fimc_set_scaler_info(struct fimc_ctx *ctx);
int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags); int fimc_prepare_config(struct fimc_ctx *ctx, u32 flags);
int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb, int fimc_prepare_addr(struct fimc_ctx *ctx, struct vb2_buffer *vb,
struct fimc_frame *frame, struct fimc_addr *paddr); struct fimc_frame *frame, struct fimc_addr *paddr);
int fimc_register_m2m_device(struct fimc_dev *fimc);
/* -----------------------------------------------------*/ /* -----------------------------------------------------*/
/* fimc-capture.c */ /* fimc-capture.c */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment