2 * Copyright 2016 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
26 #include "dm_services.h"
27 #include "core_types.h"
29 #include "custom_float.h"
30 #include "dcn10_hw_sequencer.h"
31 #include "dce110/dce110_hw_sequencer.h"
32 #include "dce/dce_hwseq.h"
35 #include "dcn10/dcn10_timing_generator.h"
36 #include "dcn10/dcn10_dpp.h"
37 #include "dcn10/dcn10_mpc.h"
38 #include "timing_generator.h"
42 #include "reg_helper.h"
43 #include "custom_float.h"
44 #include "dcn10_hubp.h"
45 #include "dcn10_hubbub.h"
53 #define FN(reg_name, field_name) \
54 hws->shifts->field_name, hws->masks->field_name
56 #define DTN_INFO_MICRO_SEC(ref_cycle) \
57 print_microsec(dc_ctx, ref_cycle)
59 void print_microsec(struct dc_context *dc_ctx, uint32_t ref_cycle)
61 static const uint32_t ref_clk_mhz = 48;
62 static const unsigned int frac = 10;
63 uint32_t us_x10 = (ref_cycle * frac) / ref_clk_mhz;
71 static void log_mpc_crc(struct dc *dc)
73 struct dc_context *dc_ctx = dc->ctx;
74 struct dce_hwseq *hws = dc->hwseq;
76 if (REG(MPC_CRC_RESULT_GB))
77 DTN_INFO("MPC_CRC_RESULT_GB:%d MPC_CRC_RESULT_C:%d MPC_CRC_RESULT_AR:%d\n",
78 REG_READ(MPC_CRC_RESULT_GB), REG_READ(MPC_CRC_RESULT_C), REG_READ(MPC_CRC_RESULT_AR));
79 if (REG(DPP_TOP0_DPP_CRC_VAL_B_A))
80 DTN_INFO("DPP_TOP0_DPP_CRC_VAL_B_A:%d DPP_TOP0_DPP_CRC_VAL_R_G:%d\n",
81 REG_READ(DPP_TOP0_DPP_CRC_VAL_B_A), REG_READ(DPP_TOP0_DPP_CRC_VAL_R_G));
84 void dcn10_log_hubbub_state(struct dc *dc)
86 struct dc_context *dc_ctx = dc->ctx;
87 struct dcn_hubbub_wm wm;
90 hubbub1_wm_read_state(dc->res_pool->hubbub, &wm);
92 DTN_INFO("HUBBUB WM: \t data_urgent \t pte_meta_urgent \t "
93 "sr_enter \t sr_exit \t dram_clk_change \n");
95 for (i = 0; i < 4; i++) {
96 struct dcn_hubbub_wm_set *s;
99 DTN_INFO("WM_Set[%d]:\t ", s->wm_set);
100 DTN_INFO_MICRO_SEC(s->data_urgent);
101 DTN_INFO_MICRO_SEC(s->pte_meta_urgent);
102 DTN_INFO_MICRO_SEC(s->sr_enter);
103 DTN_INFO_MICRO_SEC(s->sr_exit);
104 DTN_INFO_MICRO_SEC(s->dram_clk_chanage);
111 void dcn10_log_hw_state(struct dc *dc)
113 struct dc_context *dc_ctx = dc->ctx;
114 struct resource_pool *pool = dc->res_pool;
119 dcn10_log_hubbub_state(dc);
121 DTN_INFO("HUBP:\t format \t addr_hi \t width \t height \t "
122 "rotation \t mirror \t sw_mode \t "
123 "dcc_en \t blank_en \t ttu_dis \t underflow \t "
124 "min_ttu_vblank \t qos_low_wm \t qos_high_wm \n");
126 for (i = 0; i < pool->pipe_count; i++) {
127 struct hubp *hubp = pool->hubps[i];
128 struct dcn_hubp_state s;
130 hubp1_read_state(TO_DCN10_HUBP(hubp), &s);
132 DTN_INFO("[%d]:\t %xh \t %xh \t %d \t %d \t "
133 "%xh \t %xh \t %xh \t "
134 "%d \t %d \t %d \t %xh \t",
147 DTN_INFO_MICRO_SEC(s.min_ttu_vblank);
148 DTN_INFO_MICRO_SEC(s.qos_level_low_wm);
149 DTN_INFO_MICRO_SEC(s.qos_level_high_wm);
154 DTN_INFO("OTG:\t v_bs \t v_be \t v_ss \t v_se \t vpol \t vmax \t vmin \t "
155 "h_bs \t h_be \t h_ss \t h_se \t hpol \t htot \t vtot \t underflow\n");
157 for (i = 0; i < pool->res_cap->num_timing_generator; i++) {
158 struct timing_generator *tg = pool->timing_generators[i];
159 struct dcn_otg_state s = {0};
161 tgn10_read_otg_state(DCN10TG_FROM_TG(tg), &s);
163 //only print if OTG master is enabled
164 if ((s.otg_enabled & 1) == 0)
167 DTN_INFO("[%d]:\t %d \t %d \t %d \t %d \t "
168 "%d \t %d \t %d \t %d \t %d \t %d \t "
169 "%d \t %d \t %d \t %d \t %d \t ",
185 s.underflow_occurred_status);
195 static void enable_dppclk(
196 struct dce_hwseq *hws,
198 uint32_t requested_pix_clk,
201 dm_logger_write(hws->ctx->logger, LOG_SURFACE,
202 "dppclk_rate_control for pipe %d programed to %d\n",
206 if (hws->shifts->DPPCLK_RATE_CONTROL)
207 REG_UPDATE_2(DPP_CONTROL[plane_id],
208 DPPCLK_RATE_CONTROL, dppclk_div,
209 DPP_CLOCK_ENABLE, 1);
211 REG_UPDATE(DPP_CONTROL[plane_id],
212 DPP_CLOCK_ENABLE, 1);
215 static void enable_power_gating_plane(
216 struct dce_hwseq *hws,
219 bool force_on = 1; /* disable power gating */
225 REG_UPDATE(DOMAIN0_PG_CONFIG, DOMAIN0_POWER_FORCEON, force_on);
226 REG_UPDATE(DOMAIN2_PG_CONFIG, DOMAIN2_POWER_FORCEON, force_on);
227 REG_UPDATE(DOMAIN4_PG_CONFIG, DOMAIN4_POWER_FORCEON, force_on);
228 REG_UPDATE(DOMAIN6_PG_CONFIG, DOMAIN6_POWER_FORCEON, force_on);
231 REG_UPDATE(DOMAIN1_PG_CONFIG, DOMAIN1_POWER_FORCEON, force_on);
232 REG_UPDATE(DOMAIN3_PG_CONFIG, DOMAIN3_POWER_FORCEON, force_on);
233 REG_UPDATE(DOMAIN5_PG_CONFIG, DOMAIN5_POWER_FORCEON, force_on);
234 REG_UPDATE(DOMAIN7_PG_CONFIG, DOMAIN7_POWER_FORCEON, force_on);
237 static void disable_vga(
238 struct dce_hwseq *hws)
240 REG_WRITE(D1VGA_CONTROL, 0);
241 REG_WRITE(D2VGA_CONTROL, 0);
242 REG_WRITE(D3VGA_CONTROL, 0);
243 REG_WRITE(D4VGA_CONTROL, 0);
246 static void dpp_pg_control(
247 struct dce_hwseq *hws,
248 unsigned int dpp_inst,
251 uint32_t power_gate = power_on ? 0 : 1;
252 uint32_t pwr_status = power_on ? 0 : 2;
254 if (hws->ctx->dc->debug.disable_dpp_power_gate)
259 REG_UPDATE(DOMAIN1_PG_CONFIG,
260 DOMAIN1_POWER_GATE, power_gate);
262 REG_WAIT(DOMAIN1_PG_STATUS,
263 DOMAIN1_PGFSM_PWR_STATUS, pwr_status,
267 REG_UPDATE(DOMAIN3_PG_CONFIG,
268 DOMAIN3_POWER_GATE, power_gate);
270 REG_WAIT(DOMAIN3_PG_STATUS,
271 DOMAIN3_PGFSM_PWR_STATUS, pwr_status,
275 REG_UPDATE(DOMAIN5_PG_CONFIG,
276 DOMAIN5_POWER_GATE, power_gate);
278 REG_WAIT(DOMAIN5_PG_STATUS,
279 DOMAIN5_PGFSM_PWR_STATUS, pwr_status,
283 REG_UPDATE(DOMAIN7_PG_CONFIG,
284 DOMAIN7_POWER_GATE, power_gate);
286 REG_WAIT(DOMAIN7_PG_STATUS,
287 DOMAIN7_PGFSM_PWR_STATUS, pwr_status,
296 static void hubp_pg_control(
297 struct dce_hwseq *hws,
298 unsigned int hubp_inst,
301 uint32_t power_gate = power_on ? 0 : 1;
302 uint32_t pwr_status = power_on ? 0 : 2;
304 if (hws->ctx->dc->debug.disable_hubp_power_gate)
308 case 0: /* DCHUBP0 */
309 REG_UPDATE(DOMAIN0_PG_CONFIG,
310 DOMAIN0_POWER_GATE, power_gate);
312 REG_WAIT(DOMAIN0_PG_STATUS,
313 DOMAIN0_PGFSM_PWR_STATUS, pwr_status,
316 case 1: /* DCHUBP1 */
317 REG_UPDATE(DOMAIN2_PG_CONFIG,
318 DOMAIN2_POWER_GATE, power_gate);
320 REG_WAIT(DOMAIN2_PG_STATUS,
321 DOMAIN2_PGFSM_PWR_STATUS, pwr_status,
324 case 2: /* DCHUBP2 */
325 REG_UPDATE(DOMAIN4_PG_CONFIG,
326 DOMAIN4_POWER_GATE, power_gate);
328 REG_WAIT(DOMAIN4_PG_STATUS,
329 DOMAIN4_PGFSM_PWR_STATUS, pwr_status,
332 case 3: /* DCHUBP3 */
333 REG_UPDATE(DOMAIN6_PG_CONFIG,
334 DOMAIN6_POWER_GATE, power_gate);
336 REG_WAIT(DOMAIN6_PG_STATUS,
337 DOMAIN6_PGFSM_PWR_STATUS, pwr_status,
346 static void power_on_plane(
347 struct dce_hwseq *hws,
350 if (REG(DC_IP_REQUEST_CNTL)) {
351 REG_SET(DC_IP_REQUEST_CNTL, 0,
353 dpp_pg_control(hws, plane_id, true);
354 hubp_pg_control(hws, plane_id, true);
355 REG_SET(DC_IP_REQUEST_CNTL, 0,
357 dm_logger_write(hws->ctx->logger, LOG_DEBUG,
358 "Un-gated front end for pipe %d\n", plane_id);
362 static void undo_DEGVIDCN10_253_wa(struct dc *dc)
364 struct dce_hwseq *hws = dc->hwseq;
365 struct hubp *hubp = dc->res_pool->hubps[0];
367 if (!hws->wa_state.DEGVIDCN10_253_applied)
370 hubp->funcs->set_blank(hubp, true);
372 REG_SET(DC_IP_REQUEST_CNTL, 0,
375 hubp_pg_control(hws, 0, false);
376 REG_SET(DC_IP_REQUEST_CNTL, 0,
379 hws->wa_state.DEGVIDCN10_253_applied = false;
382 static void apply_DEGVIDCN10_253_wa(struct dc *dc)
384 struct dce_hwseq *hws = dc->hwseq;
385 struct hubp *hubp = dc->res_pool->hubps[0];
388 if (dc->debug.disable_stutter)
391 if (!hws->wa.DEGVIDCN10_253)
394 for (i = 0; i < dc->res_pool->pipe_count; i++) {
395 if (!dc->res_pool->hubps[i]->power_gated)
399 /* all pipe power gated, apply work around to enable stutter. */
401 REG_SET(DC_IP_REQUEST_CNTL, 0,
404 hubp_pg_control(hws, 0, true);
405 REG_SET(DC_IP_REQUEST_CNTL, 0,
408 hubp->funcs->set_hubp_blank_en(hubp, false);
409 hws->wa_state.DEGVIDCN10_253_applied = true;
412 static void bios_golden_init(struct dc *dc)
414 struct dc_bios *bp = dc->ctx->dc_bios;
417 /* initialize dcn global */
418 bp->funcs->enable_disp_power_gating(bp,
419 CONTROLLER_ID_D0, ASIC_PIPE_INIT);
421 for (i = 0; i < dc->res_pool->pipe_count; i++) {
422 /* initialize dcn per pipe */
423 bp->funcs->enable_disp_power_gating(bp,
424 CONTROLLER_ID_D0 + i, ASIC_PIPE_DISABLE);
428 static void false_optc_underflow_wa(
430 const struct dc_stream_state *stream,
431 struct timing_generator *tg)
436 if (!dc->hwseq->wa.false_optc_underflow)
439 underflow = tg->funcs->is_optc_underflow_occurred(tg);
441 for (i = 0; i < dc->res_pool->pipe_count; i++) {
442 struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
444 if (old_pipe_ctx->stream != stream)
447 dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, old_pipe_ctx);
450 tg->funcs->set_blank_data_double_buffer(tg, true);
452 if (tg->funcs->is_optc_underflow_occurred(tg) && !underflow)
453 tg->funcs->clear_optc_underflow(tg);
456 static enum dc_status dcn10_prog_pixclk_crtc_otg(
457 struct pipe_ctx *pipe_ctx,
458 struct dc_state *context,
461 struct dc_stream_state *stream = pipe_ctx->stream;
462 enum dc_color_space color_space;
463 struct tg_color black_color = {0};
464 bool enableStereo = stream->timing.timing_3d_format == TIMING_3D_FORMAT_NONE ?
466 bool rightEyePolarity = stream->timing.flags.RIGHT_EYE_3D_POLARITY;
468 /* by upper caller loop, pipe0 is parent pipe and be called first.
469 * back end is set up by for pipe0. Other children pipe share back end
470 * with pipe 0. No program is needed.
472 if (pipe_ctx->top_pipe != NULL)
475 /* TODO check if timing_changed, disable stream if timing changed */
477 /* HW program guide assume display already disable
478 * by unplug sequence. OTG assume stop.
480 pipe_ctx->stream_res.tg->funcs->enable_optc_clock(pipe_ctx->stream_res.tg, true);
482 if (false == pipe_ctx->clock_source->funcs->program_pix_clk(
483 pipe_ctx->clock_source,
484 &pipe_ctx->stream_res.pix_clk_params,
485 &pipe_ctx->pll_settings)) {
487 return DC_ERROR_UNEXPECTED;
489 pipe_ctx->stream_res.tg->dlg_otg_param.vready_offset = pipe_ctx->pipe_dlg_param.vready_offset;
490 pipe_ctx->stream_res.tg->dlg_otg_param.vstartup_start = pipe_ctx->pipe_dlg_param.vstartup_start;
491 pipe_ctx->stream_res.tg->dlg_otg_param.vupdate_offset = pipe_ctx->pipe_dlg_param.vupdate_offset;
492 pipe_ctx->stream_res.tg->dlg_otg_param.vupdate_width = pipe_ctx->pipe_dlg_param.vupdate_width;
494 pipe_ctx->stream_res.tg->dlg_otg_param.signal = pipe_ctx->stream->signal;
496 pipe_ctx->stream_res.tg->funcs->program_timing(
497 pipe_ctx->stream_res.tg,
501 pipe_ctx->stream_res.opp->funcs->opp_set_stereo_polarity(
502 pipe_ctx->stream_res.opp,
506 #if 0 /* move to after enable_crtc */
507 /* TODO: OPP FMT, ABM. etc. should be done here. */
508 /* or FPGA now. instance 0 only. TODO: move to opp.c */
510 inst_offset = reg_offsets[pipe_ctx->stream_res.tg->inst].fmt;
512 pipe_ctx->stream_res.opp->funcs->opp_program_fmt(
513 pipe_ctx->stream_res.opp,
514 &stream->bit_depth_params,
517 /* program otg blank color */
518 color_space = stream->output_color_space;
519 color_space_to_black_color(dc, color_space, &black_color);
520 pipe_ctx->stream_res.tg->funcs->set_blank_color(
521 pipe_ctx->stream_res.tg,
524 if (!pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg)) {
525 pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, true);
526 hwss_wait_for_blank_complete(pipe_ctx->stream_res.tg);
527 false_optc_underflow_wa(dc, pipe_ctx->stream, pipe_ctx->stream_res.tg);
530 /* VTG is within DCHUB command block. DCFCLK is always on */
531 if (false == pipe_ctx->stream_res.tg->funcs->enable_crtc(pipe_ctx->stream_res.tg)) {
533 return DC_ERROR_UNEXPECTED;
536 /* TODO program crtc source select for non-virtual signal*/
537 /* TODO program FMT */
538 /* TODO setup link_enc */
539 /* TODO set stream attributes */
540 /* TODO program audio */
541 /* TODO enable stream if timing changed */
542 /* TODO unblank stream if DP */
547 static void reset_back_end_for_pipe(
549 struct pipe_ctx *pipe_ctx,
550 struct dc_state *context)
554 if (pipe_ctx->stream_res.stream_enc == NULL) {
555 pipe_ctx->stream = NULL;
559 if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
560 /* DPMS may already disable */
561 if (!pipe_ctx->stream->dpms_off)
562 core_link_disable_stream(pipe_ctx, FREE_ACQUIRED_RESOURCE);
565 /* by upper caller loop, parent pipe: pipe0, will be reset last.
566 * back end share by all pipes and will be disable only when disable
569 if (pipe_ctx->top_pipe == NULL) {
570 pipe_ctx->stream_res.tg->funcs->disable_crtc(pipe_ctx->stream_res.tg);
572 pipe_ctx->stream_res.tg->funcs->enable_optc_clock(pipe_ctx->stream_res.tg, false);
575 for (i = 0; i < dc->res_pool->pipe_count; i++)
576 if (&dc->current_state->res_ctx.pipe_ctx[i] == pipe_ctx)
579 if (i == dc->res_pool->pipe_count)
582 pipe_ctx->stream = NULL;
583 dm_logger_write(dc->ctx->logger, LOG_DEBUG,
584 "Reset back end for pipe %d, tg:%d\n",
585 pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst);
588 static void dcn10_verify_allow_pstate_change_high(struct dc *dc)
590 static bool should_log_hw_state; /* prevent hw state log by default */
592 if (!hubbub1_verify_allow_pstate_change_high(dc->res_pool->hubbub)) {
593 if (should_log_hw_state) {
594 dcn10_log_hw_state(dc);
601 /* trigger HW to start disconnect plane from stream on the next vsync */
602 static void plane_atomic_disconnect(struct dc *dc, struct pipe_ctx *pipe_ctx)
604 int fe_idx = pipe_ctx->pipe_idx;
605 struct hubp *hubp = dc->res_pool->hubps[fe_idx];
606 struct mpc *mpc = dc->res_pool->mpc;
608 struct mpc_tree *mpc_tree_params;
609 struct mpcc *mpcc_to_remove = NULL;
611 /* look at tree rather than mi here to know if we already reset */
612 for (opp_id = 0; opp_id < dc->res_pool->pipe_count; opp_id++) {
613 struct output_pixel_processor *opp = dc->res_pool->opps[opp_id];
615 mpc_tree_params = &(opp->mpc_tree_params);
616 mpcc_to_remove = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, fe_idx);
617 if (mpcc_to_remove != NULL)
622 if (opp_id == dc->res_pool->pipe_count)
625 mpc->funcs->remove_mpcc(mpc, mpc_tree_params, mpcc_to_remove);
626 dc->res_pool->opps[opp_id]->mpcc_disconnect_pending[fe_idx] = true;
628 dc->optimized_required = true;
630 if (hubp->funcs->hubp_disconnect)
631 hubp->funcs->hubp_disconnect(hubp);
633 if (dc->debug.sanity_checks)
634 dcn10_verify_allow_pstate_change_high(dc);
637 static void plane_atomic_power_down(struct dc *dc, int fe_idx)
639 struct dce_hwseq *hws = dc->hwseq;
640 struct dpp *dpp = dc->res_pool->dpps[fe_idx];
642 if (REG(DC_IP_REQUEST_CNTL)) {
643 REG_SET(DC_IP_REQUEST_CNTL, 0,
645 dpp_pg_control(hws, fe_idx, false);
646 hubp_pg_control(hws, fe_idx, false);
647 dpp->funcs->dpp_reset(dpp);
648 REG_SET(DC_IP_REQUEST_CNTL, 0,
650 dm_logger_write(dc->ctx->logger, LOG_DEBUG,
651 "Power gated front end %d\n", fe_idx);
655 /* disable HW used by plane.
656 * note: cannot disable until disconnect is complete
658 static void plane_atomic_disable(struct dc *dc, struct pipe_ctx *pipe_ctx)
660 int fe_idx = pipe_ctx->pipe_idx;
661 struct dce_hwseq *hws = dc->hwseq;
662 struct hubp *hubp = dc->res_pool->hubps[fe_idx];
663 int opp_id = hubp->opp_id;
665 dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe_ctx);
667 REG_UPDATE(HUBP_CLK_CNTL[fe_idx],
668 HUBP_CLOCK_ENABLE, 0);
669 REG_UPDATE(DPP_CONTROL[fe_idx],
670 DPP_CLOCK_ENABLE, 0);
672 if (opp_id != 0xf && dc->res_pool->opps[opp_id]->mpc_tree_params.opp_list == NULL)
673 REG_UPDATE(OPP_PIPE_CONTROL[opp_id],
674 OPP_PIPE_CLOCK_EN, 0);
676 hubp->power_gated = true;
677 dc->optimized_required = false; /* We're powering off, no need to optimize */
679 plane_atomic_power_down(dc, fe_idx);
681 pipe_ctx->stream = NULL;
682 memset(&pipe_ctx->stream_res, 0, sizeof(pipe_ctx->stream_res));
683 memset(&pipe_ctx->plane_res, 0, sizeof(pipe_ctx->plane_res));
684 pipe_ctx->top_pipe = NULL;
685 pipe_ctx->bottom_pipe = NULL;
686 pipe_ctx->plane_state = NULL;
689 static void dcn10_disable_plane(struct dc *dc, struct pipe_ctx *pipe_ctx)
691 if (dc->res_pool->hubps[pipe_ctx->pipe_idx]->power_gated)
694 plane_atomic_disable(dc, pipe_ctx);
696 apply_DEGVIDCN10_253_wa(dc);
698 dm_logger_write(dc->ctx->logger, LOG_DC,
699 "Power down front end %d\n",
703 static void dcn10_init_hw(struct dc *dc)
706 struct abm *abm = dc->res_pool->abm;
707 struct dmcu *dmcu = dc->res_pool->dmcu;
708 struct dce_hwseq *hws = dc->hwseq;
709 struct dc_bios *dcb = dc->ctx->dc_bios;
710 struct dc_state *context = dc->current_state;
712 if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment)) {
713 REG_WRITE(REFCLK_CNTL, 0);
714 REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, 1);
715 REG_WRITE(DIO_MEM_PWR_CTRL, 0);
717 if (!dc->debug.disable_clock_gate) {
718 /* enable all DCN clock gating */
719 REG_WRITE(DCCG_GATE_DISABLE_CNTL, 0);
721 REG_WRITE(DCCG_GATE_DISABLE_CNTL2, 0);
723 REG_UPDATE(DCFCLK_CNTL, DCFCLK_GATE_DIS, 0);
726 enable_power_gating_plane(dc->hwseq, true);
729 /* end of FPGA. Below if real ASIC */
731 if (!dcb->funcs->is_accelerated_mode(dcb)) {
732 bios_golden_init(dc);
733 disable_vga(dc->hwseq);
736 for (i = 0; i < dc->link_count; i++) {
737 /* Power up AND update implementation according to the
738 * required signal (which may be different from the
739 * default signal on connector).
741 struct dc_link *link = dc->links[i];
743 if (link->link_enc->connector.id == CONNECTOR_ID_EDP)
744 dc->hwss.edp_power_control(link, true);
746 link->link_enc->funcs->hw_init(link->link_enc);
749 for (i = 0; i < dc->res_pool->pipe_count; i++) {
750 struct timing_generator *tg = dc->res_pool->timing_generators[i];
752 if (tg->funcs->is_tg_enabled(tg))
756 /* Blank controller using driver code instead of
759 for (i = 0; i < dc->res_pool->pipe_count; i++) {
760 struct timing_generator *tg = dc->res_pool->timing_generators[i];
762 if (tg->funcs->is_tg_enabled(tg)) {
763 tg->funcs->set_blank(tg, true);
764 hwss_wait_for_blank_complete(tg);
768 /* Initialize MPC tree based on HW values */
769 for (opp_id = 0; opp_id < dc->res_pool->pipe_count; opp_id++) {
770 struct output_pixel_processor *opp = dc->res_pool->opps[opp_id];
771 struct mpc_tree *mpc_tree_params = &(opp->mpc_tree_params);
773 dc->res_pool->mpc->funcs->init_mpcc_list_from_hw(dc->res_pool->mpc, mpc_tree_params);
776 for (i = 0; i < dc->res_pool->pipe_count; i++) {
777 struct timing_generator *tg = dc->res_pool->timing_generators[i];
778 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
779 struct hubp *hubp = dc->res_pool->hubps[i];
781 pipe_ctx->stream_res.tg = tg;
782 pipe_ctx->pipe_idx = i;
784 pipe_ctx->plane_res.hubp = hubp;
786 hubp->opp_id = dc->res_pool->mpc->funcs->get_opp_id(dc->res_pool->mpc, i);
787 hubp->power_gated = false;
789 if (hubp->opp_id != 0xf)
790 pipe_ctx->stream_res.opp = dc->res_pool->opps[hubp->opp_id];
792 plane_atomic_disconnect(dc, pipe_ctx);
795 for (i = 0; i < dc->res_pool->pipe_count; i++) {
796 struct timing_generator *tg = dc->res_pool->timing_generators[i];
798 if (tg->funcs->is_tg_enabled(tg))
799 tg->funcs->unlock(tg);
802 for (i = 0; i < dc->res_pool->pipe_count; i++) {
803 struct timing_generator *tg = dc->res_pool->timing_generators[i];
804 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
806 dcn10_disable_plane(dc, pipe_ctx);
808 pipe_ctx->stream_res.tg = NULL;
809 pipe_ctx->plane_res.hubp = NULL;
811 tg->funcs->tg_init(tg);
814 for (i = 0; i < dc->res_pool->audio_count; i++) {
815 struct audio *audio = dc->res_pool->audios[i];
817 audio->funcs->hw_init(audio);
821 abm->funcs->init_backlight(abm);
822 abm->funcs->abm_init(abm);
826 dmcu->funcs->dmcu_init(dmcu);
828 /* power AFMT HDMI memory TODO: may move to dis/en output save power*/
829 REG_WRITE(DIO_MEM_PWR_CTRL, 0);
831 if (!dc->debug.disable_clock_gate) {
832 /* enable all DCN clock gating */
833 REG_WRITE(DCCG_GATE_DISABLE_CNTL, 0);
835 REG_WRITE(DCCG_GATE_DISABLE_CNTL2, 0);
837 REG_UPDATE(DCFCLK_CNTL, DCFCLK_GATE_DIS, 0);
840 enable_power_gating_plane(dc->hwseq, true);
843 static void reset_hw_ctx_wrap(
845 struct dc_state *context)
850 for (i = dc->res_pool->pipe_count - 1; i >= 0 ; i--) {
851 struct pipe_ctx *pipe_ctx_old =
852 &dc->current_state->res_ctx.pipe_ctx[i];
853 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
855 if (!pipe_ctx_old->stream)
858 if (pipe_ctx_old->top_pipe)
861 if (!pipe_ctx->stream ||
862 pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
863 struct clock_source *old_clk = pipe_ctx_old->clock_source;
865 reset_back_end_for_pipe(dc, pipe_ctx_old, dc->current_state);
867 old_clk->funcs->cs_power_down(old_clk);
873 static bool patch_address_for_sbs_tb_stereo(
874 struct pipe_ctx *pipe_ctx, PHYSICAL_ADDRESS_LOC *addr)
876 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
877 bool sec_split = pipe_ctx->top_pipe &&
878 pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;
879 if (sec_split && plane_state->address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
880 (pipe_ctx->stream->timing.timing_3d_format ==
881 TIMING_3D_FORMAT_SIDE_BY_SIDE ||
882 pipe_ctx->stream->timing.timing_3d_format ==
883 TIMING_3D_FORMAT_TOP_AND_BOTTOM)) {
884 *addr = plane_state->address.grph_stereo.left_addr;
885 plane_state->address.grph_stereo.left_addr =
886 plane_state->address.grph_stereo.right_addr;
889 if (pipe_ctx->stream->view_format != VIEW_3D_FORMAT_NONE &&
890 plane_state->address.type != PLN_ADDR_TYPE_GRPH_STEREO) {
891 plane_state->address.type = PLN_ADDR_TYPE_GRPH_STEREO;
892 plane_state->address.grph_stereo.right_addr =
893 plane_state->address.grph_stereo.left_addr;
901 static void dcn10_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)
903 bool addr_patched = false;
904 PHYSICAL_ADDRESS_LOC addr;
905 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
907 if (plane_state == NULL)
909 addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);
910 pipe_ctx->plane_res.hubp->funcs->hubp_program_surface_flip_and_addr(
911 pipe_ctx->plane_res.hubp,
912 &plane_state->address,
913 plane_state->flip_immediate);
914 plane_state->status.requested_address = plane_state->address;
916 pipe_ctx->plane_state->address.grph_stereo.left_addr = addr;
919 static bool dcn10_set_input_transfer_func(struct pipe_ctx *pipe_ctx,
920 const struct dc_plane_state *plane_state)
922 struct dpp *dpp_base = pipe_ctx->plane_res.dpp;
923 const struct dc_transfer_func *tf = NULL;
926 if (dpp_base == NULL)
929 if (plane_state->in_transfer_func)
930 tf = plane_state->in_transfer_func;
932 if (plane_state->gamma_correction && dce_use_lut(plane_state))
933 dpp_base->funcs->dpp_program_input_lut(dpp_base, plane_state->gamma_correction);
936 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_BYPASS);
937 else if (tf->type == TF_TYPE_PREDEFINED) {
939 case TRANSFER_FUNCTION_SRGB:
940 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_HW_sRGB);
942 case TRANSFER_FUNCTION_BT709:
943 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_HW_xvYCC);
945 case TRANSFER_FUNCTION_LINEAR:
946 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_BYPASS);
948 case TRANSFER_FUNCTION_PQ:
953 } else if (tf->type == TF_TYPE_BYPASS) {
954 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_BYPASS);
956 /*TF_TYPE_DISTRIBUTED_POINTS*/
962 /*modify the method to handle rgb for arr_points*/
963 static bool convert_to_custom_float(
964 struct pwl_result_data *rgb_resulted,
965 struct curve_points *arr_points,
966 uint32_t hw_points_num)
968 struct custom_float_format fmt;
970 struct pwl_result_data *rgb = rgb_resulted;
974 fmt.exponenta_bits = 6;
975 fmt.mantissa_bits = 12;
978 if (!convert_to_custom_float_format(arr_points[0].x, &fmt,
979 &arr_points[0].custom_float_x)) {
984 if (!convert_to_custom_float_format(arr_points[0].offset, &fmt,
985 &arr_points[0].custom_float_offset)) {
990 if (!convert_to_custom_float_format(arr_points[0].slope, &fmt,
991 &arr_points[0].custom_float_slope)) {
996 fmt.mantissa_bits = 10;
999 if (!convert_to_custom_float_format(arr_points[1].x, &fmt,
1000 &arr_points[1].custom_float_x)) {
1001 BREAK_TO_DEBUGGER();
1005 if (!convert_to_custom_float_format(arr_points[1].y, &fmt,
1006 &arr_points[1].custom_float_y)) {
1007 BREAK_TO_DEBUGGER();
1011 if (!convert_to_custom_float_format(arr_points[1].slope, &fmt,
1012 &arr_points[1].custom_float_slope)) {
1013 BREAK_TO_DEBUGGER();
1017 fmt.mantissa_bits = 12;
1020 while (i != hw_points_num) {
1021 if (!convert_to_custom_float_format(rgb->red, &fmt,
1023 BREAK_TO_DEBUGGER();
1027 if (!convert_to_custom_float_format(rgb->green, &fmt,
1029 BREAK_TO_DEBUGGER();
1033 if (!convert_to_custom_float_format(rgb->blue, &fmt,
1035 BREAK_TO_DEBUGGER();
1039 if (!convert_to_custom_float_format(rgb->delta_red, &fmt,
1040 &rgb->delta_red_reg)) {
1041 BREAK_TO_DEBUGGER();
1045 if (!convert_to_custom_float_format(rgb->delta_green, &fmt,
1046 &rgb->delta_green_reg)) {
1047 BREAK_TO_DEBUGGER();
1051 if (!convert_to_custom_float_format(rgb->delta_blue, &fmt,
1052 &rgb->delta_blue_reg)) {
1053 BREAK_TO_DEBUGGER();
1063 #define MAX_REGIONS_NUMBER 34
1064 #define MAX_LOW_POINT 25
1065 #define NUMBER_SEGMENTS 32
1068 dcn10_translate_regamma_to_hw_format(const struct dc_transfer_func *output_tf,
1069 struct pwl_params *regamma_params)
1071 struct curve_points *arr_points;
1072 struct pwl_result_data *rgb_resulted;
1073 struct pwl_result_data *rgb;
1074 struct pwl_result_data *rgb_plus_1;
1075 struct fixed31_32 y_r;
1076 struct fixed31_32 y_g;
1077 struct fixed31_32 y_b;
1078 struct fixed31_32 y1_min;
1079 struct fixed31_32 y3_max;
1081 int32_t segment_start, segment_end;
1083 uint32_t j, k, seg_distr[MAX_REGIONS_NUMBER], increment, start_index, hw_points;
1085 if (output_tf == NULL || regamma_params == NULL || output_tf->type == TF_TYPE_BYPASS)
1090 arr_points = regamma_params->arr_points;
1091 rgb_resulted = regamma_params->rgb_resulted;
1094 memset(regamma_params, 0, sizeof(struct pwl_params));
1095 memset(seg_distr, 0, sizeof(seg_distr));
1097 if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
1099 * segments are from 2^-25 to 2^7
1101 for (i = 0; i < 32 ; i++)
1104 segment_start = -25;
1108 * segment is from 2^-10 to 2^0
1109 * There are less than 256 points, for optimization
1122 segment_start = -10;
1126 for (i = segment_end - segment_start; i < MAX_REGIONS_NUMBER ; i++)
1129 for (k = 0; k < MAX_REGIONS_NUMBER; k++) {
1130 if (seg_distr[k] != -1)
1131 hw_points += (1 << seg_distr[k]);
1135 for (k = 0; k < (segment_end - segment_start); k++) {
1136 increment = NUMBER_SEGMENTS / (1 << seg_distr[k]);
1137 start_index = (segment_start + k + MAX_LOW_POINT) * NUMBER_SEGMENTS;
1138 for (i = start_index; i < start_index + NUMBER_SEGMENTS; i += increment) {
1139 if (j == hw_points - 1)
1141 rgb_resulted[j].red = output_tf->tf_pts.red[i];
1142 rgb_resulted[j].green = output_tf->tf_pts.green[i];
1143 rgb_resulted[j].blue = output_tf->tf_pts.blue[i];
1149 start_index = (segment_end + MAX_LOW_POINT) * NUMBER_SEGMENTS;
1150 rgb_resulted[hw_points - 1].red = output_tf->tf_pts.red[start_index];
1151 rgb_resulted[hw_points - 1].green = output_tf->tf_pts.green[start_index];
1152 rgb_resulted[hw_points - 1].blue = output_tf->tf_pts.blue[start_index];
1154 arr_points[0].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2),
1155 dal_fixed31_32_from_int(segment_start));
1156 arr_points[1].x = dal_fixed31_32_pow(dal_fixed31_32_from_int(2),
1157 dal_fixed31_32_from_int(segment_end));
1159 y_r = rgb_resulted[0].red;
1160 y_g = rgb_resulted[0].green;
1161 y_b = rgb_resulted[0].blue;
1163 y1_min = dal_fixed31_32_min(y_r, dal_fixed31_32_min(y_g, y_b));
1165 arr_points[0].y = y1_min;
1166 arr_points[0].slope = dal_fixed31_32_div(arr_points[0].y, arr_points[0].x);
1167 y_r = rgb_resulted[hw_points - 1].red;
1168 y_g = rgb_resulted[hw_points - 1].green;
1169 y_b = rgb_resulted[hw_points - 1].blue;
1171 /* see comment above, m_arrPoints[1].y should be the Y value for the
1172 * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
1174 y3_max = dal_fixed31_32_max(y_r, dal_fixed31_32_max(y_g, y_b));
1176 arr_points[1].y = y3_max;
1178 arr_points[1].slope = dal_fixed31_32_zero;
1180 if (output_tf->tf == TRANSFER_FUNCTION_PQ) {
1181 /* for PQ, we want to have a straight line from last HW X point,
1182 * and the slope to be such that we hit 1.0 at 10000 nits.
1184 const struct fixed31_32 end_value =
1185 dal_fixed31_32_from_int(125);
1187 arr_points[1].slope = dal_fixed31_32_div(
1188 dal_fixed31_32_sub(dal_fixed31_32_one, arr_points[1].y),
1189 dal_fixed31_32_sub(end_value, arr_points[1].x));
1192 regamma_params->hw_points_num = hw_points;
1195 for (k = 0; k < MAX_REGIONS_NUMBER && i < MAX_REGIONS_NUMBER; k++) {
1196 if (seg_distr[k] != -1) {
1197 regamma_params->arr_curve_points[k].segments_num =
1199 regamma_params->arr_curve_points[i].offset =
1200 regamma_params->arr_curve_points[k].offset + (1 << seg_distr[k]);
1205 if (seg_distr[k] != -1)
1206 regamma_params->arr_curve_points[k].segments_num = seg_distr[k];
1209 rgb_plus_1 = rgb_resulted + 1;
1213 while (i != hw_points + 1) {
1214 if (dal_fixed31_32_lt(rgb_plus_1->red, rgb->red))
1215 rgb_plus_1->red = rgb->red;
1216 if (dal_fixed31_32_lt(rgb_plus_1->green, rgb->green))
1217 rgb_plus_1->green = rgb->green;
1218 if (dal_fixed31_32_lt(rgb_plus_1->blue, rgb->blue))
1219 rgb_plus_1->blue = rgb->blue;
1221 rgb->delta_red = dal_fixed31_32_sub(rgb_plus_1->red, rgb->red);
1222 rgb->delta_green = dal_fixed31_32_sub(rgb_plus_1->green, rgb->green);
1223 rgb->delta_blue = dal_fixed31_32_sub(rgb_plus_1->blue, rgb->blue);
1230 convert_to_custom_float(rgb_resulted, arr_points, hw_points);
1238 dcn10_set_output_transfer_func(struct pipe_ctx *pipe_ctx,
1239 const struct dc_stream_state *stream)
1241 struct dpp *dpp = pipe_ctx->plane_res.dpp;
1246 dpp->regamma_params.hw_points_num = GAMMA_HW_POINTS_NUM;
1248 if (stream->out_transfer_func &&
1249 stream->out_transfer_func->type == TF_TYPE_PREDEFINED &&
1250 stream->out_transfer_func->tf == TRANSFER_FUNCTION_SRGB)
1251 dpp->funcs->dpp_program_regamma_pwl(dpp, NULL, OPP_REGAMMA_SRGB);
1253 /* dcn10_translate_regamma_to_hw_format takes 750us, only do it when full
1256 else if (dcn10_translate_regamma_to_hw_format(
1257 stream->out_transfer_func,
1258 &dpp->regamma_params)) {
1259 dpp->funcs->dpp_program_regamma_pwl(
1261 &dpp->regamma_params, OPP_REGAMMA_USER);
1263 dpp->funcs->dpp_program_regamma_pwl(dpp, NULL, OPP_REGAMMA_BYPASS);
1268 static void dcn10_pipe_control_lock(
1270 struct pipe_ctx *pipe,
1273 struct hubp *hubp = NULL;
1274 hubp = dc->res_pool->hubps[pipe->pipe_idx];
1275 /* use TG master update lock to lock everything on the TG
1276 * therefore only top pipe need to lock
1281 if (dc->debug.sanity_checks)
1282 dcn10_verify_allow_pstate_change_high(dc);
1285 pipe->stream_res.tg->funcs->lock(pipe->stream_res.tg);
1287 pipe->stream_res.tg->funcs->unlock(pipe->stream_res.tg);
1289 if (dc->debug.sanity_checks)
1290 dcn10_verify_allow_pstate_change_high(dc);
1293 static bool wait_for_reset_trigger_to_occur(
1294 struct dc_context *dc_ctx,
1295 struct timing_generator *tg)
1299 /* To avoid endless loop we wait at most
1300 * frames_to_wait_on_triggered_reset frames for the reset to occur. */
1301 const uint32_t frames_to_wait_on_triggered_reset = 10;
1304 for (i = 0; i < frames_to_wait_on_triggered_reset; i++) {
1306 if (!tg->funcs->is_counter_moving(tg)) {
1307 DC_ERROR("TG counter is not moving!\n");
1311 if (tg->funcs->did_triggered_reset_occur(tg)) {
1313 /* usually occurs at i=1 */
1314 DC_SYNC_INFO("GSL: reset occurred at wait count: %d\n",
1319 /* Wait for one frame. */
1320 tg->funcs->wait_for_state(tg, CRTC_STATE_VACTIVE);
1321 tg->funcs->wait_for_state(tg, CRTC_STATE_VBLANK);
1325 DC_ERROR("GSL: Timeout on reset trigger!\n");
1330 static void dcn10_enable_timing_synchronization(
1334 struct pipe_ctx *grouped_pipes[])
1336 struct dc_context *dc_ctx = dc->ctx;
1339 DC_SYNC_INFO("Setting up OTG reset trigger\n");
1341 for (i = 1; i < group_size; i++)
1342 grouped_pipes[i]->stream_res.tg->funcs->enable_reset_trigger(
1343 grouped_pipes[i]->stream_res.tg,
1344 grouped_pipes[0]->stream_res.tg->inst);
1346 DC_SYNC_INFO("Waiting for trigger\n");
1348 /* Need to get only check 1 pipe for having reset as all the others are
1349 * synchronized. Look at last pipe programmed to reset.
1352 wait_for_reset_trigger_to_occur(dc_ctx, grouped_pipes[1]->stream_res.tg);
1353 for (i = 1; i < group_size; i++)
1354 grouped_pipes[i]->stream_res.tg->funcs->disable_reset_trigger(
1355 grouped_pipes[i]->stream_res.tg);
1357 DC_SYNC_INFO("Sync complete\n");
1360 static void dcn10_enable_per_frame_crtc_position_reset(
1363 struct pipe_ctx *grouped_pipes[])
1365 struct dc_context *dc_ctx = dc->ctx;
1368 DC_SYNC_INFO("Setting up\n");
1369 for (i = 0; i < group_size; i++)
1370 grouped_pipes[i]->stream_res.tg->funcs->enable_crtc_reset(
1371 grouped_pipes[i]->stream_res.tg,
1372 grouped_pipes[i]->stream->triggered_crtc_reset.event_source->status.primary_otg_inst,
1373 &grouped_pipes[i]->stream->triggered_crtc_reset);
1375 DC_SYNC_INFO("Waiting for trigger\n");
1377 for (i = 1; i < group_size; i++)
1378 wait_for_reset_trigger_to_occur(dc_ctx, grouped_pipes[i]->stream_res.tg);
1380 DC_SYNC_INFO("Multi-display sync is complete\n");
1383 /*static void print_rq_dlg_ttu(
1385 struct pipe_ctx *pipe_ctx)
1387 dm_logger_write(core_dc->ctx->logger, LOG_BANDWIDTH_CALCS,
1388 "\n============== DML TTU Output parameters [%d] ==============\n"
1389 "qos_level_low_wm: %d, \n"
1390 "qos_level_high_wm: %d, \n"
1391 "min_ttu_vblank: %d, \n"
1392 "qos_level_flip: %d, \n"
1393 "refcyc_per_req_delivery_l: %d, \n"
1394 "qos_level_fixed_l: %d, \n"
1395 "qos_ramp_disable_l: %d, \n"
1396 "refcyc_per_req_delivery_pre_l: %d, \n"
1397 "refcyc_per_req_delivery_c: %d, \n"
1398 "qos_level_fixed_c: %d, \n"
1399 "qos_ramp_disable_c: %d, \n"
1400 "refcyc_per_req_delivery_pre_c: %d\n"
1401 "=============================================================\n",
1403 pipe_ctx->ttu_regs.qos_level_low_wm,
1404 pipe_ctx->ttu_regs.qos_level_high_wm,
1405 pipe_ctx->ttu_regs.min_ttu_vblank,
1406 pipe_ctx->ttu_regs.qos_level_flip,
1407 pipe_ctx->ttu_regs.refcyc_per_req_delivery_l,
1408 pipe_ctx->ttu_regs.qos_level_fixed_l,
1409 pipe_ctx->ttu_regs.qos_ramp_disable_l,
1410 pipe_ctx->ttu_regs.refcyc_per_req_delivery_pre_l,
1411 pipe_ctx->ttu_regs.refcyc_per_req_delivery_c,
1412 pipe_ctx->ttu_regs.qos_level_fixed_c,
1413 pipe_ctx->ttu_regs.qos_ramp_disable_c,
1414 pipe_ctx->ttu_regs.refcyc_per_req_delivery_pre_c
1417 dm_logger_write(core_dc->ctx->logger, LOG_BANDWIDTH_CALCS,
1418 "\n============== DML DLG Output parameters [%d] ==============\n"
1419 "refcyc_h_blank_end: %d, \n"
1420 "dlg_vblank_end: %d, \n"
1421 "min_dst_y_next_start: %d, \n"
1422 "refcyc_per_htotal: %d, \n"
1423 "refcyc_x_after_scaler: %d, \n"
1424 "dst_y_after_scaler: %d, \n"
1425 "dst_y_prefetch: %d, \n"
1426 "dst_y_per_vm_vblank: %d, \n"
1427 "dst_y_per_row_vblank: %d, \n"
1428 "ref_freq_to_pix_freq: %d, \n"
1429 "vratio_prefetch: %d, \n"
1430 "refcyc_per_pte_group_vblank_l: %d, \n"
1431 "refcyc_per_meta_chunk_vblank_l: %d, \n"
1432 "dst_y_per_pte_row_nom_l: %d, \n"
1433 "refcyc_per_pte_group_nom_l: %d, \n",
1435 pipe_ctx->dlg_regs.refcyc_h_blank_end,
1436 pipe_ctx->dlg_regs.dlg_vblank_end,
1437 pipe_ctx->dlg_regs.min_dst_y_next_start,
1438 pipe_ctx->dlg_regs.refcyc_per_htotal,
1439 pipe_ctx->dlg_regs.refcyc_x_after_scaler,
1440 pipe_ctx->dlg_regs.dst_y_after_scaler,
1441 pipe_ctx->dlg_regs.dst_y_prefetch,
1442 pipe_ctx->dlg_regs.dst_y_per_vm_vblank,
1443 pipe_ctx->dlg_regs.dst_y_per_row_vblank,
1444 pipe_ctx->dlg_regs.ref_freq_to_pix_freq,
1445 pipe_ctx->dlg_regs.vratio_prefetch,
1446 pipe_ctx->dlg_regs.refcyc_per_pte_group_vblank_l,
1447 pipe_ctx->dlg_regs.refcyc_per_meta_chunk_vblank_l,
1448 pipe_ctx->dlg_regs.dst_y_per_pte_row_nom_l,
1449 pipe_ctx->dlg_regs.refcyc_per_pte_group_nom_l
1452 dm_logger_write(core_dc->ctx->logger, LOG_BANDWIDTH_CALCS,
1453 "\ndst_y_per_meta_row_nom_l: %d, \n"
1454 "refcyc_per_meta_chunk_nom_l: %d, \n"
1455 "refcyc_per_line_delivery_pre_l: %d, \n"
1456 "refcyc_per_line_delivery_l: %d, \n"
1457 "vratio_prefetch_c: %d, \n"
1458 "refcyc_per_pte_group_vblank_c: %d, \n"
1459 "refcyc_per_meta_chunk_vblank_c: %d, \n"
1460 "dst_y_per_pte_row_nom_c: %d, \n"
1461 "refcyc_per_pte_group_nom_c: %d, \n"
1462 "dst_y_per_meta_row_nom_c: %d, \n"
1463 "refcyc_per_meta_chunk_nom_c: %d, \n"
1464 "refcyc_per_line_delivery_pre_c: %d, \n"
1465 "refcyc_per_line_delivery_c: %d \n"
1466 "========================================================\n",
1467 pipe_ctx->dlg_regs.dst_y_per_meta_row_nom_l,
1468 pipe_ctx->dlg_regs.refcyc_per_meta_chunk_nom_l,
1469 pipe_ctx->dlg_regs.refcyc_per_line_delivery_pre_l,
1470 pipe_ctx->dlg_regs.refcyc_per_line_delivery_l,
1471 pipe_ctx->dlg_regs.vratio_prefetch_c,
1472 pipe_ctx->dlg_regs.refcyc_per_pte_group_vblank_c,
1473 pipe_ctx->dlg_regs.refcyc_per_meta_chunk_vblank_c,
1474 pipe_ctx->dlg_regs.dst_y_per_pte_row_nom_c,
1475 pipe_ctx->dlg_regs.refcyc_per_pte_group_nom_c,
1476 pipe_ctx->dlg_regs.dst_y_per_meta_row_nom_c,
1477 pipe_ctx->dlg_regs.refcyc_per_meta_chunk_nom_c,
1478 pipe_ctx->dlg_regs.refcyc_per_line_delivery_pre_c,
1479 pipe_ctx->dlg_regs.refcyc_per_line_delivery_c
1482 dm_logger_write(core_dc->ctx->logger, LOG_BANDWIDTH_CALCS,
1483 "\n============== DML RQ Output parameters [%d] ==============\n"
1485 "min_chunk_size: %d \n"
1486 "meta_chunk_size: %d \n"
1487 "min_meta_chunk_size: %d \n"
1488 "dpte_group_size: %d \n"
1489 "mpte_group_size: %d \n"
1490 "swath_height: %d \n"
1491 "pte_row_height_linear: %d \n"
1492 "========================================================\n",
1494 pipe_ctx->rq_regs.rq_regs_l.chunk_size,
1495 pipe_ctx->rq_regs.rq_regs_l.min_chunk_size,
1496 pipe_ctx->rq_regs.rq_regs_l.meta_chunk_size,
1497 pipe_ctx->rq_regs.rq_regs_l.min_meta_chunk_size,
1498 pipe_ctx->rq_regs.rq_regs_l.dpte_group_size,
1499 pipe_ctx->rq_regs.rq_regs_l.mpte_group_size,
1500 pipe_ctx->rq_regs.rq_regs_l.swath_height,
1501 pipe_ctx->rq_regs.rq_regs_l.pte_row_height_linear
1506 static void mmhub_read_vm_system_aperture_settings(struct dcn10_hubp *hubp1,
1507 struct vm_system_aperture_param *apt,
1508 struct dce_hwseq *hws)
1510 PHYSICAL_ADDRESS_LOC physical_page_number;
1511 uint32_t logical_addr_low;
1512 uint32_t logical_addr_high;
1514 REG_GET(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_MSB,
1515 PHYSICAL_PAGE_NUMBER_MSB, &physical_page_number.high_part);
1516 REG_GET(MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR_LSB,
1517 PHYSICAL_PAGE_NUMBER_LSB, &physical_page_number.low_part);
1519 REG_GET(MC_VM_SYSTEM_APERTURE_LOW_ADDR,
1520 LOGICAL_ADDR, &logical_addr_low);
1522 REG_GET(MC_VM_SYSTEM_APERTURE_HIGH_ADDR,
1523 LOGICAL_ADDR, &logical_addr_high);
1525 apt->sys_default.quad_part = physical_page_number.quad_part << 12;
1526 apt->sys_low.quad_part = (int64_t)logical_addr_low << 18;
1527 apt->sys_high.quad_part = (int64_t)logical_addr_high << 18;
1530 /* Temporary read settings, future will get values from kmd directly */
1531 static void mmhub_read_vm_context0_settings(struct dcn10_hubp *hubp1,
1532 struct vm_context0_param *vm0,
1533 struct dce_hwseq *hws)
1535 PHYSICAL_ADDRESS_LOC fb_base;
1536 PHYSICAL_ADDRESS_LOC fb_offset;
1537 uint32_t fb_base_value;
1538 uint32_t fb_offset_value;
1540 REG_GET(DCHUBBUB_SDPIF_FB_BASE, SDPIF_FB_BASE, &fb_base_value);
1541 REG_GET(DCHUBBUB_SDPIF_FB_OFFSET, SDPIF_FB_OFFSET, &fb_offset_value);
1543 REG_GET(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_HI32,
1544 PAGE_DIRECTORY_ENTRY_HI32, &vm0->pte_base.high_part);
1545 REG_GET(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR_LO32,
1546 PAGE_DIRECTORY_ENTRY_LO32, &vm0->pte_base.low_part);
1548 REG_GET(VM_CONTEXT0_PAGE_TABLE_START_ADDR_HI32,
1549 LOGICAL_PAGE_NUMBER_HI4, &vm0->pte_start.high_part);
1550 REG_GET(VM_CONTEXT0_PAGE_TABLE_START_ADDR_LO32,
1551 LOGICAL_PAGE_NUMBER_LO32, &vm0->pte_start.low_part);
1553 REG_GET(VM_CONTEXT0_PAGE_TABLE_END_ADDR_HI32,
1554 LOGICAL_PAGE_NUMBER_HI4, &vm0->pte_end.high_part);
1555 REG_GET(VM_CONTEXT0_PAGE_TABLE_END_ADDR_LO32,
1556 LOGICAL_PAGE_NUMBER_LO32, &vm0->pte_end.low_part);
1558 REG_GET(VM_L2_PROTECTION_FAULT_DEFAULT_ADDR_HI32,
1559 PHYSICAL_PAGE_ADDR_HI4, &vm0->fault_default.high_part);
1560 REG_GET(VM_L2_PROTECTION_FAULT_DEFAULT_ADDR_LO32,
1561 PHYSICAL_PAGE_ADDR_LO32, &vm0->fault_default.low_part);
1564 * The values in VM_CONTEXT0_PAGE_TABLE_BASE_ADDR is in UMA space.
1565 * Therefore we need to do
1566 * DCN_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR = VM_CONTEXT0_PAGE_TABLE_BASE_ADDR
1567 * - DCHUBBUB_SDPIF_FB_OFFSET + DCHUBBUB_SDPIF_FB_BASE
1569 fb_base.quad_part = (uint64_t)fb_base_value << 24;
1570 fb_offset.quad_part = (uint64_t)fb_offset_value << 24;
1571 vm0->pte_base.quad_part += fb_base.quad_part;
1572 vm0->pte_base.quad_part -= fb_offset.quad_part;
1576 static void dcn10_program_pte_vm(struct dce_hwseq *hws, struct hubp *hubp)
1578 struct dcn10_hubp *hubp1 = TO_DCN10_HUBP(hubp);
1579 struct vm_system_aperture_param apt = { {{ 0 } } };
1580 struct vm_context0_param vm0 = { { { 0 } } };
1582 mmhub_read_vm_system_aperture_settings(hubp1, &apt, hws);
1583 mmhub_read_vm_context0_settings(hubp1, &vm0, hws);
1585 hubp->funcs->hubp_set_vm_system_aperture_settings(hubp, &apt);
1586 hubp->funcs->hubp_set_vm_context0_settings(hubp, &vm0);
1589 static void dcn10_enable_plane(
1591 struct pipe_ctx *pipe_ctx,
1592 struct dc_state *context)
1594 struct dce_hwseq *hws = dc->hwseq;
1596 if (dc->debug.sanity_checks) {
1597 dcn10_verify_allow_pstate_change_high(dc);
1600 undo_DEGVIDCN10_253_wa(dc);
1602 power_on_plane(dc->hwseq,
1603 pipe_ctx->pipe_idx);
1605 /* enable DCFCLK current DCHUB */
1606 REG_UPDATE(HUBP_CLK_CNTL[pipe_ctx->pipe_idx],
1607 HUBP_CLOCK_ENABLE, 1);
1609 /* make sure OPP_PIPE_CLOCK_EN = 1 */
1610 REG_UPDATE(OPP_PIPE_CONTROL[pipe_ctx->stream_res.tg->inst],
1611 OPP_PIPE_CLOCK_EN, 1);
1612 /*TODO: REG_UPDATE(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, 0x1f);*/
1614 /* TODO: enable/disable in dm as per update type.
1616 dm_logger_write(dc->ctx->logger, LOG_DC,
1617 "Pipe:%d 0x%x: addr hi:0x%x, "
1620 " %d; dst: %d, %d, %d, %d;\n",
1623 plane_state->address.grph.addr.high_part,
1624 plane_state->address.grph.addr.low_part,
1625 plane_state->src_rect.x,
1626 plane_state->src_rect.y,
1627 plane_state->src_rect.width,
1628 plane_state->src_rect.height,
1629 plane_state->dst_rect.x,
1630 plane_state->dst_rect.y,
1631 plane_state->dst_rect.width,
1632 plane_state->dst_rect.height);
1634 dm_logger_write(dc->ctx->logger, LOG_DC,
1635 "Pipe %d: width, height, x, y format:%d\n"
1636 "viewport:%d, %d, %d, %d\n"
1637 "recout: %d, %d, %d, %d\n",
1639 plane_state->format,
1640 pipe_ctx->plane_res.scl_data.viewport.width,
1641 pipe_ctx->plane_res.scl_data.viewport.height,
1642 pipe_ctx->plane_res.scl_data.viewport.x,
1643 pipe_ctx->plane_res.scl_data.viewport.y,
1644 pipe_ctx->plane_res.scl_data.recout.width,
1645 pipe_ctx->plane_res.scl_data.recout.height,
1646 pipe_ctx->plane_res.scl_data.recout.x,
1647 pipe_ctx->plane_res.scl_data.recout.y);
1648 print_rq_dlg_ttu(dc, pipe_ctx);
1651 if (dc->config.gpu_vm_support)
1652 dcn10_program_pte_vm(hws, pipe_ctx->plane_res.hubp);
1654 if (dc->debug.sanity_checks) {
1655 dcn10_verify_allow_pstate_change_high(dc);
1659 static void program_gamut_remap(struct pipe_ctx *pipe_ctx)
1661 struct dpp_grph_csc_adjustment adjust;
1662 memset(&adjust, 0, sizeof(adjust));
1663 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS;
1666 if (pipe_ctx->stream->gamut_remap_matrix.enable_remap == true) {
1667 adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW;
1668 adjust.temperature_matrix[0] =
1670 gamut_remap_matrix.matrix[0];
1671 adjust.temperature_matrix[1] =
1673 gamut_remap_matrix.matrix[1];
1674 adjust.temperature_matrix[2] =
1676 gamut_remap_matrix.matrix[2];
1677 adjust.temperature_matrix[3] =
1679 gamut_remap_matrix.matrix[4];
1680 adjust.temperature_matrix[4] =
1682 gamut_remap_matrix.matrix[5];
1683 adjust.temperature_matrix[5] =
1685 gamut_remap_matrix.matrix[6];
1686 adjust.temperature_matrix[6] =
1688 gamut_remap_matrix.matrix[8];
1689 adjust.temperature_matrix[7] =
1691 gamut_remap_matrix.matrix[9];
1692 adjust.temperature_matrix[8] =
1694 gamut_remap_matrix.matrix[10];
1697 pipe_ctx->plane_res.dpp->funcs->dpp_set_gamut_remap(pipe_ctx->plane_res.dpp, &adjust);
1701 static void program_csc_matrix(struct pipe_ctx *pipe_ctx,
1702 enum dc_color_space colorspace,
1706 struct out_csc_color_matrix tbl_entry;
1708 if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) {
1709 enum dc_color_space color_space =
1710 pipe_ctx->stream->output_color_space;
1712 //uint16_t matrix[12];
1713 for (i = 0; i < 12; i++)
1714 tbl_entry.regval[i] = pipe_ctx->stream->csc_color_matrix.matrix[i];
1716 tbl_entry.color_space = color_space;
1717 //tbl_entry.regval = matrix;
1719 if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment != NULL)
1720 pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment(pipe_ctx->plane_res.dpp, &tbl_entry);
1722 if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default != NULL)
1723 pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_default(pipe_ctx->plane_res.dpp, colorspace);
1727 static void program_output_csc(struct dc *dc,
1728 struct pipe_ctx *pipe_ctx,
1729 enum dc_color_space colorspace,
1733 if (pipe_ctx->plane_res.dpp->funcs->dpp_set_csc_adjustment != NULL)
1734 program_csc_matrix(pipe_ctx,
1739 static bool is_lower_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
1741 if (pipe_ctx->plane_state->visible)
1743 if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx->bottom_pipe))
1748 static bool is_upper_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
1750 if (pipe_ctx->plane_state->visible)
1752 if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
1757 static bool is_pipe_tree_visible(struct pipe_ctx *pipe_ctx)
1759 if (pipe_ctx->plane_state->visible)
1761 if (pipe_ctx->top_pipe && is_upper_pipe_tree_visible(pipe_ctx->top_pipe))
1763 if (pipe_ctx->bottom_pipe && is_lower_pipe_tree_visible(pipe_ctx->bottom_pipe))
1768 static bool is_rgb_cspace(enum dc_color_space output_color_space)
1770 switch (output_color_space) {
1771 case COLOR_SPACE_SRGB:
1772 case COLOR_SPACE_SRGB_LIMITED:
1773 case COLOR_SPACE_2020_RGB_FULLRANGE:
1774 case COLOR_SPACE_2020_RGB_LIMITEDRANGE:
1775 case COLOR_SPACE_ADOBERGB:
1777 case COLOR_SPACE_YCBCR601:
1778 case COLOR_SPACE_YCBCR709:
1779 case COLOR_SPACE_YCBCR601_LIMITED:
1780 case COLOR_SPACE_YCBCR709_LIMITED:
1781 case COLOR_SPACE_2020_YCBCR:
1784 /* Add a case to switch */
1785 BREAK_TO_DEBUGGER();
1790 static void dcn10_get_surface_visual_confirm_color(
1791 const struct pipe_ctx *pipe_ctx,
1792 struct tg_color *color)
1794 uint32_t color_value = MAX_TG_COLOR_VALUE;
1796 switch (pipe_ctx->plane_res.scl_data.format) {
1797 case PIXEL_FORMAT_ARGB8888:
1798 /* set boarder color to red */
1799 color->color_r_cr = color_value;
1802 case PIXEL_FORMAT_ARGB2101010:
1803 /* set boarder color to blue */
1804 color->color_b_cb = color_value;
1806 case PIXEL_FORMAT_420BPP8:
1807 /* set boarder color to green */
1808 color->color_g_y = color_value;
1810 case PIXEL_FORMAT_420BPP10:
1811 /* set boarder color to yellow */
1812 color->color_g_y = color_value;
1813 color->color_r_cr = color_value;
1815 case PIXEL_FORMAT_FP16:
1816 /* set boarder color to white */
1817 color->color_r_cr = color_value;
1818 color->color_b_cb = color_value;
1819 color->color_g_y = color_value;
1826 static uint16_t fixed_point_to_int_frac(
1827 struct fixed31_32 arg,
1828 uint8_t integer_bits,
1829 uint8_t fractional_bits)
1832 int32_t divisor = 1 << fractional_bits;
1836 uint16_t d = (uint16_t)dal_fixed31_32_floor(
1840 if (d <= (uint16_t)(1 << integer_bits) - (1 / (uint16_t)divisor))
1841 numerator = (uint16_t)dal_fixed31_32_floor(
1842 dal_fixed31_32_mul_int(
1846 numerator = dal_fixed31_32_floor(
1848 dal_fixed31_32_from_int(
1849 1LL << integer_bits),
1850 dal_fixed31_32_recip(
1851 dal_fixed31_32_from_int(
1856 result = (uint16_t)numerator;
1858 result = (uint16_t)(
1859 (1 << (integer_bits + fractional_bits + 1)) + numerator);
1861 if ((result != 0) && dal_fixed31_32_lt(
1862 arg, dal_fixed31_32_zero))
1863 result |= 1 << (integer_bits + fractional_bits);
1868 void build_prescale_params(struct dc_bias_and_scale *bias_and_scale,
1869 const struct dc_plane_state *plane_state)
1871 if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN
1872 && plane_state->format != SURFACE_PIXEL_FORMAT_INVALID
1873 && plane_state->input_csc_color_matrix.enable_adjustment
1874 && plane_state->coeff_reduction_factor.value != 0) {
1875 bias_and_scale->scale_blue = fixed_point_to_int_frac(
1876 dal_fixed31_32_mul(plane_state->coeff_reduction_factor,
1877 dal_fixed31_32_from_fraction(256, 255)),
1880 bias_and_scale->scale_red = bias_and_scale->scale_blue;
1881 bias_and_scale->scale_green = bias_and_scale->scale_blue;
1883 bias_and_scale->scale_blue = 0x2000;
1884 bias_and_scale->scale_red = 0x2000;
1885 bias_and_scale->scale_green = 0x2000;
1889 static void update_dpp(struct dpp *dpp, struct dc_plane_state *plane_state)
1891 struct dc_bias_and_scale bns_params = {0};
1893 // program the input csc
1894 dpp->funcs->dpp_setup(dpp,
1895 plane_state->format,
1896 EXPANSION_MODE_ZERO,
1897 plane_state->input_csc_color_matrix,
1898 COLOR_SPACE_YCBCR601_LIMITED);
1900 //set scale and bias registers
1901 build_prescale_params(&bns_params, plane_state);
1902 if (dpp->funcs->dpp_program_bias_and_scale)
1903 dpp->funcs->dpp_program_bias_and_scale(dpp, &bns_params);
1906 static void update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
1908 struct hubp *hubp = pipe_ctx->plane_res.hubp;
1909 struct mpcc_blnd_cfg blnd_cfg;
1910 bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;
1912 struct mpcc *new_mpcc;
1913 struct mpc *mpc = dc->res_pool->mpc;
1914 struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
1916 /* TODO: proper fix once fpga works */
1918 if (dc->debug.surface_visual_confirm)
1919 dcn10_get_surface_visual_confirm_color(
1920 pipe_ctx, &blnd_cfg.black_color);
1922 color_space_to_black_color(
1923 dc, pipe_ctx->stream->output_color_space,
1924 &blnd_cfg.black_color);
1926 if (per_pixel_alpha)
1927 blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
1929 blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
1931 blnd_cfg.overlap_only = false;
1932 blnd_cfg.global_alpha = 0xff;
1933 blnd_cfg.global_gain = 0xff;
1935 /* DCN1.0 has output CM before MPC which seems to screw with
1936 * pre-multiplied alpha.
1938 blnd_cfg.pre_multiplied_alpha = is_rgb_cspace(
1939 pipe_ctx->stream->output_color_space)
1944 * Note: currently there is a bug in init_hw such that
1945 * on resume from hibernate, BIOS sets up MPCC0, and
1946 * we do mpcc_remove but the mpcc cannot go to idle
1947 * after remove. This cause us to pick mpcc1 here,
1948 * which causes a pstate hang for yet unknown reason.
1950 mpcc_id = hubp->inst;
1952 /* check if this MPCC is already being used */
1953 new_mpcc = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, mpcc_id);
1954 /* remove MPCC if being used */
1955 if (new_mpcc != NULL)
1956 mpc->funcs->remove_mpcc(mpc, mpc_tree_params, new_mpcc);
1958 if (dc->debug.sanity_checks)
1959 mpc->funcs->assert_mpcc_idle_before_connect(
1960 dc->res_pool->mpc, mpcc_id);
1962 /* Call MPC to insert new plane */
1963 new_mpcc = mpc->funcs->insert_plane(dc->res_pool->mpc,
1971 ASSERT(new_mpcc != NULL);
1973 hubp->opp_id = pipe_ctx->stream_res.opp->inst;
1974 hubp->mpcc_id = mpcc_id;
1977 static void update_scaler(struct pipe_ctx *pipe_ctx)
1979 bool per_pixel_alpha =
1980 pipe_ctx->plane_state->per_pixel_alpha && pipe_ctx->bottom_pipe;
1982 /* TODO: proper fix once fpga works */
1984 pipe_ctx->plane_res.scl_data.lb_params.alpha_en = per_pixel_alpha;
1985 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP;
1986 /* scaler configuration */
1987 pipe_ctx->plane_res.dpp->funcs->dpp_set_scaler(
1988 pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data);
1991 static void update_dchubp_dpp(
1993 struct pipe_ctx *pipe_ctx,
1994 struct dc_state *context)
1996 struct dce_hwseq *hws = dc->hwseq;
1997 struct hubp *hubp = pipe_ctx->plane_res.hubp;
1998 struct dpp *dpp = pipe_ctx->plane_res.dpp;
1999 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2000 union plane_size size = plane_state->plane_size;
2002 /* depends on DML calculation, DPP clock value may change dynamically */
2003 if (pipe_ctx->plane_state->update_flags.raw != 0) {
2007 pipe_ctx->stream_res.pix_clk_params.requested_pix_clk,
2008 context->bw.dcn.calc_clk.dppclk_div);
2009 dc->current_state->bw.dcn.cur_clk.dppclk_div =
2010 context->bw.dcn.calc_clk.dppclk_div;
2011 context->bw.dcn.cur_clk.dppclk_div = context->bw.dcn.calc_clk.dppclk_div;
2014 /* TODO: Need input parameter to tell current DCHUB pipe tie to which OTG
2015 * VTG is within DCHUBBUB which is commond block share by each pipe HUBP.
2016 * VTG is 1:1 mapping with OTG. Each pipe HUBP will select which VTG
2018 if (plane_state->update_flags.bits.full_update) {
2019 REG_UPDATE(DCHUBP_CNTL[pipe_ctx->pipe_idx], HUBP_VTG_SEL, pipe_ctx->stream_res.tg->inst);
2021 hubp->funcs->hubp_setup(
2023 &pipe_ctx->dlg_regs,
2024 &pipe_ctx->ttu_regs,
2026 &pipe_ctx->pipe_dlg_param);
2029 size.grph.surface_size = pipe_ctx->plane_res.scl_data.viewport;
2031 if (plane_state->update_flags.bits.full_update ||
2032 plane_state->update_flags.bits.bpp_change)
2033 update_dpp(dpp, plane_state);
2035 if (plane_state->update_flags.bits.full_update ||
2036 plane_state->update_flags.bits.per_pixel_alpha_change)
2037 update_mpcc(dc, pipe_ctx);
2039 if (plane_state->update_flags.bits.full_update ||
2040 plane_state->update_flags.bits.per_pixel_alpha_change ||
2041 plane_state->update_flags.bits.scaling_change ||
2042 plane_state->update_flags.bits.position_change) {
2043 update_scaler(pipe_ctx);
2046 if (plane_state->update_flags.bits.full_update ||
2047 plane_state->update_flags.bits.scaling_change) {
2048 hubp->funcs->mem_program_viewport(
2050 &pipe_ctx->plane_res.scl_data.viewport,
2051 &pipe_ctx->plane_res.scl_data.viewport_c);
2054 if (plane_state->update_flags.bits.full_update) {
2056 program_gamut_remap(pipe_ctx);
2058 program_output_csc(dc,
2060 pipe_ctx->stream->output_color_space,
2061 pipe_ctx->stream->csc_color_matrix.matrix,
2065 if (plane_state->update_flags.bits.full_update ||
2066 plane_state->update_flags.bits.horizontal_mirror_change ||
2067 plane_state->update_flags.bits.rotation_change ||
2068 plane_state->update_flags.bits.swizzle_change ||
2069 plane_state->update_flags.bits.bpp_change) {
2070 hubp->funcs->hubp_program_surface_config(
2072 plane_state->format,
2073 &plane_state->tiling_info,
2075 plane_state->rotation,
2077 plane_state->horizontal_mirror);
2080 hubp->power_gated = false;
2082 dc->hwss.update_plane_addr(dc, pipe_ctx);
2084 if (is_pipe_tree_visible(pipe_ctx))
2085 hubp->funcs->set_blank(hubp, false);
2089 static void program_all_pipe_in_tree(
2091 struct pipe_ctx *pipe_ctx,
2092 struct dc_state *context)
2094 if (pipe_ctx->top_pipe == NULL) {
2096 pipe_ctx->stream_res.tg->dlg_otg_param.vready_offset = pipe_ctx->pipe_dlg_param.vready_offset;
2097 pipe_ctx->stream_res.tg->dlg_otg_param.vstartup_start = pipe_ctx->pipe_dlg_param.vstartup_start;
2098 pipe_ctx->stream_res.tg->dlg_otg_param.vupdate_offset = pipe_ctx->pipe_dlg_param.vupdate_offset;
2099 pipe_ctx->stream_res.tg->dlg_otg_param.vupdate_width = pipe_ctx->pipe_dlg_param.vupdate_width;
2100 pipe_ctx->stream_res.tg->dlg_otg_param.signal = pipe_ctx->stream->signal;
2102 pipe_ctx->stream_res.tg->funcs->program_global_sync(
2103 pipe_ctx->stream_res.tg);
2104 pipe_ctx->stream_res.tg->funcs->set_blank(pipe_ctx->stream_res.tg, !is_pipe_tree_visible(pipe_ctx));
2107 if (pipe_ctx->plane_state != NULL) {
2108 struct pipe_ctx *cur_pipe_ctx =
2109 &dc->current_state->res_ctx.pipe_ctx[pipe_ctx->pipe_idx];
2111 if (pipe_ctx->plane_state->update_flags.bits.full_update)
2112 dcn10_enable_plane(dc, pipe_ctx, context);
2114 update_dchubp_dpp(dc, pipe_ctx, context);
2116 if (cur_pipe_ctx->plane_state != pipe_ctx->plane_state)
2117 dc->hwss.set_input_transfer_func(pipe_ctx, pipe_ctx->plane_state);
2119 /* dcn10_translate_regamma_to_hw_format takes 750us to finish
2120 * only do gamma programming for full update.
2121 * TODO: This can be further optimized/cleaned up
2122 * Always call this for now since it does memcmp inside before
2123 * doing heavy calculation and programming
2125 if (pipe_ctx->plane_state->update_flags.bits.full_update)
2126 dc->hwss.set_output_transfer_func(pipe_ctx, pipe_ctx->stream);
2129 if (pipe_ctx->bottom_pipe != NULL && pipe_ctx->bottom_pipe != pipe_ctx)
2130 program_all_pipe_in_tree(dc, pipe_ctx->bottom_pipe, context);
2133 static void dcn10_pplib_apply_display_requirements(
2135 struct dc_state *context)
2137 struct dm_pp_display_configuration *pp_display_cfg = &context->pp_display_cfg;
2139 pp_display_cfg->all_displays_in_sync = false;/*todo*/
2140 pp_display_cfg->nb_pstate_switch_disable = false;
2141 pp_display_cfg->min_engine_clock_khz = context->bw.dcn.cur_clk.dcfclk_khz;
2142 pp_display_cfg->min_memory_clock_khz = context->bw.dcn.cur_clk.fclk_khz;
2143 pp_display_cfg->min_engine_clock_deep_sleep_khz = context->bw.dcn.cur_clk.dcfclk_deep_sleep_khz;
2144 pp_display_cfg->min_dcfc_deep_sleep_clock_khz = context->bw.dcn.cur_clk.dcfclk_deep_sleep_khz;
2145 pp_display_cfg->avail_mclk_switch_time_us =
2146 context->bw.dcn.cur_clk.dram_ccm_us > 0 ? context->bw.dcn.cur_clk.dram_ccm_us : 0;
2147 pp_display_cfg->avail_mclk_switch_time_in_disp_active_us =
2148 context->bw.dcn.cur_clk.min_active_dram_ccm_us > 0 ? context->bw.dcn.cur_clk.min_active_dram_ccm_us : 0;
2149 pp_display_cfg->min_dcfclock_khz = context->bw.dcn.cur_clk.dcfclk_khz;
2150 pp_display_cfg->disp_clk_khz = context->bw.dcn.cur_clk.dispclk_khz;
2151 dce110_fill_display_configs(context, pp_display_cfg);
2153 if (memcmp(&dc->prev_display_config, pp_display_cfg, sizeof(
2154 struct dm_pp_display_configuration)) != 0)
2155 dm_pp_apply_display_requirements(dc->ctx, pp_display_cfg);
2157 dc->prev_display_config = *pp_display_cfg;
2160 static void optimize_shared_resources(struct dc *dc)
2162 if (dc->current_state->stream_count == 0) {
2164 dcn10_pplib_apply_display_requirements(dc, dc->current_state);
2167 if (dc->debug.pplib_wm_report_mode == WM_REPORT_OVERRIDE)
2168 dcn_bw_notify_pplib_of_wm_ranges(dc);
2171 static void ready_shared_resources(struct dc *dc, struct dc_state *context)
2174 if (dc->current_state->stream_count == 0 &&
2175 context->stream_count != 0)
2176 dcn10_pplib_apply_display_requirements(dc, context);
2179 static struct pipe_ctx *find_top_pipe_for_stream(
2181 struct dc_state *context,
2182 const struct dc_stream_state *stream)
2186 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2187 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2188 struct pipe_ctx *old_pipe_ctx =
2189 &dc->current_state->res_ctx.pipe_ctx[i];
2191 if (!pipe_ctx->plane_state && !old_pipe_ctx->plane_state)
2194 if (pipe_ctx->stream != stream)
2197 if (!pipe_ctx->top_pipe)
2203 static void dcn10_apply_ctx_for_surface(
2205 const struct dc_stream_state *stream,
2207 struct dc_state *context)
2210 struct timing_generator *tg;
2211 bool removed_pipe[4] = { false };
2212 unsigned int ref_clk_mhz = dc->res_pool->ref_clock_inKhz/1000;
2213 bool program_water_mark = false;
2215 struct pipe_ctx *top_pipe_to_program =
2216 find_top_pipe_for_stream(dc, context, stream);
2218 if (!top_pipe_to_program)
2221 tg = top_pipe_to_program->stream_res.tg;
2223 tg->funcs->lock(tg);
2225 if (num_planes == 0) {
2227 /* OTG blank before remove all front end */
2228 tg->funcs->set_blank(tg, true);
2231 /* Disconnect unused mpcc */
2232 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2233 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2234 struct pipe_ctx *old_pipe_ctx =
2235 &dc->current_state->res_ctx.pipe_ctx[i];
2237 * Powergate reused pipes that are not powergated
2238 * fairly hacky right now, using opp_id as indicator
2239 * TODO: After move dc_post to dc_update, this will
2242 if (pipe_ctx->plane_state && !old_pipe_ctx->plane_state) {
2243 if (old_pipe_ctx->stream_res.tg == tg &&
2244 old_pipe_ctx->plane_res.hubp &&
2245 old_pipe_ctx->plane_res.hubp->opp_id != 0xf) {
2246 dcn10_disable_plane(dc, pipe_ctx);
2248 * power down fe will unlock when calling reset, need
2249 * to lock it back here. Messy, need rework.
2251 pipe_ctx->stream_res.tg->funcs->lock(pipe_ctx->stream_res.tg);
2255 if (!pipe_ctx->plane_state &&
2256 old_pipe_ctx->plane_state &&
2257 old_pipe_ctx->stream_res.tg == tg) {
2259 plane_atomic_disconnect(dc, old_pipe_ctx);
2260 removed_pipe[i] = true;
2262 dm_logger_write(dc->ctx->logger, LOG_DC,
2263 "Reset mpcc for pipe %d\n",
2264 old_pipe_ctx->pipe_idx);
2268 if (num_planes > 0) {
2269 program_all_pipe_in_tree(dc, top_pipe_to_program, context);
2271 /* TODO: this is a hack w/a for switching from mpo to pipe split */
2272 if (stream->cursor_attributes.address.quad_part != 0) {
2273 struct dc_cursor_position position = { 0 };
2275 dc_stream_set_cursor_position(
2276 (struct dc_stream_state *)stream,
2278 dc_stream_set_cursor_attributes(
2279 (struct dc_stream_state *)stream,
2280 &stream->cursor_attributes);
2284 tg->funcs->unlock(tg);
2286 if (num_planes == 0)
2287 false_optc_underflow_wa(dc, stream, tg);
2289 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2290 struct pipe_ctx *old_pipe_ctx =
2291 &dc->current_state->res_ctx.pipe_ctx[i];
2292 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2294 if (pipe_ctx->stream == stream &&
2295 pipe_ctx->plane_state &&
2296 pipe_ctx->plane_state->update_flags.bits.full_update)
2297 program_water_mark = true;
2299 if (removed_pipe[i] && num_planes == 0)
2300 dcn10_disable_plane(dc, old_pipe_ctx);
2303 if (program_water_mark) {
2304 if (dc->debug.sanity_checks) {
2305 /* pstate stuck check after watermark update */
2306 dcn10_verify_allow_pstate_change_high(dc);
2308 /* watermark is for all pipes */
2309 hubbub1_program_watermarks(dc->res_pool->hubbub,
2310 &context->bw.dcn.watermarks, ref_clk_mhz);
2312 if (dc->debug.sanity_checks) {
2313 /* pstate stuck check after watermark update */
2314 dcn10_verify_allow_pstate_change_high(dc);
2317 /* dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_CALCS,
2318 "\n============== Watermark parameters ==============\n"
2319 "a.urgent_ns: %d \n"
2320 "a.cstate_enter_plus_exit: %d \n"
2321 "a.cstate_exit: %d \n"
2322 "a.pstate_change: %d \n"
2323 "a.pte_meta_urgent: %d \n"
2324 "b.urgent_ns: %d \n"
2325 "b.cstate_enter_plus_exit: %d \n"
2326 "b.cstate_exit: %d \n"
2327 "b.pstate_change: %d \n"
2328 "b.pte_meta_urgent: %d \n",
2329 context->bw.dcn.watermarks.a.urgent_ns,
2330 context->bw.dcn.watermarks.a.cstate_pstate.cstate_enter_plus_exit_ns,
2331 context->bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns,
2332 context->bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns,
2333 context->bw.dcn.watermarks.a.pte_meta_urgent_ns,
2334 context->bw.dcn.watermarks.b.urgent_ns,
2335 context->bw.dcn.watermarks.b.cstate_pstate.cstate_enter_plus_exit_ns,
2336 context->bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns,
2337 context->bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns,
2338 context->bw.dcn.watermarks.b.pte_meta_urgent_ns
2340 dm_logger_write(dc->ctx->logger, LOG_BANDWIDTH_CALCS,
2341 "\nc.urgent_ns: %d \n"
2342 "c.cstate_enter_plus_exit: %d \n"
2343 "c.cstate_exit: %d \n"
2344 "c.pstate_change: %d \n"
2345 "c.pte_meta_urgent: %d \n"
2346 "d.urgent_ns: %d \n"
2347 "d.cstate_enter_plus_exit: %d \n"
2348 "d.cstate_exit: %d \n"
2349 "d.pstate_change: %d \n"
2350 "d.pte_meta_urgent: %d \n"
2351 "========================================================\n",
2352 context->bw.dcn.watermarks.c.urgent_ns,
2353 context->bw.dcn.watermarks.c.cstate_pstate.cstate_enter_plus_exit_ns,
2354 context->bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns,
2355 context->bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns,
2356 context->bw.dcn.watermarks.c.pte_meta_urgent_ns,
2357 context->bw.dcn.watermarks.d.urgent_ns,
2358 context->bw.dcn.watermarks.d.cstate_pstate.cstate_enter_plus_exit_ns,
2359 context->bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns,
2360 context->bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns,
2361 context->bw.dcn.watermarks.d.pte_meta_urgent_ns
2366 static void dcn10_set_bandwidth(
2368 struct dc_state *context,
2369 bool decrease_allowed)
2371 struct pp_smu_display_requirement_rv *smu_req_cur =
2372 &dc->res_pool->pp_smu_req;
2373 struct pp_smu_display_requirement_rv smu_req = *smu_req_cur;
2374 struct pp_smu_funcs_rv *pp_smu = dc->res_pool->pp_smu;
2376 if (dc->debug.sanity_checks) {
2377 dcn10_verify_allow_pstate_change_high(dc);
2380 if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment))
2383 if (decrease_allowed || context->bw.dcn.calc_clk.dispclk_khz
2384 > dc->current_state->bw.dcn.cur_clk.dispclk_khz) {
2385 dc->res_pool->display_clock->funcs->set_clock(
2386 dc->res_pool->display_clock,
2387 context->bw.dcn.calc_clk.dispclk_khz);
2388 dc->current_state->bw.dcn.cur_clk.dispclk_khz =
2389 context->bw.dcn.calc_clk.dispclk_khz;
2391 if (decrease_allowed || context->bw.dcn.calc_clk.dcfclk_khz
2392 > dc->current_state->bw.dcn.cur_clk.dcfclk_khz) {
2393 smu_req.hard_min_dcefclk_khz =
2394 context->bw.dcn.calc_clk.dcfclk_khz;
2396 if (decrease_allowed || context->bw.dcn.calc_clk.fclk_khz
2397 > dc->current_state->bw.dcn.cur_clk.fclk_khz) {
2398 smu_req.hard_min_fclk_khz = context->bw.dcn.calc_clk.fclk_khz;
2400 if (decrease_allowed || context->bw.dcn.calc_clk.dcfclk_deep_sleep_khz
2401 > dc->current_state->bw.dcn.cur_clk.dcfclk_deep_sleep_khz) {
2402 dc->current_state->bw.dcn.calc_clk.dcfclk_deep_sleep_khz =
2403 context->bw.dcn.calc_clk.dcfclk_deep_sleep_khz;
2404 context->bw.dcn.cur_clk.dcfclk_deep_sleep_khz =
2405 context->bw.dcn.calc_clk.dcfclk_deep_sleep_khz;
2408 smu_req.display_count = context->stream_count;
2410 if (pp_smu->set_display_requirement)
2411 pp_smu->set_display_requirement(&pp_smu->pp_smu, &smu_req);
2413 *smu_req_cur = smu_req;
2415 /* Decrease in freq is increase in period so opposite comparison for dram_ccm */
2416 if (decrease_allowed || context->bw.dcn.calc_clk.dram_ccm_us
2417 < dc->current_state->bw.dcn.cur_clk.dram_ccm_us) {
2418 dc->current_state->bw.dcn.calc_clk.dram_ccm_us =
2419 context->bw.dcn.calc_clk.dram_ccm_us;
2420 context->bw.dcn.cur_clk.dram_ccm_us =
2421 context->bw.dcn.calc_clk.dram_ccm_us;
2423 if (decrease_allowed || context->bw.dcn.calc_clk.min_active_dram_ccm_us
2424 < dc->current_state->bw.dcn.cur_clk.min_active_dram_ccm_us) {
2425 dc->current_state->bw.dcn.calc_clk.min_active_dram_ccm_us =
2426 context->bw.dcn.calc_clk.min_active_dram_ccm_us;
2427 context->bw.dcn.cur_clk.min_active_dram_ccm_us =
2428 context->bw.dcn.calc_clk.min_active_dram_ccm_us;
2430 dcn10_pplib_apply_display_requirements(dc, context);
2432 if (dc->debug.sanity_checks) {
2433 dcn10_verify_allow_pstate_change_high(dc);
2436 /* need to fix this function. not doing the right thing here */
2439 static void set_drr(struct pipe_ctx **pipe_ctx,
2440 int num_pipes, int vmin, int vmax)
2443 struct drr_params params = {0};
2445 params.vertical_total_max = vmax;
2446 params.vertical_total_min = vmin;
2448 /* TODO: If multiple pipes are to be supported, you need
2451 for (i = 0; i < num_pipes; i++) {
2452 pipe_ctx[i]->stream_res.tg->funcs->set_drr(pipe_ctx[i]->stream_res.tg, ¶ms);
2456 static void get_position(struct pipe_ctx **pipe_ctx,
2458 struct crtc_position *position)
2462 /* TODO: handle pipes > 1
2464 for (i = 0; i < num_pipes; i++)
2465 pipe_ctx[i]->stream_res.tg->funcs->get_position(pipe_ctx[i]->stream_res.tg, position);
2468 static void set_static_screen_control(struct pipe_ctx **pipe_ctx,
2469 int num_pipes, const struct dc_static_screen_events *events)
2472 unsigned int value = 0;
2474 if (events->surface_update)
2476 if (events->cursor_update)
2479 for (i = 0; i < num_pipes; i++)
2480 pipe_ctx[i]->stream_res.tg->funcs->
2481 set_static_screen_control(pipe_ctx[i]->stream_res.tg, value);
2484 static void set_plane_config(
2485 const struct dc *dc,
2486 struct pipe_ctx *pipe_ctx,
2487 struct resource_context *res_ctx)
2490 program_gamut_remap(pipe_ctx);
2493 static void dcn10_config_stereo_parameters(
2494 struct dc_stream_state *stream, struct crtc_stereo_flags *flags)
2496 enum view_3d_format view_format = stream->view_format;
2497 enum dc_timing_3d_format timing_3d_format =\
2498 stream->timing.timing_3d_format;
2499 bool non_stereo_timing = false;
2501 if (timing_3d_format == TIMING_3D_FORMAT_NONE ||
2502 timing_3d_format == TIMING_3D_FORMAT_SIDE_BY_SIDE ||
2503 timing_3d_format == TIMING_3D_FORMAT_TOP_AND_BOTTOM)
2504 non_stereo_timing = true;
2506 if (non_stereo_timing == false &&
2507 view_format == VIEW_3D_FORMAT_FRAME_SEQUENTIAL) {
2509 flags->PROGRAM_STEREO = 1;
2510 flags->PROGRAM_POLARITY = 1;
2511 if (timing_3d_format == TIMING_3D_FORMAT_INBAND_FA ||
2512 timing_3d_format == TIMING_3D_FORMAT_DP_HDMI_INBAND_FA ||
2513 timing_3d_format == TIMING_3D_FORMAT_SIDEBAND_FA) {
2514 enum display_dongle_type dongle = \
2515 stream->sink->link->ddc->dongle_type;
2516 if (dongle == DISPLAY_DONGLE_DP_VGA_CONVERTER ||
2517 dongle == DISPLAY_DONGLE_DP_DVI_CONVERTER ||
2518 dongle == DISPLAY_DONGLE_DP_HDMI_CONVERTER)
2519 flags->DISABLE_STEREO_DP_SYNC = 1;
2521 flags->RIGHT_EYE_POLARITY =\
2522 stream->timing.flags.RIGHT_EYE_3D_POLARITY;
2523 if (timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING)
2524 flags->FRAME_PACKED = 1;
2530 static void dcn10_setup_stereo(struct pipe_ctx *pipe_ctx, struct dc *dc)
2532 struct crtc_stereo_flags flags = { 0 };
2533 struct dc_stream_state *stream = pipe_ctx->stream;
2535 dcn10_config_stereo_parameters(stream, &flags);
2537 pipe_ctx->stream_res.opp->funcs->opp_set_stereo_polarity(
2538 pipe_ctx->stream_res.opp,
2539 flags.PROGRAM_STEREO == 1 ? true:false,
2540 stream->timing.flags.RIGHT_EYE_3D_POLARITY == 1 ? true:false);
2542 pipe_ctx->stream_res.tg->funcs->program_stereo(
2543 pipe_ctx->stream_res.tg,
2550 static void dcn10_wait_for_mpcc_disconnect(
2552 struct resource_pool *res_pool,
2553 struct pipe_ctx *pipe_ctx)
2557 if (dc->debug.sanity_checks) {
2558 dcn10_verify_allow_pstate_change_high(dc);
2561 if (!pipe_ctx->stream_res.opp)
2564 for (i = 0; i < MAX_PIPES; i++) {
2565 if (pipe_ctx->stream_res.opp->mpcc_disconnect_pending[i]) {
2566 res_pool->mpc->funcs->wait_for_idle(res_pool->mpc, i);
2567 pipe_ctx->stream_res.opp->mpcc_disconnect_pending[i] = false;
2568 res_pool->hubps[i]->funcs->set_blank(res_pool->hubps[i], true);
2569 /*dm_logger_write(dc->ctx->logger, LOG_ERROR,
2570 "[debug_mpo: wait_for_mpcc finished waiting on mpcc %d]\n",
2575 if (dc->debug.sanity_checks) {
2576 dcn10_verify_allow_pstate_change_high(dc);
2581 static bool dcn10_dummy_display_power_gating(
2583 uint8_t controller_id,
2584 struct dc_bios *dcb,
2585 enum pipe_gating_control power_gating)
2590 void dcn10_update_pending_status(struct pipe_ctx *pipe_ctx)
2592 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2593 struct timing_generator *tg = pipe_ctx->stream_res.tg;
2595 if (plane_state == NULL)
2598 plane_state->status.is_flip_pending =
2599 pipe_ctx->plane_res.hubp->funcs->hubp_is_flip_pending(
2600 pipe_ctx->plane_res.hubp);
2602 plane_state->status.current_address = pipe_ctx->plane_res.hubp->current_address;
2603 if (pipe_ctx->plane_res.hubp->current_address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
2604 tg->funcs->is_stereo_left_eye) {
2605 plane_state->status.is_right_eye =
2606 !tg->funcs->is_stereo_left_eye(pipe_ctx->stream_res.tg);
2610 void dcn10_update_dchub(struct dce_hwseq *hws, struct dchub_init_data *dh_data)
2612 if (hws->ctx->dc->res_pool->hubbub != NULL)
2613 hubbub1_update_dchub(hws->ctx->dc->res_pool->hubbub, dh_data);
2616 static const struct hw_sequencer_funcs dcn10_funcs = {
2617 .program_gamut_remap = program_gamut_remap,
2618 .program_csc_matrix = program_csc_matrix,
2619 .init_hw = dcn10_init_hw,
2620 .apply_ctx_to_hw = dce110_apply_ctx_to_hw,
2621 .apply_ctx_for_surface = dcn10_apply_ctx_for_surface,
2622 .set_plane_config = set_plane_config,
2623 .update_plane_addr = dcn10_update_plane_addr,
2624 .update_dchub = dcn10_update_dchub,
2625 .update_pending_status = dcn10_update_pending_status,
2626 .set_input_transfer_func = dcn10_set_input_transfer_func,
2627 .set_output_transfer_func = dcn10_set_output_transfer_func,
2628 .power_down = dce110_power_down,
2629 .enable_accelerated_mode = dce110_enable_accelerated_mode,
2630 .enable_timing_synchronization = dcn10_enable_timing_synchronization,
2631 .enable_per_frame_crtc_position_reset = dcn10_enable_per_frame_crtc_position_reset,
2632 .update_info_frame = dce110_update_info_frame,
2633 .enable_stream = dce110_enable_stream,
2634 .disable_stream = dce110_disable_stream,
2635 .unblank_stream = dce110_unblank_stream,
2636 .enable_display_power_gating = dcn10_dummy_display_power_gating,
2637 .disable_plane = dcn10_disable_plane,
2638 .pipe_control_lock = dcn10_pipe_control_lock,
2639 .set_bandwidth = dcn10_set_bandwidth,
2640 .reset_hw_ctx_wrap = reset_hw_ctx_wrap,
2641 .prog_pixclk_crtc_otg = dcn10_prog_pixclk_crtc_otg,
2643 .get_position = get_position,
2644 .set_static_screen_control = set_static_screen_control,
2645 .setup_stereo = dcn10_setup_stereo,
2646 .set_avmute = dce110_set_avmute,
2647 .log_hw_state = dcn10_log_hw_state,
2648 .wait_for_mpcc_disconnect = dcn10_wait_for_mpcc_disconnect,
2649 .ready_shared_resources = ready_shared_resources,
2650 .optimize_shared_resources = optimize_shared_resources,
2651 .pplib_apply_display_requirements =
2652 dcn10_pplib_apply_display_requirements,
2653 .edp_backlight_control = hwss_edp_backlight_control,
2654 .edp_power_control = hwss_edp_power_control
2658 void dcn10_hw_sequencer_construct(struct dc *dc)
2660 dc->hwss = dcn10_funcs;