1 /*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
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.
21 *
22 * Authors: AMD
23 *
24 */
25 #include <linux/delay.h>
26
27 #include "dm_services.h"
28 #include "basics/dc_common.h"
29 #include "dm_helpers.h"
30 #include "core_types.h"
31 #include "resource.h"
32 #include "dcn20_resource.h"
33 #include "dcn20_hwseq.h"
34 #include "dce/dce_hwseq.h"
35 #include "dcn20_dsc.h"
36 #include "dcn20_optc.h"
37 #include "abm.h"
38 #include "clk_mgr.h"
39 #include "dmcu.h"
40 #include "hubp.h"
41 #include "timing_generator.h"
42 #include "opp.h"
43 #include "ipp.h"
44 #include "mpc.h"
45 #include "mcif_wb.h"
46 #include "dchubbub.h"
47 #include "reg_helper.h"
48 #include "dcn10/dcn10_cm_common.h"
49 #include "vm_helper.h"
50 #include "dccg.h"
51 #include "dc_dmub_srv.h"
52 #include "dce/dmub_hw_lock_mgr.h"
53 #include "hw_sequencer.h"
54 #include "dpcd_defs.h"
55 #include "inc/link_enc_cfg.h"
56 #include "link_hwss.h"
57 #include "link.h"
58
59 #define DC_LOGGER_INIT(logger)
60
61 #define CTX \
62 hws->ctx
63 #define REG(reg)\
64 hws->regs->reg
65
66 #undef FN
67 #define FN(reg_name, field_name) \
68 hws->shifts->field_name, hws->masks->field_name
69
find_free_gsl_group(const struct dc * dc)70 static int find_free_gsl_group(const struct dc *dc)
71 {
72 if (dc->res_pool->gsl_groups.gsl_0 == 0)
73 return 1;
74 if (dc->res_pool->gsl_groups.gsl_1 == 0)
75 return 2;
76 if (dc->res_pool->gsl_groups.gsl_2 == 0)
77 return 3;
78
79 return 0;
80 }
81
82 /* NOTE: This is not a generic setup_gsl function (hence the suffix as_lock)
83 * This is only used to lock pipes in pipe splitting case with immediate flip
84 * Ordinary MPC/OTG locks suppress VUPDATE which doesn't help with immediate,
85 * so we get tearing with freesync since we cannot flip multiple pipes
86 * atomically.
87 * We use GSL for this:
88 * - immediate flip: find first available GSL group if not already assigned
89 * program gsl with that group, set current OTG as master
90 * and always us 0x4 = AND of flip_ready from all pipes
91 * - vsync flip: disable GSL if used
92 *
93 * Groups in stream_res are stored as +1 from HW registers, i.e.
94 * gsl_0 <=> pipe_ctx->stream_res.gsl_group == 1
95 * Using a magic value like -1 would require tracking all inits/resets
96 */
dcn20_setup_gsl_group_as_lock(const struct dc * dc,struct pipe_ctx * pipe_ctx,bool enable)97 static void dcn20_setup_gsl_group_as_lock(
98 const struct dc *dc,
99 struct pipe_ctx *pipe_ctx,
100 bool enable)
101 {
102 struct gsl_params gsl;
103 int group_idx;
104
105 memset(&gsl, 0, sizeof(struct gsl_params));
106
107 if (enable) {
108 /* return if group already assigned since GSL was set up
109 * for vsync flip, we would unassign so it can't be "left over"
110 */
111 if (pipe_ctx->stream_res.gsl_group > 0)
112 return;
113
114 group_idx = find_free_gsl_group(dc);
115 ASSERT(group_idx != 0);
116 pipe_ctx->stream_res.gsl_group = group_idx;
117
118 /* set gsl group reg field and mark resource used */
119 switch (group_idx) {
120 case 1:
121 gsl.gsl0_en = 1;
122 dc->res_pool->gsl_groups.gsl_0 = 1;
123 break;
124 case 2:
125 gsl.gsl1_en = 1;
126 dc->res_pool->gsl_groups.gsl_1 = 1;
127 break;
128 case 3:
129 gsl.gsl2_en = 1;
130 dc->res_pool->gsl_groups.gsl_2 = 1;
131 break;
132 default:
133 BREAK_TO_DEBUGGER();
134 return; // invalid case
135 }
136 gsl.gsl_master_en = 1;
137 } else {
138 group_idx = pipe_ctx->stream_res.gsl_group;
139 if (group_idx == 0)
140 return; // if not in use, just return
141
142 pipe_ctx->stream_res.gsl_group = 0;
143
144 /* unset gsl group reg field and mark resource free */
145 switch (group_idx) {
146 case 1:
147 gsl.gsl0_en = 0;
148 dc->res_pool->gsl_groups.gsl_0 = 0;
149 break;
150 case 2:
151 gsl.gsl1_en = 0;
152 dc->res_pool->gsl_groups.gsl_1 = 0;
153 break;
154 case 3:
155 gsl.gsl2_en = 0;
156 dc->res_pool->gsl_groups.gsl_2 = 0;
157 break;
158 default:
159 BREAK_TO_DEBUGGER();
160 return;
161 }
162 gsl.gsl_master_en = 0;
163 }
164
165 /* at this point we want to program whether it's to enable or disable */
166 if (pipe_ctx->stream_res.tg->funcs->set_gsl != NULL &&
167 pipe_ctx->stream_res.tg->funcs->set_gsl_source_select != NULL) {
168 pipe_ctx->stream_res.tg->funcs->set_gsl(
169 pipe_ctx->stream_res.tg,
170 &gsl);
171
172 pipe_ctx->stream_res.tg->funcs->set_gsl_source_select(
173 pipe_ctx->stream_res.tg, group_idx, enable ? 4 : 0);
174 } else
175 BREAK_TO_DEBUGGER();
176 }
177
dcn20_set_flip_control_gsl(struct pipe_ctx * pipe_ctx,bool flip_immediate)178 void dcn20_set_flip_control_gsl(
179 struct pipe_ctx *pipe_ctx,
180 bool flip_immediate)
181 {
182 if (pipe_ctx && pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_control_surface_gsl)
183 pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_control_surface_gsl(
184 pipe_ctx->plane_res.hubp, flip_immediate);
185
186 }
187
dcn20_enable_power_gating_plane(struct dce_hwseq * hws,bool enable)188 void dcn20_enable_power_gating_plane(
189 struct dce_hwseq *hws,
190 bool enable)
191 {
192 bool force_on = true; /* disable power gating */
193 uint32_t org_ip_request_cntl = 0;
194
195 if (enable)
196 force_on = false;
197
198 REG_GET(DC_IP_REQUEST_CNTL, IP_REQUEST_EN, &org_ip_request_cntl);
199 if (org_ip_request_cntl == 0)
200 REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 1);
201
202 /* DCHUBP0/1/2/3/4/5 */
203 REG_UPDATE(DOMAIN0_PG_CONFIG, DOMAIN0_POWER_FORCEON, force_on);
204 REG_UPDATE(DOMAIN2_PG_CONFIG, DOMAIN2_POWER_FORCEON, force_on);
205 REG_UPDATE(DOMAIN4_PG_CONFIG, DOMAIN4_POWER_FORCEON, force_on);
206 REG_UPDATE(DOMAIN6_PG_CONFIG, DOMAIN6_POWER_FORCEON, force_on);
207 if (REG(DOMAIN8_PG_CONFIG))
208 REG_UPDATE(DOMAIN8_PG_CONFIG, DOMAIN8_POWER_FORCEON, force_on);
209 if (REG(DOMAIN10_PG_CONFIG))
210 REG_UPDATE(DOMAIN10_PG_CONFIG, DOMAIN8_POWER_FORCEON, force_on);
211
212 /* DPP0/1/2/3/4/5 */
213 REG_UPDATE(DOMAIN1_PG_CONFIG, DOMAIN1_POWER_FORCEON, force_on);
214 REG_UPDATE(DOMAIN3_PG_CONFIG, DOMAIN3_POWER_FORCEON, force_on);
215 REG_UPDATE(DOMAIN5_PG_CONFIG, DOMAIN5_POWER_FORCEON, force_on);
216 REG_UPDATE(DOMAIN7_PG_CONFIG, DOMAIN7_POWER_FORCEON, force_on);
217 if (REG(DOMAIN9_PG_CONFIG))
218 REG_UPDATE(DOMAIN9_PG_CONFIG, DOMAIN9_POWER_FORCEON, force_on);
219 if (REG(DOMAIN11_PG_CONFIG))
220 REG_UPDATE(DOMAIN11_PG_CONFIG, DOMAIN9_POWER_FORCEON, force_on);
221
222 /* DCS0/1/2/3/4/5 */
223 REG_UPDATE(DOMAIN16_PG_CONFIG, DOMAIN16_POWER_FORCEON, force_on);
224 REG_UPDATE(DOMAIN17_PG_CONFIG, DOMAIN17_POWER_FORCEON, force_on);
225 REG_UPDATE(DOMAIN18_PG_CONFIG, DOMAIN18_POWER_FORCEON, force_on);
226 if (REG(DOMAIN19_PG_CONFIG))
227 REG_UPDATE(DOMAIN19_PG_CONFIG, DOMAIN19_POWER_FORCEON, force_on);
228 if (REG(DOMAIN20_PG_CONFIG))
229 REG_UPDATE(DOMAIN20_PG_CONFIG, DOMAIN20_POWER_FORCEON, force_on);
230 if (REG(DOMAIN21_PG_CONFIG))
231 REG_UPDATE(DOMAIN21_PG_CONFIG, DOMAIN21_POWER_FORCEON, force_on);
232
233 if (org_ip_request_cntl == 0)
234 REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 0);
235
236 }
237
dcn20_dccg_init(struct dce_hwseq * hws)238 void dcn20_dccg_init(struct dce_hwseq *hws)
239 {
240 /*
241 * set MICROSECOND_TIME_BASE_DIV
242 * 100Mhz refclk -> 0x120264
243 * 27Mhz refclk -> 0x12021b
244 * 48Mhz refclk -> 0x120230
245 *
246 */
247 REG_WRITE(MICROSECOND_TIME_BASE_DIV, 0x120264);
248
249 /*
250 * set MILLISECOND_TIME_BASE_DIV
251 * 100Mhz refclk -> 0x1186a0
252 * 27Mhz refclk -> 0x106978
253 * 48Mhz refclk -> 0x10bb80
254 *
255 */
256 REG_WRITE(MILLISECOND_TIME_BASE_DIV, 0x1186a0);
257
258 /* This value is dependent on the hardware pipeline delay so set once per SOC */
259 REG_WRITE(DISPCLK_FREQ_CHANGE_CNTL, 0xe01003c);
260 }
261
dcn20_disable_vga(struct dce_hwseq * hws)262 void dcn20_disable_vga(
263 struct dce_hwseq *hws)
264 {
265 REG_WRITE(D1VGA_CONTROL, 0);
266 REG_WRITE(D2VGA_CONTROL, 0);
267 REG_WRITE(D3VGA_CONTROL, 0);
268 REG_WRITE(D4VGA_CONTROL, 0);
269 REG_WRITE(D5VGA_CONTROL, 0);
270 REG_WRITE(D6VGA_CONTROL, 0);
271 }
272
dcn20_program_triple_buffer(const struct dc * dc,struct pipe_ctx * pipe_ctx,bool enable_triple_buffer)273 void dcn20_program_triple_buffer(
274 const struct dc *dc,
275 struct pipe_ctx *pipe_ctx,
276 bool enable_triple_buffer)
277 {
278 if (pipe_ctx->plane_res.hubp && pipe_ctx->plane_res.hubp->funcs) {
279 pipe_ctx->plane_res.hubp->funcs->hubp_enable_tripleBuffer(
280 pipe_ctx->plane_res.hubp,
281 enable_triple_buffer);
282 }
283 }
284
285 /* Blank pixel data during initialization */
dcn20_init_blank(struct dc * dc,struct timing_generator * tg)286 void dcn20_init_blank(
287 struct dc *dc,
288 struct timing_generator *tg)
289 {
290 struct dce_hwseq *hws = dc->hwseq;
291 enum dc_color_space color_space;
292 struct tg_color black_color = {0};
293 struct output_pixel_processor *opp = NULL;
294 struct output_pixel_processor *bottom_opp = NULL;
295 uint32_t num_opps, opp_id_src0, opp_id_src1;
296 uint32_t otg_active_width, otg_active_height;
297
298 /* program opp dpg blank color */
299 color_space = COLOR_SPACE_SRGB;
300 color_space_to_black_color(dc, color_space, &black_color);
301
302 /* get the OTG active size */
303 tg->funcs->get_otg_active_size(tg,
304 &otg_active_width,
305 &otg_active_height);
306
307 /* get the OPTC source */
308 tg->funcs->get_optc_source(tg, &num_opps, &opp_id_src0, &opp_id_src1);
309
310 if (opp_id_src0 >= dc->res_pool->res_cap->num_opp) {
311 ASSERT(false);
312 return;
313 }
314 opp = dc->res_pool->opps[opp_id_src0];
315
316 /* don't override the blank pattern if already enabled with the correct one. */
317 if (opp->funcs->dpg_is_blanked && opp->funcs->dpg_is_blanked(opp))
318 return;
319
320 if (num_opps == 2) {
321 otg_active_width = otg_active_width / 2;
322
323 if (opp_id_src1 >= dc->res_pool->res_cap->num_opp) {
324 ASSERT(false);
325 return;
326 }
327 bottom_opp = dc->res_pool->opps[opp_id_src1];
328 }
329
330 opp->funcs->opp_set_disp_pattern_generator(
331 opp,
332 CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR,
333 CONTROLLER_DP_COLOR_SPACE_UDEFINED,
334 COLOR_DEPTH_UNDEFINED,
335 &black_color,
336 otg_active_width,
337 otg_active_height,
338 0);
339
340 if (num_opps == 2) {
341 bottom_opp->funcs->opp_set_disp_pattern_generator(
342 bottom_opp,
343 CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR,
344 CONTROLLER_DP_COLOR_SPACE_UDEFINED,
345 COLOR_DEPTH_UNDEFINED,
346 &black_color,
347 otg_active_width,
348 otg_active_height,
349 0);
350 }
351
352 hws->funcs.wait_for_blank_complete(opp);
353 }
354
dcn20_dsc_pg_control(struct dce_hwseq * hws,unsigned int dsc_inst,bool power_on)355 void dcn20_dsc_pg_control(
356 struct dce_hwseq *hws,
357 unsigned int dsc_inst,
358 bool power_on)
359 {
360 uint32_t power_gate = power_on ? 0 : 1;
361 uint32_t pwr_status = power_on ? 0 : 2;
362 uint32_t org_ip_request_cntl = 0;
363
364 if (hws->ctx->dc->debug.disable_dsc_power_gate)
365 return;
366
367 if (REG(DOMAIN16_PG_CONFIG) == 0)
368 return;
369
370 REG_GET(DC_IP_REQUEST_CNTL, IP_REQUEST_EN, &org_ip_request_cntl);
371 if (org_ip_request_cntl == 0)
372 REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 1);
373
374 switch (dsc_inst) {
375 case 0: /* DSC0 */
376 REG_UPDATE(DOMAIN16_PG_CONFIG,
377 DOMAIN16_POWER_GATE, power_gate);
378
379 REG_WAIT(DOMAIN16_PG_STATUS,
380 DOMAIN16_PGFSM_PWR_STATUS, pwr_status,
381 1, 1000);
382 break;
383 case 1: /* DSC1 */
384 REG_UPDATE(DOMAIN17_PG_CONFIG,
385 DOMAIN17_POWER_GATE, power_gate);
386
387 REG_WAIT(DOMAIN17_PG_STATUS,
388 DOMAIN17_PGFSM_PWR_STATUS, pwr_status,
389 1, 1000);
390 break;
391 case 2: /* DSC2 */
392 REG_UPDATE(DOMAIN18_PG_CONFIG,
393 DOMAIN18_POWER_GATE, power_gate);
394
395 REG_WAIT(DOMAIN18_PG_STATUS,
396 DOMAIN18_PGFSM_PWR_STATUS, pwr_status,
397 1, 1000);
398 break;
399 case 3: /* DSC3 */
400 REG_UPDATE(DOMAIN19_PG_CONFIG,
401 DOMAIN19_POWER_GATE, power_gate);
402
403 REG_WAIT(DOMAIN19_PG_STATUS,
404 DOMAIN19_PGFSM_PWR_STATUS, pwr_status,
405 1, 1000);
406 break;
407 case 4: /* DSC4 */
408 REG_UPDATE(DOMAIN20_PG_CONFIG,
409 DOMAIN20_POWER_GATE, power_gate);
410
411 REG_WAIT(DOMAIN20_PG_STATUS,
412 DOMAIN20_PGFSM_PWR_STATUS, pwr_status,
413 1, 1000);
414 break;
415 case 5: /* DSC5 */
416 REG_UPDATE(DOMAIN21_PG_CONFIG,
417 DOMAIN21_POWER_GATE, power_gate);
418
419 REG_WAIT(DOMAIN21_PG_STATUS,
420 DOMAIN21_PGFSM_PWR_STATUS, pwr_status,
421 1, 1000);
422 break;
423 default:
424 BREAK_TO_DEBUGGER();
425 break;
426 }
427
428 if (org_ip_request_cntl == 0)
429 REG_SET(DC_IP_REQUEST_CNTL, 0, IP_REQUEST_EN, 0);
430 }
431
dcn20_dpp_pg_control(struct dce_hwseq * hws,unsigned int dpp_inst,bool power_on)432 void dcn20_dpp_pg_control(
433 struct dce_hwseq *hws,
434 unsigned int dpp_inst,
435 bool power_on)
436 {
437 uint32_t power_gate = power_on ? 0 : 1;
438 uint32_t pwr_status = power_on ? 0 : 2;
439
440 if (hws->ctx->dc->debug.disable_dpp_power_gate)
441 return;
442 if (REG(DOMAIN1_PG_CONFIG) == 0)
443 return;
444
445 switch (dpp_inst) {
446 case 0: /* DPP0 */
447 REG_UPDATE(DOMAIN1_PG_CONFIG,
448 DOMAIN1_POWER_GATE, power_gate);
449
450 REG_WAIT(DOMAIN1_PG_STATUS,
451 DOMAIN1_PGFSM_PWR_STATUS, pwr_status,
452 1, 1000);
453 break;
454 case 1: /* DPP1 */
455 REG_UPDATE(DOMAIN3_PG_CONFIG,
456 DOMAIN3_POWER_GATE, power_gate);
457
458 REG_WAIT(DOMAIN3_PG_STATUS,
459 DOMAIN3_PGFSM_PWR_STATUS, pwr_status,
460 1, 1000);
461 break;
462 case 2: /* DPP2 */
463 REG_UPDATE(DOMAIN5_PG_CONFIG,
464 DOMAIN5_POWER_GATE, power_gate);
465
466 REG_WAIT(DOMAIN5_PG_STATUS,
467 DOMAIN5_PGFSM_PWR_STATUS, pwr_status,
468 1, 1000);
469 break;
470 case 3: /* DPP3 */
471 REG_UPDATE(DOMAIN7_PG_CONFIG,
472 DOMAIN7_POWER_GATE, power_gate);
473
474 REG_WAIT(DOMAIN7_PG_STATUS,
475 DOMAIN7_PGFSM_PWR_STATUS, pwr_status,
476 1, 1000);
477 break;
478 case 4: /* DPP4 */
479 REG_UPDATE(DOMAIN9_PG_CONFIG,
480 DOMAIN9_POWER_GATE, power_gate);
481
482 REG_WAIT(DOMAIN9_PG_STATUS,
483 DOMAIN9_PGFSM_PWR_STATUS, pwr_status,
484 1, 1000);
485 break;
486 case 5: /* DPP5 */
487 /*
488 * Do not power gate DPP5, should be left at HW default, power on permanently.
489 * PG on Pipe5 is De-featured, attempting to put it to PG state may result in hard
490 * reset.
491 * REG_UPDATE(DOMAIN11_PG_CONFIG,
492 * DOMAIN11_POWER_GATE, power_gate);
493 *
494 * REG_WAIT(DOMAIN11_PG_STATUS,
495 * DOMAIN11_PGFSM_PWR_STATUS, pwr_status,
496 * 1, 1000);
497 */
498 break;
499 default:
500 BREAK_TO_DEBUGGER();
501 break;
502 }
503 }
504
505
dcn20_hubp_pg_control(struct dce_hwseq * hws,unsigned int hubp_inst,bool power_on)506 void dcn20_hubp_pg_control(
507 struct dce_hwseq *hws,
508 unsigned int hubp_inst,
509 bool power_on)
510 {
511 uint32_t power_gate = power_on ? 0 : 1;
512 uint32_t pwr_status = power_on ? 0 : 2;
513
514 if (hws->ctx->dc->debug.disable_hubp_power_gate)
515 return;
516 if (REG(DOMAIN0_PG_CONFIG) == 0)
517 return;
518
519 switch (hubp_inst) {
520 case 0: /* DCHUBP0 */
521 REG_UPDATE(DOMAIN0_PG_CONFIG,
522 DOMAIN0_POWER_GATE, power_gate);
523
524 REG_WAIT(DOMAIN0_PG_STATUS,
525 DOMAIN0_PGFSM_PWR_STATUS, pwr_status,
526 1, 1000);
527 break;
528 case 1: /* DCHUBP1 */
529 REG_UPDATE(DOMAIN2_PG_CONFIG,
530 DOMAIN2_POWER_GATE, power_gate);
531
532 REG_WAIT(DOMAIN2_PG_STATUS,
533 DOMAIN2_PGFSM_PWR_STATUS, pwr_status,
534 1, 1000);
535 break;
536 case 2: /* DCHUBP2 */
537 REG_UPDATE(DOMAIN4_PG_CONFIG,
538 DOMAIN4_POWER_GATE, power_gate);
539
540 REG_WAIT(DOMAIN4_PG_STATUS,
541 DOMAIN4_PGFSM_PWR_STATUS, pwr_status,
542 1, 1000);
543 break;
544 case 3: /* DCHUBP3 */
545 REG_UPDATE(DOMAIN6_PG_CONFIG,
546 DOMAIN6_POWER_GATE, power_gate);
547
548 REG_WAIT(DOMAIN6_PG_STATUS,
549 DOMAIN6_PGFSM_PWR_STATUS, pwr_status,
550 1, 1000);
551 break;
552 case 4: /* DCHUBP4 */
553 REG_UPDATE(DOMAIN8_PG_CONFIG,
554 DOMAIN8_POWER_GATE, power_gate);
555
556 REG_WAIT(DOMAIN8_PG_STATUS,
557 DOMAIN8_PGFSM_PWR_STATUS, pwr_status,
558 1, 1000);
559 break;
560 case 5: /* DCHUBP5 */
561 /*
562 * Do not power gate DCHUB5, should be left at HW default, power on permanently.
563 * PG on Pipe5 is De-featured, attempting to put it to PG state may result in hard
564 * reset.
565 * REG_UPDATE(DOMAIN10_PG_CONFIG,
566 * DOMAIN10_POWER_GATE, power_gate);
567 *
568 * REG_WAIT(DOMAIN10_PG_STATUS,
569 * DOMAIN10_PGFSM_PWR_STATUS, pwr_status,
570 * 1, 1000);
571 */
572 break;
573 default:
574 BREAK_TO_DEBUGGER();
575 break;
576 }
577 }
578
579
580 /* disable HW used by plane.
581 * note: cannot disable until disconnect is complete
582 */
dcn20_plane_atomic_disable(struct dc * dc,struct pipe_ctx * pipe_ctx)583 void dcn20_plane_atomic_disable(struct dc *dc, struct pipe_ctx *pipe_ctx)
584 {
585 struct dce_hwseq *hws = dc->hwseq;
586 struct hubp *hubp = pipe_ctx->plane_res.hubp;
587 struct dpp *dpp = pipe_ctx->plane_res.dpp;
588
589 dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe_ctx);
590
591 /* In flip immediate with pipe splitting case GSL is used for
592 * synchronization so we must disable it when the plane is disabled.
593 */
594 if (pipe_ctx->stream_res.gsl_group != 0)
595 dcn20_setup_gsl_group_as_lock(dc, pipe_ctx, false);
596
597 if (hubp->funcs->hubp_update_mall_sel)
598 hubp->funcs->hubp_update_mall_sel(hubp, 0, false);
599
600 dc->hwss.set_flip_control_gsl(pipe_ctx, false);
601
602 hubp->funcs->hubp_clk_cntl(hubp, false);
603
604 dpp->funcs->dpp_dppclk_control(dpp, false, false);
605
606 hubp->power_gated = true;
607
608 hws->funcs.plane_atomic_power_down(dc,
609 pipe_ctx->plane_res.dpp,
610 pipe_ctx->plane_res.hubp);
611
612 pipe_ctx->stream = NULL;
613 memset(&pipe_ctx->stream_res, 0, sizeof(pipe_ctx->stream_res));
614 memset(&pipe_ctx->plane_res, 0, sizeof(pipe_ctx->plane_res));
615 pipe_ctx->top_pipe = NULL;
616 pipe_ctx->bottom_pipe = NULL;
617 pipe_ctx->plane_state = NULL;
618 }
619
620
dcn20_disable_plane(struct dc * dc,struct pipe_ctx * pipe_ctx)621 void dcn20_disable_plane(struct dc *dc, struct pipe_ctx *pipe_ctx)
622 {
623 bool is_phantom = pipe_ctx->plane_state && pipe_ctx->plane_state->is_phantom;
624 struct timing_generator *tg = is_phantom ? pipe_ctx->stream_res.tg : NULL;
625
626 DC_LOGGER_INIT(dc->ctx->logger);
627
628 if (!pipe_ctx->plane_res.hubp || pipe_ctx->plane_res.hubp->power_gated)
629 return;
630
631 dcn20_plane_atomic_disable(dc, pipe_ctx);
632
633 /* Turn back off the phantom OTG after the phantom plane is fully disabled
634 */
635 if (is_phantom)
636 if (tg && tg->funcs->disable_phantom_crtc)
637 tg->funcs->disable_phantom_crtc(tg);
638
639 DC_LOG_DC("Power down front end %d\n",
640 pipe_ctx->pipe_idx);
641 }
642
dcn20_disable_pixel_data(struct dc * dc,struct pipe_ctx * pipe_ctx,bool blank)643 void dcn20_disable_pixel_data(struct dc *dc, struct pipe_ctx *pipe_ctx, bool blank)
644 {
645 dcn20_blank_pixel_data(dc, pipe_ctx, blank);
646 }
647
calc_mpc_flow_ctrl_cnt(const struct dc_stream_state * stream,int opp_cnt)648 static int calc_mpc_flow_ctrl_cnt(const struct dc_stream_state *stream,
649 int opp_cnt)
650 {
651 bool hblank_halved = optc2_is_two_pixels_per_containter(&stream->timing);
652 int flow_ctrl_cnt;
653
654 if (opp_cnt >= 2)
655 hblank_halved = true;
656
657 flow_ctrl_cnt = stream->timing.h_total - stream->timing.h_addressable -
658 stream->timing.h_border_left -
659 stream->timing.h_border_right;
660
661 if (hblank_halved)
662 flow_ctrl_cnt /= 2;
663
664 /* ODM combine 4:1 case */
665 if (opp_cnt == 4)
666 flow_ctrl_cnt /= 2;
667
668 return flow_ctrl_cnt;
669 }
670
dcn20_enable_stream_timing(struct pipe_ctx * pipe_ctx,struct dc_state * context,struct dc * dc)671 enum dc_status dcn20_enable_stream_timing(
672 struct pipe_ctx *pipe_ctx,
673 struct dc_state *context,
674 struct dc *dc)
675 {
676 struct dce_hwseq *hws = dc->hwseq;
677 struct dc_stream_state *stream = pipe_ctx->stream;
678 struct drr_params params = {0};
679 unsigned int event_triggers = 0;
680 struct pipe_ctx *odm_pipe;
681 int opp_cnt = 1;
682 int opp_inst[MAX_PIPES] = { pipe_ctx->stream_res.opp->inst };
683 bool interlace = stream->timing.flags.INTERLACE;
684 int i;
685 struct mpc_dwb_flow_control flow_control;
686 struct mpc *mpc = dc->res_pool->mpc;
687 bool rate_control_2x_pclk = (interlace || optc2_is_two_pixels_per_containter(&stream->timing));
688 unsigned int k1_div = PIXEL_RATE_DIV_NA;
689 unsigned int k2_div = PIXEL_RATE_DIV_NA;
690
691 if (hws->funcs.calculate_dccg_k1_k2_values && dc->res_pool->dccg->funcs->set_pixel_rate_div) {
692 hws->funcs.calculate_dccg_k1_k2_values(pipe_ctx, &k1_div, &k2_div);
693
694 dc->res_pool->dccg->funcs->set_pixel_rate_div(
695 dc->res_pool->dccg,
696 pipe_ctx->stream_res.tg->inst,
697 k1_div, k2_div);
698 }
699 /* by upper caller loop, pipe0 is parent pipe and be called first.
700 * back end is set up by for pipe0. Other children pipe share back end
701 * with pipe 0. No program is needed.
702 */
703 if (pipe_ctx->top_pipe != NULL)
704 return DC_OK;
705
706 /* TODO check if timing_changed, disable stream if timing changed */
707
708 for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) {
709 opp_inst[opp_cnt] = odm_pipe->stream_res.opp->inst;
710 opp_cnt++;
711 }
712
713 if (opp_cnt > 1)
714 pipe_ctx->stream_res.tg->funcs->set_odm_combine(
715 pipe_ctx->stream_res.tg,
716 opp_inst, opp_cnt,
717 &pipe_ctx->stream->timing);
718
719 /* HW program guide assume display already disable
720 * by unplug sequence. OTG assume stop.
721 */
722 pipe_ctx->stream_res.tg->funcs->enable_optc_clock(pipe_ctx->stream_res.tg, true);
723
724 if (false == pipe_ctx->clock_source->funcs->program_pix_clk(
725 pipe_ctx->clock_source,
726 &pipe_ctx->stream_res.pix_clk_params,
727 dc->link_srv->dp_get_encoding_format(&pipe_ctx->link_config.dp_link_settings),
728 &pipe_ctx->pll_settings)) {
729 BREAK_TO_DEBUGGER();
730 return DC_ERROR_UNEXPECTED;
731 }
732
733 if (dc_is_hdmi_tmds_signal(stream->signal)) {
734 stream->link->phy_state.symclk_ref_cnts.otg = 1;
735 if (stream->link->phy_state.symclk_state == SYMCLK_OFF_TX_OFF)
736 stream->link->phy_state.symclk_state = SYMCLK_ON_TX_OFF;
737 else
738 stream->link->phy_state.symclk_state = SYMCLK_ON_TX_ON;
739 }
740
741 if (dc->hwseq->funcs.PLAT_58856_wa && (!dc_is_dp_signal(stream->signal)))
742 dc->hwseq->funcs.PLAT_58856_wa(context, pipe_ctx);
743
744 pipe_ctx->stream_res.tg->funcs->program_timing(
745 pipe_ctx->stream_res.tg,
746 &stream->timing,
747 pipe_ctx->pipe_dlg_param.vready_offset,
748 pipe_ctx->pipe_dlg_param.vstartup_start,
749 pipe_ctx->pipe_dlg_param.vupdate_offset,
750 pipe_ctx->pipe_dlg_param.vupdate_width,
751 pipe_ctx->stream->signal,
752 true);
753
754 rate_control_2x_pclk = rate_control_2x_pclk || opp_cnt > 1;
755 flow_control.flow_ctrl_mode = 0;
756 flow_control.flow_ctrl_cnt0 = 0x80;
757 flow_control.flow_ctrl_cnt1 = calc_mpc_flow_ctrl_cnt(stream, opp_cnt);
758 if (mpc->funcs->set_out_rate_control) {
759 for (i = 0; i < opp_cnt; ++i) {
760 mpc->funcs->set_out_rate_control(
761 mpc, opp_inst[i],
762 true,
763 rate_control_2x_pclk,
764 &flow_control);
765 }
766 }
767
768 for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe)
769 odm_pipe->stream_res.opp->funcs->opp_pipe_clock_control(
770 odm_pipe->stream_res.opp,
771 true);
772
773 pipe_ctx->stream_res.opp->funcs->opp_pipe_clock_control(
774 pipe_ctx->stream_res.opp,
775 true);
776
777 hws->funcs.blank_pixel_data(dc, pipe_ctx, true);
778
779 /* VTG is within DCHUB command block. DCFCLK is always on */
780 if (false == pipe_ctx->stream_res.tg->funcs->enable_crtc(pipe_ctx->stream_res.tg)) {
781 BREAK_TO_DEBUGGER();
782 return DC_ERROR_UNEXPECTED;
783 }
784
785 hws->funcs.wait_for_blank_complete(pipe_ctx->stream_res.opp);
786
787 params.vertical_total_min = stream->adjust.v_total_min;
788 params.vertical_total_max = stream->adjust.v_total_max;
789 params.vertical_total_mid = stream->adjust.v_total_mid;
790 params.vertical_total_mid_frame_num = stream->adjust.v_total_mid_frame_num;
791 if (pipe_ctx->stream_res.tg->funcs->set_drr)
792 pipe_ctx->stream_res.tg->funcs->set_drr(
793 pipe_ctx->stream_res.tg, ¶ms);
794
795 // DRR should set trigger event to monitor surface update event
796 if (stream->adjust.v_total_min != 0 && stream->adjust.v_total_max != 0)
797 event_triggers = 0x80;
798 /* Event triggers and num frames initialized for DRR, but can be
799 * later updated for PSR use. Note DRR trigger events are generated
800 * regardless of whether num frames met.
801 */
802 if (pipe_ctx->stream_res.tg->funcs->set_static_screen_control)
803 pipe_ctx->stream_res.tg->funcs->set_static_screen_control(
804 pipe_ctx->stream_res.tg, event_triggers, 2);
805
806 /* TODO program crtc source select for non-virtual signal*/
807 /* TODO program FMT */
808 /* TODO setup link_enc */
809 /* TODO set stream attributes */
810 /* TODO program audio */
811 /* TODO enable stream if timing changed */
812 /* TODO unblank stream if DP */
813
814 if (pipe_ctx->stream && pipe_ctx->stream->mall_stream_config.type == SUBVP_PHANTOM) {
815 if (pipe_ctx->stream_res.tg && pipe_ctx->stream_res.tg->funcs->phantom_crtc_post_enable)
816 pipe_ctx->stream_res.tg->funcs->phantom_crtc_post_enable(pipe_ctx->stream_res.tg);
817 }
818 return DC_OK;
819 }
820
dcn20_program_output_csc(struct dc * dc,struct pipe_ctx * pipe_ctx,enum dc_color_space colorspace,uint16_t * matrix,int opp_id)821 void dcn20_program_output_csc(struct dc *dc,
822 struct pipe_ctx *pipe_ctx,
823 enum dc_color_space colorspace,
824 uint16_t *matrix,
825 int opp_id)
826 {
827 struct mpc *mpc = dc->res_pool->mpc;
828 enum mpc_output_csc_mode ocsc_mode = MPC_OUTPUT_CSC_COEF_A;
829 int mpcc_id = pipe_ctx->plane_res.hubp->inst;
830
831 if (mpc->funcs->power_on_mpc_mem_pwr)
832 mpc->funcs->power_on_mpc_mem_pwr(mpc, mpcc_id, true);
833
834 if (pipe_ctx->stream->csc_color_matrix.enable_adjustment == true) {
835 if (mpc->funcs->set_output_csc != NULL)
836 mpc->funcs->set_output_csc(mpc,
837 opp_id,
838 matrix,
839 ocsc_mode);
840 } else {
841 if (mpc->funcs->set_ocsc_default != NULL)
842 mpc->funcs->set_ocsc_default(mpc,
843 opp_id,
844 colorspace,
845 ocsc_mode);
846 }
847 }
848
dcn20_set_output_transfer_func(struct dc * dc,struct pipe_ctx * pipe_ctx,const struct dc_stream_state * stream)849 bool dcn20_set_output_transfer_func(struct dc *dc, struct pipe_ctx *pipe_ctx,
850 const struct dc_stream_state *stream)
851 {
852 int mpcc_id = pipe_ctx->plane_res.hubp->inst;
853 struct mpc *mpc = pipe_ctx->stream_res.opp->ctx->dc->res_pool->mpc;
854 struct pwl_params *params = NULL;
855 /*
856 * program OGAM only for the top pipe
857 * if there is a pipe split then fix diagnostic is required:
858 * how to pass OGAM parameter for stream.
859 * if programming for all pipes is required then remove condition
860 * pipe_ctx->top_pipe == NULL ,but then fix the diagnostic.
861 */
862 if (mpc->funcs->power_on_mpc_mem_pwr)
863 mpc->funcs->power_on_mpc_mem_pwr(mpc, mpcc_id, true);
864 if (pipe_ctx->top_pipe == NULL
865 && mpc->funcs->set_output_gamma && stream->out_transfer_func) {
866 if (stream->out_transfer_func->type == TF_TYPE_HWPWL)
867 params = &stream->out_transfer_func->pwl;
868 else if (pipe_ctx->stream->out_transfer_func->type ==
869 TF_TYPE_DISTRIBUTED_POINTS &&
870 cm_helper_translate_curve_to_hw_format(dc->ctx,
871 stream->out_transfer_func,
872 &mpc->blender_params, false))
873 params = &mpc->blender_params;
874 /*
875 * there is no ROM
876 */
877 if (stream->out_transfer_func->type == TF_TYPE_PREDEFINED)
878 BREAK_TO_DEBUGGER();
879 }
880 /*
881 * if above if is not executed then 'params' equal to 0 and set in bypass
882 */
883 if (mpc->funcs->set_output_gamma)
884 mpc->funcs->set_output_gamma(mpc, mpcc_id, params);
885
886 return true;
887 }
888
dcn20_set_blend_lut(struct pipe_ctx * pipe_ctx,const struct dc_plane_state * plane_state)889 bool dcn20_set_blend_lut(
890 struct pipe_ctx *pipe_ctx, const struct dc_plane_state *plane_state)
891 {
892 struct dpp *dpp_base = pipe_ctx->plane_res.dpp;
893 bool result = true;
894 struct pwl_params *blend_lut = NULL;
895
896 if (plane_state->blend_tf) {
897 if (plane_state->blend_tf->type == TF_TYPE_HWPWL)
898 blend_lut = &plane_state->blend_tf->pwl;
899 else if (plane_state->blend_tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
900 cm_helper_translate_curve_to_hw_format(plane_state->ctx,
901 plane_state->blend_tf,
902 &dpp_base->regamma_params, false);
903 blend_lut = &dpp_base->regamma_params;
904 }
905 }
906 result = dpp_base->funcs->dpp_program_blnd_lut(dpp_base, blend_lut);
907
908 return result;
909 }
910
dcn20_set_shaper_3dlut(struct pipe_ctx * pipe_ctx,const struct dc_plane_state * plane_state)911 bool dcn20_set_shaper_3dlut(
912 struct pipe_ctx *pipe_ctx, const struct dc_plane_state *plane_state)
913 {
914 struct dpp *dpp_base = pipe_ctx->plane_res.dpp;
915 bool result = true;
916 struct pwl_params *shaper_lut = NULL;
917
918 if (plane_state->in_shaper_func) {
919 if (plane_state->in_shaper_func->type == TF_TYPE_HWPWL)
920 shaper_lut = &plane_state->in_shaper_func->pwl;
921 else if (plane_state->in_shaper_func->type == TF_TYPE_DISTRIBUTED_POINTS) {
922 cm_helper_translate_curve_to_hw_format(plane_state->ctx,
923 plane_state->in_shaper_func,
924 &dpp_base->shaper_params, true);
925 shaper_lut = &dpp_base->shaper_params;
926 }
927 }
928
929 result = dpp_base->funcs->dpp_program_shaper_lut(dpp_base, shaper_lut);
930 if (plane_state->lut3d_func &&
931 plane_state->lut3d_func->state.bits.initialized == 1)
932 result = dpp_base->funcs->dpp_program_3dlut(dpp_base,
933 &plane_state->lut3d_func->lut_3d);
934 else
935 result = dpp_base->funcs->dpp_program_3dlut(dpp_base, NULL);
936
937 return result;
938 }
939
dcn20_set_input_transfer_func(struct dc * dc,struct pipe_ctx * pipe_ctx,const struct dc_plane_state * plane_state)940 bool dcn20_set_input_transfer_func(struct dc *dc,
941 struct pipe_ctx *pipe_ctx,
942 const struct dc_plane_state *plane_state)
943 {
944 struct dce_hwseq *hws = dc->hwseq;
945 struct dpp *dpp_base = pipe_ctx->plane_res.dpp;
946 const struct dc_transfer_func *tf = NULL;
947 bool result = true;
948 bool use_degamma_ram = false;
949
950 if (dpp_base == NULL || plane_state == NULL)
951 return false;
952
953 hws->funcs.set_shaper_3dlut(pipe_ctx, plane_state);
954 hws->funcs.set_blend_lut(pipe_ctx, plane_state);
955
956 if (plane_state->in_transfer_func)
957 tf = plane_state->in_transfer_func;
958
959
960 if (tf == NULL) {
961 dpp_base->funcs->dpp_set_degamma(dpp_base,
962 IPP_DEGAMMA_MODE_BYPASS);
963 return true;
964 }
965
966 if (tf->type == TF_TYPE_HWPWL || tf->type == TF_TYPE_DISTRIBUTED_POINTS)
967 use_degamma_ram = true;
968
969 if (use_degamma_ram == true) {
970 if (tf->type == TF_TYPE_HWPWL)
971 dpp_base->funcs->dpp_program_degamma_pwl(dpp_base,
972 &tf->pwl);
973 else if (tf->type == TF_TYPE_DISTRIBUTED_POINTS) {
974 cm_helper_translate_curve_to_degamma_hw_format(tf,
975 &dpp_base->degamma_params);
976 dpp_base->funcs->dpp_program_degamma_pwl(dpp_base,
977 &dpp_base->degamma_params);
978 }
979 return true;
980 }
981 /* handle here the optimized cases when de-gamma ROM could be used.
982 *
983 */
984 if (tf->type == TF_TYPE_PREDEFINED) {
985 switch (tf->tf) {
986 case TRANSFER_FUNCTION_SRGB:
987 dpp_base->funcs->dpp_set_degamma(dpp_base,
988 IPP_DEGAMMA_MODE_HW_sRGB);
989 break;
990 case TRANSFER_FUNCTION_BT709:
991 dpp_base->funcs->dpp_set_degamma(dpp_base,
992 IPP_DEGAMMA_MODE_HW_xvYCC);
993 break;
994 case TRANSFER_FUNCTION_LINEAR:
995 dpp_base->funcs->dpp_set_degamma(dpp_base,
996 IPP_DEGAMMA_MODE_BYPASS);
997 break;
998 case TRANSFER_FUNCTION_PQ:
999 dpp_base->funcs->dpp_set_degamma(dpp_base, IPP_DEGAMMA_MODE_USER_PWL);
1000 cm_helper_translate_curve_to_degamma_hw_format(tf, &dpp_base->degamma_params);
1001 dpp_base->funcs->dpp_program_degamma_pwl(dpp_base, &dpp_base->degamma_params);
1002 result = true;
1003 break;
1004 default:
1005 result = false;
1006 break;
1007 }
1008 } else if (tf->type == TF_TYPE_BYPASS)
1009 dpp_base->funcs->dpp_set_degamma(dpp_base,
1010 IPP_DEGAMMA_MODE_BYPASS);
1011 else {
1012 /*
1013 * if we are here, we did not handle correctly.
1014 * fix is required for this use case
1015 */
1016 BREAK_TO_DEBUGGER();
1017 dpp_base->funcs->dpp_set_degamma(dpp_base,
1018 IPP_DEGAMMA_MODE_BYPASS);
1019 }
1020
1021 return result;
1022 }
1023
dcn20_update_odm(struct dc * dc,struct dc_state * context,struct pipe_ctx * pipe_ctx)1024 void dcn20_update_odm(struct dc *dc, struct dc_state *context, struct pipe_ctx *pipe_ctx)
1025 {
1026 struct pipe_ctx *odm_pipe;
1027 int opp_cnt = 1;
1028 int opp_inst[MAX_PIPES] = { pipe_ctx->stream_res.opp->inst };
1029
1030 for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) {
1031 opp_inst[opp_cnt] = odm_pipe->stream_res.opp->inst;
1032 opp_cnt++;
1033 }
1034
1035 if (opp_cnt > 1)
1036 pipe_ctx->stream_res.tg->funcs->set_odm_combine(
1037 pipe_ctx->stream_res.tg,
1038 opp_inst, opp_cnt,
1039 &pipe_ctx->stream->timing);
1040 else
1041 pipe_ctx->stream_res.tg->funcs->set_odm_bypass(
1042 pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing);
1043 }
1044
dcn20_blank_pixel_data(struct dc * dc,struct pipe_ctx * pipe_ctx,bool blank)1045 void dcn20_blank_pixel_data(
1046 struct dc *dc,
1047 struct pipe_ctx *pipe_ctx,
1048 bool blank)
1049 {
1050 struct tg_color black_color = {0};
1051 struct stream_resource *stream_res = &pipe_ctx->stream_res;
1052 struct dc_stream_state *stream = pipe_ctx->stream;
1053 enum dc_color_space color_space = stream->output_color_space;
1054 enum controller_dp_test_pattern test_pattern = CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR;
1055 enum controller_dp_color_space test_pattern_color_space = CONTROLLER_DP_COLOR_SPACE_UDEFINED;
1056 struct pipe_ctx *odm_pipe;
1057 int odm_cnt = 1;
1058 int h_active = stream->timing.h_addressable + stream->timing.h_border_left + stream->timing.h_border_right;
1059 int v_active = stream->timing.v_addressable + stream->timing.v_border_bottom + stream->timing.v_border_top;
1060 int odm_slice_width, last_odm_slice_width, offset = 0;
1061
1062 if (stream->link->test_pattern_enabled)
1063 return;
1064
1065 /* get opp dpg blank color */
1066 color_space_to_black_color(dc, color_space, &black_color);
1067
1068 for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe)
1069 odm_cnt++;
1070 odm_slice_width = h_active / odm_cnt;
1071 last_odm_slice_width = h_active - odm_slice_width * (odm_cnt - 1);
1072
1073 if (blank) {
1074 dc->hwss.set_abm_immediate_disable(pipe_ctx);
1075
1076 if (dc->debug.visual_confirm != VISUAL_CONFIRM_DISABLE) {
1077 test_pattern = CONTROLLER_DP_TEST_PATTERN_COLORSQUARES;
1078 test_pattern_color_space = CONTROLLER_DP_COLOR_SPACE_RGB;
1079 }
1080 } else {
1081 test_pattern = CONTROLLER_DP_TEST_PATTERN_VIDEOMODE;
1082 }
1083
1084 odm_pipe = pipe_ctx;
1085
1086 while (odm_pipe->next_odm_pipe) {
1087 dc->hwss.set_disp_pattern_generator(dc,
1088 odm_pipe,
1089 test_pattern,
1090 test_pattern_color_space,
1091 stream->timing.display_color_depth,
1092 &black_color,
1093 odm_slice_width,
1094 v_active,
1095 offset);
1096 offset += odm_slice_width;
1097 odm_pipe = odm_pipe->next_odm_pipe;
1098 }
1099
1100 dc->hwss.set_disp_pattern_generator(dc,
1101 odm_pipe,
1102 test_pattern,
1103 test_pattern_color_space,
1104 stream->timing.display_color_depth,
1105 &black_color,
1106 last_odm_slice_width,
1107 v_active,
1108 offset);
1109
1110 if (!blank)
1111 if (stream_res->abm) {
1112 dc->hwss.set_pipe(pipe_ctx);
1113 stream_res->abm->funcs->set_abm_level(stream_res->abm, stream->abm_level);
1114 }
1115 }
1116
1117
dcn20_power_on_plane_resources(struct dce_hwseq * hws,struct pipe_ctx * pipe_ctx)1118 static void dcn20_power_on_plane_resources(
1119 struct dce_hwseq *hws,
1120 struct pipe_ctx *pipe_ctx)
1121 {
1122 DC_LOGGER_INIT(hws->ctx->logger);
1123
1124 if (hws->funcs.dpp_root_clock_control)
1125 hws->funcs.dpp_root_clock_control(hws, pipe_ctx->plane_res.dpp->inst, true);
1126
1127 if (REG(DC_IP_REQUEST_CNTL)) {
1128 REG_SET(DC_IP_REQUEST_CNTL, 0,
1129 IP_REQUEST_EN, 1);
1130
1131 if (hws->funcs.dpp_pg_control)
1132 hws->funcs.dpp_pg_control(hws, pipe_ctx->plane_res.dpp->inst, true);
1133
1134 if (hws->funcs.hubp_pg_control)
1135 hws->funcs.hubp_pg_control(hws, pipe_ctx->plane_res.hubp->inst, true);
1136
1137 REG_SET(DC_IP_REQUEST_CNTL, 0,
1138 IP_REQUEST_EN, 0);
1139 DC_LOG_DEBUG(
1140 "Un-gated front end for pipe %d\n", pipe_ctx->plane_res.hubp->inst);
1141 }
1142 }
1143
dcn20_enable_plane(struct dc * dc,struct pipe_ctx * pipe_ctx,struct dc_state * context)1144 static void dcn20_enable_plane(struct dc *dc, struct pipe_ctx *pipe_ctx,
1145 struct dc_state *context)
1146 {
1147 //if (dc->debug.sanity_checks) {
1148 // dcn10_verify_allow_pstate_change_high(dc);
1149 //}
1150 dcn20_power_on_plane_resources(dc->hwseq, pipe_ctx);
1151
1152 /* enable DCFCLK current DCHUB */
1153 pipe_ctx->plane_res.hubp->funcs->hubp_clk_cntl(pipe_ctx->plane_res.hubp, true);
1154
1155 /* initialize HUBP on power up */
1156 pipe_ctx->plane_res.hubp->funcs->hubp_init(pipe_ctx->plane_res.hubp);
1157
1158 /* make sure OPP_PIPE_CLOCK_EN = 1 */
1159 pipe_ctx->stream_res.opp->funcs->opp_pipe_clock_control(
1160 pipe_ctx->stream_res.opp,
1161 true);
1162
1163 /* TODO: enable/disable in dm as per update type.
1164 if (plane_state) {
1165 DC_LOG_DC(dc->ctx->logger,
1166 "Pipe:%d 0x%x: addr hi:0x%x, "
1167 "addr low:0x%x, "
1168 "src: %d, %d, %d,"
1169 " %d; dst: %d, %d, %d, %d;\n",
1170 pipe_ctx->pipe_idx,
1171 plane_state,
1172 plane_state->address.grph.addr.high_part,
1173 plane_state->address.grph.addr.low_part,
1174 plane_state->src_rect.x,
1175 plane_state->src_rect.y,
1176 plane_state->src_rect.width,
1177 plane_state->src_rect.height,
1178 plane_state->dst_rect.x,
1179 plane_state->dst_rect.y,
1180 plane_state->dst_rect.width,
1181 plane_state->dst_rect.height);
1182
1183 DC_LOG_DC(dc->ctx->logger,
1184 "Pipe %d: width, height, x, y format:%d\n"
1185 "viewport:%d, %d, %d, %d\n"
1186 "recout: %d, %d, %d, %d\n",
1187 pipe_ctx->pipe_idx,
1188 plane_state->format,
1189 pipe_ctx->plane_res.scl_data.viewport.width,
1190 pipe_ctx->plane_res.scl_data.viewport.height,
1191 pipe_ctx->plane_res.scl_data.viewport.x,
1192 pipe_ctx->plane_res.scl_data.viewport.y,
1193 pipe_ctx->plane_res.scl_data.recout.width,
1194 pipe_ctx->plane_res.scl_data.recout.height,
1195 pipe_ctx->plane_res.scl_data.recout.x,
1196 pipe_ctx->plane_res.scl_data.recout.y);
1197 print_rq_dlg_ttu(dc, pipe_ctx);
1198 }
1199 */
1200 if (dc->vm_pa_config.valid) {
1201 struct vm_system_aperture_param apt;
1202
1203 apt.sys_default.quad_part = 0;
1204
1205 apt.sys_low.quad_part = dc->vm_pa_config.system_aperture.start_addr;
1206 apt.sys_high.quad_part = dc->vm_pa_config.system_aperture.end_addr;
1207
1208 // Program system aperture settings
1209 pipe_ctx->plane_res.hubp->funcs->hubp_set_vm_system_aperture_settings(pipe_ctx->plane_res.hubp, &apt);
1210 }
1211
1212 if (!pipe_ctx->top_pipe
1213 && pipe_ctx->plane_state
1214 && pipe_ctx->plane_state->flip_int_enabled
1215 && pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int)
1216 pipe_ctx->plane_res.hubp->funcs->hubp_set_flip_int(pipe_ctx->plane_res.hubp);
1217
1218 // if (dc->debug.sanity_checks) {
1219 // dcn10_verify_allow_pstate_change_high(dc);
1220 // }
1221 }
1222
dcn20_pipe_control_lock(struct dc * dc,struct pipe_ctx * pipe,bool lock)1223 void dcn20_pipe_control_lock(
1224 struct dc *dc,
1225 struct pipe_ctx *pipe,
1226 bool lock)
1227 {
1228 struct pipe_ctx *temp_pipe;
1229 bool flip_immediate = false;
1230
1231 /* use TG master update lock to lock everything on the TG
1232 * therefore only top pipe need to lock
1233 */
1234 if (!pipe || pipe->top_pipe)
1235 return;
1236
1237 if (pipe->plane_state != NULL)
1238 flip_immediate = pipe->plane_state->flip_immediate;
1239
1240 if (pipe->stream_res.gsl_group > 0) {
1241 temp_pipe = pipe->bottom_pipe;
1242 while (!flip_immediate && temp_pipe) {
1243 if (temp_pipe->plane_state != NULL)
1244 flip_immediate = temp_pipe->plane_state->flip_immediate;
1245 temp_pipe = temp_pipe->bottom_pipe;
1246 }
1247 }
1248
1249 if (flip_immediate && lock) {
1250 const int TIMEOUT_FOR_FLIP_PENDING_US = 100000;
1251 unsigned int polling_interval_us = 1;
1252 int i;
1253
1254 temp_pipe = pipe;
1255 while (temp_pipe) {
1256 if (temp_pipe->plane_state && temp_pipe->plane_state->flip_immediate) {
1257 for (i = 0; i < TIMEOUT_FOR_FLIP_PENDING_US / polling_interval_us; ++i) {
1258 if (!temp_pipe->plane_res.hubp->funcs->hubp_is_flip_pending(temp_pipe->plane_res.hubp))
1259 break;
1260 udelay(polling_interval_us);
1261 }
1262
1263 /* no reason it should take this long for immediate flips */
1264 ASSERT(i != TIMEOUT_FOR_FLIP_PENDING_US);
1265 }
1266 temp_pipe = temp_pipe->bottom_pipe;
1267 }
1268 }
1269
1270 /* In flip immediate and pipe splitting case, we need to use GSL
1271 * for synchronization. Only do setup on locking and on flip type change.
1272 */
1273 if (lock && (pipe->bottom_pipe != NULL || !flip_immediate))
1274 if ((flip_immediate && pipe->stream_res.gsl_group == 0) ||
1275 (!flip_immediate && pipe->stream_res.gsl_group > 0))
1276 dcn20_setup_gsl_group_as_lock(dc, pipe, flip_immediate);
1277
1278 if (pipe->plane_state != NULL)
1279 flip_immediate = pipe->plane_state->flip_immediate;
1280
1281 temp_pipe = pipe->bottom_pipe;
1282 while (flip_immediate && temp_pipe) {
1283 if (temp_pipe->plane_state != NULL)
1284 flip_immediate = temp_pipe->plane_state->flip_immediate;
1285 temp_pipe = temp_pipe->bottom_pipe;
1286 }
1287
1288 if (!lock && pipe->stream_res.gsl_group > 0 && pipe->plane_state &&
1289 !flip_immediate)
1290 dcn20_setup_gsl_group_as_lock(dc, pipe, false);
1291
1292 if (pipe->stream && should_use_dmub_lock(pipe->stream->link)) {
1293 union dmub_hw_lock_flags hw_locks = { 0 };
1294 struct dmub_hw_lock_inst_flags inst_flags = { 0 };
1295
1296 hw_locks.bits.lock_pipe = 1;
1297 inst_flags.otg_inst = pipe->stream_res.tg->inst;
1298
1299 if (pipe->plane_state != NULL)
1300 hw_locks.bits.triple_buffer_lock = pipe->plane_state->triplebuffer_flips;
1301
1302 dmub_hw_lock_mgr_cmd(dc->ctx->dmub_srv,
1303 lock,
1304 &hw_locks,
1305 &inst_flags);
1306 } else if (pipe->plane_state != NULL && pipe->plane_state->triplebuffer_flips) {
1307 if (lock)
1308 pipe->stream_res.tg->funcs->triplebuffer_lock(pipe->stream_res.tg);
1309 else
1310 pipe->stream_res.tg->funcs->triplebuffer_unlock(pipe->stream_res.tg);
1311 } else {
1312 if (lock)
1313 pipe->stream_res.tg->funcs->lock(pipe->stream_res.tg);
1314 else
1315 pipe->stream_res.tg->funcs->unlock(pipe->stream_res.tg);
1316 }
1317 }
1318
dcn20_detect_pipe_changes(struct pipe_ctx * old_pipe,struct pipe_ctx * new_pipe)1319 static void dcn20_detect_pipe_changes(struct pipe_ctx *old_pipe, struct pipe_ctx *new_pipe)
1320 {
1321 new_pipe->update_flags.raw = 0;
1322
1323 /* If non-phantom pipe is being transitioned to a phantom pipe,
1324 * set disable and return immediately. This is because the pipe
1325 * that was previously in use must be fully disabled before we
1326 * can "enable" it as a phantom pipe (since the OTG will certainly
1327 * be different). The post_unlock sequence will set the correct
1328 * update flags to enable the phantom pipe.
1329 */
1330 if (old_pipe->plane_state && !old_pipe->plane_state->is_phantom &&
1331 new_pipe->plane_state && new_pipe->plane_state->is_phantom) {
1332 new_pipe->update_flags.bits.disable = 1;
1333 return;
1334 }
1335
1336 /* Exit on unchanged, unused pipe */
1337 if (!old_pipe->plane_state && !new_pipe->plane_state)
1338 return;
1339 /* Detect pipe enable/disable */
1340 if (!old_pipe->plane_state && new_pipe->plane_state) {
1341 new_pipe->update_flags.bits.enable = 1;
1342 new_pipe->update_flags.bits.mpcc = 1;
1343 new_pipe->update_flags.bits.dppclk = 1;
1344 new_pipe->update_flags.bits.hubp_interdependent = 1;
1345 new_pipe->update_flags.bits.hubp_rq_dlg_ttu = 1;
1346 new_pipe->update_flags.bits.unbounded_req = 1;
1347 new_pipe->update_flags.bits.gamut_remap = 1;
1348 new_pipe->update_flags.bits.scaler = 1;
1349 new_pipe->update_flags.bits.viewport = 1;
1350 new_pipe->update_flags.bits.det_size = 1;
1351 if (!new_pipe->top_pipe && !new_pipe->prev_odm_pipe) {
1352 new_pipe->update_flags.bits.odm = 1;
1353 new_pipe->update_flags.bits.global_sync = 1;
1354 }
1355 return;
1356 }
1357
1358 /* For SubVP we need to unconditionally enable because any phantom pipes are
1359 * always removed then newly added for every full updates whenever SubVP is in use.
1360 * The remove-add sequence of the phantom pipe always results in the pipe
1361 * being blanked in enable_stream_timing (DPG).
1362 */
1363 if (new_pipe->stream && new_pipe->stream->mall_stream_config.type == SUBVP_PHANTOM)
1364 new_pipe->update_flags.bits.enable = 1;
1365
1366 /* Phantom pipes are effectively disabled, if the pipe was previously phantom
1367 * we have to enable
1368 */
1369 if (old_pipe->plane_state && old_pipe->plane_state->is_phantom &&
1370 new_pipe->plane_state && !new_pipe->plane_state->is_phantom)
1371 new_pipe->update_flags.bits.enable = 1;
1372
1373 if (old_pipe->plane_state && !new_pipe->plane_state) {
1374 new_pipe->update_flags.bits.disable = 1;
1375 return;
1376 }
1377
1378 /* Detect plane change */
1379 if (old_pipe->plane_state != new_pipe->plane_state) {
1380 new_pipe->update_flags.bits.plane_changed = true;
1381 }
1382
1383 /* Detect top pipe only changes */
1384 if (!new_pipe->top_pipe && !new_pipe->prev_odm_pipe) {
1385 /* Detect odm changes */
1386 if ((old_pipe->next_odm_pipe && new_pipe->next_odm_pipe
1387 && old_pipe->next_odm_pipe->pipe_idx != new_pipe->next_odm_pipe->pipe_idx)
1388 || (!old_pipe->next_odm_pipe && new_pipe->next_odm_pipe)
1389 || (old_pipe->next_odm_pipe && !new_pipe->next_odm_pipe)
1390 || old_pipe->stream_res.opp != new_pipe->stream_res.opp)
1391 new_pipe->update_flags.bits.odm = 1;
1392
1393 /* Detect global sync changes */
1394 if (old_pipe->pipe_dlg_param.vready_offset != new_pipe->pipe_dlg_param.vready_offset
1395 || old_pipe->pipe_dlg_param.vstartup_start != new_pipe->pipe_dlg_param.vstartup_start
1396 || old_pipe->pipe_dlg_param.vupdate_offset != new_pipe->pipe_dlg_param.vupdate_offset
1397 || old_pipe->pipe_dlg_param.vupdate_width != new_pipe->pipe_dlg_param.vupdate_width)
1398 new_pipe->update_flags.bits.global_sync = 1;
1399 }
1400
1401 if (old_pipe->det_buffer_size_kb != new_pipe->det_buffer_size_kb)
1402 new_pipe->update_flags.bits.det_size = 1;
1403
1404 /*
1405 * Detect opp / tg change, only set on change, not on enable
1406 * Assume mpcc inst = pipe index, if not this code needs to be updated
1407 * since mpcc is what is affected by these. In fact all of our sequence
1408 * makes this assumption at the moment with how hubp reset is matched to
1409 * same index mpcc reset.
1410 */
1411 if (old_pipe->stream_res.opp != new_pipe->stream_res.opp)
1412 new_pipe->update_flags.bits.opp_changed = 1;
1413 if (old_pipe->stream_res.tg != new_pipe->stream_res.tg)
1414 new_pipe->update_flags.bits.tg_changed = 1;
1415
1416 /*
1417 * Detect mpcc blending changes, only dpp inst and opp matter here,
1418 * mpccs getting removed/inserted update connected ones during their own
1419 * programming
1420 */
1421 if (old_pipe->plane_res.dpp != new_pipe->plane_res.dpp
1422 || old_pipe->stream_res.opp != new_pipe->stream_res.opp)
1423 new_pipe->update_flags.bits.mpcc = 1;
1424
1425 /* Detect dppclk change */
1426 if (old_pipe->plane_res.bw.dppclk_khz != new_pipe->plane_res.bw.dppclk_khz)
1427 new_pipe->update_flags.bits.dppclk = 1;
1428
1429 /* Check for scl update */
1430 if (memcmp(&old_pipe->plane_res.scl_data, &new_pipe->plane_res.scl_data, sizeof(struct scaler_data)))
1431 new_pipe->update_flags.bits.scaler = 1;
1432 /* Check for vp update */
1433 if (memcmp(&old_pipe->plane_res.scl_data.viewport, &new_pipe->plane_res.scl_data.viewport, sizeof(struct rect))
1434 || memcmp(&old_pipe->plane_res.scl_data.viewport_c,
1435 &new_pipe->plane_res.scl_data.viewport_c, sizeof(struct rect)))
1436 new_pipe->update_flags.bits.viewport = 1;
1437
1438 /* Detect dlg/ttu/rq updates */
1439 {
1440 struct _vcs_dpi_display_dlg_regs_st old_dlg_attr = old_pipe->dlg_regs;
1441 struct _vcs_dpi_display_ttu_regs_st old_ttu_attr = old_pipe->ttu_regs;
1442 struct _vcs_dpi_display_dlg_regs_st *new_dlg_attr = &new_pipe->dlg_regs;
1443 struct _vcs_dpi_display_ttu_regs_st *new_ttu_attr = &new_pipe->ttu_regs;
1444
1445 /* Detect pipe interdependent updates */
1446 if (old_dlg_attr.dst_y_prefetch != new_dlg_attr->dst_y_prefetch ||
1447 old_dlg_attr.vratio_prefetch != new_dlg_attr->vratio_prefetch ||
1448 old_dlg_attr.vratio_prefetch_c != new_dlg_attr->vratio_prefetch_c ||
1449 old_dlg_attr.dst_y_per_vm_vblank != new_dlg_attr->dst_y_per_vm_vblank ||
1450 old_dlg_attr.dst_y_per_row_vblank != new_dlg_attr->dst_y_per_row_vblank ||
1451 old_dlg_attr.dst_y_per_vm_flip != new_dlg_attr->dst_y_per_vm_flip ||
1452 old_dlg_attr.dst_y_per_row_flip != new_dlg_attr->dst_y_per_row_flip ||
1453 old_dlg_attr.refcyc_per_meta_chunk_vblank_l != new_dlg_attr->refcyc_per_meta_chunk_vblank_l ||
1454 old_dlg_attr.refcyc_per_meta_chunk_vblank_c != new_dlg_attr->refcyc_per_meta_chunk_vblank_c ||
1455 old_dlg_attr.refcyc_per_meta_chunk_flip_l != new_dlg_attr->refcyc_per_meta_chunk_flip_l ||
1456 old_dlg_attr.refcyc_per_line_delivery_pre_l != new_dlg_attr->refcyc_per_line_delivery_pre_l ||
1457 old_dlg_attr.refcyc_per_line_delivery_pre_c != new_dlg_attr->refcyc_per_line_delivery_pre_c ||
1458 old_ttu_attr.refcyc_per_req_delivery_pre_l != new_ttu_attr->refcyc_per_req_delivery_pre_l ||
1459 old_ttu_attr.refcyc_per_req_delivery_pre_c != new_ttu_attr->refcyc_per_req_delivery_pre_c ||
1460 old_ttu_attr.refcyc_per_req_delivery_pre_cur0 != new_ttu_attr->refcyc_per_req_delivery_pre_cur0 ||
1461 old_ttu_attr.refcyc_per_req_delivery_pre_cur1 != new_ttu_attr->refcyc_per_req_delivery_pre_cur1 ||
1462 old_ttu_attr.min_ttu_vblank != new_ttu_attr->min_ttu_vblank ||
1463 old_ttu_attr.qos_level_flip != new_ttu_attr->qos_level_flip) {
1464 old_dlg_attr.dst_y_prefetch = new_dlg_attr->dst_y_prefetch;
1465 old_dlg_attr.vratio_prefetch = new_dlg_attr->vratio_prefetch;
1466 old_dlg_attr.vratio_prefetch_c = new_dlg_attr->vratio_prefetch_c;
1467 old_dlg_attr.dst_y_per_vm_vblank = new_dlg_attr->dst_y_per_vm_vblank;
1468 old_dlg_attr.dst_y_per_row_vblank = new_dlg_attr->dst_y_per_row_vblank;
1469 old_dlg_attr.dst_y_per_vm_flip = new_dlg_attr->dst_y_per_vm_flip;
1470 old_dlg_attr.dst_y_per_row_flip = new_dlg_attr->dst_y_per_row_flip;
1471 old_dlg_attr.refcyc_per_meta_chunk_vblank_l = new_dlg_attr->refcyc_per_meta_chunk_vblank_l;
1472 old_dlg_attr.refcyc_per_meta_chunk_vblank_c = new_dlg_attr->refcyc_per_meta_chunk_vblank_c;
1473 old_dlg_attr.refcyc_per_meta_chunk_flip_l = new_dlg_attr->refcyc_per_meta_chunk_flip_l;
1474 old_dlg_attr.refcyc_per_line_delivery_pre_l = new_dlg_attr->refcyc_per_line_delivery_pre_l;
1475 old_dlg_attr.refcyc_per_line_delivery_pre_c = new_dlg_attr->refcyc_per_line_delivery_pre_c;
1476 old_ttu_attr.refcyc_per_req_delivery_pre_l = new_ttu_attr->refcyc_per_req_delivery_pre_l;
1477 old_ttu_attr.refcyc_per_req_delivery_pre_c = new_ttu_attr->refcyc_per_req_delivery_pre_c;
1478 old_ttu_attr.refcyc_per_req_delivery_pre_cur0 = new_ttu_attr->refcyc_per_req_delivery_pre_cur0;
1479 old_ttu_attr.refcyc_per_req_delivery_pre_cur1 = new_ttu_attr->refcyc_per_req_delivery_pre_cur1;
1480 old_ttu_attr.min_ttu_vblank = new_ttu_attr->min_ttu_vblank;
1481 old_ttu_attr.qos_level_flip = new_ttu_attr->qos_level_flip;
1482 new_pipe->update_flags.bits.hubp_interdependent = 1;
1483 }
1484 /* Detect any other updates to ttu/rq/dlg */
1485 if (memcmp(&old_dlg_attr, &new_pipe->dlg_regs, sizeof(old_dlg_attr)) ||
1486 memcmp(&old_ttu_attr, &new_pipe->ttu_regs, sizeof(old_ttu_attr)) ||
1487 memcmp(&old_pipe->rq_regs, &new_pipe->rq_regs, sizeof(old_pipe->rq_regs)))
1488 new_pipe->update_flags.bits.hubp_rq_dlg_ttu = 1;
1489 }
1490
1491 if (old_pipe->unbounded_req != new_pipe->unbounded_req)
1492 new_pipe->update_flags.bits.unbounded_req = 1;
1493 }
1494
dcn20_update_dchubp_dpp(struct dc * dc,struct pipe_ctx * pipe_ctx,struct dc_state * context)1495 static void dcn20_update_dchubp_dpp(
1496 struct dc *dc,
1497 struct pipe_ctx *pipe_ctx,
1498 struct dc_state *context)
1499 {
1500 struct dce_hwseq *hws = dc->hwseq;
1501 struct hubp *hubp = pipe_ctx->plane_res.hubp;
1502 struct dpp *dpp = pipe_ctx->plane_res.dpp;
1503 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
1504 struct dccg *dccg = dc->res_pool->dccg;
1505 bool viewport_changed = false;
1506
1507 if (pipe_ctx->update_flags.bits.dppclk)
1508 dpp->funcs->dpp_dppclk_control(dpp, false, true);
1509
1510 if (pipe_ctx->update_flags.bits.enable)
1511 dccg->funcs->update_dpp_dto(dccg, dpp->inst, pipe_ctx->plane_res.bw.dppclk_khz);
1512
1513 /* TODO: Need input parameter to tell current DCHUB pipe tie to which OTG
1514 * VTG is within DCHUBBUB which is commond block share by each pipe HUBP.
1515 * VTG is 1:1 mapping with OTG. Each pipe HUBP will select which VTG
1516 */
1517 if (pipe_ctx->update_flags.bits.hubp_rq_dlg_ttu) {
1518 hubp->funcs->hubp_vtg_sel(hubp, pipe_ctx->stream_res.tg->inst);
1519
1520 hubp->funcs->hubp_setup(
1521 hubp,
1522 &pipe_ctx->dlg_regs,
1523 &pipe_ctx->ttu_regs,
1524 &pipe_ctx->rq_regs,
1525 &pipe_ctx->pipe_dlg_param);
1526 }
1527
1528 if (pipe_ctx->update_flags.bits.unbounded_req && hubp->funcs->set_unbounded_requesting)
1529 hubp->funcs->set_unbounded_requesting(hubp, pipe_ctx->unbounded_req);
1530
1531 if (pipe_ctx->update_flags.bits.hubp_interdependent)
1532 hubp->funcs->hubp_setup_interdependent(
1533 hubp,
1534 &pipe_ctx->dlg_regs,
1535 &pipe_ctx->ttu_regs);
1536
1537 if (pipe_ctx->update_flags.bits.enable ||
1538 pipe_ctx->update_flags.bits.plane_changed ||
1539 plane_state->update_flags.bits.bpp_change ||
1540 plane_state->update_flags.bits.input_csc_change ||
1541 plane_state->update_flags.bits.color_space_change ||
1542 plane_state->update_flags.bits.coeff_reduction_change) {
1543 struct dc_bias_and_scale bns_params = {0};
1544
1545 // program the input csc
1546 dpp->funcs->dpp_setup(dpp,
1547 plane_state->format,
1548 EXPANSION_MODE_ZERO,
1549 plane_state->input_csc_color_matrix,
1550 plane_state->color_space,
1551 NULL);
1552
1553 if (dpp->funcs->dpp_program_bias_and_scale) {
1554 //TODO :for CNVC set scale and bias registers if necessary
1555 build_prescale_params(&bns_params, plane_state);
1556 dpp->funcs->dpp_program_bias_and_scale(dpp, &bns_params);
1557 }
1558 }
1559
1560 if (pipe_ctx->update_flags.bits.mpcc
1561 || pipe_ctx->update_flags.bits.plane_changed
1562 || plane_state->update_flags.bits.global_alpha_change
1563 || plane_state->update_flags.bits.per_pixel_alpha_change) {
1564 // MPCC inst is equal to pipe index in practice
1565 hws->funcs.update_mpcc(dc, pipe_ctx);
1566 }
1567
1568 if (pipe_ctx->update_flags.bits.scaler ||
1569 plane_state->update_flags.bits.scaling_change ||
1570 plane_state->update_flags.bits.position_change ||
1571 plane_state->update_flags.bits.per_pixel_alpha_change ||
1572 pipe_ctx->stream->update_flags.bits.scaling) {
1573 pipe_ctx->plane_res.scl_data.lb_params.alpha_en = pipe_ctx->plane_state->per_pixel_alpha;
1574 ASSERT(pipe_ctx->plane_res.scl_data.lb_params.depth == LB_PIXEL_DEPTH_36BPP);
1575 /* scaler configuration */
1576 pipe_ctx->plane_res.dpp->funcs->dpp_set_scaler(
1577 pipe_ctx->plane_res.dpp, &pipe_ctx->plane_res.scl_data);
1578 }
1579
1580 if (pipe_ctx->update_flags.bits.viewport ||
1581 (context == dc->current_state && plane_state->update_flags.bits.position_change) ||
1582 (context == dc->current_state && plane_state->update_flags.bits.scaling_change) ||
1583 (context == dc->current_state && pipe_ctx->stream->update_flags.bits.scaling)) {
1584
1585 hubp->funcs->mem_program_viewport(
1586 hubp,
1587 &pipe_ctx->plane_res.scl_data.viewport,
1588 &pipe_ctx->plane_res.scl_data.viewport_c);
1589 viewport_changed = true;
1590 }
1591
1592 /* Any updates are handled in dc interface, just need to apply existing for plane enable */
1593 if ((pipe_ctx->update_flags.bits.enable || pipe_ctx->update_flags.bits.opp_changed ||
1594 pipe_ctx->update_flags.bits.scaler || viewport_changed == true) &&
1595 pipe_ctx->stream->cursor_attributes.address.quad_part != 0) {
1596 dc->hwss.set_cursor_position(pipe_ctx);
1597 dc->hwss.set_cursor_attribute(pipe_ctx);
1598
1599 if (dc->hwss.set_cursor_sdr_white_level)
1600 dc->hwss.set_cursor_sdr_white_level(pipe_ctx);
1601 }
1602
1603 /* Any updates are handled in dc interface, just need
1604 * to apply existing for plane enable / opp change */
1605 if (pipe_ctx->update_flags.bits.enable || pipe_ctx->update_flags.bits.opp_changed
1606 || pipe_ctx->update_flags.bits.plane_changed
1607 || pipe_ctx->stream->update_flags.bits.gamut_remap
1608 || plane_state->update_flags.bits.gamut_remap_change
1609 || pipe_ctx->stream->update_flags.bits.out_csc) {
1610 /* dpp/cm gamut remap*/
1611 dc->hwss.program_gamut_remap(pipe_ctx);
1612
1613 /*call the dcn2 method which uses mpc csc*/
1614 dc->hwss.program_output_csc(dc,
1615 pipe_ctx,
1616 pipe_ctx->stream->output_color_space,
1617 pipe_ctx->stream->csc_color_matrix.matrix,
1618 hubp->opp_id);
1619 }
1620
1621 if (pipe_ctx->update_flags.bits.enable ||
1622 pipe_ctx->update_flags.bits.plane_changed ||
1623 pipe_ctx->update_flags.bits.opp_changed ||
1624 plane_state->update_flags.bits.pixel_format_change ||
1625 plane_state->update_flags.bits.horizontal_mirror_change ||
1626 plane_state->update_flags.bits.rotation_change ||
1627 plane_state->update_flags.bits.swizzle_change ||
1628 plane_state->update_flags.bits.dcc_change ||
1629 plane_state->update_flags.bits.bpp_change ||
1630 plane_state->update_flags.bits.scaling_change ||
1631 plane_state->update_flags.bits.plane_size_change) {
1632 struct plane_size size = plane_state->plane_size;
1633
1634 size.surface_size = pipe_ctx->plane_res.scl_data.viewport;
1635 hubp->funcs->hubp_program_surface_config(
1636 hubp,
1637 plane_state->format,
1638 &plane_state->tiling_info,
1639 &size,
1640 plane_state->rotation,
1641 &plane_state->dcc,
1642 plane_state->horizontal_mirror,
1643 0);
1644 hubp->power_gated = false;
1645 }
1646
1647 if (pipe_ctx->update_flags.bits.enable ||
1648 pipe_ctx->update_flags.bits.plane_changed ||
1649 plane_state->update_flags.bits.addr_update)
1650 hws->funcs.update_plane_addr(dc, pipe_ctx);
1651
1652 if (pipe_ctx->update_flags.bits.enable)
1653 hubp->funcs->set_blank(hubp, false);
1654 /* If the stream paired with this plane is phantom, the plane is also phantom */
1655 if (pipe_ctx->stream && pipe_ctx->stream->mall_stream_config.type == SUBVP_PHANTOM
1656 && hubp->funcs->phantom_hubp_post_enable)
1657 hubp->funcs->phantom_hubp_post_enable(hubp);
1658 }
1659
calculate_vready_offset_for_group(struct pipe_ctx * pipe)1660 static int calculate_vready_offset_for_group(struct pipe_ctx *pipe)
1661 {
1662 struct pipe_ctx *other_pipe;
1663 int vready_offset = pipe->pipe_dlg_param.vready_offset;
1664
1665 /* Always use the largest vready_offset of all connected pipes */
1666 for (other_pipe = pipe->bottom_pipe; other_pipe != NULL; other_pipe = other_pipe->bottom_pipe) {
1667 if (other_pipe->pipe_dlg_param.vready_offset > vready_offset)
1668 vready_offset = other_pipe->pipe_dlg_param.vready_offset;
1669 }
1670 for (other_pipe = pipe->top_pipe; other_pipe != NULL; other_pipe = other_pipe->top_pipe) {
1671 if (other_pipe->pipe_dlg_param.vready_offset > vready_offset)
1672 vready_offset = other_pipe->pipe_dlg_param.vready_offset;
1673 }
1674 for (other_pipe = pipe->next_odm_pipe; other_pipe != NULL; other_pipe = other_pipe->next_odm_pipe) {
1675 if (other_pipe->pipe_dlg_param.vready_offset > vready_offset)
1676 vready_offset = other_pipe->pipe_dlg_param.vready_offset;
1677 }
1678 for (other_pipe = pipe->prev_odm_pipe; other_pipe != NULL; other_pipe = other_pipe->prev_odm_pipe) {
1679 if (other_pipe->pipe_dlg_param.vready_offset > vready_offset)
1680 vready_offset = other_pipe->pipe_dlg_param.vready_offset;
1681 }
1682
1683 return vready_offset;
1684 }
1685
dcn20_program_pipe(struct dc * dc,struct pipe_ctx * pipe_ctx,struct dc_state * context)1686 static void dcn20_program_pipe(
1687 struct dc *dc,
1688 struct pipe_ctx *pipe_ctx,
1689 struct dc_state *context)
1690 {
1691 struct dce_hwseq *hws = dc->hwseq;
1692
1693 /* Only need to unblank on top pipe */
1694 if (resource_is_pipe_type(pipe_ctx, OTG_MASTER)) {
1695 if (pipe_ctx->update_flags.bits.enable ||
1696 pipe_ctx->update_flags.bits.odm ||
1697 pipe_ctx->stream->update_flags.bits.abm_level)
1698 hws->funcs.blank_pixel_data(dc, pipe_ctx,
1699 !pipe_ctx->plane_state ||
1700 !pipe_ctx->plane_state->visible);
1701 }
1702
1703 /* Only update TG on top pipe */
1704 if (pipe_ctx->update_flags.bits.global_sync && !pipe_ctx->top_pipe
1705 && !pipe_ctx->prev_odm_pipe) {
1706 pipe_ctx->stream_res.tg->funcs->program_global_sync(
1707 pipe_ctx->stream_res.tg,
1708 calculate_vready_offset_for_group(pipe_ctx),
1709 pipe_ctx->pipe_dlg_param.vstartup_start,
1710 pipe_ctx->pipe_dlg_param.vupdate_offset,
1711 pipe_ctx->pipe_dlg_param.vupdate_width);
1712
1713 if (pipe_ctx->stream->mall_stream_config.type != SUBVP_PHANTOM)
1714 pipe_ctx->stream_res.tg->funcs->wait_for_state(pipe_ctx->stream_res.tg, CRTC_STATE_VACTIVE);
1715
1716 pipe_ctx->stream_res.tg->funcs->set_vtg_params(
1717 pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, true);
1718
1719 if (hws->funcs.setup_vupdate_interrupt)
1720 hws->funcs.setup_vupdate_interrupt(dc, pipe_ctx);
1721 }
1722
1723 if (pipe_ctx->update_flags.bits.odm)
1724 hws->funcs.update_odm(dc, context, pipe_ctx);
1725
1726 if (pipe_ctx->update_flags.bits.enable) {
1727 dcn20_enable_plane(dc, pipe_ctx, context);
1728 if (dc->res_pool->hubbub->funcs->force_wm_propagate_to_pipes)
1729 dc->res_pool->hubbub->funcs->force_wm_propagate_to_pipes(dc->res_pool->hubbub);
1730 }
1731
1732 if (dc->res_pool->hubbub->funcs->program_det_size && pipe_ctx->update_flags.bits.det_size)
1733 dc->res_pool->hubbub->funcs->program_det_size(
1734 dc->res_pool->hubbub, pipe_ctx->plane_res.hubp->inst, pipe_ctx->det_buffer_size_kb);
1735
1736 if (pipe_ctx->update_flags.raw ||
1737 (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.raw) ||
1738 pipe_ctx->stream->update_flags.raw)
1739 dcn20_update_dchubp_dpp(dc, pipe_ctx, context);
1740
1741 if (pipe_ctx->update_flags.bits.enable ||
1742 (pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult))
1743 hws->funcs.set_hdr_multiplier(pipe_ctx);
1744
1745 if ((pipe_ctx->plane_state && pipe_ctx->plane_state->update_flags.bits.hdr_mult) ||
1746 pipe_ctx->update_flags.bits.enable)
1747 hws->funcs.set_hdr_multiplier(pipe_ctx);
1748
1749 if ((pipe_ctx->plane_state &&
1750 pipe_ctx->plane_state->update_flags.bits.in_transfer_func_change) ||
1751 (pipe_ctx->plane_state &&
1752 pipe_ctx->plane_state->update_flags.bits.gamma_change) ||
1753 (pipe_ctx->plane_state &&
1754 pipe_ctx->plane_state->update_flags.bits.lut_3d) ||
1755 pipe_ctx->update_flags.bits.enable)
1756 hws->funcs.set_input_transfer_func(dc, pipe_ctx, pipe_ctx->plane_state);
1757
1758 /* dcn10_translate_regamma_to_hw_format takes 750us to finish
1759 * only do gamma programming for powering on, internal memcmp to avoid
1760 * updating on slave planes
1761 */
1762 if (pipe_ctx->update_flags.bits.enable ||
1763 pipe_ctx->update_flags.bits.plane_changed ||
1764 pipe_ctx->stream->update_flags.bits.out_tf ||
1765 (pipe_ctx->plane_state &&
1766 pipe_ctx->plane_state->update_flags.bits.output_tf_change))
1767 hws->funcs.set_output_transfer_func(dc, pipe_ctx, pipe_ctx->stream);
1768
1769 /* If the pipe has been enabled or has a different opp, we
1770 * should reprogram the fmt. This deals with cases where
1771 * interation between mpc and odm combine on different streams
1772 * causes a different pipe to be chosen to odm combine with.
1773 */
1774 if (pipe_ctx->update_flags.bits.enable
1775 || pipe_ctx->update_flags.bits.opp_changed) {
1776
1777 pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion(
1778 pipe_ctx->stream_res.opp,
1779 COLOR_SPACE_YCBCR601,
1780 pipe_ctx->stream->timing.display_color_depth,
1781 pipe_ctx->stream->signal);
1782
1783 pipe_ctx->stream_res.opp->funcs->opp_program_fmt(
1784 pipe_ctx->stream_res.opp,
1785 &pipe_ctx->stream->bit_depth_params,
1786 &pipe_ctx->stream->clamping);
1787 }
1788
1789 /* Set ABM pipe after other pipe configurations done */
1790 if ((pipe_ctx->plane_state && pipe_ctx->plane_state->visible)) {
1791 if (pipe_ctx->stream_res.abm) {
1792 dc->hwss.set_pipe(pipe_ctx);
1793 pipe_ctx->stream_res.abm->funcs->set_abm_level(pipe_ctx->stream_res.abm,
1794 pipe_ctx->stream->abm_level);
1795 }
1796 }
1797 }
1798
dcn20_program_front_end_for_ctx(struct dc * dc,struct dc_state * context)1799 void dcn20_program_front_end_for_ctx(
1800 struct dc *dc,
1801 struct dc_state *context)
1802 {
1803 int i;
1804 struct dce_hwseq *hws = dc->hwseq;
1805 DC_LOGGER_INIT(dc->ctx->logger);
1806 unsigned int prev_hubp_count = 0;
1807 unsigned int hubp_count = 0;
1808
1809 /* Carry over GSL groups in case the context is changing. */
1810 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1811 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
1812 struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
1813
1814 if (pipe_ctx->stream == old_pipe_ctx->stream)
1815 pipe_ctx->stream_res.gsl_group = old_pipe_ctx->stream_res.gsl_group;
1816 }
1817
1818 if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) {
1819 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1820 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
1821
1822 if (!pipe_ctx->top_pipe && !pipe_ctx->prev_odm_pipe && pipe_ctx->plane_state) {
1823 ASSERT(!pipe_ctx->plane_state->triplebuffer_flips);
1824 /*turn off triple buffer for full update*/
1825 dc->hwss.program_triplebuffer(
1826 dc, pipe_ctx, pipe_ctx->plane_state->triplebuffer_flips);
1827 }
1828 }
1829 }
1830
1831 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1832 if (dc->current_state->res_ctx.pipe_ctx[i].plane_state)
1833 prev_hubp_count++;
1834 if (context->res_ctx.pipe_ctx[i].plane_state)
1835 hubp_count++;
1836 }
1837
1838 if (prev_hubp_count == 0 && hubp_count > 0) {
1839 if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
1840 dc->res_pool->hubbub->funcs->force_pstate_change_control(
1841 dc->res_pool->hubbub, true, false);
1842 udelay(500);
1843 }
1844
1845 /* Set pipe update flags and lock pipes */
1846 for (i = 0; i < dc->res_pool->pipe_count; i++)
1847 dcn20_detect_pipe_changes(&dc->current_state->res_ctx.pipe_ctx[i],
1848 &context->res_ctx.pipe_ctx[i]);
1849
1850 /* When disabling phantom pipes, turn on phantom OTG first (so we can get double
1851 * buffer updates properly)
1852 */
1853 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1854 struct dc_stream_state *stream = dc->current_state->res_ctx.pipe_ctx[i].stream;
1855
1856 if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable && stream &&
1857 dc->current_state->res_ctx.pipe_ctx[i].stream->mall_stream_config.type == SUBVP_PHANTOM) {
1858 struct timing_generator *tg = dc->current_state->res_ctx.pipe_ctx[i].stream_res.tg;
1859
1860 if (tg->funcs->enable_crtc) {
1861 if (dc->hwss.blank_phantom) {
1862 int main_pipe_width, main_pipe_height;
1863
1864 main_pipe_width = dc->current_state->res_ctx.pipe_ctx[i].stream->mall_stream_config.paired_stream->dst.width;
1865 main_pipe_height = dc->current_state->res_ctx.pipe_ctx[i].stream->mall_stream_config.paired_stream->dst.height;
1866 dc->hwss.blank_phantom(dc, tg, main_pipe_width, main_pipe_height);
1867 }
1868 tg->funcs->enable_crtc(tg);
1869 }
1870 }
1871 }
1872 /* OTG blank before disabling all front ends */
1873 for (i = 0; i < dc->res_pool->pipe_count; i++)
1874 if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable
1875 && !context->res_ctx.pipe_ctx[i].top_pipe
1876 && !context->res_ctx.pipe_ctx[i].prev_odm_pipe
1877 && context->res_ctx.pipe_ctx[i].stream)
1878 hws->funcs.blank_pixel_data(dc, &context->res_ctx.pipe_ctx[i], true);
1879
1880
1881 /* Disconnect mpcc */
1882 for (i = 0; i < dc->res_pool->pipe_count; i++)
1883 if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable
1884 || context->res_ctx.pipe_ctx[i].update_flags.bits.opp_changed) {
1885 struct hubbub *hubbub = dc->res_pool->hubbub;
1886
1887 /* Phantom pipe DET should be 0, but if a pipe in use is being transitioned to phantom
1888 * then we want to do the programming here (effectively it's being disabled). If we do
1889 * the programming later the DET won't be updated until the OTG for the phantom pipe is
1890 * turned on (i.e. in an MCLK switch) which can come in too late and cause issues with
1891 * DET allocation.
1892 */
1893 if (hubbub->funcs->program_det_size && (context->res_ctx.pipe_ctx[i].update_flags.bits.disable ||
1894 (context->res_ctx.pipe_ctx[i].plane_state && context->res_ctx.pipe_ctx[i].plane_state->is_phantom)))
1895 hubbub->funcs->program_det_size(hubbub, dc->current_state->res_ctx.pipe_ctx[i].plane_res.hubp->inst, 0);
1896 hws->funcs.plane_atomic_disconnect(dc, &dc->current_state->res_ctx.pipe_ctx[i]);
1897 DC_LOG_DC("Reset mpcc for pipe %d\n", dc->current_state->res_ctx.pipe_ctx[i].pipe_idx);
1898 }
1899
1900 /*
1901 * Program all updated pipes, order matters for mpcc setup. Start with
1902 * top pipe and program all pipes that follow in order
1903 */
1904 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1905 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
1906
1907 if (pipe->plane_state && !pipe->top_pipe) {
1908 while (pipe) {
1909 if (hws->funcs.program_pipe)
1910 hws->funcs.program_pipe(dc, pipe, context);
1911 else {
1912 /* Don't program phantom pipes in the regular front end programming sequence.
1913 * There is an MPO transition case where a pipe being used by a video plane is
1914 * transitioned directly to be a phantom pipe when closing the MPO video. However
1915 * the phantom pipe will program a new HUBP_VTG_SEL (update takes place right away),
1916 * but the MPO still exists until the double buffered update of the main pipe so we
1917 * will get a frame of underflow if the phantom pipe is programmed here.
1918 */
1919 if (pipe->stream && pipe->stream->mall_stream_config.type != SUBVP_PHANTOM)
1920 dcn20_program_pipe(dc, pipe, context);
1921 }
1922
1923 pipe = pipe->bottom_pipe;
1924 }
1925 }
1926 /* Program secondary blending tree and writeback pipes */
1927 pipe = &context->res_ctx.pipe_ctx[i];
1928 if (!pipe->top_pipe && !pipe->prev_odm_pipe
1929 && pipe->stream && pipe->stream->num_wb_info > 0
1930 && (pipe->update_flags.raw || (pipe->plane_state && pipe->plane_state->update_flags.raw)
1931 || pipe->stream->update_flags.raw)
1932 && hws->funcs.program_all_writeback_pipes_in_tree)
1933 hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context);
1934
1935 /* Avoid underflow by check of pipe line read when adding 2nd plane. */
1936 if (hws->wa.wait_hubpret_read_start_during_mpo_transition &&
1937 !pipe->top_pipe &&
1938 pipe->stream &&
1939 pipe->plane_res.hubp->funcs->hubp_wait_pipe_read_start &&
1940 dc->current_state->stream_status[0].plane_count == 1 &&
1941 context->stream_status[0].plane_count > 1) {
1942 pipe->plane_res.hubp->funcs->hubp_wait_pipe_read_start(pipe->plane_res.hubp);
1943 }
1944
1945 /* when dynamic ODM is active, pipes must be reconfigured when all planes are
1946 * disabled, as some transitions will leave software and hardware state
1947 * mismatched.
1948 */
1949 if (dc->debug.enable_single_display_2to1_odm_policy &&
1950 pipe->stream &&
1951 pipe->update_flags.bits.disable &&
1952 !pipe->prev_odm_pipe &&
1953 hws->funcs.update_odm)
1954 hws->funcs.update_odm(dc, context, pipe);
1955 }
1956 }
1957
dcn20_post_unlock_program_front_end(struct dc * dc,struct dc_state * context)1958 void dcn20_post_unlock_program_front_end(
1959 struct dc *dc,
1960 struct dc_state *context)
1961 {
1962 int i;
1963 const unsigned int TIMEOUT_FOR_PIPE_ENABLE_US = 100000;
1964 unsigned int polling_interval_us = 1;
1965 struct dce_hwseq *hwseq = dc->hwseq;
1966
1967 DC_LOGGER_INIT(dc->ctx->logger);
1968
1969 for (i = 0; i < dc->res_pool->pipe_count; i++)
1970 if (context->res_ctx.pipe_ctx[i].update_flags.bits.disable)
1971 dc->hwss.disable_plane(dc, &dc->current_state->res_ctx.pipe_ctx[i]);
1972
1973 /*
1974 * If we are enabling a pipe, we need to wait for pending clear as this is a critical
1975 * part of the enable operation otherwise, DM may request an immediate flip which
1976 * will cause HW to perform an "immediate enable" (as opposed to "vsync enable") which
1977 * is unsupported on DCN.
1978 */
1979 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1980 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
1981 // Don't check flip pending on phantom pipes
1982 if (pipe->plane_state && !pipe->top_pipe && pipe->update_flags.bits.enable &&
1983 pipe->stream->mall_stream_config.type != SUBVP_PHANTOM) {
1984 struct hubp *hubp = pipe->plane_res.hubp;
1985 int j = 0;
1986 for (j = 0; j < TIMEOUT_FOR_PIPE_ENABLE_US / polling_interval_us
1987 && hubp->funcs->hubp_is_flip_pending(hubp); j++)
1988 udelay(polling_interval_us);
1989 }
1990 }
1991
1992 if (dc->res_pool->hubbub->funcs->force_pstate_change_control)
1993 dc->res_pool->hubbub->funcs->force_pstate_change_control(
1994 dc->res_pool->hubbub, false, false);
1995
1996 for (i = 0; i < dc->res_pool->pipe_count; i++) {
1997 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
1998
1999 if (pipe->plane_state && !pipe->top_pipe) {
2000 /* Program phantom pipe here to prevent a frame of underflow in the MPO transition
2001 * case (if a pipe being used for a video plane transitions to a phantom pipe, it
2002 * can underflow due to HUBP_VTG_SEL programming if done in the regular front end
2003 * programming sequence).
2004 */
2005 while (pipe) {
2006 if (pipe->stream && pipe->stream->mall_stream_config.type == SUBVP_PHANTOM) {
2007 /* When turning on the phantom pipe we want to run through the
2008 * entire enable sequence, so apply all the "enable" flags.
2009 */
2010 if (dc->hwss.apply_update_flags_for_phantom)
2011 dc->hwss.apply_update_flags_for_phantom(pipe);
2012 if (dc->hwss.update_phantom_vp_position)
2013 dc->hwss.update_phantom_vp_position(dc, context, pipe);
2014 dcn20_program_pipe(dc, pipe, context);
2015 }
2016 pipe = pipe->bottom_pipe;
2017 }
2018 }
2019 }
2020
2021 /* P-State support transitions:
2022 * Natural -> FPO: P-State disabled in prepare, force disallow anytime is safe
2023 * FPO -> Natural: Unforce anytime after FW disable is safe (P-State will assert naturally)
2024 * Unsupported -> FPO: P-State enabled in optimize, force disallow anytime is safe
2025 * FPO -> Unsupported: P-State disabled in prepare, unforce disallow anytime is safe
2026 * FPO <-> SubVP: Force disallow is maintained on the FPO / SubVP pipes
2027 */
2028 if (hwseq && hwseq->funcs.update_force_pstate)
2029 dc->hwseq->funcs.update_force_pstate(dc, context);
2030
2031 /* Only program the MALL registers after all the main and phantom pipes
2032 * are done programming.
2033 */
2034 if (hwseq->funcs.program_mall_pipe_config)
2035 hwseq->funcs.program_mall_pipe_config(dc, context);
2036
2037 /* WA to apply WM setting*/
2038 if (hwseq->wa.DEGVIDCN21)
2039 dc->res_pool->hubbub->funcs->apply_DEDCN21_147_wa(dc->res_pool->hubbub);
2040
2041
2042 /* WA for stutter underflow during MPO transitions when adding 2nd plane */
2043 if (hwseq->wa.disallow_self_refresh_during_multi_plane_transition) {
2044
2045 if (dc->current_state->stream_status[0].plane_count == 1 &&
2046 context->stream_status[0].plane_count > 1) {
2047
2048 struct timing_generator *tg = dc->res_pool->timing_generators[0];
2049
2050 dc->res_pool->hubbub->funcs->allow_self_refresh_control(dc->res_pool->hubbub, false);
2051
2052 hwseq->wa_state.disallow_self_refresh_during_multi_plane_transition_applied = true;
2053 hwseq->wa_state.disallow_self_refresh_during_multi_plane_transition_applied_on_frame = tg->funcs->get_frame_count(tg);
2054 }
2055 }
2056 }
2057
dcn20_prepare_bandwidth(struct dc * dc,struct dc_state * context)2058 void dcn20_prepare_bandwidth(
2059 struct dc *dc,
2060 struct dc_state *context)
2061 {
2062 struct hubbub *hubbub = dc->res_pool->hubbub;
2063 unsigned int compbuf_size_kb = 0;
2064 unsigned int cache_wm_a = context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns;
2065 unsigned int i;
2066
2067 dc->clk_mgr->funcs->update_clocks(
2068 dc->clk_mgr,
2069 context,
2070 false);
2071
2072 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2073 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
2074
2075 // At optimize don't restore the original watermark value
2076 if (pipe->stream && pipe->stream->mall_stream_config.type != SUBVP_NONE) {
2077 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = 4U * 1000U * 1000U * 1000U;
2078 break;
2079 }
2080 }
2081
2082 /* program dchubbub watermarks:
2083 * For assigning wm_optimized_required, use |= operator since we don't want
2084 * to clear the value if the optimize has not happened yet
2085 */
2086 dc->wm_optimized_required |= hubbub->funcs->program_watermarks(hubbub,
2087 &context->bw_ctx.bw.dcn.watermarks,
2088 dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000,
2089 false);
2090
2091 // Restore the real watermark so we can commit the value to DMCUB
2092 // DMCUB uses the "original" watermark value in SubVP MCLK switch
2093 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = cache_wm_a;
2094
2095 /* decrease compbuf size */
2096 if (hubbub->funcs->program_compbuf_size) {
2097 if (context->bw_ctx.dml.ip.min_comp_buffer_size_kbytes) {
2098 compbuf_size_kb = context->bw_ctx.dml.ip.min_comp_buffer_size_kbytes;
2099 dc->wm_optimized_required |= (compbuf_size_kb != dc->current_state->bw_ctx.dml.ip.min_comp_buffer_size_kbytes);
2100 } else {
2101 compbuf_size_kb = context->bw_ctx.bw.dcn.compbuf_size_kb;
2102 dc->wm_optimized_required |= (compbuf_size_kb != dc->current_state->bw_ctx.bw.dcn.compbuf_size_kb);
2103 }
2104
2105 hubbub->funcs->program_compbuf_size(hubbub, compbuf_size_kb, false);
2106 }
2107 }
2108
dcn20_optimize_bandwidth(struct dc * dc,struct dc_state * context)2109 void dcn20_optimize_bandwidth(
2110 struct dc *dc,
2111 struct dc_state *context)
2112 {
2113 struct hubbub *hubbub = dc->res_pool->hubbub;
2114 int i;
2115
2116 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2117 struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
2118
2119 // At optimize don't need to restore the original watermark value
2120 if (pipe->stream && pipe->stream->mall_stream_config.type != SUBVP_NONE) {
2121 context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = 4U * 1000U * 1000U * 1000U;
2122 break;
2123 }
2124 }
2125
2126 /* program dchubbub watermarks */
2127 hubbub->funcs->program_watermarks(hubbub,
2128 &context->bw_ctx.bw.dcn.watermarks,
2129 dc->res_pool->ref_clocks.dchub_ref_clock_inKhz / 1000,
2130 true);
2131
2132 if (dc->clk_mgr->dc_mode_softmax_enabled)
2133 if (dc->clk_mgr->clks.dramclk_khz > dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000 &&
2134 context->bw_ctx.bw.dcn.clk.dramclk_khz <= dc->clk_mgr->bw_params->dc_mode_softmax_memclk * 1000)
2135 dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, dc->clk_mgr->bw_params->dc_mode_softmax_memclk);
2136
2137 /* increase compbuf size */
2138 if (hubbub->funcs->program_compbuf_size)
2139 hubbub->funcs->program_compbuf_size(hubbub, context->bw_ctx.bw.dcn.compbuf_size_kb, true);
2140
2141 if (context->bw_ctx.bw.dcn.clk.fw_based_mclk_switching) {
2142 dc_dmub_srv_p_state_delegate(dc,
2143 true, context);
2144 context->bw_ctx.bw.dcn.clk.p_state_change_support = true;
2145 dc->clk_mgr->clks.fw_based_mclk_switching = true;
2146 } else {
2147 dc->clk_mgr->clks.fw_based_mclk_switching = false;
2148 }
2149
2150 dc->clk_mgr->funcs->update_clocks(
2151 dc->clk_mgr,
2152 context,
2153 true);
2154 if (context->bw_ctx.bw.dcn.clk.zstate_support == DCN_ZSTATE_SUPPORT_ALLOW) {
2155 for (i = 0; i < dc->res_pool->pipe_count; ++i) {
2156 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2157
2158 if (pipe_ctx->stream && pipe_ctx->plane_res.hubp->funcs->program_extended_blank
2159 && pipe_ctx->stream->adjust.v_total_min == pipe_ctx->stream->adjust.v_total_max
2160 && pipe_ctx->stream->adjust.v_total_max > pipe_ctx->stream->timing.v_total)
2161 pipe_ctx->plane_res.hubp->funcs->program_extended_blank(pipe_ctx->plane_res.hubp,
2162 pipe_ctx->dlg_regs.min_dst_y_next_start);
2163 }
2164 }
2165 }
2166
dcn20_update_bandwidth(struct dc * dc,struct dc_state * context)2167 bool dcn20_update_bandwidth(
2168 struct dc *dc,
2169 struct dc_state *context)
2170 {
2171 int i;
2172 struct dce_hwseq *hws = dc->hwseq;
2173
2174 /* recalculate DML parameters */
2175 if (!dc->res_pool->funcs->validate_bandwidth(dc, context, false))
2176 return false;
2177
2178 /* apply updated bandwidth parameters */
2179 dc->hwss.prepare_bandwidth(dc, context);
2180
2181 /* update hubp configs for all pipes */
2182 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2183 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2184
2185 if (pipe_ctx->plane_state == NULL)
2186 continue;
2187
2188 if (pipe_ctx->top_pipe == NULL) {
2189 bool blank = !is_pipe_tree_visible(pipe_ctx);
2190
2191 pipe_ctx->stream_res.tg->funcs->program_global_sync(
2192 pipe_ctx->stream_res.tg,
2193 calculate_vready_offset_for_group(pipe_ctx),
2194 pipe_ctx->pipe_dlg_param.vstartup_start,
2195 pipe_ctx->pipe_dlg_param.vupdate_offset,
2196 pipe_ctx->pipe_dlg_param.vupdate_width);
2197
2198 pipe_ctx->stream_res.tg->funcs->set_vtg_params(
2199 pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing, false);
2200
2201 if (pipe_ctx->prev_odm_pipe == NULL)
2202 hws->funcs.blank_pixel_data(dc, pipe_ctx, blank);
2203
2204 if (hws->funcs.setup_vupdate_interrupt)
2205 hws->funcs.setup_vupdate_interrupt(dc, pipe_ctx);
2206 }
2207
2208 pipe_ctx->plane_res.hubp->funcs->hubp_setup(
2209 pipe_ctx->plane_res.hubp,
2210 &pipe_ctx->dlg_regs,
2211 &pipe_ctx->ttu_regs,
2212 &pipe_ctx->rq_regs,
2213 &pipe_ctx->pipe_dlg_param);
2214 }
2215
2216 return true;
2217 }
2218
dcn20_enable_writeback(struct dc * dc,struct dc_writeback_info * wb_info,struct dc_state * context)2219 void dcn20_enable_writeback(
2220 struct dc *dc,
2221 struct dc_writeback_info *wb_info,
2222 struct dc_state *context)
2223 {
2224 struct dwbc *dwb;
2225 struct mcif_wb *mcif_wb;
2226 struct timing_generator *optc;
2227
2228 ASSERT(wb_info->dwb_pipe_inst < MAX_DWB_PIPES);
2229 ASSERT(wb_info->wb_enabled);
2230 dwb = dc->res_pool->dwbc[wb_info->dwb_pipe_inst];
2231 mcif_wb = dc->res_pool->mcif_wb[wb_info->dwb_pipe_inst];
2232
2233 /* set the OPTC source mux */
2234 optc = dc->res_pool->timing_generators[dwb->otg_inst];
2235 optc->funcs->set_dwb_source(optc, wb_info->dwb_pipe_inst);
2236 /* set MCIF_WB buffer and arbitration configuration */
2237 mcif_wb->funcs->config_mcif_buf(mcif_wb, &wb_info->mcif_buf_params, wb_info->dwb_params.dest_height);
2238 mcif_wb->funcs->config_mcif_arb(mcif_wb, &context->bw_ctx.bw.dcn.bw_writeback.mcif_wb_arb[wb_info->dwb_pipe_inst]);
2239 /* Enable MCIF_WB */
2240 mcif_wb->funcs->enable_mcif(mcif_wb);
2241 /* Enable DWB */
2242 dwb->funcs->enable(dwb, &wb_info->dwb_params);
2243 /* TODO: add sequence to enable/disable warmup */
2244 }
2245
dcn20_disable_writeback(struct dc * dc,unsigned int dwb_pipe_inst)2246 void dcn20_disable_writeback(
2247 struct dc *dc,
2248 unsigned int dwb_pipe_inst)
2249 {
2250 struct dwbc *dwb;
2251 struct mcif_wb *mcif_wb;
2252
2253 ASSERT(dwb_pipe_inst < MAX_DWB_PIPES);
2254 dwb = dc->res_pool->dwbc[dwb_pipe_inst];
2255 mcif_wb = dc->res_pool->mcif_wb[dwb_pipe_inst];
2256
2257 dwb->funcs->disable(dwb);
2258 mcif_wb->funcs->disable_mcif(mcif_wb);
2259 }
2260
dcn20_wait_for_blank_complete(struct output_pixel_processor * opp)2261 bool dcn20_wait_for_blank_complete(
2262 struct output_pixel_processor *opp)
2263 {
2264 int counter;
2265
2266 for (counter = 0; counter < 1000; counter++) {
2267 if (opp->funcs->dpg_is_blanked(opp))
2268 break;
2269
2270 udelay(100);
2271 }
2272
2273 if (counter == 1000) {
2274 dm_error("DC: failed to blank crtc!\n");
2275 return false;
2276 }
2277
2278 return true;
2279 }
2280
dcn20_dmdata_status_done(struct pipe_ctx * pipe_ctx)2281 bool dcn20_dmdata_status_done(struct pipe_ctx *pipe_ctx)
2282 {
2283 struct hubp *hubp = pipe_ctx->plane_res.hubp;
2284
2285 if (!hubp)
2286 return false;
2287 return hubp->funcs->dmdata_status_done(hubp);
2288 }
2289
dcn20_disable_stream_gating(struct dc * dc,struct pipe_ctx * pipe_ctx)2290 void dcn20_disable_stream_gating(struct dc *dc, struct pipe_ctx *pipe_ctx)
2291 {
2292 struct dce_hwseq *hws = dc->hwseq;
2293
2294 if (pipe_ctx->stream_res.dsc) {
2295 struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
2296
2297 hws->funcs.dsc_pg_control(hws, pipe_ctx->stream_res.dsc->inst, true);
2298 while (odm_pipe) {
2299 hws->funcs.dsc_pg_control(hws, odm_pipe->stream_res.dsc->inst, true);
2300 odm_pipe = odm_pipe->next_odm_pipe;
2301 }
2302 }
2303 }
2304
dcn20_enable_stream_gating(struct dc * dc,struct pipe_ctx * pipe_ctx)2305 void dcn20_enable_stream_gating(struct dc *dc, struct pipe_ctx *pipe_ctx)
2306 {
2307 struct dce_hwseq *hws = dc->hwseq;
2308
2309 if (pipe_ctx->stream_res.dsc) {
2310 struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
2311
2312 hws->funcs.dsc_pg_control(hws, pipe_ctx->stream_res.dsc->inst, false);
2313 while (odm_pipe) {
2314 hws->funcs.dsc_pg_control(hws, odm_pipe->stream_res.dsc->inst, false);
2315 odm_pipe = odm_pipe->next_odm_pipe;
2316 }
2317 }
2318 }
2319
dcn20_set_dmdata_attributes(struct pipe_ctx * pipe_ctx)2320 void dcn20_set_dmdata_attributes(struct pipe_ctx *pipe_ctx)
2321 {
2322 struct dc_dmdata_attributes attr = { 0 };
2323 struct hubp *hubp = pipe_ctx->plane_res.hubp;
2324
2325 attr.dmdata_mode = DMDATA_HW_MODE;
2326 attr.dmdata_size =
2327 dc_is_hdmi_signal(pipe_ctx->stream->signal) ? 32 : 36;
2328 attr.address.quad_part =
2329 pipe_ctx->stream->dmdata_address.quad_part;
2330 attr.dmdata_dl_delta = 0;
2331 attr.dmdata_qos_mode = 0;
2332 attr.dmdata_qos_level = 0;
2333 attr.dmdata_repeat = 1; /* always repeat */
2334 attr.dmdata_updated = 1;
2335 attr.dmdata_sw_data = NULL;
2336
2337 hubp->funcs->dmdata_set_attributes(hubp, &attr);
2338 }
2339
dcn20_init_vm_ctx(struct dce_hwseq * hws,struct dc * dc,struct dc_virtual_addr_space_config * va_config,int vmid)2340 void dcn20_init_vm_ctx(
2341 struct dce_hwseq *hws,
2342 struct dc *dc,
2343 struct dc_virtual_addr_space_config *va_config,
2344 int vmid)
2345 {
2346 struct dcn_hubbub_virt_addr_config config;
2347
2348 if (vmid == 0) {
2349 ASSERT(0); /* VMID cannot be 0 for vm context */
2350 return;
2351 }
2352
2353 config.page_table_start_addr = va_config->page_table_start_addr;
2354 config.page_table_end_addr = va_config->page_table_end_addr;
2355 config.page_table_block_size = va_config->page_table_block_size_in_bytes;
2356 config.page_table_depth = va_config->page_table_depth;
2357 config.page_table_base_addr = va_config->page_table_base_addr;
2358
2359 dc->res_pool->hubbub->funcs->init_vm_ctx(dc->res_pool->hubbub, &config, vmid);
2360 }
2361
dcn20_init_sys_ctx(struct dce_hwseq * hws,struct dc * dc,struct dc_phy_addr_space_config * pa_config)2362 int dcn20_init_sys_ctx(struct dce_hwseq *hws, struct dc *dc, struct dc_phy_addr_space_config *pa_config)
2363 {
2364 struct dcn_hubbub_phys_addr_config config;
2365
2366 config.system_aperture.fb_top = pa_config->system_aperture.fb_top;
2367 config.system_aperture.fb_offset = pa_config->system_aperture.fb_offset;
2368 config.system_aperture.fb_base = pa_config->system_aperture.fb_base;
2369 config.system_aperture.agp_top = pa_config->system_aperture.agp_top;
2370 config.system_aperture.agp_bot = pa_config->system_aperture.agp_bot;
2371 config.system_aperture.agp_base = pa_config->system_aperture.agp_base;
2372 config.gart_config.page_table_start_addr = pa_config->gart_config.page_table_start_addr;
2373 config.gart_config.page_table_end_addr = pa_config->gart_config.page_table_end_addr;
2374 config.gart_config.page_table_base_addr = pa_config->gart_config.page_table_base_addr;
2375 config.page_table_default_page_addr = pa_config->page_table_default_page_addr;
2376
2377 return dc->res_pool->hubbub->funcs->init_dchub_sys_ctx(dc->res_pool->hubbub, &config);
2378 }
2379
patch_address_for_sbs_tb_stereo(struct pipe_ctx * pipe_ctx,PHYSICAL_ADDRESS_LOC * addr)2380 static bool patch_address_for_sbs_tb_stereo(
2381 struct pipe_ctx *pipe_ctx, PHYSICAL_ADDRESS_LOC *addr)
2382 {
2383 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2384 bool sec_split = pipe_ctx->top_pipe &&
2385 pipe_ctx->top_pipe->plane_state == pipe_ctx->plane_state;
2386 if (sec_split && plane_state->address.type == PLN_ADDR_TYPE_GRPH_STEREO &&
2387 (pipe_ctx->stream->timing.timing_3d_format ==
2388 TIMING_3D_FORMAT_SIDE_BY_SIDE ||
2389 pipe_ctx->stream->timing.timing_3d_format ==
2390 TIMING_3D_FORMAT_TOP_AND_BOTTOM)) {
2391 *addr = plane_state->address.grph_stereo.left_addr;
2392 plane_state->address.grph_stereo.left_addr =
2393 plane_state->address.grph_stereo.right_addr;
2394 return true;
2395 }
2396
2397 if (pipe_ctx->stream->view_format != VIEW_3D_FORMAT_NONE &&
2398 plane_state->address.type != PLN_ADDR_TYPE_GRPH_STEREO) {
2399 plane_state->address.type = PLN_ADDR_TYPE_GRPH_STEREO;
2400 plane_state->address.grph_stereo.right_addr =
2401 plane_state->address.grph_stereo.left_addr;
2402 plane_state->address.grph_stereo.right_meta_addr =
2403 plane_state->address.grph_stereo.left_meta_addr;
2404 }
2405 return false;
2406 }
2407
dcn20_update_plane_addr(const struct dc * dc,struct pipe_ctx * pipe_ctx)2408 void dcn20_update_plane_addr(const struct dc *dc, struct pipe_ctx *pipe_ctx)
2409 {
2410 bool addr_patched = false;
2411 PHYSICAL_ADDRESS_LOC addr;
2412 struct dc_plane_state *plane_state = pipe_ctx->plane_state;
2413
2414 if (plane_state == NULL)
2415 return;
2416
2417 addr_patched = patch_address_for_sbs_tb_stereo(pipe_ctx, &addr);
2418
2419 // Call Helper to track VMID use
2420 vm_helper_mark_vmid_used(dc->vm_helper, plane_state->address.vmid, pipe_ctx->plane_res.hubp->inst);
2421
2422 pipe_ctx->plane_res.hubp->funcs->hubp_program_surface_flip_and_addr(
2423 pipe_ctx->plane_res.hubp,
2424 &plane_state->address,
2425 plane_state->flip_immediate);
2426
2427 plane_state->status.requested_address = plane_state->address;
2428
2429 if (plane_state->flip_immediate)
2430 plane_state->status.current_address = plane_state->address;
2431
2432 if (addr_patched)
2433 pipe_ctx->plane_state->address.grph_stereo.left_addr = addr;
2434 }
2435
dcn20_unblank_stream(struct pipe_ctx * pipe_ctx,struct dc_link_settings * link_settings)2436 void dcn20_unblank_stream(struct pipe_ctx *pipe_ctx,
2437 struct dc_link_settings *link_settings)
2438 {
2439 struct encoder_unblank_param params = {0};
2440 struct dc_stream_state *stream = pipe_ctx->stream;
2441 struct dc_link *link = stream->link;
2442 struct dce_hwseq *hws = link->dc->hwseq;
2443 struct pipe_ctx *odm_pipe;
2444
2445 params.opp_cnt = 1;
2446 for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) {
2447 params.opp_cnt++;
2448 }
2449 /* only 3 items below are used by unblank */
2450 params.timing = pipe_ctx->stream->timing;
2451
2452 params.link_settings.link_rate = link_settings->link_rate;
2453
2454 if (link->dc->link_srv->dp_is_128b_132b_signal(pipe_ctx)) {
2455 /* TODO - DP2.0 HW: Set ODM mode in dp hpo encoder here */
2456 pipe_ctx->stream_res.hpo_dp_stream_enc->funcs->dp_unblank(
2457 pipe_ctx->stream_res.hpo_dp_stream_enc,
2458 pipe_ctx->stream_res.tg->inst);
2459 } else if (dc_is_dp_signal(pipe_ctx->stream->signal)) {
2460 if (optc2_is_two_pixels_per_containter(&stream->timing) || params.opp_cnt > 1)
2461 params.timing.pix_clk_100hz /= 2;
2462 pipe_ctx->stream_res.stream_enc->funcs->dp_set_odm_combine(
2463 pipe_ctx->stream_res.stream_enc, params.opp_cnt > 1);
2464 pipe_ctx->stream_res.stream_enc->funcs->dp_unblank(link, pipe_ctx->stream_res.stream_enc, ¶ms);
2465 }
2466
2467 if (link->local_sink && link->local_sink->sink_signal == SIGNAL_TYPE_EDP) {
2468 hws->funcs.edp_backlight_control(link, true);
2469 }
2470 }
2471
dcn20_setup_vupdate_interrupt(struct dc * dc,struct pipe_ctx * pipe_ctx)2472 void dcn20_setup_vupdate_interrupt(struct dc *dc, struct pipe_ctx *pipe_ctx)
2473 {
2474 struct timing_generator *tg = pipe_ctx->stream_res.tg;
2475 int start_line = dc->hwss.get_vupdate_offset_from_vsync(pipe_ctx);
2476
2477 if (start_line < 0)
2478 start_line = 0;
2479
2480 if (tg->funcs->setup_vertical_interrupt2)
2481 tg->funcs->setup_vertical_interrupt2(tg, start_line);
2482 }
2483
dcn20_reset_back_end_for_pipe(struct dc * dc,struct pipe_ctx * pipe_ctx,struct dc_state * context)2484 static void dcn20_reset_back_end_for_pipe(
2485 struct dc *dc,
2486 struct pipe_ctx *pipe_ctx,
2487 struct dc_state *context)
2488 {
2489 int i;
2490 struct dc_link *link = pipe_ctx->stream->link;
2491 const struct link_hwss *link_hwss = get_link_hwss(link, &pipe_ctx->link_res);
2492
2493 DC_LOGGER_INIT(dc->ctx->logger);
2494 if (pipe_ctx->stream_res.stream_enc == NULL) {
2495 pipe_ctx->stream = NULL;
2496 return;
2497 }
2498
2499 /* DPMS may already disable or */
2500 /* dpms_off status is incorrect due to fastboot
2501 * feature. When system resume from S4 with second
2502 * screen only, the dpms_off would be true but
2503 * VBIOS lit up eDP, so check link status too.
2504 */
2505 if (!pipe_ctx->stream->dpms_off || link->link_status.link_active)
2506 dc->link_srv->set_dpms_off(pipe_ctx);
2507 else if (pipe_ctx->stream_res.audio)
2508 dc->hwss.disable_audio_stream(pipe_ctx);
2509
2510 /* free acquired resources */
2511 if (pipe_ctx->stream_res.audio) {
2512 /*disable az_endpoint*/
2513 pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
2514
2515 /*free audio*/
2516 if (dc->caps.dynamic_audio == true) {
2517 /*we have to dynamic arbitrate the audio endpoints*/
2518 /*we free the resource, need reset is_audio_acquired*/
2519 update_audio_usage(&dc->current_state->res_ctx, dc->res_pool,
2520 pipe_ctx->stream_res.audio, false);
2521 pipe_ctx->stream_res.audio = NULL;
2522 }
2523 }
2524
2525 /* by upper caller loop, parent pipe: pipe0, will be reset last.
2526 * back end share by all pipes and will be disable only when disable
2527 * parent pipe.
2528 */
2529 if (pipe_ctx->top_pipe == NULL) {
2530
2531 dc->hwss.set_abm_immediate_disable(pipe_ctx);
2532
2533 pipe_ctx->stream_res.tg->funcs->disable_crtc(pipe_ctx->stream_res.tg);
2534
2535 pipe_ctx->stream_res.tg->funcs->enable_optc_clock(pipe_ctx->stream_res.tg, false);
2536 if (pipe_ctx->stream_res.tg->funcs->set_odm_bypass)
2537 pipe_ctx->stream_res.tg->funcs->set_odm_bypass(
2538 pipe_ctx->stream_res.tg, &pipe_ctx->stream->timing);
2539
2540 if (pipe_ctx->stream_res.tg->funcs->set_drr)
2541 pipe_ctx->stream_res.tg->funcs->set_drr(
2542 pipe_ctx->stream_res.tg, NULL);
2543 /* TODO - convert symclk_ref_cnts for otg to a bit map to solve
2544 * the case where the same symclk is shared across multiple otg
2545 * instances
2546 */
2547 if (dc_is_hdmi_tmds_signal(pipe_ctx->stream->signal))
2548 link->phy_state.symclk_ref_cnts.otg = 0;
2549 if (link->phy_state.symclk_state == SYMCLK_ON_TX_OFF) {
2550 link_hwss->disable_link_output(link,
2551 &pipe_ctx->link_res, pipe_ctx->stream->signal);
2552 link->phy_state.symclk_state = SYMCLK_OFF_TX_OFF;
2553 }
2554 }
2555
2556 for (i = 0; i < dc->res_pool->pipe_count; i++)
2557 if (&dc->current_state->res_ctx.pipe_ctx[i] == pipe_ctx)
2558 break;
2559
2560 if (i == dc->res_pool->pipe_count)
2561 return;
2562
2563 pipe_ctx->stream = NULL;
2564 DC_LOG_DEBUG("Reset back end for pipe %d, tg:%d\n",
2565 pipe_ctx->pipe_idx, pipe_ctx->stream_res.tg->inst);
2566 }
2567
dcn20_reset_hw_ctx_wrap(struct dc * dc,struct dc_state * context)2568 void dcn20_reset_hw_ctx_wrap(
2569 struct dc *dc,
2570 struct dc_state *context)
2571 {
2572 int i;
2573 struct dce_hwseq *hws = dc->hwseq;
2574
2575 /* Reset Back End*/
2576 for (i = dc->res_pool->pipe_count - 1; i >= 0 ; i--) {
2577 struct pipe_ctx *pipe_ctx_old =
2578 &dc->current_state->res_ctx.pipe_ctx[i];
2579 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2580
2581 if (!pipe_ctx_old->stream)
2582 continue;
2583
2584 if (pipe_ctx_old->top_pipe || pipe_ctx_old->prev_odm_pipe)
2585 continue;
2586
2587 if (!pipe_ctx->stream ||
2588 pipe_need_reprogram(pipe_ctx_old, pipe_ctx)) {
2589 struct clock_source *old_clk = pipe_ctx_old->clock_source;
2590
2591 dcn20_reset_back_end_for_pipe(dc, pipe_ctx_old, dc->current_state);
2592 if (hws->funcs.enable_stream_gating)
2593 hws->funcs.enable_stream_gating(dc, pipe_ctx_old);
2594 if (old_clk)
2595 old_clk->funcs->cs_power_down(old_clk);
2596 }
2597 }
2598 }
2599
dcn20_update_mpcc(struct dc * dc,struct pipe_ctx * pipe_ctx)2600 void dcn20_update_mpcc(struct dc *dc, struct pipe_ctx *pipe_ctx)
2601 {
2602 struct hubp *hubp = pipe_ctx->plane_res.hubp;
2603 struct mpcc_blnd_cfg blnd_cfg = {0};
2604 bool per_pixel_alpha = pipe_ctx->plane_state->per_pixel_alpha;
2605 int mpcc_id;
2606 struct mpcc *new_mpcc;
2607 struct mpc *mpc = dc->res_pool->mpc;
2608 struct mpc_tree *mpc_tree_params = &(pipe_ctx->stream_res.opp->mpc_tree_params);
2609
2610 blnd_cfg.overlap_only = false;
2611 blnd_cfg.global_gain = 0xff;
2612
2613 if (per_pixel_alpha) {
2614 blnd_cfg.pre_multiplied_alpha = pipe_ctx->plane_state->pre_multiplied_alpha;
2615 if (pipe_ctx->plane_state->global_alpha) {
2616 blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA_COMBINED_GLOBAL_GAIN;
2617 blnd_cfg.global_gain = pipe_ctx->plane_state->global_alpha_value;
2618 } else {
2619 blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_PER_PIXEL_ALPHA;
2620 }
2621 } else {
2622 blnd_cfg.pre_multiplied_alpha = false;
2623 blnd_cfg.alpha_mode = MPCC_ALPHA_BLEND_MODE_GLOBAL_ALPHA;
2624 }
2625
2626 if (pipe_ctx->plane_state->global_alpha)
2627 blnd_cfg.global_alpha = pipe_ctx->plane_state->global_alpha_value;
2628 else
2629 blnd_cfg.global_alpha = 0xff;
2630
2631 blnd_cfg.background_color_bpc = 4;
2632 blnd_cfg.bottom_gain_mode = 0;
2633 blnd_cfg.top_gain = 0x1f000;
2634 blnd_cfg.bottom_inside_gain = 0x1f000;
2635 blnd_cfg.bottom_outside_gain = 0x1f000;
2636
2637 if (pipe_ctx->plane_state->format
2638 == SURFACE_PIXEL_FORMAT_GRPH_RGBE_ALPHA)
2639 blnd_cfg.pre_multiplied_alpha = false;
2640
2641 /*
2642 * TODO: remove hack
2643 * Note: currently there is a bug in init_hw such that
2644 * on resume from hibernate, BIOS sets up MPCC0, and
2645 * we do mpcc_remove but the mpcc cannot go to idle
2646 * after remove. This cause us to pick mpcc1 here,
2647 * which causes a pstate hang for yet unknown reason.
2648 */
2649 mpcc_id = hubp->inst;
2650
2651 /* If there is no full update, don't need to touch MPC tree*/
2652 if (!pipe_ctx->plane_state->update_flags.bits.full_update &&
2653 !pipe_ctx->update_flags.bits.mpcc) {
2654 mpc->funcs->update_blending(mpc, &blnd_cfg, mpcc_id);
2655 dc->hwss.update_visual_confirm_color(dc, pipe_ctx, mpcc_id);
2656 return;
2657 }
2658
2659 /* check if this MPCC is already being used */
2660 new_mpcc = mpc->funcs->get_mpcc_for_dpp(mpc_tree_params, mpcc_id);
2661 /* remove MPCC if being used */
2662 if (new_mpcc != NULL)
2663 mpc->funcs->remove_mpcc(mpc, mpc_tree_params, new_mpcc);
2664 else
2665 if (dc->debug.sanity_checks)
2666 mpc->funcs->assert_mpcc_idle_before_connect(
2667 dc->res_pool->mpc, mpcc_id);
2668
2669 /* Call MPC to insert new plane */
2670 new_mpcc = mpc->funcs->insert_plane(dc->res_pool->mpc,
2671 mpc_tree_params,
2672 &blnd_cfg,
2673 NULL,
2674 NULL,
2675 hubp->inst,
2676 mpcc_id);
2677 dc->hwss.update_visual_confirm_color(dc, pipe_ctx, mpcc_id);
2678
2679 ASSERT(new_mpcc != NULL);
2680 hubp->opp_id = pipe_ctx->stream_res.opp->inst;
2681 hubp->mpcc_id = mpcc_id;
2682 }
2683
get_phyd32clk_src(struct dc_link * link)2684 static enum phyd32clk_clock_source get_phyd32clk_src(struct dc_link *link)
2685 {
2686 switch (link->link_enc->transmitter) {
2687 case TRANSMITTER_UNIPHY_A:
2688 return PHYD32CLKA;
2689 case TRANSMITTER_UNIPHY_B:
2690 return PHYD32CLKB;
2691 case TRANSMITTER_UNIPHY_C:
2692 return PHYD32CLKC;
2693 case TRANSMITTER_UNIPHY_D:
2694 return PHYD32CLKD;
2695 case TRANSMITTER_UNIPHY_E:
2696 return PHYD32CLKE;
2697 default:
2698 return PHYD32CLKA;
2699 }
2700 }
2701
get_odm_segment_count(struct pipe_ctx * pipe_ctx)2702 static int get_odm_segment_count(struct pipe_ctx *pipe_ctx)
2703 {
2704 struct pipe_ctx *odm_pipe = pipe_ctx->next_odm_pipe;
2705 int count = 1;
2706
2707 while (odm_pipe != NULL) {
2708 count++;
2709 odm_pipe = odm_pipe->next_odm_pipe;
2710 }
2711
2712 return count;
2713 }
2714
dcn20_enable_stream(struct pipe_ctx * pipe_ctx)2715 void dcn20_enable_stream(struct pipe_ctx *pipe_ctx)
2716 {
2717 enum dc_lane_count lane_count =
2718 pipe_ctx->stream->link->cur_link_settings.lane_count;
2719
2720 struct dc_crtc_timing *timing = &pipe_ctx->stream->timing;
2721 struct dc_link *link = pipe_ctx->stream->link;
2722
2723 uint32_t active_total_with_borders;
2724 uint32_t early_control = 0;
2725 struct timing_generator *tg = pipe_ctx->stream_res.tg;
2726 const struct link_hwss *link_hwss = get_link_hwss(link, &pipe_ctx->link_res);
2727 struct dc *dc = pipe_ctx->stream->ctx->dc;
2728 struct dtbclk_dto_params dto_params = {0};
2729 struct dccg *dccg = dc->res_pool->dccg;
2730 enum phyd32clk_clock_source phyd32clk;
2731 int dp_hpo_inst;
2732 struct dce_hwseq *hws = dc->hwseq;
2733 unsigned int k1_div = PIXEL_RATE_DIV_NA;
2734 unsigned int k2_div = PIXEL_RATE_DIV_NA;
2735
2736 if (dc->link_srv->dp_is_128b_132b_signal(pipe_ctx)) {
2737 if (dc->hwseq->funcs.setup_hpo_hw_control)
2738 dc->hwseq->funcs.setup_hpo_hw_control(dc->hwseq, true);
2739 }
2740
2741 if (dc->link_srv->dp_is_128b_132b_signal(pipe_ctx)) {
2742 dto_params.otg_inst = tg->inst;
2743 dto_params.pixclk_khz = pipe_ctx->stream->timing.pix_clk_100hz / 10;
2744 dto_params.num_odm_segments = get_odm_segment_count(pipe_ctx);
2745 dto_params.timing = &pipe_ctx->stream->timing;
2746 dto_params.ref_dtbclk_khz = dc->clk_mgr->funcs->get_dtb_ref_clk_frequency(dc->clk_mgr);
2747 dccg->funcs->set_dtbclk_dto(dccg, &dto_params);
2748 dp_hpo_inst = pipe_ctx->stream_res.hpo_dp_stream_enc->inst;
2749 dccg->funcs->set_dpstreamclk(dccg, DTBCLK0, tg->inst, dp_hpo_inst);
2750
2751 phyd32clk = get_phyd32clk_src(link);
2752 dccg->funcs->enable_symclk32_se(dccg, dp_hpo_inst, phyd32clk);
2753 } else {
2754 }
2755 if (hws->funcs.calculate_dccg_k1_k2_values && dc->res_pool->dccg->funcs->set_pixel_rate_div) {
2756 hws->funcs.calculate_dccg_k1_k2_values(pipe_ctx, &k1_div, &k2_div);
2757
2758 dc->res_pool->dccg->funcs->set_pixel_rate_div(
2759 dc->res_pool->dccg,
2760 pipe_ctx->stream_res.tg->inst,
2761 k1_div, k2_div);
2762 }
2763
2764 link_hwss->setup_stream_encoder(pipe_ctx);
2765
2766 if (pipe_ctx->plane_state && pipe_ctx->plane_state->flip_immediate != 1) {
2767 if (dc->hwss.program_dmdata_engine)
2768 dc->hwss.program_dmdata_engine(pipe_ctx);
2769 }
2770
2771 dc->hwss.update_info_frame(pipe_ctx);
2772
2773 if (dc_is_dp_signal(pipe_ctx->stream->signal))
2774 dc->link_srv->dp_trace_source_sequence(link, DPCD_SOURCE_SEQ_AFTER_UPDATE_INFO_FRAME);
2775
2776 /* enable early control to avoid corruption on DP monitor*/
2777 active_total_with_borders =
2778 timing->h_addressable
2779 + timing->h_border_left
2780 + timing->h_border_right;
2781
2782 if (lane_count != 0)
2783 early_control = active_total_with_borders % lane_count;
2784
2785 if (early_control == 0)
2786 early_control = lane_count;
2787
2788 tg->funcs->set_early_control(tg, early_control);
2789
2790 if (dc->hwseq->funcs.set_pixels_per_cycle)
2791 dc->hwseq->funcs.set_pixels_per_cycle(pipe_ctx);
2792 }
2793
dcn20_program_dmdata_engine(struct pipe_ctx * pipe_ctx)2794 void dcn20_program_dmdata_engine(struct pipe_ctx *pipe_ctx)
2795 {
2796 struct dc_stream_state *stream = pipe_ctx->stream;
2797 struct hubp *hubp = pipe_ctx->plane_res.hubp;
2798 bool enable = false;
2799 struct stream_encoder *stream_enc = pipe_ctx->stream_res.stream_enc;
2800 enum dynamic_metadata_mode mode = dc_is_dp_signal(stream->signal)
2801 ? dmdata_dp
2802 : dmdata_hdmi;
2803
2804 /* if using dynamic meta, don't set up generic infopackets */
2805 if (pipe_ctx->stream->dmdata_address.quad_part != 0) {
2806 pipe_ctx->stream_res.encoder_info_frame.hdrsmd.valid = false;
2807 enable = true;
2808 }
2809
2810 if (!hubp)
2811 return;
2812
2813 if (!stream_enc || !stream_enc->funcs->set_dynamic_metadata)
2814 return;
2815
2816 stream_enc->funcs->set_dynamic_metadata(stream_enc, enable,
2817 hubp->inst, mode);
2818 }
2819
dcn20_fpga_init_hw(struct dc * dc)2820 void dcn20_fpga_init_hw(struct dc *dc)
2821 {
2822 int i, j;
2823 struct dce_hwseq *hws = dc->hwseq;
2824 struct resource_pool *res_pool = dc->res_pool;
2825 struct dc_state *context = dc->current_state;
2826
2827 if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks)
2828 dc->clk_mgr->funcs->init_clocks(dc->clk_mgr);
2829
2830 // Initialize the dccg
2831 if (res_pool->dccg->funcs->dccg_init)
2832 res_pool->dccg->funcs->dccg_init(res_pool->dccg);
2833
2834 //Enable ability to power gate / don't force power on permanently
2835 hws->funcs.enable_power_gating_plane(hws, true);
2836
2837 // Specific to FPGA dccg and registers
2838 REG_WRITE(RBBMIF_TIMEOUT_DIS, 0xFFFFFFFF);
2839 REG_WRITE(RBBMIF_TIMEOUT_DIS_2, 0xFFFFFFFF);
2840
2841 hws->funcs.dccg_init(hws);
2842
2843 REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, 2);
2844 REG_UPDATE(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_ENABLE, 1);
2845 if (REG(REFCLK_CNTL))
2846 REG_WRITE(REFCLK_CNTL, 0);
2847 //
2848
2849
2850 /* Blank pixel data with OPP DPG */
2851 for (i = 0; i < dc->res_pool->timing_generator_count; i++) {
2852 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2853
2854 if (tg->funcs->is_tg_enabled(tg))
2855 dcn20_init_blank(dc, tg);
2856 }
2857
2858 for (i = 0; i < res_pool->timing_generator_count; i++) {
2859 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2860
2861 if (tg->funcs->is_tg_enabled(tg))
2862 tg->funcs->lock(tg);
2863 }
2864
2865 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2866 struct dpp *dpp = res_pool->dpps[i];
2867
2868 dpp->funcs->dpp_reset(dpp);
2869 }
2870
2871 /* Reset all MPCC muxes */
2872 res_pool->mpc->funcs->mpc_init(res_pool->mpc);
2873
2874 /* initialize OPP mpc_tree parameter */
2875 for (i = 0; i < dc->res_pool->res_cap->num_opp; i++) {
2876 res_pool->opps[i]->mpc_tree_params.opp_id = res_pool->opps[i]->inst;
2877 res_pool->opps[i]->mpc_tree_params.opp_list = NULL;
2878 for (j = 0; j < MAX_PIPES; j++)
2879 res_pool->opps[i]->mpcc_disconnect_pending[j] = false;
2880 }
2881
2882 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2883 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2884 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2885 struct hubp *hubp = dc->res_pool->hubps[i];
2886 struct dpp *dpp = dc->res_pool->dpps[i];
2887
2888 pipe_ctx->stream_res.tg = tg;
2889 pipe_ctx->pipe_idx = i;
2890
2891 pipe_ctx->plane_res.hubp = hubp;
2892 pipe_ctx->plane_res.dpp = dpp;
2893 pipe_ctx->plane_res.mpcc_inst = dpp->inst;
2894 hubp->mpcc_id = dpp->inst;
2895 hubp->opp_id = OPP_ID_INVALID;
2896 hubp->power_gated = false;
2897 pipe_ctx->stream_res.opp = NULL;
2898
2899 hubp->funcs->hubp_init(hubp);
2900
2901 //dc->res_pool->opps[i]->mpc_tree_params.opp_id = dc->res_pool->opps[i]->inst;
2902 //dc->res_pool->opps[i]->mpc_tree_params.opp_list = NULL;
2903 dc->res_pool->opps[i]->mpcc_disconnect_pending[pipe_ctx->plane_res.mpcc_inst] = true;
2904 pipe_ctx->stream_res.opp = dc->res_pool->opps[i];
2905 /*to do*/
2906 hws->funcs.plane_atomic_disconnect(dc, pipe_ctx);
2907 }
2908
2909 /* initialize DWB pointer to MCIF_WB */
2910 for (i = 0; i < res_pool->res_cap->num_dwb; i++)
2911 res_pool->dwbc[i]->mcif = res_pool->mcif_wb[i];
2912
2913 for (i = 0; i < dc->res_pool->timing_generator_count; i++) {
2914 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2915
2916 if (tg->funcs->is_tg_enabled(tg))
2917 tg->funcs->unlock(tg);
2918 }
2919
2920 for (i = 0; i < dc->res_pool->pipe_count; i++) {
2921 struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i];
2922
2923 dc->hwss.disable_plane(dc, pipe_ctx);
2924
2925 pipe_ctx->stream_res.tg = NULL;
2926 pipe_ctx->plane_res.hubp = NULL;
2927 }
2928
2929 for (i = 0; i < dc->res_pool->timing_generator_count; i++) {
2930 struct timing_generator *tg = dc->res_pool->timing_generators[i];
2931
2932 tg->funcs->tg_init(tg);
2933 }
2934
2935 if (dc->res_pool->hubbub->funcs->init_crb)
2936 dc->res_pool->hubbub->funcs->init_crb(dc->res_pool->hubbub);
2937 }
2938 #ifndef TRIM_FSFT
dcn20_optimize_timing_for_fsft(struct dc * dc,struct dc_crtc_timing * timing,unsigned int max_input_rate_in_khz)2939 bool dcn20_optimize_timing_for_fsft(struct dc *dc,
2940 struct dc_crtc_timing *timing,
2941 unsigned int max_input_rate_in_khz)
2942 {
2943 unsigned int old_v_front_porch;
2944 unsigned int old_v_total;
2945 unsigned int max_input_rate_in_100hz;
2946 unsigned long long new_v_total;
2947
2948 max_input_rate_in_100hz = max_input_rate_in_khz * 10;
2949 if (max_input_rate_in_100hz < timing->pix_clk_100hz)
2950 return false;
2951
2952 old_v_total = timing->v_total;
2953 old_v_front_porch = timing->v_front_porch;
2954
2955 timing->fast_transport_output_rate_100hz = timing->pix_clk_100hz;
2956 timing->pix_clk_100hz = max_input_rate_in_100hz;
2957
2958 new_v_total = div_u64((unsigned long long)old_v_total * max_input_rate_in_100hz, timing->pix_clk_100hz);
2959
2960 timing->v_total = new_v_total;
2961 timing->v_front_porch = old_v_front_porch + (timing->v_total - old_v_total);
2962 return true;
2963 }
2964 #endif
2965
dcn20_set_disp_pattern_generator(const struct dc * dc,struct pipe_ctx * pipe_ctx,enum controller_dp_test_pattern test_pattern,enum controller_dp_color_space color_space,enum dc_color_depth color_depth,const struct tg_color * solid_color,int width,int height,int offset)2966 void dcn20_set_disp_pattern_generator(const struct dc *dc,
2967 struct pipe_ctx *pipe_ctx,
2968 enum controller_dp_test_pattern test_pattern,
2969 enum controller_dp_color_space color_space,
2970 enum dc_color_depth color_depth,
2971 const struct tg_color *solid_color,
2972 int width, int height, int offset)
2973 {
2974 pipe_ctx->stream_res.opp->funcs->opp_set_disp_pattern_generator(pipe_ctx->stream_res.opp, test_pattern,
2975 color_space, color_depth, solid_color, width, height, offset);
2976 }
2977