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"
34 #include "dcn10/dcn10_dpp.h"
35 #include "dcn10/dcn10_mpc.h"
36 #include "mem_input.h"
37 #include "timing_generator.h"
41 #include "raven1/DCN/dcn_1_0_offset.h"
42 #include "raven1/DCN/dcn_1_0_sh_mask.h"
43 #include "vega10/soc15ip.h"
44 #include "reg_helper.h"
52 #define FN(reg_name, field_name) \
53 hws->shifts->field_name, hws->masks->field_name
56 static void verify_allow_pstate_change_high(
57 struct dce_hwseq
*hws
)
59 /* pstate latency is ~20us so if we wait over 40us and pstate allow
60 * still not asserted, we are probably stuck and going to hang
62 static unsigned int pstate_wait_timeout_us
= 40;
63 static unsigned int max_sampled_pstate_wait_us
; /* data collection */
64 static bool forced_pstate_allow
; /* help with revert wa */
66 unsigned int debug_index
= 0x7;
67 unsigned int debug_data
;
68 unsigned int force_allow_pstate
= 0x30;
71 if (forced_pstate_allow
) {
72 /* we hacked to force pstate allow to prevent hang last time
73 * we verify_allow_pstate_change_high. so disable force
74 * here so we can check status
76 REG_WRITE(DCHUBBUB_ARB_DRAM_STATE_CNTL
, 0);
77 forced_pstate_allow
= false;
80 /* description "3-0: Pipe0 cursor0 QOS
81 * 7-4: Pipe1 cursor0 QOS
82 * 11-8: Pipe2 cursor0 QOS
83 * 15-12: Pipe3 cursor0 QOS
84 * 16: Pipe0 Plane0 Allow Pstate Change
85 * 17: Pipe1 Plane0 Allow Pstate Change
86 * 18: Pipe2 Plane0 Allow Pstate Change
87 * 19: Pipe3 Plane0 Allow Pstate Change
88 * 20: Pipe0 Plane1 Allow Pstate Change
89 * 21: Pipe1 Plane1 Allow Pstate Change
90 * 22: Pipe2 Plane1 Allow Pstate Change
91 * 23: Pipe3 Plane1 Allow Pstate Change
92 * 24: Pipe0 cursor0 Allow Pstate Change
93 * 25: Pipe1 cursor0 Allow Pstate Change
94 * 26: Pipe2 cursor0 Allow Pstate Change
95 * 27: Pipe3 cursor0 Allow Pstate Change
96 * 28: WB0 Allow Pstate Change
97 * 29: WB1 Allow Pstate Change
98 * 30: Arbiter's allow_pstate_change
99 * 31: SOC pstate change request
102 REG_WRITE(DCHUBBUB_TEST_DEBUG_INDEX
, debug_index
);
104 for (i
= 0; i
< pstate_wait_timeout_us
; i
++) {
105 debug_data
= REG_READ(DCHUBBUB_TEST_DEBUG_DATA
);
107 if (debug_data
& (1 << 30))
110 if (max_sampled_pstate_wait_us
< i
)
111 max_sampled_pstate_wait_us
= i
;
116 /* force pstate allow to prevent system hang
117 * and break to debugger to investigate
119 REG_WRITE(DCHUBBUB_ARB_DRAM_STATE_CNTL
, force_allow_pstate
);
120 forced_pstate_allow
= true;
124 static void enable_dppclk(
125 struct dce_hwseq
*hws
,
127 uint32_t requested_pix_clk
,
130 dm_logger_write(hws
->ctx
->logger
, LOG_SURFACE
,
131 "dppclk_rate_control for pipe %d programed to %d\n",
135 if (hws
->shifts
->DPPCLK_RATE_CONTROL
)
136 REG_UPDATE_2(DPP_CONTROL
[plane_id
],
137 DPPCLK_RATE_CONTROL
, dppclk_div
,
138 DPP_CLOCK_ENABLE
, 1);
140 REG_UPDATE(DPP_CONTROL
[plane_id
],
141 DPP_CLOCK_ENABLE
, 1);
144 static void enable_power_gating_plane(
145 struct dce_hwseq
*hws
,
148 bool force_on
= 1; /* disable power gating */
154 REG_UPDATE(DOMAIN0_PG_CONFIG
, DOMAIN0_POWER_FORCEON
, force_on
);
155 REG_UPDATE(DOMAIN2_PG_CONFIG
, DOMAIN2_POWER_FORCEON
, force_on
);
156 REG_UPDATE(DOMAIN4_PG_CONFIG
, DOMAIN4_POWER_FORCEON
, force_on
);
157 REG_UPDATE(DOMAIN6_PG_CONFIG
, DOMAIN6_POWER_FORCEON
, force_on
);
160 REG_UPDATE(DOMAIN1_PG_CONFIG
, DOMAIN1_POWER_FORCEON
, force_on
);
161 REG_UPDATE(DOMAIN3_PG_CONFIG
, DOMAIN3_POWER_FORCEON
, force_on
);
162 REG_UPDATE(DOMAIN5_PG_CONFIG
, DOMAIN5_POWER_FORCEON
, force_on
);
163 REG_UPDATE(DOMAIN7_PG_CONFIG
, DOMAIN7_POWER_FORCEON
, force_on
);
166 static void disable_vga(
167 struct dce_hwseq
*hws
)
169 REG_WRITE(D1VGA_CONTROL
, 0);
170 REG_WRITE(D2VGA_CONTROL
, 0);
171 REG_WRITE(D3VGA_CONTROL
, 0);
172 REG_WRITE(D4VGA_CONTROL
, 0);
175 static void dpp_pg_control(
176 struct dce_hwseq
*hws
,
177 unsigned int dpp_inst
,
180 uint32_t power_gate
= power_on
? 0 : 1;
181 uint32_t pwr_status
= power_on
? 0 : 2;
183 if (hws
->ctx
->dc
->debug
.disable_dpp_power_gate
)
188 REG_UPDATE(DOMAIN1_PG_CONFIG
,
189 DOMAIN1_POWER_GATE
, power_gate
);
191 REG_WAIT(DOMAIN1_PG_STATUS
,
192 DOMAIN1_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
195 REG_UPDATE(DOMAIN3_PG_CONFIG
,
196 DOMAIN3_POWER_GATE
, power_gate
);
198 REG_WAIT(DOMAIN3_PG_STATUS
,
199 DOMAIN3_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
202 REG_UPDATE(DOMAIN5_PG_CONFIG
,
203 DOMAIN5_POWER_GATE
, power_gate
);
205 REG_WAIT(DOMAIN5_PG_STATUS
,
206 DOMAIN5_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
209 REG_UPDATE(DOMAIN7_PG_CONFIG
,
210 DOMAIN7_POWER_GATE
, power_gate
);
212 REG_WAIT(DOMAIN7_PG_STATUS
,
213 DOMAIN7_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
221 static void hubp_pg_control(
222 struct dce_hwseq
*hws
,
223 unsigned int hubp_inst
,
226 uint32_t power_gate
= power_on
? 0 : 1;
227 uint32_t pwr_status
= power_on
? 0 : 2;
229 if (hws
->ctx
->dc
->debug
.disable_hubp_power_gate
)
233 case 0: /* DCHUBP0 */
234 REG_UPDATE(DOMAIN0_PG_CONFIG
,
235 DOMAIN0_POWER_GATE
, power_gate
);
237 REG_WAIT(DOMAIN0_PG_STATUS
,
238 DOMAIN0_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
240 case 1: /* DCHUBP1 */
241 REG_UPDATE(DOMAIN2_PG_CONFIG
,
242 DOMAIN2_POWER_GATE
, power_gate
);
244 REG_WAIT(DOMAIN2_PG_STATUS
,
245 DOMAIN2_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
247 case 2: /* DCHUBP2 */
248 REG_UPDATE(DOMAIN4_PG_CONFIG
,
249 DOMAIN4_POWER_GATE
, power_gate
);
251 REG_WAIT(DOMAIN4_PG_STATUS
,
252 DOMAIN4_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
254 case 3: /* DCHUBP3 */
255 REG_UPDATE(DOMAIN6_PG_CONFIG
,
256 DOMAIN6_POWER_GATE
, power_gate
);
258 REG_WAIT(DOMAIN6_PG_STATUS
,
259 DOMAIN6_PGFSM_PWR_STATUS
, pwr_status
, 20000, 200000);
267 static void power_on_plane(
268 struct dce_hwseq
*hws
,
271 REG_SET(DC_IP_REQUEST_CNTL
, 0,
273 dpp_pg_control(hws
, plane_id
, true);
274 hubp_pg_control(hws
, plane_id
, true);
275 REG_SET(DC_IP_REQUEST_CNTL
, 0,
277 dm_logger_write(hws
->ctx
->logger
, LOG_DC
,
278 "Un-gated front end for pipe %d\n", plane_id
);
281 static void bios_golden_init(struct core_dc
*dc
)
283 struct dc_bios
*bp
= dc
->ctx
->dc_bios
;
286 /* initialize dcn global */
287 bp
->funcs
->enable_disp_power_gating(bp
,
288 CONTROLLER_ID_D0
, ASIC_PIPE_INIT
);
290 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
291 /* initialize dcn per pipe */
292 bp
->funcs
->enable_disp_power_gating(bp
,
293 CONTROLLER_ID_D0
+ i
, ASIC_PIPE_DISABLE
);
297 static void dcn10_init_hw(struct core_dc
*dc
)
300 struct abm
*abm
= dc
->res_pool
->abm
;
301 struct dce_hwseq
*hws
= dc
->hwseq
;
303 if (IS_FPGA_MAXIMUS_DC(dc
->ctx
->dce_environment
)) {
304 REG_WRITE(REFCLK_CNTL
, 0);
305 REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL
, DCHUBBUB_GLOBAL_TIMER_ENABLE
, 1);
306 REG_WRITE(DIO_MEM_PWR_CTRL
, 0);
308 if (!dc
->public.debug
.disable_clock_gate
) {
309 /* enable all DCN clock gating */
310 REG_WRITE(DCCG_GATE_DISABLE_CNTL
, 0);
312 REG_WRITE(DCCG_GATE_DISABLE_CNTL2
, 0);
314 REG_UPDATE(DCFCLK_CNTL
, DCFCLK_GATE_DIS
, 0);
317 enable_power_gating_plane(dc
->hwseq
, true);
320 /* end of FPGA. Below if real ASIC */
322 bios_golden_init(dc
);
324 disable_vga(dc
->hwseq
);
326 for (i
= 0; i
< dc
->link_count
; i
++) {
327 /* Power up AND update implementation according to the
328 * required signal (which may be different from the
329 * default signal on connector).
331 struct core_link
*link
= dc
->links
[i
];
333 link
->link_enc
->funcs
->hw_init(link
->link_enc
);
336 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
337 struct transform
*xfm
= dc
->res_pool
->transforms
[i
];
338 struct timing_generator
*tg
= dc
->res_pool
->timing_generators
[i
];
339 struct mpcc
*mpcc
= dc
->res_pool
->mpcc
[i
];
340 struct mpcc_cfg mpcc_cfg
;
342 xfm
->funcs
->transform_reset(xfm
);
343 mpcc_cfg
.opp_id
= 0xf;
344 mpcc_cfg
.top_dpp_id
= 0xf;
345 mpcc_cfg
.bot_mpcc_id
= 0xf;
346 mpcc_cfg
.top_of_tree
= true;
347 mpcc
->funcs
->set(mpcc
, &mpcc_cfg
);
349 /* Blank controller using driver code instead of
352 tg
->funcs
->set_blank(tg
, true);
353 hwss_wait_for_blank_complete(tg
);
356 for (i
= 0; i
< dc
->res_pool
->audio_count
; i
++) {
357 struct audio
*audio
= dc
->res_pool
->audios
[i
];
359 audio
->funcs
->hw_init(audio
);
363 abm
->funcs
->init_backlight(abm
);
364 abm
->funcs
->abm_init(abm
);
367 /* power AFMT HDMI memory TODO: may move to dis/en output save power*/
368 REG_WRITE(DIO_MEM_PWR_CTRL
, 0);
370 if (!dc
->public.debug
.disable_clock_gate
) {
371 /* enable all DCN clock gating */
372 REG_WRITE(DCCG_GATE_DISABLE_CNTL
, 0);
374 REG_WRITE(DCCG_GATE_DISABLE_CNTL2
, 0);
376 REG_UPDATE(DCFCLK_CNTL
, DCFCLK_GATE_DIS
, 0);
379 enable_power_gating_plane(dc
->hwseq
, true);
382 static enum dc_status
dcn10_prog_pixclk_crtc_otg(
383 struct pipe_ctx
*pipe_ctx
,
384 struct validate_context
*context
,
387 struct core_stream
*stream
= pipe_ctx
->stream
;
388 enum dc_color_space color_space
;
389 struct tg_color black_color
= {0};
390 bool enableStereo
= stream
->public.timing
.timing_3d_format
== TIMING_3D_FORMAT_NONE
?
392 bool rightEyePolarity
= stream
->public.timing
.flags
.RIGHT_EYE_3D_POLARITY
;
395 /* by upper caller loop, pipe0 is parent pipe and be called first.
396 * back end is set up by for pipe0. Other children pipe share back end
397 * with pipe 0. No program is needed.
399 if (pipe_ctx
->top_pipe
!= NULL
)
402 /* TODO check if timing_changed, disable stream if timing changed */
404 /* HW program guide assume display already disable
405 * by unplug sequence. OTG assume stop.
407 pipe_ctx
->tg
->funcs
->enable_optc_clock(pipe_ctx
->tg
, true);
409 if (false == pipe_ctx
->clock_source
->funcs
->program_pix_clk(
410 pipe_ctx
->clock_source
,
411 &pipe_ctx
->pix_clk_params
,
412 &pipe_ctx
->pll_settings
)) {
414 return DC_ERROR_UNEXPECTED
;
416 pipe_ctx
->tg
->dlg_otg_param
.vready_offset
= pipe_ctx
->pipe_dlg_param
.vready_offset
;
417 pipe_ctx
->tg
->dlg_otg_param
.vstartup_start
= pipe_ctx
->pipe_dlg_param
.vstartup_start
;
418 pipe_ctx
->tg
->dlg_otg_param
.vupdate_offset
= pipe_ctx
->pipe_dlg_param
.vupdate_offset
;
419 pipe_ctx
->tg
->dlg_otg_param
.vupdate_width
= pipe_ctx
->pipe_dlg_param
.vupdate_width
;
421 pipe_ctx
->tg
->dlg_otg_param
.signal
= pipe_ctx
->stream
->signal
;
423 pipe_ctx
->tg
->funcs
->program_timing(
425 &stream
->public.timing
,
428 pipe_ctx
->opp
->funcs
->opp_set_stereo_polarity(
433 #if 0 /* move to after enable_crtc */
434 /* TODO: OPP FMT, ABM. etc. should be done here. */
435 /* or FPGA now. instance 0 only. TODO: move to opp.c */
437 inst_offset
= reg_offsets
[pipe_ctx
->tg
->inst
].fmt
;
439 pipe_ctx
->opp
->funcs
->opp_program_fmt(
441 &stream
->bit_depth_params
,
444 /* program otg blank color */
445 color_space
= stream
->public.output_color_space
;
446 color_space_to_black_color(dc
, color_space
, &black_color
);
447 pipe_ctx
->tg
->funcs
->set_blank_color(
451 pipe_ctx
->tg
->funcs
->set_blank(pipe_ctx
->tg
, true);
452 hwss_wait_for_blank_complete(pipe_ctx
->tg
);
454 /* VTG is within DCHUB command block. DCFCLK is always on */
455 if (false == pipe_ctx
->tg
->funcs
->enable_crtc(pipe_ctx
->tg
)) {
457 return DC_ERROR_UNEXPECTED
;
460 /* TODO program crtc source select for non-virtual signal*/
461 /* TODO program FMT */
462 /* TODO setup link_enc */
463 /* TODO set stream attributes */
464 /* TODO program audio */
465 /* TODO enable stream if timing changed */
466 /* TODO unblank stream if DP */
471 static void reset_back_end_for_pipe(
473 struct pipe_ctx
*pipe_ctx
,
474 struct validate_context
*context
)
478 if (pipe_ctx
->stream_enc
== NULL
) {
479 pipe_ctx
->stream
= NULL
;
483 /* TODOFPGA break core_link_disable_stream into 2 functions:
484 * disable_stream and disable_link. disable_link will disable PHYPLL
485 * which is used by otg. Move disable_link after disable_crtc
487 if (!IS_FPGA_MAXIMUS_DC(dc
->ctx
->dce_environment
))
488 core_link_disable_stream(pipe_ctx
);
490 /* by upper caller loop, parent pipe: pipe0, will be reset last.
491 * back end share by all pipes and will be disable only when disable
494 if (pipe_ctx
->top_pipe
== NULL
) {
495 pipe_ctx
->tg
->funcs
->disable_crtc(pipe_ctx
->tg
);
497 pipe_ctx
->tg
->funcs
->enable_optc_clock(pipe_ctx
->tg
, false);
500 if (!IS_FPGA_MAXIMUS_DC(dc
->ctx
->dce_environment
))
501 resource_unreference_clock_source(
502 &context
->res_ctx
, dc
->res_pool
,
503 &pipe_ctx
->clock_source
);
505 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++)
506 if (&dc
->current_context
->res_ctx
.pipe_ctx
[i
] == pipe_ctx
)
509 if (i
== dc
->res_pool
->pipe_count
)
512 pipe_ctx
->stream
= NULL
;
513 dm_logger_write(dc
->ctx
->logger
, LOG_DC
,
514 "Reset back end for pipe %d, tg:%d\n",
515 pipe_ctx
->pipe_idx
, pipe_ctx
->tg
->inst
);
518 static void plane_atomic_stop(
522 struct mpcc_cfg mpcc_cfg
;
523 struct mem_input
*mi
= dc
->res_pool
->mis
[fe_idx
];
524 struct transform
*xfm
= dc
->res_pool
->transforms
[fe_idx
];
525 struct mpcc
*mpcc
= dc
->res_pool
->mpcc
[fe_idx
];
526 struct timing_generator
*tg
= dc
->res_pool
->timing_generators
[mpcc
->opp_id
];
528 mi
->funcs
->dcc_control(mi
, false, false);
530 mpcc_cfg
.opp_id
= 0xf;
531 mpcc_cfg
.top_dpp_id
= 0xf;
532 mpcc_cfg
.bot_mpcc_id
= 0xf;
533 mpcc_cfg
.top_of_tree
= tg
->inst
== mpcc
->inst
;
534 mpcc
->funcs
->set(mpcc
, &mpcc_cfg
);
536 xfm
->funcs
->transform_reset(xfm
);
539 static void reset_front_end(
543 struct dce_hwseq
*hws
= dc
->hwseq
;
544 struct mem_input
*mi
= dc
->res_pool
->mis
[fe_idx
];
545 struct mpcc
*mpcc
= dc
->res_pool
->mpcc
[fe_idx
];
546 struct timing_generator
*tg
= dc
->res_pool
->timing_generators
[mpcc
->opp_id
];
547 unsigned int opp_id
= mpcc
->opp_id
;
555 plane_atomic_stop(dc
, fe_idx
);
557 REG_UPDATE(OTG_GLOBAL_SYNC_STATUS
[tg
->inst
], VUPDATE_NO_LOCK_EVENT_CLEAR
, 1);
558 tg
->funcs
->unlock(tg
);
560 if (dc
->public.debug
.sanity_checks
)
561 verify_allow_pstate_change_high(dc
->hwseq
);
563 if (tg
->ctx
->dce_environment
!= DCE_ENV_FPGA_MAXIMUS
)
564 REG_WAIT(OTG_GLOBAL_SYNC_STATUS
[tg
->inst
],
565 VUPDATE_NO_LOCK_EVENT_OCCURRED
, 1, 20000, 200000);
567 mpcc
->funcs
->wait_for_idle(mpcc
);
569 mi
->funcs
->set_blank(mi
, true);
571 if (dc
->public.debug
.sanity_checks
)
572 verify_allow_pstate_change_high(dc
->hwseq
);
574 REG_UPDATE(HUBP_CLK_CNTL
[fe_idx
],
575 HUBP_CLOCK_ENABLE
, 0);
576 REG_UPDATE(DPP_CONTROL
[fe_idx
],
577 DPP_CLOCK_ENABLE
, 0);
579 if (tg
->inst
== mpcc
->inst
)
580 REG_UPDATE(OPP_PIPE_CONTROL
[opp_id
],
581 OPP_PIPE_CLOCK_EN
, 0);
583 dm_logger_write(dc
->ctx
->logger
, LOG_DC
,
584 "Reset front end %d\n",
587 if (dc
->public.debug
.sanity_checks
)
588 verify_allow_pstate_change_high(dc
->hwseq
);
591 static void dcn10_power_down_fe(struct core_dc
*dc
, int fe_idx
)
593 struct dce_hwseq
*hws
= dc
->hwseq
;
595 reset_front_end(dc
, fe_idx
);
597 REG_SET(DC_IP_REQUEST_CNTL
, 0,
599 dpp_pg_control(hws
, fe_idx
, false);
600 hubp_pg_control(hws
, fe_idx
, false);
601 REG_SET(DC_IP_REQUEST_CNTL
, 0,
603 dm_logger_write(dc
->ctx
->logger
, LOG_DC
,
604 "Power gated front end %d\n", fe_idx
);
606 if (dc
->public.debug
.sanity_checks
)
607 verify_allow_pstate_change_high(dc
->hwseq
);
610 static void reset_hw_ctx_wrap(
612 struct validate_context
*context
)
617 for (i
= dc
->res_pool
->pipe_count
- 1; i
>= 0 ; i
--) {
618 struct pipe_ctx
*pipe_ctx_old
=
619 &dc
->current_context
->res_ctx
.pipe_ctx
[i
];
620 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
622 /*if (!pipe_ctx_old->stream)
625 if (!pipe_ctx
->stream
|| !pipe_ctx
->surface
)
626 dcn10_power_down_fe(dc
, i
);
627 else if (pipe_need_reprogram(pipe_ctx_old
, pipe_ctx
))
628 reset_front_end(dc
, i
);
631 for (i
= dc
->res_pool
->pipe_count
- 1; i
>= 0 ; i
--) {
632 struct pipe_ctx
*pipe_ctx_old
=
633 &dc
->current_context
->res_ctx
.pipe_ctx
[i
];
634 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
636 if (!pipe_ctx_old
->stream
)
639 if (!pipe_ctx
->stream
||
640 pipe_need_reprogram(pipe_ctx_old
, pipe_ctx
))
641 reset_back_end_for_pipe(dc
, pipe_ctx_old
, dc
->current_context
);
645 static bool patch_address_for_sbs_tb_stereo(
646 struct pipe_ctx
*pipe_ctx
, PHYSICAL_ADDRESS_LOC
*addr
)
648 struct core_surface
*surface
= pipe_ctx
->surface
;
649 bool sec_split
= pipe_ctx
->top_pipe
&&
650 pipe_ctx
->top_pipe
->surface
== pipe_ctx
->surface
;
651 if (sec_split
&& surface
->public.address
.type
== PLN_ADDR_TYPE_GRPH_STEREO
&&
652 (pipe_ctx
->stream
->public.timing
.timing_3d_format
==
653 TIMING_3D_FORMAT_SIDE_BY_SIDE
||
654 pipe_ctx
->stream
->public.timing
.timing_3d_format
==
655 TIMING_3D_FORMAT_TOP_AND_BOTTOM
)) {
656 *addr
= surface
->public.address
.grph_stereo
.left_addr
;
657 surface
->public.address
.grph_stereo
.left_addr
=
658 surface
->public.address
.grph_stereo
.right_addr
;
661 if (pipe_ctx
->stream
->public.view_format
!= VIEW_3D_FORMAT_NONE
&&
662 surface
->public.address
.type
!= PLN_ADDR_TYPE_GRPH_STEREO
) {
663 surface
->public.address
.type
= PLN_ADDR_TYPE_GRPH_STEREO
;
664 surface
->public.address
.grph_stereo
.right_addr
=
665 surface
->public.address
.grph_stereo
.left_addr
;
671 static void update_plane_addr(const struct core_dc
*dc
, struct pipe_ctx
*pipe_ctx
)
673 bool addr_patched
= false;
674 PHYSICAL_ADDRESS_LOC addr
;
675 struct core_surface
*surface
= pipe_ctx
->surface
;
679 addr_patched
= patch_address_for_sbs_tb_stereo(pipe_ctx
, &addr
);
680 pipe_ctx
->mi
->funcs
->mem_input_program_surface_flip_and_addr(
682 &surface
->public.address
,
683 surface
->public.flip_immediate
);
684 surface
->status
.requested_address
= surface
->public.address
;
686 pipe_ctx
->surface
->public.address
.grph_stereo
.left_addr
= addr
;
689 static bool dcn10_set_input_transfer_func(
690 struct pipe_ctx
*pipe_ctx
, const struct core_surface
*surface
)
692 struct input_pixel_processor
*ipp
= pipe_ctx
->ipp
;
693 const struct dc_transfer_func
*tf
= NULL
;
699 if (surface
->public.in_transfer_func
)
700 tf
= surface
->public.in_transfer_func
;
702 if (surface
->public.gamma_correction
&& dce_use_lut(surface
))
703 ipp
->funcs
->ipp_program_input_lut(ipp
,
704 surface
->public.gamma_correction
);
707 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_BYPASS
);
708 else if (tf
->type
== TF_TYPE_PREDEFINED
) {
710 case TRANSFER_FUNCTION_SRGB
:
711 ipp
->funcs
->ipp_set_degamma(ipp
,
712 IPP_DEGAMMA_MODE_HW_sRGB
);
714 case TRANSFER_FUNCTION_BT709
:
715 ipp
->funcs
->ipp_set_degamma(ipp
,
716 IPP_DEGAMMA_MODE_HW_xvYCC
);
718 case TRANSFER_FUNCTION_LINEAR
:
719 ipp
->funcs
->ipp_set_degamma(ipp
,
720 IPP_DEGAMMA_MODE_BYPASS
);
722 case TRANSFER_FUNCTION_PQ
:
729 } else if (tf
->type
== TF_TYPE_BYPASS
) {
730 ipp
->funcs
->ipp_set_degamma(ipp
, IPP_DEGAMMA_MODE_BYPASS
);
732 /*TF_TYPE_DISTRIBUTED_POINTS*/
738 /*modify the method to handle rgb for arr_points*/
739 static bool convert_to_custom_float(
740 struct pwl_result_data
*rgb_resulted
,
741 struct curve_points
*arr_points
,
742 uint32_t hw_points_num
)
744 struct custom_float_format fmt
;
746 struct pwl_result_data
*rgb
= rgb_resulted
;
750 fmt
.exponenta_bits
= 6;
751 fmt
.mantissa_bits
= 12;
754 if (!convert_to_custom_float_format(
757 &arr_points
[0].custom_float_x
)) {
762 if (!convert_to_custom_float_format(
763 arr_points
[0].offset
,
765 &arr_points
[0].custom_float_offset
)) {
770 if (!convert_to_custom_float_format(
773 &arr_points
[0].custom_float_slope
)) {
778 fmt
.mantissa_bits
= 10;
781 if (!convert_to_custom_float_format(
784 &arr_points
[1].custom_float_x
)) {
789 if (!convert_to_custom_float_format(
792 &arr_points
[1].custom_float_y
)) {
797 if (!convert_to_custom_float_format(
800 &arr_points
[1].custom_float_slope
)) {
805 fmt
.mantissa_bits
= 12;
808 while (i
!= hw_points_num
) {
809 if (!convert_to_custom_float_format(
817 if (!convert_to_custom_float_format(
825 if (!convert_to_custom_float_format(
833 if (!convert_to_custom_float_format(
836 &rgb
->delta_red_reg
)) {
841 if (!convert_to_custom_float_format(
844 &rgb
->delta_green_reg
)) {
849 if (!convert_to_custom_float_format(
852 &rgb
->delta_blue_reg
)) {
863 #define MAX_REGIONS_NUMBER 34
864 #define MAX_LOW_POINT 25
865 #define NUMBER_SEGMENTS 32
867 static bool dcn10_translate_regamma_to_hw_format(const struct dc_transfer_func
868 *output_tf
, struct pwl_params
*regamma_params
)
870 struct curve_points
*arr_points
;
871 struct pwl_result_data
*rgb_resulted
;
872 struct pwl_result_data
*rgb
;
873 struct pwl_result_data
*rgb_plus_1
;
874 struct fixed31_32 y_r
;
875 struct fixed31_32 y_g
;
876 struct fixed31_32 y_b
;
877 struct fixed31_32 y1_min
;
878 struct fixed31_32 y3_max
;
880 int32_t segment_start
, segment_end
;
882 uint32_t j
, k
, seg_distr
[MAX_REGIONS_NUMBER
], increment
, start_index
, hw_points
;
884 if (output_tf
== NULL
|| regamma_params
== NULL
||
885 output_tf
->type
== TF_TYPE_BYPASS
)
888 arr_points
= regamma_params
->arr_points
;
889 rgb_resulted
= regamma_params
->rgb_resulted
;
892 memset(regamma_params
, 0, sizeof(struct pwl_params
));
893 memset(seg_distr
, 0, sizeof(seg_distr
));
895 if (output_tf
->tf
== TRANSFER_FUNCTION_PQ
) {
897 * segments are from 2^-25 to 2^7
899 for (i
= 0; i
< 32 ; i
++)
906 * segment is from 2^-10 to 2^0
907 * There are less than 256 points, for optimization
924 for (i
= segment_end
- segment_start
; i
< MAX_REGIONS_NUMBER
; i
++)
927 for (k
= 0; k
< MAX_REGIONS_NUMBER
; k
++) {
928 if (seg_distr
[k
] != -1)
929 hw_points
+= (1 << seg_distr
[k
]);
933 for (k
= 0; k
< (segment_end
- segment_start
); k
++) {
934 increment
= NUMBER_SEGMENTS
/ (1 << seg_distr
[k
]);
935 start_index
= (segment_start
+ k
+ MAX_LOW_POINT
) * NUMBER_SEGMENTS
;
936 for (i
= start_index
; i
< start_index
+ NUMBER_SEGMENTS
; i
+= increment
) {
937 if (j
== hw_points
- 1)
939 rgb_resulted
[j
].red
= output_tf
->tf_pts
.red
[i
];
940 rgb_resulted
[j
].green
= output_tf
->tf_pts
.green
[i
];
941 rgb_resulted
[j
].blue
= output_tf
->tf_pts
.blue
[i
];
947 start_index
= (segment_end
+ MAX_LOW_POINT
) * NUMBER_SEGMENTS
;
948 rgb_resulted
[hw_points
- 1].red
=
949 output_tf
->tf_pts
.red
[start_index
];
950 rgb_resulted
[hw_points
- 1].green
=
951 output_tf
->tf_pts
.green
[start_index
];
952 rgb_resulted
[hw_points
- 1].blue
=
953 output_tf
->tf_pts
.blue
[start_index
];
955 arr_points
[0].x
= dal_fixed31_32_pow(dal_fixed31_32_from_int(2),
956 dal_fixed31_32_from_int(segment_start
));
957 arr_points
[1].x
= dal_fixed31_32_pow(dal_fixed31_32_from_int(2),
958 dal_fixed31_32_from_int(segment_end
));
959 arr_points
[2].x
= dal_fixed31_32_pow(dal_fixed31_32_from_int(2),
960 dal_fixed31_32_from_int(segment_end
));
962 y_r
= rgb_resulted
[0].red
;
963 y_g
= rgb_resulted
[0].green
;
964 y_b
= rgb_resulted
[0].blue
;
966 y1_min
= dal_fixed31_32_min(y_r
, dal_fixed31_32_min(y_g
, y_b
));
968 arr_points
[0].y
= y1_min
;
969 arr_points
[0].slope
= dal_fixed31_32_div(
972 y_r
= rgb_resulted
[hw_points
- 1].red
;
973 y_g
= rgb_resulted
[hw_points
- 1].green
;
974 y_b
= rgb_resulted
[hw_points
- 1].blue
;
976 /* see comment above, m_arrPoints[1].y should be the Y value for the
977 * region end (m_numOfHwPoints), not last HW point(m_numOfHwPoints - 1)
979 y3_max
= dal_fixed31_32_max(y_r
, dal_fixed31_32_max(y_g
, y_b
));
981 arr_points
[1].y
= y3_max
;
982 arr_points
[2].y
= y3_max
;
984 arr_points
[1].slope
= dal_fixed31_32_zero
;
985 arr_points
[2].slope
= dal_fixed31_32_zero
;
987 if (output_tf
->tf
== TRANSFER_FUNCTION_PQ
) {
988 /* for PQ, we want to have a straight line from last HW X point,
989 * and the slope to be such that we hit 1.0 at 10000 nits.
991 const struct fixed31_32 end_value
=
992 dal_fixed31_32_from_int(125);
994 arr_points
[1].slope
= dal_fixed31_32_div(
995 dal_fixed31_32_sub(dal_fixed31_32_one
, arr_points
[1].y
),
996 dal_fixed31_32_sub(end_value
, arr_points
[1].x
));
997 arr_points
[2].slope
= dal_fixed31_32_div(
998 dal_fixed31_32_sub(dal_fixed31_32_one
, arr_points
[1].y
),
999 dal_fixed31_32_sub(end_value
, arr_points
[1].x
));
1002 regamma_params
->hw_points_num
= hw_points
;
1005 for (k
= 0; k
< MAX_REGIONS_NUMBER
&& i
< MAX_REGIONS_NUMBER
; k
++) {
1006 if (seg_distr
[k
] != -1) {
1007 regamma_params
->arr_curve_points
[k
].segments_num
=
1009 regamma_params
->arr_curve_points
[i
].offset
=
1010 regamma_params
->arr_curve_points
[k
].
1011 offset
+ (1 << seg_distr
[k
]);
1016 if (seg_distr
[k
] != -1)
1017 regamma_params
->arr_curve_points
[k
].segments_num
=
1021 rgb_plus_1
= rgb_resulted
+ 1;
1025 while (i
!= hw_points
+ 1) {
1026 if (dal_fixed31_32_lt(rgb_plus_1
->red
, rgb
->red
))
1027 rgb_plus_1
->red
= rgb
->red
;
1028 if (dal_fixed31_32_lt(rgb_plus_1
->green
, rgb
->green
))
1029 rgb_plus_1
->green
= rgb
->green
;
1030 if (dal_fixed31_32_lt(rgb_plus_1
->blue
, rgb
->blue
))
1031 rgb_plus_1
->blue
= rgb
->blue
;
1033 rgb
->delta_red
= dal_fixed31_32_sub(
1036 rgb
->delta_green
= dal_fixed31_32_sub(
1039 rgb
->delta_blue
= dal_fixed31_32_sub(
1048 convert_to_custom_float(rgb_resulted
, arr_points
, hw_points
);
1053 static bool dcn10_set_output_transfer_func(
1054 struct pipe_ctx
*pipe_ctx
,
1055 const struct core_stream
*stream
)
1057 struct output_pixel_processor
*opp
= pipe_ctx
->opp
;
1062 opp
->regamma_params
.hw_points_num
= GAMMA_HW_POINTS_NUM
;
1064 if (stream
->public.out_transfer_func
&&
1065 stream
->public.out_transfer_func
->type
==
1066 TF_TYPE_PREDEFINED
&&
1067 stream
->public.out_transfer_func
->tf
==
1068 TRANSFER_FUNCTION_SRGB
) {
1069 opp
->funcs
->opp_set_regamma_mode(opp
, OPP_REGAMMA_SRGB
);
1070 } else if (dcn10_translate_regamma_to_hw_format(
1071 stream
->public.out_transfer_func
, &opp
->regamma_params
)) {
1072 opp
->funcs
->opp_program_regamma_pwl(opp
, &opp
->regamma_params
);
1073 opp
->funcs
->opp_set_regamma_mode(opp
, OPP_REGAMMA_USER
);
1075 opp
->funcs
->opp_set_regamma_mode(opp
, OPP_REGAMMA_BYPASS
);
1081 static void dcn10_pipe_control_lock(
1083 struct pipe_ctx
*pipe
,
1086 /* use TG master update lock to lock everything on the TG
1087 * therefore only top pipe need to lock
1092 if (dc
->public.debug
.sanity_checks
)
1093 verify_allow_pstate_change_high(dc
->hwseq
);
1096 pipe
->tg
->funcs
->lock(pipe
->tg
);
1098 pipe
->tg
->funcs
->unlock(pipe
->tg
);
1100 if (dc
->public.debug
.sanity_checks
)
1101 verify_allow_pstate_change_high(dc
->hwseq
);
1104 static bool wait_for_reset_trigger_to_occur(
1105 struct dc_context
*dc_ctx
,
1106 struct timing_generator
*tg
)
1110 /* To avoid endless loop we wait at most
1111 * frames_to_wait_on_triggered_reset frames for the reset to occur. */
1112 const uint32_t frames_to_wait_on_triggered_reset
= 10;
1115 for (i
= 0; i
< frames_to_wait_on_triggered_reset
; i
++) {
1117 if (!tg
->funcs
->is_counter_moving(tg
)) {
1118 DC_ERROR("TG counter is not moving!\n");
1122 if (tg
->funcs
->did_triggered_reset_occur(tg
)) {
1124 /* usually occurs at i=1 */
1125 DC_SYNC_INFO("GSL: reset occurred at wait count: %d\n",
1130 /* Wait for one frame. */
1131 tg
->funcs
->wait_for_state(tg
, CRTC_STATE_VACTIVE
);
1132 tg
->funcs
->wait_for_state(tg
, CRTC_STATE_VBLANK
);
1136 DC_ERROR("GSL: Timeout on reset trigger!\n");
1141 static void dcn10_enable_timing_synchronization(
1145 struct pipe_ctx
*grouped_pipes
[])
1147 struct dc_context
*dc_ctx
= dc
->ctx
;
1150 DC_SYNC_INFO("Setting up OTG reset trigger\n");
1152 for (i
= 1; i
< group_size
; i
++)
1153 grouped_pipes
[i
]->tg
->funcs
->enable_reset_trigger(
1154 grouped_pipes
[i
]->tg
, grouped_pipes
[0]->tg
->inst
);
1157 DC_SYNC_INFO("Waiting for trigger\n");
1159 /* Need to get only check 1 pipe for having reset as all the others are
1160 * synchronized. Look at last pipe programmed to reset.
1162 wait_for_reset_trigger_to_occur(dc_ctx
, grouped_pipes
[1]->tg
);
1163 for (i
= 1; i
< group_size
; i
++)
1164 grouped_pipes
[i
]->tg
->funcs
->disable_reset_trigger(
1165 grouped_pipes
[i
]->tg
);
1167 DC_SYNC_INFO("Sync complete\n");
1170 static void print_rq_dlg_ttu(
1171 struct core_dc
*core_dc
,
1172 struct pipe_ctx
*pipe_ctx
)
1174 dm_logger_write(core_dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1175 "\n============== DML TTU Output parameters [%d] ==============\n"
1176 "qos_level_low_wm: %d, \n"
1177 "qos_level_high_wm: %d, \n"
1178 "min_ttu_vblank: %d, \n"
1179 "qos_level_flip: %d, \n"
1180 "refcyc_per_req_delivery_l: %d, \n"
1181 "qos_level_fixed_l: %d, \n"
1182 "qos_ramp_disable_l: %d, \n"
1183 "refcyc_per_req_delivery_pre_l: %d, \n"
1184 "refcyc_per_req_delivery_c: %d, \n"
1185 "qos_level_fixed_c: %d, \n"
1186 "qos_ramp_disable_c: %d, \n"
1187 "refcyc_per_req_delivery_pre_c: %d\n"
1188 "=============================================================\n",
1190 pipe_ctx
->ttu_regs
.qos_level_low_wm
,
1191 pipe_ctx
->ttu_regs
.qos_level_high_wm
,
1192 pipe_ctx
->ttu_regs
.min_ttu_vblank
,
1193 pipe_ctx
->ttu_regs
.qos_level_flip
,
1194 pipe_ctx
->ttu_regs
.refcyc_per_req_delivery_l
,
1195 pipe_ctx
->ttu_regs
.qos_level_fixed_l
,
1196 pipe_ctx
->ttu_regs
.qos_ramp_disable_l
,
1197 pipe_ctx
->ttu_regs
.refcyc_per_req_delivery_pre_l
,
1198 pipe_ctx
->ttu_regs
.refcyc_per_req_delivery_c
,
1199 pipe_ctx
->ttu_regs
.qos_level_fixed_c
,
1200 pipe_ctx
->ttu_regs
.qos_ramp_disable_c
,
1201 pipe_ctx
->ttu_regs
.refcyc_per_req_delivery_pre_c
1204 dm_logger_write(core_dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1205 "\n============== DML DLG Output parameters [%d] ==============\n"
1206 "refcyc_h_blank_end: %d, \n"
1207 "dlg_vblank_end: %d, \n"
1208 "min_dst_y_next_start: %d, \n"
1209 "refcyc_per_htotal: %d, \n"
1210 "refcyc_x_after_scaler: %d, \n"
1211 "dst_y_after_scaler: %d, \n"
1212 "dst_y_prefetch: %d, \n"
1213 "dst_y_per_vm_vblank: %d, \n"
1214 "dst_y_per_row_vblank: %d, \n"
1215 "ref_freq_to_pix_freq: %d, \n"
1216 "vratio_prefetch: %d, \n"
1217 "refcyc_per_pte_group_vblank_l: %d, \n"
1218 "refcyc_per_meta_chunk_vblank_l: %d, \n"
1219 "dst_y_per_pte_row_nom_l: %d, \n"
1220 "refcyc_per_pte_group_nom_l: %d, \n",
1222 pipe_ctx
->dlg_regs
.refcyc_h_blank_end
,
1223 pipe_ctx
->dlg_regs
.dlg_vblank_end
,
1224 pipe_ctx
->dlg_regs
.min_dst_y_next_start
,
1225 pipe_ctx
->dlg_regs
.refcyc_per_htotal
,
1226 pipe_ctx
->dlg_regs
.refcyc_x_after_scaler
,
1227 pipe_ctx
->dlg_regs
.dst_y_after_scaler
,
1228 pipe_ctx
->dlg_regs
.dst_y_prefetch
,
1229 pipe_ctx
->dlg_regs
.dst_y_per_vm_vblank
,
1230 pipe_ctx
->dlg_regs
.dst_y_per_row_vblank
,
1231 pipe_ctx
->dlg_regs
.ref_freq_to_pix_freq
,
1232 pipe_ctx
->dlg_regs
.vratio_prefetch
,
1233 pipe_ctx
->dlg_regs
.refcyc_per_pte_group_vblank_l
,
1234 pipe_ctx
->dlg_regs
.refcyc_per_meta_chunk_vblank_l
,
1235 pipe_ctx
->dlg_regs
.dst_y_per_pte_row_nom_l
,
1236 pipe_ctx
->dlg_regs
.refcyc_per_pte_group_nom_l
1239 dm_logger_write(core_dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1240 "\ndst_y_per_meta_row_nom_l: %d, \n"
1241 "refcyc_per_meta_chunk_nom_l: %d, \n"
1242 "refcyc_per_line_delivery_pre_l: %d, \n"
1243 "refcyc_per_line_delivery_l: %d, \n"
1244 "vratio_prefetch_c: %d, \n"
1245 "refcyc_per_pte_group_vblank_c: %d, \n"
1246 "refcyc_per_meta_chunk_vblank_c: %d, \n"
1247 "dst_y_per_pte_row_nom_c: %d, \n"
1248 "refcyc_per_pte_group_nom_c: %d, \n"
1249 "dst_y_per_meta_row_nom_c: %d, \n"
1250 "refcyc_per_meta_chunk_nom_c: %d, \n"
1251 "refcyc_per_line_delivery_pre_c: %d, \n"
1252 "refcyc_per_line_delivery_c: %d \n"
1253 "========================================================\n",
1254 pipe_ctx
->dlg_regs
.dst_y_per_meta_row_nom_l
,
1255 pipe_ctx
->dlg_regs
.refcyc_per_meta_chunk_nom_l
,
1256 pipe_ctx
->dlg_regs
.refcyc_per_line_delivery_pre_l
,
1257 pipe_ctx
->dlg_regs
.refcyc_per_line_delivery_l
,
1258 pipe_ctx
->dlg_regs
.vratio_prefetch_c
,
1259 pipe_ctx
->dlg_regs
.refcyc_per_pte_group_vblank_c
,
1260 pipe_ctx
->dlg_regs
.refcyc_per_meta_chunk_vblank_c
,
1261 pipe_ctx
->dlg_regs
.dst_y_per_pte_row_nom_c
,
1262 pipe_ctx
->dlg_regs
.refcyc_per_pte_group_nom_c
,
1263 pipe_ctx
->dlg_regs
.dst_y_per_meta_row_nom_c
,
1264 pipe_ctx
->dlg_regs
.refcyc_per_meta_chunk_nom_c
,
1265 pipe_ctx
->dlg_regs
.refcyc_per_line_delivery_pre_c
,
1266 pipe_ctx
->dlg_regs
.refcyc_per_line_delivery_c
1269 dm_logger_write(core_dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1270 "\n============== DML RQ Output parameters [%d] ==============\n"
1272 "min_chunk_size: %d \n"
1273 "meta_chunk_size: %d \n"
1274 "min_meta_chunk_size: %d \n"
1275 "dpte_group_size: %d \n"
1276 "mpte_group_size: %d \n"
1277 "swath_height: %d \n"
1278 "pte_row_height_linear: %d \n"
1279 "========================================================\n",
1281 pipe_ctx
->rq_regs
.rq_regs_l
.chunk_size
,
1282 pipe_ctx
->rq_regs
.rq_regs_l
.min_chunk_size
,
1283 pipe_ctx
->rq_regs
.rq_regs_l
.meta_chunk_size
,
1284 pipe_ctx
->rq_regs
.rq_regs_l
.min_meta_chunk_size
,
1285 pipe_ctx
->rq_regs
.rq_regs_l
.dpte_group_size
,
1286 pipe_ctx
->rq_regs
.rq_regs_l
.mpte_group_size
,
1287 pipe_ctx
->rq_regs
.rq_regs_l
.swath_height
,
1288 pipe_ctx
->rq_regs
.rq_regs_l
.pte_row_height_linear
1292 static void dcn10_power_on_fe(
1294 struct pipe_ctx
*pipe_ctx
,
1295 struct validate_context
*context
)
1297 struct dc_surface
*dc_surface
= &pipe_ctx
->surface
->public;
1298 struct dce_hwseq
*hws
= dc
->hwseq
;
1300 power_on_plane(dc
->hwseq
,
1301 pipe_ctx
->pipe_idx
);
1303 /* enable DCFCLK current DCHUB */
1304 REG_UPDATE(HUBP_CLK_CNTL
[pipe_ctx
->pipe_idx
],
1305 HUBP_CLOCK_ENABLE
, 1);
1307 /* make sure OPP_PIPE_CLOCK_EN = 1 */
1308 REG_UPDATE(OPP_PIPE_CONTROL
[pipe_ctx
->tg
->inst
],
1309 OPP_PIPE_CLOCK_EN
, 1);
1310 /*TODO: REG_UPDATE(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, 0x1f);*/
1313 dm_logger_write(dc
->ctx
->logger
, LOG_DC
,
1314 "Pipe:%d 0x%x: addr hi:0x%x, "
1317 " %d; dst: %d, %d, %d, %d;\n",
1320 dc_surface
->address
.grph
.addr
.high_part
,
1321 dc_surface
->address
.grph
.addr
.low_part
,
1322 dc_surface
->src_rect
.x
,
1323 dc_surface
->src_rect
.y
,
1324 dc_surface
->src_rect
.width
,
1325 dc_surface
->src_rect
.height
,
1326 dc_surface
->dst_rect
.x
,
1327 dc_surface
->dst_rect
.y
,
1328 dc_surface
->dst_rect
.width
,
1329 dc_surface
->dst_rect
.height
);
1331 dm_logger_write(dc
->ctx
->logger
, LOG_HW_SET_MODE
,
1332 "Pipe %d: width, height, x, y\n"
1333 "viewport:%d, %d, %d, %d\n"
1334 "recout: %d, %d, %d, %d\n",
1336 pipe_ctx
->scl_data
.viewport
.width
,
1337 pipe_ctx
->scl_data
.viewport
.height
,
1338 pipe_ctx
->scl_data
.viewport
.x
,
1339 pipe_ctx
->scl_data
.viewport
.y
,
1340 pipe_ctx
->scl_data
.recout
.width
,
1341 pipe_ctx
->scl_data
.recout
.height
,
1342 pipe_ctx
->scl_data
.recout
.x
,
1343 pipe_ctx
->scl_data
.recout
.y
);
1344 print_rq_dlg_ttu(dc
, pipe_ctx
);
1348 static void program_gamut_remap(struct pipe_ctx
*pipe_ctx
)
1350 struct xfm_grph_csc_adjustment adjust
;
1351 memset(&adjust
, 0, sizeof(adjust
));
1352 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS
;
1355 if (pipe_ctx
->stream
->public.gamut_remap_matrix
.enable_remap
== true) {
1356 adjust
.gamut_adjust_type
= GRAPHICS_GAMUT_ADJUST_TYPE_SW
;
1357 adjust
.temperature_matrix
[0] =
1359 public.gamut_remap_matrix
.matrix
[0];
1360 adjust
.temperature_matrix
[1] =
1362 public.gamut_remap_matrix
.matrix
[1];
1363 adjust
.temperature_matrix
[2] =
1365 public.gamut_remap_matrix
.matrix
[2];
1366 adjust
.temperature_matrix
[3] =
1368 public.gamut_remap_matrix
.matrix
[4];
1369 adjust
.temperature_matrix
[4] =
1371 public.gamut_remap_matrix
.matrix
[5];
1372 adjust
.temperature_matrix
[5] =
1374 public.gamut_remap_matrix
.matrix
[6];
1375 adjust
.temperature_matrix
[6] =
1377 public.gamut_remap_matrix
.matrix
[8];
1378 adjust
.temperature_matrix
[7] =
1380 public.gamut_remap_matrix
.matrix
[9];
1381 adjust
.temperature_matrix
[8] =
1383 public.gamut_remap_matrix
.matrix
[10];
1386 pipe_ctx
->xfm
->funcs
->transform_set_gamut_remap(pipe_ctx
->xfm
, &adjust
);
1390 static void program_csc_matrix(struct pipe_ctx
*pipe_ctx
,
1391 enum dc_color_space colorspace
,
1395 struct out_csc_color_matrix tbl_entry
;
1397 if (pipe_ctx
->stream
->public.csc_color_matrix
.enable_adjustment
1399 enum dc_color_space color_space
=
1400 pipe_ctx
->stream
->public.output_color_space
;
1402 //uint16_t matrix[12];
1403 for (i
= 0; i
< 12; i
++)
1404 tbl_entry
.regval
[i
] = pipe_ctx
->stream
->public.csc_color_matrix
.matrix
[i
];
1406 tbl_entry
.color_space
= color_space
;
1407 //tbl_entry.regval = matrix;
1408 pipe_ctx
->opp
->funcs
->opp_set_csc_adjustment(pipe_ctx
->opp
, &tbl_entry
);
1411 static bool is_lower_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
1413 if (pipe_ctx
->surface
->public.visible
)
1415 if (pipe_ctx
->bottom_pipe
&& is_lower_pipe_tree_visible(pipe_ctx
->bottom_pipe
))
1420 static bool is_upper_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
1422 if (pipe_ctx
->surface
->public.visible
)
1424 if (pipe_ctx
->top_pipe
&& is_upper_pipe_tree_visible(pipe_ctx
->top_pipe
))
1429 static bool is_pipe_tree_visible(struct pipe_ctx
*pipe_ctx
)
1431 if (pipe_ctx
->surface
->public.visible
)
1433 if (pipe_ctx
->top_pipe
&& is_upper_pipe_tree_visible(pipe_ctx
->top_pipe
))
1435 if (pipe_ctx
->bottom_pipe
&& is_lower_pipe_tree_visible(pipe_ctx
->bottom_pipe
))
1440 static bool is_rgb_cspace(enum dc_color_space output_color_space
)
1442 switch (output_color_space
) {
1443 case COLOR_SPACE_SRGB
:
1444 case COLOR_SPACE_SRGB_LIMITED
:
1445 case COLOR_SPACE_2020_RGB_FULLRANGE
:
1446 case COLOR_SPACE_2020_RGB_LIMITEDRANGE
:
1447 case COLOR_SPACE_ADOBERGB
:
1449 case COLOR_SPACE_YCBCR601
:
1450 case COLOR_SPACE_YCBCR709
:
1451 case COLOR_SPACE_YCBCR601_LIMITED
:
1452 case COLOR_SPACE_YCBCR709_LIMITED
:
1453 case COLOR_SPACE_2020_YCBCR
:
1456 /* Add a case to switch */
1457 BREAK_TO_DEBUGGER();
1462 static void dcn10_get_surface_visual_confirm_color(
1463 const struct pipe_ctx
*pipe_ctx
,
1464 struct tg_color
*color
)
1466 uint32_t color_value
= MAX_TG_COLOR_VALUE
;
1468 switch (pipe_ctx
->scl_data
.format
) {
1469 case PIXEL_FORMAT_ARGB8888
:
1470 /* set boarder color to red */
1471 color
->color_r_cr
= color_value
;
1474 case PIXEL_FORMAT_ARGB2101010
:
1475 /* set boarder color to blue */
1476 color
->color_b_cb
= color_value
;
1478 case PIXEL_FORMAT_420BPP8
:
1479 /* set boarder color to green */
1480 color
->color_g_y
= color_value
;
1482 case PIXEL_FORMAT_420BPP10
:
1483 /* set boarder color to yellow */
1484 color
->color_g_y
= color_value
;
1485 color
->color_r_cr
= color_value
;
1487 case PIXEL_FORMAT_FP16
:
1488 /* set boarder color to white */
1489 color
->color_r_cr
= color_value
;
1490 color
->color_b_cb
= color_value
;
1491 color
->color_g_y
= color_value
;
1498 static void update_dchubp_dpp(
1500 struct pipe_ctx
*pipe_ctx
,
1501 struct validate_context
*context
)
1503 struct dce_hwseq
*hws
= dc
->hwseq
;
1504 struct mem_input
*mi
= pipe_ctx
->mi
;
1505 struct input_pixel_processor
*ipp
= pipe_ctx
->ipp
;
1506 struct core_surface
*surface
= pipe_ctx
->surface
;
1507 union plane_size size
= surface
->public.plane_size
;
1508 struct default_adjustment ocsc
= {0};
1509 struct tg_color black_color
= {0};
1510 struct mpcc_cfg mpcc_cfg
;
1511 bool per_pixel_alpha
= surface
->public.per_pixel_alpha
&& pipe_ctx
->bottom_pipe
;
1513 /* TODO: proper fix once fpga works */
1514 /* depends on DML calculation, DPP clock value may change dynamically */
1518 pipe_ctx
->pix_clk_params
.requested_pix_clk
,
1519 context
->bw
.dcn
.calc_clk
.dppclk_div
);
1520 dc
->current_context
->bw
.dcn
.cur_clk
.dppclk_div
=
1521 context
->bw
.dcn
.calc_clk
.dppclk_div
;
1522 context
->bw
.dcn
.cur_clk
.dppclk_div
= context
->bw
.dcn
.calc_clk
.dppclk_div
;
1524 /* TODO: Need input parameter to tell current DCHUB pipe tie to which OTG
1525 * VTG is within DCHUBBUB which is commond block share by each pipe HUBP.
1526 * VTG is 1:1 mapping with OTG. Each pipe HUBP will select which VTG
1528 REG_UPDATE(DCHUBP_CNTL
[pipe_ctx
->pipe_idx
], HUBP_VTG_SEL
, pipe_ctx
->tg
->inst
);
1530 update_plane_addr(dc
, pipe_ctx
);
1532 mi
->funcs
->mem_input_setup(
1534 &pipe_ctx
->dlg_regs
,
1535 &pipe_ctx
->ttu_regs
,
1537 &pipe_ctx
->pipe_dlg_param
);
1539 size
.grph
.surface_size
= pipe_ctx
->scl_data
.viewport
;
1541 if (dc
->public.config
.gpu_vm_support
)
1542 mi
->funcs
->mem_input_program_pte_vm(
1544 surface
->public.format
,
1545 &surface
->public.tiling_info
,
1546 surface
->public.rotation
);
1548 ipp
->funcs
->ipp_setup(ipp
,
1549 surface
->public.format
,
1551 IPP_OUTPUT_FORMAT_12_BIT_FIX
);
1553 pipe_ctx
->scl_data
.lb_params
.alpha_en
= per_pixel_alpha
;
1554 mpcc_cfg
.top_dpp_id
= pipe_ctx
->pipe_idx
;
1555 if (pipe_ctx
->bottom_pipe
)
1556 mpcc_cfg
.bot_mpcc_id
= pipe_ctx
->bottom_pipe
->mpcc
->inst
;
1558 mpcc_cfg
.bot_mpcc_id
= 0xf;
1559 mpcc_cfg
.opp_id
= pipe_ctx
->tg
->inst
;
1560 mpcc_cfg
.top_of_tree
= pipe_ctx
->pipe_idx
== pipe_ctx
->tg
->inst
;
1561 mpcc_cfg
.per_pixel_alpha
= per_pixel_alpha
;
1562 /* DCN1.0 has output CM before MPC which seems to screw with
1563 * pre-multiplied alpha.
1565 mpcc_cfg
.pre_multiplied_alpha
= is_rgb_cspace(
1566 pipe_ctx
->stream
->public.output_color_space
)
1568 pipe_ctx
->mpcc
->funcs
->set(pipe_ctx
->mpcc
, &mpcc_cfg
);
1570 if (dc
->public.debug
.surface_visual_confirm
) {
1571 dcn10_get_surface_visual_confirm_color(pipe_ctx
, &black_color
);
1573 color_space_to_black_color(
1574 dc
, pipe_ctx
->stream
->public.output_color_space
,
1577 pipe_ctx
->mpcc
->funcs
->set_bg_color(pipe_ctx
->mpcc
, &black_color
);
1579 pipe_ctx
->scl_data
.lb_params
.depth
= LB_PIXEL_DEPTH_30BPP
;
1580 /* scaler configuration */
1581 pipe_ctx
->xfm
->funcs
->transform_set_scaler(
1582 pipe_ctx
->xfm
, &pipe_ctx
->scl_data
);
1583 mi
->funcs
->mem_program_viewport(mi
,
1584 &pipe_ctx
->scl_data
.viewport
, &pipe_ctx
->scl_data
.viewport_c
);
1587 program_gamut_remap(pipe_ctx
);
1589 /*TODO add adjustments parameters*/
1590 ocsc
.out_color_space
= pipe_ctx
->stream
->public.output_color_space
;
1591 pipe_ctx
->xfm
->funcs
->opp_set_csc_default(pipe_ctx
->xfm
, &ocsc
);
1593 mi
->funcs
->mem_input_program_surface_config(
1595 surface
->public.format
,
1596 &surface
->public.tiling_info
,
1598 surface
->public.rotation
,
1599 &surface
->public.dcc
,
1600 surface
->public.horizontal_mirror
);
1602 mi
->funcs
->set_blank(mi
, !is_pipe_tree_visible(pipe_ctx
));
1605 static void program_all_pipe_in_tree(
1607 struct pipe_ctx
*pipe_ctx
,
1608 struct validate_context
*context
)
1610 unsigned int ref_clk_mhz
= dc
->res_pool
->ref_clock_inKhz
/1000;
1612 if (pipe_ctx
->top_pipe
== NULL
) {
1614 /* lock otg_master_update to process all pipes associated with
1615 * this OTG. this is done only one time.
1617 /* watermark is for all pipes */
1618 pipe_ctx
->mi
->funcs
->program_watermarks(
1619 pipe_ctx
->mi
, &context
->bw
.dcn
.watermarks
, ref_clk_mhz
);
1621 if (dc
->public.debug
.sanity_checks
) {
1622 /* pstate stuck check after watermark update */
1623 verify_allow_pstate_change_high(dc
->hwseq
);
1626 pipe_ctx
->tg
->funcs
->lock(pipe_ctx
->tg
);
1628 pipe_ctx
->tg
->dlg_otg_param
.vready_offset
= pipe_ctx
->pipe_dlg_param
.vready_offset
;
1629 pipe_ctx
->tg
->dlg_otg_param
.vstartup_start
= pipe_ctx
->pipe_dlg_param
.vstartup_start
;
1630 pipe_ctx
->tg
->dlg_otg_param
.vupdate_offset
= pipe_ctx
->pipe_dlg_param
.vupdate_offset
;
1631 pipe_ctx
->tg
->dlg_otg_param
.vupdate_width
= pipe_ctx
->pipe_dlg_param
.vupdate_width
;
1632 pipe_ctx
->tg
->dlg_otg_param
.signal
= pipe_ctx
->stream
->signal
;
1634 pipe_ctx
->tg
->funcs
->program_global_sync(
1636 pipe_ctx
->tg
->funcs
->set_blank(pipe_ctx
->tg
, !is_pipe_tree_visible(pipe_ctx
));
1639 if (pipe_ctx
->surface
!= NULL
) {
1640 dcn10_power_on_fe(dc
, pipe_ctx
, context
);
1641 update_dchubp_dpp(dc
, pipe_ctx
, context
);
1644 if (dc
->public.debug
.sanity_checks
) {
1645 /* pstate stuck check after each pipe is programmed */
1646 verify_allow_pstate_change_high(dc
->hwseq
);
1649 if (pipe_ctx
->bottom_pipe
!= NULL
)
1650 program_all_pipe_in_tree(dc
, pipe_ctx
->bottom_pipe
, context
);
1653 static void dcn10_pplib_apply_display_requirements(
1655 struct validate_context
*context
)
1657 struct dm_pp_display_configuration
*pp_display_cfg
= &context
->pp_display_cfg
;
1659 pp_display_cfg
->all_displays_in_sync
= false;/*todo*/
1660 pp_display_cfg
->nb_pstate_switch_disable
= false;
1661 pp_display_cfg
->min_engine_clock_khz
= context
->bw
.dcn
.cur_clk
.dcfclk_khz
;
1662 pp_display_cfg
->min_memory_clock_khz
= context
->bw
.dcn
.cur_clk
.fclk_khz
;
1663 pp_display_cfg
->min_engine_clock_deep_sleep_khz
= context
->bw
.dcn
.cur_clk
.dcfclk_deep_sleep_khz
;
1664 pp_display_cfg
->min_dcfc_deep_sleep_clock_khz
= context
->bw
.dcn
.cur_clk
.dcfclk_deep_sleep_khz
;
1665 pp_display_cfg
->avail_mclk_switch_time_us
=
1666 context
->bw
.dcn
.cur_clk
.dram_ccm_us
> 0 ? context
->bw
.dcn
.cur_clk
.dram_ccm_us
: 0;
1667 pp_display_cfg
->avail_mclk_switch_time_in_disp_active_us
=
1668 context
->bw
.dcn
.cur_clk
.min_active_dram_ccm_us
> 0 ? context
->bw
.dcn
.cur_clk
.min_active_dram_ccm_us
: 0;
1669 pp_display_cfg
->min_dcfclock_khz
= context
->bw
.dcn
.cur_clk
.dcfclk_khz
;
1670 pp_display_cfg
->disp_clk_khz
= context
->bw
.dcn
.cur_clk
.dispclk_khz
;
1671 dce110_fill_display_configs(context
, pp_display_cfg
);
1673 if (memcmp(&dc
->prev_display_config
, pp_display_cfg
, sizeof(
1674 struct dm_pp_display_configuration
)) != 0)
1675 dm_pp_apply_display_requirements(dc
->ctx
, pp_display_cfg
);
1677 dc
->prev_display_config
= *pp_display_cfg
;
1680 static void dcn10_apply_ctx_for_surface(
1682 struct core_surface
*surface
,
1683 struct validate_context
*context
)
1687 if (dc
->public.debug
.sanity_checks
)
1688 verify_allow_pstate_change_high(dc
->hwseq
);
1693 for (be_idx
= 0; be_idx
< dc
->res_pool
->pipe_count
; be_idx
++)
1694 if (surface
== context
->res_ctx
.pipe_ctx
[be_idx
].surface
)
1697 /* reset unused mpcc */
1698 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
1699 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
1700 struct pipe_ctx
*old_pipe_ctx
=
1701 &dc
->current_context
->res_ctx
.pipe_ctx
[i
];
1703 if (!pipe_ctx
->surface
&& !old_pipe_ctx
->surface
)
1707 * Powergate reused pipes that are not powergated
1708 * fairly hacky right now, using opp_id as indicator
1711 if (pipe_ctx
->surface
&& !old_pipe_ctx
->surface
) {
1712 if (pipe_ctx
->mpcc
->opp_id
!= 0xf && pipe_ctx
->tg
->inst
== be_idx
) {
1713 dcn10_power_down_fe(dc
, pipe_ctx
->pipe_idx
);
1715 * power down fe will unlock when calling reset, need
1716 * to lock it back here. Messy, need rework.
1718 pipe_ctx
->tg
->funcs
->lock(pipe_ctx
->tg
);
1723 if ((!pipe_ctx
->surface
&& old_pipe_ctx
->surface
)
1724 || (!pipe_ctx
->stream
&& old_pipe_ctx
->stream
)) {
1725 struct mpcc_cfg mpcc_cfg
;
1726 int opp_id_cached
= old_pipe_ctx
->mpcc
->opp_id
;
1728 if (old_pipe_ctx
->tg
->inst
!= be_idx
)
1731 if (!old_pipe_ctx
->top_pipe
) {
1737 mpcc_cfg
.opp_id
= 0xf;
1738 mpcc_cfg
.top_dpp_id
= 0xf;
1739 mpcc_cfg
.bot_mpcc_id
= 0xf;
1740 mpcc_cfg
.top_of_tree
= !old_pipe_ctx
->top_pipe
;
1741 old_pipe_ctx
->mpcc
->funcs
->set(old_pipe_ctx
->mpcc
, &mpcc_cfg
);
1742 old_pipe_ctx
->top_pipe
->opp
->mpcc_disconnect_pending
[old_pipe_ctx
->mpcc
->inst
] = true;
1744 if (dc
->public.debug
.sanity_checks
)
1745 verify_allow_pstate_change_high(dc
->hwseq
);
1748 * the mpcc is the only thing that keeps track of the mpcc
1749 * mapping for reset front end right now. Might need some
1752 old_pipe_ctx
->mpcc
->opp_id
= opp_id_cached
;
1754 old_pipe_ctx
->top_pipe
= NULL
;
1755 old_pipe_ctx
->bottom_pipe
= NULL
;
1756 old_pipe_ctx
->surface
= NULL
;
1758 dm_logger_write(dc
->ctx
->logger
, LOG_DC
,
1759 "Reset mpcc for pipe %d\n",
1760 old_pipe_ctx
->pipe_idx
);
1764 for (i
= 0; i
< dc
->res_pool
->pipe_count
; i
++) {
1765 struct pipe_ctx
*pipe_ctx
= &context
->res_ctx
.pipe_ctx
[i
];
1767 if (pipe_ctx
->surface
!= surface
)
1770 /* looking for top pipe to program */
1771 if (!pipe_ctx
->top_pipe
)
1772 program_all_pipe_in_tree(dc
, pipe_ctx
, context
);
1775 dm_logger_write(dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1776 "\n============== Watermark parameters ==============\n"
1777 "a.urgent_ns: %d \n"
1778 "a.cstate_enter_plus_exit: %d \n"
1779 "a.cstate_exit: %d \n"
1780 "a.pstate_change: %d \n"
1781 "a.pte_meta_urgent: %d \n"
1782 "b.urgent_ns: %d \n"
1783 "b.cstate_enter_plus_exit: %d \n"
1784 "b.cstate_exit: %d \n"
1785 "b.pstate_change: %d \n"
1786 "b.pte_meta_urgent: %d \n",
1787 context
->bw
.dcn
.watermarks
.a
.urgent_ns
,
1788 context
->bw
.dcn
.watermarks
.a
.cstate_pstate
.cstate_enter_plus_exit_ns
,
1789 context
->bw
.dcn
.watermarks
.a
.cstate_pstate
.cstate_exit_ns
,
1790 context
->bw
.dcn
.watermarks
.a
.cstate_pstate
.pstate_change_ns
,
1791 context
->bw
.dcn
.watermarks
.a
.pte_meta_urgent_ns
,
1792 context
->bw
.dcn
.watermarks
.b
.urgent_ns
,
1793 context
->bw
.dcn
.watermarks
.b
.cstate_pstate
.cstate_enter_plus_exit_ns
,
1794 context
->bw
.dcn
.watermarks
.b
.cstate_pstate
.cstate_exit_ns
,
1795 context
->bw
.dcn
.watermarks
.b
.cstate_pstate
.pstate_change_ns
,
1796 context
->bw
.dcn
.watermarks
.b
.pte_meta_urgent_ns
1798 dm_logger_write(dc
->ctx
->logger
, LOG_BANDWIDTH_CALCS
,
1799 "\nc.urgent_ns: %d \n"
1800 "c.cstate_enter_plus_exit: %d \n"
1801 "c.cstate_exit: %d \n"
1802 "c.pstate_change: %d \n"
1803 "c.pte_meta_urgent: %d \n"
1804 "d.urgent_ns: %d \n"
1805 "d.cstate_enter_plus_exit: %d \n"
1806 "d.cstate_exit: %d \n"
1807 "d.pstate_change: %d \n"
1808 "d.pte_meta_urgent: %d \n"
1809 "========================================================\n",
1810 context
->bw
.dcn
.watermarks
.c
.urgent_ns
,
1811 context
->bw
.dcn
.watermarks
.c
.cstate_pstate
.cstate_enter_plus_exit_ns
,
1812 context
->bw
.dcn
.watermarks
.c
.cstate_pstate
.cstate_exit_ns
,
1813 context
->bw
.dcn
.watermarks
.c
.cstate_pstate
.pstate_change_ns
,
1814 context
->bw
.dcn
.watermarks
.c
.pte_meta_urgent_ns
,
1815 context
->bw
.dcn
.watermarks
.d
.urgent_ns
,
1816 context
->bw
.dcn
.watermarks
.d
.cstate_pstate
.cstate_enter_plus_exit_ns
,
1817 context
->bw
.dcn
.watermarks
.d
.cstate_pstate
.cstate_exit_ns
,
1818 context
->bw
.dcn
.watermarks
.d
.cstate_pstate
.pstate_change_ns
,
1819 context
->bw
.dcn
.watermarks
.d
.pte_meta_urgent_ns
1822 if (dc
->public.debug
.sanity_checks
)
1823 verify_allow_pstate_change_high(dc
->hwseq
);
1826 static void dcn10_set_bandwidth(
1828 struct validate_context
*context
,
1829 bool decrease_allowed
)
1831 struct dm_pp_clock_for_voltage_req clock
;
1833 if (IS_FPGA_MAXIMUS_DC(dc
->ctx
->dce_environment
))
1836 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.dispclk_khz
1837 > dc
->current_context
->bw
.dcn
.cur_clk
.dispclk_khz
) {
1838 dc
->res_pool
->display_clock
->funcs
->set_clock(
1839 dc
->res_pool
->display_clock
,
1840 context
->bw
.dcn
.calc_clk
.dispclk_khz
);
1841 dc
->current_context
->bw
.dcn
.cur_clk
.dispclk_khz
=
1842 context
->bw
.dcn
.calc_clk
.dispclk_khz
;
1844 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.dcfclk_khz
1845 > dc
->current_context
->bw
.dcn
.cur_clk
.dcfclk_khz
) {
1846 clock
.clk_type
= DM_PP_CLOCK_TYPE_DCFCLK
;
1847 clock
.clocks_in_khz
= context
->bw
.dcn
.calc_clk
.dcfclk_khz
;
1848 dm_pp_apply_clock_for_voltage_request(dc
->ctx
, &clock
);
1849 dc
->current_context
->bw
.dcn
.cur_clk
.dcfclk_khz
= clock
.clocks_in_khz
;
1850 context
->bw
.dcn
.cur_clk
.dcfclk_khz
= clock
.clocks_in_khz
;
1852 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.fclk_khz
1853 > dc
->current_context
->bw
.dcn
.cur_clk
.fclk_khz
) {
1854 clock
.clk_type
= DM_PP_CLOCK_TYPE_FCLK
;
1855 clock
.clocks_in_khz
= context
->bw
.dcn
.calc_clk
.fclk_khz
;
1856 dm_pp_apply_clock_for_voltage_request(dc
->ctx
, &clock
);
1857 dc
->current_context
->bw
.dcn
.calc_clk
.fclk_khz
= clock
.clocks_in_khz
;
1858 context
->bw
.dcn
.cur_clk
.fclk_khz
= clock
.clocks_in_khz
;
1860 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.dcfclk_deep_sleep_khz
1861 > dc
->current_context
->bw
.dcn
.cur_clk
.dcfclk_deep_sleep_khz
) {
1862 dc
->current_context
->bw
.dcn
.calc_clk
.dcfclk_deep_sleep_khz
=
1863 context
->bw
.dcn
.calc_clk
.dcfclk_deep_sleep_khz
;
1864 context
->bw
.dcn
.cur_clk
.dcfclk_deep_sleep_khz
=
1865 context
->bw
.dcn
.calc_clk
.dcfclk_deep_sleep_khz
;
1867 /* Decrease in freq is increase in period so opposite comparison for dram_ccm */
1868 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.dram_ccm_us
1869 < dc
->current_context
->bw
.dcn
.cur_clk
.dram_ccm_us
) {
1870 dc
->current_context
->bw
.dcn
.calc_clk
.dram_ccm_us
=
1871 context
->bw
.dcn
.calc_clk
.dram_ccm_us
;
1872 context
->bw
.dcn
.cur_clk
.dram_ccm_us
=
1873 context
->bw
.dcn
.calc_clk
.dram_ccm_us
;
1875 if (decrease_allowed
|| context
->bw
.dcn
.calc_clk
.min_active_dram_ccm_us
1876 < dc
->current_context
->bw
.dcn
.cur_clk
.min_active_dram_ccm_us
) {
1877 dc
->current_context
->bw
.dcn
.calc_clk
.min_active_dram_ccm_us
=
1878 context
->bw
.dcn
.calc_clk
.min_active_dram_ccm_us
;
1879 context
->bw
.dcn
.cur_clk
.min_active_dram_ccm_us
=
1880 context
->bw
.dcn
.calc_clk
.min_active_dram_ccm_us
;
1882 dcn10_pplib_apply_display_requirements(dc
, context
);
1884 /* need to fix this function. not doing the right thing here */
1887 static void set_drr(struct pipe_ctx
**pipe_ctx
,
1888 int num_pipes
, int vmin
, int vmax
)
1891 struct drr_params params
= {0};
1893 params
.vertical_total_max
= vmax
;
1894 params
.vertical_total_min
= vmin
;
1896 /* TODO: If multiple pipes are to be supported, you need
1899 for (i
= 0; i
< num_pipes
; i
++) {
1900 pipe_ctx
[i
]->tg
->funcs
->set_drr(pipe_ctx
[i
]->tg
, ¶ms
);
1904 static void get_position(struct pipe_ctx
**pipe_ctx
,
1906 struct crtc_position
*position
)
1910 /* TODO: handle pipes > 1
1912 for (i
= 0; i
< num_pipes
; i
++)
1913 pipe_ctx
[i
]->tg
->funcs
->get_position(pipe_ctx
[i
]->tg
, position
);
1916 static void set_static_screen_control(struct pipe_ctx
**pipe_ctx
,
1917 int num_pipes
, const struct dc_static_screen_events
*events
)
1920 unsigned int value
= 0;
1922 if (events
->surface_update
)
1924 if (events
->cursor_update
)
1927 for (i
= 0; i
< num_pipes
; i
++)
1928 pipe_ctx
[i
]->tg
->funcs
->
1929 set_static_screen_control(pipe_ctx
[i
]->tg
, value
);
1932 static void set_plane_config(
1933 const struct core_dc
*dc
,
1934 struct pipe_ctx
*pipe_ctx
,
1935 struct resource_context
*res_ctx
)
1938 program_gamut_remap(pipe_ctx
);
1941 static void dcn10_config_stereo_parameters(
1942 struct core_stream
*stream
, struct crtc_stereo_flags
*flags
)
1944 enum view_3d_format view_format
= stream
->public.view_format
;
1945 enum dc_timing_3d_format timing_3d_format
=\
1946 stream
->public.timing
.timing_3d_format
;
1947 bool non_stereo_timing
= false;
1949 if (timing_3d_format
== TIMING_3D_FORMAT_NONE
||
1950 timing_3d_format
== TIMING_3D_FORMAT_SIDE_BY_SIDE
||
1951 timing_3d_format
== TIMING_3D_FORMAT_TOP_AND_BOTTOM
)
1952 non_stereo_timing
= true;
1954 if (non_stereo_timing
== false &&
1955 view_format
== VIEW_3D_FORMAT_FRAME_SEQUENTIAL
) {
1957 flags
->PROGRAM_STEREO
= 1;
1958 flags
->PROGRAM_POLARITY
= 1;
1959 if (timing_3d_format
== TIMING_3D_FORMAT_INBAND_FA
||
1960 timing_3d_format
== TIMING_3D_FORMAT_DP_HDMI_INBAND_FA
||
1961 timing_3d_format
== TIMING_3D_FORMAT_SIDEBAND_FA
) {
1962 enum display_dongle_type dongle
= \
1963 stream
->sink
->link
->public.ddc
->dongle_type
;
1964 if (dongle
== DISPLAY_DONGLE_DP_VGA_CONVERTER
||
1965 dongle
== DISPLAY_DONGLE_DP_DVI_CONVERTER
||
1966 dongle
== DISPLAY_DONGLE_DP_HDMI_CONVERTER
)
1967 flags
->DISABLE_STEREO_DP_SYNC
= 1;
1969 flags
->RIGHT_EYE_POLARITY
=\
1970 stream
->public.timing
.flags
.RIGHT_EYE_3D_POLARITY
;
1971 if (timing_3d_format
== TIMING_3D_FORMAT_HW_FRAME_PACKING
)
1972 flags
->FRAME_PACKED
= 1;
1978 static void dcn10_setup_stereo(struct pipe_ctx
*pipe_ctx
, struct core_dc
*dc
)
1980 struct crtc_stereo_flags flags
= { 0 };
1981 struct core_stream
*stream
= pipe_ctx
->stream
;
1983 dcn10_config_stereo_parameters(stream
, &flags
);
1985 pipe_ctx
->opp
->funcs
->opp_set_stereo_polarity(
1987 flags
.PROGRAM_STEREO
== 1 ? true:false,
1988 stream
->public.timing
.flags
.RIGHT_EYE_3D_POLARITY
== 1 ? true:false);
1990 pipe_ctx
->tg
->funcs
->program_stereo(
1992 &stream
->public.timing
,
1998 static void dcn10_log_hw_state(struct core_dc
*dc
)
2000 struct dc_context
*dc_ctx
= dc
->ctx
;
2001 struct dce_hwseq
*hws
= dc
->hwseq
;
2003 DTN_INFO("%s: Hello World", __func__
);
2005 if (REG(MPC_CRC_RESULT_GB
))
2006 DTN_INFO("MPC_CRC_RESULT_GB:%d MPC_CRC_RESULT_C:%d MPC_CRC_RESULT_AR:%d\n",
2007 REG_READ(MPC_CRC_RESULT_GB
), REG_READ(MPC_CRC_RESULT_C
), REG_READ(MPC_CRC_RESULT_AR
));
2008 if (REG(DPP_TOP0_DPP_CRC_VAL_B_A
))
2009 DTN_INFO("DPP_TOP0_DPP_CRC_VAL_B_A:%d DPP_TOP0_DPP_CRC_VAL_R_G:%d\n",
2010 REG_READ(DPP_TOP0_DPP_CRC_VAL_B_A
), REG_READ(DPP_TOP0_DPP_CRC_VAL_R_G
));
2011 /* todo: add meaningful register reads and print out HW state
2016 static void dcn10_wait_for_mpcc_disconnect(struct resource_pool
*res_pool
, struct pipe_ctx
*pipe_ctx
)
2019 for (i
= 0; i
< MAX_PIPES
; i
++) {
2020 if (!pipe_ctx
->opp
|| !pipe_ctx
->mpcc
)
2023 if (pipe_ctx
->opp
->mpcc_disconnect_pending
[i
]) {
2024 pipe_ctx
->mpcc
->funcs
->wait_for_idle(res_pool
->mpcc
[i
]);
2025 pipe_ctx
->opp
->mpcc_disconnect_pending
[i
] = false;
2030 static bool dcn10_dummy_display_power_gating(
2032 uint8_t controller_id
,
2033 struct dc_bios
*dcb
,
2034 enum pipe_gating_control power_gating
)
2039 void dcn10_update_pending_status(struct pipe_ctx
*pipe_ctx
)
2041 struct core_surface
*surface
= pipe_ctx
->surface
;
2042 struct timing_generator
*tg
= pipe_ctx
->tg
;
2044 if (surface
->ctx
->dc
->debug
.sanity_checks
) {
2045 struct core_dc
*dc
= DC_TO_CORE(surface
->ctx
->dc
);
2047 verify_allow_pstate_change_high(dc
->hwseq
);
2050 if (surface
== NULL
)
2053 surface
->status
.is_flip_pending
=
2054 pipe_ctx
->mi
->funcs
->mem_input_is_flip_pending(
2057 /* DCN we read INUSE address in MI, do we still need this wa? */
2058 if (surface
->status
.is_flip_pending
&&
2059 !surface
->public.visible
) {
2060 pipe_ctx
->mi
->current_address
=
2061 pipe_ctx
->mi
->request_address
;
2062 BREAK_TO_DEBUGGER();
2065 surface
->status
.current_address
= pipe_ctx
->mi
->current_address
;
2066 if (pipe_ctx
->mi
->current_address
.type
== PLN_ADDR_TYPE_GRPH_STEREO
&&
2067 tg
->funcs
->is_stereo_left_eye
) {
2068 surface
->status
.is_right_eye
=
2069 !tg
->funcs
->is_stereo_left_eye(pipe_ctx
->tg
);
2073 static const struct hw_sequencer_funcs dcn10_funcs
= {
2074 .program_gamut_remap
= program_gamut_remap
,
2075 .program_csc_matrix
= program_csc_matrix
,
2076 .init_hw
= dcn10_init_hw
,
2077 .apply_ctx_to_hw
= dce110_apply_ctx_to_hw
,
2078 .apply_ctx_for_surface
= dcn10_apply_ctx_for_surface
,
2079 .set_plane_config
= set_plane_config
,
2080 .update_plane_addr
= update_plane_addr
,
2081 .update_pending_status
= dcn10_update_pending_status
,
2082 .set_input_transfer_func
= dcn10_set_input_transfer_func
,
2083 .set_output_transfer_func
= dcn10_set_output_transfer_func
,
2084 .power_down
= dce110_power_down
,
2085 .enable_accelerated_mode
= dce110_enable_accelerated_mode
,
2086 .enable_timing_synchronization
= dcn10_enable_timing_synchronization
,
2087 .update_info_frame
= dce110_update_info_frame
,
2088 .enable_stream
= dce110_enable_stream
,
2089 .disable_stream
= dce110_disable_stream
,
2090 .unblank_stream
= dce110_unblank_stream
,
2091 .enable_display_power_gating
= dcn10_dummy_display_power_gating
,
2092 .power_down_front_end
= dcn10_power_down_fe
,
2093 .power_on_front_end
= dcn10_power_on_fe
,
2094 .pipe_control_lock
= dcn10_pipe_control_lock
,
2095 .set_bandwidth
= dcn10_set_bandwidth
,
2096 .reset_hw_ctx_wrap
= reset_hw_ctx_wrap
,
2097 .prog_pixclk_crtc_otg
= dcn10_prog_pixclk_crtc_otg
,
2099 .get_position
= get_position
,
2100 .set_static_screen_control
= set_static_screen_control
,
2101 .setup_stereo
= dcn10_setup_stereo
,
2102 .set_avmute
= dce110_set_avmute
,
2103 .log_hw_state
= dcn10_log_hw_state
,
2104 .wait_for_mpcc_disconnect
= dcn10_wait_for_mpcc_disconnect
2108 void dcn10_hw_sequencer_construct(struct core_dc
*dc
)
2110 dc
->hwss
= dcn10_funcs
;