• Home
  • Raw
  • Download

Lines Matching refs:mtk_crtc

82 static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)  in mtk_drm_crtc_finish_page_flip()  argument
84 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_drm_crtc_finish_page_flip()
88 drm_crtc_send_vblank_event(crtc, mtk_crtc->event); in mtk_drm_crtc_finish_page_flip()
90 mtk_crtc->event = NULL; in mtk_drm_crtc_finish_page_flip()
94 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) in mtk_drm_finish_page_flip() argument
96 drm_crtc_handle_vblank(&mtk_crtc->base); in mtk_drm_finish_page_flip()
97 if (mtk_crtc->pending_needs_vblank) { in mtk_drm_finish_page_flip()
98 mtk_drm_crtc_finish_page_flip(mtk_crtc); in mtk_drm_finish_page_flip()
99 mtk_crtc->pending_needs_vblank = false; in mtk_drm_finish_page_flip()
105 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_destroy() local
107 mtk_disp_mutex_put(mtk_crtc->mutex); in mtk_drm_crtc_destroy()
171 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_enable_vblank() local
172 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_enable_vblank()
174 mtk_ddp_comp_enable_vblank(comp, &mtk_crtc->base); in mtk_drm_crtc_enable_vblank()
181 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_disable_vblank() local
182 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_disable_vblank()
187 static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_enable() argument
192 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_clk_enable()
193 ret = clk_prepare_enable(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
203 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
207 static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_disable() argument
211 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_clk_disable()
212 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_disable()
220 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_ddp_comp_for_plane() local
223 unsigned int local_index = plane - mtk_crtc->planes; in mtk_drm_ddp_comp_for_plane()
225 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_ddp_comp_for_plane()
226 comp = mtk_crtc->ddp_comp[i]; in mtk_drm_ddp_comp_for_plane()
245 static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_init() argument
247 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_crtc_ddp_hw_init()
283 ret = mtk_disp_mutex_prepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
289 ret = mtk_crtc_ddp_clk_enable(mtk_crtc); in mtk_crtc_ddp_hw_init()
295 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_init()
296 mtk_mmsys_ddp_connect(mtk_crtc->mmsys_dev, in mtk_crtc_ddp_hw_init()
297 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_init()
298 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_init()
299 mtk_disp_mutex_add_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_init()
300 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
302 mtk_disp_mutex_add_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
303 mtk_disp_mutex_enable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
305 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_hw_init()
306 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i]; in mtk_crtc_ddp_hw_init()
316 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_hw_init()
317 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_hw_init()
335 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
341 static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_fini() argument
343 struct drm_device *drm = mtk_crtc->base.dev; in mtk_crtc_ddp_hw_fini()
344 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_crtc_ddp_hw_fini()
347 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_hw_fini()
348 mtk_ddp_comp_stop(mtk_crtc->ddp_comp[i]); in mtk_crtc_ddp_hw_fini()
350 mtk_ddp_comp_bgclr_in_off(mtk_crtc->ddp_comp[i]); in mtk_crtc_ddp_hw_fini()
353 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_hw_fini()
354 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
355 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
356 mtk_disp_mutex_disable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
357 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_fini()
358 mtk_mmsys_ddp_disconnect(mtk_crtc->mmsys_dev, in mtk_crtc_ddp_hw_fini()
359 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_fini()
360 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_fini()
361 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
362 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
364 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
365 mtk_crtc_ddp_clk_disable(mtk_crtc); in mtk_crtc_ddp_hw_fini()
366 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
381 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_config() local
382 struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state); in mtk_crtc_ddp_config()
383 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_crtc_ddp_config()
401 if (mtk_crtc->pending_planes) { in mtk_crtc_ddp_config()
402 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_config()
403 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_config()
420 mtk_crtc->pending_planes = false; in mtk_crtc_ddp_config()
423 if (mtk_crtc->pending_async_planes) { in mtk_crtc_ddp_config()
424 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_config()
425 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_config()
442 mtk_crtc->pending_async_planes = false; in mtk_crtc_ddp_config()
446 static void mtk_drm_crtc_hw_config(struct mtk_drm_crtc *mtk_crtc) in mtk_drm_crtc_hw_config() argument
451 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_drm_crtc_hw_config()
456 mutex_lock(&mtk_crtc->hw_lock); in mtk_drm_crtc_hw_config()
457 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_hw_config()
458 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_hw_config()
473 mtk_crtc->pending_planes = true; in mtk_drm_crtc_hw_config()
475 mtk_crtc->pending_async_planes = true; in mtk_drm_crtc_hw_config()
478 mtk_disp_mutex_acquire(mtk_crtc->mutex); in mtk_drm_crtc_hw_config()
480 mtk_disp_mutex_release(mtk_crtc->mutex); in mtk_drm_crtc_hw_config()
483 if (mtk_crtc->cmdq_client) { in mtk_drm_crtc_hw_config()
484 mbox_flush(mtk_crtc->cmdq_client->chan, 2000); in mtk_drm_crtc_hw_config()
485 cmdq_handle = cmdq_pkt_create(mtk_crtc->cmdq_client, PAGE_SIZE); in mtk_drm_crtc_hw_config()
486 cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); in mtk_drm_crtc_hw_config()
487 cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); in mtk_drm_crtc_hw_config()
493 mutex_unlock(&mtk_crtc->hw_lock); in mtk_drm_crtc_hw_config()
511 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_async_update() local
515 if (!mtk_crtc->enabled) in mtk_drm_crtc_async_update()
519 mtk_drm_crtc_hw_config(mtk_crtc); in mtk_drm_crtc_async_update()
525 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_enable() local
526 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_enable()
537 ret = mtk_crtc_ddp_hw_init(mtk_crtc); in mtk_drm_crtc_atomic_enable()
544 mtk_crtc->enabled = true; in mtk_drm_crtc_atomic_enable()
550 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_disable() local
551 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_disable()
555 if (!mtk_crtc->enabled) in mtk_drm_crtc_atomic_disable()
559 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_atomic_disable()
560 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_atomic_disable()
567 mtk_crtc->pending_planes = true; in mtk_drm_crtc_atomic_disable()
569 mtk_drm_crtc_hw_config(mtk_crtc); in mtk_drm_crtc_atomic_disable()
574 mtk_crtc_ddp_hw_fini(mtk_crtc); in mtk_drm_crtc_atomic_disable()
577 mtk_crtc->enabled = false; in mtk_drm_crtc_atomic_disable()
584 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_begin() local
587 if (mtk_crtc->event && state->base.event) in mtk_drm_crtc_atomic_begin()
595 mtk_crtc->event = state->base.event; in mtk_drm_crtc_atomic_begin()
605 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_flush() local
608 if (mtk_crtc->event) in mtk_drm_crtc_atomic_flush()
609 mtk_crtc->pending_needs_vblank = true; in mtk_drm_crtc_atomic_flush()
611 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_crtc_atomic_flush()
612 mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state); in mtk_drm_crtc_atomic_flush()
613 mtk_ddp_ctm_set(mtk_crtc->ddp_comp[i], crtc->state); in mtk_drm_crtc_atomic_flush()
615 mtk_drm_crtc_hw_config(mtk_crtc); in mtk_drm_crtc_atomic_flush()
640 struct mtk_drm_crtc *mtk_crtc, in mtk_drm_crtc_init() argument
647 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_init()
648 if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_PRIMARY) in mtk_drm_crtc_init()
649 primary = &mtk_crtc->planes[i]; in mtk_drm_crtc_init()
650 else if (mtk_crtc->planes[i].type == DRM_PLANE_TYPE_CURSOR) in mtk_drm_crtc_init()
651 cursor = &mtk_crtc->planes[i]; in mtk_drm_crtc_init()
654 ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor, in mtk_drm_crtc_init()
659 drm_crtc_helper_add(&mtk_crtc->base, &mtk_crtc_helper_funcs); in mtk_drm_crtc_init()
664 drm_crtc_cleanup(&mtk_crtc->base); in mtk_drm_crtc_init()
670 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_irq() local
674 if (!priv->data->shadow_register && !mtk_crtc->cmdq_client) in mtk_crtc_ddp_irq()
680 mtk_drm_finish_page_flip(mtk_crtc); in mtk_crtc_ddp_irq()
683 static int mtk_drm_crtc_num_comp_planes(struct mtk_drm_crtc *mtk_crtc, in mtk_drm_crtc_num_comp_planes() argument
691 comp = mtk_crtc->ddp_comp[comp_idx]; in mtk_drm_crtc_num_comp_planes()
715 struct mtk_drm_crtc *mtk_crtc, in mtk_drm_crtc_init_comp_planes() argument
718 int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx); in mtk_drm_crtc_init_comp_planes()
719 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[comp_idx]; in mtk_drm_crtc_init_comp_planes()
724 &mtk_crtc->planes[mtk_crtc->layer_nr], in mtk_drm_crtc_init_comp_planes()
726 mtk_drm_crtc_plane_type(mtk_crtc->layer_nr, in mtk_drm_crtc_init_comp_planes()
732 mtk_crtc->layer_nr++; in mtk_drm_crtc_init_comp_planes()
742 struct mtk_drm_crtc *mtk_crtc; in mtk_drm_crtc_create() local
766 mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL); in mtk_drm_crtc_create()
767 if (!mtk_crtc) in mtk_drm_crtc_create()
770 mtk_crtc->mmsys_dev = priv->mmsys_dev; in mtk_drm_crtc_create()
771 mtk_crtc->ddp_comp_nr = path_len; in mtk_drm_crtc_create()
772 mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, in mtk_drm_crtc_create()
773 sizeof(*mtk_crtc->ddp_comp), in mtk_drm_crtc_create()
775 if (!mtk_crtc->ddp_comp) in mtk_drm_crtc_create()
778 mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe); in mtk_drm_crtc_create()
779 if (IS_ERR(mtk_crtc->mutex)) { in mtk_drm_crtc_create()
780 ret = PTR_ERR(mtk_crtc->mutex); in mtk_drm_crtc_create()
785 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_crtc_create()
798 mtk_crtc->ddp_comp[i] = comp; in mtk_drm_crtc_create()
809 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_drm_crtc_create()
810 num_comp_planes += mtk_drm_crtc_num_comp_planes(mtk_crtc, i); in mtk_drm_crtc_create()
812 mtk_crtc->planes = devm_kcalloc(dev, num_comp_planes, in mtk_drm_crtc_create()
814 if (!mtk_crtc->planes) in mtk_drm_crtc_create()
817 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_crtc_create()
818 ret = mtk_drm_crtc_init_comp_planes(drm_dev, mtk_crtc, i, in mtk_drm_crtc_create()
824 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, pipe); in mtk_drm_crtc_create()
829 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, gamma_lut_size); in mtk_drm_crtc_create()
830 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, has_ctm, gamma_lut_size); in mtk_drm_crtc_create()
832 mutex_init(&mtk_crtc->hw_lock); in mtk_drm_crtc_create()
835 mtk_crtc->cmdq_client = in mtk_drm_crtc_create()
836 cmdq_mbox_create(mtk_crtc->mmsys_dev, in mtk_drm_crtc_create()
837 drm_crtc_index(&mtk_crtc->base), in mtk_drm_crtc_create()
839 if (IS_ERR(mtk_crtc->cmdq_client)) { in mtk_drm_crtc_create()
841 drm_crtc_index(&mtk_crtc->base)); in mtk_drm_crtc_create()
842 mtk_crtc->cmdq_client = NULL; in mtk_drm_crtc_create()
845 if (mtk_crtc->cmdq_client) { in mtk_drm_crtc_create()
848 drm_crtc_index(&mtk_crtc->base), in mtk_drm_crtc_create()
849 &mtk_crtc->cmdq_event); in mtk_drm_crtc_create()
852 drm_crtc_index(&mtk_crtc->base)); in mtk_drm_crtc_create()
853 cmdq_mbox_destroy(mtk_crtc->cmdq_client); in mtk_drm_crtc_create()
854 mtk_crtc->cmdq_client = NULL; in mtk_drm_crtc_create()