• Home
  • Raw
  • Download

Lines Matching refs:fmd

40 static void __setup_sensor_notification(struct fimc_md *fmd,  in __setup_sensor_notification()  argument
49 if (!src_inf || WARN_ON(fmd == NULL)) in __setup_sensor_notification()
53 spin_lock_irqsave(&fmd->slock, flags); in __setup_sensor_notification()
55 spin_unlock_irqrestore(&fmd->slock, flags); in __setup_sensor_notification()
68 struct fimc_md *fmd = entity_to_fimc_mdev(me); in fimc_pipeline_prepare() local
121 __setup_sensor_notification(fmd, sensor, p->subdevs[IDX_FIMC]); in fimc_pipeline_prepare()
195 struct fimc_md *fmd) in __fimc_pipeline_enable() argument
201 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) { in __fimc_pipeline_enable()
202 ret = clk_prepare_enable(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_enable()
211 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) in __fimc_pipeline_enable()
212 clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_enable()
229 struct fimc_md *fmd = entity_to_fimc_mdev(me); in __fimc_pipeline_open() local
249 return __fimc_pipeline_enable(ep, fmd); in __fimc_pipeline_open()
262 struct fimc_md *fmd; in __fimc_pipeline_close() local
272 fmd = entity_to_fimc_mdev(&sd->entity); in __fimc_pipeline_close()
275 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) in __fimc_pipeline_close()
276 clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_close()
297 struct fimc_md *fmd; in __fimc_pipeline_s_stream() local
311 fmd = entity_to_fimc_mdev(&sd->entity); in __fimc_pipeline_s_stream()
313 if (!fmd->user_subdev_api) { in __fimc_pipeline_s_stream()
340 ret = __fimc_pipeline_enable(ep, fmd); in __fimc_pipeline_s_stream()
373 struct fimc_md *fmd) in fimc_md_pipeline_create() argument
381 list_add_tail(&p->list, &fmd->pipelines); in fimc_md_pipeline_create()
387 static void fimc_md_pipelines_free(struct fimc_md *fmd) in fimc_md_pipelines_free() argument
389 while (!list_empty(&fmd->pipelines)) { in fimc_md_pipelines_free()
392 p = list_entry(fmd->pipelines.next, typeof(*p), list); in fimc_md_pipelines_free()
398 static int fimc_md_parse_one_endpoint(struct fimc_md *fmd, in fimc_md_parse_one_endpoint() argument
401 int index = fmd->num_sensors; in fimc_md_parse_one_endpoint()
402 struct fimc_source_info *pd = &fmd->sensor[index].pdata; in fimc_md_parse_one_endpoint()
423 v4l2_info(&fmd->v4l2_dev, "Remote device at %pOF not found\n", in fimc_md_parse_one_endpoint()
441 v4l2_err(&fmd->v4l2_dev, "Wrong port id (%u) at node %pOF\n", in fimc_md_parse_one_endpoint()
460 if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) { in fimc_md_parse_one_endpoint()
465 fmd->sensor[index].asd.match_type = V4L2_ASYNC_MATCH_FWNODE; in fimc_md_parse_one_endpoint()
466 fmd->sensor[index].asd.match.fwnode = of_fwnode_handle(rem); in fimc_md_parse_one_endpoint()
468 ret = v4l2_async_notifier_add_subdev(&fmd->subdev_notifier, in fimc_md_parse_one_endpoint()
469 &fmd->sensor[index].asd); in fimc_md_parse_one_endpoint()
475 fmd->num_sensors++; in fimc_md_parse_one_endpoint()
481 static int fimc_md_parse_port_node(struct fimc_md *fmd, in fimc_md_parse_port_node() argument
488 ret = fimc_md_parse_one_endpoint(fmd, ep); in fimc_md_parse_port_node()
497 static int fimc_md_register_sensor_entities(struct fimc_md *fmd) in fimc_md_register_sensor_entities() argument
499 struct device_node *parent = fmd->pdev->dev.of_node; in fimc_md_register_sensor_entities()
508 if (!fmd->pmf) in fimc_md_register_sensor_entities()
511 ret = pm_runtime_resume_and_get(fmd->pmf); in fimc_md_register_sensor_entities()
515 fmd->num_sensors = 0; in fimc_md_register_sensor_entities()
528 ret = fimc_md_parse_port_node(fmd, port); in fimc_md_register_sensor_entities()
542 ret = fimc_md_parse_port_node(fmd, node); in fimc_md_register_sensor_entities()
551 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
556 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_register_sensor_entities()
557 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
576 static int register_fimc_lite_entity(struct fimc_md *fmd, in register_fimc_lite_entity() argument
584 fmd->fimc_lite[fimc_lite->index])) in register_fimc_lite_entity()
590 ep = fimc_md_pipeline_create(fmd); in register_fimc_lite_entity()
596 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_lite_entity()
598 fmd->fimc_lite[fimc_lite->index] = fimc_lite; in register_fimc_lite_entity()
600 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.LITE%d\n", in register_fimc_lite_entity()
605 static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) in register_fimc_entity() argument
611 if (WARN_ON(fimc->id >= FIMC_MAX_DEVS || fmd->fimc[fimc->id])) in register_fimc_entity()
617 ep = fimc_md_pipeline_create(fmd); in register_fimc_entity()
623 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_entity()
625 if (!fmd->pmf && fimc->pdev) in register_fimc_entity()
626 fmd->pmf = &fimc->pdev->dev; in register_fimc_entity()
627 fmd->fimc[fimc->id] = fimc; in register_fimc_entity()
628 fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; in register_fimc_entity()
630 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", in register_fimc_entity()
636 static int register_csis_entity(struct fimc_md *fmd, in register_csis_entity() argument
648 if (WARN_ON(fmd->csis[id].sd)) in register_csis_entity()
652 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_csis_entity()
654 fmd->csis[id].sd = sd; in register_csis_entity()
656 v4l2_err(&fmd->v4l2_dev, in register_csis_entity()
661 static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is) in register_fimc_is_entity() argument
668 ep = fimc_md_pipeline_create(fmd); in register_fimc_is_entity()
674 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_is_entity()
676 v4l2_err(&fmd->v4l2_dev, in register_fimc_is_entity()
681 fmd->fimc_is = is; in register_fimc_is_entity()
685 static int fimc_md_register_platform_entity(struct fimc_md *fmd, in fimc_md_register_platform_entity() argument
704 ret = register_fimc_entity(fmd, drvdata); in fimc_md_register_platform_entity()
707 ret = register_fimc_lite_entity(fmd, drvdata); in fimc_md_register_platform_entity()
710 ret = register_csis_entity(fmd, pdev, drvdata); in fimc_md_register_platform_entity()
713 ret = register_fimc_is_entity(fmd, drvdata); in fimc_md_register_platform_entity()
724 dev_info(&fmd->pdev->dev, "deferring %s device registration\n", in fimc_md_register_platform_entity()
727 dev_err(&fmd->pdev->dev, "%s device registration failed (%d)\n", in fimc_md_register_platform_entity()
733 static int fimc_md_register_platform_entities(struct fimc_md *fmd, in fimc_md_register_platform_entities() argument
759 ret = fimc_md_register_platform_entity(fmd, pdev, in fimc_md_register_platform_entities()
771 static void fimc_md_unregister_entities(struct fimc_md *fmd) in fimc_md_unregister_entities() argument
776 struct fimc_dev *dev = fmd->fimc[i]; in fimc_md_unregister_entities()
781 fmd->fimc[i] = NULL; in fimc_md_unregister_entities()
784 struct fimc_lite *dev = fmd->fimc_lite[i]; in fimc_md_unregister_entities()
789 fmd->fimc_lite[i] = NULL; in fimc_md_unregister_entities()
792 if (fmd->csis[i].sd == NULL) in fimc_md_unregister_entities()
794 v4l2_device_unregister_subdev(fmd->csis[i].sd); in fimc_md_unregister_entities()
795 fmd->csis[i].sd = NULL; in fimc_md_unregister_entities()
798 if (fmd->fimc_is) in fimc_md_unregister_entities()
799 v4l2_device_unregister_subdev(&fmd->fimc_is->isp.subdev); in fimc_md_unregister_entities()
801 v4l2_info(&fmd->v4l2_dev, "Unregistered all entities\n"); in fimc_md_unregister_entities()
812 static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, in __fimc_md_create_fimc_sink_links() argument
830 if (!fmd->fimc[i]) in __fimc_md_create_fimc_sink_links()
836 if (!fmd->fimc[i]->variant->has_cam_if) in __fimc_md_create_fimc_sink_links()
841 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_sink_links()
853 v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n", in __fimc_md_create_fimc_sink_links()
858 if (!fmd->fimc_lite[i]) in __fimc_md_create_fimc_sink_links()
861 sink = &fmd->fimc_lite[i]->subdev.entity; in __fimc_md_create_fimc_sink_links()
873 v4l2_info(&fmd->v4l2_dev, "created link [%s] -> [%s]\n", in __fimc_md_create_fimc_sink_links()
880 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) in __fimc_md_create_flite_source_links() argument
886 struct fimc_lite *fimc = fmd->fimc_lite[i]; in __fimc_md_create_flite_source_links()
899 sink = &fmd->fimc_is->isp.subdev.entity; in __fimc_md_create_flite_source_links()
910 static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) in __fimc_md_create_fimc_is_links() argument
912 struct fimc_isp *isp = &fmd->fimc_is->isp; in __fimc_md_create_fimc_is_links()
919 if (fmd->fimc[i] == NULL) in __fimc_md_create_fimc_is_links()
923 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_is_links()
954 static int fimc_md_create_links(struct fimc_md *fmd) in fimc_md_create_links() argument
963 for (i = 0; i < fmd->num_sensors; i++) { in fimc_md_create_links()
964 if (fmd->sensor[i].subdev == NULL) in fimc_md_create_links()
967 sensor = fmd->sensor[i].subdev; in fimc_md_create_links()
980 csis = fmd->csis[pdata->mux_id].sd; in fimc_md_create_links()
993 v4l2_info(&fmd->v4l2_dev, "created link [%s] => [%s]\n", in fimc_md_create_links()
1006 v4l2_err(&fmd->v4l2_dev, "Wrong bus_type: %x\n", in fimc_md_create_links()
1014 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1019 if (fmd->csis[i].sd == NULL) in fimc_md_create_links()
1022 source = &fmd->csis[i].sd->entity; in fimc_md_create_links()
1027 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1034 if (!fmd->fimc[i]) in fimc_md_create_links()
1037 source = &fmd->fimc[i]->vid_cap.subdev.entity; in fimc_md_create_links()
1038 sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; in fimc_md_create_links()
1046 ret = __fimc_md_create_flite_source_links(fmd); in fimc_md_create_links()
1050 if (fmd->use_isp) in fimc_md_create_links()
1051 ret = __fimc_md_create_fimc_is_links(fmd); in fimc_md_create_links()
1059 static void fimc_md_put_clocks(struct fimc_md *fmd) in fimc_md_put_clocks() argument
1064 if (IS_ERR(fmd->camclk[i].clock)) in fimc_md_put_clocks()
1066 clk_put(fmd->camclk[i].clock); in fimc_md_put_clocks()
1067 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1072 if (IS_ERR(fmd->wbclk[i])) in fimc_md_put_clocks()
1074 clk_put(fmd->wbclk[i]); in fimc_md_put_clocks()
1075 fmd->wbclk[i] = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1079 static int fimc_md_get_clocks(struct fimc_md *fmd) in fimc_md_get_clocks() argument
1081 struct device *dev = &fmd->pdev->dev; in fimc_md_get_clocks()
1087 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1098 fmd->camclk[i].clock = clock; in fimc_md_get_clocks()
1101 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1103 if (!fmd->use_isp) in fimc_md_get_clocks()
1109 fmd->wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1115 v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s\n", in fimc_md_get_clocks()
1120 fmd->wbclk[i] = clock; in fimc_md_get_clocks()
1123 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1240 struct fimc_md *fmd = dev_get_drvdata(dev); in fimc_md_sysfs_show() local
1242 if (fmd->user_subdev_api) in fimc_md_sysfs_show()
1252 struct fimc_md *fmd = dev_get_drvdata(dev); in fimc_md_sysfs_store() local
1263 fmd->user_subdev_api = subdev_api; in fimc_md_sysfs_store()
1265 if (fmd->fimc[i]) in fimc_md_sysfs_store()
1266 fmd->fimc[i]->vid_cap.user_subdev_api = subdev_api; in fimc_md_sysfs_store()
1284 if (camclk->fmd->pmf == NULL) in cam_clk_prepare()
1287 return pm_runtime_resume_and_get(camclk->fmd->pmf); in cam_clk_prepare()
1294 if (camclk->fmd->pmf == NULL) in cam_clk_unprepare()
1297 pm_runtime_put_sync(camclk->fmd->pmf); in cam_clk_unprepare()
1305 static void fimc_md_unregister_clk_provider(struct fimc_md *fmd) in fimc_md_unregister_clk_provider() argument
1307 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_unregister_clk_provider()
1317 static int fimc_md_register_clk_provider(struct fimc_md *fmd) in fimc_md_register_clk_provider() argument
1319 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_register_clk_provider()
1320 struct device *dev = &fmd->pdev->dev; in fimc_md_register_clk_provider()
1333 p_name = __clk_get_name(fmd->camclk[i].clock); in fimc_md_register_clk_provider()
1341 camclk->fmd = fmd; in fimc_md_register_clk_provider()
1366 fimc_md_unregister_clk_provider(fmd); in fimc_md_register_clk_provider()
1374 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_bound() local
1379 for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++) in subdev_notifier_bound()
1380 if (fmd->sensor[i].asd.match.fwnode == in subdev_notifier_bound()
1382 si = &fmd->sensor[i]; in subdev_notifier_bound()
1396 v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice: %s (%d)\n", in subdev_notifier_bound()
1397 subdev->name, fmd->num_sensors); in subdev_notifier_bound()
1399 fmd->num_sensors++; in subdev_notifier_bound()
1406 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_complete() local
1409 mutex_lock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1411 ret = fimc_md_create_links(fmd); in subdev_notifier_complete()
1415 ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); in subdev_notifier_complete()
1417 mutex_unlock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1421 return media_device_register(&fmd->media_dev); in subdev_notifier_complete()
1434 struct fimc_md *fmd; in fimc_md_probe() local
1437 fmd = devm_kzalloc(dev, sizeof(*fmd), GFP_KERNEL); in fimc_md_probe()
1438 if (!fmd) in fimc_md_probe()
1441 spin_lock_init(&fmd->slock); in fimc_md_probe()
1442 INIT_LIST_HEAD(&fmd->pipelines); in fimc_md_probe()
1443 fmd->pdev = pdev; in fimc_md_probe()
1445 strscpy(fmd->media_dev.model, "Samsung S5P FIMC", in fimc_md_probe()
1446 sizeof(fmd->media_dev.model)); in fimc_md_probe()
1447 fmd->media_dev.ops = &fimc_md_ops; in fimc_md_probe()
1448 fmd->media_dev.dev = dev; in fimc_md_probe()
1450 v4l2_dev = &fmd->v4l2_dev; in fimc_md_probe()
1451 v4l2_dev->mdev = &fmd->media_dev; in fimc_md_probe()
1455 fmd->use_isp = fimc_md_is_isp_available(dev->of_node); in fimc_md_probe()
1456 fmd->user_subdev_api = true; in fimc_md_probe()
1458 media_device_init(&fmd->media_dev); in fimc_md_probe()
1460 ret = v4l2_device_register(dev, &fmd->v4l2_dev); in fimc_md_probe()
1466 ret = fimc_md_get_clocks(fmd); in fimc_md_probe()
1478 platform_set_drvdata(pdev, fmd); in fimc_md_probe()
1480 v4l2_async_notifier_init(&fmd->subdev_notifier); in fimc_md_probe()
1482 ret = fimc_md_register_platform_entities(fmd, dev->of_node); in fimc_md_probe()
1486 ret = fimc_md_register_sensor_entities(fmd); in fimc_md_probe()
1498 ret = fimc_md_register_clk_provider(fmd); in fimc_md_probe()
1504 if (fmd->num_sensors > 0) { in fimc_md_probe()
1505 fmd->subdev_notifier.ops = &subdev_notifier_ops; in fimc_md_probe()
1506 fmd->num_sensors = 0; in fimc_md_probe()
1508 ret = v4l2_async_notifier_register(&fmd->v4l2_dev, in fimc_md_probe()
1509 &fmd->subdev_notifier); in fimc_md_probe()
1517 fimc_md_unregister_clk_provider(fmd); in fimc_md_probe()
1521 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_probe()
1523 fimc_md_unregister_entities(fmd); in fimc_md_probe()
1525 fimc_md_put_clocks(fmd); in fimc_md_probe()
1527 v4l2_device_unregister(&fmd->v4l2_dev); in fimc_md_probe()
1529 media_device_cleanup(&fmd->media_dev); in fimc_md_probe()
1535 struct fimc_md *fmd = platform_get_drvdata(pdev); in fimc_md_remove() local
1537 if (!fmd) in fimc_md_remove()
1540 fimc_md_unregister_clk_provider(fmd); in fimc_md_remove()
1541 v4l2_async_notifier_unregister(&fmd->subdev_notifier); in fimc_md_remove()
1542 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_remove()
1544 v4l2_device_unregister(&fmd->v4l2_dev); in fimc_md_remove()
1546 fimc_md_unregister_entities(fmd); in fimc_md_remove()
1547 fimc_md_pipelines_free(fmd); in fimc_md_remove()
1548 media_device_unregister(&fmd->media_dev); in fimc_md_remove()
1549 media_device_cleanup(&fmd->media_dev); in fimc_md_remove()
1550 fimc_md_put_clocks(fmd); in fimc_md_remove()