• Home
  • Raw
  • Download

Lines Matching +full:display +full:- +full:hub

1 // SPDX-License-Identifier: GPL-2.0-only
65 offset = 0x000 + (offset - 0x500); in tegra_plane_offset()
66 return plane->offset + offset; in tegra_plane_offset()
70 offset = 0x180 + (offset - 0x700); in tegra_plane_offset()
71 return plane->offset + offset; in tegra_plane_offset()
75 offset = 0x1c0 + (offset - 0x800); in tegra_plane_offset()
76 return plane->offset + offset; in tegra_plane_offset()
79 dev_WARN(plane->dc->dev, "invalid offset: %x\n", offset); in tegra_plane_offset()
81 return plane->offset + offset; in tegra_plane_offset()
87 return tegra_dc_readl(plane->dc, tegra_plane_offset(plane, offset)); in tegra_plane_readl()
93 tegra_dc_writel(plane->dc, value, tegra_plane_offset(plane, offset)); in tegra_plane_writel()
100 mutex_lock(&wgrp->lock); in tegra_windowgroup_enable()
102 if (wgrp->usecount == 0) { in tegra_windowgroup_enable()
103 err = host1x_client_resume(wgrp->parent); in tegra_windowgroup_enable()
105 dev_err(wgrp->parent->dev, "failed to resume: %d\n", err); in tegra_windowgroup_enable()
109 reset_control_deassert(wgrp->rst); in tegra_windowgroup_enable()
112 wgrp->usecount++; in tegra_windowgroup_enable()
115 mutex_unlock(&wgrp->lock); in tegra_windowgroup_enable()
123 mutex_lock(&wgrp->lock); in tegra_windowgroup_disable()
125 if (wgrp->usecount == 1) { in tegra_windowgroup_disable()
126 err = reset_control_assert(wgrp->rst); in tegra_windowgroup_disable()
129 wgrp->index); in tegra_windowgroup_disable()
132 host1x_client_suspend(wgrp->parent); in tegra_windowgroup_disable()
135 wgrp->usecount--; in tegra_windowgroup_disable()
136 mutex_unlock(&wgrp->lock); in tegra_windowgroup_disable()
139 int tegra_display_hub_prepare(struct tegra_display_hub *hub) in tegra_display_hub_prepare() argument
145 * display controller is disabled. There's currently no good point at in tegra_display_hub_prepare()
149 for (i = 0; i < hub->soc->num_wgrps; i++) { in tegra_display_hub_prepare()
150 struct tegra_windowgroup *wgrp = &hub->wgrps[i]; in tegra_display_hub_prepare()
153 if (wgrp->parent) in tegra_display_hub_prepare()
160 void tegra_display_hub_cleanup(struct tegra_display_hub *hub) in tegra_display_hub_cleanup() argument
165 * XXX Remove this once window groups can be more fine-grainedly in tegra_display_hub_cleanup()
168 for (i = 0; i < hub->soc->num_wgrps; i++) { in tegra_display_hub_cleanup()
169 struct tegra_windowgroup *wgrp = &hub->wgrps[i]; in tegra_display_hub_cleanup()
172 if (wgrp->parent) in tegra_display_hub_cleanup()
179 struct tegra_dc *dc = plane->dc; in tegra_shared_plane_update()
183 mask = COMMON_UPDATE | WIN_A_UPDATE << plane->base.index; in tegra_shared_plane_update()
199 struct tegra_dc *dc = plane->dc; in tegra_shared_plane_activate()
203 mask = COMMON_ACTREQ | WIN_A_ACT_REQ << plane->base.index; in tegra_shared_plane_activate()
229 struct device *dev = dc->dev; in tegra_dc_owns_shared_plane()
231 if (tegra_shared_plane_get_owner(plane, dc) == dc->pipe) { in tegra_dc_owns_shared_plane()
232 if (plane->dc == dc) in tegra_dc_owns_shared_plane()
236 dc->pipe, plane->index); in tegra_dc_owns_shared_plane()
247 struct tegra_dc *old = plane->dc, *dc = new ? new : old; in tegra_shared_plane_set_owner()
248 struct device *dev = new ? new->dev : old->dev; in tegra_shared_plane_set_owner()
249 unsigned int owner, index = plane->index; in tegra_shared_plane_set_owner()
255 if (new && (owner != OWNER_MASK && owner != new->pipe)) { in tegra_shared_plane_set_owner()
257 return -EBUSY; in tegra_shared_plane_set_owner()
267 old->pipe, owner); in tegra_shared_plane_set_owner()
272 value |= OWNER(new->pipe); in tegra_shared_plane_set_owner()
278 plane->dc = new; in tegra_shared_plane_set_owner()
324 value |= THREAD_NUM(plane->base.index); in tegra_dc_assign_shared_plane()
343 struct tegra_bo_tiling *tiling = &plane_state->tiling; in tegra_shared_plane_atomic_check()
344 struct tegra_dc *dc = to_tegra_dc(state->crtc); in tegra_shared_plane_atomic_check()
348 if (!state->crtc || !state->fb) in tegra_shared_plane_atomic_check()
351 err = tegra_plane_format(state->fb->format->format, in tegra_shared_plane_atomic_check()
352 &plane_state->format, in tegra_shared_plane_atomic_check()
353 &plane_state->swap); in tegra_shared_plane_atomic_check()
357 err = tegra_fb_get_tiling(state->fb, tiling); in tegra_shared_plane_atomic_check()
361 if (tiling->mode == TEGRA_BO_TILING_MODE_BLOCK && in tegra_shared_plane_atomic_check()
362 !dc->soc->supports_block_linear) { in tegra_shared_plane_atomic_check()
364 return -EINVAL; in tegra_shared_plane_atomic_check()
369 * error out if the user tries to display a framebuffer with such a in tegra_shared_plane_atomic_check()
372 if (state->fb->format->num_planes > 2) { in tegra_shared_plane_atomic_check()
373 if (state->fb->pitches[2] != state->fb->pitches[1]) { in tegra_shared_plane_atomic_check()
374 DRM_ERROR("unsupported UV-plane configuration\n"); in tegra_shared_plane_atomic_check()
375 return -EINVAL; in tegra_shared_plane_atomic_check()
381 err = tegra_plane_state_add(&tegra->base, state); in tegra_shared_plane_atomic_check()
397 if (!old_state || !old_state->crtc) in tegra_shared_plane_atomic_disable()
400 dc = to_tegra_dc(old_state->crtc); in tegra_shared_plane_atomic_disable()
402 err = host1x_client_resume(&dc->client); in tegra_shared_plane_atomic_disable()
404 dev_err(dc->dev, "failed to resume: %d\n", err); in tegra_shared_plane_atomic_disable()
409 * XXX Legacy helpers seem to sometimes call ->atomic_disable() even in tegra_shared_plane_atomic_disable()
413 if (WARN_ON(p->dc == NULL)) in tegra_shared_plane_atomic_disable()
414 p->dc = dc; in tegra_shared_plane_atomic_disable()
422 host1x_client_suspend(&dc->client); in tegra_shared_plane_atomic_disable()
428 struct tegra_plane_state *state = to_tegra_plane_state(plane->state); in tegra_shared_plane_atomic_update()
429 struct tegra_dc *dc = to_tegra_dc(plane->state->crtc); in tegra_shared_plane_atomic_update()
430 unsigned int zpos = plane->state->normalized_zpos; in tegra_shared_plane_atomic_update()
431 struct drm_framebuffer *fb = plane->state->fb; in tegra_shared_plane_atomic_update()
438 if (!plane->state->crtc || !plane->state->fb) in tegra_shared_plane_atomic_update()
441 if (!plane->state->visible) { in tegra_shared_plane_atomic_update()
446 err = host1x_client_resume(&dc->client); in tegra_shared_plane_atomic_update()
448 dev_err(dc->dev, "failed to resume: %d\n", err); in tegra_shared_plane_atomic_update()
467 value = K2(255) | K1(255) | WINDOW_LAYER_DEPTH(255 - zpos); in tegra_shared_plane_atomic_update()
480 base = state->iova[0] + fb->offsets[0]; in tegra_shared_plane_atomic_update()
482 tegra_plane_writel(p, state->format, DC_WIN_COLOR_DEPTH); in tegra_shared_plane_atomic_update()
485 value = V_POSITION(plane->state->crtc_y) | in tegra_shared_plane_atomic_update()
486 H_POSITION(plane->state->crtc_x); in tegra_shared_plane_atomic_update()
489 value = V_SIZE(plane->state->crtc_h) | H_SIZE(plane->state->crtc_w); in tegra_shared_plane_atomic_update()
495 value = V_SIZE(plane->state->crtc_h) | H_SIZE(plane->state->crtc_w); in tegra_shared_plane_atomic_update()
501 value = PITCH(fb->pitches[0]); in tegra_shared_plane_atomic_update()
507 value = OFFSET_X(plane->state->src_y >> 16) | in tegra_shared_plane_atomic_update()
508 OFFSET_Y(plane->state->src_x >> 16); in tegra_shared_plane_atomic_update()
511 if (dc->soc->supports_block_linear) { in tegra_shared_plane_atomic_update()
512 unsigned long height = state->tiling.value; in tegra_shared_plane_atomic_update()
515 switch (state->tiling.mode) { in tegra_shared_plane_atomic_update()
540 host1x_client_suspend(&dc->client); in tegra_shared_plane_atomic_update()
557 struct tegra_drm *tegra = drm->dev_private; in tegra_shared_plane_create()
558 struct tegra_display_hub *hub = tegra->hub; in tegra_shared_plane_create() local
570 return ERR_PTR(-ENOMEM); in tegra_shared_plane_create()
572 plane->base.offset = 0x0a00 + 0x0300 * index; in tegra_shared_plane_create()
573 plane->base.index = index; in tegra_shared_plane_create()
575 plane->wgrp = &hub->wgrps[wgrp]; in tegra_shared_plane_create()
576 plane->wgrp->parent = &dc->client; in tegra_shared_plane_create()
578 p = &plane->base.base; in tegra_shared_plane_create()
603 state = kmemdup(obj->state, sizeof(*state), GFP_KERNEL); in tegra_display_hub_duplicate_state()
607 __drm_atomic_helper_private_obj_duplicate_state(obj, &state->base); in tegra_display_hub_duplicate_state()
609 return &state->base; in tegra_display_hub_duplicate_state()
627 tegra_display_hub_get_state(struct tegra_display_hub *hub, in tegra_display_hub_get_state() argument
632 priv = drm_atomic_get_private_obj_state(state, &hub->base); in tegra_display_hub_get_state()
642 struct tegra_drm *tegra = drm->dev_private; in tegra_display_hub_atomic_check()
648 if (!tegra->hub) in tegra_display_hub_atomic_check()
651 hub_state = tegra_display_hub_get_state(tegra->hub, state); in tegra_display_hub_atomic_check()
656 * The display hub display clock needs to be fed by the display clock in tegra_display_hub_atomic_check()
666 if (new->active) { in tegra_display_hub_atomic_check()
667 if (!hub_state->clk || dc->pclk > hub_state->rate) { in tegra_display_hub_atomic_check()
668 hub_state->dc = to_tegra_dc(dc->base.crtc); in tegra_display_hub_atomic_check()
669 hub_state->clk = hub_state->dc->clk; in tegra_display_hub_atomic_check()
670 hub_state->rate = dc->pclk; in tegra_display_hub_atomic_check()
683 err = host1x_client_resume(&dc->client); in tegra_display_hub_update()
685 dev_err(dc->dev, "failed to resume: %d\n", err); in tegra_display_hub_update()
702 host1x_client_suspend(&dc->client); in tegra_display_hub_update()
708 struct tegra_drm *tegra = drm->dev_private; in tegra_display_hub_atomic_commit()
709 struct tegra_display_hub *hub = tegra->hub; in tegra_display_hub_atomic_commit() local
711 struct device *dev = hub->client.dev; in tegra_display_hub_atomic_commit()
714 hub_state = to_tegra_display_hub_state(hub->base.state); in tegra_display_hub_atomic_commit()
716 if (hub_state->clk) { in tegra_display_hub_atomic_commit()
717 err = clk_set_rate(hub_state->clk, hub_state->rate); in tegra_display_hub_atomic_commit()
720 hub_state->clk, hub_state->rate); in tegra_display_hub_atomic_commit()
722 err = clk_set_parent(hub->clk_disp, hub_state->clk); in tegra_display_hub_atomic_commit()
725 hub->clk_disp, hub_state->clk, err); in tegra_display_hub_atomic_commit()
728 if (hub_state->dc) in tegra_display_hub_atomic_commit()
729 tegra_display_hub_update(hub_state->dc); in tegra_display_hub_atomic_commit()
734 struct tegra_display_hub *hub = to_tegra_display_hub(client); in tegra_display_hub_init() local
735 struct drm_device *drm = dev_get_drvdata(client->host); in tegra_display_hub_init()
736 struct tegra_drm *tegra = drm->dev_private; in tegra_display_hub_init()
741 return -ENOMEM; in tegra_display_hub_init()
743 drm_atomic_private_obj_init(drm, &hub->base, &state->base, in tegra_display_hub_init()
746 tegra->hub = hub; in tegra_display_hub_init()
753 struct drm_device *drm = dev_get_drvdata(client->host); in tegra_display_hub_exit()
754 struct tegra_drm *tegra = drm->dev_private; in tegra_display_hub_exit()
756 drm_atomic_private_obj_fini(&tegra->hub->base); in tegra_display_hub_exit()
757 tegra->hub = NULL; in tegra_display_hub_exit()
764 struct tegra_display_hub *hub = to_tegra_display_hub(client); in tegra_display_hub_runtime_suspend() local
765 struct device *dev = client->dev; in tegra_display_hub_runtime_suspend()
766 unsigned int i = hub->num_heads; in tegra_display_hub_runtime_suspend()
769 err = reset_control_assert(hub->rst); in tegra_display_hub_runtime_suspend()
773 while (i--) in tegra_display_hub_runtime_suspend()
774 clk_disable_unprepare(hub->clk_heads[i]); in tegra_display_hub_runtime_suspend()
776 clk_disable_unprepare(hub->clk_hub); in tegra_display_hub_runtime_suspend()
777 clk_disable_unprepare(hub->clk_dsc); in tegra_display_hub_runtime_suspend()
778 clk_disable_unprepare(hub->clk_disp); in tegra_display_hub_runtime_suspend()
787 struct tegra_display_hub *hub = to_tegra_display_hub(client); in tegra_display_hub_runtime_resume() local
788 struct device *dev = client->dev; in tegra_display_hub_runtime_resume()
798 err = clk_prepare_enable(hub->clk_disp); in tegra_display_hub_runtime_resume()
802 err = clk_prepare_enable(hub->clk_dsc); in tegra_display_hub_runtime_resume()
806 err = clk_prepare_enable(hub->clk_hub); in tegra_display_hub_runtime_resume()
810 for (i = 0; i < hub->num_heads; i++) { in tegra_display_hub_runtime_resume()
811 err = clk_prepare_enable(hub->clk_heads[i]); in tegra_display_hub_runtime_resume()
816 err = reset_control_deassert(hub->rst); in tegra_display_hub_runtime_resume()
823 while (i--) in tegra_display_hub_runtime_resume()
824 clk_disable_unprepare(hub->clk_heads[i]); in tegra_display_hub_runtime_resume()
826 clk_disable_unprepare(hub->clk_hub); in tegra_display_hub_runtime_resume()
828 clk_disable_unprepare(hub->clk_dsc); in tegra_display_hub_runtime_resume()
830 clk_disable_unprepare(hub->clk_disp); in tegra_display_hub_runtime_resume()
846 struct tegra_display_hub *hub; in tegra_display_hub_probe() local
851 hub = devm_kzalloc(&pdev->dev, sizeof(*hub), GFP_KERNEL); in tegra_display_hub_probe()
852 if (!hub) in tegra_display_hub_probe()
853 return -ENOMEM; in tegra_display_hub_probe()
855 hub->soc = of_device_get_match_data(&pdev->dev); in tegra_display_hub_probe()
857 hub->clk_disp = devm_clk_get(&pdev->dev, "disp"); in tegra_display_hub_probe()
858 if (IS_ERR(hub->clk_disp)) { in tegra_display_hub_probe()
859 err = PTR_ERR(hub->clk_disp); in tegra_display_hub_probe()
863 if (hub->soc->supports_dsc) { in tegra_display_hub_probe()
864 hub->clk_dsc = devm_clk_get(&pdev->dev, "dsc"); in tegra_display_hub_probe()
865 if (IS_ERR(hub->clk_dsc)) { in tegra_display_hub_probe()
866 err = PTR_ERR(hub->clk_dsc); in tegra_display_hub_probe()
871 hub->clk_hub = devm_clk_get(&pdev->dev, "hub"); in tegra_display_hub_probe()
872 if (IS_ERR(hub->clk_hub)) { in tegra_display_hub_probe()
873 err = PTR_ERR(hub->clk_hub); in tegra_display_hub_probe()
877 hub->rst = devm_reset_control_get(&pdev->dev, "misc"); in tegra_display_hub_probe()
878 if (IS_ERR(hub->rst)) { in tegra_display_hub_probe()
879 err = PTR_ERR(hub->rst); in tegra_display_hub_probe()
883 hub->wgrps = devm_kcalloc(&pdev->dev, hub->soc->num_wgrps, in tegra_display_hub_probe()
884 sizeof(*hub->wgrps), GFP_KERNEL); in tegra_display_hub_probe()
885 if (!hub->wgrps) in tegra_display_hub_probe()
886 return -ENOMEM; in tegra_display_hub_probe()
888 for (i = 0; i < hub->soc->num_wgrps; i++) { in tegra_display_hub_probe()
889 struct tegra_windowgroup *wgrp = &hub->wgrps[i]; in tegra_display_hub_probe()
893 mutex_init(&wgrp->lock); in tegra_display_hub_probe()
894 wgrp->usecount = 0; in tegra_display_hub_probe()
895 wgrp->index = i; in tegra_display_hub_probe()
897 wgrp->rst = devm_reset_control_get(&pdev->dev, id); in tegra_display_hub_probe()
898 if (IS_ERR(wgrp->rst)) in tegra_display_hub_probe()
899 return PTR_ERR(wgrp->rst); in tegra_display_hub_probe()
901 err = reset_control_assert(wgrp->rst); in tegra_display_hub_probe()
906 hub->num_heads = of_get_child_count(pdev->dev.of_node); in tegra_display_hub_probe()
908 hub->clk_heads = devm_kcalloc(&pdev->dev, hub->num_heads, sizeof(clk), in tegra_display_hub_probe()
910 if (!hub->clk_heads) in tegra_display_hub_probe()
911 return -ENOMEM; in tegra_display_hub_probe()
913 for (i = 0; i < hub->num_heads; i++) { in tegra_display_hub_probe()
914 child = of_get_next_child(pdev->dev.of_node, child); in tegra_display_hub_probe()
916 dev_err(&pdev->dev, "failed to find node for head %u\n", in tegra_display_hub_probe()
918 return -ENODEV; in tegra_display_hub_probe()
921 clk = devm_get_clk_from_child(&pdev->dev, child, "dc"); in tegra_display_hub_probe()
923 dev_err(&pdev->dev, "failed to get clock for head %u\n", in tegra_display_hub_probe()
929 hub->clk_heads[i] = clk; in tegra_display_hub_probe()
935 err = reset_control_assert(hub->rst); in tegra_display_hub_probe()
939 platform_set_drvdata(pdev, hub); in tegra_display_hub_probe()
940 pm_runtime_enable(&pdev->dev); in tegra_display_hub_probe()
942 INIT_LIST_HEAD(&hub->client.list); in tegra_display_hub_probe()
943 hub->client.ops = &tegra_display_hub_ops; in tegra_display_hub_probe()
944 hub->client.dev = &pdev->dev; in tegra_display_hub_probe()
946 err = host1x_client_register(&hub->client); in tegra_display_hub_probe()
948 dev_err(&pdev->dev, "failed to register host1x client: %d\n", in tegra_display_hub_probe()
951 err = devm_of_platform_populate(&pdev->dev); in tegra_display_hub_probe()
958 host1x_client_unregister(&hub->client); in tegra_display_hub_probe()
959 pm_runtime_disable(&pdev->dev); in tegra_display_hub_probe()
965 struct tegra_display_hub *hub = platform_get_drvdata(pdev); in tegra_display_hub_remove() local
969 err = host1x_client_unregister(&hub->client); in tegra_display_hub_remove()
971 dev_err(&pdev->dev, "failed to unregister host1x client: %d\n", in tegra_display_hub_remove()
975 for (i = 0; i < hub->soc->num_wgrps; i++) { in tegra_display_hub_remove()
976 struct tegra_windowgroup *wgrp = &hub->wgrps[i]; in tegra_display_hub_remove()
978 mutex_destroy(&wgrp->lock); in tegra_display_hub_remove()
981 pm_runtime_disable(&pdev->dev); in tegra_display_hub_remove()
998 .compatible = "nvidia,tegra194-display",
1001 .compatible = "nvidia,tegra186-display",
1011 .name = "tegra-display-hub",