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