Lines Matching refs:mtk_crtc
77 static void mtk_drm_crtc_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) in mtk_drm_crtc_finish_page_flip() argument
79 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_drm_crtc_finish_page_flip()
83 drm_crtc_send_vblank_event(crtc, mtk_crtc->event); in mtk_drm_crtc_finish_page_flip()
85 mtk_crtc->event = NULL; in mtk_drm_crtc_finish_page_flip()
89 static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) in mtk_drm_finish_page_flip() argument
91 drm_crtc_handle_vblank(&mtk_crtc->base); in mtk_drm_finish_page_flip()
92 if (mtk_crtc->pending_needs_vblank) { in mtk_drm_finish_page_flip()
93 mtk_drm_crtc_finish_page_flip(mtk_crtc); in mtk_drm_finish_page_flip()
94 mtk_crtc->pending_needs_vblank = false; in mtk_drm_finish_page_flip()
100 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_destroy() local
103 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_drm_crtc_destroy()
104 clk_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_drm_crtc_destroy()
106 mtk_disp_mutex_put(mtk_crtc->mutex); in mtk_drm_crtc_destroy()
174 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_enable_vblank() local
175 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_enable_vblank()
177 mtk_ddp_comp_enable_vblank(comp, &mtk_crtc->base); in mtk_drm_crtc_enable_vblank()
184 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_disable_vblank() local
185 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_disable_vblank()
190 static int mtk_crtc_ddp_clk_enable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_enable() argument
196 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_clk_enable()
197 ret = clk_enable(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
207 clk_disable(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_enable()
211 static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_clk_disable() argument
216 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_clk_disable()
217 clk_disable(mtk_crtc->ddp_comp[i]->clk); in mtk_crtc_ddp_clk_disable()
220 static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_init() argument
222 struct drm_crtc *crtc = &mtk_crtc->base; in mtk_crtc_ddp_hw_init()
259 ret = mtk_disp_mutex_prepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
265 ret = mtk_crtc_ddp_clk_enable(mtk_crtc); in mtk_crtc_ddp_hw_init()
272 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_init()
273 mtk_ddp_add_comp_to_path(mtk_crtc->config_regs, in mtk_crtc_ddp_hw_init()
274 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_init()
275 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_init()
276 mtk_disp_mutex_add_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_init()
277 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
279 mtk_disp_mutex_add_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_init()
280 mtk_disp_mutex_enable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
282 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_crtc_ddp_hw_init()
283 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[i]; in mtk_crtc_ddp_hw_init()
290 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_hw_init()
291 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_hw_init()
295 mtk_ddp_comp_layer_config(mtk_crtc->ddp_comp[0], i, in mtk_crtc_ddp_hw_init()
302 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_init()
308 static void mtk_crtc_ddp_hw_fini(struct mtk_drm_crtc *mtk_crtc) in mtk_crtc_ddp_hw_fini() argument
310 struct drm_device *drm = mtk_crtc->base.dev; in mtk_crtc_ddp_hw_fini()
314 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_hw_fini()
315 mtk_ddp_comp_stop(mtk_crtc->ddp_comp[i]); in mtk_crtc_ddp_hw_fini()
316 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_crtc_ddp_hw_fini()
317 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
318 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
319 mtk_disp_mutex_disable(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
320 for (i = 0; i < mtk_crtc->ddp_comp_nr - 1; i++) { in mtk_crtc_ddp_hw_fini()
321 mtk_ddp_remove_comp_from_path(mtk_crtc->config_regs, in mtk_crtc_ddp_hw_fini()
322 mtk_crtc->ddp_comp[i]->id, in mtk_crtc_ddp_hw_fini()
323 mtk_crtc->ddp_comp[i + 1]->id); in mtk_crtc_ddp_hw_fini()
324 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, in mtk_crtc_ddp_hw_fini()
325 mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
327 mtk_disp_mutex_remove_comp(mtk_crtc->mutex, mtk_crtc->ddp_comp[i]->id); in mtk_crtc_ddp_hw_fini()
328 mtk_crtc_ddp_clk_disable(mtk_crtc); in mtk_crtc_ddp_hw_fini()
329 mtk_disp_mutex_unprepare(mtk_crtc->mutex); in mtk_crtc_ddp_hw_fini()
336 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_config() local
337 struct mtk_crtc_state *state = to_mtk_crtc_state(mtk_crtc->base.state); in mtk_crtc_ddp_config()
338 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_crtc_ddp_config()
354 if (mtk_crtc->pending_planes) { in mtk_crtc_ddp_config()
355 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_crtc_ddp_config()
356 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_crtc_ddp_config()
366 mtk_crtc->pending_planes = false; in mtk_crtc_ddp_config()
373 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_enable() local
374 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_enable()
385 ret = mtk_crtc_ddp_hw_init(mtk_crtc); in mtk_drm_crtc_atomic_enable()
392 mtk_crtc->enabled = true; in mtk_drm_crtc_atomic_enable()
398 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_disable() local
399 struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0]; in mtk_drm_crtc_atomic_disable()
403 if (!mtk_crtc->enabled) in mtk_drm_crtc_atomic_disable()
407 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_atomic_disable()
408 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_atomic_disable()
415 mtk_crtc->pending_planes = true; in mtk_drm_crtc_atomic_disable()
421 mtk_crtc_ddp_hw_fini(mtk_crtc); in mtk_drm_crtc_atomic_disable()
424 mtk_crtc->enabled = false; in mtk_drm_crtc_atomic_disable()
431 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_begin() local
433 if (mtk_crtc->event && state->base.event) in mtk_drm_crtc_atomic_begin()
439 mtk_crtc->event = state->base.event; in mtk_drm_crtc_atomic_begin()
447 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_drm_crtc_atomic_flush() local
452 if (mtk_crtc->event) in mtk_drm_crtc_atomic_flush()
453 mtk_crtc->pending_needs_vblank = true; in mtk_drm_crtc_atomic_flush()
454 for (i = 0; i < mtk_crtc->layer_nr; i++) { in mtk_drm_crtc_atomic_flush()
455 struct drm_plane *plane = &mtk_crtc->planes[i]; in mtk_drm_crtc_atomic_flush()
466 mtk_crtc->pending_planes = true; in mtk_drm_crtc_atomic_flush()
468 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) in mtk_drm_crtc_atomic_flush()
469 mtk_ddp_gamma_set(mtk_crtc->ddp_comp[i], crtc->state); in mtk_drm_crtc_atomic_flush()
472 mtk_disp_mutex_acquire(mtk_crtc->mutex); in mtk_drm_crtc_atomic_flush()
474 mtk_disp_mutex_release(mtk_crtc->mutex); in mtk_drm_crtc_atomic_flush()
500 struct mtk_drm_crtc *mtk_crtc, in mtk_drm_crtc_init() argument
506 ret = drm_crtc_init_with_planes(drm, &mtk_crtc->base, primary, cursor, in mtk_drm_crtc_init()
511 drm_crtc_helper_add(&mtk_crtc->base, &mtk_crtc_helper_funcs); in mtk_drm_crtc_init()
516 drm_crtc_cleanup(&mtk_crtc->base); in mtk_drm_crtc_init()
522 struct mtk_drm_crtc *mtk_crtc = to_mtk_crtc(crtc); in mtk_crtc_ddp_irq() local
528 mtk_drm_finish_page_flip(mtk_crtc); in mtk_crtc_ddp_irq()
536 struct mtk_drm_crtc *mtk_crtc; in mtk_drm_crtc_create() local
559 mtk_crtc = devm_kzalloc(dev, sizeof(*mtk_crtc), GFP_KERNEL); in mtk_drm_crtc_create()
560 if (!mtk_crtc) in mtk_drm_crtc_create()
563 mtk_crtc->config_regs = priv->config_regs; in mtk_drm_crtc_create()
564 mtk_crtc->ddp_comp_nr = path_len; in mtk_drm_crtc_create()
565 mtk_crtc->ddp_comp = devm_kmalloc_array(dev, mtk_crtc->ddp_comp_nr, in mtk_drm_crtc_create()
566 sizeof(*mtk_crtc->ddp_comp), in mtk_drm_crtc_create()
568 if (!mtk_crtc->ddp_comp) in mtk_drm_crtc_create()
571 mtk_crtc->mutex = mtk_disp_mutex_get(priv->mutex_dev, pipe); in mtk_drm_crtc_create()
572 if (IS_ERR(mtk_crtc->mutex)) { in mtk_drm_crtc_create()
573 ret = PTR_ERR(mtk_crtc->mutex); in mtk_drm_crtc_create()
578 for (i = 0; i < mtk_crtc->ddp_comp_nr; i++) { in mtk_drm_crtc_create()
599 mtk_crtc->ddp_comp[i] = comp; in mtk_drm_crtc_create()
602 mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]); in mtk_drm_crtc_create()
603 mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr, in mtk_drm_crtc_create()
607 for (zpos = 0; zpos < mtk_crtc->layer_nr; zpos++) { in mtk_drm_crtc_create()
611 ret = mtk_plane_init(drm_dev, &mtk_crtc->planes[zpos], in mtk_drm_crtc_create()
617 ret = mtk_drm_crtc_init(drm_dev, mtk_crtc, &mtk_crtc->planes[0], in mtk_drm_crtc_create()
618 mtk_crtc->layer_nr > 1 ? &mtk_crtc->planes[1] : in mtk_drm_crtc_create()
622 drm_mode_crtc_set_gamma_size(&mtk_crtc->base, MTK_LUT_SIZE); in mtk_drm_crtc_create()
623 drm_crtc_enable_color_mgmt(&mtk_crtc->base, 0, false, MTK_LUT_SIZE); in mtk_drm_crtc_create()
630 clk_unprepare(mtk_crtc->ddp_comp[i]->clk); in mtk_drm_crtc_create()