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_get_sync(fmd->pmf); in fimc_md_register_sensor_entities()
513 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
517 fmd->num_sensors = 0; in fimc_md_register_sensor_entities()
530 ret = fimc_md_parse_port_node(fmd, port); in fimc_md_register_sensor_entities()
544 ret = fimc_md_parse_port_node(fmd, node); in fimc_md_register_sensor_entities()
553 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
558 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_register_sensor_entities()
559 pm_runtime_put(fmd->pmf); in fimc_md_register_sensor_entities()
578 static int register_fimc_lite_entity(struct fimc_md *fmd, in register_fimc_lite_entity() argument
586 fmd->fimc_lite[fimc_lite->index])) in register_fimc_lite_entity()
592 ep = fimc_md_pipeline_create(fmd); in register_fimc_lite_entity()
598 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_lite_entity()
600 fmd->fimc_lite[fimc_lite->index] = fimc_lite; in register_fimc_lite_entity()
602 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.LITE%d\n", in register_fimc_lite_entity()
607 static int register_fimc_entity(struct fimc_md *fmd, struct fimc_dev *fimc) in register_fimc_entity() argument
613 if (WARN_ON(fimc->id >= FIMC_MAX_DEVS || fmd->fimc[fimc->id])) in register_fimc_entity()
619 ep = fimc_md_pipeline_create(fmd); in register_fimc_entity()
625 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_entity()
627 if (!fmd->pmf && fimc->pdev) in register_fimc_entity()
628 fmd->pmf = &fimc->pdev->dev; in register_fimc_entity()
629 fmd->fimc[fimc->id] = fimc; in register_fimc_entity()
630 fimc->vid_cap.user_subdev_api = fmd->user_subdev_api; in register_fimc_entity()
632 v4l2_err(&fmd->v4l2_dev, "Failed to register FIMC.%d (%d)\n", in register_fimc_entity()
638 static int register_csis_entity(struct fimc_md *fmd, in register_csis_entity() argument
650 if (WARN_ON(fmd->csis[id].sd)) in register_csis_entity()
654 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_csis_entity()
656 fmd->csis[id].sd = sd; in register_csis_entity()
658 v4l2_err(&fmd->v4l2_dev, in register_csis_entity()
663 static int register_fimc_is_entity(struct fimc_md *fmd, struct fimc_is *is) in register_fimc_is_entity() argument
670 ep = fimc_md_pipeline_create(fmd); in register_fimc_is_entity()
676 ret = v4l2_device_register_subdev(&fmd->v4l2_dev, sd); in register_fimc_is_entity()
678 v4l2_err(&fmd->v4l2_dev, in register_fimc_is_entity()
683 fmd->fimc_is = is; in register_fimc_is_entity()
687 static int fimc_md_register_platform_entity(struct fimc_md *fmd, in fimc_md_register_platform_entity() argument
706 ret = register_fimc_entity(fmd, drvdata); in fimc_md_register_platform_entity()
709 ret = register_fimc_lite_entity(fmd, drvdata); in fimc_md_register_platform_entity()
712 ret = register_csis_entity(fmd, pdev, drvdata); in fimc_md_register_platform_entity()
715 ret = register_fimc_is_entity(fmd, drvdata); in fimc_md_register_platform_entity()
726 dev_info(&fmd->pdev->dev, "deferring %s device registration\n", in fimc_md_register_platform_entity()
729 dev_err(&fmd->pdev->dev, "%s device registration failed (%d)\n", in fimc_md_register_platform_entity()
735 static int fimc_md_register_platform_entities(struct fimc_md *fmd, in fimc_md_register_platform_entities() argument
761 ret = fimc_md_register_platform_entity(fmd, pdev, in fimc_md_register_platform_entities()
773 static void fimc_md_unregister_entities(struct fimc_md *fmd) in fimc_md_unregister_entities() argument
778 struct fimc_dev *dev = fmd->fimc[i]; in fimc_md_unregister_entities()
783 fmd->fimc[i] = NULL; in fimc_md_unregister_entities()
786 struct fimc_lite *dev = fmd->fimc_lite[i]; in fimc_md_unregister_entities()
791 fmd->fimc_lite[i] = NULL; in fimc_md_unregister_entities()
794 if (fmd->csis[i].sd == NULL) in fimc_md_unregister_entities()
796 v4l2_device_unregister_subdev(fmd->csis[i].sd); in fimc_md_unregister_entities()
797 fmd->csis[i].sd = NULL; in fimc_md_unregister_entities()
800 if (fmd->fimc_is) in fimc_md_unregister_entities()
801 v4l2_device_unregister_subdev(&fmd->fimc_is->isp.subdev); in fimc_md_unregister_entities()
803 v4l2_info(&fmd->v4l2_dev, "Unregistered all entities\n"); in fimc_md_unregister_entities()
814 static int __fimc_md_create_fimc_sink_links(struct fimc_md *fmd, in __fimc_md_create_fimc_sink_links() argument
832 if (!fmd->fimc[i]) in __fimc_md_create_fimc_sink_links()
838 if (!fmd->fimc[i]->variant->has_cam_if) in __fimc_md_create_fimc_sink_links()
843 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_sink_links()
855 v4l2_info(&fmd->v4l2_dev, "created link [%s] %c> [%s]\n", in __fimc_md_create_fimc_sink_links()
860 if (!fmd->fimc_lite[i]) in __fimc_md_create_fimc_sink_links()
863 sink = &fmd->fimc_lite[i]->subdev.entity; in __fimc_md_create_fimc_sink_links()
875 v4l2_info(&fmd->v4l2_dev, "created link [%s] -> [%s]\n", in __fimc_md_create_fimc_sink_links()
882 static int __fimc_md_create_flite_source_links(struct fimc_md *fmd) in __fimc_md_create_flite_source_links() argument
888 struct fimc_lite *fimc = fmd->fimc_lite[i]; in __fimc_md_create_flite_source_links()
901 sink = &fmd->fimc_is->isp.subdev.entity; in __fimc_md_create_flite_source_links()
912 static int __fimc_md_create_fimc_is_links(struct fimc_md *fmd) in __fimc_md_create_fimc_is_links() argument
914 struct fimc_isp *isp = &fmd->fimc_is->isp; in __fimc_md_create_fimc_is_links()
921 if (fmd->fimc[i] == NULL) in __fimc_md_create_fimc_is_links()
925 sink = &fmd->fimc[i]->vid_cap.subdev.entity; in __fimc_md_create_fimc_is_links()
956 static int fimc_md_create_links(struct fimc_md *fmd) in fimc_md_create_links() argument
965 for (i = 0; i < fmd->num_sensors; i++) { in fimc_md_create_links()
966 if (fmd->sensor[i].subdev == NULL) in fimc_md_create_links()
969 sensor = fmd->sensor[i].subdev; in fimc_md_create_links()
982 csis = fmd->csis[pdata->mux_id].sd; in fimc_md_create_links()
995 v4l2_info(&fmd->v4l2_dev, "created link [%s] => [%s]\n", in fimc_md_create_links()
1008 v4l2_err(&fmd->v4l2_dev, "Wrong bus_type: %x\n", in fimc_md_create_links()
1016 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1021 if (fmd->csis[i].sd == NULL) in fimc_md_create_links()
1024 source = &fmd->csis[i].sd->entity; in fimc_md_create_links()
1029 ret = __fimc_md_create_fimc_sink_links(fmd, source, sensor, in fimc_md_create_links()
1036 if (!fmd->fimc[i]) in fimc_md_create_links()
1039 source = &fmd->fimc[i]->vid_cap.subdev.entity; in fimc_md_create_links()
1040 sink = &fmd->fimc[i]->vid_cap.ve.vdev.entity; in fimc_md_create_links()
1048 ret = __fimc_md_create_flite_source_links(fmd); in fimc_md_create_links()
1052 if (fmd->use_isp) in fimc_md_create_links()
1053 ret = __fimc_md_create_fimc_is_links(fmd); in fimc_md_create_links()
1061 static void fimc_md_put_clocks(struct fimc_md *fmd) in fimc_md_put_clocks() argument
1066 if (IS_ERR(fmd->camclk[i].clock)) in fimc_md_put_clocks()
1068 clk_put(fmd->camclk[i].clock); in fimc_md_put_clocks()
1069 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1074 if (IS_ERR(fmd->wbclk[i])) in fimc_md_put_clocks()
1076 clk_put(fmd->wbclk[i]); in fimc_md_put_clocks()
1077 fmd->wbclk[i] = ERR_PTR(-EINVAL); in fimc_md_put_clocks()
1081 static int fimc_md_get_clocks(struct fimc_md *fmd) in fimc_md_get_clocks() argument
1083 struct device *dev = &fmd->pdev->dev; in fimc_md_get_clocks()
1089 fmd->camclk[i].clock = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1100 fmd->camclk[i].clock = clock; in fimc_md_get_clocks()
1103 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1105 if (!fmd->use_isp) in fimc_md_get_clocks()
1111 fmd->wbclk[CLK_IDX_WB_A] = ERR_PTR(-EINVAL); in fimc_md_get_clocks()
1117 v4l2_err(&fmd->v4l2_dev, "Failed to get clock: %s\n", in fimc_md_get_clocks()
1122 fmd->wbclk[i] = clock; in fimc_md_get_clocks()
1125 fimc_md_put_clocks(fmd); in fimc_md_get_clocks()
1242 struct fimc_md *fmd = dev_get_drvdata(dev); in fimc_md_sysfs_show() local
1244 if (fmd->user_subdev_api) in fimc_md_sysfs_show()
1254 struct fimc_md *fmd = dev_get_drvdata(dev); in fimc_md_sysfs_store() local
1265 fmd->user_subdev_api = subdev_api; in fimc_md_sysfs_store()
1267 if (fmd->fimc[i]) in fimc_md_sysfs_store()
1268 fmd->fimc[i]->vid_cap.user_subdev_api = subdev_api; in fimc_md_sysfs_store()
1287 if (camclk->fmd->pmf == NULL) in cam_clk_prepare()
1290 ret = pm_runtime_get_sync(camclk->fmd->pmf); in cam_clk_prepare()
1298 if (camclk->fmd->pmf == NULL) in cam_clk_unprepare()
1301 pm_runtime_put_sync(camclk->fmd->pmf); in cam_clk_unprepare()
1309 static void fimc_md_unregister_clk_provider(struct fimc_md *fmd) in fimc_md_unregister_clk_provider() argument
1311 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_unregister_clk_provider()
1321 static int fimc_md_register_clk_provider(struct fimc_md *fmd) in fimc_md_register_clk_provider() argument
1323 struct cam_clk_provider *cp = &fmd->clk_provider; in fimc_md_register_clk_provider()
1324 struct device *dev = &fmd->pdev->dev; in fimc_md_register_clk_provider()
1337 p_name = __clk_get_name(fmd->camclk[i].clock); in fimc_md_register_clk_provider()
1345 camclk->fmd = fmd; in fimc_md_register_clk_provider()
1370 fimc_md_unregister_clk_provider(fmd); in fimc_md_register_clk_provider()
1378 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_bound() local
1383 for (i = 0; i < ARRAY_SIZE(fmd->sensor); i++) in subdev_notifier_bound()
1384 if (fmd->sensor[i].asd.match.fwnode == in subdev_notifier_bound()
1386 si = &fmd->sensor[i]; in subdev_notifier_bound()
1400 v4l2_info(&fmd->v4l2_dev, "Registered sensor subdevice: %s (%d)\n", in subdev_notifier_bound()
1401 subdev->name, fmd->num_sensors); in subdev_notifier_bound()
1403 fmd->num_sensors++; in subdev_notifier_bound()
1410 struct fimc_md *fmd = notifier_to_fimc_md(notifier); in subdev_notifier_complete() local
1413 mutex_lock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1415 ret = fimc_md_create_links(fmd); in subdev_notifier_complete()
1419 ret = v4l2_device_register_subdev_nodes(&fmd->v4l2_dev); in subdev_notifier_complete()
1421 mutex_unlock(&fmd->media_dev.graph_mutex); in subdev_notifier_complete()
1425 return media_device_register(&fmd->media_dev); in subdev_notifier_complete()
1438 struct fimc_md *fmd; in fimc_md_probe() local
1441 fmd = devm_kzalloc(dev, sizeof(*fmd), GFP_KERNEL); in fimc_md_probe()
1442 if (!fmd) in fimc_md_probe()
1445 spin_lock_init(&fmd->slock); in fimc_md_probe()
1446 INIT_LIST_HEAD(&fmd->pipelines); in fimc_md_probe()
1447 fmd->pdev = pdev; in fimc_md_probe()
1449 strscpy(fmd->media_dev.model, "Samsung S5P FIMC", in fimc_md_probe()
1450 sizeof(fmd->media_dev.model)); in fimc_md_probe()
1451 fmd->media_dev.ops = &fimc_md_ops; in fimc_md_probe()
1452 fmd->media_dev.dev = dev; in fimc_md_probe()
1454 v4l2_dev = &fmd->v4l2_dev; in fimc_md_probe()
1455 v4l2_dev->mdev = &fmd->media_dev; in fimc_md_probe()
1459 fmd->use_isp = fimc_md_is_isp_available(dev->of_node); in fimc_md_probe()
1460 fmd->user_subdev_api = true; in fimc_md_probe()
1462 media_device_init(&fmd->media_dev); in fimc_md_probe()
1464 ret = v4l2_device_register(dev, &fmd->v4l2_dev); in fimc_md_probe()
1470 ret = fimc_md_get_clocks(fmd); in fimc_md_probe()
1482 platform_set_drvdata(pdev, fmd); in fimc_md_probe()
1484 v4l2_async_notifier_init(&fmd->subdev_notifier); in fimc_md_probe()
1486 ret = fimc_md_register_platform_entities(fmd, dev->of_node); in fimc_md_probe()
1490 ret = fimc_md_register_sensor_entities(fmd); in fimc_md_probe()
1502 ret = fimc_md_register_clk_provider(fmd); in fimc_md_probe()
1508 if (fmd->num_sensors > 0) { in fimc_md_probe()
1509 fmd->subdev_notifier.ops = &subdev_notifier_ops; in fimc_md_probe()
1510 fmd->num_sensors = 0; in fimc_md_probe()
1512 ret = v4l2_async_notifier_register(&fmd->v4l2_dev, in fimc_md_probe()
1513 &fmd->subdev_notifier); in fimc_md_probe()
1521 fimc_md_unregister_clk_provider(fmd); in fimc_md_probe()
1525 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_probe()
1527 fimc_md_unregister_entities(fmd); in fimc_md_probe()
1529 fimc_md_put_clocks(fmd); in fimc_md_probe()
1531 v4l2_device_unregister(&fmd->v4l2_dev); in fimc_md_probe()
1533 media_device_cleanup(&fmd->media_dev); in fimc_md_probe()
1539 struct fimc_md *fmd = platform_get_drvdata(pdev); in fimc_md_remove() local
1541 if (!fmd) in fimc_md_remove()
1544 fimc_md_unregister_clk_provider(fmd); in fimc_md_remove()
1545 v4l2_async_notifier_unregister(&fmd->subdev_notifier); in fimc_md_remove()
1546 v4l2_async_notifier_cleanup(&fmd->subdev_notifier); in fimc_md_remove()
1548 v4l2_device_unregister(&fmd->v4l2_dev); in fimc_md_remove()
1550 fimc_md_unregister_entities(fmd); in fimc_md_remove()
1551 fimc_md_pipelines_free(fmd); in fimc_md_remove()
1552 media_device_unregister(&fmd->media_dev); in fimc_md_remove()
1553 media_device_cleanup(&fmd->media_dev); in fimc_md_remove()
1554 fimc_md_put_clocks(fmd); in fimc_md_remove()