dcn10_resource.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256
  1. /*
  2. * Copyright 2016 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. * Authors: AMD
  23. *
  24. */
  25. #include "dm_services.h"
  26. #include "dc.h"
  27. #include "resource.h"
  28. #include "include/irq_service_interface.h"
  29. #include "dcn10/dcn10_resource.h"
  30. #include "dcn10/dcn10_ipp.h"
  31. #include "dcn10/dcn10_mpc.h"
  32. #include "irq/dcn10/irq_service_dcn10.h"
  33. #include "dcn10/dcn10_dpp.h"
  34. #include "dcn10_optc.h"
  35. #include "dcn10/dcn10_hw_sequencer.h"
  36. #include "dce110/dce110_hw_sequencer.h"
  37. #include "dcn10/dcn10_opp.h"
  38. #include "dcn10/dcn10_link_encoder.h"
  39. #include "dcn10/dcn10_stream_encoder.h"
  40. #include "dce/dce_clocks.h"
  41. #include "dce/dce_clock_source.h"
  42. #include "dce/dce_audio.h"
  43. #include "dce/dce_hwseq.h"
  44. #include "../virtual/virtual_stream_encoder.h"
  45. #include "dce110/dce110_resource.h"
  46. #include "dce112/dce112_resource.h"
  47. #include "dcn10_hubp.h"
  48. #include "dcn10_hubbub.h"
  49. #include "soc15_hw_ip.h"
  50. #include "vega10_ip_offset.h"
  51. #include "dcn/dcn_1_0_offset.h"
  52. #include "dcn/dcn_1_0_sh_mask.h"
  53. #include "nbio/nbio_7_0_offset.h"
  54. #include "mmhub/mmhub_9_1_offset.h"
  55. #include "mmhub/mmhub_9_1_sh_mask.h"
  56. #include "reg_helper.h"
  57. #include "dce/dce_abm.h"
  58. #include "dce/dce_dmcu.h"
  59. #ifndef mmDP0_DP_DPHY_INTERNAL_CTRL
  60. #define mmDP0_DP_DPHY_INTERNAL_CTRL 0x210f
  61. #define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  62. #define mmDP1_DP_DPHY_INTERNAL_CTRL 0x220f
  63. #define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  64. #define mmDP2_DP_DPHY_INTERNAL_CTRL 0x230f
  65. #define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  66. #define mmDP3_DP_DPHY_INTERNAL_CTRL 0x240f
  67. #define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  68. #define mmDP4_DP_DPHY_INTERNAL_CTRL 0x250f
  69. #define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  70. #define mmDP5_DP_DPHY_INTERNAL_CTRL 0x260f
  71. #define mmDP5_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  72. #define mmDP6_DP_DPHY_INTERNAL_CTRL 0x270f
  73. #define mmDP6_DP_DPHY_INTERNAL_CTRL_BASE_IDX 2
  74. #endif
  75. enum dcn10_clk_src_array_id {
  76. DCN10_CLK_SRC_PLL0,
  77. DCN10_CLK_SRC_PLL1,
  78. DCN10_CLK_SRC_PLL2,
  79. DCN10_CLK_SRC_PLL3,
  80. DCN10_CLK_SRC_TOTAL
  81. };
  82. /* begin *********************
  83. * macros to expend register list macro defined in HW object header file */
  84. /* DCN */
  85. #define BASE_INNER(seg) \
  86. DCE_BASE__INST0_SEG ## seg
  87. #define BASE(seg) \
  88. BASE_INNER(seg)
  89. #define SR(reg_name)\
  90. .reg_name = BASE(mm ## reg_name ## _BASE_IDX) + \
  91. mm ## reg_name
  92. #define SRI(reg_name, block, id)\
  93. .reg_name = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
  94. mm ## block ## id ## _ ## reg_name
  95. #define SRII(reg_name, block, id)\
  96. .reg_name[id] = BASE(mm ## block ## id ## _ ## reg_name ## _BASE_IDX) + \
  97. mm ## block ## id ## _ ## reg_name
  98. /* NBIO */
  99. #define NBIO_BASE_INNER(seg) \
  100. NBIF_BASE__INST0_SEG ## seg
  101. #define NBIO_BASE(seg) \
  102. NBIO_BASE_INNER(seg)
  103. #define NBIO_SR(reg_name)\
  104. .reg_name = NBIO_BASE(mm ## reg_name ## _BASE_IDX) + \
  105. mm ## reg_name
  106. /* MMHUB */
  107. #define MMHUB_BASE_INNER(seg) \
  108. MMHUB_BASE__INST0_SEG ## seg
  109. #define MMHUB_BASE(seg) \
  110. MMHUB_BASE_INNER(seg)
  111. #define MMHUB_SR(reg_name)\
  112. .reg_name = MMHUB_BASE(mm ## reg_name ## _BASE_IDX) + \
  113. mm ## reg_name
  114. /* macros to expend register list macro defined in HW object header file
  115. * end *********************/
  116. static const struct dce_dmcu_registers dmcu_regs = {
  117. DMCU_DCN10_REG_LIST()
  118. };
  119. static const struct dce_dmcu_shift dmcu_shift = {
  120. DMCU_MASK_SH_LIST_DCN10(__SHIFT)
  121. };
  122. static const struct dce_dmcu_mask dmcu_mask = {
  123. DMCU_MASK_SH_LIST_DCN10(_MASK)
  124. };
  125. static const struct dce_abm_registers abm_regs = {
  126. ABM_DCN10_REG_LIST(0)
  127. };
  128. static const struct dce_abm_shift abm_shift = {
  129. ABM_MASK_SH_LIST_DCN10(__SHIFT)
  130. };
  131. static const struct dce_abm_mask abm_mask = {
  132. ABM_MASK_SH_LIST_DCN10(_MASK)
  133. };
  134. #define stream_enc_regs(id)\
  135. [id] = {\
  136. SE_DCN_REG_LIST(id)\
  137. }
  138. static const struct dcn10_stream_enc_registers stream_enc_regs[] = {
  139. stream_enc_regs(0),
  140. stream_enc_regs(1),
  141. stream_enc_regs(2),
  142. stream_enc_regs(3),
  143. };
  144. static const struct dcn10_stream_encoder_shift se_shift = {
  145. SE_COMMON_MASK_SH_LIST_DCN10(__SHIFT)
  146. };
  147. static const struct dcn10_stream_encoder_mask se_mask = {
  148. SE_COMMON_MASK_SH_LIST_DCN10(_MASK)
  149. };
  150. #define audio_regs(id)\
  151. [id] = {\
  152. AUD_COMMON_REG_LIST(id)\
  153. }
  154. static const struct dce_audio_registers audio_regs[] = {
  155. audio_regs(0),
  156. audio_regs(1),
  157. audio_regs(2),
  158. audio_regs(3),
  159. };
  160. #define DCE120_AUD_COMMON_MASK_SH_LIST(mask_sh)\
  161. SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_INDEX, AZALIA_ENDPOINT_REG_INDEX, mask_sh),\
  162. SF(AZF0ENDPOINT0_AZALIA_F0_CODEC_ENDPOINT_DATA, AZALIA_ENDPOINT_REG_DATA, mask_sh),\
  163. AUD_COMMON_MASK_SH_LIST_BASE(mask_sh)
  164. static const struct dce_audio_shift audio_shift = {
  165. DCE120_AUD_COMMON_MASK_SH_LIST(__SHIFT)
  166. };
  167. static const struct dce_aduio_mask audio_mask = {
  168. DCE120_AUD_COMMON_MASK_SH_LIST(_MASK)
  169. };
  170. #define aux_regs(id)\
  171. [id] = {\
  172. AUX_REG_LIST(id)\
  173. }
  174. static const struct dcn10_link_enc_aux_registers link_enc_aux_regs[] = {
  175. aux_regs(0),
  176. aux_regs(1),
  177. aux_regs(2),
  178. aux_regs(3)
  179. };
  180. #define hpd_regs(id)\
  181. [id] = {\
  182. HPD_REG_LIST(id)\
  183. }
  184. static const struct dcn10_link_enc_hpd_registers link_enc_hpd_regs[] = {
  185. hpd_regs(0),
  186. hpd_regs(1),
  187. hpd_regs(2),
  188. hpd_regs(3)
  189. };
  190. #define link_regs(id)\
  191. [id] = {\
  192. LE_DCN10_REG_LIST(id), \
  193. SRI(DP_DPHY_INTERNAL_CTRL, DP, id) \
  194. }
  195. static const struct dcn10_link_enc_registers link_enc_regs[] = {
  196. link_regs(0),
  197. link_regs(1),
  198. link_regs(2),
  199. link_regs(3)
  200. };
  201. static const struct dcn10_link_enc_shift le_shift = {
  202. LINK_ENCODER_MASK_SH_LIST_DCN10(__SHIFT)
  203. };
  204. static const struct dcn10_link_enc_mask le_mask = {
  205. LINK_ENCODER_MASK_SH_LIST_DCN10(_MASK)
  206. };
  207. #define ipp_regs(id)\
  208. [id] = {\
  209. IPP_REG_LIST_DCN10(id),\
  210. }
  211. static const struct dcn10_ipp_registers ipp_regs[] = {
  212. ipp_regs(0),
  213. ipp_regs(1),
  214. ipp_regs(2),
  215. ipp_regs(3),
  216. };
  217. static const struct dcn10_ipp_shift ipp_shift = {
  218. IPP_MASK_SH_LIST_DCN10(__SHIFT)
  219. };
  220. static const struct dcn10_ipp_mask ipp_mask = {
  221. IPP_MASK_SH_LIST_DCN10(_MASK),
  222. };
  223. #define opp_regs(id)\
  224. [id] = {\
  225. OPP_REG_LIST_DCN10(id),\
  226. }
  227. static const struct dcn10_opp_registers opp_regs[] = {
  228. opp_regs(0),
  229. opp_regs(1),
  230. opp_regs(2),
  231. opp_regs(3),
  232. };
  233. static const struct dcn10_opp_shift opp_shift = {
  234. OPP_MASK_SH_LIST_DCN10(__SHIFT)
  235. };
  236. static const struct dcn10_opp_mask opp_mask = {
  237. OPP_MASK_SH_LIST_DCN10(_MASK),
  238. };
  239. #define tf_regs(id)\
  240. [id] = {\
  241. TF_REG_LIST_DCN10(id),\
  242. }
  243. static const struct dcn_dpp_registers tf_regs[] = {
  244. tf_regs(0),
  245. tf_regs(1),
  246. tf_regs(2),
  247. tf_regs(3),
  248. };
  249. static const struct dcn_dpp_shift tf_shift = {
  250. TF_REG_LIST_SH_MASK_DCN10(__SHIFT),
  251. TF_DEBUG_REG_LIST_SH_DCN10
  252. };
  253. static const struct dcn_dpp_mask tf_mask = {
  254. TF_REG_LIST_SH_MASK_DCN10(_MASK),
  255. TF_DEBUG_REG_LIST_MASK_DCN10
  256. };
  257. static const struct dcn_mpc_registers mpc_regs = {
  258. MPC_COMMON_REG_LIST_DCN1_0(0),
  259. MPC_COMMON_REG_LIST_DCN1_0(1),
  260. MPC_COMMON_REG_LIST_DCN1_0(2),
  261. MPC_COMMON_REG_LIST_DCN1_0(3),
  262. MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(0),
  263. MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(1),
  264. MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(2),
  265. MPC_OUT_MUX_COMMON_REG_LIST_DCN1_0(3)
  266. };
  267. static const struct dcn_mpc_shift mpc_shift = {
  268. MPC_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
  269. };
  270. static const struct dcn_mpc_mask mpc_mask = {
  271. MPC_COMMON_MASK_SH_LIST_DCN1_0(_MASK),
  272. };
  273. #define tg_regs(id)\
  274. [id] = {TG_COMMON_REG_LIST_DCN1_0(id)}
  275. static const struct dcn_optc_registers tg_regs[] = {
  276. tg_regs(0),
  277. tg_regs(1),
  278. tg_regs(2),
  279. tg_regs(3),
  280. };
  281. static const struct dcn_optc_shift tg_shift = {
  282. TG_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
  283. };
  284. static const struct dcn_optc_mask tg_mask = {
  285. TG_COMMON_MASK_SH_LIST_DCN1_0(_MASK)
  286. };
  287. static const struct bios_registers bios_regs = {
  288. NBIO_SR(BIOS_SCRATCH_3),
  289. NBIO_SR(BIOS_SCRATCH_6)
  290. };
  291. #define hubp_regs(id)\
  292. [id] = {\
  293. HUBP_REG_LIST_DCN10(id)\
  294. }
  295. static const struct dcn_mi_registers hubp_regs[] = {
  296. hubp_regs(0),
  297. hubp_regs(1),
  298. hubp_regs(2),
  299. hubp_regs(3),
  300. };
  301. static const struct dcn_mi_shift hubp_shift = {
  302. HUBP_MASK_SH_LIST_DCN10(__SHIFT)
  303. };
  304. static const struct dcn_mi_mask hubp_mask = {
  305. HUBP_MASK_SH_LIST_DCN10(_MASK)
  306. };
  307. static const struct dcn_hubbub_registers hubbub_reg = {
  308. HUBBUB_REG_LIST_DCN10(0)
  309. };
  310. static const struct dcn_hubbub_shift hubbub_shift = {
  311. HUBBUB_MASK_SH_LIST_DCN10(__SHIFT)
  312. };
  313. static const struct dcn_hubbub_mask hubbub_mask = {
  314. HUBBUB_MASK_SH_LIST_DCN10(_MASK)
  315. };
  316. #define clk_src_regs(index, pllid)\
  317. [index] = {\
  318. CS_COMMON_REG_LIST_DCN1_0(index, pllid),\
  319. }
  320. static const struct dce110_clk_src_regs clk_src_regs[] = {
  321. clk_src_regs(0, A),
  322. clk_src_regs(1, B),
  323. clk_src_regs(2, C),
  324. clk_src_regs(3, D)
  325. };
  326. static const struct dce110_clk_src_shift cs_shift = {
  327. CS_COMMON_MASK_SH_LIST_DCN1_0(__SHIFT)
  328. };
  329. static const struct dce110_clk_src_mask cs_mask = {
  330. CS_COMMON_MASK_SH_LIST_DCN1_0(_MASK)
  331. };
  332. static const struct resource_caps res_cap = {
  333. .num_timing_generator = 4,
  334. .num_video_plane = 4,
  335. .num_audio = 4,
  336. .num_stream_encoder = 4,
  337. .num_pll = 4,
  338. };
  339. static const struct dc_debug debug_defaults_drv = {
  340. .sanity_checks = true,
  341. .disable_dmcu = true,
  342. .force_abm_enable = false,
  343. .timing_trace = false,
  344. .clock_trace = true,
  345. /* raven smu dones't allow 0 disp clk,
  346. * smu min disp clk limit is 50Mhz
  347. * keep min disp clk 100Mhz avoid smu hang
  348. */
  349. .min_disp_clk_khz = 100000,
  350. .disable_pplib_clock_request = true,
  351. .disable_pplib_wm_range = false,
  352. .pplib_wm_report_mode = WM_REPORT_DEFAULT,
  353. .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
  354. .force_single_disp_pipe_split = true,
  355. .disable_dcc = DCC_ENABLE,
  356. .voltage_align_fclk = true,
  357. .disable_stereo_support = true,
  358. .vsr_support = true,
  359. .performance_trace = false,
  360. .az_endpoint_mute_only = true,
  361. .recovery_enabled = false, /*enable this by default after testing.*/
  362. .max_downscale_src_width = 3840,
  363. };
  364. static const struct dc_debug debug_defaults_diags = {
  365. .disable_dmcu = true,
  366. .force_abm_enable = false,
  367. .timing_trace = true,
  368. .clock_trace = true,
  369. .disable_stutter = true,
  370. .disable_pplib_clock_request = true,
  371. .disable_pplib_wm_range = true
  372. };
  373. static void dcn10_dpp_destroy(struct dpp **dpp)
  374. {
  375. kfree(TO_DCN10_DPP(*dpp));
  376. *dpp = NULL;
  377. }
  378. static struct dpp *dcn10_dpp_create(
  379. struct dc_context *ctx,
  380. uint32_t inst)
  381. {
  382. struct dcn10_dpp *dpp =
  383. kzalloc(sizeof(struct dcn10_dpp), GFP_KERNEL);
  384. if (!dpp)
  385. return NULL;
  386. dpp1_construct(dpp, ctx, inst,
  387. &tf_regs[inst], &tf_shift, &tf_mask);
  388. return &dpp->base;
  389. }
  390. static struct input_pixel_processor *dcn10_ipp_create(
  391. struct dc_context *ctx, uint32_t inst)
  392. {
  393. struct dcn10_ipp *ipp =
  394. kzalloc(sizeof(struct dcn10_ipp), GFP_KERNEL);
  395. if (!ipp) {
  396. BREAK_TO_DEBUGGER();
  397. return NULL;
  398. }
  399. dcn10_ipp_construct(ipp, ctx, inst,
  400. &ipp_regs[inst], &ipp_shift, &ipp_mask);
  401. return &ipp->base;
  402. }
  403. static struct output_pixel_processor *dcn10_opp_create(
  404. struct dc_context *ctx, uint32_t inst)
  405. {
  406. struct dcn10_opp *opp =
  407. kzalloc(sizeof(struct dcn10_opp), GFP_KERNEL);
  408. if (!opp) {
  409. BREAK_TO_DEBUGGER();
  410. return NULL;
  411. }
  412. dcn10_opp_construct(opp, ctx, inst,
  413. &opp_regs[inst], &opp_shift, &opp_mask);
  414. return &opp->base;
  415. }
  416. static struct mpc *dcn10_mpc_create(struct dc_context *ctx)
  417. {
  418. struct dcn10_mpc *mpc10 = kzalloc(sizeof(struct dcn10_mpc),
  419. GFP_KERNEL);
  420. if (!mpc10)
  421. return NULL;
  422. dcn10_mpc_construct(mpc10, ctx,
  423. &mpc_regs,
  424. &mpc_shift,
  425. &mpc_mask,
  426. 4);
  427. return &mpc10->base;
  428. }
  429. static struct hubbub *dcn10_hubbub_create(struct dc_context *ctx)
  430. {
  431. struct hubbub *hubbub = kzalloc(sizeof(struct hubbub),
  432. GFP_KERNEL);
  433. if (!hubbub)
  434. return NULL;
  435. hubbub1_construct(hubbub, ctx,
  436. &hubbub_reg,
  437. &hubbub_shift,
  438. &hubbub_mask);
  439. return hubbub;
  440. }
  441. static struct timing_generator *dcn10_timing_generator_create(
  442. struct dc_context *ctx,
  443. uint32_t instance)
  444. {
  445. struct optc *tgn10 =
  446. kzalloc(sizeof(struct optc), GFP_KERNEL);
  447. if (!tgn10)
  448. return NULL;
  449. tgn10->base.inst = instance;
  450. tgn10->base.ctx = ctx;
  451. tgn10->tg_regs = &tg_regs[instance];
  452. tgn10->tg_shift = &tg_shift;
  453. tgn10->tg_mask = &tg_mask;
  454. dcn10_timing_generator_init(tgn10);
  455. return &tgn10->base;
  456. }
  457. static const struct encoder_feature_support link_enc_feature = {
  458. .max_hdmi_deep_color = COLOR_DEPTH_121212,
  459. .max_hdmi_pixel_clock = 600000,
  460. .ycbcr420_supported = true,
  461. .flags.bits.IS_HBR2_CAPABLE = true,
  462. .flags.bits.IS_HBR3_CAPABLE = true,
  463. .flags.bits.IS_TPS3_CAPABLE = true,
  464. .flags.bits.IS_TPS4_CAPABLE = true,
  465. .flags.bits.IS_YCBCR_CAPABLE = true
  466. };
  467. struct link_encoder *dcn10_link_encoder_create(
  468. const struct encoder_init_data *enc_init_data)
  469. {
  470. struct dcn10_link_encoder *enc10 =
  471. kzalloc(sizeof(struct dcn10_link_encoder), GFP_KERNEL);
  472. if (!enc10)
  473. return NULL;
  474. dcn10_link_encoder_construct(enc10,
  475. enc_init_data,
  476. &link_enc_feature,
  477. &link_enc_regs[enc_init_data->transmitter],
  478. &link_enc_aux_regs[enc_init_data->channel - 1],
  479. &link_enc_hpd_regs[enc_init_data->hpd_source],
  480. &le_shift,
  481. &le_mask);
  482. return &enc10->base;
  483. }
  484. struct clock_source *dcn10_clock_source_create(
  485. struct dc_context *ctx,
  486. struct dc_bios *bios,
  487. enum clock_source_id id,
  488. const struct dce110_clk_src_regs *regs,
  489. bool dp_clk_src)
  490. {
  491. struct dce110_clk_src *clk_src =
  492. kzalloc(sizeof(struct dce110_clk_src), GFP_KERNEL);
  493. if (!clk_src)
  494. return NULL;
  495. if (dce110_clk_src_construct(clk_src, ctx, bios, id,
  496. regs, &cs_shift, &cs_mask)) {
  497. clk_src->base.dp_clk_src = dp_clk_src;
  498. return &clk_src->base;
  499. }
  500. BREAK_TO_DEBUGGER();
  501. return NULL;
  502. }
  503. static void read_dce_straps(
  504. struct dc_context *ctx,
  505. struct resource_straps *straps)
  506. {
  507. generic_reg_get(ctx, mmDC_PINSTRAPS + BASE(mmDC_PINSTRAPS_BASE_IDX),
  508. FN(DC_PINSTRAPS, DC_PINSTRAPS_AUDIO), &straps->dc_pinstraps_audio);
  509. }
  510. static struct audio *create_audio(
  511. struct dc_context *ctx, unsigned int inst)
  512. {
  513. return dce_audio_create(ctx, inst,
  514. &audio_regs[inst], &audio_shift, &audio_mask);
  515. }
  516. static struct stream_encoder *dcn10_stream_encoder_create(
  517. enum engine_id eng_id,
  518. struct dc_context *ctx)
  519. {
  520. struct dcn10_stream_encoder *enc1 =
  521. kzalloc(sizeof(struct dcn10_stream_encoder), GFP_KERNEL);
  522. if (!enc1)
  523. return NULL;
  524. dcn10_stream_encoder_construct(enc1, ctx, ctx->dc_bios, eng_id,
  525. &stream_enc_regs[eng_id],
  526. &se_shift, &se_mask);
  527. return &enc1->base;
  528. }
  529. static const struct dce_hwseq_registers hwseq_reg = {
  530. HWSEQ_DCN1_REG_LIST()
  531. };
  532. static const struct dce_hwseq_shift hwseq_shift = {
  533. HWSEQ_DCN1_MASK_SH_LIST(__SHIFT)
  534. };
  535. static const struct dce_hwseq_mask hwseq_mask = {
  536. HWSEQ_DCN1_MASK_SH_LIST(_MASK)
  537. };
  538. static struct dce_hwseq *dcn10_hwseq_create(
  539. struct dc_context *ctx)
  540. {
  541. struct dce_hwseq *hws = kzalloc(sizeof(struct dce_hwseq), GFP_KERNEL);
  542. if (hws) {
  543. hws->ctx = ctx;
  544. hws->regs = &hwseq_reg;
  545. hws->shifts = &hwseq_shift;
  546. hws->masks = &hwseq_mask;
  547. hws->wa.DEGVIDCN10_253 = true;
  548. hws->wa.false_optc_underflow = true;
  549. }
  550. return hws;
  551. }
  552. static const struct resource_create_funcs res_create_funcs = {
  553. .read_dce_straps = read_dce_straps,
  554. .create_audio = create_audio,
  555. .create_stream_encoder = dcn10_stream_encoder_create,
  556. .create_hwseq = dcn10_hwseq_create,
  557. };
  558. static const struct resource_create_funcs res_create_maximus_funcs = {
  559. .read_dce_straps = NULL,
  560. .create_audio = NULL,
  561. .create_stream_encoder = NULL,
  562. .create_hwseq = dcn10_hwseq_create,
  563. };
  564. void dcn10_clock_source_destroy(struct clock_source **clk_src)
  565. {
  566. kfree(TO_DCE110_CLK_SRC(*clk_src));
  567. *clk_src = NULL;
  568. }
  569. static struct pp_smu_funcs_rv *dcn10_pp_smu_create(struct dc_context *ctx)
  570. {
  571. struct pp_smu_funcs_rv *pp_smu = kzalloc(sizeof(*pp_smu), GFP_KERNEL);
  572. if (!pp_smu)
  573. return pp_smu;
  574. dm_pp_get_funcs_rv(ctx, pp_smu);
  575. return pp_smu;
  576. }
  577. static void destruct(struct dcn10_resource_pool *pool)
  578. {
  579. unsigned int i;
  580. for (i = 0; i < pool->base.stream_enc_count; i++) {
  581. if (pool->base.stream_enc[i] != NULL) {
  582. /* TODO: free dcn version of stream encoder once implemented
  583. * rather than using virtual stream encoder
  584. */
  585. kfree(pool->base.stream_enc[i]);
  586. pool->base.stream_enc[i] = NULL;
  587. }
  588. }
  589. if (pool->base.mpc != NULL) {
  590. kfree(TO_DCN10_MPC(pool->base.mpc));
  591. pool->base.mpc = NULL;
  592. }
  593. if (pool->base.hubbub != NULL) {
  594. kfree(pool->base.hubbub);
  595. pool->base.hubbub = NULL;
  596. }
  597. for (i = 0; i < pool->base.pipe_count; i++) {
  598. if (pool->base.opps[i] != NULL)
  599. pool->base.opps[i]->funcs->opp_destroy(&pool->base.opps[i]);
  600. if (pool->base.dpps[i] != NULL)
  601. dcn10_dpp_destroy(&pool->base.dpps[i]);
  602. if (pool->base.ipps[i] != NULL)
  603. pool->base.ipps[i]->funcs->ipp_destroy(&pool->base.ipps[i]);
  604. if (pool->base.hubps[i] != NULL) {
  605. kfree(TO_DCN10_HUBP(pool->base.hubps[i]));
  606. pool->base.hubps[i] = NULL;
  607. }
  608. if (pool->base.irqs != NULL) {
  609. dal_irq_service_destroy(&pool->base.irqs);
  610. }
  611. if (pool->base.timing_generators[i] != NULL) {
  612. kfree(DCN10TG_FROM_TG(pool->base.timing_generators[i]));
  613. pool->base.timing_generators[i] = NULL;
  614. }
  615. }
  616. for (i = 0; i < pool->base.stream_enc_count; i++)
  617. kfree(pool->base.stream_enc[i]);
  618. for (i = 0; i < pool->base.audio_count; i++) {
  619. if (pool->base.audios[i])
  620. dce_aud_destroy(&pool->base.audios[i]);
  621. }
  622. for (i = 0; i < pool->base.clk_src_count; i++) {
  623. if (pool->base.clock_sources[i] != NULL) {
  624. dcn10_clock_source_destroy(&pool->base.clock_sources[i]);
  625. pool->base.clock_sources[i] = NULL;
  626. }
  627. }
  628. if (pool->base.dp_clock_source != NULL) {
  629. dcn10_clock_source_destroy(&pool->base.dp_clock_source);
  630. pool->base.dp_clock_source = NULL;
  631. }
  632. if (pool->base.abm != NULL)
  633. dce_abm_destroy(&pool->base.abm);
  634. if (pool->base.dmcu != NULL)
  635. dce_dmcu_destroy(&pool->base.dmcu);
  636. if (pool->base.display_clock != NULL)
  637. dce_disp_clk_destroy(&pool->base.display_clock);
  638. kfree(pool->base.pp_smu);
  639. }
  640. static struct hubp *dcn10_hubp_create(
  641. struct dc_context *ctx,
  642. uint32_t inst)
  643. {
  644. struct dcn10_hubp *hubp1 =
  645. kzalloc(sizeof(struct dcn10_hubp), GFP_KERNEL);
  646. if (!hubp1)
  647. return NULL;
  648. dcn10_hubp_construct(hubp1, ctx, inst,
  649. &hubp_regs[inst], &hubp_shift, &hubp_mask);
  650. return &hubp1->base;
  651. }
  652. static void get_pixel_clock_parameters(
  653. const struct pipe_ctx *pipe_ctx,
  654. struct pixel_clk_params *pixel_clk_params)
  655. {
  656. const struct dc_stream_state *stream = pipe_ctx->stream;
  657. pixel_clk_params->requested_pix_clk = stream->timing.pix_clk_khz;
  658. pixel_clk_params->encoder_object_id = stream->sink->link->link_enc->id;
  659. pixel_clk_params->signal_type = pipe_ctx->stream->signal;
  660. pixel_clk_params->controller_id = pipe_ctx->stream_res.tg->inst + 1;
  661. /* TODO: un-hardcode*/
  662. pixel_clk_params->requested_sym_clk = LINK_RATE_LOW *
  663. LINK_RATE_REF_FREQ_IN_KHZ;
  664. pixel_clk_params->flags.ENABLE_SS = 0;
  665. pixel_clk_params->color_depth =
  666. stream->timing.display_color_depth;
  667. pixel_clk_params->flags.DISPLAY_BLANKED = 1;
  668. pixel_clk_params->pixel_encoding = stream->timing.pixel_encoding;
  669. if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR422)
  670. pixel_clk_params->color_depth = COLOR_DEPTH_888;
  671. if (stream->timing.pixel_encoding == PIXEL_ENCODING_YCBCR420)
  672. pixel_clk_params->requested_pix_clk /= 2;
  673. }
  674. static void build_clamping_params(struct dc_stream_state *stream)
  675. {
  676. stream->clamping.clamping_level = CLAMPING_FULL_RANGE;
  677. stream->clamping.c_depth = stream->timing.display_color_depth;
  678. stream->clamping.pixel_encoding = stream->timing.pixel_encoding;
  679. }
  680. static void build_pipe_hw_param(struct pipe_ctx *pipe_ctx)
  681. {
  682. get_pixel_clock_parameters(pipe_ctx, &pipe_ctx->stream_res.pix_clk_params);
  683. pipe_ctx->clock_source->funcs->get_pix_clk_dividers(
  684. pipe_ctx->clock_source,
  685. &pipe_ctx->stream_res.pix_clk_params,
  686. &pipe_ctx->pll_settings);
  687. pipe_ctx->stream->clamping.pixel_encoding = pipe_ctx->stream->timing.pixel_encoding;
  688. resource_build_bit_depth_reduction_params(pipe_ctx->stream,
  689. &pipe_ctx->stream->bit_depth_params);
  690. build_clamping_params(pipe_ctx->stream);
  691. }
  692. static enum dc_status build_mapped_resource(
  693. const struct dc *dc,
  694. struct dc_state *context,
  695. struct dc_stream_state *stream)
  696. {
  697. struct pipe_ctx *pipe_ctx = resource_get_head_pipe_for_stream(&context->res_ctx, stream);
  698. /*TODO Seems unneeded anymore */
  699. /* if (old_context && resource_is_stream_unchanged(old_context, stream)) {
  700. if (stream != NULL && old_context->streams[i] != NULL) {
  701. todo: shouldn't have to copy missing parameter here
  702. resource_build_bit_depth_reduction_params(stream,
  703. &stream->bit_depth_params);
  704. stream->clamping.pixel_encoding =
  705. stream->timing.pixel_encoding;
  706. resource_build_bit_depth_reduction_params(stream,
  707. &stream->bit_depth_params);
  708. build_clamping_params(stream);
  709. continue;
  710. }
  711. }
  712. */
  713. if (!pipe_ctx)
  714. return DC_ERROR_UNEXPECTED;
  715. build_pipe_hw_param(pipe_ctx);
  716. return DC_OK;
  717. }
  718. enum dc_status dcn10_add_stream_to_ctx(
  719. struct dc *dc,
  720. struct dc_state *new_ctx,
  721. struct dc_stream_state *dc_stream)
  722. {
  723. enum dc_status result = DC_ERROR_UNEXPECTED;
  724. result = resource_map_pool_resources(dc, new_ctx, dc_stream);
  725. if (result == DC_OK)
  726. result = resource_map_phy_clock_resources(dc, new_ctx, dc_stream);
  727. if (result == DC_OK)
  728. result = build_mapped_resource(dc, new_ctx, dc_stream);
  729. return result;
  730. }
  731. static struct pipe_ctx *dcn10_acquire_idle_pipe_for_layer(
  732. struct dc_state *context,
  733. const struct resource_pool *pool,
  734. struct dc_stream_state *stream)
  735. {
  736. struct resource_context *res_ctx = &context->res_ctx;
  737. struct pipe_ctx *head_pipe = resource_get_head_pipe_for_stream(res_ctx, stream);
  738. struct pipe_ctx *idle_pipe = find_idle_secondary_pipe(res_ctx, pool);
  739. if (!head_pipe) {
  740. ASSERT(0);
  741. return NULL;
  742. }
  743. if (!idle_pipe)
  744. return NULL;
  745. idle_pipe->stream = head_pipe->stream;
  746. idle_pipe->stream_res.tg = head_pipe->stream_res.tg;
  747. idle_pipe->stream_res.abm = head_pipe->stream_res.abm;
  748. idle_pipe->stream_res.opp = head_pipe->stream_res.opp;
  749. idle_pipe->plane_res.hubp = pool->hubps[idle_pipe->pipe_idx];
  750. idle_pipe->plane_res.ipp = pool->ipps[idle_pipe->pipe_idx];
  751. idle_pipe->plane_res.dpp = pool->dpps[idle_pipe->pipe_idx];
  752. idle_pipe->plane_res.mpcc_inst = pool->dpps[idle_pipe->pipe_idx]->inst;
  753. return idle_pipe;
  754. }
  755. static bool dcn10_get_dcc_compression_cap(const struct dc *dc,
  756. const struct dc_dcc_surface_param *input,
  757. struct dc_surface_dcc_cap *output)
  758. {
  759. return dc->res_pool->hubbub->funcs->get_dcc_compression_cap(
  760. dc->res_pool->hubbub,
  761. input,
  762. output);
  763. }
  764. static void dcn10_destroy_resource_pool(struct resource_pool **pool)
  765. {
  766. struct dcn10_resource_pool *dcn10_pool = TO_DCN10_RES_POOL(*pool);
  767. destruct(dcn10_pool);
  768. kfree(dcn10_pool);
  769. *pool = NULL;
  770. }
  771. static enum dc_status dcn10_validate_plane(const struct dc_plane_state *plane_state, struct dc_caps *caps)
  772. {
  773. if (plane_state->format >= SURFACE_PIXEL_FORMAT_VIDEO_BEGIN
  774. && caps->max_video_width != 0
  775. && plane_state->src_rect.width > caps->max_video_width)
  776. return DC_FAIL_SURFACE_VALIDATE;
  777. return DC_OK;
  778. }
  779. static struct dc_cap_funcs cap_funcs = {
  780. .get_dcc_compression_cap = dcn10_get_dcc_compression_cap
  781. };
  782. static struct resource_funcs dcn10_res_pool_funcs = {
  783. .destroy = dcn10_destroy_resource_pool,
  784. .link_enc_create = dcn10_link_encoder_create,
  785. .validate_bandwidth = dcn_validate_bandwidth,
  786. .acquire_idle_pipe_for_layer = dcn10_acquire_idle_pipe_for_layer,
  787. .validate_plane = dcn10_validate_plane,
  788. .add_stream_to_ctx = dcn10_add_stream_to_ctx
  789. };
  790. static uint32_t read_pipe_fuses(struct dc_context *ctx)
  791. {
  792. uint32_t value = dm_read_reg_soc15(ctx, mmCC_DC_PIPE_DIS, 0);
  793. /* RV1 support max 4 pipes */
  794. value = value & 0xf;
  795. return value;
  796. }
  797. static bool construct(
  798. uint8_t num_virtual_links,
  799. struct dc *dc,
  800. struct dcn10_resource_pool *pool)
  801. {
  802. int i;
  803. int j;
  804. struct dc_context *ctx = dc->ctx;
  805. uint32_t pipe_fuses = read_pipe_fuses(ctx);
  806. ctx->dc_bios->regs = &bios_regs;
  807. pool->base.res_cap = &res_cap;
  808. pool->base.funcs = &dcn10_res_pool_funcs;
  809. /*
  810. * TODO fill in from actual raven resource when we create
  811. * more than virtual encoder
  812. */
  813. /*************************************************
  814. * Resource + asic cap harcoding *
  815. *************************************************/
  816. pool->base.underlay_pipe_index = NO_UNDERLAY_PIPE;
  817. /* max pipe num for ASIC before check pipe fuses */
  818. pool->base.pipe_count = pool->base.res_cap->num_timing_generator;
  819. dc->caps.max_video_width = 3840;
  820. dc->caps.max_downscale_ratio = 200;
  821. dc->caps.i2c_speed_in_khz = 100;
  822. dc->caps.max_cursor_size = 256;
  823. dc->caps.max_slave_planes = 1;
  824. dc->caps.is_apu = true;
  825. dc->caps.post_blend_color_processing = false;
  826. if (dc->ctx->dce_environment == DCE_ENV_PRODUCTION_DRV)
  827. dc->debug = debug_defaults_drv;
  828. else
  829. dc->debug = debug_defaults_diags;
  830. /*************************************************
  831. * Create resources *
  832. *************************************************/
  833. pool->base.clock_sources[DCN10_CLK_SRC_PLL0] =
  834. dcn10_clock_source_create(ctx, ctx->dc_bios,
  835. CLOCK_SOURCE_COMBO_PHY_PLL0,
  836. &clk_src_regs[0], false);
  837. pool->base.clock_sources[DCN10_CLK_SRC_PLL1] =
  838. dcn10_clock_source_create(ctx, ctx->dc_bios,
  839. CLOCK_SOURCE_COMBO_PHY_PLL1,
  840. &clk_src_regs[1], false);
  841. pool->base.clock_sources[DCN10_CLK_SRC_PLL2] =
  842. dcn10_clock_source_create(ctx, ctx->dc_bios,
  843. CLOCK_SOURCE_COMBO_PHY_PLL2,
  844. &clk_src_regs[2], false);
  845. pool->base.clock_sources[DCN10_CLK_SRC_PLL3] =
  846. dcn10_clock_source_create(ctx, ctx->dc_bios,
  847. CLOCK_SOURCE_COMBO_PHY_PLL3,
  848. &clk_src_regs[3], false);
  849. pool->base.clk_src_count = DCN10_CLK_SRC_TOTAL;
  850. pool->base.dp_clock_source =
  851. dcn10_clock_source_create(ctx, ctx->dc_bios,
  852. CLOCK_SOURCE_ID_DP_DTO,
  853. /* todo: not reuse phy_pll registers */
  854. &clk_src_regs[0], true);
  855. for (i = 0; i < pool->base.clk_src_count; i++) {
  856. if (pool->base.clock_sources[i] == NULL) {
  857. dm_error("DC: failed to create clock sources!\n");
  858. BREAK_TO_DEBUGGER();
  859. goto fail;
  860. }
  861. }
  862. pool->base.display_clock = dce120_disp_clk_create(ctx);
  863. if (pool->base.display_clock == NULL) {
  864. dm_error("DC: failed to create display clock!\n");
  865. BREAK_TO_DEBUGGER();
  866. goto fail;
  867. }
  868. pool->base.dmcu = dcn10_dmcu_create(ctx,
  869. &dmcu_regs,
  870. &dmcu_shift,
  871. &dmcu_mask);
  872. if (pool->base.dmcu == NULL) {
  873. dm_error("DC: failed to create dmcu!\n");
  874. BREAK_TO_DEBUGGER();
  875. goto fail;
  876. }
  877. pool->base.abm = dce_abm_create(ctx,
  878. &abm_regs,
  879. &abm_shift,
  880. &abm_mask);
  881. if (pool->base.abm == NULL) {
  882. dm_error("DC: failed to create abm!\n");
  883. BREAK_TO_DEBUGGER();
  884. goto fail;
  885. }
  886. dml_init_instance(&dc->dml, DML_PROJECT_RAVEN1);
  887. memcpy(dc->dcn_ip, &dcn10_ip_defaults, sizeof(dcn10_ip_defaults));
  888. memcpy(dc->dcn_soc, &dcn10_soc_defaults, sizeof(dcn10_soc_defaults));
  889. if (ASICREV_IS_RV1_F0(dc->ctx->asic_id.hw_internal_rev)) {
  890. dc->dcn_soc->urgent_latency = 3;
  891. dc->debug.disable_dmcu = true;
  892. dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 41.60f;
  893. }
  894. dc->dcn_soc->number_of_channels = dc->ctx->asic_id.vram_width / ddr4_dram_width;
  895. ASSERT(dc->dcn_soc->number_of_channels < 3);
  896. if (dc->dcn_soc->number_of_channels == 0)/*old sbios bug*/
  897. dc->dcn_soc->number_of_channels = 2;
  898. if (dc->dcn_soc->number_of_channels == 1) {
  899. dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 19.2f;
  900. dc->dcn_soc->fabric_and_dram_bandwidth_vnom0p8 = 17.066f;
  901. dc->dcn_soc->fabric_and_dram_bandwidth_vmid0p72 = 14.933f;
  902. dc->dcn_soc->fabric_and_dram_bandwidth_vmin0p65 = 12.8f;
  903. if (ASICREV_IS_RV1_F0(dc->ctx->asic_id.hw_internal_rev)) {
  904. dc->dcn_soc->fabric_and_dram_bandwidth_vmax0p9 = 20.80f;
  905. }
  906. }
  907. pool->base.pp_smu = dcn10_pp_smu_create(ctx);
  908. if (!dc->debug.disable_pplib_clock_request)
  909. dcn_bw_update_from_pplib(dc);
  910. dcn_bw_sync_calcs_and_dml(dc);
  911. if (!dc->debug.disable_pplib_wm_range) {
  912. dc->res_pool = &pool->base;
  913. dcn_bw_notify_pplib_of_wm_ranges(dc);
  914. }
  915. {
  916. struct irq_service_init_data init_data;
  917. init_data.ctx = dc->ctx;
  918. pool->base.irqs = dal_irq_service_dcn10_create(&init_data);
  919. if (!pool->base.irqs)
  920. goto fail;
  921. }
  922. /* index to valid pipe resource */
  923. j = 0;
  924. /* mem input -> ipp -> dpp -> opp -> TG */
  925. for (i = 0; i < pool->base.pipe_count; i++) {
  926. /* if pipe is disabled, skip instance of HW pipe,
  927. * i.e, skip ASIC register instance
  928. */
  929. if ((pipe_fuses & (1 << i)) != 0)
  930. continue;
  931. pool->base.hubps[j] = dcn10_hubp_create(ctx, i);
  932. if (pool->base.hubps[j] == NULL) {
  933. BREAK_TO_DEBUGGER();
  934. dm_error(
  935. "DC: failed to create memory input!\n");
  936. goto fail;
  937. }
  938. pool->base.ipps[j] = dcn10_ipp_create(ctx, i);
  939. if (pool->base.ipps[j] == NULL) {
  940. BREAK_TO_DEBUGGER();
  941. dm_error(
  942. "DC: failed to create input pixel processor!\n");
  943. goto fail;
  944. }
  945. pool->base.dpps[j] = dcn10_dpp_create(ctx, i);
  946. if (pool->base.dpps[j] == NULL) {
  947. BREAK_TO_DEBUGGER();
  948. dm_error(
  949. "DC: failed to create dpp!\n");
  950. goto fail;
  951. }
  952. pool->base.opps[j] = dcn10_opp_create(ctx, i);
  953. if (pool->base.opps[j] == NULL) {
  954. BREAK_TO_DEBUGGER();
  955. dm_error(
  956. "DC: failed to create output pixel processor!\n");
  957. goto fail;
  958. }
  959. pool->base.timing_generators[j] = dcn10_timing_generator_create(
  960. ctx, i);
  961. if (pool->base.timing_generators[j] == NULL) {
  962. BREAK_TO_DEBUGGER();
  963. dm_error("DC: failed to create tg!\n");
  964. goto fail;
  965. }
  966. /* check next valid pipe */
  967. j++;
  968. }
  969. /* valid pipe num */
  970. pool->base.pipe_count = j;
  971. pool->base.timing_generator_count = j;
  972. /* within dml lib, it is hard code to 4. If ASIC pipe is fused,
  973. * the value may be changed
  974. */
  975. dc->dml.ip.max_num_dpp = pool->base.pipe_count;
  976. dc->dcn_ip->max_num_dpp = pool->base.pipe_count;
  977. pool->base.mpc = dcn10_mpc_create(ctx);
  978. if (pool->base.mpc == NULL) {
  979. BREAK_TO_DEBUGGER();
  980. dm_error("DC: failed to create mpc!\n");
  981. goto fail;
  982. }
  983. pool->base.hubbub = dcn10_hubbub_create(ctx);
  984. if (pool->base.hubbub == NULL) {
  985. BREAK_TO_DEBUGGER();
  986. dm_error("DC: failed to create hubbub!\n");
  987. goto fail;
  988. }
  989. if (!resource_construct(num_virtual_links, dc, &pool->base,
  990. (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) ?
  991. &res_create_funcs : &res_create_maximus_funcs)))
  992. goto fail;
  993. dcn10_hw_sequencer_construct(dc);
  994. dc->caps.max_planes = pool->base.pipe_count;
  995. dc->cap_funcs = cap_funcs;
  996. return true;
  997. fail:
  998. destruct(pool);
  999. return false;
  1000. }
  1001. struct resource_pool *dcn10_create_resource_pool(
  1002. uint8_t num_virtual_links,
  1003. struct dc *dc)
  1004. {
  1005. struct dcn10_resource_pool *pool =
  1006. kzalloc(sizeof(struct dcn10_resource_pool), GFP_KERNEL);
  1007. if (!pool)
  1008. return NULL;
  1009. if (construct(num_virtual_links, dc, pool))
  1010. return &pool->base;
  1011. BREAK_TO_DEBUGGER();
  1012. return NULL;
  1013. }