Lines Matching refs:mtk_crtc

71 static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc)  in mtk_drm_crtc_finish_page_flip()  argument
73 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_drm_crtc_finish_page_flip()
77 drm_crtc_send_vblank_event(crtc, mtk_crtc->event); in mtk_drm_crtc_finish_page_flip()
79 mtk_crtc->event = NULL; in mtk_drm_crtc_finish_page_flip()
83 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) in mtk_drm_finish_page_flip() argument
85 drm_crtc_handle_vblank(&mtk_crtc->base); in mtk_drm_finish_page_flip()
86 if (mtk_crtc->pending_needs_vblank) { in mtk_drm_finish_page_flip()
87 mtk_drm_crtc_finish_page_flip(mtk_crtc); in mtk_drm_finish_page_flip()
88 mtk_crtc->pending_needs_vblank = false; in mtk_drm_finish_page_flip()
94 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_destroy() local
96 mtk_disp_mutex_put(mtk_crtc->mutex); in mtk_drm_crtc_destroy()
164 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_enable_vblank() local
165 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_enable_vblank()
167 mtk_ddp_comp_enable_vblank(comp, &mtk_crtc->base); in mtk_drm_crtc_enable_vblank()
174 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_disable_vblank() local
175 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_disable_vblank()
180 static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_enable() argument
186 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_clk_enable()
187 ret = clk_prepare_enable(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
197 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
201 static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_disable() argument
206 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_clk_disable()
207 clk_disable_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_disable()
210 static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_init() argument
212 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_crtc_ddp_hw_init()
249 ret = mtk_disp_mutex_prepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
255 ret = mtk_crtc_ddp_clk_enable(mtk_crtc); in mtk_crtc_ddp_hw_init()
262 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_init()
263 mtk_ddp_add_comp_to_path(mtk_crtc->config_regs, in mtk_crtc_ddp_hw_init()
264 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_init()
265 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_init()
266 mtk_disp_mutex_add_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_init()
267 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
269 mtk_disp_mutex_add_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
270 mtk_disp_mutex_enable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
272 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_hw_init()
273 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i]; in mtk_crtc_ddp_hw_init()
280 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_hw_init()
281 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_hw_init()
285 mtk_ddp_comp_layer_config(mtk_crtc->ddp_comp[0], i, in mtk_crtc_ddp_hw_init()
292 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
298 static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_fini() argument
300 struct drm_device *drm = mtk_crtc->base.dev; in mtk_crtc_ddp_hw_fini()
304 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_hw_fini()
305 mtk_ddp_comp_stop(mtk_crtc->ddp_comp[i]); in mtk_crtc_ddp_hw_fini()
306 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_hw_fini()
307 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
308 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
309 mtk_disp_mutex_disable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
310 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_fini()
311 mtk_ddp_remove_comp_from_path(mtk_crtc->config_regs, in mtk_crtc_ddp_hw_fini()
312 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_fini()
313 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_fini()
314 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
315 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
317 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
318 mtk_crtc_ddp_clk_disable(mtk_crtc); in mtk_crtc_ddp_hw_fini()
319 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
326 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_config() local
327 struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state); in mtk_crtc_ddp_config()
328 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_crtc_ddp_config()
344 if (mtk_crtc->pending_planes) { in mtk_crtc_ddp_config()
345 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_config()
346 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_config()
356 mtk_crtc->pending_planes = false; in mtk_crtc_ddp_config()
363 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_enable() local
364 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_enable()
375 ret = mtk_crtc_ddp_hw_init(mtk_crtc); in mtk_drm_crtc_atomic_enable()
382 mtk_crtc->enabled = true; in mtk_drm_crtc_atomic_enable()
388 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_disable() local
389 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_disable()
393 if (!mtk_crtc->enabled) in mtk_drm_crtc_atomic_disable()
397 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_atomic_disable()
398 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_atomic_disable()
405 mtk_crtc->pending_planes = true; in mtk_drm_crtc_atomic_disable()
411 mtk_crtc_ddp_hw_fini(mtk_crtc); in mtk_drm_crtc_atomic_disable()
414 mtk_crtc->enabled = false; in mtk_drm_crtc_atomic_disable()
421 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_begin() local
423 if (mtk_crtc->event && state->base.event) in mtk_drm_crtc_atomic_begin()
429 mtk_crtc->event = state->base.event; in mtk_drm_crtc_atomic_begin()
437 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_flush() local
442 if (mtk_crtc->event) in mtk_drm_crtc_atomic_flush()
443 mtk_crtc->pending_needs_vblank = true; in mtk_drm_crtc_atomic_flush()
444 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_atomic_flush()
445 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_atomic_flush()
456 mtk_crtc->pending_planes = true; in mtk_drm_crtc_atomic_flush()
458 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_drm_crtc_atomic_flush()
459 mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state); in mtk_drm_crtc_atomic_flush()
462 mtk_disp_mutex_acquire(mtk_crtc->mutex); in mtk_drm_crtc_atomic_flush()
464 mtk_disp_mutex_release(mtk_crtc->mutex); in mtk_drm_crtc_atomic_flush()
490 struct mtk_drm_crtc *mtk_crtc, in mtk_drm_crtc_init() argument
496 ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor, in mtk_drm_crtc_init()
501 drm_crtc_helper_add(&mtk_crtc->base, &mtk_crtc_helper_funcs); in mtk_drm_crtc_init()
506 drm_crtc_cleanup(&mtk_crtc->base); in mtk_drm_crtc_init()
512 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_irq() local
518 mtk_drm_finish_page_flip(mtk_crtc); in mtk_crtc_ddp_irq()
526 struct mtk_drm_crtc *mtk_crtc; in mtk_drm_crtc_create() local
549 mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL); in mtk_drm_crtc_create()
550 if (!mtk_crtc) in mtk_drm_crtc_create()
553 mtk_crtc->config_regs = priv->config_regs; in mtk_drm_crtc_create()
554 mtk_crtc->ddp_comp_nr = path_len; in mtk_drm_crtc_create()
555 mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, in mtk_drm_crtc_create()
556 sizeof(*mtk_crtc->ddp_comp), in mtk_drm_crtc_create()
558 if (!mtk_crtc->ddp_comp) in mtk_drm_crtc_create()
561 mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe); in mtk_drm_crtc_create()
562 if (IS_ERR(mtk_crtc->mutex)) { in mtk_drm_crtc_create()
563 ret = PTR_ERR(mtk_crtc->mutex); in mtk_drm_crtc_create()
568 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_crtc_create()
581 mtk_crtc->ddp_comp[i] = comp; in mtk_drm_crtc_create()
584 mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]); in mtk_drm_crtc_create()
585 mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr, in mtk_drm_crtc_create()
589 for (zpos = 0; zpos < mtk_crtc->layer_nr; zpos++) { in mtk_drm_crtc_create()
593 ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], in mtk_drm_crtc_create()
599 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0], in mtk_drm_crtc_create()
600 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] : in mtk_drm_crtc_create()
604 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE); in mtk_drm_crtc_create()
605 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE); in mtk_drm_crtc_create()