Lines Matching +full:mt8173 +full:- +full:mmsys

1 // SPDX-License-Identifier: GPL-2.0-only
13 #include <linux/dma-mapping.h>
51 if (info->num_planes != 1) in mtk_drm_mode_fb_create()
52 return ERR_PTR(-EINVAL); in mtk_drm_mode_fb_create()
327 .min_width = 2, /* 2-pixel align when ethdr is bypassed */
332 { .compatible = "mediatek,mt2701-mmsys",
334 { .compatible = "mediatek,mt7623-mmsys",
336 { .compatible = "mediatek,mt2712-mmsys",
338 { .compatible = "mediatek,mt8167-mmsys",
340 { .compatible = "mediatek,mt8173-mmsys",
342 { .compatible = "mediatek,mt8183-mmsys",
344 { .compatible = "mediatek,mt8186-mmsys",
346 { .compatible = "mediatek,mt8188-vdosys0",
348 { .compatible = "mediatek,mt8188-vdosys1",
350 { .compatible = "mediatek,mt8192-mmsys",
352 { .compatible = "mediatek,mt8195-mmsys",
354 { .compatible = "mediatek,mt8195-vdosys0",
356 { .compatible = "mediatek,mt8195-vdosys1",
364 if (!strncmp(dev_name(dev), "mediatek-drm", sizeof("mediatek-drm") - 1)) in mtk_drm_match()
374 struct device_node *phandle = dev->parent->of_node; in mtk_drm_get_all_drm_priv()
381 for_each_child_of_node(phandle->parent, node) { in mtk_drm_get_all_drm_priv()
392 drm_dev = device_find_child(&pdev->dev, NULL, mtk_drm_match); in mtk_drm_get_all_drm_priv()
400 if (temp_drm_priv->data->main_len) in mtk_drm_get_all_drm_priv()
402 else if (temp_drm_priv->data->ext_len) in mtk_drm_get_all_drm_priv()
404 else if (temp_drm_priv->data->third_len) in mtk_drm_get_all_drm_priv()
407 if (temp_drm_priv->mtk_drm_bound) in mtk_drm_get_all_drm_priv()
416 if (drm_priv->data->mmsys_dev_num == cnt) { in mtk_drm_get_all_drm_priv()
419 all_drm_priv[j]->all_drm_private[i] = all_drm_priv[i]; in mtk_drm_get_all_drm_priv()
429 const struct mtk_mmsys_driver_data *drv_data = private->data; in mtk_drm_find_mmsys_comp()
432 if (drv_data->main_path) in mtk_drm_find_mmsys_comp()
433 for (i = 0; i < drv_data->main_len; i++) in mtk_drm_find_mmsys_comp()
434 if (drv_data->main_path[i] == comp_id) in mtk_drm_find_mmsys_comp()
437 if (drv_data->ext_path) in mtk_drm_find_mmsys_comp()
438 for (i = 0; i < drv_data->ext_len; i++) in mtk_drm_find_mmsys_comp()
439 if (drv_data->ext_path[i] == comp_id) in mtk_drm_find_mmsys_comp()
442 if (drv_data->third_path) in mtk_drm_find_mmsys_comp()
443 for (i = 0; i < drv_data->third_len; i++) in mtk_drm_find_mmsys_comp()
444 if (drv_data->third_path[i] == comp_id) in mtk_drm_find_mmsys_comp()
447 if (drv_data->num_conn_routes) in mtk_drm_find_mmsys_comp()
448 for (i = 0; i < drv_data->num_conn_routes; i++) in mtk_drm_find_mmsys_comp()
449 if (drv_data->conn_routes[i].route_ddp == comp_id) in mtk_drm_find_mmsys_comp()
457 struct mtk_drm_private *private = drm->dev_private; in mtk_drm_kms_init()
464 return -ENODEV; in mtk_drm_kms_init()
470 drm->mode_config.min_width = 64; in mtk_drm_kms_init()
471 drm->mode_config.min_height = 64; in mtk_drm_kms_init()
478 drm->mode_config.max_width = 4096; in mtk_drm_kms_init()
479 drm->mode_config.max_height = 4096; in mtk_drm_kms_init()
480 drm->mode_config.funcs = &mtk_drm_mode_config_funcs; in mtk_drm_kms_init()
481 drm->mode_config.helper_private = &mtk_drm_mode_config_helpers; in mtk_drm_kms_init()
483 for (i = 0; i < private->data->mmsys_dev_num; i++) { in mtk_drm_kms_init()
484 drm->dev_private = private->all_drm_private[i]; in mtk_drm_kms_init()
485 ret = component_bind_all(private->all_drm_private[i]->dev, drm); in mtk_drm_kms_init()
499 * OVL0 -> COLOR0 -> AAL -> OD -> RDMA0 -> UFOE -> DSI0 ... in mtk_drm_kms_init()
500 * 2. For multi mmsys architecture, crtc path data are located in in mtk_drm_kms_init()
506 for (j = 0; j < private->data->mmsys_dev_num; j++) { in mtk_drm_kms_init()
507 priv_n = private->all_drm_private[j]; in mtk_drm_kms_init()
509 if (priv_n->data->max_width) in mtk_drm_kms_init()
510 drm->mode_config.max_width = priv_n->data->max_width; in mtk_drm_kms_init()
512 if (priv_n->data->min_width) in mtk_drm_kms_init()
513 drm->mode_config.min_width = priv_n->data->min_width; in mtk_drm_kms_init()
515 if (priv_n->data->min_height) in mtk_drm_kms_init()
516 drm->mode_config.min_height = priv_n->data->min_height; in mtk_drm_kms_init()
518 if (i == CRTC_MAIN && priv_n->data->main_len) { in mtk_drm_kms_init()
519 ret = mtk_crtc_create(drm, priv_n->data->main_path, in mtk_drm_kms_init()
520 priv_n->data->main_len, j, in mtk_drm_kms_init()
521 priv_n->data->conn_routes, in mtk_drm_kms_init()
522 priv_n->data->num_conn_routes); in mtk_drm_kms_init()
527 } else if (i == CRTC_EXT && priv_n->data->ext_len) { in mtk_drm_kms_init()
528 ret = mtk_crtc_create(drm, priv_n->data->ext_path, in mtk_drm_kms_init()
529 priv_n->data->ext_len, j, NULL, 0); in mtk_drm_kms_init()
534 } else if (i == CRTC_THIRD && priv_n->data->third_len) { in mtk_drm_kms_init()
535 ret = mtk_crtc_create(drm, priv_n->data->third_path, in mtk_drm_kms_init()
536 priv_n->data->third_len, j, NULL, 0); in mtk_drm_kms_init()
546 drm->mode_config.cursor_width = 512; in mtk_drm_kms_init()
547 drm->mode_config.cursor_height = 512; in mtk_drm_kms_init()
554 ret = -ENODEV; in mtk_drm_kms_init()
555 dev_err(drm->dev, "Need at least one OVL device\n"); in mtk_drm_kms_init()
559 for (i = 0; i < private->data->mmsys_dev_num; i++) in mtk_drm_kms_init()
560 private->all_drm_private[i]->dma_dev = dma_dev; in mtk_drm_kms_init()
578 for (i = 0; i < private->data->mmsys_dev_num; i++) in mtk_drm_kms_init()
579 component_unbind_all(private->all_drm_private[i]->dev, drm); in mtk_drm_kms_init()
581 for (i = 0; i < private->data->mmsys_dev_num; i++) in mtk_drm_kms_init()
582 put_device(private->all_drm_private[i]->mutex_dev); in mtk_drm_kms_init()
592 component_unbind_all(drm->dev, drm); in mtk_drm_kms_deinit()
599 * not dev->dev, as drm_gem_prime_import() expects.
604 struct mtk_drm_private *private = dev->dev_private; in mtk_gem_prime_import()
606 return drm_gem_prime_import_dev(dev, dma_buf, private->dma_dev); in mtk_gem_prime_import()
638 pdev = of_find_device_by_node(private->mutex_node); in mtk_drm_bind()
640 dev_err(dev, "Waiting for disp-mutex device %pOF\n", in mtk_drm_bind()
641 private->mutex_node); in mtk_drm_bind()
642 of_node_put(private->mutex_node); in mtk_drm_bind()
643 return -EPROBE_DEFER; in mtk_drm_bind()
646 private->mutex_dev = &pdev->dev; in mtk_drm_bind()
647 private->mtk_drm_bound = true; in mtk_drm_bind()
648 private->dev = dev; in mtk_drm_bind()
657 private->drm_master = true; in mtk_drm_bind()
658 drm->dev_private = private; in mtk_drm_bind()
659 for (i = 0; i < private->data->mmsys_dev_num; i++) in mtk_drm_bind()
660 private->all_drm_private[i]->drm = drm; in mtk_drm_bind()
677 private->drm = NULL; in mtk_drm_bind()
679 for (i = 0; i < private->data->mmsys_dev_num; i++) in mtk_drm_bind()
680 private->all_drm_private[i]->drm = NULL; in mtk_drm_bind()
688 /* for multi mmsys dev, unregister drm dev in mmsys master */ in mtk_drm_unbind()
689 if (private->drm_master) { in mtk_drm_unbind()
690 drm_dev_unregister(private->drm); in mtk_drm_unbind()
691 mtk_drm_kms_deinit(private->drm); in mtk_drm_unbind()
692 drm_dev_put(private->drm); in mtk_drm_unbind()
694 private->mtk_drm_bound = false; in mtk_drm_unbind()
695 private->drm_master = false; in mtk_drm_unbind()
696 private->drm = NULL; in mtk_drm_unbind()
705 { .compatible = "mediatek,mt8167-disp-aal",
707 { .compatible = "mediatek,mt8173-disp-aal",
709 { .compatible = "mediatek,mt8183-disp-aal",
711 { .compatible = "mediatek,mt8192-disp-aal",
713 { .compatible = "mediatek,mt8167-disp-ccorr",
715 { .compatible = "mediatek,mt8183-disp-ccorr",
717 { .compatible = "mediatek,mt8192-disp-ccorr",
719 { .compatible = "mediatek,mt2701-disp-color",
721 { .compatible = "mediatek,mt8167-disp-color",
723 { .compatible = "mediatek,mt8173-disp-color",
725 { .compatible = "mediatek,mt8167-disp-dither",
727 { .compatible = "mediatek,mt8183-disp-dither",
729 { .compatible = "mediatek,mt8195-disp-dsc",
731 { .compatible = "mediatek,mt8167-disp-gamma",
733 { .compatible = "mediatek,mt8173-disp-gamma",
735 { .compatible = "mediatek,mt8183-disp-gamma",
737 { .compatible = "mediatek,mt8195-disp-gamma",
739 { .compatible = "mediatek,mt8195-disp-merge",
741 { .compatible = "mediatek,mt2701-disp-mutex",
743 { .compatible = "mediatek,mt2712-disp-mutex",
745 { .compatible = "mediatek,mt8167-disp-mutex",
747 { .compatible = "mediatek,mt8173-disp-mutex",
749 { .compatible = "mediatek,mt8183-disp-mutex",
751 { .compatible = "mediatek,mt8186-disp-mutex",
753 { .compatible = "mediatek,mt8188-disp-mutex",
755 { .compatible = "mediatek,mt8192-disp-mutex",
757 { .compatible = "mediatek,mt8195-disp-mutex",
759 { .compatible = "mediatek,mt8173-disp-od",
761 { .compatible = "mediatek,mt2701-disp-ovl",
763 { .compatible = "mediatek,mt8167-disp-ovl",
765 { .compatible = "mediatek,mt8173-disp-ovl",
767 { .compatible = "mediatek,mt8183-disp-ovl",
769 { .compatible = "mediatek,mt8192-disp-ovl",
771 { .compatible = "mediatek,mt8195-disp-ovl",
773 { .compatible = "mediatek,mt8183-disp-ovl-2l",
775 { .compatible = "mediatek,mt8192-disp-ovl-2l",
777 { .compatible = "mediatek,mt8192-disp-postmask",
779 { .compatible = "mediatek,mt2701-disp-pwm",
781 { .compatible = "mediatek,mt8167-disp-pwm",
783 { .compatible = "mediatek,mt8173-disp-pwm",
785 { .compatible = "mediatek,mt2701-disp-rdma",
787 { .compatible = "mediatek,mt8167-disp-rdma",
789 { .compatible = "mediatek,mt8173-disp-rdma",
791 { .compatible = "mediatek,mt8183-disp-rdma",
793 { .compatible = "mediatek,mt8195-disp-rdma",
795 { .compatible = "mediatek,mt8173-disp-ufoe",
797 { .compatible = "mediatek,mt8173-disp-wdma",
799 { .compatible = "mediatek,mt2701-dpi",
801 { .compatible = "mediatek,mt8167-dsi",
803 { .compatible = "mediatek,mt8173-dpi",
805 { .compatible = "mediatek,mt8183-dpi",
807 { .compatible = "mediatek,mt8186-dpi",
809 { .compatible = "mediatek,mt8188-dp-intf",
811 { .compatible = "mediatek,mt8192-dpi",
813 { .compatible = "mediatek,mt8195-dp-intf",
815 { .compatible = "mediatek,mt2701-dsi",
817 { .compatible = "mediatek,mt8173-dsi",
819 { .compatible = "mediatek,mt8183-dsi",
821 { .compatible = "mediatek,mt8186-dsi",
823 { .compatible = "mediatek,mt8188-dsi",
833 return -EINVAL; in mtk_drm_of_get_ddp_comp_type()
835 *ctype = (enum mtk_ddp_comp_type)((uintptr_t)of_id->data); in mtk_drm_of_get_ddp_comp_type()
850 return -ENOENT; in mtk_drm_of_get_ddp_ep_cid()
855 return -EINVAL; in mtk_drm_of_get_ddp_ep_cid()
865 return -ENODEV; in mtk_drm_of_get_ddp_ep_cid()
887 * mtk_drm_of_ddp_path_build_one - Build a Display HW Pipeline for a CRTC Path
888 * @dev: The mediatek-drm device
889 * @cpath: CRTC Path relative to a VDO or MMSYS
894 * on the board-specific desired display configuration; this function walks
895 * through all of the output endpoints starting from a VDO or MMSYS hardware
899 * * %0 - Display HW Pipeline successfully built and validated
900 * * %-ENOENT - Display pipeline was not specified in device tree
901 * * %-EINVAL - Display pipeline built but validation failed
902 * * %-ENOMEM - Failure to allocate pipeline array to pass to the caller
908 struct device_node *next = NULL, *prev, *vdo = dev->parent->of_node; in mtk_drm_of_ddp_path_build_one()
933 * Walk through port outputs until we reach the last valid mediatek-drm component. in mtk_drm_of_ddp_path_build_one()
956 idx--; in mtk_drm_of_ddp_path_build_one()
964 if (ret == -ENODEV) in mtk_drm_of_ddp_path_build_one()
968 switch (temp_path[idx - 1]) { in mtk_drm_of_ddp_path_build_one()
980 temp_path[idx - 1], ret); in mtk_drm_of_ddp_path_build_one()
981 return -EINVAL; in mtk_drm_of_ddp_path_build_one()
986 return -ENOMEM; in mtk_drm_of_ddp_path_build_one()
1013 ret = dev_err_probe(dev, -EINVAL, in mtk_drm_of_ddp_path_build()
1028 &data->main_path, &data->main_len); in mtk_drm_of_ddp_path_build()
1029 if (ret && ret != -ENODEV) in mtk_drm_of_ddp_path_build()
1035 &data->ext_path, &data->ext_len); in mtk_drm_of_ddp_path_build()
1036 if (ret && ret != -ENODEV) in mtk_drm_of_ddp_path_build()
1042 &data->third_path, &data->third_len); in mtk_drm_of_ddp_path_build()
1043 if (ret && ret != -ENODEV) in mtk_drm_of_ddp_path_build()
1052 struct device *dev = &pdev->dev; in mtk_drm_probe()
1053 struct device_node *phandle = dev->parent->of_node; in mtk_drm_probe()
1065 return -ENOMEM; in mtk_drm_probe()
1067 private->mmsys_dev = dev->parent; in mtk_drm_probe()
1068 if (!private->mmsys_dev) { in mtk_drm_probe()
1069 dev_err(dev, "Failed to get MMSYS device\n"); in mtk_drm_probe()
1070 return -ENODEV; in mtk_drm_probe()
1075 return -ENODEV; in mtk_drm_probe()
1077 mtk_drm_data = (struct mtk_mmsys_driver_data *)of_id->data; in mtk_drm_probe()
1079 return -EINVAL; in mtk_drm_probe()
1083 dev_dbg(dev, "Building display pipeline for MMSYS %u\n", in mtk_drm_probe()
1084 mtk_drm_data->mmsys_id); in mtk_drm_probe()
1085 private->data = devm_kmemdup(dev, mtk_drm_data, in mtk_drm_probe()
1087 if (!private->data) in mtk_drm_probe()
1088 return -ENOMEM; in mtk_drm_probe()
1090 ret = mtk_drm_of_ddp_path_build(dev, phandle, private->data); in mtk_drm_probe()
1095 dev_dbg(dev, "Using hardcoded paths for MMSYS %u\n", mtk_drm_data->mmsys_id); in mtk_drm_probe()
1096 private->data = mtk_drm_data; in mtk_drm_probe()
1099 private->all_drm_private = devm_kmalloc_array(dev, private->data->mmsys_dev_num, in mtk_drm_probe()
1100 sizeof(*private->all_drm_private), in mtk_drm_probe()
1102 if (!private->all_drm_private) in mtk_drm_probe()
1103 return -ENOMEM; in mtk_drm_probe()
1107 ovl_adaptor = platform_device_register_data(dev, "mediatek-disp-ovl-adaptor", in mtk_drm_probe()
1109 (void *)private->mmsys_dev, in mtk_drm_probe()
1110 sizeof(*private->mmsys_dev)); in mtk_drm_probe()
1111 private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR].dev = &ovl_adaptor->dev; in mtk_drm_probe()
1112 mtk_ddp_comp_init(NULL, &private->ddp_comp[DDP_COMPONENT_DRM_OVL_ADAPTOR], in mtk_drm_probe()
1114 component_match_add(dev, &match, compare_dev, &ovl_adaptor->dev); in mtk_drm_probe()
1118 for_each_child_of_node(phandle->parent, node) { in mtk_drm_probe()
1136 if (id < 0 || id == private->data->mmsys_id) { in mtk_drm_probe()
1137 private->mutex_node = of_node_get(node); in mtk_drm_probe()
1138 dev_dbg(dev, "get mutex for mmsys %d", private->data->mmsys_id); in mtk_drm_probe()
1153 private->comp_node[comp_id] = of_node_get(node); in mtk_drm_probe()
1178 ret = mtk_ddp_comp_init(node, &private->ddp_comp[comp_id], comp_id); in mtk_drm_probe()
1185 if (!private->mutex_node) { in mtk_drm_probe()
1186 dev_err(dev, "Failed to find disp-mutex node\n"); in mtk_drm_probe()
1187 ret = -ENODEV; in mtk_drm_probe()
1204 of_node_put(private->mutex_node); in mtk_drm_probe()
1206 of_node_put(private->comp_node[i]); in mtk_drm_probe()
1215 component_master_del(&pdev->dev, &mtk_drm_ops); in mtk_drm_remove()
1216 pm_runtime_disable(&pdev->dev); in mtk_drm_remove()
1217 of_node_put(private->mutex_node); in mtk_drm_remove()
1219 of_node_put(private->comp_node[i]); in mtk_drm_remove()
1226 drm_atomic_helper_shutdown(private->drm); in mtk_drm_shutdown()
1232 struct drm_device *drm = private->drm; in mtk_drm_sys_prepare()
1234 if (private->drm_master) in mtk_drm_sys_prepare()
1243 struct drm_device *drm = private->drm; in mtk_drm_sys_complete()
1246 if (private->drm_master) in mtk_drm_sys_complete()
1262 .name = "mediatek-drm",