Lines Matching refs:fmd

39 static void __setup_sensor_notification(struct fimc_md *fmd,  in __setup_sensor_notification()  argument
48 if (!src_inf || WARN_ON(fmd == NULL)) in __setup_sensor_notification()
52 spin_lock_irqsave(&fmd->slock, flags); in __setup_sensor_notification()
54 spin_unlock_irqrestore(&fmd->slock, flags); in __setup_sensor_notification()
67 struct fimc_md *fmd = entity_to_fimc_mdev(me); in fimc_pipeline_prepare() local
120 __setup_sensor_notification(fmd, sensor, p->subdevs[IDX_FIMC]); in fimc_pipeline_prepare()
194 struct fimc_md *fmd) in __fimc_pipeline_enable() argument
200 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) { in __fimc_pipeline_enable()
201 ret = clk_prepare_enable(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_enable()
210 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) in __fimc_pipeline_enable()
211 clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_enable()
228 struct fimc_md *fmd = entity_to_fimc_mdev(me); in __fimc_pipeline_open() local
248 return __fimc_pipeline_enable(ep, fmd); in __fimc_pipeline_open()
261 struct fimc_md *fmd; in __fimc_pipeline_close() local
271 fmd = entity_to_fimc_mdev(&sd->entity); in __fimc_pipeline_close()
274 if (!IS_ERR(fmd->wbclk[CLK_IDX_WB_B]) && p->subdevs[IDX_IS_ISP]) in __fimc_pipeline_close()
275 clk_disable_unprepare(fmd->wbclk[CLK_IDX_WB_B]); in __fimc_pipeline_close()
296 struct fimc_md *fmd; in __fimc_pipeline_s_stream() local
310 fmd = entity_to_fimc_mdev(&sd->entity); in __fimc_pipeline_s_stream()
312 if (!fmd->user_subdev_api) { in __fimc_pipeline_s_stream()
339 ret = __fimc_pipeline_enable(ep, fmd); in __fimc_pipeline_s_stream()
372 struct fimc_md *fmd) in fimc_md_pipeline_create() argument
380 list_add_tail(&p->list, &fmd->pipelines); in fimc_md_pipeline_create()
386 static void fimc_md_pipelines_free(struct fimc_md *fmd) in fimc_md_pipelines_free() argument
388 while (!list_empty(&fmd->pipelines)) { in fimc_md_pipelines_free()
391 p = list_entry(fmd->pipelines.next, typeof(*p), list); in fimc_md_pipelines_free()
397 static int fimc_md_parse_one_endpoint(struct fimc_md *fmd, in fimc_md_parse_one_endpoint() argument
400 int index = fmd->num_sensors; in fimc_md_parse_one_endpoint()
401 struct fimc_source_info *pd = &fmd->sensor[index].pdata; in fimc_md_parse_one_endpoint()
422 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()
461 if (WARN_ON(index >= ARRAY_SIZE(fmd->sensor))) { in fimc_md_parse_one_endpoint()
466 asd = v4l2_async_nf_add_fwnode_remote(&fmd->subdev_notifier, in fimc_md_parse_one_endpoint()
475 fmd->sensor[index].asd = asd; in fimc_md_parse_one_endpoint()
476 fmd->num_sensors++; in fimc_md_parse_one_endpoint()
482 static int fimc_md_parse_port_node(struct fimc_md *fmd, in fimc_md_parse_port_node() argument
489 ret = fimc_md_parse_one_endpoint(fmd, ep); in fimc_md_parse_port_node()
500 static int fimc_md_register_sensor_entities(struct fimc_md *fmd) in fimc_md_register_sensor_entities() argument
502 struct device_node *parent = fmd->pdev->dev.of_node; in fimc_md_register_sensor_entities()
511 if (!fmd->pmf) in fimc_md_register_sensor_entities()
514 ret = pm_runtime_resume_and_get(fmd->pmf); in fimc_md_register_sensor_entities()
518 fmd->num_sensors = 0; in fimc_md_register_sensor_entities()
531 ret = fimc_md_parse_port_node(fmd, port); in fimc_md_register_sensor_entities()
545 ret = fimc_md_parse_port_node(fmd, node); in fimc_md_register_sensor_entities()
554 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
559 v4l2_async_nf_cleanup(&fmd->subdev_notifier); in fimc_md_register_sensor_entities()
560 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
579 static int register_fimc_lite_entity(struct fimc_md *fmd, in register_fimc_lite_entity() argument
587 fmd->fimc_lite[fimc_lite->index])) in register_fimc_lite_entity()
593 ep = fimc_md_pipeline_create(fmd); in register_fimc_lite_entity()
599 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_lite_entity()
601 fmd->fimc_lite[fimc_lite->index] = fimc_lite; in register_fimc_lite_entity()
603 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.LITE%d\n", in register_fimc_lite_entity()
608 static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) in register_fimc_entity() argument
614 if (WARN_ON(fimc->id >= FIMC_MAX_DEVS || fmd->fimc[fimc->id])) in register_fimc_entity()
620 ep = fimc_md_pipeline_create(fmd); in register_fimc_entity()
626 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_entity()
628 if (!fmd->pmf && fimc->pdev) in register_fimc_entity()
629 fmd->pmf = &fimc->pdev->dev; in register_fimc_entity()
630 fmd->fimc[fimc->id] = fimc; in register_fimc_entity()
631 fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; in register_fimc_entity()
633 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", in register_fimc_entity()
639 static int register_csis_entity(struct fimc_md *fmd, in register_csis_entity() argument
651 if (WARN_ON(fmd->csis[id].sd)) in register_csis_entity()
655 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_csis_entity()
657 fmd->csis[id].sd = sd; in register_csis_entity()
659 v4l2_err(&fmd->v4l2_dev, in register_csis_entity()
664 static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is) in register_fimc_is_entity() argument
671 ep = fimc_md_pipeline_create(fmd); in register_fimc_is_entity()
677 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_is_entity()
679 v4l2_err(&fmd->v4l2_dev, in register_fimc_is_entity()
684 fmd->fimc_is = is; in register_fimc_is_entity()
688 static int fimc_md_register_platform_entity(struct fimc_md *fmd, in fimc_md_register_platform_entity() argument
707 ret = register_fimc_entity(fmd, drvdata); in fimc_md_register_platform_entity()
710 ret = register_fimc_lite_entity(fmd, drvdata); in fimc_md_register_platform_entity()
713 ret = register_csis_entity(fmd, pdev, drvdata); in fimc_md_register_platform_entity()
716 ret = register_fimc_is_entity(fmd, drvdata); in fimc_md_register_platform_entity()
727 dev_info(&fmd->pdev->dev, "deferring %s device registration\n", in fimc_md_register_platform_entity()
730 dev_err(&fmd->pdev->dev, "%s device registration failed (%d)\n", in fimc_md_register_platform_entity()
736 static int fimc_md_register_platform_entities(struct fimc_md *fmd, in fimc_md_register_platform_entities() argument
762 ret = fimc_md_register_platform_entity(fmd, pdev, in fimc_md_register_platform_entities()
774 static void fimc_md_unregister_entities(struct fimc_md *fmd) in fimc_md_unregister_entities() argument
779 struct fimc_dev *dev = fmd->fimc[i]; in fimc_md_unregister_entities()
784 fmd->fimc[i] = NULL; in fimc_md_unregister_entities()
787 struct fimc_lite *dev = fmd->fimc_lite[i]; in fimc_md_unregister_entities()
792 fmd->fimc_lite[i] = NULL; in fimc_md_unregister_entities()
795 if (fmd->csis[i].sd == NULL) in fimc_md_unregister_entities()
797 v4l2_device_unregister_subdev(fmd->csis[i].sd); in fimc_md_unregister_entities()
798 fmd->csis[i].sd = NULL; in fimc_md_unregister_entities()
801 if (fmd->fimc_is) in fimc_md_unregister_entities()
802 v4l2_device_unregister_subdev(&fmd->fimc_is->isp.subdev); in fimc_md_unregister_entities()
804 v4l2_info(&fmd->v4l2_dev, "Unregistered all entities\n"); in fimc_md_unregister_entities()
815 static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, in __fimc_md_create_fimc_sink_links() argument
833 if (!fmd->fimc[i]) in __fimc_md_create_fimc_sink_links()
839 if (!fmd->fimc[i]->variant->has_cam_if) in __fimc_md_create_fimc_sink_links()
844 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_sink_links()
856 v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n", in __fimc_md_create_fimc_sink_links()
861 if (!fmd->fimc_lite[i]) in __fimc_md_create_fimc_sink_links()
864 sink = &fmd->fimc_lite[i]->subdev.entity; in __fimc_md_create_fimc_sink_links()
876 v4l2_info(&fmd->v4l2_dev, "created link [%s] -> [%s]\n", in __fimc_md_create_fimc_sink_links()
883 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) in __fimc_md_create_flite_source_links() argument
889 struct fimc_lite *fimc = fmd->fimc_lite[i]; in __fimc_md_create_flite_source_links()
902 sink = &fmd->fimc_is->isp.subdev.entity; in __fimc_md_create_flite_source_links()
913 static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) in __fimc_md_create_fimc_is_links() argument
915 struct fimc_isp *isp = &fmd->fimc_is->isp; in __fimc_md_create_fimc_is_links()
922 if (fmd->fimc[i] == NULL) in __fimc_md_create_fimc_is_links()
926 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_is_links()
957 static int fimc_md_create_links(struct fimc_md *fmd) in fimc_md_create_links() argument
966 for (i = 0; i < fmd->num_sensors; i++) { in fimc_md_create_links()
967 if (fmd->sensor[i].subdev == NULL) in fimc_md_create_links()
970 sensor = fmd->sensor[i].subdev; in fimc_md_create_links()
983 csis = fmd->csis[pdata->mux_id].sd; in fimc_md_create_links()
996 v4l2_info(&fmd->v4l2_dev, "created link [%s] => [%s]\n", in fimc_md_create_links()
1009 v4l2_err(&fmd->v4l2_dev, "Wrong bus_type: %x\n", in fimc_md_create_links()
1017 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1022 if (fmd->csis[i].sd == NULL) in fimc_md_create_links()
1025 source = &fmd->csis[i].sd->entity; in fimc_md_create_links()
1030 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1037 if (!fmd->fimc[i]) in fimc_md_create_links()
1040 source = &fmd->fimc[i]->vid_cap.subdev.entity; in fimc_md_create_links()
1041 sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; in fimc_md_create_links()
1049 ret = __fimc_md_create_flite_source_links(fmd); in fimc_md_create_links()
1053 if (fmd->use_isp) in fimc_md_create_links()
1054 ret = __fimc_md_create_fimc_is_links(fmd); in fimc_md_create_links()
1062 static void fimc_md_put_clocks(struct fimc_md *fmd) in fimc_md_put_clocks() argument
1067 if (IS_ERR(fmd->camclk[i].clock)) in fimc_md_put_clocks()
1069 clk_put(fmd->camclk[i].clock); in fimc_md_put_clocks()
1070 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1075 if (IS_ERR(fmd->wbclk[i])) in fimc_md_put_clocks()
1077 clk_put(fmd->wbclk[i]); in fimc_md_put_clocks()
1078 fmd->wbclk[i] = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1082 static int fimc_md_get_clocks(struct fimc_md *fmd) in fimc_md_get_clocks() argument
1084 struct device *dev = &fmd->pdev->dev; in fimc_md_get_clocks()
1090 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1101 fmd->camclk[i].clock = clock; in fimc_md_get_clocks()
1104 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1106 if (!fmd->use_isp) in fimc_md_get_clocks()
1112 fmd->wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1118 v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s\n", in fimc_md_get_clocks()
1123 fmd->wbclk[i] = clock; in fimc_md_get_clocks()
1126 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1243 struct fimc_md *fmd = dev_get_drvdata(dev); in subdev_conf_mode_show() local
1245 if (fmd->user_subdev_api) in subdev_conf_mode_show()
1255 struct fimc_md *fmd = dev_get_drvdata(dev); in subdev_conf_mode_store() local
1266 fmd->user_subdev_api = subdev_api; in subdev_conf_mode_store()
1268 if (fmd->fimc[i]) in subdev_conf_mode_store()
1269 fmd->fimc[i]->vid_cap.user_subdev_api = subdev_api; in subdev_conf_mode_store()
1286 if (camclk->fmd->pmf == NULL) in cam_clk_prepare()
1289 return pm_runtime_resume_and_get(camclk->fmd->pmf); in cam_clk_prepare()
1296 if (camclk->fmd->pmf == NULL) in cam_clk_unprepare()
1299 pm_runtime_put_sync(camclk->fmd->pmf); in cam_clk_unprepare()
1307 static void fimc_md_unregister_clk_provider(struct fimc_md *fmd) in fimc_md_unregister_clk_provider() argument
1309 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_unregister_clk_provider()
1319 static int fimc_md_register_clk_provider(struct fimc_md *fmd) in fimc_md_register_clk_provider() argument
1321 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_register_clk_provider()
1322 struct device *dev = &fmd->pdev->dev; in fimc_md_register_clk_provider()
1335 p_name = __clk_get_name(fmd->camclk[i].clock); in fimc_md_register_clk_provider()
1343 camclk->fmd = fmd; in fimc_md_register_clk_provider()
1368 fimc_md_unregister_clk_provider(fmd); in fimc_md_register_clk_provider()
1376 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_bound() local
1381 for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++) in subdev_notifier_bound()
1382 if (fmd->sensor[i].asd == asd) in subdev_notifier_bound()
1383 si = &fmd->sensor[i]; in subdev_notifier_bound()
1397 v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice: %s (%d)\n", in subdev_notifier_bound()
1398 subdev->name, fmd->num_sensors); in subdev_notifier_bound()
1400 fmd->num_sensors++; in subdev_notifier_bound()
1407 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_complete() local
1410 mutex_lock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1412 ret = fimc_md_create_links(fmd); in subdev_notifier_complete()
1416 ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); in subdev_notifier_complete()
1418 mutex_unlock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1422 return media_device_register(&fmd->media_dev); in subdev_notifier_complete()
1435 struct fimc_md *fmd; in fimc_md_probe() local
1438 fmd = devm_kzalloc(dev, sizeof(*fmd), GFP_KERNEL); in fimc_md_probe()
1439 if (!fmd) in fimc_md_probe()
1446 spin_lock_init(&fmd->slock); in fimc_md_probe()
1447 INIT_LIST_HEAD(&fmd->pipelines); in fimc_md_probe()
1448 fmd->pdev = pdev; in fimc_md_probe()
1450 strscpy(fmd->media_dev.model, "Samsung S5P FIMC", in fimc_md_probe()
1451 sizeof(fmd->media_dev.model)); in fimc_md_probe()
1452 fmd->media_dev.ops = &fimc_md_ops; in fimc_md_probe()
1453 fmd->media_dev.dev = dev; in fimc_md_probe()
1455 v4l2_dev = &fmd->v4l2_dev; in fimc_md_probe()
1456 v4l2_dev->mdev = &fmd->media_dev; in fimc_md_probe()
1460 fmd->use_isp = fimc_md_is_isp_available(dev->of_node); in fimc_md_probe()
1461 fmd->user_subdev_api = true; in fimc_md_probe()
1463 media_device_init(&fmd->media_dev); in fimc_md_probe()
1465 ret = v4l2_device_register(dev, &fmd->v4l2_dev); in fimc_md_probe()
1471 ret = fimc_md_get_clocks(fmd); in fimc_md_probe()
1479 platform_set_drvdata(pdev, fmd); in fimc_md_probe()
1481 v4l2_async_nf_init(&fmd->subdev_notifier, &fmd->v4l2_dev); in fimc_md_probe()
1483 ret = fimc_md_register_platform_entities(fmd, dev->of_node); in fimc_md_probe()
1487 ret = fimc_md_register_sensor_entities(fmd); in fimc_md_probe()
1499 ret = fimc_md_register_clk_provider(fmd); in fimc_md_probe()
1505 if (fmd->num_sensors > 0) { in fimc_md_probe()
1506 fmd->subdev_notifier.ops = &subdev_notifier_ops; in fimc_md_probe()
1507 fmd->num_sensors = 0; in fimc_md_probe()
1509 ret = v4l2_async_nf_register(&fmd->subdev_notifier); in fimc_md_probe()
1517 fimc_md_unregister_clk_provider(fmd); in fimc_md_probe()
1521 v4l2_async_nf_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_nf_unregister(&fmd->subdev_notifier); in fimc_md_remove()
1542 v4l2_async_nf_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()