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