Lines Matching +full:csi +full:- +full:out

1 // SPDX-License-Identifier: GPL-2.0+
4 * Copyright (C) 2016-2019 Bootlin
10 #include <linux/dma-mapping.h>
21 #include <media/v4l2-dev.h>
22 #include <media/v4l2-device.h>
23 #include <media/v4l2-fwnode.h>
24 #include <media/v4l2-ioctl.h>
25 #include <media/v4l2-mediabus.h>
27 #include <media/videobuf2-core.h>
28 #include <media/videobuf2-dma-contig.h>
40 dev_warn_once(link->graph_obj.mdev->dev, in sun4i_csi_video_link_validate()
57 struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi, in sun4i_csi_notify_bound() local
60 csi->src_subdev = subdev; in sun4i_csi_notify_bound()
61 csi->src_pad = media_entity_get_fwnode_pad(&subdev->entity, in sun4i_csi_notify_bound()
62 subdev->fwnode, in sun4i_csi_notify_bound()
64 if (csi->src_pad < 0) { in sun4i_csi_notify_bound()
65 dev_err(csi->dev, "Couldn't find output pad for subdev %s\n", in sun4i_csi_notify_bound()
66 subdev->name); in sun4i_csi_notify_bound()
67 return csi->src_pad; in sun4i_csi_notify_bound()
70 dev_dbg(csi->dev, "Bound %s pad: %d\n", subdev->name, csi->src_pad); in sun4i_csi_notify_bound()
76 struct sun4i_csi *csi = container_of(notifier, struct sun4i_csi, in sun4i_csi_notify_complete() local
78 struct v4l2_subdev *subdev = &csi->subdev; in sun4i_csi_notify_complete()
79 struct video_device *vdev = &csi->vdev; in sun4i_csi_notify_complete()
82 ret = v4l2_device_register_subdev(&csi->v4l, subdev); in sun4i_csi_notify_complete()
86 ret = sun4i_csi_v4l2_register(csi); in sun4i_csi_notify_complete()
90 ret = media_device_register(&csi->mdev); in sun4i_csi_notify_complete()
95 ret = media_create_pad_link(&subdev->entity, CSI_SUBDEV_SOURCE, in sun4i_csi_notify_complete()
96 &vdev->entity, 0, in sun4i_csi_notify_complete()
102 ret = media_create_pad_link(&csi->src_subdev->entity, csi->src_pad, in sun4i_csi_notify_complete()
103 &subdev->entity, CSI_SUBDEV_SINK, in sun4i_csi_notify_complete()
109 ret = v4l2_device_register_subdev_nodes(&csi->v4l); in sun4i_csi_notify_complete()
116 media_device_unregister(&csi->mdev); in sun4i_csi_notify_complete()
126 static int sun4i_csi_notifier_init(struct sun4i_csi *csi) in sun4i_csi_notifier_init() argument
135 v4l2_async_nf_init(&csi->notifier, &csi->v4l); in sun4i_csi_notifier_init()
137 ep = fwnode_graph_get_endpoint_by_id(dev_fwnode(csi->dev), 0, 0, in sun4i_csi_notifier_init()
140 return -EINVAL; in sun4i_csi_notifier_init()
144 goto out; in sun4i_csi_notifier_init()
146 csi->bus = vep.bus.parallel; in sun4i_csi_notifier_init()
148 asd = v4l2_async_nf_add_fwnode_remote(&csi->notifier, ep, in sun4i_csi_notifier_init()
152 goto out; in sun4i_csi_notifier_init()
155 csi->notifier.ops = &sun4i_csi_notify_ops; in sun4i_csi_notifier_init()
157 out: in sun4i_csi_notifier_init()
166 struct sun4i_csi *csi; in sun4i_csi_probe() local
170 csi = devm_kzalloc(&pdev->dev, sizeof(*csi), GFP_KERNEL); in sun4i_csi_probe()
171 if (!csi) in sun4i_csi_probe()
172 return -ENOMEM; in sun4i_csi_probe()
173 platform_set_drvdata(pdev, csi); in sun4i_csi_probe()
174 csi->dev = &pdev->dev; in sun4i_csi_probe()
175 subdev = &csi->subdev; in sun4i_csi_probe()
176 vdev = &csi->vdev; in sun4i_csi_probe()
178 csi->traits = of_device_get_match_data(&pdev->dev); in sun4i_csi_probe()
179 if (!csi->traits) in sun4i_csi_probe()
180 return -EINVAL; in sun4i_csi_probe()
182 csi->mdev.dev = csi->dev; in sun4i_csi_probe()
183 strscpy(csi->mdev.model, "Allwinner Video Capture Device", in sun4i_csi_probe()
184 sizeof(csi->mdev.model)); in sun4i_csi_probe()
185 csi->mdev.hw_revision = 0; in sun4i_csi_probe()
186 media_device_init(&csi->mdev); in sun4i_csi_probe()
187 csi->v4l.mdev = &csi->mdev; in sun4i_csi_probe()
189 csi->regs = devm_platform_ioremap_resource(pdev, 0); in sun4i_csi_probe()
190 if (IS_ERR(csi->regs)) in sun4i_csi_probe()
191 return PTR_ERR(csi->regs); in sun4i_csi_probe()
197 csi->bus_clk = devm_clk_get(&pdev->dev, "bus"); in sun4i_csi_probe()
198 if (IS_ERR(csi->bus_clk)) { in sun4i_csi_probe()
199 dev_err(&pdev->dev, "Couldn't get our bus clock\n"); in sun4i_csi_probe()
200 return PTR_ERR(csi->bus_clk); in sun4i_csi_probe()
203 if (csi->traits->has_isp) { in sun4i_csi_probe()
204 csi->isp_clk = devm_clk_get(&pdev->dev, "isp"); in sun4i_csi_probe()
205 if (IS_ERR(csi->isp_clk)) { in sun4i_csi_probe()
206 dev_err(&pdev->dev, "Couldn't get our ISP clock\n"); in sun4i_csi_probe()
207 return PTR_ERR(csi->isp_clk); in sun4i_csi_probe()
211 csi->ram_clk = devm_clk_get(&pdev->dev, "ram"); in sun4i_csi_probe()
212 if (IS_ERR(csi->ram_clk)) { in sun4i_csi_probe()
213 dev_err(&pdev->dev, "Couldn't get our ram clock\n"); in sun4i_csi_probe()
214 return PTR_ERR(csi->ram_clk); in sun4i_csi_probe()
217 csi->rst = devm_reset_control_get(&pdev->dev, NULL); in sun4i_csi_probe()
218 if (IS_ERR(csi->rst)) { in sun4i_csi_probe()
219 dev_err(&pdev->dev, "Couldn't get our reset line\n"); in sun4i_csi_probe()
220 return PTR_ERR(csi->rst); in sun4i_csi_probe()
225 subdev->internal_ops = &sun4i_csi_subdev_internal_ops; in sun4i_csi_probe()
226 subdev->flags = V4L2_SUBDEV_FL_HAS_DEVNODE | V4L2_SUBDEV_FL_HAS_EVENTS; in sun4i_csi_probe()
227 subdev->entity.function = MEDIA_ENT_F_VID_IF_BRIDGE; in sun4i_csi_probe()
228 subdev->entity.ops = &sun4i_csi_subdev_entity_ops; in sun4i_csi_probe()
229 subdev->owner = THIS_MODULE; in sun4i_csi_probe()
230 snprintf(subdev->name, sizeof(subdev->name), "sun4i-csi-0"); in sun4i_csi_probe()
231 v4l2_set_subdevdata(subdev, csi); in sun4i_csi_probe()
233 csi->subdev_pads[CSI_SUBDEV_SINK].flags = in sun4i_csi_probe()
235 csi->subdev_pads[CSI_SUBDEV_SOURCE].flags = MEDIA_PAD_FL_SOURCE; in sun4i_csi_probe()
236 ret = media_entity_pads_init(&subdev->entity, CSI_SUBDEV_PADS, in sun4i_csi_probe()
237 csi->subdev_pads); in sun4i_csi_probe()
241 csi->vdev_pad.flags = MEDIA_PAD_FL_SINK | MEDIA_PAD_FL_MUST_CONNECT; in sun4i_csi_probe()
242 vdev->entity.ops = &sun4i_csi_video_entity_ops; in sun4i_csi_probe()
243 ret = media_entity_pads_init(&vdev->entity, 1, &csi->vdev_pad); in sun4i_csi_probe()
247 ret = sun4i_csi_dma_register(csi, irq); in sun4i_csi_probe()
251 ret = sun4i_csi_notifier_init(csi); in sun4i_csi_probe()
255 ret = v4l2_async_nf_register(&csi->notifier); in sun4i_csi_probe()
257 dev_err(csi->dev, "Couldn't register our notifier.\n"); in sun4i_csi_probe()
261 pm_runtime_enable(&pdev->dev); in sun4i_csi_probe()
266 media_device_unregister(&csi->mdev); in sun4i_csi_probe()
267 sun4i_csi_dma_unregister(csi); in sun4i_csi_probe()
270 media_device_cleanup(&csi->mdev); in sun4i_csi_probe()
277 struct sun4i_csi *csi = platform_get_drvdata(pdev); in sun4i_csi_remove() local
279 pm_runtime_disable(&pdev->dev); in sun4i_csi_remove()
280 v4l2_async_nf_unregister(&csi->notifier); in sun4i_csi_remove()
281 v4l2_async_nf_cleanup(&csi->notifier); in sun4i_csi_remove()
282 vb2_video_unregister_device(&csi->vdev); in sun4i_csi_remove()
283 media_device_unregister(&csi->mdev); in sun4i_csi_remove()
284 sun4i_csi_dma_unregister(csi); in sun4i_csi_remove()
285 media_device_cleanup(&csi->mdev); in sun4i_csi_remove()
301 { .compatible = "allwinner,sun4i-a10-csi1", .data = &sun4i_a10_csi1_traits },
302 { .compatible = "allwinner,sun7i-a20-csi0", .data = &sun7i_a20_csi0_traits },
309 struct sun4i_csi *csi = dev_get_drvdata(dev); in sun4i_csi_runtime_resume() local
311 reset_control_deassert(csi->rst); in sun4i_csi_runtime_resume()
312 clk_prepare_enable(csi->bus_clk); in sun4i_csi_runtime_resume()
313 clk_prepare_enable(csi->ram_clk); in sun4i_csi_runtime_resume()
314 clk_set_rate(csi->isp_clk, 80000000); in sun4i_csi_runtime_resume()
315 clk_prepare_enable(csi->isp_clk); in sun4i_csi_runtime_resume()
317 writel(1, csi->regs + CSI_EN_REG); in sun4i_csi_runtime_resume()
324 struct sun4i_csi *csi = dev_get_drvdata(dev); in sun4i_csi_runtime_suspend() local
326 clk_disable_unprepare(csi->isp_clk); in sun4i_csi_runtime_suspend()
327 clk_disable_unprepare(csi->ram_clk); in sun4i_csi_runtime_suspend()
328 clk_disable_unprepare(csi->bus_clk); in sun4i_csi_runtime_suspend()
330 reset_control_assert(csi->rst); in sun4i_csi_runtime_suspend()
345 .name = "sun4i-csi",