dc.h 79 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558
  1. /*
  2. * Copyright 2012-2023 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. #ifndef DC_INTERFACE_H_
  26. #define DC_INTERFACE_H_
  27. #include "dc_types.h"
  28. #include "dc_state.h"
  29. #include "dc_plane.h"
  30. #include "grph_object_defs.h"
  31. #include "logger_types.h"
  32. #include "hdcp_msg_types.h"
  33. #include "gpio_types.h"
  34. #include "link_service_types.h"
  35. #include "grph_object_ctrl_defs.h"
  36. #include <inc/hw/opp.h>
  37. #include "hwss/hw_sequencer.h"
  38. #include "inc/compressor.h"
  39. #include "inc/hw/dmcu.h"
  40. #include "dml/display_mode_lib.h"
  41. #include "dml2/dml2_wrapper.h"
  42. #include "dmub/inc/dmub_cmd.h"
  43. #include "spl/dc_spl_types.h"
  44. struct abm_save_restore;
  45. /* forward declaration */
  46. struct aux_payload;
  47. struct set_config_cmd_payload;
  48. struct dmub_notification;
  49. #define DC_VER "3.2.301"
  50. #define MAX_SURFACES 4
  51. #define MAX_PLANES 6
  52. #define MAX_STREAMS 6
  53. #define MIN_VIEWPORT_SIZE 12
  54. #define MAX_NUM_EDP 2
  55. #define MAX_HOST_ROUTERS_NUM 2
  56. /* Display Core Interfaces */
  57. struct dc_versions {
  58. const char *dc_ver;
  59. struct dmcu_version dmcu_version;
  60. };
  61. enum dp_protocol_version {
  62. DP_VERSION_1_4 = 0,
  63. DP_VERSION_2_1,
  64. DP_VERSION_UNKNOWN,
  65. };
  66. enum dc_plane_type {
  67. DC_PLANE_TYPE_INVALID,
  68. DC_PLANE_TYPE_DCE_RGB,
  69. DC_PLANE_TYPE_DCE_UNDERLAY,
  70. DC_PLANE_TYPE_DCN_UNIVERSAL,
  71. };
  72. // Sizes defined as multiples of 64KB
  73. enum det_size {
  74. DET_SIZE_DEFAULT = 0,
  75. DET_SIZE_192KB = 3,
  76. DET_SIZE_256KB = 4,
  77. DET_SIZE_320KB = 5,
  78. DET_SIZE_384KB = 6
  79. };
  80. struct dc_plane_cap {
  81. enum dc_plane_type type;
  82. uint32_t per_pixel_alpha : 1;
  83. struct {
  84. uint32_t argb8888 : 1;
  85. uint32_t nv12 : 1;
  86. uint32_t fp16 : 1;
  87. uint32_t p010 : 1;
  88. uint32_t ayuv : 1;
  89. } pixel_format_support;
  90. // max upscaling factor x1000
  91. // upscaling factors are always >= 1
  92. // for example, 1080p -> 8K is 4.0, or 4000 raw value
  93. struct {
  94. uint32_t argb8888;
  95. uint32_t nv12;
  96. uint32_t fp16;
  97. } max_upscale_factor;
  98. // max downscale factor x1000
  99. // downscale factors are always <= 1
  100. // for example, 8K -> 1080p is 0.25, or 250 raw value
  101. struct {
  102. uint32_t argb8888;
  103. uint32_t nv12;
  104. uint32_t fp16;
  105. } max_downscale_factor;
  106. // minimal width/height
  107. uint32_t min_width;
  108. uint32_t min_height;
  109. };
  110. /**
  111. * DOC: color-management-caps
  112. *
  113. * **Color management caps (DPP and MPC)**
  114. *
  115. * Modules/color calculates various color operations which are translated to
  116. * abstracted HW. DCE 5-12 had almost no important changes, but starting with
  117. * DCN1, every new generation comes with fairly major differences in color
  118. * pipeline. Therefore, we abstract color pipe capabilities so modules/DM can
  119. * decide mapping to HW block based on logical capabilities.
  120. */
  121. /**
  122. * struct rom_curve_caps - predefined transfer function caps for degamma and regamma
  123. * @srgb: RGB color space transfer func
  124. * @bt2020: BT.2020 transfer func
  125. * @gamma2_2: standard gamma
  126. * @pq: perceptual quantizer transfer function
  127. * @hlg: hybrid log–gamma transfer function
  128. */
  129. struct rom_curve_caps {
  130. uint16_t srgb : 1;
  131. uint16_t bt2020 : 1;
  132. uint16_t gamma2_2 : 1;
  133. uint16_t pq : 1;
  134. uint16_t hlg : 1;
  135. };
  136. /**
  137. * struct dpp_color_caps - color pipeline capabilities for display pipe and
  138. * plane blocks
  139. *
  140. * @dcn_arch: all DCE generations treated the same
  141. * @input_lut_shared: shared with DGAM. Input LUT is different than most LUTs,
  142. * just plain 256-entry lookup
  143. * @icsc: input color space conversion
  144. * @dgam_ram: programmable degamma LUT
  145. * @post_csc: post color space conversion, before gamut remap
  146. * @gamma_corr: degamma correction
  147. * @hw_3d_lut: 3D LUT support. It implies a shaper LUT before. It may be shared
  148. * with MPC by setting mpc:shared_3d_lut flag
  149. * @ogam_ram: programmable out/blend gamma LUT
  150. * @ocsc: output color space conversion
  151. * @dgam_rom_for_yuv: pre-defined degamma LUT for YUV planes
  152. * @dgam_rom_caps: pre-definied curve caps for degamma 1D LUT
  153. * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
  154. *
  155. * Note: hdr_mult and gamut remap (CTM) are always available in DPP (in that order)
  156. */
  157. struct dpp_color_caps {
  158. uint16_t dcn_arch : 1;
  159. uint16_t input_lut_shared : 1;
  160. uint16_t icsc : 1;
  161. uint16_t dgam_ram : 1;
  162. uint16_t post_csc : 1;
  163. uint16_t gamma_corr : 1;
  164. uint16_t hw_3d_lut : 1;
  165. uint16_t ogam_ram : 1;
  166. uint16_t ocsc : 1;
  167. uint16_t dgam_rom_for_yuv : 1;
  168. struct rom_curve_caps dgam_rom_caps;
  169. struct rom_curve_caps ogam_rom_caps;
  170. };
  171. /**
  172. * struct mpc_color_caps - color pipeline capabilities for multiple pipe and
  173. * plane combined blocks
  174. *
  175. * @gamut_remap: color transformation matrix
  176. * @ogam_ram: programmable out gamma LUT
  177. * @ocsc: output color space conversion matrix
  178. * @num_3dluts: MPC 3D LUT; always assumes a preceding shaper LUT
  179. * @shared_3d_lut: shared 3D LUT flag. Can be either DPP or MPC, but single
  180. * instance
  181. * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
  182. */
  183. struct mpc_color_caps {
  184. uint16_t gamut_remap : 1;
  185. uint16_t ogam_ram : 1;
  186. uint16_t ocsc : 1;
  187. uint16_t num_3dluts : 3;
  188. uint16_t shared_3d_lut:1;
  189. struct rom_curve_caps ogam_rom_caps;
  190. };
  191. /**
  192. * struct dc_color_caps - color pipes capabilities for DPP and MPC hw blocks
  193. * @dpp: color pipes caps for DPP
  194. * @mpc: color pipes caps for MPC
  195. */
  196. struct dc_color_caps {
  197. struct dpp_color_caps dpp;
  198. struct mpc_color_caps mpc;
  199. };
  200. struct dc_dmub_caps {
  201. bool psr;
  202. bool mclk_sw;
  203. bool subvp_psr;
  204. bool gecc_enable;
  205. uint8_t fams_ver;
  206. };
  207. struct dc_caps {
  208. uint32_t max_streams;
  209. uint32_t max_links;
  210. uint32_t max_audios;
  211. uint32_t max_slave_planes;
  212. uint32_t max_slave_yuv_planes;
  213. uint32_t max_slave_rgb_planes;
  214. uint32_t max_planes;
  215. uint32_t max_downscale_ratio;
  216. uint32_t i2c_speed_in_khz;
  217. uint32_t i2c_speed_in_khz_hdcp;
  218. uint32_t dmdata_alloc_size;
  219. unsigned int max_cursor_size;
  220. unsigned int max_video_width;
  221. /*
  222. * max video plane width that can be safely assumed to be always
  223. * supported by single DPP pipe.
  224. */
  225. unsigned int max_optimizable_video_width;
  226. unsigned int min_horizontal_blanking_period;
  227. int linear_pitch_alignment;
  228. bool dcc_const_color;
  229. bool dynamic_audio;
  230. bool is_apu;
  231. bool dual_link_dvi;
  232. bool post_blend_color_processing;
  233. bool force_dp_tps4_for_cp2520;
  234. bool disable_dp_clk_share;
  235. bool psp_setup_panel_mode;
  236. bool extended_aux_timeout_support;
  237. bool dmcub_support;
  238. bool zstate_support;
  239. bool ips_support;
  240. uint32_t num_of_internal_disp;
  241. enum dp_protocol_version max_dp_protocol_version;
  242. unsigned int mall_size_per_mem_channel;
  243. unsigned int mall_size_total;
  244. unsigned int cursor_cache_size;
  245. struct dc_plane_cap planes[MAX_PLANES];
  246. struct dc_color_caps color;
  247. struct dc_dmub_caps dmub_caps;
  248. bool dp_hpo;
  249. bool dp_hdmi21_pcon_support;
  250. bool edp_dsc_support;
  251. bool vbios_lttpr_aware;
  252. bool vbios_lttpr_enable;
  253. uint32_t max_otg_num;
  254. uint32_t max_cab_allocation_bytes;
  255. uint32_t cache_line_size;
  256. uint32_t cache_num_ways;
  257. uint16_t subvp_fw_processing_delay_us;
  258. uint8_t subvp_drr_max_vblank_margin_us;
  259. uint16_t subvp_prefetch_end_to_mall_start_us;
  260. uint8_t subvp_swath_height_margin_lines; // subvp start line must be aligned to 2 x swath height
  261. uint16_t subvp_pstate_allow_width_us;
  262. uint16_t subvp_vertical_int_margin_us;
  263. bool seamless_odm;
  264. uint32_t max_v_total;
  265. bool vtotal_limited_by_fp2;
  266. uint32_t max_disp_clock_khz_at_vmin;
  267. uint8_t subvp_drr_vblank_start_margin_us;
  268. bool cursor_not_scaled;
  269. bool dcmode_power_limits_present;
  270. bool sequential_ono;
  271. /* Conservative limit for DCC cases which require ODM4:1 to support*/
  272. uint32_t dcc_plane_width_limit;
  273. };
  274. struct dc_bug_wa {
  275. bool no_connect_phy_config;
  276. bool dedcn20_305_wa;
  277. bool skip_clock_update;
  278. bool lt_early_cr_pattern;
  279. struct {
  280. uint8_t uclk : 1;
  281. uint8_t fclk : 1;
  282. uint8_t dcfclk : 1;
  283. uint8_t dcfclk_ds: 1;
  284. } clock_update_disable_mask;
  285. bool skip_psr_ips_crtc_disable;
  286. };
  287. struct dc_dcc_surface_param {
  288. struct dc_size surface_size;
  289. enum surface_pixel_format format;
  290. unsigned int plane0_pitch;
  291. struct dc_size plane1_size;
  292. unsigned int plane1_pitch;
  293. union {
  294. enum swizzle_mode_values swizzle_mode;
  295. enum swizzle_mode_addr3_values swizzle_mode_addr3;
  296. };
  297. enum dc_scan_direction scan;
  298. };
  299. struct dc_dcc_setting {
  300. unsigned int max_compressed_blk_size;
  301. unsigned int max_uncompressed_blk_size;
  302. bool independent_64b_blks;
  303. //These bitfields to be used starting with DCN 3.0
  304. struct {
  305. uint32_t dcc_256_64_64 : 1;//available in ASICs before DCN 3.0 (the worst compression case)
  306. uint32_t dcc_128_128_uncontrained : 1; //available in ASICs before DCN 3.0
  307. uint32_t dcc_256_128_128 : 1; //available starting with DCN 3.0
  308. uint32_t dcc_256_256_unconstrained : 1; //available in ASICs before DCN 3.0 (the best compression case)
  309. uint32_t dcc_256_256 : 1; //available in ASICs starting with DCN 4.0x (the best compression case)
  310. uint32_t dcc_256_128 : 1; //available in ASICs starting with DCN 4.0x
  311. uint32_t dcc_256_64 : 1; //available in ASICs starting with DCN 4.0x (the worst compression case)
  312. } dcc_controls;
  313. };
  314. struct dc_surface_dcc_cap {
  315. union {
  316. struct {
  317. struct dc_dcc_setting rgb;
  318. } grph;
  319. struct {
  320. struct dc_dcc_setting luma;
  321. struct dc_dcc_setting chroma;
  322. } video;
  323. };
  324. bool capable;
  325. bool const_color_support;
  326. };
  327. struct dc_static_screen_params {
  328. struct {
  329. bool force_trigger;
  330. bool cursor_update;
  331. bool surface_update;
  332. bool overlay_update;
  333. } triggers;
  334. unsigned int num_frames;
  335. };
  336. /* Surface update type is used by dc_update_surfaces_and_stream
  337. * The update type is determined at the very beginning of the function based
  338. * on parameters passed in and decides how much programming (or updating) is
  339. * going to be done during the call.
  340. *
  341. * UPDATE_TYPE_FAST is used for really fast updates that do not require much
  342. * logical calculations or hardware register programming. This update MUST be
  343. * ISR safe on windows. Currently fast update will only be used to flip surface
  344. * address.
  345. *
  346. * UPDATE_TYPE_MED is used for slower updates which require significant hw
  347. * re-programming however do not affect bandwidth consumption or clock
  348. * requirements. At present, this is the level at which front end updates
  349. * that do not require us to run bw_calcs happen. These are in/out transfer func
  350. * updates, viewport offset changes, recout size changes and pixel depth changes.
  351. * This update can be done at ISR, but we want to minimize how often this happens.
  352. *
  353. * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
  354. * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
  355. * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
  356. * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
  357. * a full update. This cannot be done at ISR level and should be a rare event.
  358. * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
  359. * underscan we don't expect to see this call at all.
  360. */
  361. enum surface_update_type {
  362. UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
  363. UPDATE_TYPE_MED, /* ISR safe, most of programming needed, no bw/clk change*/
  364. UPDATE_TYPE_FULL, /* may need to shuffle resources */
  365. };
  366. /* Forward declaration*/
  367. struct dc;
  368. struct dc_plane_state;
  369. struct dc_state;
  370. struct dc_cap_funcs {
  371. bool (*get_dcc_compression_cap)(const struct dc *dc,
  372. const struct dc_dcc_surface_param *input,
  373. struct dc_surface_dcc_cap *output);
  374. bool (*get_subvp_en)(struct dc *dc, struct dc_state *context);
  375. };
  376. struct link_training_settings;
  377. union allow_lttpr_non_transparent_mode {
  378. struct {
  379. bool DP1_4A : 1;
  380. bool DP2_0 : 1;
  381. } bits;
  382. unsigned char raw;
  383. };
  384. /* Structure to hold configuration flags set by dm at dc creation. */
  385. struct dc_config {
  386. bool gpu_vm_support;
  387. bool disable_disp_pll_sharing;
  388. bool fbc_support;
  389. bool disable_fractional_pwm;
  390. bool allow_seamless_boot_optimization;
  391. bool seamless_boot_edp_requested;
  392. bool edp_not_connected;
  393. bool edp_no_power_sequencing;
  394. bool force_enum_edp;
  395. bool forced_clocks;
  396. union allow_lttpr_non_transparent_mode allow_lttpr_non_transparent_mode;
  397. bool multi_mon_pp_mclk_switch;
  398. bool disable_dmcu;
  399. bool enable_4to1MPC;
  400. bool enable_windowed_mpo_odm;
  401. bool forceHBR2CP2520; // Used for switching between test patterns TPS4 and CP2520
  402. uint32_t allow_edp_hotplug_detection;
  403. bool clamp_min_dcfclk;
  404. uint64_t vblank_alignment_dto_params;
  405. uint8_t vblank_alignment_max_frame_time_diff;
  406. bool is_asymmetric_memory;
  407. bool is_single_rank_dimm;
  408. bool is_vmin_only_asic;
  409. bool use_spl;
  410. bool prefer_easf;
  411. bool use_pipe_ctx_sync_logic;
  412. bool ignore_dpref_ss;
  413. bool enable_mipi_converter_optimization;
  414. bool use_default_clock_table;
  415. bool force_bios_enable_lttpr;
  416. uint8_t force_bios_fixed_vs;
  417. int sdpif_request_limit_words_per_umc;
  418. bool dc_mode_clk_limit_support;
  419. bool EnableMinDispClkODM;
  420. bool enable_auto_dpm_test_logs;
  421. unsigned int disable_ips;
  422. unsigned int disable_ips_in_vpb;
  423. bool usb4_bw_alloc_support;
  424. bool allow_0_dtb_clk;
  425. bool use_assr_psp_message;
  426. bool support_edp0_on_dp1;
  427. unsigned int enable_fpo_flicker_detection;
  428. bool disable_hbr_audio_dp2;
  429. bool consolidated_dpia_dp_lt;
  430. };
  431. enum visual_confirm {
  432. VISUAL_CONFIRM_DISABLE = 0,
  433. VISUAL_CONFIRM_SURFACE = 1,
  434. VISUAL_CONFIRM_HDR = 2,
  435. VISUAL_CONFIRM_MPCTREE = 4,
  436. VISUAL_CONFIRM_PSR = 5,
  437. VISUAL_CONFIRM_SWAPCHAIN = 6,
  438. VISUAL_CONFIRM_FAMS = 7,
  439. VISUAL_CONFIRM_SWIZZLE = 9,
  440. VISUAL_CONFIRM_REPLAY = 12,
  441. VISUAL_CONFIRM_SUBVP = 14,
  442. VISUAL_CONFIRM_MCLK_SWITCH = 16,
  443. VISUAL_CONFIRM_FAMS2 = 19,
  444. VISUAL_CONFIRM_HW_CURSOR = 20,
  445. };
  446. enum dc_psr_power_opts {
  447. psr_power_opt_invalid = 0x0,
  448. psr_power_opt_smu_opt_static_screen = 0x1,
  449. psr_power_opt_z10_static_screen = 0x10,
  450. psr_power_opt_ds_disable_allow = 0x100,
  451. };
  452. enum dml_hostvm_override_opts {
  453. DML_HOSTVM_NO_OVERRIDE = 0x0,
  454. DML_HOSTVM_OVERRIDE_FALSE = 0x1,
  455. DML_HOSTVM_OVERRIDE_TRUE = 0x2,
  456. };
  457. enum dc_replay_power_opts {
  458. replay_power_opt_invalid = 0x0,
  459. replay_power_opt_smu_opt_static_screen = 0x1,
  460. replay_power_opt_z10_static_screen = 0x10,
  461. };
  462. enum dcc_option {
  463. DCC_ENABLE = 0,
  464. DCC_DISABLE = 1,
  465. DCC_HALF_REQ_DISALBE = 2,
  466. };
  467. enum in_game_fams_config {
  468. INGAME_FAMS_SINGLE_DISP_ENABLE, // enable in-game fams
  469. INGAME_FAMS_DISABLE, // disable in-game fams
  470. INGAME_FAMS_MULTI_DISP_ENABLE, //enable in-game fams for multi-display
  471. INGAME_FAMS_MULTI_DISP_CLAMPED_ONLY, //enable in-game fams for multi-display only for clamped RR strategies
  472. };
  473. /**
  474. * enum pipe_split_policy - Pipe split strategy supported by DCN
  475. *
  476. * This enum is used to define the pipe split policy supported by DCN. By
  477. * default, DC favors MPC_SPLIT_DYNAMIC.
  478. */
  479. enum pipe_split_policy {
  480. /**
  481. * @MPC_SPLIT_DYNAMIC: DC will automatically decide how to split the
  482. * pipe in order to bring the best trade-off between performance and
  483. * power consumption. This is the recommended option.
  484. */
  485. MPC_SPLIT_DYNAMIC = 0,
  486. /**
  487. * @MPC_SPLIT_AVOID: Avoid pipe split, which means that DC will not
  488. * try any sort of split optimization.
  489. */
  490. MPC_SPLIT_AVOID = 1,
  491. /**
  492. * @MPC_SPLIT_AVOID_MULT_DISP: With this option, DC will only try to
  493. * optimize the pipe utilization when using a single display; if the
  494. * user connects to a second display, DC will avoid pipe split.
  495. */
  496. MPC_SPLIT_AVOID_MULT_DISP = 2,
  497. };
  498. enum wm_report_mode {
  499. WM_REPORT_DEFAULT = 0,
  500. WM_REPORT_OVERRIDE = 1,
  501. };
  502. enum dtm_pstate{
  503. dtm_level_p0 = 0,/*highest voltage*/
  504. dtm_level_p1,
  505. dtm_level_p2,
  506. dtm_level_p3,
  507. dtm_level_p4,/*when active_display_count = 0*/
  508. };
  509. enum dcn_pwr_state {
  510. DCN_PWR_STATE_UNKNOWN = -1,
  511. DCN_PWR_STATE_MISSION_MODE = 0,
  512. DCN_PWR_STATE_LOW_POWER = 3,
  513. };
  514. enum dcn_zstate_support_state {
  515. DCN_ZSTATE_SUPPORT_UNKNOWN,
  516. DCN_ZSTATE_SUPPORT_ALLOW,
  517. DCN_ZSTATE_SUPPORT_ALLOW_Z8_ONLY,
  518. DCN_ZSTATE_SUPPORT_ALLOW_Z8_Z10_ONLY,
  519. DCN_ZSTATE_SUPPORT_ALLOW_Z10_ONLY,
  520. DCN_ZSTATE_SUPPORT_DISALLOW,
  521. };
  522. /*
  523. * struct dc_clocks - DC pipe clocks
  524. *
  525. * For any clocks that may differ per pipe only the max is stored in this
  526. * structure
  527. */
  528. struct dc_clocks {
  529. int dispclk_khz;
  530. int actual_dispclk_khz;
  531. int dppclk_khz;
  532. int actual_dppclk_khz;
  533. int disp_dpp_voltage_level_khz;
  534. int dcfclk_khz;
  535. int socclk_khz;
  536. int dcfclk_deep_sleep_khz;
  537. int fclk_khz;
  538. int phyclk_khz;
  539. int dramclk_khz;
  540. bool p_state_change_support;
  541. enum dcn_zstate_support_state zstate_support;
  542. bool dtbclk_en;
  543. int ref_dtbclk_khz;
  544. bool fclk_p_state_change_support;
  545. enum dcn_pwr_state pwr_state;
  546. /*
  547. * Elements below are not compared for the purposes of
  548. * optimization required
  549. */
  550. bool prev_p_state_change_support;
  551. bool fclk_prev_p_state_change_support;
  552. int num_ways;
  553. int host_router_bw_kbps[MAX_HOST_ROUTERS_NUM];
  554. /*
  555. * @fw_based_mclk_switching
  556. *
  557. * DC has a mechanism that leverage the variable refresh rate to switch
  558. * memory clock in cases that we have a large latency to achieve the
  559. * memory clock change and a short vblank window. DC has some
  560. * requirements to enable this feature, and this field describes if the
  561. * system support or not such a feature.
  562. */
  563. bool fw_based_mclk_switching;
  564. bool fw_based_mclk_switching_shut_down;
  565. int prev_num_ways;
  566. enum dtm_pstate dtm_level;
  567. int max_supported_dppclk_khz;
  568. int max_supported_dispclk_khz;
  569. int bw_dppclk_khz; /*a copy of dppclk_khz*/
  570. int bw_dispclk_khz;
  571. int idle_dramclk_khz;
  572. int idle_fclk_khz;
  573. };
  574. struct dc_bw_validation_profile {
  575. bool enable;
  576. unsigned long long total_ticks;
  577. unsigned long long voltage_level_ticks;
  578. unsigned long long watermark_ticks;
  579. unsigned long long rq_dlg_ticks;
  580. unsigned long long total_count;
  581. unsigned long long skip_fast_count;
  582. unsigned long long skip_pass_count;
  583. unsigned long long skip_fail_count;
  584. };
  585. #define BW_VAL_TRACE_SETUP() \
  586. unsigned long long end_tick = 0; \
  587. unsigned long long voltage_level_tick = 0; \
  588. unsigned long long watermark_tick = 0; \
  589. unsigned long long start_tick = dc->debug.bw_val_profile.enable ? \
  590. dm_get_timestamp(dc->ctx) : 0
  591. #define BW_VAL_TRACE_COUNT() \
  592. if (dc->debug.bw_val_profile.enable) \
  593. dc->debug.bw_val_profile.total_count++
  594. #define BW_VAL_TRACE_SKIP(status) \
  595. if (dc->debug.bw_val_profile.enable) { \
  596. if (!voltage_level_tick) \
  597. voltage_level_tick = dm_get_timestamp(dc->ctx); \
  598. dc->debug.bw_val_profile.skip_ ## status ## _count++; \
  599. }
  600. #define BW_VAL_TRACE_END_VOLTAGE_LEVEL() \
  601. if (dc->debug.bw_val_profile.enable) \
  602. voltage_level_tick = dm_get_timestamp(dc->ctx)
  603. #define BW_VAL_TRACE_END_WATERMARKS() \
  604. if (dc->debug.bw_val_profile.enable) \
  605. watermark_tick = dm_get_timestamp(dc->ctx)
  606. #define BW_VAL_TRACE_FINISH() \
  607. if (dc->debug.bw_val_profile.enable) { \
  608. end_tick = dm_get_timestamp(dc->ctx); \
  609. dc->debug.bw_val_profile.total_ticks += end_tick - start_tick; \
  610. dc->debug.bw_val_profile.voltage_level_ticks += voltage_level_tick - start_tick; \
  611. if (watermark_tick) { \
  612. dc->debug.bw_val_profile.watermark_ticks += watermark_tick - voltage_level_tick; \
  613. dc->debug.bw_val_profile.rq_dlg_ticks += end_tick - watermark_tick; \
  614. } \
  615. }
  616. union mem_low_power_enable_options {
  617. struct {
  618. bool vga: 1;
  619. bool i2c: 1;
  620. bool dmcu: 1;
  621. bool dscl: 1;
  622. bool cm: 1;
  623. bool mpc: 1;
  624. bool optc: 1;
  625. bool vpg: 1;
  626. bool afmt: 1;
  627. } bits;
  628. uint32_t u32All;
  629. };
  630. union root_clock_optimization_options {
  631. struct {
  632. bool dpp: 1;
  633. bool dsc: 1;
  634. bool hdmistream: 1;
  635. bool hdmichar: 1;
  636. bool dpstream: 1;
  637. bool symclk32_se: 1;
  638. bool symclk32_le: 1;
  639. bool symclk_fe: 1;
  640. bool physymclk: 1;
  641. bool dpiasymclk: 1;
  642. uint32_t reserved: 22;
  643. } bits;
  644. uint32_t u32All;
  645. };
  646. union fine_grain_clock_gating_enable_options {
  647. struct {
  648. bool dccg_global_fgcg_rep : 1; /* Global fine grain clock gating of repeaters */
  649. bool dchub : 1; /* Display controller hub */
  650. bool dchubbub : 1;
  651. bool dpp : 1; /* Display pipes and planes */
  652. bool opp : 1; /* Output pixel processing */
  653. bool optc : 1; /* Output pipe timing combiner */
  654. bool dio : 1; /* Display output */
  655. bool dwb : 1; /* Display writeback */
  656. bool mmhubbub : 1; /* Multimedia hub */
  657. bool dmu : 1; /* Display core management unit */
  658. bool az : 1; /* Azalia */
  659. bool dchvm : 1;
  660. bool dsc : 1; /* Display stream compression */
  661. uint32_t reserved : 19;
  662. } bits;
  663. uint32_t u32All;
  664. };
  665. enum pg_hw_pipe_resources {
  666. PG_HUBP = 0,
  667. PG_DPP,
  668. PG_DSC,
  669. PG_MPCC,
  670. PG_OPP,
  671. PG_OPTC,
  672. PG_DPSTREAM,
  673. PG_HDMISTREAM,
  674. PG_PHYSYMCLK,
  675. PG_HW_PIPE_RESOURCES_NUM_ELEMENT
  676. };
  677. enum pg_hw_resources {
  678. PG_DCCG = 0,
  679. PG_DCIO,
  680. PG_DIO,
  681. PG_DCHUBBUB,
  682. PG_DCHVM,
  683. PG_DWB,
  684. PG_HPO,
  685. PG_HW_RESOURCES_NUM_ELEMENT
  686. };
  687. struct pg_block_update {
  688. bool pg_pipe_res_update[PG_HW_PIPE_RESOURCES_NUM_ELEMENT][MAX_PIPES];
  689. bool pg_res_update[PG_HW_RESOURCES_NUM_ELEMENT];
  690. };
  691. union dpia_debug_options {
  692. struct {
  693. uint32_t disable_dpia:1; /* bit 0 */
  694. uint32_t force_non_lttpr:1; /* bit 1 */
  695. uint32_t extend_aux_rd_interval:1; /* bit 2 */
  696. uint32_t disable_mst_dsc_work_around:1; /* bit 3 */
  697. uint32_t enable_force_tbt3_work_around:1; /* bit 4 */
  698. uint32_t disable_usb4_pm_support:1; /* bit 5 */
  699. uint32_t enable_consolidated_dpia_dp_lt:1; /* bit 6 */
  700. uint32_t reserved:25;
  701. } bits;
  702. uint32_t raw;
  703. };
  704. /* AUX wake work around options
  705. * 0: enable/disable work around
  706. * 1: use default timeout LINK_AUX_WAKE_TIMEOUT_MS
  707. * 15-2: reserved
  708. * 31-16: timeout in ms
  709. */
  710. union aux_wake_wa_options {
  711. struct {
  712. uint32_t enable_wa : 1;
  713. uint32_t use_default_timeout : 1;
  714. uint32_t rsvd: 14;
  715. uint32_t timeout_ms : 16;
  716. } bits;
  717. uint32_t raw;
  718. };
  719. struct dc_debug_data {
  720. uint32_t ltFailCount;
  721. uint32_t i2cErrorCount;
  722. uint32_t auxErrorCount;
  723. };
  724. struct dc_phy_addr_space_config {
  725. struct {
  726. uint64_t start_addr;
  727. uint64_t end_addr;
  728. uint64_t fb_top;
  729. uint64_t fb_offset;
  730. uint64_t fb_base;
  731. uint64_t agp_top;
  732. uint64_t agp_bot;
  733. uint64_t agp_base;
  734. } system_aperture;
  735. struct {
  736. uint64_t page_table_start_addr;
  737. uint64_t page_table_end_addr;
  738. uint64_t page_table_base_addr;
  739. bool base_addr_is_mc_addr;
  740. } gart_config;
  741. bool valid;
  742. bool is_hvm_enabled;
  743. uint64_t page_table_default_page_addr;
  744. };
  745. struct dc_virtual_addr_space_config {
  746. uint64_t page_table_base_addr;
  747. uint64_t page_table_start_addr;
  748. uint64_t page_table_end_addr;
  749. uint32_t page_table_block_size_in_bytes;
  750. uint8_t page_table_depth; // 1 = 1 level, 2 = 2 level, etc. 0 = invalid
  751. };
  752. struct dc_bounding_box_overrides {
  753. int sr_exit_time_ns;
  754. int sr_enter_plus_exit_time_ns;
  755. int sr_exit_z8_time_ns;
  756. int sr_enter_plus_exit_z8_time_ns;
  757. int urgent_latency_ns;
  758. int percent_of_ideal_drambw;
  759. int dram_clock_change_latency_ns;
  760. int dummy_clock_change_latency_ns;
  761. int fclk_clock_change_latency_ns;
  762. /* This forces a hard min on the DCFCLK we use
  763. * for DML. Unlike the debug option for forcing
  764. * DCFCLK, this override affects watermark calculations
  765. */
  766. int min_dcfclk_mhz;
  767. };
  768. struct dc_state;
  769. struct resource_pool;
  770. struct dce_hwseq;
  771. struct link_service;
  772. /*
  773. * struct dc_debug_options - DC debug struct
  774. *
  775. * This struct provides a simple mechanism for developers to change some
  776. * configurations, enable/disable features, and activate extra debug options.
  777. * This can be very handy to narrow down whether some specific feature is
  778. * causing an issue or not.
  779. */
  780. struct dc_debug_options {
  781. bool native422_support;
  782. bool disable_dsc;
  783. enum visual_confirm visual_confirm;
  784. int visual_confirm_rect_height;
  785. bool sanity_checks;
  786. bool max_disp_clk;
  787. bool surface_trace;
  788. bool timing_trace;
  789. bool clock_trace;
  790. bool validation_trace;
  791. bool bandwidth_calcs_trace;
  792. int max_downscale_src_width;
  793. /* stutter efficiency related */
  794. bool disable_stutter;
  795. bool use_max_lb;
  796. enum dcc_option disable_dcc;
  797. /*
  798. * @pipe_split_policy: Define which pipe split policy is used by the
  799. * display core.
  800. */
  801. enum pipe_split_policy pipe_split_policy;
  802. bool force_single_disp_pipe_split;
  803. bool voltage_align_fclk;
  804. bool disable_min_fclk;
  805. bool disable_dfs_bypass;
  806. bool disable_dpp_power_gate;
  807. bool disable_hubp_power_gate;
  808. bool disable_dsc_power_gate;
  809. bool disable_optc_power_gate;
  810. bool disable_hpo_power_gate;
  811. int dsc_min_slice_height_override;
  812. int dsc_bpp_increment_div;
  813. bool disable_pplib_wm_range;
  814. enum wm_report_mode pplib_wm_report_mode;
  815. unsigned int min_disp_clk_khz;
  816. unsigned int min_dpp_clk_khz;
  817. unsigned int min_dram_clk_khz;
  818. int sr_exit_time_dpm0_ns;
  819. int sr_enter_plus_exit_time_dpm0_ns;
  820. int sr_exit_time_ns;
  821. int sr_enter_plus_exit_time_ns;
  822. int sr_exit_z8_time_ns;
  823. int sr_enter_plus_exit_z8_time_ns;
  824. int urgent_latency_ns;
  825. uint32_t underflow_assert_delay_us;
  826. int percent_of_ideal_drambw;
  827. int dram_clock_change_latency_ns;
  828. bool optimized_watermark;
  829. int always_scale;
  830. bool disable_pplib_clock_request;
  831. bool disable_clock_gate;
  832. bool disable_mem_low_power;
  833. bool pstate_enabled;
  834. bool disable_dmcu;
  835. bool force_abm_enable;
  836. bool disable_stereo_support;
  837. bool vsr_support;
  838. bool performance_trace;
  839. bool az_endpoint_mute_only;
  840. bool always_use_regamma;
  841. bool recovery_enabled;
  842. bool avoid_vbios_exec_table;
  843. bool scl_reset_length10;
  844. bool hdmi20_disable;
  845. bool skip_detection_link_training;
  846. uint32_t edid_read_retry_times;
  847. unsigned int force_odm_combine; //bit vector based on otg inst
  848. unsigned int seamless_boot_odm_combine;
  849. unsigned int force_odm_combine_4to1; //bit vector based on otg inst
  850. int minimum_z8_residency_time;
  851. int minimum_z10_residency_time;
  852. bool disable_z9_mpc;
  853. unsigned int force_fclk_khz;
  854. bool enable_tri_buf;
  855. bool ips_disallow_entry;
  856. bool dmub_offload_enabled;
  857. bool dmcub_emulation;
  858. bool disable_idle_power_optimizations;
  859. unsigned int mall_size_override;
  860. unsigned int mall_additional_timer_percent;
  861. bool mall_error_as_fatal;
  862. bool dmub_command_table; /* for testing only */
  863. struct dc_bw_validation_profile bw_val_profile;
  864. bool disable_fec;
  865. bool disable_48mhz_pwrdwn;
  866. /* This forces a hard min on the DCFCLK requested to SMU/PP
  867. * watermarks are not affected.
  868. */
  869. unsigned int force_min_dcfclk_mhz;
  870. int dwb_fi_phase;
  871. bool disable_timing_sync;
  872. bool cm_in_bypass;
  873. int force_clock_mode;/*every mode change.*/
  874. bool disable_dram_clock_change_vactive_support;
  875. bool validate_dml_output;
  876. bool enable_dmcub_surface_flip;
  877. bool usbc_combo_phy_reset_wa;
  878. bool enable_dram_clock_change_one_display_vactive;
  879. /* TODO - remove once tested */
  880. bool legacy_dp2_lt;
  881. bool set_mst_en_for_sst;
  882. bool disable_uhbr;
  883. bool force_dp2_lt_fallback_method;
  884. bool ignore_cable_id;
  885. union mem_low_power_enable_options enable_mem_low_power;
  886. union root_clock_optimization_options root_clock_optimization;
  887. union fine_grain_clock_gating_enable_options enable_fine_grain_clock_gating;
  888. bool hpo_optimization;
  889. bool force_vblank_alignment;
  890. /* Enable dmub aux for legacy ddc */
  891. bool enable_dmub_aux_for_legacy_ddc;
  892. bool disable_fams;
  893. enum in_game_fams_config disable_fams_gaming;
  894. /* FEC/PSR1 sequence enable delay in 100us */
  895. uint8_t fec_enable_delay_in100us;
  896. bool enable_driver_sequence_debug;
  897. enum det_size crb_alloc_policy;
  898. int crb_alloc_policy_min_disp_count;
  899. bool disable_z10;
  900. bool enable_z9_disable_interface;
  901. bool psr_skip_crtc_disable;
  902. uint32_t ips_skip_crtc_disable_mask;
  903. union dpia_debug_options dpia_debug;
  904. bool disable_fixed_vs_aux_timeout_wa;
  905. uint32_t fixed_vs_aux_delay_config_wa;
  906. bool force_disable_subvp;
  907. bool force_subvp_mclk_switch;
  908. bool allow_sw_cursor_fallback;
  909. unsigned int force_subvp_num_ways;
  910. unsigned int force_mall_ss_num_ways;
  911. bool alloc_extra_way_for_cursor;
  912. uint32_t subvp_extra_lines;
  913. bool force_usr_allow;
  914. /* uses value at boot and disables switch */
  915. bool disable_dtb_ref_clk_switch;
  916. bool extended_blank_optimization;
  917. union aux_wake_wa_options aux_wake_wa;
  918. uint32_t mst_start_top_delay;
  919. uint8_t psr_power_use_phy_fsm;
  920. enum dml_hostvm_override_opts dml_hostvm_override;
  921. bool dml_disallow_alternate_prefetch_modes;
  922. bool use_legacy_soc_bb_mechanism;
  923. bool exit_idle_opt_for_cursor_updates;
  924. bool using_dml2;
  925. bool enable_single_display_2to1_odm_policy;
  926. bool enable_double_buffered_dsc_pg_support;
  927. bool enable_dp_dig_pixel_rate_div_policy;
  928. bool using_dml21;
  929. enum lttpr_mode lttpr_mode_override;
  930. unsigned int dsc_delay_factor_wa_x1000;
  931. unsigned int min_prefetch_in_strobe_ns;
  932. bool disable_unbounded_requesting;
  933. bool dig_fifo_off_in_blank;
  934. bool override_dispclk_programming;
  935. bool otg_crc_db;
  936. bool disallow_dispclk_dppclk_ds;
  937. bool disable_fpo_optimizations;
  938. bool support_eDP1_5;
  939. uint32_t fpo_vactive_margin_us;
  940. bool disable_fpo_vactive;
  941. bool disable_boot_optimizations;
  942. bool override_odm_optimization;
  943. bool minimize_dispclk_using_odm;
  944. bool disable_subvp_high_refresh;
  945. bool disable_dp_plus_plus_wa;
  946. uint32_t fpo_vactive_min_active_margin_us;
  947. uint32_t fpo_vactive_max_blank_us;
  948. bool enable_hpo_pg_support;
  949. bool enable_legacy_fast_update;
  950. bool disable_dc_mode_overwrite;
  951. bool replay_skip_crtc_disabled;
  952. bool ignore_pg;/*do nothing, let pmfw control it*/
  953. bool psp_disabled_wa;
  954. unsigned int ips2_eval_delay_us;
  955. unsigned int ips2_entry_delay_us;
  956. bool optimize_ips_handshake;
  957. bool disable_dmub_reallow_idle;
  958. bool disable_timeout;
  959. bool disable_extblankadj;
  960. bool enable_idle_reg_checks;
  961. unsigned int static_screen_wait_frames;
  962. uint32_t pwm_freq;
  963. bool force_chroma_subsampling_1tap;
  964. unsigned int dcc_meta_propagation_delay_us;
  965. bool disable_422_left_edge_pixel;
  966. bool dml21_force_pstate_method;
  967. uint32_t dml21_force_pstate_method_values[MAX_PIPES];
  968. uint32_t dml21_disable_pstate_method_mask;
  969. union dmub_fams2_global_feature_config fams2_config;
  970. bool enable_legacy_clock_update;
  971. unsigned int force_cositing;
  972. unsigned int disable_spl;
  973. unsigned int force_easf;
  974. unsigned int force_sharpness;
  975. unsigned int force_sharpness_level;
  976. unsigned int force_lls;
  977. bool notify_dpia_hr_bw;
  978. bool enable_ips_visual_confirm;
  979. unsigned int sharpen_policy;
  980. unsigned int scale_to_sharpness_policy;
  981. bool skip_full_updated_if_possible;
  982. };
  983. /* Generic structure that can be used to query properties of DC. More fields
  984. * can be added as required.
  985. */
  986. struct dc_current_properties {
  987. unsigned int cursor_size_limit;
  988. };
  989. enum frame_buffer_mode {
  990. FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
  991. FRAME_BUFFER_MODE_ZFB_ONLY,
  992. FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
  993. } ;
  994. struct dchub_init_data {
  995. int64_t zfb_phys_addr_base;
  996. int64_t zfb_mc_base_addr;
  997. uint64_t zfb_size_in_byte;
  998. enum frame_buffer_mode fb_mode;
  999. bool dchub_initialzied;
  1000. bool dchub_info_valid;
  1001. };
  1002. struct dml2_soc_bb;
  1003. struct dc_init_data {
  1004. struct hw_asic_id asic_id;
  1005. void *driver; /* ctx */
  1006. struct cgs_device *cgs_device;
  1007. struct dc_bounding_box_overrides bb_overrides;
  1008. int num_virtual_links;
  1009. /*
  1010. * If 'vbios_override' not NULL, it will be called instead
  1011. * of the real VBIOS. Intended use is Diagnostics on FPGA.
  1012. */
  1013. struct dc_bios *vbios_override;
  1014. enum dce_environment dce_environment;
  1015. struct dmub_offload_funcs *dmub_if;
  1016. struct dc_reg_helper_state *dmub_offload;
  1017. struct dc_config flags;
  1018. uint64_t log_mask;
  1019. struct dpcd_vendor_signature vendor_signature;
  1020. bool force_smu_not_present;
  1021. /*
  1022. * IP offset for run time initializaion of register addresses
  1023. *
  1024. * DCN3.5+ will fail dc_create() if these fields are null for them. They are
  1025. * applicable starting with DCN32/321 and are not used for ASICs upstreamed
  1026. * before them.
  1027. */
  1028. uint32_t *dcn_reg_offsets;
  1029. uint32_t *nbio_reg_offsets;
  1030. uint32_t *clk_reg_offsets;
  1031. struct dml2_soc_bb *bb_from_dmub;
  1032. };
  1033. struct dc_callback_init {
  1034. struct cp_psp cp_psp;
  1035. };
  1036. struct dc *dc_create(const struct dc_init_data *init_params);
  1037. void dc_hardware_init(struct dc *dc);
  1038. int dc_get_vmid_use_vector(struct dc *dc);
  1039. void dc_setup_vm_context(struct dc *dc, struct dc_virtual_addr_space_config *va_config, int vmid);
  1040. /* Returns the number of vmids supported */
  1041. int dc_setup_system_context(struct dc *dc, struct dc_phy_addr_space_config *pa_config);
  1042. void dc_init_callbacks(struct dc *dc,
  1043. const struct dc_callback_init *init_params);
  1044. void dc_deinit_callbacks(struct dc *dc);
  1045. void dc_destroy(struct dc **dc);
  1046. /* Surface Interfaces */
  1047. enum {
  1048. TRANSFER_FUNC_POINTS = 1025
  1049. };
  1050. struct dc_hdr_static_metadata {
  1051. /* display chromaticities and white point in units of 0.00001 */
  1052. unsigned int chromaticity_green_x;
  1053. unsigned int chromaticity_green_y;
  1054. unsigned int chromaticity_blue_x;
  1055. unsigned int chromaticity_blue_y;
  1056. unsigned int chromaticity_red_x;
  1057. unsigned int chromaticity_red_y;
  1058. unsigned int chromaticity_white_point_x;
  1059. unsigned int chromaticity_white_point_y;
  1060. uint32_t min_luminance;
  1061. uint32_t max_luminance;
  1062. uint32_t maximum_content_light_level;
  1063. uint32_t maximum_frame_average_light_level;
  1064. };
  1065. enum dc_transfer_func_type {
  1066. TF_TYPE_PREDEFINED,
  1067. TF_TYPE_DISTRIBUTED_POINTS,
  1068. TF_TYPE_BYPASS,
  1069. TF_TYPE_HWPWL
  1070. };
  1071. struct dc_transfer_func_distributed_points {
  1072. struct fixed31_32 red[TRANSFER_FUNC_POINTS];
  1073. struct fixed31_32 green[TRANSFER_FUNC_POINTS];
  1074. struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
  1075. uint16_t end_exponent;
  1076. uint16_t x_point_at_y1_red;
  1077. uint16_t x_point_at_y1_green;
  1078. uint16_t x_point_at_y1_blue;
  1079. };
  1080. enum dc_transfer_func_predefined {
  1081. TRANSFER_FUNCTION_SRGB,
  1082. TRANSFER_FUNCTION_BT709,
  1083. TRANSFER_FUNCTION_PQ,
  1084. TRANSFER_FUNCTION_LINEAR,
  1085. TRANSFER_FUNCTION_UNITY,
  1086. TRANSFER_FUNCTION_HLG,
  1087. TRANSFER_FUNCTION_HLG12,
  1088. TRANSFER_FUNCTION_GAMMA22,
  1089. TRANSFER_FUNCTION_GAMMA24,
  1090. TRANSFER_FUNCTION_GAMMA26
  1091. };
  1092. struct dc_transfer_func {
  1093. struct kref refcount;
  1094. enum dc_transfer_func_type type;
  1095. enum dc_transfer_func_predefined tf;
  1096. /* FP16 1.0 reference level in nits, default is 80 nits, only for PQ*/
  1097. uint32_t sdr_ref_white_level;
  1098. union {
  1099. struct pwl_params pwl;
  1100. struct dc_transfer_func_distributed_points tf_pts;
  1101. };
  1102. };
  1103. union dc_3dlut_state {
  1104. struct {
  1105. uint32_t initialized:1; /*if 3dlut is went through color module for initialization */
  1106. uint32_t rmu_idx_valid:1; /*if mux settings are valid*/
  1107. uint32_t rmu_mux_num:3; /*index of mux to use*/
  1108. uint32_t mpc_rmu0_mux:4; /*select mpcc on mux, one of the following : mpcc0, mpcc1, mpcc2, mpcc3*/
  1109. uint32_t mpc_rmu1_mux:4;
  1110. uint32_t mpc_rmu2_mux:4;
  1111. uint32_t reserved:15;
  1112. } bits;
  1113. uint32_t raw;
  1114. };
  1115. struct dc_3dlut {
  1116. struct kref refcount;
  1117. struct tetrahedral_params lut_3d;
  1118. struct fixed31_32 hdr_multiplier;
  1119. union dc_3dlut_state state;
  1120. };
  1121. /*
  1122. * This structure is filled in by dc_surface_get_status and contains
  1123. * the last requested address and the currently active address so the called
  1124. * can determine if there are any outstanding flips
  1125. */
  1126. struct dc_plane_status {
  1127. struct dc_plane_address requested_address;
  1128. struct dc_plane_address current_address;
  1129. bool is_flip_pending;
  1130. bool is_right_eye;
  1131. };
  1132. union surface_update_flags {
  1133. struct {
  1134. uint32_t addr_update:1;
  1135. /* Medium updates */
  1136. uint32_t dcc_change:1;
  1137. uint32_t color_space_change:1;
  1138. uint32_t horizontal_mirror_change:1;
  1139. uint32_t per_pixel_alpha_change:1;
  1140. uint32_t global_alpha_change:1;
  1141. uint32_t hdr_mult:1;
  1142. uint32_t rotation_change:1;
  1143. uint32_t swizzle_change:1;
  1144. uint32_t scaling_change:1;
  1145. uint32_t clip_size_change: 1;
  1146. uint32_t position_change:1;
  1147. uint32_t in_transfer_func_change:1;
  1148. uint32_t input_csc_change:1;
  1149. uint32_t coeff_reduction_change:1;
  1150. uint32_t output_tf_change:1;
  1151. uint32_t pixel_format_change:1;
  1152. uint32_t plane_size_change:1;
  1153. uint32_t gamut_remap_change:1;
  1154. /* Full updates */
  1155. uint32_t new_plane:1;
  1156. uint32_t bpp_change:1;
  1157. uint32_t gamma_change:1;
  1158. uint32_t bandwidth_change:1;
  1159. uint32_t clock_change:1;
  1160. uint32_t stereo_format_change:1;
  1161. uint32_t lut_3d:1;
  1162. uint32_t tmz_changed:1;
  1163. uint32_t mcm_transfer_function_enable_change:1; /* disable or enable MCM transfer func */
  1164. uint32_t full_update:1;
  1165. uint32_t sdr_white_level_nits:1;
  1166. } bits;
  1167. uint32_t raw;
  1168. };
  1169. #define DC_REMOVE_PLANE_POINTERS 1
  1170. struct dc_plane_state {
  1171. struct dc_plane_address address;
  1172. struct dc_plane_flip_time time;
  1173. bool triplebuffer_flips;
  1174. struct scaling_taps scaling_quality;
  1175. struct rect src_rect;
  1176. struct rect dst_rect;
  1177. struct rect clip_rect;
  1178. struct plane_size plane_size;
  1179. union dc_tiling_info tiling_info;
  1180. struct dc_plane_dcc_param dcc;
  1181. struct dc_gamma gamma_correction;
  1182. struct dc_transfer_func in_transfer_func;
  1183. struct dc_bias_and_scale bias_and_scale;
  1184. struct dc_csc_transform input_csc_color_matrix;
  1185. struct fixed31_32 coeff_reduction_factor;
  1186. struct fixed31_32 hdr_mult;
  1187. struct colorspace_transform gamut_remap_matrix;
  1188. // TODO: No longer used, remove
  1189. struct dc_hdr_static_metadata hdr_static_ctx;
  1190. enum dc_color_space color_space;
  1191. struct dc_3dlut lut3d_func;
  1192. struct dc_transfer_func in_shaper_func;
  1193. struct dc_transfer_func blend_tf;
  1194. struct dc_transfer_func *gamcor_tf;
  1195. enum surface_pixel_format format;
  1196. enum dc_rotation_angle rotation;
  1197. enum plane_stereo_format stereo_format;
  1198. bool is_tiling_rotated;
  1199. bool per_pixel_alpha;
  1200. bool pre_multiplied_alpha;
  1201. bool global_alpha;
  1202. int global_alpha_value;
  1203. bool visible;
  1204. bool flip_immediate;
  1205. bool horizontal_mirror;
  1206. int layer_index;
  1207. union surface_update_flags update_flags;
  1208. bool flip_int_enabled;
  1209. bool skip_manual_trigger;
  1210. /* private to DC core */
  1211. struct dc_plane_status status;
  1212. struct dc_context *ctx;
  1213. /* HACK: Workaround for forcing full reprogramming under some conditions */
  1214. bool force_full_update;
  1215. bool is_phantom; // TODO: Change mall_stream_config into mall_plane_config instead
  1216. /* private to dc_surface.c */
  1217. enum dc_irq_source irq_source;
  1218. struct kref refcount;
  1219. struct tg_color visual_confirm_color;
  1220. bool is_statically_allocated;
  1221. enum chroma_cositing cositing;
  1222. enum dc_cm2_shaper_3dlut_setting mcm_shaper_3dlut_setting;
  1223. bool mcm_lut1d_enable;
  1224. struct dc_cm2_func_luts mcm_luts;
  1225. bool lut_bank_a;
  1226. enum mpcc_movable_cm_location mcm_location;
  1227. struct dc_csc_transform cursor_csc_color_matrix;
  1228. bool adaptive_sharpness_en;
  1229. int sharpness_level;
  1230. enum linear_light_scaling linear_light_scaling;
  1231. unsigned int sdr_white_level_nits;
  1232. };
  1233. struct dc_plane_info {
  1234. struct plane_size plane_size;
  1235. union dc_tiling_info tiling_info;
  1236. struct dc_plane_dcc_param dcc;
  1237. enum surface_pixel_format format;
  1238. enum dc_rotation_angle rotation;
  1239. enum plane_stereo_format stereo_format;
  1240. enum dc_color_space color_space;
  1241. bool horizontal_mirror;
  1242. bool visible;
  1243. bool per_pixel_alpha;
  1244. bool pre_multiplied_alpha;
  1245. bool global_alpha;
  1246. int global_alpha_value;
  1247. bool input_csc_enabled;
  1248. int layer_index;
  1249. enum chroma_cositing cositing;
  1250. };
  1251. #include "dc_stream.h"
  1252. struct dc_scratch_space {
  1253. /* used to temporarily backup plane states of a stream during
  1254. * dc update. The reason is that plane states are overwritten
  1255. * with surface updates in dc update. Once they are overwritten
  1256. * current state is no longer valid. We want to temporarily
  1257. * store current value in plane states so we can still recover
  1258. * a valid current state during dc update.
  1259. */
  1260. struct dc_plane_state plane_states[MAX_SURFACES];
  1261. struct dc_stream_state stream_state;
  1262. };
  1263. struct dc {
  1264. struct dc_debug_options debug;
  1265. struct dc_versions versions;
  1266. struct dc_caps caps;
  1267. struct dc_cap_funcs cap_funcs;
  1268. struct dc_config config;
  1269. struct dc_bounding_box_overrides bb_overrides;
  1270. struct dc_bug_wa work_arounds;
  1271. struct dc_context *ctx;
  1272. struct dc_phy_addr_space_config vm_pa_config;
  1273. uint8_t link_count;
  1274. struct dc_link *links[MAX_LINKS];
  1275. struct link_service *link_srv;
  1276. struct dc_state *current_state;
  1277. struct resource_pool *res_pool;
  1278. struct clk_mgr *clk_mgr;
  1279. /* Display Engine Clock levels */
  1280. struct dm_pp_clock_levels sclk_lvls;
  1281. /* Inputs into BW and WM calculations. */
  1282. struct bw_calcs_dceip *bw_dceip;
  1283. struct bw_calcs_vbios *bw_vbios;
  1284. struct dcn_soc_bounding_box *dcn_soc;
  1285. struct dcn_ip_params *dcn_ip;
  1286. struct display_mode_lib dml;
  1287. /* HW functions */
  1288. struct hw_sequencer_funcs hwss;
  1289. struct dce_hwseq *hwseq;
  1290. /* Require to optimize clocks and bandwidth for added/removed planes */
  1291. bool optimized_required;
  1292. bool wm_optimized_required;
  1293. bool idle_optimizations_allowed;
  1294. bool enable_c20_dtm_b0;
  1295. /* Require to maintain clocks and bandwidth for UEFI enabled HW */
  1296. /* FBC compressor */
  1297. struct compressor *fbc_compressor;
  1298. struct dc_debug_data debug_data;
  1299. struct dpcd_vendor_signature vendor_signature;
  1300. const char *build_id;
  1301. struct vm_helper *vm_helper;
  1302. uint32_t *dcn_reg_offsets;
  1303. uint32_t *nbio_reg_offsets;
  1304. uint32_t *clk_reg_offsets;
  1305. /* Scratch memory */
  1306. struct {
  1307. struct {
  1308. /*
  1309. * For matching clock_limits table in driver with table
  1310. * from PMFW.
  1311. */
  1312. struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
  1313. } update_bw_bounding_box;
  1314. struct dc_scratch_space current_state;
  1315. struct dc_scratch_space new_state;
  1316. struct dc_stream_state temp_stream; // Used so we don't need to allocate stream on the stack
  1317. } scratch;
  1318. struct dml2_configuration_options dml2_options;
  1319. struct dml2_configuration_options dml2_tmp;
  1320. enum dc_acpi_cm_power_state power_state;
  1321. };
  1322. struct dc_scaling_info {
  1323. struct rect src_rect;
  1324. struct rect dst_rect;
  1325. struct rect clip_rect;
  1326. struct scaling_taps scaling_quality;
  1327. };
  1328. struct dc_fast_update {
  1329. const struct dc_flip_addrs *flip_addr;
  1330. const struct dc_gamma *gamma;
  1331. const struct colorspace_transform *gamut_remap_matrix;
  1332. const struct dc_csc_transform *input_csc_color_matrix;
  1333. const struct fixed31_32 *coeff_reduction_factor;
  1334. struct dc_transfer_func *out_transfer_func;
  1335. struct dc_csc_transform *output_csc_transform;
  1336. const struct dc_csc_transform *cursor_csc_color_matrix;
  1337. };
  1338. struct dc_surface_update {
  1339. struct dc_plane_state *surface;
  1340. /* isr safe update parameters. null means no updates */
  1341. const struct dc_flip_addrs *flip_addr;
  1342. const struct dc_plane_info *plane_info;
  1343. const struct dc_scaling_info *scaling_info;
  1344. struct fixed31_32 hdr_mult;
  1345. /* following updates require alloc/sleep/spin that is not isr safe,
  1346. * null means no updates
  1347. */
  1348. const struct dc_gamma *gamma;
  1349. const struct dc_transfer_func *in_transfer_func;
  1350. const struct dc_csc_transform *input_csc_color_matrix;
  1351. const struct fixed31_32 *coeff_reduction_factor;
  1352. const struct dc_transfer_func *func_shaper;
  1353. const struct dc_3dlut *lut3d_func;
  1354. const struct dc_transfer_func *blend_tf;
  1355. const struct colorspace_transform *gamut_remap_matrix;
  1356. /*
  1357. * Color Transformations for pre-blend MCM (Shaper, 3DLUT, 1DLUT)
  1358. *
  1359. * change cm2_params.component_settings: Full update
  1360. * change cm2_params.cm2_luts: Fast update
  1361. */
  1362. struct dc_cm2_parameters *cm2_params;
  1363. const struct dc_csc_transform *cursor_csc_color_matrix;
  1364. unsigned int sdr_white_level_nits;
  1365. };
  1366. /*
  1367. * Create a new surface with default parameters;
  1368. */
  1369. void dc_gamma_retain(struct dc_gamma *dc_gamma);
  1370. void dc_gamma_release(struct dc_gamma **dc_gamma);
  1371. struct dc_gamma *dc_create_gamma(void);
  1372. void dc_transfer_func_retain(struct dc_transfer_func *dc_tf);
  1373. void dc_transfer_func_release(struct dc_transfer_func *dc_tf);
  1374. struct dc_transfer_func *dc_create_transfer_func(void);
  1375. struct dc_3dlut *dc_create_3dlut_func(void);
  1376. void dc_3dlut_func_release(struct dc_3dlut *lut);
  1377. void dc_3dlut_func_retain(struct dc_3dlut *lut);
  1378. void dc_post_update_surfaces_to_stream(
  1379. struct dc *dc);
  1380. #include "dc_stream.h"
  1381. /**
  1382. * struct dc_validation_set - Struct to store surface/stream associations for validation
  1383. */
  1384. struct dc_validation_set {
  1385. /**
  1386. * @stream: Stream state properties
  1387. */
  1388. struct dc_stream_state *stream;
  1389. /**
  1390. * @plane_states: Surface state
  1391. */
  1392. struct dc_plane_state *plane_states[MAX_SURFACES];
  1393. /**
  1394. * @plane_count: Total of active planes
  1395. */
  1396. uint8_t plane_count;
  1397. };
  1398. bool dc_validate_boot_timing(const struct dc *dc,
  1399. const struct dc_sink *sink,
  1400. struct dc_crtc_timing *crtc_timing);
  1401. enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state);
  1402. void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info);
  1403. enum dc_status dc_validate_with_context(struct dc *dc,
  1404. const struct dc_validation_set set[],
  1405. int set_count,
  1406. struct dc_state *context,
  1407. bool fast_validate);
  1408. bool dc_set_generic_gpio_for_stereo(bool enable,
  1409. struct gpio_service *gpio_service);
  1410. /*
  1411. * fast_validate: we return after determining if we can support the new state,
  1412. * but before we populate the programming info
  1413. */
  1414. enum dc_status dc_validate_global_state(
  1415. struct dc *dc,
  1416. struct dc_state *new_ctx,
  1417. bool fast_validate);
  1418. bool dc_acquire_release_mpc_3dlut(
  1419. struct dc *dc, bool acquire,
  1420. struct dc_stream_state *stream,
  1421. struct dc_3dlut **lut,
  1422. struct dc_transfer_func **shaper);
  1423. bool dc_resource_is_dsc_encoding_supported(const struct dc *dc);
  1424. void get_audio_check(struct audio_info *aud_modes,
  1425. struct audio_check *aud_chk);
  1426. bool fast_nonaddr_updates_exist(struct dc_fast_update *fast_update, int surface_count);
  1427. void populate_fast_updates(struct dc_fast_update *fast_update,
  1428. struct dc_surface_update *srf_updates,
  1429. int surface_count,
  1430. struct dc_stream_update *stream_update);
  1431. /*
  1432. * Set up streams and links associated to drive sinks
  1433. * The streams parameter is an absolute set of all active streams.
  1434. *
  1435. * After this call:
  1436. * Phy, Encoder, Timing Generator are programmed and enabled.
  1437. * New streams are enabled with blank stream; no memory read.
  1438. */
  1439. enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params *params);
  1440. struct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
  1441. struct dc_stream_state *stream,
  1442. int mpcc_inst);
  1443. uint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
  1444. void dc_set_disable_128b_132b_stream_overhead(bool disable);
  1445. /* The function returns minimum bandwidth required to drive a given timing
  1446. * return - minimum required timing bandwidth in kbps.
  1447. */
  1448. uint32_t dc_bandwidth_in_kbps_from_timing(
  1449. const struct dc_crtc_timing *timing,
  1450. const enum dc_link_encoding_format link_encoding);
  1451. /* Link Interfaces */
  1452. /*
  1453. * A link contains one or more sinks and their connected status.
  1454. * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
  1455. */
  1456. struct dc_link {
  1457. struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
  1458. unsigned int sink_count;
  1459. struct dc_sink *local_sink;
  1460. unsigned int link_index;
  1461. enum dc_connection_type type;
  1462. enum signal_type connector_signal;
  1463. enum dc_irq_source irq_source_hpd;
  1464. enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse */
  1465. bool is_hpd_filter_disabled;
  1466. bool dp_ss_off;
  1467. /**
  1468. * @link_state_valid:
  1469. *
  1470. * If there is no link and local sink, this variable should be set to
  1471. * false. Otherwise, it should be set to true; usually, the function
  1472. * core_link_enable_stream sets this field to true.
  1473. */
  1474. bool link_state_valid;
  1475. bool aux_access_disabled;
  1476. bool sync_lt_in_progress;
  1477. bool skip_stream_reenable;
  1478. bool is_internal_display;
  1479. /** @todo Rename. Flag an endpoint as having a programmable mapping to a DIG encoder. */
  1480. bool is_dig_mapping_flexible;
  1481. bool hpd_status; /* HPD status of link without physical HPD pin. */
  1482. bool is_hpd_pending; /* Indicates a new received hpd */
  1483. /* USB4 DPIA links skip verifying link cap, instead performing the fallback method
  1484. * for every link training. This is incompatible with DP LL compliance automation,
  1485. * which expects the same link settings to be used every retry on a link loss.
  1486. * This flag is used to skip the fallback when link loss occurs during automation.
  1487. */
  1488. bool skip_fallback_on_link_loss;
  1489. bool edp_sink_present;
  1490. struct dp_trace dp_trace;
  1491. /* caps is the same as reported_link_cap. link_traing use
  1492. * reported_link_cap. Will clean up. TODO
  1493. */
  1494. struct dc_link_settings reported_link_cap;
  1495. struct dc_link_settings verified_link_cap;
  1496. struct dc_link_settings cur_link_settings;
  1497. struct dc_lane_settings cur_lane_setting[LANE_COUNT_DP_MAX];
  1498. struct dc_link_settings preferred_link_setting;
  1499. /* preferred_training_settings are override values that
  1500. * come from DM. DM is responsible for the memory
  1501. * management of the override pointers.
  1502. */
  1503. struct dc_link_training_overrides preferred_training_settings;
  1504. struct dp_audio_test_data audio_test_data;
  1505. uint8_t ddc_hw_inst;
  1506. uint8_t hpd_src;
  1507. uint8_t link_enc_hw_inst;
  1508. /* DIG link encoder ID. Used as index in link encoder resource pool.
  1509. * For links with fixed mapping to DIG, this is not changed after dc_link
  1510. * object creation.
  1511. */
  1512. enum engine_id eng_id;
  1513. enum engine_id dpia_preferred_eng_id;
  1514. bool test_pattern_enabled;
  1515. /* Pending/Current test pattern are only used to perform and track
  1516. * FIXED_VS retimer test pattern/lane adjustment override state.
  1517. * Pending allows link HWSS to differentiate PHY vs non-PHY pattern,
  1518. * to perform specific lane adjust overrides before setting certain
  1519. * PHY test patterns. In cases when lane adjust and set test pattern
  1520. * calls are not performed atomically (i.e. performing link training),
  1521. * pending_test_pattern will be invalid or contain a non-PHY test pattern
  1522. * and current_test_pattern will contain required context for any future
  1523. * set pattern/set lane adjust to transition between override state(s).
  1524. * */
  1525. enum dp_test_pattern current_test_pattern;
  1526. enum dp_test_pattern pending_test_pattern;
  1527. union compliance_test_state compliance_test_state;
  1528. void *priv;
  1529. struct ddc_service *ddc;
  1530. enum dp_panel_mode panel_mode;
  1531. bool aux_mode;
  1532. /* Private to DC core */
  1533. const struct dc *dc;
  1534. struct dc_context *ctx;
  1535. struct panel_cntl *panel_cntl;
  1536. struct link_encoder *link_enc;
  1537. struct graphics_object_id link_id;
  1538. /* Endpoint type distinguishes display endpoints which do not have entries
  1539. * in the BIOS connector table from those that do. Helps when tracking link
  1540. * encoder to display endpoint assignments.
  1541. */
  1542. enum display_endpoint_type ep_type;
  1543. union ddi_channel_mapping ddi_channel_mapping;
  1544. struct connector_device_tag_info device_tag;
  1545. struct dpcd_caps dpcd_caps;
  1546. uint32_t dongle_max_pix_clk;
  1547. unsigned short chip_caps;
  1548. unsigned int dpcd_sink_count;
  1549. struct hdcp_caps hdcp_caps;
  1550. enum edp_revision edp_revision;
  1551. union dpcd_sink_ext_caps dpcd_sink_ext_caps;
  1552. struct psr_settings psr_settings;
  1553. struct replay_settings replay_settings;
  1554. /* Drive settings read from integrated info table */
  1555. struct dc_lane_settings bios_forced_drive_settings;
  1556. /* Vendor specific LTTPR workaround variables */
  1557. uint8_t vendor_specific_lttpr_link_rate_wa;
  1558. bool apply_vendor_specific_lttpr_link_rate_wa;
  1559. /* MST record stream using this link */
  1560. struct link_flags {
  1561. bool dp_keep_receiver_powered;
  1562. bool dp_skip_DID2;
  1563. bool dp_skip_reset_segment;
  1564. bool dp_skip_fs_144hz;
  1565. bool dp_mot_reset_segment;
  1566. /* Some USB4 docks do not handle turning off MST DSC once it has been enabled. */
  1567. bool dpia_mst_dsc_always_on;
  1568. /* Forced DPIA into TBT3 compatibility mode. */
  1569. bool dpia_forced_tbt3_mode;
  1570. bool dongle_mode_timing_override;
  1571. bool blank_stream_on_ocs_change;
  1572. bool read_dpcd204h_on_irq_hpd;
  1573. bool disable_assr_for_uhbr;
  1574. } wa_flags;
  1575. struct link_mst_stream_allocation_table mst_stream_alloc_table;
  1576. struct dc_link_status link_status;
  1577. struct dprx_states dprx_states;
  1578. struct gpio *hpd_gpio;
  1579. enum dc_link_fec_state fec_state;
  1580. bool link_powered_externally; // Used to bypass hardware sequencing delays when panel is powered down forcibly
  1581. struct dc_panel_config panel_config;
  1582. struct phy_state phy_state;
  1583. // BW ALLOCATON USB4 ONLY
  1584. struct dc_dpia_bw_alloc dpia_bw_alloc_config;
  1585. bool skip_implict_edp_power_control;
  1586. };
  1587. /* Return an enumerated dc_link.
  1588. * dc_link order is constant and determined at
  1589. * boot time. They cannot be created or destroyed.
  1590. * Use dc_get_caps() to get number of links.
  1591. */
  1592. struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index);
  1593. /* Return instance id of the edp link. Inst 0 is primary edp link. */
  1594. bool dc_get_edp_link_panel_inst(const struct dc *dc,
  1595. const struct dc_link *link,
  1596. unsigned int *inst_out);
  1597. /* Return an array of link pointers to edp links. */
  1598. void dc_get_edp_links(const struct dc *dc,
  1599. struct dc_link **edp_links,
  1600. int *edp_num);
  1601. void dc_set_edp_power(const struct dc *dc, struct dc_link *edp_link,
  1602. bool powerOn);
  1603. /* The function initiates detection handshake over the given link. It first
  1604. * determines if there are display connections over the link. If so it initiates
  1605. * detection protocols supported by the connected receiver device. The function
  1606. * contains protocol specific handshake sequences which are sometimes mandatory
  1607. * to establish a proper connection between TX and RX. So it is always
  1608. * recommended to call this function as the first link operation upon HPD event
  1609. * or power up event. Upon completion, the function will update link structure
  1610. * in place based on latest RX capabilities. The function may also cause dpms
  1611. * to be reset to off for all currently enabled streams to the link. It is DM's
  1612. * responsibility to serialize detection and DPMS updates.
  1613. *
  1614. * @reason - Indicate which event triggers this detection. dc may customize
  1615. * detection flow depending on the triggering events.
  1616. * return false - if detection is not fully completed. This could happen when
  1617. * there is an unrecoverable error during detection or detection is partially
  1618. * completed (detection has been delegated to dm mst manager ie.
  1619. * link->connection_type == dc_connection_mst_branch when returning false).
  1620. * return true - detection is completed, link has been fully updated with latest
  1621. * detection result.
  1622. */
  1623. bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason);
  1624. struct dc_sink_init_data;
  1625. /* When link connection type is dc_connection_mst_branch, remote sink can be
  1626. * added to the link. The interface creates a remote sink and associates it with
  1627. * current link. The sink will be retained by link until remove remote sink is
  1628. * called.
  1629. *
  1630. * @dc_link - link the remote sink will be added to.
  1631. * @edid - byte array of EDID raw data.
  1632. * @len - size of the edid in byte
  1633. * @init_data -
  1634. */
  1635. struct dc_sink *dc_link_add_remote_sink(
  1636. struct dc_link *dc_link,
  1637. const uint8_t *edid,
  1638. int len,
  1639. struct dc_sink_init_data *init_data);
  1640. /* Remove remote sink from a link with dc_connection_mst_branch connection type.
  1641. * @link - link the sink should be removed from
  1642. * @sink - sink to be removed.
  1643. */
  1644. void dc_link_remove_remote_sink(
  1645. struct dc_link *link,
  1646. struct dc_sink *sink);
  1647. /* Enable HPD interrupt handler for a given link */
  1648. void dc_link_enable_hpd(const struct dc_link *link);
  1649. /* Disable HPD interrupt handler for a given link */
  1650. void dc_link_disable_hpd(const struct dc_link *link);
  1651. /* determine if there is a sink connected to the link
  1652. *
  1653. * @type - dc_connection_single if connected, dc_connection_none otherwise.
  1654. * return - false if an unexpected error occurs, true otherwise.
  1655. *
  1656. * NOTE: This function doesn't detect downstream sink connections i.e
  1657. * dc_connection_mst_branch, dc_connection_sst_branch. In this case, it will
  1658. * return dc_connection_single if the branch device is connected despite of
  1659. * downstream sink's connection status.
  1660. */
  1661. bool dc_link_detect_connection_type(struct dc_link *link,
  1662. enum dc_connection_type *type);
  1663. /* query current hpd pin value
  1664. * return - true HPD is asserted (HPD high), false otherwise (HPD low)
  1665. *
  1666. */
  1667. bool dc_link_get_hpd_state(struct dc_link *link);
  1668. /* Getter for cached link status from given link */
  1669. const struct dc_link_status *dc_link_get_status(const struct dc_link *link);
  1670. /* enable/disable hardware HPD filter.
  1671. *
  1672. * @link - The link the HPD pin is associated with.
  1673. * @enable = true - enable hardware HPD filter. HPD event will only queued to irq
  1674. * handler once after no HPD change has been detected within dc default HPD
  1675. * filtering interval since last HPD event. i.e if display keeps toggling hpd
  1676. * pulses within default HPD interval, no HPD event will be received until HPD
  1677. * toggles have stopped. Then HPD event will be queued to irq handler once after
  1678. * dc default HPD filtering interval since last HPD event.
  1679. *
  1680. * @enable = false - disable hardware HPD filter. HPD event will be queued
  1681. * immediately to irq handler after no HPD change has been detected within
  1682. * IRQ_HPD (aka HPD short pulse) interval (i.e 2ms).
  1683. */
  1684. void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
  1685. /* submit i2c read/write payloads through ddc channel
  1686. * @link_index - index to a link with ddc in i2c mode
  1687. * @cmd - i2c command structure
  1688. * return - true if success, false otherwise.
  1689. */
  1690. bool dc_submit_i2c(
  1691. struct dc *dc,
  1692. uint32_t link_index,
  1693. struct i2c_command *cmd);
  1694. /* submit i2c read/write payloads through oem channel
  1695. * @link_index - index to a link with ddc in i2c mode
  1696. * @cmd - i2c command structure
  1697. * return - true if success, false otherwise.
  1698. */
  1699. bool dc_submit_i2c_oem(
  1700. struct dc *dc,
  1701. struct i2c_command *cmd);
  1702. enum aux_return_code_type;
  1703. /* Attempt to transfer the given aux payload. This function does not perform
  1704. * retries or handle error states. The reply is returned in the payload->reply
  1705. * and the result through operation_result. Returns the number of bytes
  1706. * transferred,or -1 on a failure.
  1707. */
  1708. int dc_link_aux_transfer_raw(struct ddc_service *ddc,
  1709. struct aux_payload *payload,
  1710. enum aux_return_code_type *operation_result);
  1711. bool dc_is_oem_i2c_device_present(
  1712. struct dc *dc,
  1713. size_t slave_address
  1714. );
  1715. /* return true if the connected receiver supports the hdcp version */
  1716. bool dc_link_is_hdcp14(struct dc_link *link, enum signal_type signal);
  1717. bool dc_link_is_hdcp22(struct dc_link *link, enum signal_type signal);
  1718. /* Notify DC about DP RX Interrupt (aka DP IRQ_HPD).
  1719. *
  1720. * TODO - When defer_handling is true the function will have a different purpose.
  1721. * It no longer does complete hpd rx irq handling. We should create a separate
  1722. * interface specifically for this case.
  1723. *
  1724. * Return:
  1725. * true - Downstream port status changed. DM should call DC to do the
  1726. * detection.
  1727. * false - no change in Downstream port status. No further action required
  1728. * from DM.
  1729. */
  1730. bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
  1731. union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss,
  1732. bool defer_handling, bool *has_left_work);
  1733. /* handle DP specs define test automation sequence*/
  1734. void dc_link_dp_handle_automated_test(struct dc_link *link);
  1735. /* handle DP Link loss sequence and try to recover RX link loss with best
  1736. * effort
  1737. */
  1738. void dc_link_dp_handle_link_loss(struct dc_link *link);
  1739. /* Determine if hpd rx irq should be handled or ignored
  1740. * return true - hpd rx irq should be handled.
  1741. * return false - it is safe to ignore hpd rx irq event
  1742. */
  1743. bool dc_link_dp_allow_hpd_rx_irq(const struct dc_link *link);
  1744. /* Determine if link loss is indicated with a given hpd_irq_dpcd_data.
  1745. * @link - link the hpd irq data associated with
  1746. * @hpd_irq_dpcd_data - input hpd irq data
  1747. * return - true if hpd irq data indicates a link lost
  1748. */
  1749. bool dc_link_check_link_loss_status(struct dc_link *link,
  1750. union hpd_irq_data *hpd_irq_dpcd_data);
  1751. /* Read hpd rx irq data from a given link
  1752. * @link - link where the hpd irq data should be read from
  1753. * @irq_data - output hpd irq data
  1754. * return - DC_OK if hpd irq data is read successfully, otherwise hpd irq data
  1755. * read has failed.
  1756. */
  1757. enum dc_status dc_link_dp_read_hpd_rx_irq_data(
  1758. struct dc_link *link,
  1759. union hpd_irq_data *irq_data);
  1760. /* The function clears recorded DP RX states in the link. DM should call this
  1761. * function when it is resuming from S3 power state to previously connected links.
  1762. *
  1763. * TODO - in the future we should consider to expand link resume interface to
  1764. * support clearing previous rx states. So we don't have to rely on dm to call
  1765. * this interface explicitly.
  1766. */
  1767. void dc_link_clear_dprx_states(struct dc_link *link);
  1768. /* Destruct the mst topology of the link and reset the allocated payload table
  1769. *
  1770. * NOTE: this should only be called if DM chooses not to call dc_link_detect but
  1771. * still wants to reset MST topology on an unplug event */
  1772. bool dc_link_reset_cur_dp_mst_topology(struct dc_link *link);
  1773. /* The function calculates effective DP link bandwidth when a given link is
  1774. * using the given link settings.
  1775. *
  1776. * return - total effective link bandwidth in kbps.
  1777. */
  1778. uint32_t dc_link_bandwidth_kbps(
  1779. const struct dc_link *link,
  1780. const struct dc_link_settings *link_setting);
  1781. /* The function takes a snapshot of current link resource allocation state
  1782. * @dc: pointer to dc of the dm calling this
  1783. * @map: a dc link resource snapshot defined internally to dc.
  1784. *
  1785. * DM needs to capture a snapshot of current link resource allocation mapping
  1786. * and store it in its persistent storage.
  1787. *
  1788. * Some of the link resource is using first come first serve policy.
  1789. * The allocation mapping depends on original hotplug order. This information
  1790. * is lost after driver is loaded next time. The snapshot is used in order to
  1791. * restore link resource to its previous state so user will get consistent
  1792. * link capability allocation across reboot.
  1793. *
  1794. */
  1795. void dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map);
  1796. /* This function restores link resource allocation state from a snapshot
  1797. * @dc: pointer to dc of the dm calling this
  1798. * @map: a dc link resource snapshot defined internally to dc.
  1799. *
  1800. * DM needs to call this function after initial link detection on boot and
  1801. * before first commit streams to restore link resource allocation state
  1802. * from previous boot session.
  1803. *
  1804. * Some of the link resource is using first come first serve policy.
  1805. * The allocation mapping depends on original hotplug order. This information
  1806. * is lost after driver is loaded next time. The snapshot is used in order to
  1807. * restore link resource to its previous state so user will get consistent
  1808. * link capability allocation across reboot.
  1809. *
  1810. */
  1811. void dc_restore_link_res_map(const struct dc *dc, uint32_t *map);
  1812. /* TODO: this is not meant to be exposed to DM. Should switch to stream update
  1813. * interface i.e stream_update->dsc_config
  1814. */
  1815. bool dc_link_update_dsc_config(struct pipe_ctx *pipe_ctx);
  1816. /* translate a raw link rate data to bandwidth in kbps */
  1817. uint32_t dc_link_bw_kbps_from_raw_frl_link_rate_data(const struct dc *dc, uint8_t bw);
  1818. /* determine the optimal bandwidth given link and required bw.
  1819. * @link - current detected link
  1820. * @req_bw - requested bandwidth in kbps
  1821. * @link_settings - returned most optimal link settings that can fit the
  1822. * requested bandwidth
  1823. * return - false if link can't support requested bandwidth, true if link
  1824. * settings is found.
  1825. */
  1826. bool dc_link_decide_edp_link_settings(struct dc_link *link,
  1827. struct dc_link_settings *link_settings,
  1828. uint32_t req_bw);
  1829. /* return the max dp link settings can be driven by the link without considering
  1830. * connected RX device and its capability
  1831. */
  1832. bool dc_link_dp_get_max_link_enc_cap(const struct dc_link *link,
  1833. struct dc_link_settings *max_link_enc_cap);
  1834. /* determine when the link is driving MST mode, what DP link channel coding
  1835. * format will be used. The decision will remain unchanged until next HPD event.
  1836. *
  1837. * @link - a link with DP RX connection
  1838. * return - if stream is committed to this link with MST signal type, type of
  1839. * channel coding format dc will choose.
  1840. */
  1841. enum dp_link_encoding dc_link_dp_mst_decide_link_encoding_format(
  1842. const struct dc_link *link);
  1843. /* get max dp link settings the link can enable with all things considered. (i.e
  1844. * TX/RX/Cable capabilities and dp override policies.
  1845. *
  1846. * @link - a link with DP RX connection
  1847. * return - max dp link settings the link can enable.
  1848. *
  1849. */
  1850. const struct dc_link_settings *dc_link_get_link_cap(const struct dc_link *link);
  1851. /* Get the highest encoding format that the link supports; highest meaning the
  1852. * encoding format which supports the maximum bandwidth.
  1853. *
  1854. * @link - a link with DP RX connection
  1855. * return - highest encoding format link supports.
  1856. */
  1857. enum dc_link_encoding_format dc_link_get_highest_encoding_format(const struct dc_link *link);
  1858. /* Check if a RX (ex. DP sink, MST hub, passive or active dongle) is connected
  1859. * to a link with dp connector signal type.
  1860. * @link - a link with dp connector signal type
  1861. * return - true if connected, false otherwise
  1862. */
  1863. bool dc_link_is_dp_sink_present(struct dc_link *link);
  1864. /* Force DP lane settings update to main-link video signal and notify the change
  1865. * to DP RX via DPCD. This is a debug interface used for video signal integrity
  1866. * tuning purpose. The interface assumes link has already been enabled with DP
  1867. * signal.
  1868. *
  1869. * @lt_settings - a container structure with desired hw_lane_settings
  1870. */
  1871. void dc_link_set_drive_settings(struct dc *dc,
  1872. struct link_training_settings *lt_settings,
  1873. struct dc_link *link);
  1874. /* Enable a test pattern in Link or PHY layer in an active link for compliance
  1875. * test or debugging purpose. The test pattern will remain until next un-plug.
  1876. *
  1877. * @link - active link with DP signal output enabled.
  1878. * @test_pattern - desired test pattern to output.
  1879. * NOTE: set to DP_TEST_PATTERN_VIDEO_MODE to disable previous test pattern.
  1880. * @test_pattern_color_space - for video test pattern choose a desired color
  1881. * space.
  1882. * @p_link_settings - For PHY pattern choose a desired link settings
  1883. * @p_custom_pattern - some test pattern will require a custom input to
  1884. * customize some pattern details. Otherwise keep it to NULL.
  1885. * @cust_pattern_size - size of the custom pattern input.
  1886. *
  1887. */
  1888. bool dc_link_dp_set_test_pattern(
  1889. struct dc_link *link,
  1890. enum dp_test_pattern test_pattern,
  1891. enum dp_test_pattern_color_space test_pattern_color_space,
  1892. const struct link_training_settings *p_link_settings,
  1893. const unsigned char *p_custom_pattern,
  1894. unsigned int cust_pattern_size);
  1895. /* Force DP link settings to always use a specific value until reboot to a
  1896. * specific link. If link has already been enabled, the interface will also
  1897. * switch to desired link settings immediately. This is a debug interface to
  1898. * generic dp issue trouble shooting.
  1899. */
  1900. void dc_link_set_preferred_link_settings(struct dc *dc,
  1901. struct dc_link_settings *link_setting,
  1902. struct dc_link *link);
  1903. /* Force DP link to customize a specific link training behavior by overriding to
  1904. * standard DP specs defined protocol. This is a debug interface to trouble shoot
  1905. * display specific link training issues or apply some display specific
  1906. * workaround in link training.
  1907. *
  1908. * @link_settings - if not NULL, force preferred link settings to the link.
  1909. * @lt_override - a set of override pointers. If any pointer is none NULL, dc
  1910. * will apply this particular override in future link training. If NULL is
  1911. * passed in, dc resets previous overrides.
  1912. * NOTE: DM must keep the memory from override pointers until DM resets preferred
  1913. * training settings.
  1914. */
  1915. void dc_link_set_preferred_training_settings(struct dc *dc,
  1916. struct dc_link_settings *link_setting,
  1917. struct dc_link_training_overrides *lt_overrides,
  1918. struct dc_link *link,
  1919. bool skip_immediate_retrain);
  1920. /* return - true if FEC is supported with connected DP RX, false otherwise */
  1921. bool dc_link_is_fec_supported(const struct dc_link *link);
  1922. /* query FEC enablement policy to determine if FEC will be enabled by dc during
  1923. * link enablement.
  1924. * return - true if FEC should be enabled, false otherwise.
  1925. */
  1926. bool dc_link_should_enable_fec(const struct dc_link *link);
  1927. /* determine lttpr mode the current link should be enabled with a specific link
  1928. * settings.
  1929. */
  1930. enum lttpr_mode dc_link_decide_lttpr_mode(struct dc_link *link,
  1931. struct dc_link_settings *link_setting);
  1932. /* Force DP RX to update its power state.
  1933. * NOTE: this interface doesn't update dp main-link. Calling this function will
  1934. * cause DP TX main-link and DP RX power states out of sync. DM has to restore
  1935. * RX power state back upon finish DM specific execution requiring DP RX in a
  1936. * specific power state.
  1937. * @on - true to set DP RX in D0 power state, false to set DP RX in D3 power
  1938. * state.
  1939. */
  1940. void dc_link_dp_receiver_power_ctrl(struct dc_link *link, bool on);
  1941. /* Force link to read base dp receiver caps from dpcd 000h - 00Fh and overwrite
  1942. * current value read from extended receiver cap from 02200h - 0220Fh.
  1943. * Some DP RX has problems of providing accurate DP receiver caps from extended
  1944. * field, this interface is a workaround to revert link back to use base caps.
  1945. */
  1946. void dc_link_overwrite_extended_receiver_cap(
  1947. struct dc_link *link);
  1948. void dc_link_edp_panel_backlight_power_on(struct dc_link *link,
  1949. bool wait_for_hpd);
  1950. /* Set backlight level of an embedded panel (eDP, LVDS).
  1951. * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer
  1952. * and 16 bit fractional, where 1.0 is max backlight value.
  1953. */
  1954. bool dc_link_set_backlight_level(const struct dc_link *dc_link,
  1955. uint32_t backlight_pwm_u16_16,
  1956. uint32_t frame_ramp);
  1957. /* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */
  1958. bool dc_link_set_backlight_level_nits(struct dc_link *link,
  1959. bool isHDR,
  1960. uint32_t backlight_millinits,
  1961. uint32_t transition_time_in_ms);
  1962. bool dc_link_get_backlight_level_nits(struct dc_link *link,
  1963. uint32_t *backlight_millinits,
  1964. uint32_t *backlight_millinits_peak);
  1965. int dc_link_get_backlight_level(const struct dc_link *dc_link);
  1966. int dc_link_get_target_backlight_pwm(const struct dc_link *link);
  1967. bool dc_link_set_psr_allow_active(struct dc_link *dc_link, const bool *enable,
  1968. bool wait, bool force_static, const unsigned int *power_opts);
  1969. bool dc_link_get_psr_state(const struct dc_link *dc_link, enum dc_psr_state *state);
  1970. bool dc_link_setup_psr(struct dc_link *dc_link,
  1971. const struct dc_stream_state *stream, struct psr_config *psr_config,
  1972. struct psr_context *psr_context);
  1973. /*
  1974. * Communicate with DMUB to allow or disallow Panel Replay on the specified link:
  1975. *
  1976. * @link: pointer to the dc_link struct instance
  1977. * @enable: enable(active) or disable(inactive) replay
  1978. * @wait: state transition need to wait the active set completed.
  1979. * @force_static: force disable(inactive) the replay
  1980. * @power_opts: set power optimazation parameters to DMUB.
  1981. *
  1982. * return: allow Replay active will return true, else will return false.
  1983. */
  1984. bool dc_link_set_replay_allow_active(struct dc_link *dc_link, const bool *enable,
  1985. bool wait, bool force_static, const unsigned int *power_opts);
  1986. bool dc_link_get_replay_state(const struct dc_link *dc_link, uint64_t *state);
  1987. /* On eDP links this function call will stall until T12 has elapsed.
  1988. * If the panel is not in power off state, this function will return
  1989. * immediately.
  1990. */
  1991. bool dc_link_wait_for_t12(struct dc_link *link);
  1992. /* Determine if dp trace has been initialized to reflect upto date result *
  1993. * return - true if trace is initialized and has valid data. False dp trace
  1994. * doesn't have valid result.
  1995. */
  1996. bool dc_dp_trace_is_initialized(struct dc_link *link);
  1997. /* Query a dp trace flag to indicate if the current dp trace data has been
  1998. * logged before
  1999. */
  2000. bool dc_dp_trace_is_logged(struct dc_link *link,
  2001. bool in_detection);
  2002. /* Set dp trace flag to indicate whether DM has already logged the current dp
  2003. * trace data. DM can set is_logged to true upon logging and check
  2004. * dc_dp_trace_is_logged before logging to avoid logging the same result twice.
  2005. */
  2006. void dc_dp_trace_set_is_logged_flag(struct dc_link *link,
  2007. bool in_detection,
  2008. bool is_logged);
  2009. /* Obtain driver time stamp for last dp link training end. The time stamp is
  2010. * formatted based on dm_get_timestamp DM function.
  2011. * @in_detection - true to get link training end time stamp of last link
  2012. * training in detection sequence. false to get link training end time stamp
  2013. * of last link training in commit (dpms) sequence
  2014. */
  2015. unsigned long long dc_dp_trace_get_lt_end_timestamp(struct dc_link *link,
  2016. bool in_detection);
  2017. /* Get how many link training attempts dc has done with latest sequence.
  2018. * @in_detection - true to get link training count of last link
  2019. * training in detection sequence. false to get link training count of last link
  2020. * training in commit (dpms) sequence
  2021. */
  2022. const struct dp_trace_lt_counts *dc_dp_trace_get_lt_counts(struct dc_link *link,
  2023. bool in_detection);
  2024. /* Get how many link loss has happened since last link training attempts */
  2025. unsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link);
  2026. /*
  2027. * USB4 DPIA BW ALLOCATION PUBLIC FUNCTIONS
  2028. */
  2029. /*
  2030. * Send a request from DP-Tx requesting to allocate BW remotely after
  2031. * allocating it locally. This will get processed by CM and a CB function
  2032. * will be called.
  2033. *
  2034. * @link: pointer to the dc_link struct instance
  2035. * @req_bw: The requested bw in Kbyte to allocated
  2036. *
  2037. * return: none
  2038. */
  2039. void dc_link_set_usb4_req_bw_req(struct dc_link *link, int req_bw);
  2040. /*
  2041. * Handle function for when the status of the Request above is complete.
  2042. * We will find out the result of allocating on CM and update structs.
  2043. *
  2044. * @link: pointer to the dc_link struct instance
  2045. * @bw: Allocated or Estimated BW depending on the result
  2046. * @result: Response type
  2047. *
  2048. * return: none
  2049. */
  2050. void dc_link_handle_usb4_bw_alloc_response(struct dc_link *link,
  2051. uint8_t bw, uint8_t result);
  2052. /*
  2053. * Handle the USB4 BW Allocation related functionality here:
  2054. * Plug => Try to allocate max bw from timing parameters supported by the sink
  2055. * Unplug => de-allocate bw
  2056. *
  2057. * @link: pointer to the dc_link struct instance
  2058. * @peak_bw: Peak bw used by the link/sink
  2059. *
  2060. * return: allocated bw else return 0
  2061. */
  2062. int dc_link_dp_dpia_handle_usb4_bandwidth_allocation_for_link(
  2063. struct dc_link *link, int peak_bw);
  2064. /*
  2065. * Validate the BW of all the valid DPIA links to make sure it doesn't exceed
  2066. * available BW for each host router
  2067. *
  2068. * @dc: pointer to dc struct
  2069. * @stream: pointer to all possible streams
  2070. * @count: number of valid DPIA streams
  2071. *
  2072. * return: TRUE if bw used by DPIAs doesn't exceed available BW else return FALSE
  2073. */
  2074. bool dc_link_dp_dpia_validate(struct dc *dc, const struct dc_stream_state *streams,
  2075. const unsigned int count);
  2076. /* Sink Interfaces - A sink corresponds to a display output device */
  2077. struct dc_container_id {
  2078. // 128bit GUID in binary form
  2079. unsigned char guid[16];
  2080. // 8 byte port ID -> ELD.PortID
  2081. unsigned int portId[2];
  2082. // 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
  2083. unsigned short manufacturerName;
  2084. // 2 byte product code -> ELD.ProductCode
  2085. unsigned short productCode;
  2086. };
  2087. struct dc_sink_dsc_caps {
  2088. // 'true' if these are virtual DPCD's DSC caps (immediately upstream of sink in MST topology),
  2089. // 'false' if they are sink's DSC caps
  2090. bool is_virtual_dpcd_dsc;
  2091. // 'true' if MST topology supports DSC passthrough for sink
  2092. // 'false' if MST topology does not support DSC passthrough
  2093. bool is_dsc_passthrough_supported;
  2094. struct dsc_dec_dpcd_caps dsc_dec_caps;
  2095. };
  2096. struct dc_sink_fec_caps {
  2097. bool is_rx_fec_supported;
  2098. bool is_topology_fec_supported;
  2099. };
  2100. struct scdc_caps {
  2101. union hdmi_scdc_manufacturer_OUI_data manufacturer_OUI;
  2102. union hdmi_scdc_device_id_data device_id;
  2103. };
  2104. /*
  2105. * The sink structure contains EDID and other display device properties
  2106. */
  2107. struct dc_sink {
  2108. enum signal_type sink_signal;
  2109. struct dc_edid dc_edid; /* raw edid */
  2110. struct dc_edid_caps edid_caps; /* parse display caps */
  2111. struct dc_container_id *dc_container_id;
  2112. uint32_t dongle_max_pix_clk;
  2113. void *priv;
  2114. struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
  2115. bool converter_disable_audio;
  2116. struct scdc_caps scdc_caps;
  2117. struct dc_sink_dsc_caps dsc_caps;
  2118. struct dc_sink_fec_caps fec_caps;
  2119. bool is_vsc_sdp_colorimetry_supported;
  2120. /* private to DC core */
  2121. struct dc_link *link;
  2122. struct dc_context *ctx;
  2123. uint32_t sink_id;
  2124. /* private to dc_sink.c */
  2125. // refcount must be the last member in dc_sink, since we want the
  2126. // sink structure to be logically cloneable up to (but not including)
  2127. // refcount
  2128. struct kref refcount;
  2129. };
  2130. void dc_sink_retain(struct dc_sink *sink);
  2131. void dc_sink_release(struct dc_sink *sink);
  2132. struct dc_sink_init_data {
  2133. enum signal_type sink_signal;
  2134. struct dc_link *link;
  2135. uint32_t dongle_max_pix_clk;
  2136. bool converter_disable_audio;
  2137. };
  2138. struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
  2139. /* Newer interfaces */
  2140. struct dc_cursor {
  2141. struct dc_plane_address address;
  2142. struct dc_cursor_attributes attributes;
  2143. };
  2144. /* Interrupt interfaces */
  2145. enum dc_irq_source dc_interrupt_to_irq_source(
  2146. struct dc *dc,
  2147. uint32_t src_id,
  2148. uint32_t ext_id);
  2149. bool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable);
  2150. void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
  2151. enum dc_irq_source dc_get_hpd_irq_source_at_index(
  2152. struct dc *dc, uint32_t link_index);
  2153. void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable);
  2154. /* Power Interfaces */
  2155. void dc_set_power_state(
  2156. struct dc *dc,
  2157. enum dc_acpi_cm_power_state power_state);
  2158. void dc_resume(struct dc *dc);
  2159. void dc_power_down_on_boot(struct dc *dc);
  2160. /*
  2161. * HDCP Interfaces
  2162. */
  2163. enum hdcp_message_status dc_process_hdcp_msg(
  2164. enum signal_type signal,
  2165. struct dc_link *link,
  2166. struct hdcp_protection_message *message_info);
  2167. bool dc_is_dmcu_initialized(struct dc *dc);
  2168. enum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping);
  2169. void dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg);
  2170. bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc,
  2171. unsigned int pitch,
  2172. unsigned int height,
  2173. enum surface_pixel_format format,
  2174. struct dc_cursor_attributes *cursor_attr);
  2175. #define dc_allow_idle_optimizations(dc, allow) dc_allow_idle_optimizations_internal(dc, allow, __func__)
  2176. #define dc_exit_ips_for_hw_access(dc) dc_exit_ips_for_hw_access_internal(dc, __func__)
  2177. void dc_allow_idle_optimizations_internal(struct dc *dc, bool allow, const char *caller_name);
  2178. void dc_exit_ips_for_hw_access_internal(struct dc *dc, const char *caller_name);
  2179. bool dc_dmub_is_ips_idle_state(struct dc *dc);
  2180. /* set min and max memory clock to lowest and highest DPM level, respectively */
  2181. void dc_unlock_memory_clock_frequency(struct dc *dc);
  2182. /* set min memory clock to the min required for current mode, max to maxDPM */
  2183. void dc_lock_memory_clock_frequency(struct dc *dc);
  2184. /* set soft max for memclk, to be used for AC/DC switching clock limitations */
  2185. void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable);
  2186. /* cleanup on driver unload */
  2187. void dc_hardware_release(struct dc *dc);
  2188. /* disables fw based mclk switch */
  2189. void dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(struct dc *dc);
  2190. bool dc_set_psr_allow_active(struct dc *dc, bool enable);
  2191. bool dc_set_replay_allow_active(struct dc *dc, bool active);
  2192. bool dc_set_ips_disable(struct dc *dc, unsigned int disable_ips);
  2193. void dc_z10_restore(const struct dc *dc);
  2194. void dc_z10_save_init(struct dc *dc);
  2195. bool dc_is_dmub_outbox_supported(struct dc *dc);
  2196. bool dc_enable_dmub_notifications(struct dc *dc);
  2197. bool dc_abm_save_restore(
  2198. struct dc *dc,
  2199. struct dc_stream_state *stream,
  2200. struct abm_save_restore *pData);
  2201. void dc_enable_dmub_outbox(struct dc *dc);
  2202. bool dc_process_dmub_aux_transfer_async(struct dc *dc,
  2203. uint32_t link_index,
  2204. struct aux_payload *payload);
  2205. /* Get dc link index from dpia port index */
  2206. uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,
  2207. uint8_t dpia_port_index);
  2208. bool dc_process_dmub_set_config_async(struct dc *dc,
  2209. uint32_t link_index,
  2210. struct set_config_cmd_payload *payload,
  2211. struct dmub_notification *notify);
  2212. enum dc_status dc_process_dmub_set_mst_slots(const struct dc *dc,
  2213. uint32_t link_index,
  2214. uint8_t mst_alloc_slots,
  2215. uint8_t *mst_slots_in_use);
  2216. void dc_process_dmub_dpia_set_tps_notification(const struct dc *dc, uint32_t link_index, uint8_t tps);
  2217. void dc_process_dmub_dpia_hpd_int_enable(const struct dc *dc,
  2218. uint32_t hpd_int_enable);
  2219. void dc_print_dmub_diagnostic_data(const struct dc *dc);
  2220. void dc_query_current_properties(struct dc *dc, struct dc_current_properties *properties);
  2221. struct dc_power_profile {
  2222. int power_level; /* Lower is better */
  2223. };
  2224. struct dc_power_profile dc_get_power_profile_for_dc_state(const struct dc_state *context);
  2225. unsigned int dc_get_det_buffer_size_from_state(const struct dc_state *context);
  2226. /* DSC Interfaces */
  2227. #include "dc_dsc.h"
  2228. /* Disable acc mode Interfaces */
  2229. void dc_disable_accelerated_mode(struct dc *dc);
  2230. bool dc_is_timing_changed(struct dc_stream_state *cur_stream,
  2231. struct dc_stream_state *new_stream);
  2232. #endif /* DC_INTERFACE_H_ */