Commit | Line | Data |
---|---|---|
7ed4e635 HW |
1 | /* |
2 | * Copyright 2016 Advanced Micro Devices, Inc. | |
6ca3928d | 3 | * Copyright 2019 Raptor Engineering, LLC |
7ed4e635 HW |
4 | * |
5 | * Permission is hereby granted, free of charge, to any person obtaining a | |
6 | * copy of this software and associated documentation files (the "Software"), | |
7 | * to deal in the Software without restriction, including without limitation | |
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
9 | * and/or sell copies of the Software, and to permit persons to whom the | |
10 | * Software is furnished to do so, subject to the following conditions: | |
11 | * | |
12 | * The above copyright notice and this permission notice shall be included in | |
13 | * all copies or substantial portions of the Software. | |
14 | * | |
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR | |
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | |
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |
21 | * OTHER DEALINGS IN THE SOFTWARE. | |
22 | * | |
23 | * Authors: AMD | |
24 | * | |
25 | */ | |
26 | ||
27 | #include "dm_services.h" | |
28 | #include "dc.h" | |
29 | ||
8b8eed05 | 30 | #include "dcn20/dcn20_init.h" |
78c77382 | 31 | |
7ed4e635 HW |
32 | #include "resource.h" |
33 | #include "include/irq_service_interface.h" | |
34 | #include "dcn20/dcn20_resource.h" | |
35 | ||
ee373411 | 36 | #include "dml/dcn20/dcn20_fpu.h" |
c8b3538d | 37 | |
7ed4e635 HW |
38 | #include "dcn10/dcn10_hubp.h" |
39 | #include "dcn10/dcn10_ipp.h" | |
8b8eed05 MA |
40 | #include "dcn20/dcn20_hubbub.h" |
41 | #include "dcn20/dcn20_mpc.h" | |
42 | #include "dcn20/dcn20_hubp.h" | |
7ed4e635 | 43 | #include "irq/dcn20/irq_service_dcn20.h" |
8b8eed05 MA |
44 | #include "dcn20/dcn20_dpp.h" |
45 | #include "dcn20/dcn20_optc.h" | |
e53524cd MA |
46 | #include "dcn20/dcn20_hwseq.h" |
47 | #include "dce110/dce110_hwseq.h" | |
278141f5 | 48 | #include "dcn10/dcn10_resource.h" |
8b8eed05 | 49 | #include "dcn20/dcn20_opp.h" |
7ed4e635 | 50 | |
8b8eed05 | 51 | #include "dcn20/dcn20_dsc.h" |
97bda032 | 52 | |
8b8eed05 MA |
53 | #include "dcn20/dcn20_link_encoder.h" |
54 | #include "dcn20/dcn20_stream_encoder.h" | |
7ed4e635 HW |
55 | #include "dce/dce_clock_source.h" |
56 | #include "dce/dce_audio.h" | |
57 | #include "dce/dce_hwseq.h" | |
58 | #include "virtual/virtual_stream_encoder.h" | |
59 | #include "dce110/dce110_resource.h" | |
60 | #include "dml/display_mode_vba.h" | |
8b8eed05 MA |
61 | #include "dcn20/dcn20_dccg.h" |
62 | #include "dcn20/dcn20_vmid.h" | |
d4caa72e | 63 | #include "dce/dce_panel_cntl.h" |
7ed4e635 HW |
64 | |
65 | #include "navi10_ip_offset.h" | |
66 | ||
67 | #include "dcn/dcn_2_0_0_offset.h" | |
68 | #include "dcn/dcn_2_0_0_sh_mask.h" | |
a771ded8 RL |
69 | #include "dpcs/dpcs_2_0_0_offset.h" |
70 | #include "dpcs/dpcs_2_0_0_sh_mask.h" | |
7ed4e635 HW |
71 | |
72 | #include "nbio/nbio_2_3_offset.h" | |
73 | ||
bb21290f CL |
74 | #include "dcn20/dcn20_dwb.h" |
75 | #include "dcn20/dcn20_mmhubbub.h" | |
76 | ||
7ed4e635 HW |
77 | #include "mmhub/mmhub_2_0_0_offset.h" |
78 | #include "mmhub/mmhub_2_0_0_sh_mask.h" | |
79 | ||
80 | #include "reg_helper.h" | |
81 | #include "dce/dce_abm.h" | |
82 | #include "dce/dce_dmcu.h" | |
83 | #include "dce/dce_aux.h" | |
84 | #include "dce/dce_i2c.h" | |
85 | #include "vm_helper.h" | |
64d283cb | 86 | #include "link_enc_cfg.h" |
7ed4e635 HW |
87 | |
88 | #include "amdgpu_socbb.h" | |
89 | ||
a98cdd8c | 90 | #include "link.h" |
7ed4e635 HW |
91 | #define DC_LOGGER_INIT(logger) |
92 | ||
7ed4e635 HW |
93 | #ifndef mmDP0_DP_DPHY_INTERNAL_CTRL |
94 | #define mmDP0_DP_DPHY_INTERNAL_CTRL 0x210f | |
95 | #define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
96 | #define mmDP1_DP_DPHY_INTERNAL_CTRL 0x220f | |
97 | #define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
98 | #define mmDP2_DP_DPHY_INTERNAL_CTRL 0x230f | |
99 | #define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
100 | #define mmDP3_DP_DPHY_INTERNAL_CTRL 0x240f | |
101 | #define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
102 | #define mmDP4_DP_DPHY_INTERNAL_CTRL 0x250f | |
103 | #define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
104 | #define mmDP5_DP_DPHY_INTERNAL_CTRL 0x260f | |
105 | #define mmDP5_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
106 | #define mmDP6_DP_DPHY_INTERNAL_CTRL 0x270f | |
107 | #define mmDP6_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2 | |
108 | #endif | |
109 | ||
110 | ||
111 | enum dcn20_clk_src_array_id { | |
112 | DCN20_CLK_SRC_PLL0, | |
113 | DCN20_CLK_SRC_PLL1, | |
114 | DCN20_CLK_SRC_PLL2, | |
115 | DCN20_CLK_SRC_PLL3, | |
116 | DCN20_CLK_SRC_PLL4, | |
117 | DCN20_CLK_SRC_PLL5, | |
118 | DCN20_CLK_SRC_TOTAL | |
119 | }; | |
120 | ||
121 | /* begin ********************* | |
122 | * macros to expend register list macro defined in HW object header file */ | |
123 | ||
124 | /* DCN */ | |
7ed4e635 HW |
125 | #define BASE_INNER(seg) DCN_BASE__INST0_SEG ## seg |
126 | ||
127 | #define BASE(seg) BASE_INNER(seg) | |
128 | ||
129 | #define SR(reg_name)\ | |
130 | .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \ | |
131 | mm ## reg_name | |
132 | ||
133 | #define SRI(reg_name, block, id)\ | |
134 | .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ | |
135 | mm ## block ## id ## _ ## reg_name | |
136 | ||
158858bf AP |
137 | #define SRI2_DWB(reg_name, block, id)\ |
138 | .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \ | |
139 | mm ## reg_name | |
140 | #define SF_DWB(reg_name, field_name, post_fix)\ | |
141 | .field_name = reg_name ## __ ## field_name ## post_fix | |
142 | ||
143 | #define SF_DWB2(reg_name, block, id, field_name, post_fix) \ | |
144 | .field_name = reg_name ## __ ## field_name ## post_fix | |
145 | ||
7ed4e635 HW |
146 | #define SRIR(var_name, reg_name, block, id)\ |
147 | .var_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ | |
148 | mm ## block ## id ## _ ## reg_name | |
149 | ||
150 | #define SRII(reg_name, block, id)\ | |
151 | .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ | |
152 | mm ## block ## id ## _ ## reg_name | |
153 | ||
154 | #define DCCG_SRII(reg_name, block, id)\ | |
155 | .block ## _ ## reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \ | |
156 | mm ## block ## id ## _ ## reg_name | |
157 | ||
1e461c37 AC |
158 | #define VUPDATE_SRII(reg_name, block, id)\ |
159 | .reg_name[id] = BASE(mm ## reg_name ## _ ## block ## id ## _BASE_IDX) + \ | |
160 | mm ## reg_name ## _ ## block ## id | |
161 | ||
7ed4e635 HW |
162 | /* NBIO */ |
163 | #define NBIO_BASE_INNER(seg) \ | |
164 | NBIO_BASE__INST0_SEG ## seg | |
165 | ||
166 | #define NBIO_BASE(seg) \ | |
167 | NBIO_BASE_INNER(seg) | |
168 | ||
169 | #define NBIO_SR(reg_name)\ | |
170 | .reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) + \ | |
171 | mm ## reg_name | |
172 | ||
173 | /* MMHUB */ | |
174 | #define MMHUB_BASE_INNER(seg) \ | |
175 | MMHUB_BASE__INST0_SEG ## seg | |
176 | ||
177 | #define MMHUB_BASE(seg) \ | |
178 | MMHUB_BASE_INNER(seg) | |
179 | ||
180 | #define MMHUB_SR(reg_name)\ | |
181 | .reg_name = MMHUB_BASE(mmMM ## reg_name ## _BASE_IDX) + \ | |
182 | mmMM ## reg_name | |
183 | ||
184 | static const struct bios_registers bios_regs = { | |
185 | NBIO_SR(BIOS_SCRATCH_3), | |
186 | NBIO_SR(BIOS_SCRATCH_6) | |
187 | }; | |
188 | ||
189 | #define clk_src_regs(index, pllid)\ | |
190 | [index] = {\ | |
191 | CS_COMMON_REG_LIST_DCN2_0(index, pllid),\ | |
192 | } | |
193 | ||
194 | static const struct dce110_clk_src_regs clk_src_regs[] = { | |
195 | clk_src_regs(0, A), | |
196 | clk_src_regs(1, B), | |
197 | clk_src_regs(2, C), | |
198 | clk_src_regs(3, D), | |
199 | clk_src_regs(4, E), | |
200 | clk_src_regs(5, F) | |
201 | }; | |
202 | ||
203 | static const struct dce110_clk_src_shift cs_shift = { | |
204 | CS_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT) | |
205 | }; | |
206 | ||
207 | static const struct dce110_clk_src_mask cs_mask = { | |
208 | CS_COMMON_MASK_SH_LIST_DCN2_0(_MASK) | |
209 | }; | |
210 | ||
211 | static const struct dce_dmcu_registers dmcu_regs = { | |
212 | DMCU_DCN10_REG_LIST() | |
213 | }; | |
214 | ||
215 | static const struct dce_dmcu_shift dmcu_shift = { | |
216 | DMCU_MASK_SH_LIST_DCN10(__SHIFT) | |
217 | }; | |
218 | ||
219 | static const struct dce_dmcu_mask dmcu_mask = { | |
220 | DMCU_MASK_SH_LIST_DCN10(_MASK) | |
221 | }; | |
d7c29549 | 222 | |
7ed4e635 | 223 | static const struct dce_abm_registers abm_regs = { |
d7c29549 | 224 | ABM_DCN20_REG_LIST() |
7ed4e635 HW |
225 | }; |
226 | ||
227 | static const struct dce_abm_shift abm_shift = { | |
d7c29549 | 228 | ABM_MASK_SH_LIST_DCN20(__SHIFT) |
7ed4e635 HW |
229 | }; |
230 | ||
231 | static const struct dce_abm_mask abm_mask = { | |
d7c29549 | 232 | ABM_MASK_SH_LIST_DCN20(_MASK) |
7ed4e635 | 233 | }; |
d7c29549 | 234 | |
7ed4e635 HW |
235 | #define audio_regs(id)\ |
236 | [id] = {\ | |
237 | AUD_COMMON_REG_LIST(id)\ | |
238 | } | |
239 | ||
240 | static const struct dce_audio_registers audio_regs[] = { | |
241 | audio_regs(0), | |
242 | audio_regs(1), | |
243 | audio_regs(2), | |
244 | audio_regs(3), | |
245 | audio_regs(4), | |
246 | audio_regs(5), | |
247 | audio_regs(6), | |
248 | }; | |
249 | ||
250 | #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\ | |
251 | SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\ | |
252 | SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\ | |
253 | AUD_COMMON_MASK_SH_LIST_BASE(mask_sh) | |
254 | ||
255 | static const struct dce_audio_shift audio_shift = { | |
256 | DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT) | |
257 | }; | |
258 | ||
54a9bcb0 | 259 | static const struct dce_audio_mask audio_mask = { |
7ed4e635 HW |
260 | DCE120_AUD_COMMON_MASK_SH_LIST(_MASK) |
261 | }; | |
262 | ||
263 | #define stream_enc_regs(id)\ | |
264 | [id] = {\ | |
265 | SE_DCN2_REG_LIST(id)\ | |
266 | } | |
267 | ||
268 | static const struct dcn10_stream_enc_registers stream_enc_regs[] = { | |
269 | stream_enc_regs(0), | |
270 | stream_enc_regs(1), | |
271 | stream_enc_regs(2), | |
272 | stream_enc_regs(3), | |
273 | stream_enc_regs(4), | |
274 | stream_enc_regs(5), | |
275 | }; | |
276 | ||
277 | static const struct dcn10_stream_encoder_shift se_shift = { | |
278 | SE_COMMON_MASK_SH_LIST_DCN20(__SHIFT) | |
279 | }; | |
280 | ||
281 | static const struct dcn10_stream_encoder_mask se_mask = { | |
282 | SE_COMMON_MASK_SH_LIST_DCN20(_MASK) | |
283 | }; | |
284 | ||
285 | ||
286 | #define aux_regs(id)\ | |
287 | [id] = {\ | |
288 | DCN2_AUX_REG_LIST(id)\ | |
289 | } | |
290 | ||
291 | static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = { | |
292 | aux_regs(0), | |
293 | aux_regs(1), | |
294 | aux_regs(2), | |
295 | aux_regs(3), | |
296 | aux_regs(4), | |
297 | aux_regs(5) | |
298 | }; | |
299 | ||
300 | #define hpd_regs(id)\ | |
301 | [id] = {\ | |
302 | HPD_REG_LIST(id)\ | |
303 | } | |
304 | ||
305 | static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = { | |
306 | hpd_regs(0), | |
307 | hpd_regs(1), | |
308 | hpd_regs(2), | |
309 | hpd_regs(3), | |
310 | hpd_regs(4), | |
311 | hpd_regs(5) | |
312 | }; | |
313 | ||
314 | #define link_regs(id, phyid)\ | |
315 | [id] = {\ | |
316 | LE_DCN10_REG_LIST(id), \ | |
317 | UNIPHY_DCN2_REG_LIST(phyid), \ | |
a771ded8 | 318 | DPCS_DCN2_REG_LIST(id), \ |
7ed4e635 HW |
319 | SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \ |
320 | } | |
321 | ||
322 | static const struct dcn10_link_enc_registers link_enc_regs[] = { | |
323 | link_regs(0, A), | |
324 | link_regs(1, B), | |
325 | link_regs(2, C), | |
326 | link_regs(3, D), | |
327 | link_regs(4, E), | |
328 | link_regs(5, F) | |
329 | }; | |
330 | ||
331 | static const struct dcn10_link_enc_shift le_shift = { | |
a771ded8 RL |
332 | LINK_ENCODER_MASK_SH_LIST_DCN20(__SHIFT),\ |
333 | DPCS_DCN2_MASK_SH_LIST(__SHIFT) | |
7ed4e635 HW |
334 | }; |
335 | ||
336 | static const struct dcn10_link_enc_mask le_mask = { | |
a771ded8 RL |
337 | LINK_ENCODER_MASK_SH_LIST_DCN20(_MASK),\ |
338 | DPCS_DCN2_MASK_SH_LIST(_MASK) | |
7ed4e635 HW |
339 | }; |
340 | ||
d4caa72e AK |
341 | static const struct dce_panel_cntl_registers panel_cntl_regs[] = { |
342 | { DCN_PANEL_CNTL_REG_LIST() } | |
904fb6e0 AK |
343 | }; |
344 | ||
d4caa72e AK |
345 | static const struct dce_panel_cntl_shift panel_cntl_shift = { |
346 | DCE_PANEL_CNTL_MASK_SH_LIST(__SHIFT) | |
904fb6e0 AK |
347 | }; |
348 | ||
d4caa72e AK |
349 | static const struct dce_panel_cntl_mask panel_cntl_mask = { |
350 | DCE_PANEL_CNTL_MASK_SH_LIST(_MASK) | |
904fb6e0 AK |
351 | }; |
352 | ||
7ed4e635 HW |
353 | #define ipp_regs(id)\ |
354 | [id] = {\ | |
355 | IPP_REG_LIST_DCN20(id),\ | |
356 | } | |
357 | ||
358 | static const struct dcn10_ipp_registers ipp_regs[] = { | |
359 | ipp_regs(0), | |
360 | ipp_regs(1), | |
361 | ipp_regs(2), | |
362 | ipp_regs(3), | |
363 | ipp_regs(4), | |
364 | ipp_regs(5), | |
365 | }; | |
366 | ||
367 | static const struct dcn10_ipp_shift ipp_shift = { | |
368 | IPP_MASK_SH_LIST_DCN20(__SHIFT) | |
369 | }; | |
370 | ||
371 | static const struct dcn10_ipp_mask ipp_mask = { | |
372 | IPP_MASK_SH_LIST_DCN20(_MASK), | |
373 | }; | |
374 | ||
375 | #define opp_regs(id)\ | |
376 | [id] = {\ | |
377 | OPP_REG_LIST_DCN20(id),\ | |
378 | } | |
379 | ||
380 | static const struct dcn20_opp_registers opp_regs[] = { | |
381 | opp_regs(0), | |
382 | opp_regs(1), | |
383 | opp_regs(2), | |
384 | opp_regs(3), | |
385 | opp_regs(4), | |
386 | opp_regs(5), | |
387 | }; | |
388 | ||
389 | static const struct dcn20_opp_shift opp_shift = { | |
390 | OPP_MASK_SH_LIST_DCN20(__SHIFT) | |
391 | }; | |
392 | ||
393 | static const struct dcn20_opp_mask opp_mask = { | |
394 | OPP_MASK_SH_LIST_DCN20(_MASK) | |
395 | }; | |
396 | ||
397 | #define aux_engine_regs(id)\ | |
398 | [id] = {\ | |
399 | AUX_COMMON_REG_LIST0(id), \ | |
400 | .AUXN_IMPCAL = 0, \ | |
401 | .AUXP_IMPCAL = 0, \ | |
402 | .AUX_RESET_MASK = DP_AUX0_AUX_CONTROL__AUX_RESET_MASK, \ | |
403 | } | |
404 | ||
405 | static const struct dce110_aux_registers aux_engine_regs[] = { | |
406 | aux_engine_regs(0), | |
407 | aux_engine_regs(1), | |
408 | aux_engine_regs(2), | |
409 | aux_engine_regs(3), | |
410 | aux_engine_regs(4), | |
411 | aux_engine_regs(5) | |
412 | }; | |
413 | ||
414 | #define tf_regs(id)\ | |
415 | [id] = {\ | |
416 | TF_REG_LIST_DCN20(id),\ | |
d9eb70ae | 417 | TF_REG_LIST_DCN20_COMMON_APPEND(id),\ |
7ed4e635 HW |
418 | } |
419 | ||
420 | static const struct dcn2_dpp_registers tf_regs[] = { | |
421 | tf_regs(0), | |
422 | tf_regs(1), | |
423 | tf_regs(2), | |
424 | tf_regs(3), | |
425 | tf_regs(4), | |
426 | tf_regs(5), | |
427 | }; | |
428 | ||
429 | static const struct dcn2_dpp_shift tf_shift = { | |
d56eaa7c | 430 | TF_REG_LIST_SH_MASK_DCN20(__SHIFT), |
c1e34175 | 431 | TF_DEBUG_REG_LIST_SH_DCN20 |
7ed4e635 HW |
432 | }; |
433 | ||
434 | static const struct dcn2_dpp_mask tf_mask = { | |
d56eaa7c | 435 | TF_REG_LIST_SH_MASK_DCN20(_MASK), |
c1e34175 | 436 | TF_DEBUG_REG_LIST_MASK_DCN20 |
7ed4e635 HW |
437 | }; |
438 | ||
bb21290f CL |
439 | #define dwbc_regs_dcn2(id)\ |
440 | [id] = {\ | |
441 | DWBC_COMMON_REG_LIST_DCN2_0(id),\ | |
442 | } | |
443 | ||
444 | static const struct dcn20_dwbc_registers dwbc20_regs[] = { | |
445 | dwbc_regs_dcn2(0), | |
446 | }; | |
447 | ||
448 | static const struct dcn20_dwbc_shift dwbc20_shift = { | |
449 | DWBC_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT) | |
450 | }; | |
451 | ||
452 | static const struct dcn20_dwbc_mask dwbc20_mask = { | |
453 | DWBC_COMMON_MASK_SH_LIST_DCN2_0(_MASK) | |
454 | }; | |
455 | ||
456 | #define mcif_wb_regs_dcn2(id)\ | |
457 | [id] = {\ | |
458 | MCIF_WB_COMMON_REG_LIST_DCN2_0(id),\ | |
459 | } | |
460 | ||
461 | static const struct dcn20_mmhubbub_registers mcif_wb20_regs[] = { | |
462 | mcif_wb_regs_dcn2(0), | |
463 | }; | |
464 | ||
465 | static const struct dcn20_mmhubbub_shift mcif_wb20_shift = { | |
466 | MCIF_WB_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT) | |
467 | }; | |
468 | ||
469 | static const struct dcn20_mmhubbub_mask mcif_wb20_mask = { | |
470 | MCIF_WB_COMMON_MASK_SH_LIST_DCN2_0(_MASK) | |
471 | }; | |
472 | ||
7ed4e635 HW |
473 | static const struct dcn20_mpc_registers mpc_regs = { |
474 | MPC_REG_LIST_DCN2_0(0), | |
475 | MPC_REG_LIST_DCN2_0(1), | |
476 | MPC_REG_LIST_DCN2_0(2), | |
477 | MPC_REG_LIST_DCN2_0(3), | |
478 | MPC_REG_LIST_DCN2_0(4), | |
479 | MPC_REG_LIST_DCN2_0(5), | |
480 | MPC_OUT_MUX_REG_LIST_DCN2_0(0), | |
481 | MPC_OUT_MUX_REG_LIST_DCN2_0(1), | |
482 | MPC_OUT_MUX_REG_LIST_DCN2_0(2), | |
483 | MPC_OUT_MUX_REG_LIST_DCN2_0(3), | |
484 | MPC_OUT_MUX_REG_LIST_DCN2_0(4), | |
485 | MPC_OUT_MUX_REG_LIST_DCN2_0(5), | |
e8027e08 | 486 | MPC_DBG_REG_LIST_DCN2_0() |
7ed4e635 HW |
487 | }; |
488 | ||
489 | static const struct dcn20_mpc_shift mpc_shift = { | |
c1e34175 NA |
490 | MPC_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT), |
491 | MPC_DEBUG_REG_LIST_SH_DCN20 | |
7ed4e635 HW |
492 | }; |
493 | ||
494 | static const struct dcn20_mpc_mask mpc_mask = { | |
c1e34175 NA |
495 | MPC_COMMON_MASK_SH_LIST_DCN2_0(_MASK), |
496 | MPC_DEBUG_REG_LIST_MASK_DCN20 | |
7ed4e635 HW |
497 | }; |
498 | ||
499 | #define tg_regs(id)\ | |
500 | [id] = {TG_COMMON_REG_LIST_DCN2_0(id)} | |
501 | ||
502 | ||
503 | static const struct dcn_optc_registers tg_regs[] = { | |
504 | tg_regs(0), | |
505 | tg_regs(1), | |
506 | tg_regs(2), | |
507 | tg_regs(3), | |
508 | tg_regs(4), | |
509 | tg_regs(5) | |
510 | }; | |
511 | ||
512 | static const struct dcn_optc_shift tg_shift = { | |
513 | TG_COMMON_MASK_SH_LIST_DCN2_0(__SHIFT) | |
514 | }; | |
515 | ||
516 | static const struct dcn_optc_mask tg_mask = { | |
517 | TG_COMMON_MASK_SH_LIST_DCN2_0(_MASK) | |
518 | }; | |
519 | ||
520 | #define hubp_regs(id)\ | |
521 | [id] = {\ | |
522 | HUBP_REG_LIST_DCN20(id)\ | |
523 | } | |
524 | ||
525 | static const struct dcn_hubp2_registers hubp_regs[] = { | |
526 | hubp_regs(0), | |
527 | hubp_regs(1), | |
528 | hubp_regs(2), | |
529 | hubp_regs(3), | |
530 | hubp_regs(4), | |
531 | hubp_regs(5) | |
532 | }; | |
533 | ||
534 | static const struct dcn_hubp2_shift hubp_shift = { | |
535 | HUBP_MASK_SH_LIST_DCN20(__SHIFT) | |
536 | }; | |
537 | ||
538 | static const struct dcn_hubp2_mask hubp_mask = { | |
539 | HUBP_MASK_SH_LIST_DCN20(_MASK) | |
540 | }; | |
541 | ||
542 | static const struct dcn_hubbub_registers hubbub_reg = { | |
543 | HUBBUB_REG_LIST_DCN20(0) | |
544 | }; | |
545 | ||
546 | static const struct dcn_hubbub_shift hubbub_shift = { | |
547 | HUBBUB_MASK_SH_LIST_DCN20(__SHIFT) | |
548 | }; | |
549 | ||
550 | static const struct dcn_hubbub_mask hubbub_mask = { | |
551 | HUBBUB_MASK_SH_LIST_DCN20(_MASK) | |
552 | }; | |
553 | ||
554 | #define vmid_regs(id)\ | |
555 | [id] = {\ | |
556 | DCN20_VMID_REG_LIST(id)\ | |
557 | } | |
558 | ||
559 | static const struct dcn_vmid_registers vmid_regs[] = { | |
560 | vmid_regs(0), | |
561 | vmid_regs(1), | |
562 | vmid_regs(2), | |
563 | vmid_regs(3), | |
564 | vmid_regs(4), | |
565 | vmid_regs(5), | |
566 | vmid_regs(6), | |
567 | vmid_regs(7), | |
568 | vmid_regs(8), | |
569 | vmid_regs(9), | |
570 | vmid_regs(10), | |
571 | vmid_regs(11), | |
572 | vmid_regs(12), | |
573 | vmid_regs(13), | |
574 | vmid_regs(14), | |
575 | vmid_regs(15) | |
576 | }; | |
577 | ||
578 | static const struct dcn20_vmid_shift vmid_shifts = { | |
579 | DCN20_VMID_MASK_SH_LIST(__SHIFT) | |
580 | }; | |
581 | ||
582 | static const struct dcn20_vmid_mask vmid_masks = { | |
583 | DCN20_VMID_MASK_SH_LIST(_MASK) | |
584 | }; | |
585 | ||
8276dd87 | 586 | static const struct dce110_aux_registers_shift aux_shift = { |
587 | DCN_AUX_MASK_SH_LIST(__SHIFT) | |
588 | }; | |
589 | ||
590 | static const struct dce110_aux_registers_mask aux_mask = { | |
591 | DCN_AUX_MASK_SH_LIST(_MASK) | |
592 | }; | |
593 | ||
bf7f5ac3 YMM |
594 | static int map_transmitter_id_to_phy_instance( |
595 | enum transmitter transmitter) | |
596 | { | |
597 | switch (transmitter) { | |
598 | case TRANSMITTER_UNIPHY_A: | |
599 | return 0; | |
600 | break; | |
601 | case TRANSMITTER_UNIPHY_B: | |
602 | return 1; | |
603 | break; | |
604 | case TRANSMITTER_UNIPHY_C: | |
605 | return 2; | |
606 | break; | |
607 | case TRANSMITTER_UNIPHY_D: | |
608 | return 3; | |
609 | break; | |
610 | case TRANSMITTER_UNIPHY_E: | |
611 | return 4; | |
612 | break; | |
613 | case TRANSMITTER_UNIPHY_F: | |
614 | return 5; | |
615 | break; | |
616 | default: | |
617 | ASSERT(0); | |
618 | return 0; | |
619 | } | |
620 | } | |
8276dd87 | 621 | |
97bda032 HW |
622 | #define dsc_regsDCN20(id)\ |
623 | [id] = {\ | |
624 | DSC_REG_LIST_DCN20(id)\ | |
625 | } | |
626 | ||
627 | static const struct dcn20_dsc_registers dsc_regs[] = { | |
628 | dsc_regsDCN20(0), | |
629 | dsc_regsDCN20(1), | |
630 | dsc_regsDCN20(2), | |
631 | dsc_regsDCN20(3), | |
632 | dsc_regsDCN20(4), | |
633 | dsc_regsDCN20(5) | |
634 | }; | |
635 | ||
636 | static const struct dcn20_dsc_shift dsc_shift = { | |
637 | DSC_REG_LIST_SH_MASK_DCN20(__SHIFT) | |
638 | }; | |
639 | ||
640 | static const struct dcn20_dsc_mask dsc_mask = { | |
641 | DSC_REG_LIST_SH_MASK_DCN20(_MASK) | |
642 | }; | |
7ed4e635 HW |
643 | |
644 | static const struct dccg_registers dccg_regs = { | |
645 | DCCG_REG_LIST_DCN2() | |
646 | }; | |
647 | ||
648 | static const struct dccg_shift dccg_shift = { | |
649 | DCCG_MASK_SH_LIST_DCN2(__SHIFT) | |
650 | }; | |
651 | ||
652 | static const struct dccg_mask dccg_mask = { | |
653 | DCCG_MASK_SH_LIST_DCN2(_MASK) | |
654 | }; | |
655 | ||
656 | static const struct resource_caps res_cap_nv10 = { | |
657 | .num_timing_generator = 6, | |
658 | .num_opp = 6, | |
659 | .num_video_plane = 6, | |
660 | .num_audio = 7, | |
661 | .num_stream_encoder = 6, | |
662 | .num_pll = 6, | |
9cbee6ef | 663 | .num_dwb = 1, |
7ed4e635 HW |
664 | .num_ddc = 6, |
665 | .num_vmid = 16, | |
97bda032 | 666 | .num_dsc = 6, |
7ed4e635 HW |
667 | }; |
668 | ||
669 | static const struct dc_plane_cap plane_cap = { | |
670 | .type = DC_PLANE_TYPE_DCN_UNIVERSAL, | |
7ed4e635 | 671 | .per_pixel_alpha = true, |
5b1b2f20 AD |
672 | |
673 | .pixel_format_support = { | |
674 | .argb8888 = true, | |
675 | .nv12 = true, | |
cbec6477 SW |
676 | .fp16 = true, |
677 | .p010 = true | |
5b1b2f20 AD |
678 | }, |
679 | ||
680 | .max_upscale_factor = { | |
681 | .argb8888 = 16000, | |
682 | .nv12 = 16000, | |
683 | .fp16 = 1 | |
684 | }, | |
685 | ||
686 | .max_downscale_factor = { | |
687 | .argb8888 = 250, | |
688 | .nv12 = 250, | |
689 | .fp16 = 1 | |
3b26ca2d IK |
690 | }, |
691 | 16, | |
692 | 16 | |
7ed4e635 | 693 | }; |
2ebe1773 BL |
694 | static const struct resource_caps res_cap_nv14 = { |
695 | .num_timing_generator = 5, | |
696 | .num_opp = 5, | |
697 | .num_video_plane = 5, | |
698 | .num_audio = 6, | |
699 | .num_stream_encoder = 5, | |
700 | .num_pll = 5, | |
80df905d | 701 | .num_dwb = 1, |
2ebe1773 | 702 | .num_ddc = 5, |
6bb27085 ZL |
703 | .num_vmid = 16, |
704 | .num_dsc = 5, | |
2ebe1773 | 705 | }; |
7ed4e635 HW |
706 | |
707 | static const struct dc_debug_options debug_defaults_drv = { | |
f0a574c9 | 708 | .disable_dmcu = false, |
7ed4e635 HW |
709 | .force_abm_enable = false, |
710 | .timing_trace = false, | |
711 | .clock_trace = true, | |
712 | .disable_pplib_clock_request = true, | |
ef35c7ba | 713 | .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP, |
4d25a0d5 | 714 | .force_single_disp_pipe_split = false, |
7ed4e635 HW |
715 | .disable_dcc = DCC_ENABLE, |
716 | .vsr_support = true, | |
717 | .performance_trace = false, | |
718 | .max_downscale_src_width = 5120,/*upto 5K*/ | |
719 | .disable_pplib_wm_range = false, | |
720 | .scl_reset_length10 = true, | |
9e14d4f1 | 721 | .sanity_checks = false, |
1a7d296d | 722 | .underflow_assert_delay_us = 0xFFFFFFFF, |
0baae624 | 723 | .enable_legacy_fast_update = true, |
79de4d9a | 724 | .using_dml2 = false, |
7ed4e635 HW |
725 | }; |
726 | ||
7ed4e635 HW |
727 | void dcn20_dpp_destroy(struct dpp **dpp) |
728 | { | |
729 | kfree(TO_DCN20_DPP(*dpp)); | |
730 | *dpp = NULL; | |
731 | } | |
732 | ||
733 | struct dpp *dcn20_dpp_create( | |
734 | struct dc_context *ctx, | |
735 | uint32_t inst) | |
736 | { | |
737 | struct dcn20_dpp *dpp = | |
3bb11050 | 738 | kzalloc(sizeof(struct dcn20_dpp), GFP_ATOMIC); |
7ed4e635 HW |
739 | |
740 | if (!dpp) | |
741 | return NULL; | |
742 | ||
743 | if (dpp2_construct(dpp, ctx, inst, | |
744 | &tf_regs[inst], &tf_shift, &tf_mask)) | |
745 | return &dpp->base; | |
746 | ||
747 | BREAK_TO_DEBUGGER(); | |
748 | kfree(dpp); | |
749 | return NULL; | |
750 | } | |
751 | ||
752 | struct input_pixel_processor *dcn20_ipp_create( | |
753 | struct dc_context *ctx, uint32_t inst) | |
754 | { | |
755 | struct dcn10_ipp *ipp = | |
3bb11050 | 756 | kzalloc(sizeof(struct dcn10_ipp), GFP_ATOMIC); |
7ed4e635 HW |
757 | |
758 | if (!ipp) { | |
759 | BREAK_TO_DEBUGGER(); | |
760 | return NULL; | |
761 | } | |
762 | ||
763 | dcn20_ipp_construct(ipp, ctx, inst, | |
764 | &ipp_regs[inst], &ipp_shift, &ipp_mask); | |
765 | return &ipp->base; | |
766 | } | |
767 | ||
768 | ||
769 | struct output_pixel_processor *dcn20_opp_create( | |
770 | struct dc_context *ctx, uint32_t inst) | |
771 | { | |
772 | struct dcn20_opp *opp = | |
3bb11050 | 773 | kzalloc(sizeof(struct dcn20_opp), GFP_ATOMIC); |
7ed4e635 HW |
774 | |
775 | if (!opp) { | |
776 | BREAK_TO_DEBUGGER(); | |
777 | return NULL; | |
778 | } | |
779 | ||
780 | dcn20_opp_construct(opp, ctx, inst, | |
781 | &opp_regs[inst], &opp_shift, &opp_mask); | |
782 | return &opp->base; | |
783 | } | |
784 | ||
785 | struct dce_aux *dcn20_aux_engine_create( | |
786 | struct dc_context *ctx, | |
787 | uint32_t inst) | |
788 | { | |
789 | struct aux_engine_dce110 *aux_engine = | |
3bb11050 | 790 | kzalloc(sizeof(struct aux_engine_dce110), GFP_ATOMIC); |
7ed4e635 HW |
791 | |
792 | if (!aux_engine) | |
793 | return NULL; | |
794 | ||
795 | dce110_aux_engine_construct(aux_engine, ctx, inst, | |
796 | SW_AUX_TIMEOUT_PERIOD_MULTIPLIER * AUX_TIMEOUT_PERIOD, | |
8276dd87 | 797 | &aux_engine_regs[inst], |
798 | &aux_mask, | |
f6040a43 | 799 | &aux_shift, |
800 | ctx->dc->caps.extended_aux_timeout_support); | |
7ed4e635 HW |
801 | |
802 | return &aux_engine->base; | |
803 | } | |
804 | #define i2c_inst_regs(id) { I2C_HW_ENGINE_COMMON_REG_LIST(id) } | |
805 | ||
806 | static const struct dce_i2c_registers i2c_hw_regs[] = { | |
807 | i2c_inst_regs(1), | |
808 | i2c_inst_regs(2), | |
809 | i2c_inst_regs(3), | |
810 | i2c_inst_regs(4), | |
811 | i2c_inst_regs(5), | |
812 | i2c_inst_regs(6), | |
813 | }; | |
814 | ||
815 | static const struct dce_i2c_shift i2c_shifts = { | |
816 | I2C_COMMON_MASK_SH_LIST_DCN2(__SHIFT) | |
817 | }; | |
818 | ||
819 | static const struct dce_i2c_mask i2c_masks = { | |
820 | I2C_COMMON_MASK_SH_LIST_DCN2(_MASK) | |
821 | }; | |
822 | ||
823 | struct dce_i2c_hw *dcn20_i2c_hw_create( | |
824 | struct dc_context *ctx, | |
825 | uint32_t inst) | |
826 | { | |
827 | struct dce_i2c_hw *dce_i2c_hw = | |
3bb11050 | 828 | kzalloc(sizeof(struct dce_i2c_hw), GFP_ATOMIC); |
7ed4e635 HW |
829 | |
830 | if (!dce_i2c_hw) | |
831 | return NULL; | |
832 | ||
833 | dcn2_i2c_hw_construct(dce_i2c_hw, ctx, inst, | |
834 | &i2c_hw_regs[inst], &i2c_shifts, &i2c_masks); | |
835 | ||
836 | return dce_i2c_hw; | |
837 | } | |
838 | struct mpc *dcn20_mpc_create(struct dc_context *ctx) | |
839 | { | |
840 | struct dcn20_mpc *mpc20 = kzalloc(sizeof(struct dcn20_mpc), | |
3bb11050 | 841 | GFP_ATOMIC); |
7ed4e635 HW |
842 | |
843 | if (!mpc20) | |
844 | return NULL; | |
845 | ||
846 | dcn20_mpc_construct(mpc20, ctx, | |
847 | &mpc_regs, | |
848 | &mpc_shift, | |
849 | &mpc_mask, | |
850 | 6); | |
851 | ||
852 | return &mpc20->base; | |
853 | } | |
854 | ||
855 | struct hubbub *dcn20_hubbub_create(struct dc_context *ctx) | |
856 | { | |
857 | int i; | |
858 | struct dcn20_hubbub *hubbub = kzalloc(sizeof(struct dcn20_hubbub), | |
3bb11050 | 859 | GFP_ATOMIC); |
7ed4e635 HW |
860 | |
861 | if (!hubbub) | |
862 | return NULL; | |
863 | ||
864 | hubbub2_construct(hubbub, ctx, | |
865 | &hubbub_reg, | |
866 | &hubbub_shift, | |
867 | &hubbub_mask); | |
868 | ||
869 | for (i = 0; i < res_cap_nv10.num_vmid; i++) { | |
870 | struct dcn20_vmid *vmid = &hubbub->vmid[i]; | |
871 | ||
872 | vmid->ctx = ctx; | |
873 | ||
874 | vmid->regs = &vmid_regs[i]; | |
875 | vmid->shifts = &vmid_shifts; | |
876 | vmid->masks = &vmid_masks; | |
877 | } | |
878 | ||
879 | return &hubbub->base; | |
880 | } | |
881 | ||
882 | struct timing_generator *dcn20_timing_generator_create( | |
883 | struct dc_context *ctx, | |
884 | uint32_t instance) | |
885 | { | |
886 | struct optc *tgn10 = | |
3bb11050 | 887 | kzalloc(sizeof(struct optc), GFP_ATOMIC); |
7ed4e635 HW |
888 | |
889 | if (!tgn10) | |
890 | return NULL; | |
891 | ||
892 | tgn10->base.inst = instance; | |
893 | tgn10->base.ctx = ctx; | |
894 | ||
895 | tgn10->tg_regs = &tg_regs[instance]; | |
896 | tgn10->tg_shift = &tg_shift; | |
897 | tgn10->tg_mask = &tg_mask; | |
898 | ||
899 | dcn20_timing_generator_init(tgn10); | |
900 | ||
901 | return &tgn10->base; | |
902 | } | |
903 | ||
904 | static const struct encoder_feature_support link_enc_feature = { | |
905 | .max_hdmi_deep_color = COLOR_DEPTH_121212, | |
906 | .max_hdmi_pixel_clock = 600000, | |
907 | .hdmi_ycbcr420_supported = true, | |
908 | .dp_ycbcr420_supported = true, | |
c14b726e | 909 | .fec_supported = true, |
7ed4e635 HW |
910 | .flags.bits.IS_HBR2_CAPABLE = true, |
911 | .flags.bits.IS_HBR3_CAPABLE = true, | |
912 | .flags.bits.IS_TPS3_CAPABLE = true, | |
913 | .flags.bits.IS_TPS4_CAPABLE = true | |
914 | }; | |
915 | ||
916 | struct link_encoder *dcn20_link_encoder_create( | |
e216431b | 917 | struct dc_context *ctx, |
7ed4e635 HW |
918 | const struct encoder_init_data *enc_init_data) |
919 | { | |
920 | struct dcn20_link_encoder *enc20 = | |
921 | kzalloc(sizeof(struct dcn20_link_encoder), GFP_KERNEL); | |
bf7f5ac3 | 922 | int link_regs_id; |
7ed4e635 HW |
923 | |
924 | if (!enc20) | |
925 | return NULL; | |
926 | ||
bf7f5ac3 YMM |
927 | link_regs_id = |
928 | map_transmitter_id_to_phy_instance(enc_init_data->transmitter); | |
929 | ||
7ed4e635 HW |
930 | dcn20_link_encoder_construct(enc20, |
931 | enc_init_data, | |
932 | &link_enc_feature, | |
bf7f5ac3 | 933 | &link_enc_regs[link_regs_id], |
7ed4e635 HW |
934 | &link_enc_aux_regs[enc_init_data->channel - 1], |
935 | &link_enc_hpd_regs[enc_init_data->hpd_source], | |
936 | &le_shift, | |
937 | &le_mask); | |
938 | ||
939 | return &enc20->enc10.base; | |
940 | } | |
941 | ||
d4caa72e | 942 | static struct panel_cntl *dcn20_panel_cntl_create(const struct panel_cntl_init_data *init_data) |
904fb6e0 | 943 | { |
d4caa72e AK |
944 | struct dce_panel_cntl *panel_cntl = |
945 | kzalloc(sizeof(struct dce_panel_cntl), GFP_KERNEL); | |
904fb6e0 | 946 | |
d4caa72e | 947 | if (!panel_cntl) |
904fb6e0 AK |
948 | return NULL; |
949 | ||
d4caa72e | 950 | dce_panel_cntl_construct(panel_cntl, |
904fb6e0 | 951 | init_data, |
d4caa72e AK |
952 | &panel_cntl_regs[init_data->inst], |
953 | &panel_cntl_shift, | |
954 | &panel_cntl_mask); | |
904fb6e0 | 955 | |
d4caa72e | 956 | return &panel_cntl->base; |
904fb6e0 AK |
957 | } |
958 | ||
dfd84d90 | 959 | static struct clock_source *dcn20_clock_source_create( |
7ed4e635 HW |
960 | struct dc_context *ctx, |
961 | struct dc_bios *bios, | |
962 | enum clock_source_id id, | |
963 | const struct dce110_clk_src_regs *regs, | |
964 | bool dp_clk_src) | |
965 | { | |
966 | struct dce110_clk_src *clk_src = | |
3bb11050 | 967 | kzalloc(sizeof(struct dce110_clk_src), GFP_ATOMIC); |
7ed4e635 HW |
968 | |
969 | if (!clk_src) | |
970 | return NULL; | |
971 | ||
972 | if (dcn20_clk_src_construct(clk_src, ctx, bios, id, | |
973 | regs, &cs_shift, &cs_mask)) { | |
974 | clk_src->base.dp_clk_src = dp_clk_src; | |
975 | return &clk_src->base; | |
976 | } | |
977 | ||
cabe144b | 978 | kfree(clk_src); |
7ed4e635 HW |
979 | BREAK_TO_DEBUGGER(); |
980 | return NULL; | |
981 | } | |
982 | ||
983 | static void read_dce_straps( | |
984 | struct dc_context *ctx, | |
985 | struct resource_straps *straps) | |
986 | { | |
987 | generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX), | |
988 | FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio); | |
989 | } | |
990 | ||
991 | static struct audio *dcn20_create_audio( | |
992 | struct dc_context *ctx, unsigned int inst) | |
993 | { | |
994 | return dce_audio_create(ctx, inst, | |
995 | &audio_regs[inst], &audio_shift, &audio_mask); | |
996 | } | |
997 | ||
998 | struct stream_encoder *dcn20_stream_encoder_create( | |
999 | enum engine_id eng_id, | |
1000 | struct dc_context *ctx) | |
1001 | { | |
1002 | struct dcn10_stream_encoder *enc1 = | |
1003 | kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL); | |
1004 | ||
1005 | if (!enc1) | |
1006 | return NULL; | |
1007 | ||
9fd4c2d7 ZL |
1008 | if (ASICREV_IS_NAVI14_M(ctx->asic_id.hw_internal_rev)) { |
1009 | if (eng_id >= ENGINE_ID_DIGD) | |
1010 | eng_id++; | |
1011 | } | |
1012 | ||
7ed4e635 HW |
1013 | dcn20_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id, |
1014 | &stream_enc_regs[eng_id], | |
1015 | &se_shift, &se_mask); | |
1016 | ||
1017 | return &enc1->base; | |
1018 | } | |
1019 | ||
1020 | static const struct dce_hwseq_registers hwseq_reg = { | |
1021 | HWSEQ_DCN2_REG_LIST() | |
1022 | }; | |
1023 | ||
1024 | static const struct dce_hwseq_shift hwseq_shift = { | |
1025 | HWSEQ_DCN2_MASK_SH_LIST(__SHIFT) | |
1026 | }; | |
1027 | ||
1028 | static const struct dce_hwseq_mask hwseq_mask = { | |
1029 | HWSEQ_DCN2_MASK_SH_LIST(_MASK) | |
1030 | }; | |
1031 | ||
1032 | struct dce_hwseq *dcn20_hwseq_create( | |
1033 | struct dc_context *ctx) | |
1034 | { | |
1035 | struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL); | |
1036 | ||
1037 | if (hws) { | |
1038 | hws->ctx = ctx; | |
1039 | hws->regs = &hwseq_reg; | |
1040 | hws->shifts = &hwseq_shift; | |
1041 | hws->masks = &hwseq_mask; | |
1042 | } | |
1043 | return hws; | |
1044 | } | |
1045 | ||
1046 | static const struct resource_create_funcs res_create_funcs = { | |
1047 | .read_dce_straps = read_dce_straps, | |
1048 | .create_audio = dcn20_create_audio, | |
1049 | .create_stream_encoder = dcn20_stream_encoder_create, | |
1050 | .create_hwseq = dcn20_hwseq_create, | |
1051 | }; | |
1052 | ||
44e149bb AD |
1053 | static void dcn20_pp_smu_destroy(struct pp_smu_funcs **pp_smu); |
1054 | ||
7ed4e635 HW |
1055 | void dcn20_clock_source_destroy(struct clock_source **clk_src) |
1056 | { | |
1057 | kfree(TO_DCE110_CLK_SRC(*clk_src)); | |
1058 | *clk_src = NULL; | |
1059 | } | |
1060 | ||
97bda032 HW |
1061 | |
1062 | struct display_stream_compressor *dcn20_dsc_create( | |
1063 | struct dc_context *ctx, uint32_t inst) | |
1064 | { | |
1065 | struct dcn20_dsc *dsc = | |
3bb11050 | 1066 | kzalloc(sizeof(struct dcn20_dsc), GFP_ATOMIC); |
97bda032 HW |
1067 | |
1068 | if (!dsc) { | |
1069 | BREAK_TO_DEBUGGER(); | |
1070 | return NULL; | |
1071 | } | |
1072 | ||
1073 | dsc2_construct(dsc, ctx, inst, &dsc_regs[inst], &dsc_shift, &dsc_mask); | |
1074 | return &dsc->base; | |
1075 | } | |
1076 | ||
1077 | void dcn20_dsc_destroy(struct display_stream_compressor **dsc) | |
1078 | { | |
1079 | kfree(container_of(*dsc, struct dcn20_dsc, base)); | |
1080 | *dsc = NULL; | |
1081 | } | |
1082 | ||
7ed4e635 | 1083 | |
d9e32672 | 1084 | static void dcn20_resource_destruct(struct dcn20_resource_pool *pool) |
7ed4e635 HW |
1085 | { |
1086 | unsigned int i; | |
1087 | ||
1088 | for (i = 0; i < pool->base.stream_enc_count; i++) { | |
1089 | if (pool->base.stream_enc[i] != NULL) { | |
1090 | kfree(DCN10STRENC_FROM_STRENC(pool->base.stream_enc[i])); | |
1091 | pool->base.stream_enc[i] = NULL; | |
1092 | } | |
1093 | } | |
1094 | ||
97bda032 HW |
1095 | for (i = 0; i < pool->base.res_cap->num_dsc; i++) { |
1096 | if (pool->base.dscs[i] != NULL) | |
1097 | dcn20_dsc_destroy(&pool->base.dscs[i]); | |
1098 | } | |
7ed4e635 HW |
1099 | |
1100 | if (pool->base.mpc != NULL) { | |
1101 | kfree(TO_DCN20_MPC(pool->base.mpc)); | |
1102 | pool->base.mpc = NULL; | |
1103 | } | |
1104 | if (pool->base.hubbub != NULL) { | |
1105 | kfree(pool->base.hubbub); | |
1106 | pool->base.hubbub = NULL; | |
1107 | } | |
1108 | for (i = 0; i < pool->base.pipe_count; i++) { | |
1109 | if (pool->base.dpps[i] != NULL) | |
1110 | dcn20_dpp_destroy(&pool->base.dpps[i]); | |
1111 | ||
1112 | if (pool->base.ipps[i] != NULL) | |
1113 | pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]); | |
1114 | ||
1115 | if (pool->base.hubps[i] != NULL) { | |
1116 | kfree(TO_DCN20_HUBP(pool->base.hubps[i])); | |
1117 | pool->base.hubps[i] = NULL; | |
1118 | } | |
1119 | ||
1120 | if (pool->base.irqs != NULL) { | |
1121 | dal_irq_service_destroy(&pool->base.irqs); | |
1122 | } | |
1123 | } | |
1124 | ||
1125 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | |
1126 | if (pool->base.engines[i] != NULL) | |
1127 | dce110_engine_destroy(&pool->base.engines[i]); | |
1128 | if (pool->base.hw_i2cs[i] != NULL) { | |
1129 | kfree(pool->base.hw_i2cs[i]); | |
1130 | pool->base.hw_i2cs[i] = NULL; | |
1131 | } | |
1132 | if (pool->base.sw_i2cs[i] != NULL) { | |
1133 | kfree(pool->base.sw_i2cs[i]); | |
1134 | pool->base.sw_i2cs[i] = NULL; | |
1135 | } | |
1136 | } | |
1137 | ||
1138 | for (i = 0; i < pool->base.res_cap->num_opp; i++) { | |
1139 | if (pool->base.opps[i] != NULL) | |
1140 | pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]); | |
1141 | } | |
1142 | ||
1143 | for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { | |
1144 | if (pool->base.timing_generators[i] != NULL) { | |
1145 | kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i])); | |
1146 | pool->base.timing_generators[i] = NULL; | |
1147 | } | |
1148 | } | |
1149 | ||
bb21290f CL |
1150 | for (i = 0; i < pool->base.res_cap->num_dwb; i++) { |
1151 | if (pool->base.dwbc[i] != NULL) { | |
1152 | kfree(TO_DCN20_DWBC(pool->base.dwbc[i])); | |
1153 | pool->base.dwbc[i] = NULL; | |
1154 | } | |
1155 | if (pool->base.mcif_wb[i] != NULL) { | |
1156 | kfree(TO_DCN20_MMHUBBUB(pool->base.mcif_wb[i])); | |
1157 | pool->base.mcif_wb[i] = NULL; | |
1158 | } | |
1159 | } | |
1160 | ||
7ed4e635 HW |
1161 | for (i = 0; i < pool->base.audio_count; i++) { |
1162 | if (pool->base.audios[i]) | |
1163 | dce_aud_destroy(&pool->base.audios[i]); | |
1164 | } | |
1165 | ||
1166 | for (i = 0; i < pool->base.clk_src_count; i++) { | |
1167 | if (pool->base.clock_sources[i] != NULL) { | |
1168 | dcn20_clock_source_destroy(&pool->base.clock_sources[i]); | |
1169 | pool->base.clock_sources[i] = NULL; | |
1170 | } | |
1171 | } | |
1172 | ||
1173 | if (pool->base.dp_clock_source != NULL) { | |
1174 | dcn20_clock_source_destroy(&pool->base.dp_clock_source); | |
1175 | pool->base.dp_clock_source = NULL; | |
1176 | } | |
1177 | ||
1178 | ||
1179 | if (pool->base.abm != NULL) | |
1180 | dce_abm_destroy(&pool->base.abm); | |
1181 | ||
1182 | if (pool->base.dmcu != NULL) | |
1183 | dce_dmcu_destroy(&pool->base.dmcu); | |
1184 | ||
1185 | if (pool->base.dccg != NULL) | |
1186 | dcn_dccg_destroy(&pool->base.dccg); | |
1187 | ||
1188 | if (pool->base.pp_smu != NULL) | |
1189 | dcn20_pp_smu_destroy(&pool->base.pp_smu); | |
1190 | ||
98ce7d32 WL |
1191 | if (pool->base.oem_device != NULL) { |
1192 | struct dc *dc = pool->base.oem_device->ctx->dc; | |
1193 | ||
1194 | dc->link_srv->destroy_ddc_service(&pool->base.oem_device); | |
1195 | } | |
7ed4e635 HW |
1196 | } |
1197 | ||
1198 | struct hubp *dcn20_hubp_create( | |
1199 | struct dc_context *ctx, | |
1200 | uint32_t inst) | |
1201 | { | |
1202 | struct dcn20_hubp *hubp2 = | |
3bb11050 | 1203 | kzalloc(sizeof(struct dcn20_hubp), GFP_ATOMIC); |
7ed4e635 HW |
1204 | |
1205 | if (!hubp2) | |
1206 | return NULL; | |
1207 | ||
1208 | if (hubp2_construct(hubp2, ctx, inst, | |
1209 | &hubp_regs[inst], &hubp_shift, &hubp_mask)) | |
1210 | return &hubp2->base; | |
1211 | ||
1212 | BREAK_TO_DEBUGGER(); | |
1213 | kfree(hubp2); | |
1214 | return NULL; | |
1215 | } | |
1216 | ||
1217 | static void get_pixel_clock_parameters( | |
1218 | struct pipe_ctx *pipe_ctx, | |
1219 | struct pixel_clk_params *pixel_clk_params) | |
1220 | { | |
1221 | const struct dc_stream_state *stream = pipe_ctx->stream; | |
b1f6d01c DL |
1222 | struct pipe_ctx *odm_pipe; |
1223 | int opp_cnt = 1; | |
64d283cb JK |
1224 | struct dc_link *link = stream->link; |
1225 | struct link_encoder *link_enc = NULL; | |
88ef4c5b ST |
1226 | struct dc *dc = pipe_ctx->stream->ctx->dc; |
1227 | struct dce_hwseq *hws = dc->hwseq; | |
b1f6d01c DL |
1228 | |
1229 | for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) | |
1230 | opp_cnt++; | |
7ed4e635 HW |
1231 | |
1232 | pixel_clk_params->requested_pix_clk_100hz = stream->timing.pix_clk_100hz; | |
64d283cb | 1233 | |
66d58bf7 | 1234 | link_enc = link_enc_cfg_get_link_enc(link); |
64d283cb JK |
1235 | if (link_enc) |
1236 | pixel_clk_params->encoder_object_id = link_enc->id; | |
0c7ea6f8 | 1237 | |
7ed4e635 HW |
1238 | pixel_clk_params->signal_type = pipe_ctx->stream->signal; |
1239 | pixel_clk_params->controller_id = pipe_ctx->stream_res.tg->inst + 1; | |
1240 | /* TODO: un-hardcode*/ | |
f01ee019 | 1241 | /* TODO - DP2.0 HW: calculate requested_sym_clk for UHBR rates */ |
7ed4e635 HW |
1242 | pixel_clk_params->requested_sym_clk = LINK_RATE_LOW * |
1243 | LINK_RATE_REF_FREQ_IN_KHZ; | |
1244 | pixel_clk_params->flags.ENABLE_SS = 0; | |
1245 | pixel_clk_params->color_depth = | |
1246 | stream->timing.display_color_depth; | |
1247 | pixel_clk_params->flags.DISPLAY_BLANKED = 1; | |
1248 | pixel_clk_params->pixel_encoding = stream->timing.pixel_encoding; | |
1249 | ||
1250 | if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422) | |
1251 | pixel_clk_params->color_depth = COLOR_DEPTH_888; | |
1252 | ||
b1f6d01c DL |
1253 | if (opp_cnt == 4) |
1254 | pixel_clk_params->requested_pix_clk_100hz /= 4; | |
78c77382 | 1255 | else if (optc2_is_two_pixels_per_containter(&stream->timing) || opp_cnt == 2) |
7ed4e635 | 1256 | pixel_clk_params->requested_pix_clk_100hz /= 2; |
88ef4c5b ST |
1257 | else if (hws->funcs.is_dp_dig_pixel_rate_div_policy) { |
1258 | if (hws->funcs.is_dp_dig_pixel_rate_div_policy(pipe_ctx)) | |
1259 | pixel_clk_params->requested_pix_clk_100hz /= 2; | |
1260 | } | |
1261 | ||
7ed4e635 HW |
1262 | if (stream->timing.timing_3d_format == TIMING_3D_FORMAT_HW_FRAME_PACKING) |
1263 | pixel_clk_params->requested_pix_clk_100hz *= 2; | |
1264 | ||
1265 | } | |
1266 | ||
1267 | static void build_clamping_params(struct dc_stream_state *stream) | |
1268 | { | |
1269 | stream->clamping.clamping_level = CLAMPING_FULL_RANGE; | |
1270 | stream->clamping.c_depth = stream->timing.display_color_depth; | |
1271 | stream->clamping.pixel_encoding = stream->timing.pixel_encoding; | |
1272 | } | |
1273 | ||
cfab8038 | 1274 | void dcn20_build_pipe_pix_clk_params(struct pipe_ctx *pipe_ctx) |
7ed4e635 | 1275 | { |
7ed4e635 | 1276 | get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->stream_res.pix_clk_params); |
7ed4e635 | 1277 | pipe_ctx->clock_source->funcs->get_pix_clk_dividers( |
cfab8038 WL |
1278 | pipe_ctx->clock_source, |
1279 | &pipe_ctx->stream_res.pix_clk_params, | |
1280 | &pipe_ctx->pll_settings); | |
1281 | } | |
1282 | ||
1283 | static enum dc_status build_pipe_hw_param(struct pipe_ctx *pipe_ctx) | |
1284 | { | |
1285 | ||
1286 | dcn20_build_pipe_pix_clk_params(pipe_ctx); | |
7ed4e635 HW |
1287 | |
1288 | pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding; | |
1289 | ||
1290 | resource_build_bit_depth_reduction_params(pipe_ctx->stream, | |
1291 | &pipe_ctx->stream->bit_depth_params); | |
1292 | build_clamping_params(pipe_ctx->stream); | |
1293 | ||
1294 | return DC_OK; | |
1295 | } | |
1296 | ||
1297 | enum dc_status dcn20_build_mapped_resource(const struct dc *dc, struct dc_state *context, struct dc_stream_state *stream) | |
1298 | { | |
1299 | enum dc_status status = DC_OK; | |
53f32880 | 1300 | struct pipe_ctx *pipe_ctx = resource_get_otg_master_for_stream(&context->res_ctx, stream); |
7ed4e635 | 1301 | |
7ed4e635 HW |
1302 | if (!pipe_ctx) |
1303 | return DC_ERROR_UNEXPECTED; | |
1304 | ||
1305 | ||
1306 | status = build_pipe_hw_param(pipe_ctx); | |
1307 | ||
1308 | return status; | |
1309 | } | |
1310 | ||
97bda032 | 1311 | |
570bc18c | 1312 | void dcn20_acquire_dsc(const struct dc *dc, |
14e49bb3 | 1313 | struct resource_context *res_ctx, |
eab4bb97 NC |
1314 | struct display_stream_compressor **dsc, |
1315 | int pipe_idx) | |
97bda032 HW |
1316 | { |
1317 | int i; | |
14e49bb3 NC |
1318 | const struct resource_pool *pool = dc->res_pool; |
1319 | struct display_stream_compressor *dsc_old = dc->current_state->res_ctx.pipe_ctx[pipe_idx].stream_res.dsc; | |
c9ae6e16 | 1320 | |
14e49bb3 | 1321 | ASSERT(*dsc == NULL); /* If this ASSERT fails, dsc was not released properly */ |
c9ae6e16 | 1322 | *dsc = NULL; |
97bda032 | 1323 | |
14e49bb3 | 1324 | /* Always do 1-to-1 mapping when number of DSCs is same as number of pipes */ |
eab4bb97 NC |
1325 | if (pool->res_cap->num_dsc == pool->res_cap->num_opp) { |
1326 | *dsc = pool->dscs[pipe_idx]; | |
1327 | res_ctx->is_dsc_acquired[pipe_idx] = true; | |
1328 | return; | |
1329 | } | |
1330 | ||
14e49bb3 NC |
1331 | /* Return old DSC to avoid the need for re-programming */ |
1332 | if (dsc_old && !res_ctx->is_dsc_acquired[dsc_old->inst]) { | |
1333 | *dsc = dsc_old; | |
1334 | res_ctx->is_dsc_acquired[dsc_old->inst] = true; | |
1335 | return ; | |
1336 | } | |
1337 | ||
97bda032 HW |
1338 | /* Find first free DSC */ |
1339 | for (i = 0; i < pool->res_cap->num_dsc; i++) | |
1340 | if (!res_ctx->is_dsc_acquired[i]) { | |
c9ae6e16 | 1341 | *dsc = pool->dscs[i]; |
97bda032 HW |
1342 | res_ctx->is_dsc_acquired[i] = true; |
1343 | break; | |
1344 | } | |
97bda032 HW |
1345 | } |
1346 | ||
7287a675 | 1347 | void dcn20_release_dsc(struct resource_context *res_ctx, |
97bda032 | 1348 | const struct resource_pool *pool, |
c9ae6e16 | 1349 | struct display_stream_compressor **dsc) |
97bda032 HW |
1350 | { |
1351 | int i; | |
1352 | ||
1353 | for (i = 0; i < pool->res_cap->num_dsc; i++) | |
c9ae6e16 | 1354 | if (pool->dscs[i] == *dsc) { |
97bda032 | 1355 | res_ctx->is_dsc_acquired[i] = false; |
c9ae6e16 | 1356 | *dsc = NULL; |
97bda032 HW |
1357 | break; |
1358 | } | |
1359 | } | |
1360 | ||
7ed4e635 | 1361 | |
7ed4e635 | 1362 | |
8c20a1ed | 1363 | enum dc_status dcn20_add_dsc_to_stream_resource(struct dc *dc, |
c9ae6e16 NC |
1364 | struct dc_state *dc_ctx, |
1365 | struct dc_stream_state *dc_stream) | |
1366 | { | |
1367 | enum dc_status result = DC_OK; | |
1368 | int i; | |
97bda032 | 1369 | |
c9ae6e16 NC |
1370 | /* Get a DSC if required and available */ |
1371 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | |
1372 | struct pipe_ctx *pipe_ctx = &dc_ctx->res_ctx.pipe_ctx[i]; | |
97bda032 | 1373 | |
2e68ad8f BL |
1374 | if (pipe_ctx->top_pipe) |
1375 | continue; | |
1376 | ||
c9ae6e16 NC |
1377 | if (pipe_ctx->stream != dc_stream) |
1378 | continue; | |
97bda032 | 1379 | |
8c20a1ed DF |
1380 | if (pipe_ctx->stream_res.dsc) |
1381 | continue; | |
1382 | ||
570bc18c | 1383 | dcn20_acquire_dsc(dc, &dc_ctx->res_ctx, &pipe_ctx->stream_res.dsc, i); |
97bda032 | 1384 | |
c9ae6e16 NC |
1385 | /* The number of DSCs can be less than the number of pipes */ |
1386 | if (!pipe_ctx->stream_res.dsc) { | |
c9ae6e16 | 1387 | result = DC_NO_DSC_RESOURCE; |
97bda032 | 1388 | } |
7ed4e635 | 1389 | |
c9ae6e16 NC |
1390 | break; |
1391 | } | |
7ed4e635 HW |
1392 | |
1393 | return result; | |
1394 | } | |
1395 | ||
1396 | ||
ba32c50f | 1397 | static enum dc_status remove_dsc_from_stream_resource(struct dc *dc, |
c9ae6e16 NC |
1398 | struct dc_state *new_ctx, |
1399 | struct dc_stream_state *dc_stream) | |
7ed4e635 HW |
1400 | { |
1401 | struct pipe_ctx *pipe_ctx = NULL; | |
1402 | int i; | |
1403 | ||
7ed4e635 HW |
1404 | for (i = 0; i < MAX_PIPES; i++) { |
1405 | if (new_ctx->res_ctx.pipe_ctx[i].stream == dc_stream && !new_ctx->res_ctx.pipe_ctx[i].top_pipe) { | |
1406 | pipe_ctx = &new_ctx->res_ctx.pipe_ctx[i]; | |
b1f6d01c DL |
1407 | |
1408 | if (pipe_ctx->stream_res.dsc) | |
7287a675 | 1409 | dcn20_release_dsc(&new_ctx->res_ctx, dc->res_pool, &pipe_ctx->stream_res.dsc); |
7ed4e635 HW |
1410 | } |
1411 | } | |
1412 | ||
1413 | if (!pipe_ctx) | |
1414 | return DC_ERROR_UNEXPECTED; | |
b1f6d01c DL |
1415 | else |
1416 | return DC_OK; | |
7ed4e635 | 1417 | } |
c9ae6e16 NC |
1418 | |
1419 | ||
1420 | enum dc_status dcn20_add_stream_to_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream) | |
1421 | { | |
1422 | enum dc_status result = DC_ERROR_UNEXPECTED; | |
1423 | ||
1424 | result = resource_map_pool_resources(dc, new_ctx, dc_stream); | |
1425 | ||
1426 | if (result == DC_OK) | |
1427 | result = resource_map_phy_clock_resources(dc, new_ctx, dc_stream); | |
1428 | ||
c9ae6e16 NC |
1429 | /* Get a DSC if required and available */ |
1430 | if (result == DC_OK && dc_stream->timing.flags.DSC) | |
8c20a1ed | 1431 | result = dcn20_add_dsc_to_stream_resource(dc, new_ctx, dc_stream); |
c9ae6e16 NC |
1432 | |
1433 | if (result == DC_OK) | |
1434 | result = dcn20_build_mapped_resource(dc, new_ctx, dc_stream); | |
1435 | ||
1436 | return result; | |
1437 | } | |
1438 | ||
1439 | ||
1440 | enum dc_status dcn20_remove_stream_from_ctx(struct dc *dc, struct dc_state *new_ctx, struct dc_stream_state *dc_stream) | |
1441 | { | |
1442 | enum dc_status result = DC_OK; | |
1443 | ||
ba32c50f | 1444 | result = remove_dsc_from_stream_resource(dc, new_ctx, dc_stream); |
c9ae6e16 NC |
1445 | |
1446 | return result; | |
1447 | } | |
7ed4e635 | 1448 | |
a6126e14 RS |
1449 | /** |
1450 | * dcn20_split_stream_for_odm - Check if stream can be splited for ODM | |
1451 | * | |
1452 | * @dc: DC object with resource pool info required for pipe split | |
1453 | * @res_ctx: Persistent state of resources | |
1454 | * @prev_odm_pipe: Reference to the previous ODM pipe | |
1455 | * @next_odm_pipe: Reference to the next ODM pipe | |
1456 | * | |
1457 | * This function takes a logically active pipe and a logically free pipe and | |
1458 | * halves all the scaling parameters that need to be halved while populating | |
1459 | * the free pipe with the required resources and configuring the next/previous | |
1460 | * ODM pipe pointers. | |
1461 | * | |
1462 | * Return: | |
1463 | * Return true if split stream for ODM is possible, otherwise, return false. | |
1464 | */ | |
b6bfba6c | 1465 | bool dcn20_split_stream_for_odm( |
14e49bb3 | 1466 | const struct dc *dc, |
b1f6d01c | 1467 | struct resource_context *res_ctx, |
b1f6d01c DL |
1468 | struct pipe_ctx *prev_odm_pipe, |
1469 | struct pipe_ctx *next_odm_pipe) | |
1470 | { | |
1471 | int pipe_idx = next_odm_pipe->pipe_idx; | |
14e49bb3 | 1472 | const struct resource_pool *pool = dc->res_pool; |
b1f6d01c DL |
1473 | |
1474 | *next_odm_pipe = *prev_odm_pipe; | |
b1f6d01c DL |
1475 | |
1476 | next_odm_pipe->pipe_idx = pipe_idx; | |
1477 | next_odm_pipe->plane_res.mi = pool->mis[next_odm_pipe->pipe_idx]; | |
1478 | next_odm_pipe->plane_res.hubp = pool->hubps[next_odm_pipe->pipe_idx]; | |
1479 | next_odm_pipe->plane_res.ipp = pool->ipps[next_odm_pipe->pipe_idx]; | |
1480 | next_odm_pipe->plane_res.xfm = pool->transforms[next_odm_pipe->pipe_idx]; | |
1481 | next_odm_pipe->plane_res.dpp = pool->dpps[next_odm_pipe->pipe_idx]; | |
1482 | next_odm_pipe->plane_res.mpcc_inst = pool->dpps[next_odm_pipe->pipe_idx]->inst; | |
b1f6d01c | 1483 | next_odm_pipe->stream_res.dsc = NULL; |
b1f6d01c | 1484 | if (prev_odm_pipe->next_odm_pipe && prev_odm_pipe->next_odm_pipe != next_odm_pipe) { |
b1f6d01c DL |
1485 | next_odm_pipe->next_odm_pipe = prev_odm_pipe->next_odm_pipe; |
1486 | next_odm_pipe->next_odm_pipe->prev_odm_pipe = next_odm_pipe; | |
1487 | } | |
2e7b43e6 DL |
1488 | if (prev_odm_pipe->top_pipe && prev_odm_pipe->top_pipe->next_odm_pipe) { |
1489 | prev_odm_pipe->top_pipe->next_odm_pipe->bottom_pipe = next_odm_pipe; | |
1490 | next_odm_pipe->top_pipe = prev_odm_pipe->top_pipe->next_odm_pipe; | |
1491 | } | |
1492 | if (prev_odm_pipe->bottom_pipe && prev_odm_pipe->bottom_pipe->next_odm_pipe) { | |
1493 | prev_odm_pipe->bottom_pipe->next_odm_pipe->top_pipe = next_odm_pipe; | |
1494 | next_odm_pipe->bottom_pipe = prev_odm_pipe->bottom_pipe->next_odm_pipe; | |
1495 | } | |
b1f6d01c DL |
1496 | prev_odm_pipe->next_odm_pipe = next_odm_pipe; |
1497 | next_odm_pipe->prev_odm_pipe = prev_odm_pipe; | |
b1f6d01c DL |
1498 | |
1499 | if (prev_odm_pipe->plane_state) { | |
c0358809 DL |
1500 | struct scaler_data *sd = &prev_odm_pipe->plane_res.scl_data; |
1501 | int new_width; | |
1502 | ||
b1f6d01c DL |
1503 | /* HACTIVE halved for odm combine */ |
1504 | sd->h_active /= 2; | |
b1f6d01c DL |
1505 | /* Calculate new vp and recout for left pipe */ |
1506 | /* Need at least 16 pixels width per side */ | |
1507 | if (sd->recout.x + 16 >= sd->h_active) | |
1508 | return false; | |
1509 | new_width = sd->h_active - sd->recout.x; | |
1510 | sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int( | |
1511 | sd->ratios.horz, sd->recout.width - new_width)); | |
1512 | sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int( | |
1513 | sd->ratios.horz_c, sd->recout.width - new_width)); | |
1514 | sd->recout.width = new_width; | |
1515 | ||
1516 | /* Calculate new vp and recout for right pipe */ | |
1517 | sd = &next_odm_pipe->plane_res.scl_data; | |
c0358809 DL |
1518 | /* HACTIVE halved for odm combine */ |
1519 | sd->h_active /= 2; | |
b1f6d01c DL |
1520 | /* Need at least 16 pixels width per side */ |
1521 | if (new_width <= 16) | |
1522 | return false; | |
c0358809 | 1523 | new_width = sd->recout.width + sd->recout.x - sd->h_active; |
b1f6d01c DL |
1524 | sd->viewport.width -= dc_fixpt_floor(dc_fixpt_mul_int( |
1525 | sd->ratios.horz, sd->recout.width - new_width)); | |
1526 | sd->viewport_c.width -= dc_fixpt_floor(dc_fixpt_mul_int( | |
1527 | sd->ratios.horz_c, sd->recout.width - new_width)); | |
1528 | sd->recout.width = new_width; | |
1529 | sd->viewport.x += dc_fixpt_floor(dc_fixpt_mul_int( | |
1530 | sd->ratios.horz, sd->h_active - sd->recout.x)); | |
1531 | sd->viewport_c.x += dc_fixpt_floor(dc_fixpt_mul_int( | |
1532 | sd->ratios.horz_c, sd->h_active - sd->recout.x)); | |
1533 | sd->recout.x = 0; | |
1534 | } | |
2e7b43e6 DL |
1535 | if (!next_odm_pipe->top_pipe) |
1536 | next_odm_pipe->stream_res.opp = pool->opps[next_odm_pipe->pipe_idx]; | |
1537 | else | |
1538 | next_odm_pipe->stream_res.opp = next_odm_pipe->top_pipe->stream_res.opp; | |
73d48f08 | 1539 | if (next_odm_pipe->stream->timing.flags.DSC == 1 && !next_odm_pipe->top_pipe) { |
570bc18c | 1540 | dcn20_acquire_dsc(dc, res_ctx, &next_odm_pipe->stream_res.dsc, next_odm_pipe->pipe_idx); |
b1f6d01c DL |
1541 | ASSERT(next_odm_pipe->stream_res.dsc); |
1542 | if (next_odm_pipe->stream_res.dsc == NULL) | |
1543 | return false; | |
1544 | } | |
b1f6d01c DL |
1545 | |
1546 | return true; | |
1547 | } | |
1548 | ||
65d68369 | 1549 | void dcn20_split_stream_for_mpc( |
7ed4e635 HW |
1550 | struct resource_context *res_ctx, |
1551 | const struct resource_pool *pool, | |
1552 | struct pipe_ctx *primary_pipe, | |
b1f6d01c | 1553 | struct pipe_ctx *secondary_pipe) |
7ed4e635 HW |
1554 | { |
1555 | int pipe_idx = secondary_pipe->pipe_idx; | |
7ed4e635 | 1556 | struct pipe_ctx *sec_bot_pipe = secondary_pipe->bottom_pipe; |
7ed4e635 HW |
1557 | |
1558 | *secondary_pipe = *primary_pipe; | |
1559 | secondary_pipe->bottom_pipe = sec_bot_pipe; | |
1560 | ||
1561 | secondary_pipe->pipe_idx = pipe_idx; | |
1562 | secondary_pipe->plane_res.mi = pool->mis[secondary_pipe->pipe_idx]; | |
1563 | secondary_pipe->plane_res.hubp = pool->hubps[secondary_pipe->pipe_idx]; | |
1564 | secondary_pipe->plane_res.ipp = pool->ipps[secondary_pipe->pipe_idx]; | |
1565 | secondary_pipe->plane_res.xfm = pool->transforms[secondary_pipe->pipe_idx]; | |
1566 | secondary_pipe->plane_res.dpp = pool->dpps[secondary_pipe->pipe_idx]; | |
1567 | secondary_pipe->plane_res.mpcc_inst = pool->dpps[secondary_pipe->pipe_idx]->inst; | |
c92b4c46 | 1568 | secondary_pipe->stream_res.dsc = NULL; |
7ed4e635 HW |
1569 | if (primary_pipe->bottom_pipe && primary_pipe->bottom_pipe != secondary_pipe) { |
1570 | ASSERT(!secondary_pipe->bottom_pipe); | |
1571 | secondary_pipe->bottom_pipe = primary_pipe->bottom_pipe; | |
1572 | secondary_pipe->bottom_pipe->top_pipe = secondary_pipe; | |
1573 | } | |
1574 | primary_pipe->bottom_pipe = secondary_pipe; | |
1575 | secondary_pipe->top_pipe = primary_pipe; | |
1576 | ||
b1f6d01c | 1577 | ASSERT(primary_pipe->plane_state); |
7ed4e635 HW |
1578 | } |
1579 | ||
7ed4e635 HW |
1580 | unsigned int dcn20_calc_max_scaled_time( |
1581 | unsigned int time_per_pixel, | |
1582 | enum mmhubbub_wbif_mode mode, | |
1583 | unsigned int urgent_watermark) | |
1584 | { | |
1585 | unsigned int time_per_byte = 0; | |
1586 | unsigned int total_y_free_entry = 0x200; /* two memory piece for luma */ | |
1587 | unsigned int total_c_free_entry = 0x140; /* two memory piece for chroma */ | |
1588 | unsigned int small_free_entry, max_free_entry; | |
1589 | unsigned int buf_lh_capability; | |
1590 | unsigned int max_scaled_time; | |
1591 | ||
1592 | if (mode == PACKED_444) /* packed mode */ | |
1593 | time_per_byte = time_per_pixel/4; | |
1594 | else if (mode == PLANAR_420_8BPC) | |
1595 | time_per_byte = time_per_pixel; | |
1596 | else if (mode == PLANAR_420_10BPC) /* p010 */ | |
1597 | time_per_byte = time_per_pixel * 819/1024; | |
1598 | ||
1599 | if (time_per_byte == 0) | |
1600 | time_per_byte = 1; | |
1601 | ||
1602 | small_free_entry = (total_y_free_entry > total_c_free_entry) ? total_c_free_entry : total_y_free_entry; | |
1603 | max_free_entry = (mode == PACKED_444) ? total_y_free_entry + total_c_free_entry : small_free_entry; | |
1604 | buf_lh_capability = max_free_entry*time_per_byte*32/16; /* there is 4bit fraction */ | |
1605 | max_scaled_time = buf_lh_capability - urgent_watermark; | |
1606 | return max_scaled_time; | |
1607 | } | |
1608 | ||
1609 | void dcn20_set_mcif_arb_params( | |
1610 | struct dc *dc, | |
1611 | struct dc_state *context, | |
1612 | display_e2e_pipe_params_st *pipes, | |
1613 | int pipe_cnt) | |
1614 | { | |
1615 | enum mmhubbub_wbif_mode wbif_mode; | |
1616 | struct mcif_arb_params *wb_arb_params; | |
cf689e86 | 1617 | int i, j, dwb_pipe; |
7ed4e635 HW |
1618 | |
1619 | /* Writeback MCIF_WB arbitration parameters */ | |
1620 | dwb_pipe = 0; | |
1621 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | |
1622 | ||
1623 | if (!context->res_ctx.pipe_ctx[i].stream) | |
1624 | continue; | |
1625 | ||
1626 | for (j = 0; j < MAX_DWB_PIPES; j++) { | |
1627 | if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].wb_enabled == false) | |
1628 | continue; | |
1629 | ||
1630 | //wb_arb_params = &context->res_ctx.pipe_ctx[i].stream->writeback_info[j].mcif_arb_params; | |
1631 | wb_arb_params = &context->bw_ctx.bw.dcn.bw_writeback.mcif_wb_arb[dwb_pipe]; | |
1632 | ||
1633 | if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].dwb_params.out_format == dwb_scaler_mode_yuv420) { | |
1634 | if (context->res_ctx.pipe_ctx[i].stream->writeback_info[j].dwb_params.output_depth == DWB_OUTPUT_PIXEL_DEPTH_8BPC) | |
1635 | wbif_mode = PLANAR_420_8BPC; | |
1636 | else | |
1637 | wbif_mode = PLANAR_420_10BPC; | |
1638 | } else | |
1639 | wbif_mode = PACKED_444; | |
1640 | ||
cf689e86 MW |
1641 | DC_FP_START(); |
1642 | dcn20_fpu_set_wb_arb_params(wb_arb_params, context, pipes, pipe_cnt, i); | |
1643 | DC_FP_END(); | |
1644 | ||
7ed4e635 HW |
1645 | wb_arb_params->slice_lines = 32; |
1646 | wb_arb_params->arbitration_slice = 2; | |
1647 | wb_arb_params->max_scaled_time = dcn20_calc_max_scaled_time(wb_arb_params->time_per_pixel, | |
1648 | wbif_mode, | |
1649 | wb_arb_params->cli_watermark[0]); /* assume 4 watermark sets have the same value */ | |
1650 | ||
1651 | dwb_pipe++; | |
1652 | ||
1653 | if (dwb_pipe >= MAX_DWB_PIPES) | |
1654 | return; | |
1655 | } | |
1656 | if (dwb_pipe >= MAX_DWB_PIPES) | |
1657 | return; | |
1658 | } | |
1659 | } | |
1660 | ||
b6bfba6c | 1661 | bool dcn20_validate_dsc(struct dc *dc, struct dc_state *new_ctx) |
0ba37b20 DL |
1662 | { |
1663 | int i; | |
1664 | ||
1665 | /* Validate DSC config, dsc count validation is already done */ | |
1666 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | |
1667 | struct pipe_ctx *pipe_ctx = &new_ctx->res_ctx.pipe_ctx[i]; | |
1668 | struct dc_stream_state *stream = pipe_ctx->stream; | |
1669 | struct dsc_config dsc_cfg; | |
b1f6d01c DL |
1670 | struct pipe_ctx *odm_pipe; |
1671 | int opp_cnt = 1; | |
1672 | ||
1673 | for (odm_pipe = pipe_ctx->next_odm_pipe; odm_pipe; odm_pipe = odm_pipe->next_odm_pipe) | |
1674 | opp_cnt++; | |
0ba37b20 DL |
1675 | |
1676 | /* Only need to validate top pipe */ | |
b1f6d01c | 1677 | if (pipe_ctx->top_pipe || pipe_ctx->prev_odm_pipe || !stream || !stream->timing.flags.DSC) |
0ba37b20 DL |
1678 | continue; |
1679 | ||
b1f6d01c DL |
1680 | dsc_cfg.pic_width = (stream->timing.h_addressable + stream->timing.h_border_left |
1681 | + stream->timing.h_border_right) / opp_cnt; | |
0ba37b20 DL |
1682 | dsc_cfg.pic_height = stream->timing.v_addressable + stream->timing.v_border_top |
1683 | + stream->timing.v_border_bottom; | |
0ba37b20 DL |
1684 | dsc_cfg.pixel_encoding = stream->timing.pixel_encoding; |
1685 | dsc_cfg.color_depth = stream->timing.display_color_depth; | |
df8e34ac | 1686 | dsc_cfg.is_odm = pipe_ctx->next_odm_pipe ? true : false; |
0ba37b20 | 1687 | dsc_cfg.dc_dsc_cfg = stream->timing.dsc_cfg; |
b1f6d01c | 1688 | dsc_cfg.dc_dsc_cfg.num_slices_h /= opp_cnt; |
0ba37b20 DL |
1689 | |
1690 | if (!pipe_ctx->stream_res.dsc->funcs->dsc_validate_stream(pipe_ctx->stream_res.dsc, &dsc_cfg)) | |
1691 | return false; | |
1692 | } | |
1693 | return true; | |
1694 | } | |
0ba37b20 | 1695 | |
b6bfba6c | 1696 | struct pipe_ctx *dcn20_find_secondary_pipe(struct dc *dc, |
c681491a JL |
1697 | struct resource_context *res_ctx, |
1698 | const struct resource_pool *pool, | |
1699 | const struct pipe_ctx *primary_pipe) | |
1700 | { | |
1701 | struct pipe_ctx *secondary_pipe = NULL; | |
1702 | ||
1703 | if (dc && primary_pipe) { | |
1704 | int j; | |
1705 | int preferred_pipe_idx = 0; | |
1706 | ||
1707 | /* first check the prev dc state: | |
1708 | * if this primary pipe has a bottom pipe in prev. state | |
1709 | * and if the bottom pipe is still available (which it should be), | |
1710 | * pick that pipe as secondary | |
7a214cd8 | 1711 | * Same logic applies for ODM pipes |
c681491a | 1712 | */ |
324b1fcb | 1713 | if (dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].next_odm_pipe) { |
1714 | preferred_pipe_idx = dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].next_odm_pipe->pipe_idx; | |
c681491a JL |
1715 | if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) { |
1716 | secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx]; | |
1717 | secondary_pipe->pipe_idx = preferred_pipe_idx; | |
1718 | } | |
7a214cd8 SL |
1719 | } |
1720 | if (secondary_pipe == NULL && | |
324b1fcb | 1721 | dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].bottom_pipe) { |
1722 | preferred_pipe_idx = dc->current_state->res_ctx.pipe_ctx[primary_pipe->pipe_idx].bottom_pipe->pipe_idx; | |
b1f6d01c DL |
1723 | if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) { |
1724 | secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx]; | |
1725 | secondary_pipe->pipe_idx = preferred_pipe_idx; | |
1726 | } | |
c681491a JL |
1727 | } |
1728 | ||
1729 | /* | |
1730 | * if this primary pipe does not have a bottom pipe in prev. state | |
1731 | * start backward and find a pipe that did not used to be a bottom pipe in | |
1732 | * prev. dc state. This way we make sure we keep the same assignment as | |
1733 | * last state and will not have to reprogram every pipe | |
1734 | */ | |
1735 | if (secondary_pipe == NULL) { | |
1736 | for (j = dc->res_pool->pipe_count - 1; j >= 0; j--) { | |
8b8eda01 DL |
1737 | if (dc->current_state->res_ctx.pipe_ctx[j].top_pipe == NULL |
1738 | && dc->current_state->res_ctx.pipe_ctx[j].prev_odm_pipe == NULL) { | |
c681491a JL |
1739 | preferred_pipe_idx = j; |
1740 | ||
1741 | if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) { | |
1742 | secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx]; | |
1743 | secondary_pipe->pipe_idx = preferred_pipe_idx; | |
1744 | break; | |
1745 | } | |
1746 | } | |
1747 | } | |
1748 | } | |
1749 | /* | |
1750 | * We should never hit this assert unless assignments are shuffled around | |
1751 | * if this happens we will prob. hit a vsync tdr | |
1752 | */ | |
1753 | ASSERT(secondary_pipe); | |
1754 | /* | |
1755 | * search backwards for the second pipe to keep pipe | |
1756 | * assignment more consistent | |
1757 | */ | |
1758 | if (secondary_pipe == NULL) { | |
1759 | for (j = dc->res_pool->pipe_count - 1; j >= 0; j--) { | |
1760 | preferred_pipe_idx = j; | |
1761 | ||
1762 | if (res_ctx->pipe_ctx[preferred_pipe_idx].stream == NULL) { | |
1763 | secondary_pipe = &res_ctx->pipe_ctx[preferred_pipe_idx]; | |
1764 | secondary_pipe->pipe_idx = preferred_pipe_idx; | |
1765 | break; | |
1766 | } | |
1767 | } | |
1768 | } | |
1769 | } | |
1770 | ||
1771 | return secondary_pipe; | |
1772 | } | |
1773 | ||
ea817dd5 | 1774 | void dcn20_merge_pipes_for_validate( |
6de20237 | 1775 | struct dc *dc, |
b6bfba6c | 1776 | struct dc_state *context) |
7ed4e635 | 1777 | { |
b6bfba6c | 1778 | int i; |
7ed4e635 | 1779 | |
b1f6d01c DL |
1780 | /* merge previously split odm pipes since mode support needs to make the decision */ |
1781 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | |
1782 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; | |
1783 | struct pipe_ctx *odm_pipe = pipe->next_odm_pipe; | |
1784 | ||
1785 | if (pipe->prev_odm_pipe) | |
1786 | continue; | |
1787 | ||
1788 | pipe->next_odm_pipe = NULL; | |
1789 | while (odm_pipe) { | |
1790 | struct pipe_ctx *next_odm_pipe = odm_pipe->next_odm_pipe; | |
1791 | ||
1792 | odm_pipe->plane_state = NULL; | |
1793 | odm_pipe->stream = NULL; | |
1794 | odm_pipe->top_pipe = NULL; | |
1795 | odm_pipe->bottom_pipe = NULL; | |
1796 | odm_pipe->prev_odm_pipe = NULL; | |
1797 | odm_pipe->next_odm_pipe = NULL; | |
b1f6d01c | 1798 | if (odm_pipe->stream_res.dsc) |
7287a675 | 1799 | dcn20_release_dsc(&context->res_ctx, dc->res_pool, &odm_pipe->stream_res.dsc); |
b1f6d01c DL |
1800 | /* Clear plane_res and stream_res */ |
1801 | memset(&odm_pipe->plane_res, 0, sizeof(odm_pipe->plane_res)); | |
1802 | memset(&odm_pipe->stream_res, 0, sizeof(odm_pipe->stream_res)); | |
1803 | odm_pipe = next_odm_pipe; | |
1804 | } | |
1805 | if (pipe->plane_state) | |
1806 | resource_build_scaling_params(pipe); | |
1807 | } | |
1808 | ||
1809 | /* merge previously mpc split pipes since mode support needs to make the decision */ | |
7ed4e635 HW |
1810 | for (i = 0; i < dc->res_pool->pipe_count; i++) { |
1811 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; | |
1812 | struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe; | |
1813 | ||
1814 | if (!hsplit_pipe || hsplit_pipe->plane_state != pipe->plane_state) | |
1815 | continue; | |
1816 | ||
7ed4e635 HW |
1817 | pipe->bottom_pipe = hsplit_pipe->bottom_pipe; |
1818 | if (hsplit_pipe->bottom_pipe) | |
1819 | hsplit_pipe->bottom_pipe->top_pipe = pipe; | |
1820 | hsplit_pipe->plane_state = NULL; | |
1821 | hsplit_pipe->stream = NULL; | |
1822 | hsplit_pipe->top_pipe = NULL; | |
1823 | hsplit_pipe->bottom_pipe = NULL; | |
b1f6d01c | 1824 | |
7ed4e635 HW |
1825 | /* Clear plane_res and stream_res */ |
1826 | memset(&hsplit_pipe->plane_res, 0, sizeof(hsplit_pipe->plane_res)); | |
1827 | memset(&hsplit_pipe->stream_res, 0, sizeof(hsplit_pipe->stream_res)); | |
1828 | if (pipe->plane_state) | |
1829 | resource_build_scaling_params(pipe); | |
1830 | } | |
b6bfba6c | 1831 | } |
7ed4e635 | 1832 | |
b6bfba6c DL |
1833 | int dcn20_validate_apply_pipe_split_flags( |
1834 | struct dc *dc, | |
1835 | struct dc_state *context, | |
1836 | int vlevel, | |
65d68369 | 1837 | int *split, |
7287a675 | 1838 | bool *merge) |
b6bfba6c | 1839 | { |
b745ecdb | 1840 | int i, pipe_idx, vlevel_split; |
cd3e05a7 | 1841 | int plane_count = 0; |
b6bfba6c | 1842 | bool force_split = false; |
cd3e05a7 | 1843 | bool avoid_split = dc->debug.pipe_split_policy == MPC_SPLIT_AVOID; |
570bc18c DL |
1844 | struct vba_vars_st *v = &context->bw_ctx.dml.vba; |
1845 | int max_mpc_comb = v->maxMpcComb; | |
7ed4e635 | 1846 | |
cd3e05a7 DL |
1847 | if (context->stream_count > 1) { |
1848 | if (dc->debug.pipe_split_policy == MPC_SPLIT_AVOID_MULT_DISP) | |
1849 | avoid_split = true; | |
1850 | } else if (dc->debug.force_single_disp_pipe_split) | |
1851 | force_split = true; | |
1852 | ||
7ed4e635 HW |
1853 | for (i = 0; i < dc->res_pool->pipe_count; i++) { |
1854 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; | |
7ed4e635 | 1855 | |
b6dbb8ff NK |
1856 | /** |
1857 | * Workaround for avoiding pipe-split in cases where we'd split | |
1858 | * planes that are too small, resulting in splits that aren't | |
1859 | * valid for the scaler. | |
1860 | */ | |
1861 | if (pipe->plane_state && | |
1862 | (pipe->plane_state->dst_rect.width <= 16 || | |
1863 | pipe->plane_state->dst_rect.height <= 16 || | |
1864 | pipe->plane_state->src_rect.width <= 16 || | |
1865 | pipe->plane_state->src_rect.height <= 16)) | |
1866 | avoid_split = true; | |
1867 | ||
1868 | /* TODO: fix dc bugs and remove this split threshold thing */ | |
cd3e05a7 DL |
1869 | if (pipe->stream && !pipe->prev_odm_pipe && |
1870 | (!pipe->top_pipe || pipe->top_pipe->plane_state != pipe->plane_state)) | |
1871 | ++plane_count; | |
7ed4e635 | 1872 | } |
cd3e05a7 | 1873 | if (plane_count > dc->res_pool->pipe_count / 2) |
7ed4e635 HW |
1874 | avoid_split = true; |
1875 | ||
a0a85ac4 DZ |
1876 | /* W/A: Mode timing with borders may not work well with pipe split, avoid for this corner case */ |
1877 | for (i = 0; i < dc->res_pool->pipe_count; i++) { | |
1878 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; | |
1879 | struct dc_crtc_timing timing; | |
1880 | ||
1881 | if (!pipe->stream) | |
1882 | continue; | |
1883 | else { | |
1884 | timing = pipe->stream->timing; | |
1885 | if (timing.h_border_left + timing.h_border_right | |
1886 | + timing.v_border_top + timing.v_border_bottom > 0) { | |
1887 | avoid_split = true; | |
1888 | break; | |
1889 | } | |
1890 | } | |
1891 | } | |
1892 | ||
b745ecdb | 1893 | /* Avoid split loop looks for lowest voltage level that allows most unsplit pipes possible */ |
b6bfba6c DL |
1894 | if (avoid_split) { |
1895 | for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { | |
1896 | if (!context->res_ctx.pipe_ctx[i].stream) | |
1897 | continue; | |
1898 | ||
b745ecdb | 1899 | for (vlevel_split = vlevel; vlevel <= context->bw_ctx.dml.soc.num_states; vlevel++) |
570bc18c DL |
1900 | if (v->NoOfDPP[vlevel][0][pipe_idx] == 1 && |
1901 | v->ModeSupport[vlevel][0]) | |
b6bfba6c DL |
1902 | break; |
1903 | /* Impossible to not split this pipe */ | |
b745ecdb DL |
1904 | if (vlevel > context->bw_ctx.dml.soc.num_states) |
1905 | vlevel = vlevel_split; | |
1dfedb39 SL |
1906 | else |
1907 | max_mpc_comb = 0; | |
b6bfba6c DL |
1908 | pipe_idx++; |
1909 | } | |
570bc18c | 1910 | v->maxMpcComb = max_mpc_comb; |
b6bfba6c DL |
1911 | } |
1912 | ||
b745ecdb | 1913 | /* Split loop sets which pipe should be split based on dml outputs and dc flags */ |
7ed4e635 | 1914 | for (i = 0, pipe_idx = 0; i < dc->res_pool->pipe_count; i++) { |
b6bfba6c | 1915 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; |
570bc18c DL |
1916 | int pipe_plane = v->pipe_plane[pipe_idx]; |
1917 | bool split4mpc = context->stream_count == 1 && plane_count == 1 | |
1918 | && dc->config.enable_4to1MPC && dc->res_pool->pipe_count >= 4; | |
b6bfba6c | 1919 | |
7ed4e635 HW |
1920 | if (!context->res_ctx.pipe_ctx[i].stream) |
1921 | continue; | |
b6bfba6c | 1922 | |
4d765d31 DL |
1923 | if (split4mpc || v->NoOfDPP[vlevel][max_mpc_comb][pipe_plane] == 4) |
1924 | split[i] = 4; | |
1925 | else if (force_split || v->NoOfDPP[vlevel][max_mpc_comb][pipe_plane] == 2) | |
65d68369 | 1926 | split[i] = 2; |
4d765d31 | 1927 | |
b6bfba6c DL |
1928 | if ((pipe->stream->view_format == |
1929 | VIEW_3D_FORMAT_SIDE_BY_SIDE || | |
1930 | pipe->stream->view_format == | |
1931 | VIEW_3D_FORMAT_TOP_AND_BOTTOM) && | |
1932 | (pipe->stream->timing.timing_3d_format == | |
1933 | TIMING_3D_FORMAT_TOP_AND_BOTTOM || | |
1934 | pipe->stream->timing.timing_3d_format == | |
1935 | TIMING_3D_FORMAT_SIDE_BY_SIDE)) | |
65d68369 | 1936 | split[i] = 2; |
b6bfba6c | 1937 | if (dc->debug.force_odm_combine & (1 << pipe->stream_res.tg->inst)) { |
65d68369 | 1938 | split[i] = 2; |
570bc18c | 1939 | v->ODMCombineEnablePerState[vlevel][pipe_plane] = dm_odm_combine_mode_2to1; |
b6bfba6c | 1940 | } |
5dba4991 BL |
1941 | if (dc->debug.force_odm_combine_4to1 & (1 << pipe->stream_res.tg->inst)) { |
1942 | split[i] = 4; | |
1943 | v->ODMCombineEnablePerState[vlevel][pipe_plane] = dm_odm_combine_mode_4to1; | |
1944 | } | |
5e908012 CP |
1945 | /*420 format workaround*/ |
1946 | if (pipe->stream->timing.h_addressable > 7680 && | |
1947 | pipe->stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420) { | |
1948 | split[i] = 4; | |
1949 | } | |
570bc18c DL |
1950 | v->ODMCombineEnabled[pipe_plane] = |
1951 | v->ODMCombineEnablePerState[vlevel][pipe_plane]; | |
1952 | ||
1953 | if (v->ODMCombineEnabled[pipe_plane] == dm_odm_combine_mode_disabled) { | |
21741810 | 1954 | if (resource_get_mpc_slice_count(pipe) == 2) { |
570bc18c DL |
1955 | /*If need split for mpc but 2 way split already*/ |
1956 | if (split[i] == 4) | |
1957 | split[i] = 2; /* 2 -> 4 MPC */ | |
1958 | else if (split[i] == 2) | |
1959 | split[i] = 0; /* 2 -> 2 MPC */ | |
1960 | else if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) | |
1961 | merge[i] = true; /* 2 -> 1 MPC */ | |
21741810 | 1962 | } else if (resource_get_mpc_slice_count(pipe) == 4) { |
570bc18c DL |
1963 | /*If need split for mpc but 4 way split already*/ |
1964 | if (split[i] == 2 && ((pipe->top_pipe && !pipe->top_pipe->top_pipe) | |
1965 | || !pipe->bottom_pipe)) { | |
1966 | merge[i] = true; /* 4 -> 2 MPC */ | |
1967 | } else if (split[i] == 0 && pipe->top_pipe && | |
1968 | pipe->top_pipe->plane_state == pipe->plane_state) | |
1969 | merge[i] = true; /* 4 -> 1 MPC */ | |
65d68369 | 1970 | split[i] = 0; |
21741810 | 1971 | } else if (resource_get_odm_slice_count(pipe) > 1) { |
570bc18c | 1972 | /* ODM -> MPC transition */ |
7287a675 | 1973 | if (pipe->prev_odm_pipe) { |
570bc18c DL |
1974 | split[i] = 0; |
1975 | merge[i] = true; | |
7287a675 DL |
1976 | } |
1977 | } | |
570bc18c | 1978 | } else { |
21741810 | 1979 | if (resource_get_odm_slice_count(pipe) == 2) { |
570bc18c DL |
1980 | /*If need split for odm but 2 way split already*/ |
1981 | if (split[i] == 4) | |
1982 | split[i] = 2; /* 2 -> 4 ODM */ | |
1983 | else if (split[i] == 2) | |
1984 | split[i] = 0; /* 2 -> 2 ODM */ | |
1985 | else if (pipe->prev_odm_pipe) { | |
1986 | ASSERT(0); /* NOT expected yet */ | |
1987 | merge[i] = true; /* exit ODM */ | |
1988 | } | |
21741810 | 1989 | } else if (resource_get_odm_slice_count(pipe) == 4) { |
570bc18c DL |
1990 | /*If need split for odm but 4 way split already*/ |
1991 | if (split[i] == 2 && ((pipe->prev_odm_pipe && !pipe->prev_odm_pipe->prev_odm_pipe) | |
1992 | || !pipe->next_odm_pipe)) { | |
570bc18c DL |
1993 | merge[i] = true; /* 4 -> 2 ODM */ |
1994 | } else if (split[i] == 0 && pipe->prev_odm_pipe) { | |
1995 | ASSERT(0); /* NOT expected yet */ | |
1996 | merge[i] = true; /* exit ODM */ | |
1997 | } | |
65d68369 | 1998 | split[i] = 0; |
21741810 | 1999 | } else if (resource_get_mpc_slice_count(pipe) > 1) { |
570bc18c DL |
2000 | /* MPC -> ODM transition */ |
2001 | ASSERT(0); /* NOT expected yet */ | |
2002 | if (pipe->top_pipe && pipe->top_pipe->plane_state == pipe->plane_state) { | |
2003 | split[i] = 0; | |
2004 | merge[i] = true; | |
2005 | } | |
65d68369 | 2006 | } |
7287a675 DL |
2007 | } |
2008 | ||
b6bfba6c | 2009 | /* Adjust dppclk when split is forced, do not bother with dispclk */ |
cf689e86 MW |
2010 | if (split[i] != 0 && v->NoOfDPP[vlevel][max_mpc_comb][pipe_idx] == 1) { |
2011 | DC_FP_START(); | |
2012 | dcn20_fpu_adjust_dppclk(v, vlevel, max_mpc_comb, pipe_idx, false); | |
2013 | DC_FP_END(); | |
2014 | } | |
7ed4e635 HW |
2015 | pipe_idx++; |
2016 | } | |
2017 | ||
b6bfba6c DL |
2018 | return vlevel; |
2019 | } | |
2020 | ||
2021 | bool dcn20_fast_validate_bw( | |
2022 | struct dc *dc, | |
2023 | struct dc_state *context, | |
2024 | display_e2e_pipe_params_st *pipes, | |
2025 | int *pipe_cnt_out, | |
2026 | int *pipe_split_from, | |
fa896813 IZ |
2027 | int *vlevel_out, |
2028 | bool fast_validate) | |
b6bfba6c DL |
2029 | { |
2030 | bool out = false; | |
65d68369 | 2031 | int split[MAX_PIPES] = { 0 }; |
b6bfba6c DL |
2032 | int pipe_cnt, i, pipe_idx, vlevel; |
2033 | ||
2034 | ASSERT(pipes); | |
2035 | if (!pipes) | |
2036 | return false; | |
2037 | ||
2038 | dcn20_merge_pipes_for_validate(dc, context); | |
2039 | ||
cf689e86 | 2040 | DC_FP_START(); |
fa896813 | 2041 | pipe_cnt = dc->res_pool->funcs->populate_dml_pipes(dc, context, pipes, fast_validate); |
cf689e86 | 2042 | DC_FP_END(); |
b6bfba6c DL |
2043 | |
2044 | *pipe_cnt_out = pipe_cnt; | |
2045 | ||
2046 | if (!pipe_cnt) { | |
2047 | out = true; | |
2048 | goto validate_out; | |
2049 | } | |
2050 | ||
2051 | vlevel = dml_get_voltage_level(&context->bw_ctx.dml, pipes, pipe_cnt); | |
2052 | ||
2053 | if (vlevel > context->bw_ctx.dml.soc.num_states) | |
2054 | goto validate_fail; | |
2055 | ||
7287a675 | 2056 | vlevel = dcn20_validate_apply_pipe_split_flags(dc, context, vlevel, split, NULL); |
b6bfba6c DL |
2057 | |
2058 | /*initialize pipe_just_split_from to invalid idx*/ | |
2059 | for (i = 0; i < MAX_PIPES; i++) | |
2060 | pipe_split_from[i] = -1; | |
2061 | ||
7ed4e635 HW |
2062 | for (i = 0, pipe_idx = -1; i < dc->res_pool->pipe_count; i++) { |
2063 | struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i]; | |
2064 | struct pipe_ctx *hsplit_pipe = pipe->bottom_pipe; | |
7ed4e635 HW |
2065 | |
2066 | if (!pipe->stream || pipe_split_from[i] >= 0) | |
2067 | continue; | |
2068 | ||
2069 | pipe_idx++; | |
2070 | ||
7ed4e635 | 2071 | if (!pipe->top_pipe && !pipe->plane_state && context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx]) { |
c681491a | 2072 | hsplit_pipe = dcn20_find_secondary_pipe(dc, &context->res_ctx, dc->res_pool, pipe); |
7ed4e635 | 2073 | ASSERT(hsplit_pipe); |
b1f6d01c | 2074 | if (!dcn20_split_stream_for_odm( |
14e49bb3 | 2075 | dc, &context->res_ctx, |
b1f6d01c | 2076 | pipe, hsplit_pipe)) |
7ed4e635 HW |
2077 | goto validate_fail; |
2078 | pipe_split_from[hsplit_pipe->pipe_idx] = pipe_idx; | |
2079 | dcn20_build_mapped_resource(dc, context, pipe->stream); | |
2080 | } | |
2081 | ||
2082 | if (!pipe->plane_state) | |
2083 | continue; | |
2084 | /* Skip 2nd half of already split pipe */ | |
2085 | if (pipe->top_pipe && pipe->plane_state == pipe->top_pipe->plane_state) | |
2086 | continue; | |
2087 | ||
02ce5a79 DL |
2088 | /* We do not support mpo + odm at the moment */ |
2089 | if (hsplit_pipe && hsplit_pipe->plane_state != pipe->plane_state | |
2090 | && context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx]) | |
2091 | goto validate_fail; | |
2092 | ||
65d68369 | 2093 | if (split[i] == 2) { |
7ed4e635 HW |
2094 | if (!hsplit_pipe || hsplit_pipe->plane_state != pipe->plane_state) { |
2095 | /* pipe not split previously needs split */ | |
c681491a | 2096 | hsplit_pipe = dcn20_find_secondary_pipe(dc, &context->res_ctx, dc->res_pool, pipe); |
b6bfba6c | 2097 | ASSERT(hsplit_pipe); |
ff86391e | 2098 | if (!hsplit_pipe) { |
cf689e86 MW |
2099 | DC_FP_START(); |
2100 | dcn20_fpu_adjust_dppclk(&context->bw_ctx.dml.vba, vlevel, context->bw_ctx.dml.vba.maxMpcComb, pipe_idx, true); | |
2101 | DC_FP_END(); | |
7ed4e635 | 2102 | continue; |
ff86391e | 2103 | } |
b1f6d01c DL |
2104 | if (context->bw_ctx.dml.vba.ODMCombineEnabled[pipe_idx]) { |
2105 | if (!dcn20_split_stream_for_odm( | |
14e49bb3 | 2106 | dc, &context->res_ctx, |
b1f6d01c DL |
2107 | pipe, hsplit_pipe)) |
2108 | goto validate_fail; | |
387596ef | 2109 | dcn20_build_mapped_resource(dc, context, pipe->stream); |
65d68369 IZ |
2110 | } else { |
2111 | dcn20_split_stream_for_mpc( | |
b8a8d34b | 2112 | &context->res_ctx, dc->res_pool, |
65d68369 | 2113 | pipe, hsplit_pipe); |
65f9ace4 SL |
2114 | resource_build_scaling_params(pipe); |
2115 | resource_build_scaling_params(hsplit_pipe); | |
65d68369 | 2116 | } |
7ed4e635 HW |
2117 | pipe_split_from[hsplit_pipe->pipe_idx] = pipe_idx; |
2118 | } | |
02ce5a79 | 2119 | } else if (hsplit_pipe && hsplit_pipe->plane_state == pipe->plane_state) { |
7ed4e635 HW |
2120 | /* merge should already have been done */ |
2121 | ASSERT(0); | |
2122 | } | |
2123 | } | |
0ba37b20 | 2124 | /* Actual dsc count per stream dsc validation*/ |
c84ad0d6 | 2125 | if (!dcn20_validate_dsc(dc, context)) { |
0ba37b20 DL |
2126 | context->bw_ctx.dml.vba.ValidationStatus[context->bw_ctx.dml.vba.soc.num_states] = |
2127 | DML_FAIL_DSC_VALIDATION_FAILURE; | |
2128 | goto validate_fail; | |
2129 | } | |
7ed4e635 | 2130 | |
6de20237 | 2131 | *vlevel_out = vlevel; |
42351c66 | 2132 | |
6de20237 EY |
2133 | out = true; |
2134 | goto validate_out; | |
2135 | ||
2136 | validate_fail: | |
2137 | out = false; | |
2138 | ||
2139 | validate_out: | |
2140 | return out; | |
2141 | } | |
2142 | ||
8b91fd8b DK |
2143 | bool dcn20_validate_bandwidth(struct dc *dc, struct dc_state *context, |
2144 | bool fast_validate) | |
2145 | { | |
41401ac6 | 2146 | bool voltage_supported; |
2091ac69 SAS |
2147 | display_e2e_pipe_params_st *pipes; |
2148 | ||
2149 | pipes = kcalloc(dc->res_pool->pipe_count, sizeof(display_e2e_pipe_params_st), GFP_KERNEL); | |
2150 | if (!pipes) | |
2151 | return false; | |
2152 | ||
8b91fd8b | 2153 | DC_FP_START(); |
2091ac69 | 2154 | voltage_supported = dcn20_validate_bandwidth_fp(dc, context, fast_validate, pipes); |
7a8a3430 | 2155 | DC_FP_END(); |
2091ac69 SAS |
2156 | |
2157 | kfree(pipes); | |
057fc695 JL |
2158 | return voltage_supported; |
2159 | } | |
2160 | ||
198f0e89 | 2161 | struct pipe_ctx *dcn20_acquire_free_pipe_for_layer( |
460ea898 WL |
2162 | const struct dc_state *cur_ctx, |
2163 | struct dc_state *new_ctx, | |
7ed4e635 | 2164 | const struct resource_pool *pool, |
73d45092 | 2165 | const struct pipe_ctx *opp_head) |
7ed4e635 | 2166 | { |
460ea898 | 2167 | struct resource_context *res_ctx = &new_ctx->res_ctx; |
53f32880 WL |
2168 | struct pipe_ctx *otg_master = resource_get_otg_master_for_stream(res_ctx, opp_head->stream); |
2169 | struct pipe_ctx *sec_dpp_pipe = resource_find_free_secondary_pipe_legacy(res_ctx, pool, otg_master); | |
7ed4e635 | 2170 | |
73d45092 | 2171 | ASSERT(otg_master); |
7ed4e635 | 2172 | |
73d45092 | 2173 | if (!sec_dpp_pipe) |
7a17c8ce | 2174 | return NULL; |
7ed4e635 | 2175 | |
73d45092 WL |
2176 | sec_dpp_pipe->stream = opp_head->stream; |
2177 | sec_dpp_pipe->stream_res.tg = opp_head->stream_res.tg; | |
2178 | sec_dpp_pipe->stream_res.opp = opp_head->stream_res.opp; | |
7ed4e635 | 2179 | |
73d45092 WL |
2180 | sec_dpp_pipe->plane_res.hubp = pool->hubps[sec_dpp_pipe->pipe_idx]; |
2181 | sec_dpp_pipe->plane_res.ipp = pool->ipps[sec_dpp_pipe->pipe_idx]; | |
2182 | sec_dpp_pipe->plane_res.dpp = pool->dpps[sec_dpp_pipe->pipe_idx]; | |
2183 | sec_dpp_pipe->plane_res.mpcc_inst = pool->dpps[sec_dpp_pipe->pipe_idx]->inst; | |
7ed4e635 | 2184 | |
73d45092 | 2185 | return sec_dpp_pipe; |
7ed4e635 HW |
2186 | } |
2187 | ||
2188 | bool dcn20_get_dcc_compression_cap(const struct dc *dc, | |
2189 | const struct dc_dcc_surface_param *input, | |
2190 | struct dc_surface_dcc_cap *output) | |
2191 | { | |
2192 | return dc->res_pool->hubbub->funcs->get_dcc_compression_cap( | |
2193 | dc->res_pool->hubbub, | |
2194 | input, | |
2195 | output); | |
2196 | } | |
2197 | ||
2198 | static void dcn20_destroy_resource_pool(struct resource_pool **pool) | |
2199 | { | |
2200 | struct dcn20_resource_pool *dcn20_pool = TO_DCN20_RES_POOL(*pool); | |
2201 | ||
d9e32672 | 2202 | dcn20_resource_destruct(dcn20_pool); |
7ed4e635 HW |
2203 | kfree(dcn20_pool); |
2204 | *pool = NULL; | |
2205 | } | |
2206 | ||
2207 | ||
2208 | static struct dc_cap_funcs cap_funcs = { | |
2209 | .get_dcc_compression_cap = dcn20_get_dcc_compression_cap | |
2210 | }; | |
2211 | ||
2212 | ||
8d8c82b6 | 2213 | enum dc_status dcn20_patch_unknown_plane_state(struct dc_plane_state *plane_state) |
7ed4e635 | 2214 | { |
7ed4e635 HW |
2215 | enum surface_pixel_format surf_pix_format = plane_state->format; |
2216 | unsigned int bpp = resource_pixel_format_to_bpp(surf_pix_format); | |
2217 | ||
febb4147 | 2218 | plane_state->tiling_info.gfx9.swizzle = DC_SW_64KB_S; |
7ed4e635 | 2219 | if (bpp == 64) |
febb4147 | 2220 | plane_state->tiling_info.gfx9.swizzle = DC_SW_64KB_D; |
7ed4e635 | 2221 | |
b1c3b7f1 | 2222 | return DC_OK; |
7ed4e635 HW |
2223 | } |
2224 | ||
21741810 WL |
2225 | void dcn20_release_pipe(struct dc_state *context, |
2226 | struct pipe_ctx *pipe, | |
2227 | const struct resource_pool *pool) | |
2228 | { | |
2229 | if (resource_is_pipe_type(pipe, OPP_HEAD) && pipe->stream_res.dsc) | |
2230 | dcn20_release_dsc(&context->res_ctx, pool, &pipe->stream_res.dsc); | |
2231 | memset(pipe, 0, sizeof(*pipe)); | |
2232 | } | |
2233 | ||
25457a1f | 2234 | static const struct resource_funcs dcn20_res_pool_funcs = { |
7ed4e635 HW |
2235 | .destroy = dcn20_destroy_resource_pool, |
2236 | .link_enc_create = dcn20_link_encoder_create, | |
d4caa72e | 2237 | .panel_cntl_create = dcn20_panel_cntl_create, |
7ed4e635 | 2238 | .validate_bandwidth = dcn20_validate_bandwidth, |
198f0e89 | 2239 | .acquire_free_pipe_as_secondary_dpp_pipe = dcn20_acquire_free_pipe_for_layer, |
21741810 | 2240 | .release_pipe = dcn20_release_pipe, |
7ed4e635 | 2241 | .add_stream_to_ctx = dcn20_add_stream_to_ctx, |
b4f71c8c | 2242 | .add_dsc_to_stream_resource = dcn20_add_dsc_to_stream_resource, |
7ed4e635 HW |
2243 | .remove_stream_from_ctx = dcn20_remove_stream_from_ctx, |
2244 | .populate_dml_writeback_from_context = dcn20_populate_dml_writeback_from_context, | |
8d8c82b6 | 2245 | .patch_unknown_plane_state = dcn20_patch_unknown_plane_state, |
c9ae6e16 | 2246 | .set_mcif_arb_params = dcn20_set_mcif_arb_params, |
b6bfba6c | 2247 | .populate_dml_pipes = dcn20_populate_dml_pipes_from_context, |
278141f5 | 2248 | .find_first_free_match_stream_enc_for_link = dcn10_find_first_free_match_stream_enc_for_link |
7ed4e635 HW |
2249 | }; |
2250 | ||
bb21290f CL |
2251 | bool dcn20_dwbc_create(struct dc_context *ctx, struct resource_pool *pool) |
2252 | { | |
2253 | int i; | |
2254 | uint32_t pipe_count = pool->res_cap->num_dwb; | |
2255 | ||
bb21290f CL |
2256 | for (i = 0; i < pipe_count; i++) { |
2257 | struct dcn20_dwbc *dwbc20 = kzalloc(sizeof(struct dcn20_dwbc), | |
2258 | GFP_KERNEL); | |
2259 | ||
2260 | if (!dwbc20) { | |
2261 | dm_error("DC: failed to create dwbc20!\n"); | |
2262 | return false; | |
2263 | } | |
2264 | dcn20_dwbc_construct(dwbc20, ctx, | |
2265 | &dwbc20_regs[i], | |
2266 | &dwbc20_shift, | |
2267 | &dwbc20_mask, | |
2268 | i); | |
2269 | pool->dwbc[i] = &dwbc20->base; | |
2270 | } | |
2271 | return true; | |
2272 | } | |
2273 | ||
2274 | bool dcn20_mmhubbub_create(struct dc_context *ctx, struct resource_pool *pool) | |
2275 | { | |
2276 | int i; | |
2277 | uint32_t pipe_count = pool->res_cap->num_dwb; | |
2278 | ||
2279 | ASSERT(pipe_count > 0); | |
2280 | ||
2281 | for (i = 0; i < pipe_count; i++) { | |
2282 | struct dcn20_mmhubbub *mcif_wb20 = kzalloc(sizeof(struct dcn20_mmhubbub), | |
2283 | GFP_KERNEL); | |
2284 | ||
2285 | if (!mcif_wb20) { | |
2286 | dm_error("DC: failed to create mcif_wb20!\n"); | |
2287 | return false; | |
2288 | } | |
2289 | ||
2290 | dcn20_mmhubbub_construct(mcif_wb20, ctx, | |
2291 | &mcif_wb20_regs[i], | |
2292 | &mcif_wb20_shift, | |
2293 | &mcif_wb20_mask, | |
2294 | i); | |
2295 | ||
2296 | pool->mcif_wb[i] = &mcif_wb20->base; | |
2297 | } | |
2298 | return true; | |
2299 | } | |
2300 | ||
44e149bb | 2301 | static struct pp_smu_funcs *dcn20_pp_smu_create(struct dc_context *ctx) |
7ed4e635 | 2302 | { |
3bb11050 | 2303 | struct pp_smu_funcs *pp_smu = kzalloc(sizeof(*pp_smu), GFP_ATOMIC); |
7ed4e635 HW |
2304 | |
2305 | if (!pp_smu) | |
2306 | return pp_smu; | |
2307 | ||
2308 | dm_pp_get_funcs(ctx, pp_smu); | |
2309 | ||
2310 | if (pp_smu->ctx.ver != PP_SMU_VER_NV) | |
2311 | pp_smu = memset(pp_smu, 0, sizeof(struct pp_smu_funcs)); | |
2312 | ||
2313 | return pp_smu; | |
2314 | } | |
2315 | ||
44e149bb | 2316 | static void dcn20_pp_smu_destroy(struct pp_smu_funcs **pp_smu) |
7ed4e635 HW |
2317 | { |
2318 | if (pp_smu && *pp_smu) { | |
2319 | kfree(*pp_smu); | |
2320 | *pp_smu = NULL; | |
2321 | } | |
2322 | } | |
2323 | ||
675a9e38 LL |
2324 | static struct _vcs_dpi_soc_bounding_box_st *get_asic_rev_soc_bb( |
2325 | uint32_t hw_internal_rev) | |
2326 | { | |
e1ab4a91 ML |
2327 | if (ASICREV_IS_NAVI14_M(hw_internal_rev)) |
2328 | return &dcn2_0_nv14_soc; | |
2329 | ||
675a9e38 LL |
2330 | if (ASICREV_IS_NAVI12_P(hw_internal_rev)) |
2331 | return &dcn2_0_nv12_soc; | |
2332 | ||
2333 | return &dcn2_0_soc; | |
2334 | } | |
2335 | ||
2336 | static struct _vcs_dpi_ip_params_st *get_asic_rev_ip_params( | |
2337 | uint32_t hw_internal_rev) | |
2338 | { | |
72b741af Z |
2339 | /* NV14 */ |
2340 | if (ASICREV_IS_NAVI14_M(hw_internal_rev)) | |
2341 | return &dcn2_0_nv14_ip; | |
2342 | ||
675a9e38 LL |
2343 | /* NV12 and NV10 */ |
2344 | return &dcn2_0_ip; | |
2345 | } | |
2346 | ||
2347 | static enum dml_project get_dml_project_version(uint32_t hw_internal_rev) | |
2348 | { | |
2349 | return DML_PROJECT_NAVI10v2; | |
2350 | } | |
2351 | ||
7ed4e635 HW |
2352 | static bool init_soc_bounding_box(struct dc *dc, |
2353 | struct dcn20_resource_pool *pool) | |
2354 | { | |
675a9e38 LL |
2355 | struct _vcs_dpi_soc_bounding_box_st *loaded_bb = |
2356 | get_asic_rev_soc_bb(dc->ctx->asic_id.hw_internal_rev); | |
2357 | struct _vcs_dpi_ip_params_st *loaded_ip = | |
2358 | get_asic_rev_ip_params(dc->ctx->asic_id.hw_internal_rev); | |
2359 | ||
7ed4e635 HW |
2360 | DC_LOGGER_INIT(dc->ctx->logger); |
2361 | ||
7ed4e635 HW |
2362 | if (pool->base.pp_smu) { |
2363 | struct pp_smu_nv_clock_table max_clocks = {0}; | |
2364 | unsigned int uclk_states[8] = {0}; | |
2365 | unsigned int num_states = 0; | |
2366 | enum pp_smu_status status; | |
2367 | bool clock_limits_available = false; | |
2368 | bool uclk_states_available = false; | |
2369 | ||
2370 | if (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states) { | |
2371 | status = (pool->base.pp_smu->nv_funcs.get_uclk_dpm_states) | |
2372 | (&pool->base.pp_smu->nv_funcs.pp_smu, uclk_states, &num_states); | |
2373 | ||
2374 | uclk_states_available = (status == PP_SMU_RESULT_OK); | |
2375 | } | |
2376 | ||
2377 | if (pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks) { | |
2378 | status = (*pool->base.pp_smu->nv_funcs.get_maximum_sustainable_clocks) | |
2379 | (&pool->base.pp_smu->nv_funcs.pp_smu, &max_clocks); | |
c2ad17c3 AW |
2380 | /* SMU cannot set DCF clock to anything equal to or higher than SOC clock |
2381 | */ | |
2382 | if (max_clocks.dcfClockInKhz >= max_clocks.socClockInKhz) | |
2383 | max_clocks.dcfClockInKhz = max_clocks.socClockInKhz - 1000; | |
7ed4e635 HW |
2384 | clock_limits_available = (status == PP_SMU_RESULT_OK); |
2385 | } | |
2386 | ||
bc39a69a AJ |
2387 | if (clock_limits_available && uclk_states_available && num_states) { |
2388 | DC_FP_START(); | |
44ce0cd3 | 2389 | dcn20_update_bounding_box(dc, loaded_bb, &max_clocks, uclk_states, num_states); |
bc39a69a AJ |
2390 | DC_FP_END(); |
2391 | } else if (clock_limits_available) { | |
2392 | DC_FP_START(); | |
44ce0cd3 | 2393 | dcn20_cap_soc_clocks(loaded_bb, max_clocks); |
bc39a69a AJ |
2394 | DC_FP_END(); |
2395 | } | |
7ed4e635 HW |
2396 | } |
2397 | ||
675a9e38 LL |
2398 | loaded_ip->max_num_otg = pool->base.res_cap->num_timing_generator; |
2399 | loaded_ip->max_num_dpp = pool->base.pipe_count; | |
bc39a69a | 2400 | DC_FP_START(); |
44ce0cd3 | 2401 | dcn20_patch_bounding_box(dc, loaded_bb); |
bc39a69a | 2402 | DC_FP_END(); |
7ed4e635 HW |
2403 | return true; |
2404 | } | |
2405 | ||
d9e32672 | 2406 | static bool dcn20_resource_construct( |
7ed4e635 HW |
2407 | uint8_t num_virtual_links, |
2408 | struct dc *dc, | |
2409 | struct dcn20_resource_pool *pool) | |
2410 | { | |
2411 | int i; | |
2412 | struct dc_context *ctx = dc->ctx; | |
2413 | struct irq_service_init_data init_data; | |
130ac6d8 | 2414 | struct ddc_service_init_data ddc_init_data = {0}; |
675a9e38 LL |
2415 | struct _vcs_dpi_soc_bounding_box_st *loaded_bb = |
2416 | get_asic_rev_soc_bb(ctx->asic_id.hw_internal_rev); | |
2417 | struct _vcs_dpi_ip_params_st *loaded_ip = | |
2418 | get_asic_rev_ip_params(ctx->asic_id.hw_internal_rev); | |
2419 | enum dml_project dml_project_version = | |
2420 | get_dml_project_version(ctx->asic_id.hw_internal_rev); | |
7ed4e635 HW |
2421 | |
2422 | ctx->dc_bios->regs = &bios_regs; | |
7ed4e635 HW |
2423 | pool->base.funcs = &dcn20_res_pool_funcs; |
2424 | ||
2ebe1773 BL |
2425 | if (ASICREV_IS_NAVI14_M(ctx->asic_id.hw_internal_rev)) { |
2426 | pool->base.res_cap = &res_cap_nv14; | |
2427 | pool->base.pipe_count = 5; | |
2428 | pool->base.mpcc_count = 5; | |
2429 | } else { | |
2430 | pool->base.res_cap = &res_cap_nv10; | |
2431 | pool->base.pipe_count = 6; | |
2432 | pool->base.mpcc_count = 6; | |
2433 | } | |
7ed4e635 HW |
2434 | /************************************************* |
2435 | * Resource + asic cap harcoding * | |
2436 | *************************************************/ | |
2437 | pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE; | |
2438 | ||
7ed4e635 HW |
2439 | dc->caps.max_downscale_ratio = 200; |
2440 | dc->caps.i2c_speed_in_khz = 100; | |
b15cde19 | 2441 | dc->caps.i2c_speed_in_khz_hdcp = 100; /*1.4 w/a not applied by default*/ |
7ed4e635 | 2442 | dc->caps.max_cursor_size = 256; |
9248681f | 2443 | dc->caps.min_horizontal_blanking_period = 80; |
7ed4e635 HW |
2444 | dc->caps.dmdata_alloc_size = 2048; |
2445 | ||
2446 | dc->caps.max_slave_planes = 1; | |
ae030570 AK |
2447 | dc->caps.max_slave_yuv_planes = 1; |
2448 | dc->caps.max_slave_rgb_planes = 1; | |
7ed4e635 HW |
2449 | dc->caps.post_blend_color_processing = true; |
2450 | dc->caps.force_dp_tps4_for_cp2520 = true; | |
ca4f844e | 2451 | dc->caps.extended_aux_timeout_support = true; |
be53bd4f | 2452 | dc->caps.dmcub_support = true; |
7ed4e635 | 2453 | |
a8bf7164 KK |
2454 | /* Color pipeline capabilities */ |
2455 | dc->caps.color.dpp.dcn_arch = 1; | |
2456 | dc->caps.color.dpp.input_lut_shared = 0; | |
2457 | dc->caps.color.dpp.icsc = 1; | |
2458 | dc->caps.color.dpp.dgam_ram = 1; | |
2459 | dc->caps.color.dpp.dgam_rom_caps.srgb = 1; | |
2460 | dc->caps.color.dpp.dgam_rom_caps.bt2020 = 1; | |
2461 | dc->caps.color.dpp.dgam_rom_caps.gamma2_2 = 0; | |
2462 | dc->caps.color.dpp.dgam_rom_caps.pq = 0; | |
2463 | dc->caps.color.dpp.dgam_rom_caps.hlg = 0; | |
2464 | dc->caps.color.dpp.post_csc = 0; | |
2465 | dc->caps.color.dpp.gamma_corr = 0; | |
c6160900 | 2466 | dc->caps.color.dpp.dgam_rom_for_yuv = 1; |
a8bf7164 KK |
2467 | |
2468 | dc->caps.color.dpp.hw_3d_lut = 1; | |
2469 | dc->caps.color.dpp.ogam_ram = 1; | |
2470 | // no OGAM ROM on DCN2, only MPC ROM | |
2471 | dc->caps.color.dpp.ogam_rom_caps.srgb = 0; | |
2472 | dc->caps.color.dpp.ogam_rom_caps.bt2020 = 0; | |
2473 | dc->caps.color.dpp.ogam_rom_caps.gamma2_2 = 0; | |
2474 | dc->caps.color.dpp.ogam_rom_caps.pq = 0; | |
2475 | dc->caps.color.dpp.ogam_rom_caps.hlg = 0; | |
2476 | dc->caps.color.dpp.ocsc = 0; | |
2477 | ||
2478 | dc->caps.color.mpc.gamut_remap = 0; | |
2479 | dc->caps.color.mpc.num_3dluts = 0; | |
2480 | dc->caps.color.mpc.shared_3d_lut = 0; | |
2481 | dc->caps.color.mpc.ogam_ram = 1; | |
2482 | dc->caps.color.mpc.ogam_rom_caps.srgb = 0; | |
2483 | dc->caps.color.mpc.ogam_rom_caps.bt2020 = 0; | |
2484 | dc->caps.color.mpc.ogam_rom_caps.gamma2_2 = 0; | |
2485 | dc->caps.color.mpc.ogam_rom_caps.pq = 0; | |
2486 | dc->caps.color.mpc.ogam_rom_caps.hlg = 0; | |
2487 | dc->caps.color.mpc.ocsc = 1; | |
2488 | ||
068ab0cd | 2489 | dc->caps.dp_hdmi21_pcon_support = true; |
c022375a | 2490 | |
25879d7b | 2491 | if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV) |
7ed4e635 | 2492 | dc->debug = debug_defaults_drv; |
25879d7b | 2493 | |
7ed4e635 HW |
2494 | //dcn2.0x |
2495 | dc->work_arounds.dedcn20_305_wa = true; | |
2496 | ||
2497 | // Init the vm_helper | |
2498 | if (dc->vm_helper) | |
bda9afda | 2499 | vm_helper_init(dc->vm_helper, 16); |
7ed4e635 HW |
2500 | |
2501 | /************************************************* | |
2502 | * Create resources * | |
2503 | *************************************************/ | |
2504 | ||
2505 | pool->base.clock_sources[DCN20_CLK_SRC_PLL0] = | |
2506 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2507 | CLOCK_SOURCE_COMBO_PHY_PLL0, | |
2508 | &clk_src_regs[0], false); | |
2509 | pool->base.clock_sources[DCN20_CLK_SRC_PLL1] = | |
2510 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2511 | CLOCK_SOURCE_COMBO_PHY_PLL1, | |
2512 | &clk_src_regs[1], false); | |
2513 | pool->base.clock_sources[DCN20_CLK_SRC_PLL2] = | |
2514 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2515 | CLOCK_SOURCE_COMBO_PHY_PLL2, | |
2516 | &clk_src_regs[2], false); | |
2517 | pool->base.clock_sources[DCN20_CLK_SRC_PLL3] = | |
2518 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2519 | CLOCK_SOURCE_COMBO_PHY_PLL3, | |
2520 | &clk_src_regs[3], false); | |
2521 | pool->base.clock_sources[DCN20_CLK_SRC_PLL4] = | |
2522 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2523 | CLOCK_SOURCE_COMBO_PHY_PLL4, | |
2524 | &clk_src_regs[4], false); | |
2525 | pool->base.clock_sources[DCN20_CLK_SRC_PLL5] = | |
2526 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2527 | CLOCK_SOURCE_COMBO_PHY_PLL5, | |
2528 | &clk_src_regs[5], false); | |
2529 | pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL; | |
2530 | /* todo: not reuse phy_pll registers */ | |
2531 | pool->base.dp_clock_source = | |
2532 | dcn20_clock_source_create(ctx, ctx->dc_bios, | |
2533 | CLOCK_SOURCE_ID_DP_DTO, | |
2534 | &clk_src_regs[0], true); | |
2535 | ||
2536 | for (i = 0; i < pool->base.clk_src_count; i++) { | |
2537 | if (pool->base.clock_sources[i] == NULL) { | |
2538 | dm_error("DC: failed to create clock sources!\n"); | |
2539 | BREAK_TO_DEBUGGER(); | |
2540 | goto create_fail; | |
2541 | } | |
2542 | } | |
2543 | ||
2544 | pool->base.dccg = dccg2_create(ctx, &dccg_regs, &dccg_shift, &dccg_mask); | |
2545 | if (pool->base.dccg == NULL) { | |
2546 | dm_error("DC: failed to create dccg!\n"); | |
2547 | BREAK_TO_DEBUGGER(); | |
2548 | goto create_fail; | |
2549 | } | |
2550 | ||
2551 | pool->base.dmcu = dcn20_dmcu_create(ctx, | |
2552 | &dmcu_regs, | |
2553 | &dmcu_shift, | |
2554 | &dmcu_mask); | |
2555 | if (pool->base.dmcu == NULL) { | |
2556 | dm_error("DC: failed to create dmcu!\n"); | |
2557 | BREAK_TO_DEBUGGER(); | |
2558 | goto create_fail; | |
2559 | } | |
2560 | ||
d7c29549 | 2561 | pool->base.abm = dce_abm_create(ctx, |
7ed4e635 HW |
2562 | &abm_regs, |
2563 | &abm_shift, | |
2564 | &abm_mask); | |
2565 | if (pool->base.abm == NULL) { | |
2566 | dm_error("DC: failed to create abm!\n"); | |
2567 | BREAK_TO_DEBUGGER(); | |
2568 | goto create_fail; | |
d7c29549 | 2569 | } |
7ed4e635 HW |
2570 | |
2571 | pool->base.pp_smu = dcn20_pp_smu_create(ctx); | |
2572 | ||
2573 | ||
2574 | if (!init_soc_bounding_box(dc, pool)) { | |
2575 | dm_error("DC: failed to initialize soc bounding box!\n"); | |
2576 | BREAK_TO_DEBUGGER(); | |
2577 | goto create_fail; | |
2578 | } | |
2579 | ||
675a9e38 | 2580 | dml_init_instance(&dc->dml, loaded_bb, loaded_ip, dml_project_version); |
7ed4e635 HW |
2581 | |
2582 | if (!dc->debug.disable_pplib_wm_range) { | |
2583 | struct pp_smu_wm_range_sets ranges = {0}; | |
2584 | int i = 0; | |
2585 | ||
2586 | ranges.num_reader_wm_sets = 0; | |
2587 | ||
675a9e38 | 2588 | if (loaded_bb->num_states == 1) { |
7ed4e635 HW |
2589 | ranges.reader_wm_sets[0].wm_inst = i; |
2590 | ranges.reader_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; | |
2591 | ranges.reader_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
2592 | ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; | |
2593 | ranges.reader_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
2594 | ||
2595 | ranges.num_reader_wm_sets = 1; | |
675a9e38 LL |
2596 | } else if (loaded_bb->num_states > 1) { |
2597 | for (i = 0; i < 4 && i < loaded_bb->num_states; i++) { | |
7ed4e635 HW |
2598 | ranges.reader_wm_sets[i].wm_inst = i; |
2599 | ranges.reader_wm_sets[i].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; | |
2600 | ranges.reader_wm_sets[i].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
cf689e86 MW |
2601 | DC_FP_START(); |
2602 | dcn20_fpu_set_wm_ranges(i, &ranges, loaded_bb); | |
2603 | DC_FP_END(); | |
7ed4e635 HW |
2604 | |
2605 | ranges.num_reader_wm_sets = i + 1; | |
2606 | } | |
7ed4e635 | 2607 | |
5d36f783 JL |
2608 | ranges.reader_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; |
2609 | ranges.reader_wm_sets[ranges.num_reader_wm_sets - 1].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
2610 | } | |
7ed4e635 HW |
2611 | |
2612 | ranges.num_writer_wm_sets = 1; | |
2613 | ||
2614 | ranges.writer_wm_sets[0].wm_inst = 0; | |
2615 | ranges.writer_wm_sets[0].min_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; | |
2616 | ranges.writer_wm_sets[0].max_fill_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
2617 | ranges.writer_wm_sets[0].min_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MIN; | |
2618 | ranges.writer_wm_sets[0].max_drain_clk_mhz = PP_SMU_WM_SET_RANGE_CLK_UNCONSTRAINED_MAX; | |
2619 | ||
2620 | /* Notify PP Lib/SMU which Watermarks to use for which clock ranges */ | |
2621 | if (pool->base.pp_smu->nv_funcs.set_wm_ranges) | |
2622 | pool->base.pp_smu->nv_funcs.set_wm_ranges(&pool->base.pp_smu->nv_funcs.pp_smu, &ranges); | |
2623 | } | |
2624 | ||
2625 | init_data.ctx = dc->ctx; | |
2626 | pool->base.irqs = dal_irq_service_dcn20_create(&init_data); | |
2627 | if (!pool->base.irqs) | |
2628 | goto create_fail; | |
2629 | ||
2630 | /* mem input -> ipp -> dpp -> opp -> TG */ | |
2631 | for (i = 0; i < pool->base.pipe_count; i++) { | |
2632 | pool->base.hubps[i] = dcn20_hubp_create(ctx, i); | |
2633 | if (pool->base.hubps[i] == NULL) { | |
2634 | BREAK_TO_DEBUGGER(); | |
2635 | dm_error( | |
2636 | "DC: failed to create memory input!\n"); | |
2637 | goto create_fail; | |
2638 | } | |
2639 | ||
2640 | pool->base.ipps[i] = dcn20_ipp_create(ctx, i); | |
2641 | if (pool->base.ipps[i] == NULL) { | |
2642 | BREAK_TO_DEBUGGER(); | |
2643 | dm_error( | |
2644 | "DC: failed to create input pixel processor!\n"); | |
2645 | goto create_fail; | |
2646 | } | |
2647 | ||
2648 | pool->base.dpps[i] = dcn20_dpp_create(ctx, i); | |
2649 | if (pool->base.dpps[i] == NULL) { | |
2650 | BREAK_TO_DEBUGGER(); | |
2651 | dm_error( | |
2652 | "DC: failed to create dpps!\n"); | |
2653 | goto create_fail; | |
2654 | } | |
2655 | } | |
2656 | for (i = 0; i < pool->base.res_cap->num_ddc; i++) { | |
2657 | pool->base.engines[i] = dcn20_aux_engine_create(ctx, i); | |
2658 | if (pool->base.engines[i] == NULL) { | |
2659 | BREAK_TO_DEBUGGER(); | |
2660 | dm_error( | |
2661 | "DC:failed to create aux engine!!\n"); | |
2662 | goto create_fail; | |
2663 | } | |
2664 | pool->base.hw_i2cs[i] = dcn20_i2c_hw_create(ctx, i); | |
2665 | if (pool->base.hw_i2cs[i] == NULL) { | |
2666 | BREAK_TO_DEBUGGER(); | |
2667 | dm_error( | |
2668 | "DC:failed to create hw i2c!!\n"); | |
2669 | goto create_fail; | |
2670 | } | |
2671 | pool->base.sw_i2cs[i] = NULL; | |
2672 | } | |
2673 | ||
2674 | for (i = 0; i < pool->base.res_cap->num_opp; i++) { | |
2675 | pool->base.opps[i] = dcn20_opp_create(ctx, i); | |
2676 | if (pool->base.opps[i] == NULL) { | |
2677 | BREAK_TO_DEBUGGER(); | |
2678 | dm_error( | |
2679 | "DC: failed to create output pixel processor!\n"); | |
2680 | goto create_fail; | |
2681 | } | |
2682 | } | |
2683 | ||
2684 | for (i = 0; i < pool->base.res_cap->num_timing_generator; i++) { | |
2685 | pool->base.timing_generators[i] = dcn20_timing_generator_create( | |
2686 | ctx, i); | |
2687 | if (pool->base.timing_generators[i] == NULL) { | |
2688 | BREAK_TO_DEBUGGER(); | |
2689 | dm_error("DC: failed to create tg!\n"); | |
2690 | goto create_fail; | |
2691 | } | |
2692 | } | |
2693 | ||
2694 | pool->base.timing_generator_count = i; | |
2695 | ||
2696 | pool->base.mpc = dcn20_mpc_create(ctx); | |
2697 | if (pool->base.mpc == NULL) { | |
2698 | BREAK_TO_DEBUGGER(); | |
2699 | dm_error("DC: failed to create mpc!\n"); | |
2700 | goto create_fail; | |
2701 | } | |
2702 | ||
2703 | pool->base.hubbub = dcn20_hubbub_create(ctx); | |
2704 | if (pool->base.hubbub == NULL) { | |
2705 | BREAK_TO_DEBUGGER(); | |
2706 | dm_error("DC: failed to create hubbub!\n"); | |
2707 | goto create_fail; | |
2708 | } | |
2709 | ||
97bda032 HW |
2710 | for (i = 0; i < pool->base.res_cap->num_dsc; i++) { |
2711 | pool->base.dscs[i] = dcn20_dsc_create(ctx, i); | |
2712 | if (pool->base.dscs[i] == NULL) { | |
2713 | BREAK_TO_DEBUGGER(); | |
2714 | dm_error("DC: failed to create display stream compressor %d!\n", i); | |
2715 | goto create_fail; | |
2716 | } | |
2717 | } | |
7ed4e635 | 2718 | |
bb21290f CL |
2719 | if (!dcn20_dwbc_create(ctx, &pool->base)) { |
2720 | BREAK_TO_DEBUGGER(); | |
2721 | dm_error("DC: failed to create dwbc!\n"); | |
2722 | goto create_fail; | |
2723 | } | |
2724 | if (!dcn20_mmhubbub_create(ctx, &pool->base)) { | |
2725 | BREAK_TO_DEBUGGER(); | |
2726 | dm_error("DC: failed to create mcif_wb!\n"); | |
2727 | goto create_fail; | |
2728 | } | |
2729 | ||
7ed4e635 | 2730 | if (!resource_construct(num_virtual_links, dc, &pool->base, |
25879d7b QZ |
2731 | &res_create_funcs)) |
2732 | goto create_fail; | |
7ed4e635 HW |
2733 | |
2734 | dcn20_hw_sequencer_construct(dc); | |
2735 | ||
3c9de4da AL |
2736 | // IF NV12, set PG function pointer to NULL. It's not that |
2737 | // PG isn't supported for NV12, it's that we don't want to | |
2738 | // program the registers because that will cause more power | |
2739 | // to be consumed. We could have created dcn20_init_hw to get | |
2740 | // the same effect by checking ASIC rev, but there was a | |
2741 | // request at some point to not check ASIC rev on hw sequencer. | |
15ce104c | 2742 | if (ASICREV_IS_NAVI12_P(dc->ctx->asic_id.hw_internal_rev)) { |
3c9de4da | 2743 | dc->hwseq->funcs.enable_power_gating_plane = NULL; |
15ce104c AL |
2744 | dc->debug.disable_dpp_power_gate = true; |
2745 | dc->debug.disable_hubp_power_gate = true; | |
2746 | } | |
2747 | ||
3c9de4da | 2748 | |
7ed4e635 HW |
2749 | dc->caps.max_planes = pool->base.pipe_count; |
2750 | ||
2751 | for (i = 0; i < dc->caps.max_planes; ++i) | |
2752 | dc->caps.planes[i] = plane_cap; | |
2753 | ||
2754 | dc->cap_funcs = cap_funcs; | |
2755 | ||
d9a07577 JL |
2756 | if (dc->ctx->dc_bios->fw_info.oem_i2c_present) { |
2757 | ddc_init_data.ctx = dc->ctx; | |
2758 | ddc_init_data.link = NULL; | |
2759 | ddc_init_data.id.id = dc->ctx->dc_bios->fw_info.oem_i2c_obj_id; | |
2760 | ddc_init_data.id.enum_id = 0; | |
2761 | ddc_init_data.id.type = OBJECT_TYPE_GENERIC; | |
98ce7d32 | 2762 | pool->base.oem_device = dc->link_srv->create_ddc_service(&ddc_init_data); |
d9a07577 JL |
2763 | } else { |
2764 | pool->base.oem_device = NULL; | |
2765 | } | |
2766 | ||
7ed4e635 HW |
2767 | return true; |
2768 | ||
2769 | create_fail: | |
2770 | ||
d9e32672 | 2771 | dcn20_resource_destruct(pool); |
7ed4e635 HW |
2772 | |
2773 | return false; | |
2774 | } | |
2775 | ||
2776 | struct resource_pool *dcn20_create_resource_pool( | |
2777 | const struct dc_init_data *init_data, | |
2778 | struct dc *dc) | |
2779 | { | |
2780 | struct dcn20_resource_pool *pool = | |
3bb11050 | 2781 | kzalloc(sizeof(struct dcn20_resource_pool), GFP_ATOMIC); |
7ed4e635 HW |
2782 | |
2783 | if (!pool) | |
2784 | return NULL; | |
2785 | ||
d9e32672 | 2786 | if (dcn20_resource_construct(init_data->num_virtual_links, dc, pool)) |
7ed4e635 HW |
2787 | return &pool->base; |
2788 | ||
2789 | BREAK_TO_DEBUGGER(); | |
2790 | kfree(pool); | |
2791 | return NULL; | |
2792 | } |