Lines Matching +full:1000 +full:base +full:- +full:t

1 // SPDX-License-Identifier: GPL-2.0
30 for_each_new_connector_in_state(crtc_st->state, conn, conn_st, i) { in komeda_crtc_get_color_config()
31 if (conn_st->crtc != crtc_st->crtc) in komeda_crtc_get_color_config()
34 conn_bpc = conn->display_info.bpc ? conn->display_info.bpc : 8; in komeda_crtc_get_color_config()
35 conn_color_formats &= conn->display_info.color_formats; in komeda_crtc_get_color_config()
41 /* connector doesn't config any color_format, use RGB444 as default */ in komeda_crtc_get_color_config()
53 if (!kcrtc_st->base.active) { in komeda_crtc_update_clock_ratio()
54 kcrtc_st->clock_ratio = 0; in komeda_crtc_update_clock_ratio()
58 pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock * 1000ULL; in komeda_crtc_update_clock_ratio()
61 kcrtc_st->clock_ratio = div64_u64(aclk << 32, pxlclk); in komeda_crtc_update_clock_ratio()
65 * komeda_crtc_atomic_check - build display output data flow
74 * Zero for success or -errno
89 if (crtc_state->active) { in komeda_crtc_atomic_check()
96 err = komeda_release_unclaimed_resources(kcrtc->slave, kcrtc_st); in komeda_crtc_atomic_check()
100 err = komeda_release_unclaimed_resources(kcrtc->master, kcrtc_st); in komeda_crtc_atomic_check()
114 struct komeda_dev *mdev = kcrtc->base.dev->dev_private; in komeda_crtc_prepare()
115 struct komeda_pipeline *master = kcrtc->master; in komeda_crtc_prepare()
116 struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(kcrtc->base.state); in komeda_crtc_prepare()
117 struct drm_display_mode *mode = &kcrtc_st->base.adjusted_mode; in komeda_crtc_prepare()
121 mutex_lock(&mdev->lock); in komeda_crtc_prepare()
123 new_mode = mdev->dpmode | BIT(master->id); in komeda_crtc_prepare()
124 if (WARN_ON(new_mode == mdev->dpmode)) { in komeda_crtc_prepare()
129 err = mdev->funcs->change_opmode(mdev, new_mode); in komeda_crtc_prepare()
131 DRM_ERROR("failed to change opmode: 0x%x -> 0x%x.\n,", in komeda_crtc_prepare()
132 mdev->dpmode, new_mode); in komeda_crtc_prepare()
136 mdev->dpmode = new_mode; in komeda_crtc_prepare()
143 err = clk_set_rate(mdev->aclk, komeda_crtc_get_aclk(kcrtc_st)); in komeda_crtc_prepare()
146 err = clk_prepare_enable(mdev->aclk); in komeda_crtc_prepare()
151 err = clk_set_rate(master->pxlclk, mode->crtc_clock * 1000); in komeda_crtc_prepare()
153 DRM_ERROR("failed to set pxlclk for pipe%d\n", master->id); in komeda_crtc_prepare()
154 err = clk_prepare_enable(master->pxlclk); in komeda_crtc_prepare()
156 DRM_ERROR("failed to enable pxl clk for pipe%d.\n", master->id); in komeda_crtc_prepare()
159 mutex_unlock(&mdev->lock); in komeda_crtc_prepare()
167 struct komeda_dev *mdev = kcrtc->base.dev->dev_private; in komeda_crtc_unprepare()
168 struct komeda_pipeline *master = kcrtc->master; in komeda_crtc_unprepare()
172 mutex_lock(&mdev->lock); in komeda_crtc_unprepare()
174 new_mode = mdev->dpmode & (~BIT(master->id)); in komeda_crtc_unprepare()
176 if (WARN_ON(new_mode == mdev->dpmode)) { in komeda_crtc_unprepare()
181 err = mdev->funcs->change_opmode(mdev, new_mode); in komeda_crtc_unprepare()
183 DRM_ERROR("failed to change opmode: 0x%x -> 0x%x.\n,", in komeda_crtc_unprepare()
184 mdev->dpmode, new_mode); in komeda_crtc_unprepare()
188 mdev->dpmode = new_mode; in komeda_crtc_unprepare()
190 clk_disable_unprepare(master->pxlclk); in komeda_crtc_unprepare()
192 clk_disable_unprepare(mdev->aclk); in komeda_crtc_unprepare()
195 mutex_unlock(&mdev->lock); in komeda_crtc_unprepare()
203 struct drm_crtc *crtc = &kcrtc->base; in komeda_crtc_handle_event()
204 u32 events = evts->pipes[kcrtc->master->id]; in komeda_crtc_handle_event()
210 struct komeda_wb_connector *wb_conn = kcrtc->wb_conn; in komeda_crtc_handle_event()
213 drm_writeback_signal_completion(&wb_conn->base, 0); in komeda_crtc_handle_event()
216 drm_crtc_index(&kcrtc->base)); in komeda_crtc_handle_event()
226 spin_lock_irqsave(&crtc->dev->event_lock, flags); in komeda_crtc_handle_event()
227 if (kcrtc->disable_done) { in komeda_crtc_handle_event()
228 complete_all(kcrtc->disable_done); in komeda_crtc_handle_event()
229 kcrtc->disable_done = NULL; in komeda_crtc_handle_event()
230 } else if (crtc->state->event) { in komeda_crtc_handle_event()
231 event = crtc->state->event; in komeda_crtc_handle_event()
236 crtc->state->event = NULL; in komeda_crtc_handle_event()
240 drm_crtc_index(&kcrtc->base)); in komeda_crtc_handle_event()
242 spin_unlock_irqrestore(&crtc->dev->event_lock, flags); in komeda_crtc_handle_event()
251 struct komeda_crtc_state *kcrtc_st = to_kcrtc_st(crtc->state); in komeda_crtc_do_flush()
252 struct komeda_dev *mdev = kcrtc->base.dev->dev_private; in komeda_crtc_do_flush()
253 struct komeda_pipeline *master = kcrtc->master; in komeda_crtc_do_flush()
254 struct komeda_pipeline *slave = kcrtc->slave; in komeda_crtc_do_flush()
255 struct komeda_wb_connector *wb_conn = kcrtc->wb_conn; in komeda_crtc_do_flush()
260 kcrtc_st->active_pipes, kcrtc_st->affected_pipes); in komeda_crtc_do_flush()
263 if (has_bit(master->id, kcrtc_st->affected_pipes)) in komeda_crtc_do_flush()
264 komeda_pipeline_update(master, old->state); in komeda_crtc_do_flush()
266 if (slave && has_bit(slave->id, kcrtc_st->affected_pipes)) in komeda_crtc_do_flush()
267 komeda_pipeline_update(slave, old->state); in komeda_crtc_do_flush()
269 conn_st = wb_conn ? wb_conn->base.base.state : NULL; in komeda_crtc_do_flush()
270 if (conn_st && conn_st->writeback_job) in komeda_crtc_do_flush()
271 drm_writeback_queue_job(&wb_conn->base, conn_st); in komeda_crtc_do_flush()
274 mdev->funcs->flush(mdev, master->id, kcrtc_st->active_pipes); in komeda_crtc_do_flush()
283 pm_runtime_get_sync(crtc->dev->dev); in komeda_crtc_atomic_enable()
294 struct drm_device *drm = kcrtc->base.dev; in komeda_crtc_flush_and_wait_for_flip_done()
295 struct komeda_dev *mdev = kcrtc->master->mdev; in komeda_crtc_flush_and_wait_for_flip_done()
299 /* if caller doesn't send a flip_done, use a private flip_done */ in komeda_crtc_flush_and_wait_for_flip_done()
304 kcrtc->disable_done = &temp; in komeda_crtc_flush_and_wait_for_flip_done()
308 mdev->funcs->flush(mdev, kcrtc->master->id, 0); in komeda_crtc_flush_and_wait_for_flip_done()
312 DRM_ERROR("wait pipe%d flip done timeout\n", kcrtc->master->id); in komeda_crtc_flush_and_wait_for_flip_done()
316 spin_lock_irqsave(&drm->event_lock, flags); in komeda_crtc_flush_and_wait_for_flip_done()
317 kcrtc->disable_done = NULL; in komeda_crtc_flush_and_wait_for_flip_done()
318 spin_unlock_irqrestore(&drm->event_lock, flags); in komeda_crtc_flush_and_wait_for_flip_done()
331 struct komeda_pipeline *master = kcrtc->master; in komeda_crtc_atomic_disable()
332 struct komeda_pipeline *slave = kcrtc->slave; in komeda_crtc_atomic_disable()
338 old_st->active_pipes, old_st->affected_pipes); in komeda_crtc_atomic_disable()
340 if (slave && has_bit(slave->id, old_st->active_pipes)) in komeda_crtc_atomic_disable()
341 komeda_pipeline_disable(slave, old->state); in komeda_crtc_atomic_disable()
343 if (has_bit(master->id, old_st->active_pipes)) in komeda_crtc_atomic_disable()
344 needs_phase2 = komeda_pipeline_disable(master, old->state); in komeda_crtc_atomic_disable()
346 /* crtc_disable has two scenarios according to the state->active switch. in komeda_crtc_atomic_disable()
347 * 1. active -> inactive in komeda_crtc_atomic_disable()
350 * use the crtc->state->event to tracking the HW disable operation. in komeda_crtc_atomic_disable()
351 * 2. active -> active in komeda_crtc_atomic_disable()
352 * the crtc->commit is not for disable, but a modeset operation when in komeda_crtc_atomic_disable()
356 * so on this case the crtc->commit is for the whole process. in komeda_crtc_atomic_disable()
358 * flip_done for tracing the disable. and crtc->state->event for in komeda_crtc_atomic_disable()
363 disable_done = (needs_phase2 || crtc->state->active) ? in komeda_crtc_atomic_disable()
364 NULL : &crtc->state->commit->flip_done; in komeda_crtc_atomic_disable()
371 komeda_pipeline_disable(kcrtc->master, old->state); in komeda_crtc_atomic_disable()
373 disable_done = crtc->state->active ? in komeda_crtc_atomic_disable()
374 NULL : &crtc->state->commit->flip_done; in komeda_crtc_atomic_disable()
382 pm_runtime_put(crtc->dev->dev); in komeda_crtc_atomic_disable()
405 /* Once dual-link one display pipeline drives two display outputs, in komeda_calc_min_aclk_rate()
408 if (kcrtc->master->dual_link) in komeda_calc_min_aclk_rate()
417 struct drm_crtc *crtc = kcrtc_st->base.crtc; in komeda_crtc_get_aclk()
418 struct komeda_dev *mdev = crtc->dev->dev_private; in komeda_crtc_get_aclk()
419 unsigned long pxlclk = kcrtc_st->base.adjusted_mode.crtc_clock * 1000; in komeda_crtc_get_aclk()
424 return clk_round_rate(mdev->aclk, min_aclk); in komeda_crtc_get_aclk()
430 struct komeda_dev *mdev = crtc->dev->dev_private; in komeda_crtc_mode_valid()
432 struct komeda_pipeline *master = kcrtc->master; in komeda_crtc_mode_valid()
435 if (m->flags & DRM_MODE_FLAG_INTERLACE) in komeda_crtc_mode_valid()
438 min_pxlclk = m->clock * 1000; in komeda_crtc_mode_valid()
439 if (master->dual_link) in komeda_crtc_mode_valid()
442 if (min_pxlclk != clk_round_rate(master->pxlclk, min_pxlclk)) { in komeda_crtc_mode_valid()
443 DRM_DEBUG_ATOMIC("pxlclk doesn't support %lu Hz\n", min_pxlclk); in komeda_crtc_mode_valid()
449 if (clk_round_rate(mdev->aclk, min_aclk) < min_aclk) { in komeda_crtc_mode_valid()
450 DRM_DEBUG_ATOMIC("engine clk can't satisfy the requirement of %s-clk: %lu.\n", in komeda_crtc_mode_valid()
451 m->name, min_pxlclk); in komeda_crtc_mode_valid()
468 if (kcrtc->master->dual_link) { in komeda_crtc_mode_fixup()
469 adjusted_mode->crtc_clock /= 2; in komeda_crtc_mode_fixup()
470 adjusted_mode->crtc_hdisplay /= 2; in komeda_crtc_mode_fixup()
471 adjusted_mode->crtc_hsync_start /= 2; in komeda_crtc_mode_fixup()
472 adjusted_mode->crtc_hsync_end /= 2; in komeda_crtc_mode_fixup()
473 adjusted_mode->crtc_htotal /= 2; in komeda_crtc_mode_fixup()
476 clk_rate = adjusted_mode->crtc_clock * 1000; in komeda_crtc_mode_fixup()
478 adjusted_mode->crtc_clock = clk_round_rate(kcrtc->master->pxlclk, in komeda_crtc_mode_fixup()
479 clk_rate) / 1000; in komeda_crtc_mode_fixup()
497 if (crtc->state) in komeda_crtc_reset()
498 __drm_atomic_helper_crtc_destroy_state(crtc->state); in komeda_crtc_reset()
500 kfree(to_kcrtc_st(crtc->state)); in komeda_crtc_reset()
501 crtc->state = NULL; in komeda_crtc_reset()
505 __drm_atomic_helper_crtc_reset(crtc, &state->base); in komeda_crtc_reset()
511 struct komeda_crtc_state *old = to_kcrtc_st(crtc->state); in komeda_crtc_atomic_duplicate_state()
518 __drm_atomic_helper_crtc_duplicate_state(crtc, &new->base); in komeda_crtc_atomic_duplicate_state()
520 new->affected_pipes = old->active_pipes; in komeda_crtc_atomic_duplicate_state()
521 new->clock_ratio = old->clock_ratio; in komeda_crtc_atomic_duplicate_state()
522 new->max_slave_zorder = old->max_slave_zorder; in komeda_crtc_atomic_duplicate_state()
524 return &new->base; in komeda_crtc_atomic_duplicate_state()
536 struct komeda_dev *mdev = crtc->dev->dev_private; in komeda_crtc_vblank_enable()
539 mdev->funcs->on_off_vblank(mdev, kcrtc->master->id, true); in komeda_crtc_vblank_enable()
545 struct komeda_dev *mdev = crtc->dev->dev_private; in komeda_crtc_vblank_disable()
548 mdev->funcs->on_off_vblank(mdev, kcrtc->master->id, false); in komeda_crtc_vblank_disable()
570 kms->n_crtcs = 0; in komeda_kms_setup_crtcs()
572 for (i = 0; i < mdev->n_pipelines; i++) { in komeda_kms_setup_crtcs()
573 crtc = &kms->crtcs[kms->n_crtcs]; in komeda_kms_setup_crtcs()
574 master = mdev->pipelines[i]; in komeda_kms_setup_crtcs()
576 crtc->master = master; in komeda_kms_setup_crtcs()
577 crtc->slave = komeda_pipeline_get_slave(master); in komeda_kms_setup_crtcs()
579 if (crtc->slave) in komeda_kms_setup_crtcs()
580 sprintf(str, "pipe-%d", crtc->slave->id); in komeda_kms_setup_crtcs()
584 DRM_INFO("CRTC-%d: master(pipe-%d) slave(%s).\n", in komeda_kms_setup_crtcs()
585 kms->n_crtcs, master->id, str); in komeda_kms_setup_crtcs()
587 kms->n_crtcs++; in komeda_kms_setup_crtcs()
599 drm_for_each_plane(plane, &kms->base) { in get_crtc_primary()
600 if (plane->type != DRM_PLANE_TYPE_PRIMARY) in get_crtc_primary()
605 if (kplane->layer->base.pipeline == crtc->master) in get_crtc_primary()
619 bridge = devm_drm_of_get_bridge(dev, pipe->of_node, in komeda_attach_bridge()
623 of_node_full_name(pipe->of_node)); in komeda_attach_bridge()
628 of_node_full_name(pipe->of_node)); in komeda_attach_bridge()
636 struct drm_crtc *crtc = &kcrtc->base; in komeda_crtc_add()
637 struct drm_device *base = &kms->base; in komeda_crtc_add() local
638 struct komeda_pipeline *pipe = kcrtc->master; in komeda_crtc_add()
639 struct drm_encoder *encoder = &kcrtc->encoder; in komeda_crtc_add()
642 err = drm_crtc_init_with_planes(base, crtc, in komeda_crtc_add()
650 crtc->port = pipe->of_output_port; in komeda_crtc_add()
655 kcrtc->encoder.possible_crtcs = drm_crtc_mask(crtc); in komeda_crtc_add()
656 err = drm_simple_encoder_init(base, encoder, DRM_MODE_ENCODER_TMDS); in komeda_crtc_add()
660 if (pipe->of_output_links[0]) { in komeda_crtc_add()
661 err = komeda_attach_bridge(base->dev, pipe, encoder); in komeda_crtc_add()
677 for (i = 0; i < kms->n_crtcs; i++) { in komeda_kms_add_crtcs()
678 err = komeda_crtc_add(kms, &kms->crtcs[i]); in komeda_kms_add_crtcs()