xref: /openbsd-src/sys/dev/pci/drm/amd/display/dc/dc.h (revision a0689bdc7ad4bbffa58ddc078dc06e7777c109fc)
1fb4d8502Sjsg /*
2f005ef32Sjsg  * Copyright 2012-2023 Advanced Micro Devices, Inc.
3fb4d8502Sjsg  *
4fb4d8502Sjsg  * Permission is hereby granted, free of charge, to any person obtaining a
5fb4d8502Sjsg  * copy of this software and associated documentation files (the "Software"),
6fb4d8502Sjsg  * to deal in the Software without restriction, including without limitation
7fb4d8502Sjsg  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8fb4d8502Sjsg  * and/or sell copies of the Software, and to permit persons to whom the
9fb4d8502Sjsg  * Software is furnished to do so, subject to the following conditions:
10fb4d8502Sjsg  *
11fb4d8502Sjsg  * The above copyright notice and this permission notice shall be included in
12fb4d8502Sjsg  * all copies or substantial portions of the Software.
13fb4d8502Sjsg  *
14fb4d8502Sjsg  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15fb4d8502Sjsg  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16fb4d8502Sjsg  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
17fb4d8502Sjsg  * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18fb4d8502Sjsg  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19fb4d8502Sjsg  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20fb4d8502Sjsg  * OTHER DEALINGS IN THE SOFTWARE.
21fb4d8502Sjsg  *
22fb4d8502Sjsg  * Authors: AMD
23fb4d8502Sjsg  *
24fb4d8502Sjsg  */
25fb4d8502Sjsg 
26fb4d8502Sjsg #ifndef DC_INTERFACE_H_
27fb4d8502Sjsg #define DC_INTERFACE_H_
28fb4d8502Sjsg 
29fb4d8502Sjsg #include "dc_types.h"
30fb4d8502Sjsg #include "grph_object_defs.h"
31fb4d8502Sjsg #include "logger_types.h"
32f005ef32Sjsg #include "hdcp_msg_types.h"
33fb4d8502Sjsg #include "gpio_types.h"
34fb4d8502Sjsg #include "link_service_types.h"
35fb4d8502Sjsg #include "grph_object_ctrl_defs.h"
36fb4d8502Sjsg #include <inc/hw/opp.h>
37fb4d8502Sjsg 
38fb4d8502Sjsg #include "inc/hw_sequencer.h"
39fb4d8502Sjsg #include "inc/compressor.h"
40c349dbc7Sjsg #include "inc/hw/dmcu.h"
41fb4d8502Sjsg #include "dml/display_mode_lib.h"
42fb4d8502Sjsg 
43f005ef32Sjsg struct abm_save_restore;
44f005ef32Sjsg 
455ca02815Sjsg /* forward declaration */
465ca02815Sjsg struct aux_payload;
471bb76ff1Sjsg struct set_config_cmd_payload;
481bb76ff1Sjsg struct dmub_notification;
495ca02815Sjsg 
50f005ef32Sjsg #define DC_VER "3.2.247"
51fb4d8502Sjsg 
52fb4d8502Sjsg #define MAX_SURFACES 3
53c349dbc7Sjsg #define MAX_PLANES 6
54fb4d8502Sjsg #define MAX_STREAMS 6
555ca02815Sjsg #define MIN_VIEWPORT_SIZE 12
565ca02815Sjsg #define MAX_NUM_EDP 2
57fb4d8502Sjsg 
58539d1f6aSjsg /* Display Core Interfaces */
59fb4d8502Sjsg struct dc_versions {
60fb4d8502Sjsg 	const char *dc_ver;
61fb4d8502Sjsg 	struct dmcu_version dmcu_version;
62fb4d8502Sjsg };
63fb4d8502Sjsg 
64c349dbc7Sjsg enum dp_protocol_version {
65f005ef32Sjsg 	DP_VERSION_1_4 = 0,
66f005ef32Sjsg 	DP_VERSION_2_1,
67f005ef32Sjsg 	DP_VERSION_UNKNOWN,
68c349dbc7Sjsg };
69c349dbc7Sjsg 
70c349dbc7Sjsg enum dc_plane_type {
71c349dbc7Sjsg 	DC_PLANE_TYPE_INVALID,
72c349dbc7Sjsg 	DC_PLANE_TYPE_DCE_RGB,
73c349dbc7Sjsg 	DC_PLANE_TYPE_DCE_UNDERLAY,
74c349dbc7Sjsg 	DC_PLANE_TYPE_DCN_UNIVERSAL,
75c349dbc7Sjsg };
76c349dbc7Sjsg 
771bb76ff1Sjsg // Sizes defined as multiples of 64KB
781bb76ff1Sjsg enum det_size {
791bb76ff1Sjsg 	DET_SIZE_DEFAULT = 0,
801bb76ff1Sjsg 	DET_SIZE_192KB = 3,
811bb76ff1Sjsg 	DET_SIZE_256KB = 4,
821bb76ff1Sjsg 	DET_SIZE_320KB = 5,
831bb76ff1Sjsg 	DET_SIZE_384KB = 6
841bb76ff1Sjsg };
851bb76ff1Sjsg 
861bb76ff1Sjsg 
87c349dbc7Sjsg struct dc_plane_cap {
88c349dbc7Sjsg 	enum dc_plane_type type;
89c349dbc7Sjsg 	uint32_t per_pixel_alpha : 1;
90c349dbc7Sjsg 	struct {
91c349dbc7Sjsg 		uint32_t argb8888 : 1;
92c349dbc7Sjsg 		uint32_t nv12 : 1;
93c349dbc7Sjsg 		uint32_t fp16 : 1;
94c349dbc7Sjsg 		uint32_t p010 : 1;
95c349dbc7Sjsg 		uint32_t ayuv : 1;
96c349dbc7Sjsg 	} pixel_format_support;
97c349dbc7Sjsg 	// max upscaling factor x1000
98c349dbc7Sjsg 	// upscaling factors are always >= 1
99c349dbc7Sjsg 	// for example, 1080p -> 8K is 4.0, or 4000 raw value
100c349dbc7Sjsg 	struct {
101c349dbc7Sjsg 		uint32_t argb8888;
102c349dbc7Sjsg 		uint32_t nv12;
103c349dbc7Sjsg 		uint32_t fp16;
104c349dbc7Sjsg 	} max_upscale_factor;
105c349dbc7Sjsg 	// max downscale factor x1000
106c349dbc7Sjsg 	// downscale factors are always <= 1
107c349dbc7Sjsg 	// for example, 8K -> 1080p is 0.25, or 250 raw value
108c349dbc7Sjsg 	struct {
109c349dbc7Sjsg 		uint32_t argb8888;
110c349dbc7Sjsg 		uint32_t nv12;
111c349dbc7Sjsg 		uint32_t fp16;
112c349dbc7Sjsg 	} max_downscale_factor;
113ad8b1aafSjsg 	// minimal width/height
114ad8b1aafSjsg 	uint32_t min_width;
115ad8b1aafSjsg 	uint32_t min_height;
116ad8b1aafSjsg };
117ad8b1aafSjsg 
1181bb76ff1Sjsg /**
1191bb76ff1Sjsg  * DOC: color-management-caps
1201bb76ff1Sjsg  *
1211bb76ff1Sjsg  * **Color management caps (DPP and MPC)**
1221bb76ff1Sjsg  *
1231bb76ff1Sjsg  * Modules/color calculates various color operations which are translated to
1241bb76ff1Sjsg  * abstracted HW. DCE 5-12 had almost no important changes, but starting with
1251bb76ff1Sjsg  * DCN1, every new generation comes with fairly major differences in color
1261bb76ff1Sjsg  * pipeline. Therefore, we abstract color pipe capabilities so modules/DM can
1271bb76ff1Sjsg  * decide mapping to HW block based on logical capabilities.
1281bb76ff1Sjsg  */
1291bb76ff1Sjsg 
1301bb76ff1Sjsg /**
1311bb76ff1Sjsg  * struct rom_curve_caps - predefined transfer function caps for degamma and regamma
1321bb76ff1Sjsg  * @srgb: RGB color space transfer func
1331bb76ff1Sjsg  * @bt2020: BT.2020 transfer func
1341bb76ff1Sjsg  * @gamma2_2: standard gamma
1351bb76ff1Sjsg  * @pq: perceptual quantizer transfer function
1361bb76ff1Sjsg  * @hlg: hybrid log–gamma transfer function
1371bb76ff1Sjsg  */
138ad8b1aafSjsg struct rom_curve_caps {
139ad8b1aafSjsg 	uint16_t srgb : 1;
140ad8b1aafSjsg 	uint16_t bt2020 : 1;
141ad8b1aafSjsg 	uint16_t gamma2_2 : 1;
142ad8b1aafSjsg 	uint16_t pq : 1;
143ad8b1aafSjsg 	uint16_t hlg : 1;
144ad8b1aafSjsg };
145ad8b1aafSjsg 
1461bb76ff1Sjsg /**
1471bb76ff1Sjsg  * struct dpp_color_caps - color pipeline capabilities for display pipe and
1481bb76ff1Sjsg  * plane blocks
1491bb76ff1Sjsg  *
1501bb76ff1Sjsg  * @dcn_arch: all DCE generations treated the same
1511bb76ff1Sjsg  * @input_lut_shared: shared with DGAM. Input LUT is different than most LUTs,
1521bb76ff1Sjsg  * just plain 256-entry lookup
1531bb76ff1Sjsg  * @icsc: input color space conversion
1541bb76ff1Sjsg  * @dgam_ram: programmable degamma LUT
1551bb76ff1Sjsg  * @post_csc: post color space conversion, before gamut remap
1561bb76ff1Sjsg  * @gamma_corr: degamma correction
1571bb76ff1Sjsg  * @hw_3d_lut: 3D LUT support. It implies a shaper LUT before. It may be shared
1581bb76ff1Sjsg  * with MPC by setting mpc:shared_3d_lut flag
1591bb76ff1Sjsg  * @ogam_ram: programmable out/blend gamma LUT
1601bb76ff1Sjsg  * @ocsc: output color space conversion
1611bb76ff1Sjsg  * @dgam_rom_for_yuv: pre-defined degamma LUT for YUV planes
1621bb76ff1Sjsg  * @dgam_rom_caps: pre-definied curve caps for degamma 1D LUT
1631bb76ff1Sjsg  * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
1641bb76ff1Sjsg  *
1651bb76ff1Sjsg  * Note: hdr_mult and gamut remap (CTM) are always available in DPP (in that order)
1661bb76ff1Sjsg  */
167ad8b1aafSjsg struct dpp_color_caps {
1681bb76ff1Sjsg 	uint16_t dcn_arch : 1;
1691bb76ff1Sjsg 	uint16_t input_lut_shared : 1;
170ad8b1aafSjsg 	uint16_t icsc : 1;
171ad8b1aafSjsg 	uint16_t dgam_ram : 1;
1721bb76ff1Sjsg 	uint16_t post_csc : 1;
173ad8b1aafSjsg 	uint16_t gamma_corr : 1;
174ad8b1aafSjsg 	uint16_t hw_3d_lut : 1;
1751bb76ff1Sjsg 	uint16_t ogam_ram : 1;
176ad8b1aafSjsg 	uint16_t ocsc : 1;
1775ca02815Sjsg 	uint16_t dgam_rom_for_yuv : 1;
178ad8b1aafSjsg 	struct rom_curve_caps dgam_rom_caps;
179ad8b1aafSjsg 	struct rom_curve_caps ogam_rom_caps;
180ad8b1aafSjsg };
181ad8b1aafSjsg 
1821bb76ff1Sjsg /**
1831bb76ff1Sjsg  * struct mpc_color_caps - color pipeline capabilities for multiple pipe and
1841bb76ff1Sjsg  * plane combined blocks
1851bb76ff1Sjsg  *
1861bb76ff1Sjsg  * @gamut_remap: color transformation matrix
1871bb76ff1Sjsg  * @ogam_ram: programmable out gamma LUT
1881bb76ff1Sjsg  * @ocsc: output color space conversion matrix
1891bb76ff1Sjsg  * @num_3dluts: MPC 3D LUT; always assumes a preceding shaper LUT
1901bb76ff1Sjsg  * @shared_3d_lut: shared 3D LUT flag. Can be either DPP or MPC, but single
1911bb76ff1Sjsg  * instance
1921bb76ff1Sjsg  * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
1931bb76ff1Sjsg  */
194ad8b1aafSjsg struct mpc_color_caps {
195ad8b1aafSjsg 	uint16_t gamut_remap : 1;
196ad8b1aafSjsg 	uint16_t ogam_ram : 1;
197ad8b1aafSjsg 	uint16_t ocsc : 1;
1981bb76ff1Sjsg 	uint16_t num_3dluts : 3;
1991bb76ff1Sjsg 	uint16_t shared_3d_lut:1;
200ad8b1aafSjsg 	struct rom_curve_caps ogam_rom_caps;
201ad8b1aafSjsg };
202ad8b1aafSjsg 
2031bb76ff1Sjsg /**
2041bb76ff1Sjsg  * struct dc_color_caps - color pipes capabilities for DPP and MPC hw blocks
2051bb76ff1Sjsg  * @dpp: color pipes caps for DPP
2061bb76ff1Sjsg  * @mpc: color pipes caps for MPC
2071bb76ff1Sjsg  */
208ad8b1aafSjsg struct dc_color_caps {
209ad8b1aafSjsg 	struct dpp_color_caps dpp;
210ad8b1aafSjsg 	struct mpc_color_caps mpc;
211c349dbc7Sjsg };
212c349dbc7Sjsg 
2131bb76ff1Sjsg struct dc_dmub_caps {
2141bb76ff1Sjsg 	bool psr;
2151bb76ff1Sjsg 	bool mclk_sw;
216f005ef32Sjsg 	bool subvp_psr;
217f005ef32Sjsg 	bool gecc_enable;
2181bb76ff1Sjsg };
2191bb76ff1Sjsg 
220fb4d8502Sjsg struct dc_caps {
221fb4d8502Sjsg 	uint32_t max_streams;
222fb4d8502Sjsg 	uint32_t max_links;
223fb4d8502Sjsg 	uint32_t max_audios;
224fb4d8502Sjsg 	uint32_t max_slave_planes;
2255ca02815Sjsg 	uint32_t max_slave_yuv_planes;
2265ca02815Sjsg 	uint32_t max_slave_rgb_planes;
227fb4d8502Sjsg 	uint32_t max_planes;
228fb4d8502Sjsg 	uint32_t max_downscale_ratio;
229fb4d8502Sjsg 	uint32_t i2c_speed_in_khz;
2305ca02815Sjsg 	uint32_t i2c_speed_in_khz_hdcp;
231fb4d8502Sjsg 	uint32_t dmdata_alloc_size;
232fb4d8502Sjsg 	unsigned int max_cursor_size;
233fb4d8502Sjsg 	unsigned int max_video_width;
234914a7b63Sjsg 	/*
235914a7b63Sjsg 	 * max video plane width that can be safely assumed to be always
236914a7b63Sjsg 	 * supported by single DPP pipe.
237914a7b63Sjsg 	 */
238914a7b63Sjsg 	unsigned int max_optimizable_video_width;
2395ca02815Sjsg 	unsigned int min_horizontal_blanking_period;
240fb4d8502Sjsg 	int linear_pitch_alignment;
241fb4d8502Sjsg 	bool dcc_const_color;
242fb4d8502Sjsg 	bool dynamic_audio;
243fb4d8502Sjsg 	bool is_apu;
244fb4d8502Sjsg 	bool dual_link_dvi;
245fb4d8502Sjsg 	bool post_blend_color_processing;
246fb4d8502Sjsg 	bool force_dp_tps4_for_cp2520;
247fb4d8502Sjsg 	bool disable_dp_clk_share;
248fb4d8502Sjsg 	bool psp_setup_panel_mode;
249c349dbc7Sjsg 	bool extended_aux_timeout_support;
250c349dbc7Sjsg 	bool dmcub_support;
2511bb76ff1Sjsg 	bool zstate_support;
2525ca02815Sjsg 	uint32_t num_of_internal_disp;
253c349dbc7Sjsg 	enum dp_protocol_version max_dp_protocol_version;
2545ca02815Sjsg 	unsigned int mall_size_per_mem_channel;
2555ca02815Sjsg 	unsigned int mall_size_total;
2565ca02815Sjsg 	unsigned int cursor_cache_size;
257c349dbc7Sjsg 	struct dc_plane_cap planes[MAX_PLANES];
258ad8b1aafSjsg 	struct dc_color_caps color;
2591bb76ff1Sjsg 	struct dc_dmub_caps dmub_caps;
2601bb76ff1Sjsg 	bool dp_hpo;
2611bb76ff1Sjsg 	bool dp_hdmi21_pcon_support;
2621bb76ff1Sjsg 	bool edp_dsc_support;
2635ca02815Sjsg 	bool vbios_lttpr_aware;
2645ca02815Sjsg 	bool vbios_lttpr_enable;
2655580f0c5Sjsg 	uint32_t max_otg_num;
2661bb76ff1Sjsg 	uint32_t max_cab_allocation_bytes;
2671bb76ff1Sjsg 	uint32_t cache_line_size;
2681bb76ff1Sjsg 	uint32_t cache_num_ways;
2691bb76ff1Sjsg 	uint16_t subvp_fw_processing_delay_us;
270f005ef32Sjsg 	uint8_t subvp_drr_max_vblank_margin_us;
2711bb76ff1Sjsg 	uint16_t subvp_prefetch_end_to_mall_start_us;
2721bb76ff1Sjsg 	uint8_t subvp_swath_height_margin_lines; // subvp start line must be aligned to 2 x swath height
2731bb76ff1Sjsg 	uint16_t subvp_pstate_allow_width_us;
2741bb76ff1Sjsg 	uint16_t subvp_vertical_int_margin_us;
2751bb76ff1Sjsg 	bool seamless_odm;
276f005ef32Sjsg 	uint32_t max_v_total;
277f005ef32Sjsg 	uint8_t subvp_drr_vblank_start_margin_us;
278c349dbc7Sjsg };
279c349dbc7Sjsg 
280c349dbc7Sjsg struct dc_bug_wa {
281c349dbc7Sjsg 	bool no_connect_phy_config;
282c349dbc7Sjsg 	bool dedcn20_305_wa;
283c349dbc7Sjsg 	bool skip_clock_update;
284c349dbc7Sjsg 	bool lt_early_cr_pattern;
285f005ef32Sjsg 	struct {
286f005ef32Sjsg 		uint8_t uclk : 1;
287f005ef32Sjsg 		uint8_t fclk : 1;
288f005ef32Sjsg 		uint8_t dcfclk : 1;
289f005ef32Sjsg 		uint8_t dcfclk_ds: 1;
290f005ef32Sjsg 	} clock_update_disable_mask;
291fb4d8502Sjsg };
292fb4d8502Sjsg struct dc_dcc_surface_param {
293fb4d8502Sjsg 	struct dc_size surface_size;
294fb4d8502Sjsg 	enum surface_pixel_format format;
295fb4d8502Sjsg 	enum swizzle_mode_values swizzle_mode;
296fb4d8502Sjsg 	enum dc_scan_direction scan;
297fb4d8502Sjsg };
298fb4d8502Sjsg 
299fb4d8502Sjsg struct dc_dcc_setting {
300fb4d8502Sjsg 	unsigned int max_compressed_blk_size;
301fb4d8502Sjsg 	unsigned int max_uncompressed_blk_size;
302fb4d8502Sjsg 	bool independent_64b_blks;
3031bb76ff1Sjsg 	//These bitfields to be used starting with DCN
304ad8b1aafSjsg 	struct {
3051bb76ff1Sjsg 		uint32_t dcc_256_64_64 : 1;//available in ASICs before DCN (the worst compression case)
3061bb76ff1Sjsg 		uint32_t dcc_128_128_uncontrained : 1;  //available in ASICs before DCN
3071bb76ff1Sjsg 		uint32_t dcc_256_128_128 : 1;		//available starting with DCN
3081bb76ff1Sjsg 		uint32_t dcc_256_256_unconstrained : 1;  //available in ASICs before DCN (the best compression case)
309ad8b1aafSjsg 	} dcc_controls;
310fb4d8502Sjsg };
311fb4d8502Sjsg 
312fb4d8502Sjsg struct dc_surface_dcc_cap {
313fb4d8502Sjsg 	union {
314fb4d8502Sjsg 		struct {
315fb4d8502Sjsg 			struct dc_dcc_setting rgb;
316fb4d8502Sjsg 		} grph;
317fb4d8502Sjsg 
318fb4d8502Sjsg 		struct {
319fb4d8502Sjsg 			struct dc_dcc_setting luma;
320fb4d8502Sjsg 			struct dc_dcc_setting chroma;
321fb4d8502Sjsg 		} video;
322fb4d8502Sjsg 	};
323fb4d8502Sjsg 
324fb4d8502Sjsg 	bool capable;
325fb4d8502Sjsg 	bool const_color_support;
326fb4d8502Sjsg };
327fb4d8502Sjsg 
328c349dbc7Sjsg struct dc_static_screen_params {
329c349dbc7Sjsg 	struct {
330fb4d8502Sjsg 		bool force_trigger;
331fb4d8502Sjsg 		bool cursor_update;
332fb4d8502Sjsg 		bool surface_update;
333fb4d8502Sjsg 		bool overlay_update;
334c349dbc7Sjsg 	} triggers;
335c349dbc7Sjsg 	unsigned int num_frames;
336fb4d8502Sjsg };
337fb4d8502Sjsg 
338fb4d8502Sjsg 
339fb4d8502Sjsg /* Surface update type is used by dc_update_surfaces_and_stream
340fb4d8502Sjsg  * The update type is determined at the very beginning of the function based
341fb4d8502Sjsg  * on parameters passed in and decides how much programming (or updating) is
342fb4d8502Sjsg  * going to be done during the call.
343fb4d8502Sjsg  *
344fb4d8502Sjsg  * UPDATE_TYPE_FAST is used for really fast updates that do not require much
345fb4d8502Sjsg  * logical calculations or hardware register programming. This update MUST be
346fb4d8502Sjsg  * ISR safe on windows. Currently fast update will only be used to flip surface
347fb4d8502Sjsg  * address.
348fb4d8502Sjsg  *
349fb4d8502Sjsg  * UPDATE_TYPE_MED is used for slower updates which require significant hw
350fb4d8502Sjsg  * re-programming however do not affect bandwidth consumption or clock
351fb4d8502Sjsg  * requirements. At present, this is the level at which front end updates
352fb4d8502Sjsg  * that do not require us to run bw_calcs happen. These are in/out transfer func
353fb4d8502Sjsg  * updates, viewport offset changes, recout size changes and pixel depth changes.
354fb4d8502Sjsg  * This update can be done at ISR, but we want to minimize how often this happens.
355fb4d8502Sjsg  *
356fb4d8502Sjsg  * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
357fb4d8502Sjsg  * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
358fb4d8502Sjsg  * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
359fb4d8502Sjsg  * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
360fb4d8502Sjsg  * a full update. This cannot be done at ISR level and should be a rare event.
361fb4d8502Sjsg  * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
362fb4d8502Sjsg  * underscan we don't expect to see this call at all.
363fb4d8502Sjsg  */
364fb4d8502Sjsg 
365fb4d8502Sjsg enum surface_update_type {
366fb4d8502Sjsg 	UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
367fb4d8502Sjsg 	UPDATE_TYPE_MED,  /* ISR safe, most of programming needed, no bw/clk change*/
368fb4d8502Sjsg 	UPDATE_TYPE_FULL, /* may need to shuffle resources */
369fb4d8502Sjsg };
370fb4d8502Sjsg 
371fb4d8502Sjsg /* Forward declaration*/
372fb4d8502Sjsg struct dc;
373fb4d8502Sjsg struct dc_plane_state;
374fb4d8502Sjsg struct dc_state;
375fb4d8502Sjsg 
376fb4d8502Sjsg 
377fb4d8502Sjsg struct dc_cap_funcs {
378fb4d8502Sjsg 	bool (*get_dcc_compression_cap)(const struct dc *dc,
379fb4d8502Sjsg 			const struct dc_dcc_surface_param *input,
380fb4d8502Sjsg 			struct dc_surface_dcc_cap *output);
381fb4d8502Sjsg };
382fb4d8502Sjsg 
383fb4d8502Sjsg struct link_training_settings;
384fb4d8502Sjsg 
3851bb76ff1Sjsg union allow_lttpr_non_transparent_mode {
3861bb76ff1Sjsg 	struct {
3871bb76ff1Sjsg 		bool DP1_4A : 1;
3881bb76ff1Sjsg 		bool DP2_0 : 1;
3891bb76ff1Sjsg 	} bits;
3901bb76ff1Sjsg 	unsigned char raw;
3911bb76ff1Sjsg };
392fb4d8502Sjsg 
393fb4d8502Sjsg /* Structure to hold configuration flags set by dm at dc creation. */
394fb4d8502Sjsg struct dc_config {
395fb4d8502Sjsg 	bool gpu_vm_support;
396fb4d8502Sjsg 	bool disable_disp_pll_sharing;
397c349dbc7Sjsg 	bool fbc_support;
398c349dbc7Sjsg 	bool disable_fractional_pwm;
399c349dbc7Sjsg 	bool allow_seamless_boot_optimization;
4001bb76ff1Sjsg 	bool seamless_boot_edp_requested;
401c349dbc7Sjsg 	bool edp_not_connected;
4025ca02815Sjsg 	bool edp_no_power_sequencing;
403c349dbc7Sjsg 	bool force_enum_edp;
404c349dbc7Sjsg 	bool forced_clocks;
4051bb76ff1Sjsg 	union allow_lttpr_non_transparent_mode allow_lttpr_non_transparent_mode;
406c349dbc7Sjsg 	bool multi_mon_pp_mclk_switch;
407ad8b1aafSjsg 	bool disable_dmcu;
408ad8b1aafSjsg 	bool enable_4to1MPC;
4091bb76ff1Sjsg 	bool enable_windowed_mpo_odm;
410f005ef32Sjsg 	bool forceHBR2CP2520; // Used for switching between test patterns TPS4 and CP2520
4111bb76ff1Sjsg 	uint32_t allow_edp_hotplug_detection;
412ad8b1aafSjsg 	bool clamp_min_dcfclk;
4135ca02815Sjsg 	uint64_t vblank_alignment_dto_params;
4145ca02815Sjsg 	uint8_t  vblank_alignment_max_frame_time_diff;
4155ca02815Sjsg 	bool is_asymmetric_memory;
4165ca02815Sjsg 	bool is_single_rank_dimm;
4171bb76ff1Sjsg 	bool is_vmin_only_asic;
4181bb76ff1Sjsg 	bool use_pipe_ctx_sync_logic;
4191bb76ff1Sjsg 	bool ignore_dpref_ss;
4201bb76ff1Sjsg 	bool enable_mipi_converter_optimization;
4211bb76ff1Sjsg 	bool use_default_clock_table;
4221bb76ff1Sjsg 	bool force_bios_enable_lttpr;
4231bb76ff1Sjsg 	uint8_t force_bios_fixed_vs;
424f005ef32Sjsg 	int sdpif_request_limit_words_per_umc;
425f005ef32Sjsg 	bool use_old_fixed_vs_sequence;
426f005ef32Sjsg 	bool dc_mode_clk_limit_support;
427fb4d8502Sjsg };
428fb4d8502Sjsg 
429fb4d8502Sjsg enum visual_confirm {
430fb4d8502Sjsg 	VISUAL_CONFIRM_DISABLE = 0,
431fb4d8502Sjsg 	VISUAL_CONFIRM_SURFACE = 1,
432fb4d8502Sjsg 	VISUAL_CONFIRM_HDR = 2,
433c349dbc7Sjsg 	VISUAL_CONFIRM_MPCTREE = 4,
434ad8b1aafSjsg 	VISUAL_CONFIRM_PSR = 5,
4351bb76ff1Sjsg 	VISUAL_CONFIRM_SWAPCHAIN = 6,
4361bb76ff1Sjsg 	VISUAL_CONFIRM_FAMS = 7,
4375ca02815Sjsg 	VISUAL_CONFIRM_SWIZZLE = 9,
438f005ef32Sjsg 	VISUAL_CONFIRM_REPLAY = 12,
4391bb76ff1Sjsg 	VISUAL_CONFIRM_SUBVP = 14,
440f005ef32Sjsg 	VISUAL_CONFIRM_MCLK_SWITCH = 16,
4411bb76ff1Sjsg };
4421bb76ff1Sjsg 
4431bb76ff1Sjsg enum dc_psr_power_opts {
4441bb76ff1Sjsg 	psr_power_opt_invalid = 0x0,
4451bb76ff1Sjsg 	psr_power_opt_smu_opt_static_screen = 0x1,
4461bb76ff1Sjsg 	psr_power_opt_z10_static_screen = 0x10,
4471bb76ff1Sjsg 	psr_power_opt_ds_disable_allow = 0x100,
4481bb76ff1Sjsg };
4491bb76ff1Sjsg 
4501bb76ff1Sjsg enum dml_hostvm_override_opts {
4511bb76ff1Sjsg 	DML_HOSTVM_NO_OVERRIDE = 0x0,
4521bb76ff1Sjsg 	DML_HOSTVM_OVERRIDE_FALSE = 0x1,
4531bb76ff1Sjsg 	DML_HOSTVM_OVERRIDE_TRUE = 0x2,
454fb4d8502Sjsg };
455fb4d8502Sjsg 
456fb4d8502Sjsg enum dcc_option {
457fb4d8502Sjsg 	DCC_ENABLE = 0,
458fb4d8502Sjsg 	DCC_DISABLE = 1,
459fb4d8502Sjsg 	DCC_HALF_REQ_DISALBE = 2,
460fb4d8502Sjsg };
461fb4d8502Sjsg 
4621bb76ff1Sjsg /**
4631bb76ff1Sjsg  * enum pipe_split_policy - Pipe split strategy supported by DCN
4641bb76ff1Sjsg  *
4651bb76ff1Sjsg  * This enum is used to define the pipe split policy supported by DCN. By
4661bb76ff1Sjsg  * default, DC favors MPC_SPLIT_DYNAMIC.
4671bb76ff1Sjsg  */
468fb4d8502Sjsg enum pipe_split_policy {
4691bb76ff1Sjsg 	/**
4701bb76ff1Sjsg 	 * @MPC_SPLIT_DYNAMIC: DC will automatically decide how to split the
4711bb76ff1Sjsg 	 * pipe in order to bring the best trade-off between performance and
4721bb76ff1Sjsg 	 * power consumption. This is the recommended option.
4731bb76ff1Sjsg 	 */
474fb4d8502Sjsg 	MPC_SPLIT_DYNAMIC = 0,
4751bb76ff1Sjsg 
4761bb76ff1Sjsg 	/**
477f005ef32Sjsg 	 * @MPC_SPLIT_AVOID: Avoid pipe split, which means that DC will not
4781bb76ff1Sjsg 	 * try any sort of split optimization.
4791bb76ff1Sjsg 	 */
480fb4d8502Sjsg 	MPC_SPLIT_AVOID = 1,
4811bb76ff1Sjsg 
4821bb76ff1Sjsg 	/**
483f005ef32Sjsg 	 * @MPC_SPLIT_AVOID_MULT_DISP: With this option, DC will only try to
484f005ef32Sjsg 	 * optimize the pipe utilization when using a single display; if the
485f005ef32Sjsg 	 * user connects to a second display, DC will avoid pipe split.
4861bb76ff1Sjsg 	 */
487fb4d8502Sjsg 	MPC_SPLIT_AVOID_MULT_DISP = 2,
488fb4d8502Sjsg };
489fb4d8502Sjsg 
490fb4d8502Sjsg enum wm_report_mode {
491fb4d8502Sjsg 	WM_REPORT_DEFAULT = 0,
492fb4d8502Sjsg 	WM_REPORT_OVERRIDE = 1,
493fb4d8502Sjsg };
494c349dbc7Sjsg enum dtm_pstate{
495c349dbc7Sjsg 	dtm_level_p0 = 0,/*highest voltage*/
496c349dbc7Sjsg 	dtm_level_p1,
497c349dbc7Sjsg 	dtm_level_p2,
498c349dbc7Sjsg 	dtm_level_p3,
499c349dbc7Sjsg 	dtm_level_p4,/*when active_display_count = 0*/
500c349dbc7Sjsg };
501c349dbc7Sjsg 
502c349dbc7Sjsg enum dcn_pwr_state {
503c349dbc7Sjsg 	DCN_PWR_STATE_UNKNOWN = -1,
504c349dbc7Sjsg 	DCN_PWR_STATE_MISSION_MODE = 0,
505c349dbc7Sjsg 	DCN_PWR_STATE_LOW_POWER = 3,
506c349dbc7Sjsg };
507fb4d8502Sjsg 
5085ca02815Sjsg enum dcn_zstate_support_state {
5095ca02815Sjsg 	DCN_ZSTATE_SUPPORT_UNKNOWN,
5105ca02815Sjsg 	DCN_ZSTATE_SUPPORT_ALLOW,
511a6b89d9dSjsg 	DCN_ZSTATE_SUPPORT_ALLOW_Z8_ONLY,
512a6b89d9dSjsg 	DCN_ZSTATE_SUPPORT_ALLOW_Z8_Z10_ONLY,
5131bb76ff1Sjsg 	DCN_ZSTATE_SUPPORT_ALLOW_Z10_ONLY,
5145ca02815Sjsg 	DCN_ZSTATE_SUPPORT_DISALLOW,
5155ca02815Sjsg };
5168352e164Sjsg 
517f005ef32Sjsg /*
518f005ef32Sjsg  * struct dc_clocks - DC pipe clocks
5198352e164Sjsg  *
5208352e164Sjsg  * For any clocks that may differ per pipe only the max is stored in this
5218352e164Sjsg  * structure
522fb4d8502Sjsg  */
523fb4d8502Sjsg struct dc_clocks {
524fb4d8502Sjsg 	int dispclk_khz;
5255ca02815Sjsg 	int actual_dispclk_khz;
526fb4d8502Sjsg 	int dppclk_khz;
5275ca02815Sjsg 	int actual_dppclk_khz;
528ad8b1aafSjsg 	int disp_dpp_voltage_level_khz;
529fb4d8502Sjsg 	int dcfclk_khz;
530fb4d8502Sjsg 	int socclk_khz;
531fb4d8502Sjsg 	int dcfclk_deep_sleep_khz;
532fb4d8502Sjsg 	int fclk_khz;
533fb4d8502Sjsg 	int phyclk_khz;
534c349dbc7Sjsg 	int dramclk_khz;
535c349dbc7Sjsg 	bool p_state_change_support;
5365ca02815Sjsg 	enum dcn_zstate_support_state zstate_support;
5375ca02815Sjsg 	bool dtbclk_en;
5381bb76ff1Sjsg 	int ref_dtbclk_khz;
5391bb76ff1Sjsg 	bool fclk_p_state_change_support;
540c349dbc7Sjsg 	enum dcn_pwr_state pwr_state;
541c349dbc7Sjsg 	/*
542c349dbc7Sjsg 	 * Elements below are not compared for the purposes of
543c349dbc7Sjsg 	 * optimization required
544c349dbc7Sjsg 	 */
545c349dbc7Sjsg 	bool prev_p_state_change_support;
5461bb76ff1Sjsg 	bool fclk_prev_p_state_change_support;
5471bb76ff1Sjsg 	int num_ways;
5488352e164Sjsg 
549f005ef32Sjsg 	/*
5508352e164Sjsg 	 * @fw_based_mclk_switching
5518352e164Sjsg 	 *
5528352e164Sjsg 	 * DC has a mechanism that leverage the variable refresh rate to switch
5538352e164Sjsg 	 * memory clock in cases that we have a large latency to achieve the
5548352e164Sjsg 	 * memory clock change and a short vblank window. DC has some
5558352e164Sjsg 	 * requirements to enable this feature, and this field describes if the
5568352e164Sjsg 	 * system support or not such a feature.
5578352e164Sjsg 	 */
5581bb76ff1Sjsg 	bool fw_based_mclk_switching;
5591bb76ff1Sjsg 	bool fw_based_mclk_switching_shut_down;
5601bb76ff1Sjsg 	int prev_num_ways;
561c349dbc7Sjsg 	enum dtm_pstate dtm_level;
562c349dbc7Sjsg 	int max_supported_dppclk_khz;
563c349dbc7Sjsg 	int max_supported_dispclk_khz;
564c349dbc7Sjsg 	int bw_dppclk_khz; /*a copy of dppclk_khz*/
565c349dbc7Sjsg 	int bw_dispclk_khz;
566fb4d8502Sjsg };
567fb4d8502Sjsg 
568c349dbc7Sjsg struct dc_bw_validation_profile {
569c349dbc7Sjsg 	bool enable;
570c349dbc7Sjsg 
571c349dbc7Sjsg 	unsigned long long total_ticks;
572c349dbc7Sjsg 	unsigned long long voltage_level_ticks;
573c349dbc7Sjsg 	unsigned long long watermark_ticks;
574c349dbc7Sjsg 	unsigned long long rq_dlg_ticks;
575c349dbc7Sjsg 
576c349dbc7Sjsg 	unsigned long long total_count;
577c349dbc7Sjsg 	unsigned long long skip_fast_count;
578c349dbc7Sjsg 	unsigned long long skip_pass_count;
579c349dbc7Sjsg 	unsigned long long skip_fail_count;
580c349dbc7Sjsg };
581c349dbc7Sjsg 
582c349dbc7Sjsg #define BW_VAL_TRACE_SETUP() \
583c349dbc7Sjsg 		unsigned long long end_tick = 0; \
584c349dbc7Sjsg 		unsigned long long voltage_level_tick = 0; \
585c349dbc7Sjsg 		unsigned long long watermark_tick = 0; \
586c349dbc7Sjsg 		unsigned long long start_tick = dc->debug.bw_val_profile.enable ? \
587c349dbc7Sjsg 				dm_get_timestamp(dc->ctx) : 0
588c349dbc7Sjsg 
589c349dbc7Sjsg #define BW_VAL_TRACE_COUNT() \
590c349dbc7Sjsg 		if (dc->debug.bw_val_profile.enable) \
591c349dbc7Sjsg 			dc->debug.bw_val_profile.total_count++
592c349dbc7Sjsg 
593c349dbc7Sjsg #define BW_VAL_TRACE_SKIP(status) \
594c349dbc7Sjsg 		if (dc->debug.bw_val_profile.enable) { \
595c349dbc7Sjsg 			if (!voltage_level_tick) \
596c349dbc7Sjsg 				voltage_level_tick = dm_get_timestamp(dc->ctx); \
597c349dbc7Sjsg 			dc->debug.bw_val_profile.skip_ ## status ## _count++; \
598c349dbc7Sjsg 		}
599c349dbc7Sjsg 
600c349dbc7Sjsg #define BW_VAL_TRACE_END_VOLTAGE_LEVEL() \
601c349dbc7Sjsg 		if (dc->debug.bw_val_profile.enable) \
602c349dbc7Sjsg 			voltage_level_tick = dm_get_timestamp(dc->ctx)
603c349dbc7Sjsg 
604c349dbc7Sjsg #define BW_VAL_TRACE_END_WATERMARKS() \
605c349dbc7Sjsg 		if (dc->debug.bw_val_profile.enable) \
606c349dbc7Sjsg 			watermark_tick = dm_get_timestamp(dc->ctx)
607c349dbc7Sjsg 
608c349dbc7Sjsg #define BW_VAL_TRACE_FINISH() \
609c349dbc7Sjsg 		if (dc->debug.bw_val_profile.enable) { \
610c349dbc7Sjsg 			end_tick = dm_get_timestamp(dc->ctx); \
611c349dbc7Sjsg 			dc->debug.bw_val_profile.total_ticks += end_tick - start_tick; \
612c349dbc7Sjsg 			dc->debug.bw_val_profile.voltage_level_ticks += voltage_level_tick - start_tick; \
613c349dbc7Sjsg 			if (watermark_tick) { \
614c349dbc7Sjsg 				dc->debug.bw_val_profile.watermark_ticks += watermark_tick - voltage_level_tick; \
615c349dbc7Sjsg 				dc->debug.bw_val_profile.rq_dlg_ticks += end_tick - watermark_tick; \
616c349dbc7Sjsg 			} \
617c349dbc7Sjsg 		}
618c349dbc7Sjsg 
6195ca02815Sjsg union mem_low_power_enable_options {
6205ca02815Sjsg 	struct {
6215ca02815Sjsg 		bool vga: 1;
6225ca02815Sjsg 		bool i2c: 1;
6235ca02815Sjsg 		bool dmcu: 1;
6245ca02815Sjsg 		bool dscl: 1;
6255ca02815Sjsg 		bool cm: 1;
6265ca02815Sjsg 		bool mpc: 1;
6275ca02815Sjsg 		bool optc: 1;
6281bb76ff1Sjsg 		bool vpg: 1;
6291bb76ff1Sjsg 		bool afmt: 1;
6305ca02815Sjsg 	} bits;
6315ca02815Sjsg 	uint32_t u32All;
632fb4d8502Sjsg };
633fb4d8502Sjsg 
6341bb76ff1Sjsg union root_clock_optimization_options {
6351bb76ff1Sjsg 	struct {
6361bb76ff1Sjsg 		bool dpp: 1;
6371bb76ff1Sjsg 		bool dsc: 1;
6381bb76ff1Sjsg 		bool hdmistream: 1;
6391bb76ff1Sjsg 		bool hdmichar: 1;
6401bb76ff1Sjsg 		bool dpstream: 1;
6411bb76ff1Sjsg 		bool symclk32_se: 1;
6421bb76ff1Sjsg 		bool symclk32_le: 1;
6431bb76ff1Sjsg 		bool symclk_fe: 1;
6441bb76ff1Sjsg 		bool physymclk: 1;
6451bb76ff1Sjsg 		bool dpiasymclk: 1;
6461bb76ff1Sjsg 		uint32_t reserved: 22;
6471bb76ff1Sjsg 	} bits;
6481bb76ff1Sjsg 	uint32_t u32All;
6491bb76ff1Sjsg };
6501bb76ff1Sjsg 
6511bb76ff1Sjsg union dpia_debug_options {
6521bb76ff1Sjsg 	struct {
6531bb76ff1Sjsg 		uint32_t disable_dpia:1; /* bit 0 */
6541bb76ff1Sjsg 		uint32_t force_non_lttpr:1; /* bit 1 */
6551bb76ff1Sjsg 		uint32_t extend_aux_rd_interval:1; /* bit 2 */
6561bb76ff1Sjsg 		uint32_t disable_mst_dsc_work_around:1; /* bit 3 */
6571bb76ff1Sjsg 		uint32_t enable_force_tbt3_work_around:1; /* bit 4 */
6581bb76ff1Sjsg 		uint32_t reserved:27;
6591bb76ff1Sjsg 	} bits;
6601bb76ff1Sjsg 	uint32_t raw;
6611bb76ff1Sjsg };
6621bb76ff1Sjsg 
6631bb76ff1Sjsg /* AUX wake work around options
6641bb76ff1Sjsg  * 0: enable/disable work around
6651bb76ff1Sjsg  * 1: use default timeout LINK_AUX_WAKE_TIMEOUT_MS
6661bb76ff1Sjsg  * 15-2: reserved
6671bb76ff1Sjsg  * 31-16: timeout in ms
6681bb76ff1Sjsg  */
6691bb76ff1Sjsg union aux_wake_wa_options {
6701bb76ff1Sjsg 	struct {
6711bb76ff1Sjsg 		uint32_t enable_wa : 1;
6721bb76ff1Sjsg 		uint32_t use_default_timeout : 1;
6731bb76ff1Sjsg 		uint32_t rsvd: 14;
6741bb76ff1Sjsg 		uint32_t timeout_ms : 16;
6751bb76ff1Sjsg 	} bits;
6761bb76ff1Sjsg 	uint32_t raw;
6771bb76ff1Sjsg };
6781bb76ff1Sjsg 
679fb4d8502Sjsg struct dc_debug_data {
680fb4d8502Sjsg 	uint32_t ltFailCount;
681fb4d8502Sjsg 	uint32_t i2cErrorCount;
682fb4d8502Sjsg 	uint32_t auxErrorCount;
683fb4d8502Sjsg };
684fb4d8502Sjsg 
685c349dbc7Sjsg struct dc_phy_addr_space_config {
686c349dbc7Sjsg 	struct {
687c349dbc7Sjsg 		uint64_t start_addr;
688c349dbc7Sjsg 		uint64_t end_addr;
689c349dbc7Sjsg 		uint64_t fb_top;
690c349dbc7Sjsg 		uint64_t fb_offset;
691c349dbc7Sjsg 		uint64_t fb_base;
692c349dbc7Sjsg 		uint64_t agp_top;
693c349dbc7Sjsg 		uint64_t agp_bot;
694c349dbc7Sjsg 		uint64_t agp_base;
695c349dbc7Sjsg 	} system_aperture;
696c349dbc7Sjsg 
697c349dbc7Sjsg 	struct {
698c349dbc7Sjsg 		uint64_t page_table_start_addr;
699c349dbc7Sjsg 		uint64_t page_table_end_addr;
700c349dbc7Sjsg 		uint64_t page_table_base_addr;
7015ca02815Sjsg 		bool base_addr_is_mc_addr;
702c349dbc7Sjsg 	} gart_config;
703c349dbc7Sjsg 
704c349dbc7Sjsg 	bool valid;
705c349dbc7Sjsg 	bool is_hvm_enabled;
706c349dbc7Sjsg 	uint64_t page_table_default_page_addr;
707c349dbc7Sjsg };
708c349dbc7Sjsg 
709c349dbc7Sjsg struct dc_virtual_addr_space_config {
710c349dbc7Sjsg 	uint64_t	page_table_base_addr;
711c349dbc7Sjsg 	uint64_t	page_table_start_addr;
712c349dbc7Sjsg 	uint64_t	page_table_end_addr;
713c349dbc7Sjsg 	uint32_t	page_table_block_size_in_bytes;
714c349dbc7Sjsg 	uint8_t		page_table_depth; // 1 = 1 level, 2 = 2 level, etc.  0 = invalid
715c349dbc7Sjsg };
716c349dbc7Sjsg 
717c349dbc7Sjsg struct dc_bounding_box_overrides {
718c349dbc7Sjsg 	int sr_exit_time_ns;
719c349dbc7Sjsg 	int sr_enter_plus_exit_time_ns;
720f005ef32Sjsg 	int sr_exit_z8_time_ns;
721f005ef32Sjsg 	int sr_enter_plus_exit_z8_time_ns;
722c349dbc7Sjsg 	int urgent_latency_ns;
723c349dbc7Sjsg 	int percent_of_ideal_drambw;
724c349dbc7Sjsg 	int dram_clock_change_latency_ns;
725ad8b1aafSjsg 	int dummy_clock_change_latency_ns;
7261bb76ff1Sjsg 	int fclk_clock_change_latency_ns;
727c349dbc7Sjsg 	/* This forces a hard min on the DCFCLK we use
728c349dbc7Sjsg 	 * for DML.  Unlike the debug option for forcing
729c349dbc7Sjsg 	 * DCFCLK, this override affects watermark calculations
730c349dbc7Sjsg 	 */
731c349dbc7Sjsg 	int min_dcfclk_mhz;
732c349dbc7Sjsg };
733fb4d8502Sjsg 
734fb4d8502Sjsg struct dc_state;
735fb4d8502Sjsg struct resource_pool;
736fb4d8502Sjsg struct dce_hwseq;
737f005ef32Sjsg struct link_service;
7385ca02815Sjsg 
739f005ef32Sjsg /*
7401bb76ff1Sjsg  * struct dc_debug_options - DC debug struct
7411bb76ff1Sjsg  *
7421bb76ff1Sjsg  * This struct provides a simple mechanism for developers to change some
7431bb76ff1Sjsg  * configurations, enable/disable features, and activate extra debug options.
7441bb76ff1Sjsg  * This can be very handy to narrow down whether some specific feature is
7451bb76ff1Sjsg  * causing an issue or not.
7461bb76ff1Sjsg  */
7475ca02815Sjsg struct dc_debug_options {
7485ca02815Sjsg 	bool native422_support;
7495ca02815Sjsg 	bool disable_dsc;
7505ca02815Sjsg 	enum visual_confirm visual_confirm;
7511bb76ff1Sjsg 	int visual_confirm_rect_height;
7521bb76ff1Sjsg 
7535ca02815Sjsg 	bool sanity_checks;
7545ca02815Sjsg 	bool max_disp_clk;
7555ca02815Sjsg 	bool surface_trace;
7565ca02815Sjsg 	bool timing_trace;
7575ca02815Sjsg 	bool clock_trace;
7585ca02815Sjsg 	bool validation_trace;
7595ca02815Sjsg 	bool bandwidth_calcs_trace;
7605ca02815Sjsg 	int max_downscale_src_width;
7615ca02815Sjsg 
7625ca02815Sjsg 	/* stutter efficiency related */
7635ca02815Sjsg 	bool disable_stutter;
7645ca02815Sjsg 	bool use_max_lb;
7655ca02815Sjsg 	enum dcc_option disable_dcc;
7661bb76ff1Sjsg 
767f005ef32Sjsg 	/*
7681bb76ff1Sjsg 	 * @pipe_split_policy: Define which pipe split policy is used by the
7691bb76ff1Sjsg 	 * display core.
7701bb76ff1Sjsg 	 */
7715ca02815Sjsg 	enum pipe_split_policy pipe_split_policy;
7725ca02815Sjsg 	bool force_single_disp_pipe_split;
7735ca02815Sjsg 	bool voltage_align_fclk;
7745ca02815Sjsg 	bool disable_min_fclk;
7755ca02815Sjsg 
7765ca02815Sjsg 	bool disable_dfs_bypass;
7775ca02815Sjsg 	bool disable_dpp_power_gate;
7785ca02815Sjsg 	bool disable_hubp_power_gate;
7795ca02815Sjsg 	bool disable_dsc_power_gate;
7805ca02815Sjsg 	int dsc_min_slice_height_override;
7815ca02815Sjsg 	int dsc_bpp_increment_div;
7825ca02815Sjsg 	bool disable_pplib_wm_range;
7835ca02815Sjsg 	enum wm_report_mode pplib_wm_report_mode;
7845ca02815Sjsg 	unsigned int min_disp_clk_khz;
7855ca02815Sjsg 	unsigned int min_dpp_clk_khz;
7861bb76ff1Sjsg 	unsigned int min_dram_clk_khz;
7875ca02815Sjsg 	int sr_exit_time_dpm0_ns;
7885ca02815Sjsg 	int sr_enter_plus_exit_time_dpm0_ns;
7895ca02815Sjsg 	int sr_exit_time_ns;
7905ca02815Sjsg 	int sr_enter_plus_exit_time_ns;
791f005ef32Sjsg 	int sr_exit_z8_time_ns;
792f005ef32Sjsg 	int sr_enter_plus_exit_z8_time_ns;
7935ca02815Sjsg 	int urgent_latency_ns;
7945ca02815Sjsg 	uint32_t underflow_assert_delay_us;
7955ca02815Sjsg 	int percent_of_ideal_drambw;
7965ca02815Sjsg 	int dram_clock_change_latency_ns;
7975ca02815Sjsg 	bool optimized_watermark;
7985ca02815Sjsg 	int always_scale;
7995ca02815Sjsg 	bool disable_pplib_clock_request;
8005ca02815Sjsg 	bool disable_clock_gate;
8015ca02815Sjsg 	bool disable_mem_low_power;
8025ca02815Sjsg 	bool pstate_enabled;
8035ca02815Sjsg 	bool disable_dmcu;
8045ca02815Sjsg 	bool force_abm_enable;
8055ca02815Sjsg 	bool disable_stereo_support;
8065ca02815Sjsg 	bool vsr_support;
8075ca02815Sjsg 	bool performance_trace;
8085ca02815Sjsg 	bool az_endpoint_mute_only;
8095ca02815Sjsg 	bool always_use_regamma;
8105ca02815Sjsg 	bool recovery_enabled;
8115ca02815Sjsg 	bool avoid_vbios_exec_table;
8125ca02815Sjsg 	bool scl_reset_length10;
8135ca02815Sjsg 	bool hdmi20_disable;
8145ca02815Sjsg 	bool skip_detection_link_training;
8155ca02815Sjsg 	uint32_t edid_read_retry_times;
8165ca02815Sjsg 	unsigned int force_odm_combine; //bit vector based on otg inst
8171bb76ff1Sjsg 	unsigned int seamless_boot_odm_combine;
8185ca02815Sjsg 	unsigned int force_odm_combine_4to1; //bit vector based on otg inst
81911b6e7f9Sjsg 	int minimum_z8_residency_time;
8205ca02815Sjsg 	bool disable_z9_mpc;
8215ca02815Sjsg 	unsigned int force_fclk_khz;
8225ca02815Sjsg 	bool enable_tri_buf;
8235ca02815Sjsg 	bool dmub_offload_enabled;
8245ca02815Sjsg 	bool dmcub_emulation;
8255ca02815Sjsg 	bool disable_idle_power_optimizations;
8265ca02815Sjsg 	unsigned int mall_size_override;
8275ca02815Sjsg 	unsigned int mall_additional_timer_percent;
8285ca02815Sjsg 	bool mall_error_as_fatal;
8295ca02815Sjsg 	bool dmub_command_table; /* for testing only */
8305ca02815Sjsg 	struct dc_bw_validation_profile bw_val_profile;
8315ca02815Sjsg 	bool disable_fec;
8325ca02815Sjsg 	bool disable_48mhz_pwrdwn;
8335ca02815Sjsg 	/* This forces a hard min on the DCFCLK requested to SMU/PP
8345ca02815Sjsg 	 * watermarks are not affected.
8355ca02815Sjsg 	 */
8365ca02815Sjsg 	unsigned int force_min_dcfclk_mhz;
8375ca02815Sjsg 	int dwb_fi_phase;
8385ca02815Sjsg 	bool disable_timing_sync;
8395ca02815Sjsg 	bool cm_in_bypass;
8405ca02815Sjsg 	int force_clock_mode;/*every mode change.*/
8415ca02815Sjsg 
8425ca02815Sjsg 	bool disable_dram_clock_change_vactive_support;
8435ca02815Sjsg 	bool validate_dml_output;
8445ca02815Sjsg 	bool enable_dmcub_surface_flip;
8455ca02815Sjsg 	bool usbc_combo_phy_reset_wa;
8465ca02815Sjsg 	bool enable_dram_clock_change_one_display_vactive;
8471bb76ff1Sjsg 	/* TODO - remove once tested */
8481bb76ff1Sjsg 	bool legacy_dp2_lt;
8491bb76ff1Sjsg 	bool set_mst_en_for_sst;
8501bb76ff1Sjsg 	bool disable_uhbr;
8511bb76ff1Sjsg 	bool force_dp2_lt_fallback_method;
8521bb76ff1Sjsg 	bool ignore_cable_id;
8535ca02815Sjsg 	union mem_low_power_enable_options enable_mem_low_power;
8541bb76ff1Sjsg 	union root_clock_optimization_options root_clock_optimization;
8551bb76ff1Sjsg 	bool hpo_optimization;
8565ca02815Sjsg 	bool force_vblank_alignment;
8575ca02815Sjsg 
8585ca02815Sjsg 	/* Enable dmub aux for legacy ddc */
8595ca02815Sjsg 	bool enable_dmub_aux_for_legacy_ddc;
8601bb76ff1Sjsg 	bool disable_fams;
861f005ef32Sjsg 	bool disable_fams_gaming;
8625ca02815Sjsg 	/* FEC/PSR1 sequence enable delay in 100us */
8635ca02815Sjsg 	uint8_t fec_enable_delay_in100us;
8641bb76ff1Sjsg 	bool enable_driver_sequence_debug;
8651bb76ff1Sjsg 	enum det_size crb_alloc_policy;
8661bb76ff1Sjsg 	int crb_alloc_policy_min_disp_count;
8675ca02815Sjsg 	bool disable_z10;
8681bb76ff1Sjsg 	bool enable_z9_disable_interface;
869cc452180Sjsg 	bool psr_skip_crtc_disable;
8701bb76ff1Sjsg 	union dpia_debug_options dpia_debug;
8711bb76ff1Sjsg 	bool disable_fixed_vs_aux_timeout_wa;
872f005ef32Sjsg 	uint32_t fixed_vs_aux_delay_config_wa;
8731bb76ff1Sjsg 	bool force_disable_subvp;
8741bb76ff1Sjsg 	bool force_subvp_mclk_switch;
8751bb76ff1Sjsg 	bool allow_sw_cursor_fallback;
8761bb76ff1Sjsg 	unsigned int force_subvp_num_ways;
8771bb76ff1Sjsg 	unsigned int force_mall_ss_num_ways;
8781bb76ff1Sjsg 	bool alloc_extra_way_for_cursor;
879f005ef32Sjsg 	uint32_t subvp_extra_lines;
8801bb76ff1Sjsg 	bool force_usr_allow;
8811bb76ff1Sjsg 	/* uses value at boot and disables switch */
8821bb76ff1Sjsg 	bool disable_dtb_ref_clk_switch;
8831bb76ff1Sjsg 	bool extended_blank_optimization;
8841bb76ff1Sjsg 	union aux_wake_wa_options aux_wake_wa;
8851bb76ff1Sjsg 	uint32_t mst_start_top_delay;
8861bb76ff1Sjsg 	uint8_t psr_power_use_phy_fsm;
8871bb76ff1Sjsg 	enum dml_hostvm_override_opts dml_hostvm_override;
8881bb76ff1Sjsg 	bool dml_disallow_alternate_prefetch_modes;
8891bb76ff1Sjsg 	bool use_legacy_soc_bb_mechanism;
8901bb76ff1Sjsg 	bool exit_idle_opt_for_cursor_updates;
8911bb76ff1Sjsg 	bool enable_single_display_2to1_odm_policy;
8921bb76ff1Sjsg 	bool enable_double_buffered_dsc_pg_support;
8931bb76ff1Sjsg 	bool enable_dp_dig_pixel_rate_div_policy;
8941bb76ff1Sjsg 	enum lttpr_mode lttpr_mode_override;
8951bb76ff1Sjsg 	unsigned int dsc_delay_factor_wa_x1000;
8961bb76ff1Sjsg 	unsigned int min_prefetch_in_strobe_ns;
897f005ef32Sjsg 	bool disable_unbounded_requesting;
898f005ef32Sjsg 	bool dig_fifo_off_in_blank;
899f005ef32Sjsg 	bool temp_mst_deallocation_sequence;
900f005ef32Sjsg 	bool override_dispclk_programming;
901f005ef32Sjsg 	bool disable_fpo_optimizations;
902f005ef32Sjsg 	bool support_eDP1_5;
903f005ef32Sjsg 	uint32_t fpo_vactive_margin_us;
904f005ef32Sjsg 	bool disable_fpo_vactive;
905f005ef32Sjsg 	bool disable_boot_optimizations;
906f005ef32Sjsg 	bool override_odm_optimization;
907f005ef32Sjsg 	bool minimize_dispclk_using_odm;
908f005ef32Sjsg 	bool disable_subvp_high_refresh;
909f005ef32Sjsg 	bool disable_dp_plus_plus_wa;
910f005ef32Sjsg 	uint32_t fpo_vactive_min_active_margin_us;
911f005ef32Sjsg 	uint32_t fpo_vactive_max_blank_us;
912f005ef32Sjsg 	bool enable_legacy_fast_update;
913f005ef32Sjsg 	bool disable_dc_mode_overwrite;
914f005ef32Sjsg 	bool replay_skip_crtc_disabled;
9155ca02815Sjsg };
9165ca02815Sjsg 
917c349dbc7Sjsg struct gpu_info_soc_bounding_box_v1_0;
918f005ef32Sjsg 
919f005ef32Sjsg /* Generic structure that can be used to query properties of DC. More fields
920f005ef32Sjsg  * can be added as required.
921f005ef32Sjsg  */
922f005ef32Sjsg struct dc_current_properties {
923f005ef32Sjsg 	unsigned int cursor_size_limit;
924f005ef32Sjsg };
925f005ef32Sjsg 
926fb4d8502Sjsg struct dc {
9275ca02815Sjsg 	struct dc_debug_options debug;
928fb4d8502Sjsg 	struct dc_versions versions;
929fb4d8502Sjsg 	struct dc_caps caps;
930fb4d8502Sjsg 	struct dc_cap_funcs cap_funcs;
931fb4d8502Sjsg 	struct dc_config config;
932c349dbc7Sjsg 	struct dc_bounding_box_overrides bb_overrides;
933c349dbc7Sjsg 	struct dc_bug_wa work_arounds;
934fb4d8502Sjsg 	struct dc_context *ctx;
935c349dbc7Sjsg 	struct dc_phy_addr_space_config vm_pa_config;
936fb4d8502Sjsg 
937fb4d8502Sjsg 	uint8_t link_count;
938fb4d8502Sjsg 	struct dc_link *links[MAX_PIPES * 2];
939f005ef32Sjsg 	struct link_service *link_srv;
940fb4d8502Sjsg 
941fb4d8502Sjsg 	struct dc_state *current_state;
942fb4d8502Sjsg 	struct resource_pool *res_pool;
943fb4d8502Sjsg 
944c349dbc7Sjsg 	struct clk_mgr *clk_mgr;
945c349dbc7Sjsg 
946fb4d8502Sjsg 	/* Display Engine Clock levels */
947fb4d8502Sjsg 	struct dm_pp_clock_levels sclk_lvls;
948fb4d8502Sjsg 
949fb4d8502Sjsg 	/* Inputs into BW and WM calculations. */
950fb4d8502Sjsg 	struct bw_calcs_dceip *bw_dceip;
951fb4d8502Sjsg 	struct bw_calcs_vbios *bw_vbios;
952fb4d8502Sjsg 	struct dcn_soc_bounding_box *dcn_soc;
953fb4d8502Sjsg 	struct dcn_ip_params *dcn_ip;
954fb4d8502Sjsg 	struct display_mode_lib dml;
955fb4d8502Sjsg 
956fb4d8502Sjsg 	/* HW functions */
957fb4d8502Sjsg 	struct hw_sequencer_funcs hwss;
958fb4d8502Sjsg 	struct dce_hwseq *hwseq;
959fb4d8502Sjsg 
960c349dbc7Sjsg 	/* Require to optimize clocks and bandwidth for added/removed planes */
961fb4d8502Sjsg 	bool optimized_required;
962c349dbc7Sjsg 	bool wm_optimized_required;
963ad8b1aafSjsg 	bool idle_optimizations_allowed;
9641bb76ff1Sjsg 	bool enable_c20_dtm_b0;
965fb4d8502Sjsg 
966c349dbc7Sjsg 	/* Require to maintain clocks and bandwidth for UEFI enabled HW */
967fb4d8502Sjsg 
968fb4d8502Sjsg 	/* FBC compressor */
969fb4d8502Sjsg 	struct compressor *fbc_compressor;
970fb4d8502Sjsg 
971fb4d8502Sjsg 	struct dc_debug_data debug_data;
972c349dbc7Sjsg 	struct dpcd_vendor_signature vendor_signature;
973c349dbc7Sjsg 
974c349dbc7Sjsg 	const char *build_id;
975c349dbc7Sjsg 	struct vm_helper *vm_helper;
9761bb76ff1Sjsg 
9771bb76ff1Sjsg 	uint32_t *dcn_reg_offsets;
9781bb76ff1Sjsg 	uint32_t *nbio_reg_offsets;
9791bb76ff1Sjsg 
9801bb76ff1Sjsg 	/* Scratch memory */
9811bb76ff1Sjsg 	struct {
9821bb76ff1Sjsg 		struct {
9831bb76ff1Sjsg 			/*
9841bb76ff1Sjsg 			 * For matching clock_limits table in driver with table
9851bb76ff1Sjsg 			 * from PMFW.
9861bb76ff1Sjsg 			 */
9871bb76ff1Sjsg 			struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
9881bb76ff1Sjsg 		} update_bw_bounding_box;
9891bb76ff1Sjsg 	} scratch;
990fb4d8502Sjsg };
991fb4d8502Sjsg 
992fb4d8502Sjsg enum frame_buffer_mode {
993fb4d8502Sjsg 	FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
994fb4d8502Sjsg 	FRAME_BUFFER_MODE_ZFB_ONLY,
995fb4d8502Sjsg 	FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
996fb4d8502Sjsg } ;
997fb4d8502Sjsg 
998fb4d8502Sjsg struct dchub_init_data {
999fb4d8502Sjsg 	int64_t zfb_phys_addr_base;
1000fb4d8502Sjsg 	int64_t zfb_mc_base_addr;
1001fb4d8502Sjsg 	uint64_t zfb_size_in_byte;
1002fb4d8502Sjsg 	enum frame_buffer_mode fb_mode;
1003fb4d8502Sjsg 	bool dchub_initialzied;
1004fb4d8502Sjsg 	bool dchub_info_valid;
1005fb4d8502Sjsg };
1006fb4d8502Sjsg 
1007fb4d8502Sjsg struct dc_init_data {
1008fb4d8502Sjsg 	struct hw_asic_id asic_id;
1009fb4d8502Sjsg 	void *driver; /* ctx */
1010fb4d8502Sjsg 	struct cgs_device *cgs_device;
1011c349dbc7Sjsg 	struct dc_bounding_box_overrides bb_overrides;
1012fb4d8502Sjsg 
1013fb4d8502Sjsg 	int num_virtual_links;
1014fb4d8502Sjsg 	/*
1015fb4d8502Sjsg 	 * If 'vbios_override' not NULL, it will be called instead
1016fb4d8502Sjsg 	 * of the real VBIOS. Intended use is Diagnostics on FPGA.
1017fb4d8502Sjsg 	 */
1018fb4d8502Sjsg 	struct dc_bios *vbios_override;
1019fb4d8502Sjsg 	enum dce_environment dce_environment;
1020fb4d8502Sjsg 
1021c349dbc7Sjsg 	struct dmub_offload_funcs *dmub_if;
1022c349dbc7Sjsg 	struct dc_reg_helper_state *dmub_offload;
1023c349dbc7Sjsg 
1024fb4d8502Sjsg 	struct dc_config flags;
1025c349dbc7Sjsg 	uint64_t log_mask;
1026c349dbc7Sjsg 
1027c349dbc7Sjsg 	struct dpcd_vendor_signature vendor_signature;
1028ad8b1aafSjsg 	bool force_smu_not_present;
10291bb76ff1Sjsg 	/*
10301bb76ff1Sjsg 	 * IP offset for run time initializaion of register addresses
10311bb76ff1Sjsg 	 *
10321bb76ff1Sjsg 	 * DCN3.5+ will fail dc_create() if these fields are null for them. They are
10331bb76ff1Sjsg 	 * applicable starting with DCN32/321 and are not used for ASICs upstreamed
10341bb76ff1Sjsg 	 * before them.
10351bb76ff1Sjsg 	 */
10361bb76ff1Sjsg 	uint32_t *dcn_reg_offsets;
10371bb76ff1Sjsg 	uint32_t *nbio_reg_offsets;
1038c349dbc7Sjsg };
1039c349dbc7Sjsg 
1040c349dbc7Sjsg struct dc_callback_init {
1041c349dbc7Sjsg 	struct cp_psp cp_psp;
1042fb4d8502Sjsg };
1043fb4d8502Sjsg 
1044fb4d8502Sjsg struct dc *dc_create(const struct dc_init_data *init_params);
1045c349dbc7Sjsg void dc_hardware_init(struct dc *dc);
1046fb4d8502Sjsg 
1047c349dbc7Sjsg int dc_get_vmid_use_vector(struct dc *dc);
1048c349dbc7Sjsg void dc_setup_vm_context(struct dc *dc, struct dc_virtual_addr_space_config *va_config, int vmid);
1049c349dbc7Sjsg /* Returns the number of vmids supported */
1050c349dbc7Sjsg int dc_setup_system_context(struct dc *dc, struct dc_phy_addr_space_config *pa_config);
1051c349dbc7Sjsg void dc_init_callbacks(struct dc *dc,
1052c349dbc7Sjsg 		const struct dc_callback_init *init_params);
1053c349dbc7Sjsg void dc_deinit_callbacks(struct dc *dc);
1054fb4d8502Sjsg void dc_destroy(struct dc **dc);
1055fb4d8502Sjsg 
1056539d1f6aSjsg /* Surface Interfaces */
1057fb4d8502Sjsg 
1058fb4d8502Sjsg enum {
1059fb4d8502Sjsg 	TRANSFER_FUNC_POINTS = 1025
1060fb4d8502Sjsg };
1061fb4d8502Sjsg 
1062fb4d8502Sjsg struct dc_hdr_static_metadata {
1063fb4d8502Sjsg 	/* display chromaticities and white point in units of 0.00001 */
1064fb4d8502Sjsg 	unsigned int chromaticity_green_x;
1065fb4d8502Sjsg 	unsigned int chromaticity_green_y;
1066fb4d8502Sjsg 	unsigned int chromaticity_blue_x;
1067fb4d8502Sjsg 	unsigned int chromaticity_blue_y;
1068fb4d8502Sjsg 	unsigned int chromaticity_red_x;
1069fb4d8502Sjsg 	unsigned int chromaticity_red_y;
1070fb4d8502Sjsg 	unsigned int chromaticity_white_point_x;
1071fb4d8502Sjsg 	unsigned int chromaticity_white_point_y;
1072fb4d8502Sjsg 
1073fb4d8502Sjsg 	uint32_t min_luminance;
1074fb4d8502Sjsg 	uint32_t max_luminance;
1075fb4d8502Sjsg 	uint32_t maximum_content_light_level;
1076fb4d8502Sjsg 	uint32_t maximum_frame_average_light_level;
1077fb4d8502Sjsg };
1078fb4d8502Sjsg 
1079fb4d8502Sjsg enum dc_transfer_func_type {
1080fb4d8502Sjsg 	TF_TYPE_PREDEFINED,
1081fb4d8502Sjsg 	TF_TYPE_DISTRIBUTED_POINTS,
1082fb4d8502Sjsg 	TF_TYPE_BYPASS,
1083fb4d8502Sjsg 	TF_TYPE_HWPWL
1084fb4d8502Sjsg };
1085fb4d8502Sjsg 
1086fb4d8502Sjsg struct dc_transfer_func_distributed_points {
1087fb4d8502Sjsg 	struct fixed31_32 red[TRANSFER_FUNC_POINTS];
1088fb4d8502Sjsg 	struct fixed31_32 green[TRANSFER_FUNC_POINTS];
1089fb4d8502Sjsg 	struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
1090fb4d8502Sjsg 
1091fb4d8502Sjsg 	uint16_t end_exponent;
1092fb4d8502Sjsg 	uint16_t x_point_at_y1_red;
1093fb4d8502Sjsg 	uint16_t x_point_at_y1_green;
1094fb4d8502Sjsg 	uint16_t x_point_at_y1_blue;
1095fb4d8502Sjsg };
1096fb4d8502Sjsg 
1097fb4d8502Sjsg enum dc_transfer_func_predefined {
1098fb4d8502Sjsg 	TRANSFER_FUNCTION_SRGB,
1099fb4d8502Sjsg 	TRANSFER_FUNCTION_BT709,
1100fb4d8502Sjsg 	TRANSFER_FUNCTION_PQ,
1101fb4d8502Sjsg 	TRANSFER_FUNCTION_LINEAR,
1102fb4d8502Sjsg 	TRANSFER_FUNCTION_UNITY,
1103fb4d8502Sjsg 	TRANSFER_FUNCTION_HLG,
1104fb4d8502Sjsg 	TRANSFER_FUNCTION_HLG12,
1105c349dbc7Sjsg 	TRANSFER_FUNCTION_GAMMA22,
1106c349dbc7Sjsg 	TRANSFER_FUNCTION_GAMMA24,
1107c349dbc7Sjsg 	TRANSFER_FUNCTION_GAMMA26
1108fb4d8502Sjsg };
1109fb4d8502Sjsg 
1110c349dbc7Sjsg 
1111fb4d8502Sjsg struct dc_transfer_func {
1112fb4d8502Sjsg 	struct kref refcount;
1113fb4d8502Sjsg 	enum dc_transfer_func_type type;
1114fb4d8502Sjsg 	enum dc_transfer_func_predefined tf;
1115fb4d8502Sjsg 	/* FP16 1.0 reference level in nits, default is 80 nits, only for PQ*/
1116fb4d8502Sjsg 	uint32_t sdr_ref_white_level;
1117fb4d8502Sjsg 	union {
1118fb4d8502Sjsg 		struct pwl_params pwl;
1119fb4d8502Sjsg 		struct dc_transfer_func_distributed_points tf_pts;
1120fb4d8502Sjsg 	};
1121fb4d8502Sjsg };
1122fb4d8502Sjsg 
1123c349dbc7Sjsg 
1124c349dbc7Sjsg union dc_3dlut_state {
1125c349dbc7Sjsg 	struct {
1126c349dbc7Sjsg 		uint32_t initialized:1;		/*if 3dlut is went through color module for initialization */
1127c349dbc7Sjsg 		uint32_t rmu_idx_valid:1;	/*if mux settings are valid*/
1128c349dbc7Sjsg 		uint32_t rmu_mux_num:3;		/*index of mux to use*/
1129c349dbc7Sjsg 		uint32_t mpc_rmu0_mux:4;	/*select mpcc on mux, one of the following : mpcc0, mpcc1, mpcc2, mpcc3*/
1130c349dbc7Sjsg 		uint32_t mpc_rmu1_mux:4;
1131c349dbc7Sjsg 		uint32_t mpc_rmu2_mux:4;
1132c349dbc7Sjsg 		uint32_t reserved:15;
1133c349dbc7Sjsg 	} bits;
1134c349dbc7Sjsg 	uint32_t raw;
1135c349dbc7Sjsg };
1136c349dbc7Sjsg 
1137c349dbc7Sjsg 
1138c349dbc7Sjsg struct dc_3dlut {
1139c349dbc7Sjsg 	struct kref refcount;
1140c349dbc7Sjsg 	struct tetrahedral_params lut_3d;
1141c349dbc7Sjsg 	struct fixed31_32 hdr_multiplier;
1142c349dbc7Sjsg 	union dc_3dlut_state state;
1143c349dbc7Sjsg };
1144fb4d8502Sjsg /*
1145fb4d8502Sjsg  * This structure is filled in by dc_surface_get_status and contains
1146fb4d8502Sjsg  * the last requested address and the currently active address so the called
1147fb4d8502Sjsg  * can determine if there are any outstanding flips
1148fb4d8502Sjsg  */
1149fb4d8502Sjsg struct dc_plane_status {
1150fb4d8502Sjsg 	struct dc_plane_address requested_address;
1151fb4d8502Sjsg 	struct dc_plane_address current_address;
1152fb4d8502Sjsg 	bool is_flip_pending;
1153fb4d8502Sjsg 	bool is_right_eye;
1154fb4d8502Sjsg };
1155fb4d8502Sjsg 
1156fb4d8502Sjsg union surface_update_flags {
1157fb4d8502Sjsg 
1158fb4d8502Sjsg 	struct {
1159c349dbc7Sjsg 		uint32_t addr_update:1;
1160fb4d8502Sjsg 		/* Medium updates */
1161fb4d8502Sjsg 		uint32_t dcc_change:1;
1162fb4d8502Sjsg 		uint32_t color_space_change:1;
1163fb4d8502Sjsg 		uint32_t horizontal_mirror_change:1;
1164fb4d8502Sjsg 		uint32_t per_pixel_alpha_change:1;
1165c349dbc7Sjsg 		uint32_t global_alpha_change:1;
1166c349dbc7Sjsg 		uint32_t hdr_mult:1;
1167fb4d8502Sjsg 		uint32_t rotation_change:1;
1168fb4d8502Sjsg 		uint32_t swizzle_change:1;
1169fb4d8502Sjsg 		uint32_t scaling_change:1;
1170fb4d8502Sjsg 		uint32_t position_change:1;
1171fb4d8502Sjsg 		uint32_t in_transfer_func_change:1;
1172fb4d8502Sjsg 		uint32_t input_csc_change:1;
1173fb4d8502Sjsg 		uint32_t coeff_reduction_change:1;
1174fb4d8502Sjsg 		uint32_t output_tf_change:1;
1175fb4d8502Sjsg 		uint32_t pixel_format_change:1;
1176c349dbc7Sjsg 		uint32_t plane_size_change:1;
1177c349dbc7Sjsg 		uint32_t gamut_remap_change:1;
1178fb4d8502Sjsg 
1179fb4d8502Sjsg 		/* Full updates */
1180fb4d8502Sjsg 		uint32_t new_plane:1;
1181fb4d8502Sjsg 		uint32_t bpp_change:1;
1182fb4d8502Sjsg 		uint32_t gamma_change:1;
1183fb4d8502Sjsg 		uint32_t bandwidth_change:1;
1184fb4d8502Sjsg 		uint32_t clock_change:1;
1185fb4d8502Sjsg 		uint32_t stereo_format_change:1;
11861bb76ff1Sjsg 		uint32_t lut_3d:1;
11871bb76ff1Sjsg 		uint32_t tmz_changed:1;
1188fb4d8502Sjsg 		uint32_t full_update:1;
1189fb4d8502Sjsg 	} bits;
1190fb4d8502Sjsg 
1191fb4d8502Sjsg 	uint32_t raw;
1192fb4d8502Sjsg };
1193fb4d8502Sjsg 
1194fb4d8502Sjsg struct dc_plane_state {
1195fb4d8502Sjsg 	struct dc_plane_address address;
1196fb4d8502Sjsg 	struct dc_plane_flip_time time;
1197c349dbc7Sjsg 	bool triplebuffer_flips;
1198fb4d8502Sjsg 	struct scaling_taps scaling_quality;
1199fb4d8502Sjsg 	struct rect src_rect;
1200fb4d8502Sjsg 	struct rect dst_rect;
1201fb4d8502Sjsg 	struct rect clip_rect;
1202fb4d8502Sjsg 
1203c349dbc7Sjsg 	struct plane_size plane_size;
1204fb4d8502Sjsg 	union dc_tiling_info tiling_info;
1205fb4d8502Sjsg 
1206fb4d8502Sjsg 	struct dc_plane_dcc_param dcc;
1207fb4d8502Sjsg 
1208fb4d8502Sjsg 	struct dc_gamma *gamma_correction;
1209fb4d8502Sjsg 	struct dc_transfer_func *in_transfer_func;
1210fb4d8502Sjsg 	struct dc_bias_and_scale *bias_and_scale;
1211fb4d8502Sjsg 	struct dc_csc_transform input_csc_color_matrix;
1212fb4d8502Sjsg 	struct fixed31_32 coeff_reduction_factor;
1213c349dbc7Sjsg 	struct fixed31_32 hdr_mult;
1214c349dbc7Sjsg 	struct colorspace_transform gamut_remap_matrix;
1215fb4d8502Sjsg 
1216fb4d8502Sjsg 	// TODO: No longer used, remove
1217fb4d8502Sjsg 	struct dc_hdr_static_metadata hdr_static_ctx;
1218fb4d8502Sjsg 
1219fb4d8502Sjsg 	enum dc_color_space color_space;
1220fb4d8502Sjsg 
1221c349dbc7Sjsg 	struct dc_3dlut *lut3d_func;
1222c349dbc7Sjsg 	struct dc_transfer_func *in_shaper_func;
1223c349dbc7Sjsg 	struct dc_transfer_func *blend_tf;
1224c349dbc7Sjsg 
1225ad8b1aafSjsg 	struct dc_transfer_func *gamcor_tf;
1226fb4d8502Sjsg 	enum surface_pixel_format format;
1227fb4d8502Sjsg 	enum dc_rotation_angle rotation;
1228fb4d8502Sjsg 	enum plane_stereo_format stereo_format;
1229fb4d8502Sjsg 
1230fb4d8502Sjsg 	bool is_tiling_rotated;
1231fb4d8502Sjsg 	bool per_pixel_alpha;
12321bb76ff1Sjsg 	bool pre_multiplied_alpha;
1233c349dbc7Sjsg 	bool global_alpha;
1234c349dbc7Sjsg 	int  global_alpha_value;
1235fb4d8502Sjsg 	bool visible;
1236fb4d8502Sjsg 	bool flip_immediate;
1237fb4d8502Sjsg 	bool horizontal_mirror;
1238c349dbc7Sjsg 	int layer_index;
1239fb4d8502Sjsg 
1240fb4d8502Sjsg 	union surface_update_flags update_flags;
12415ca02815Sjsg 	bool flip_int_enabled;
12425ca02815Sjsg 	bool skip_manual_trigger;
12435ca02815Sjsg 
1244fb4d8502Sjsg 	/* private to DC core */
1245fb4d8502Sjsg 	struct dc_plane_status status;
1246fb4d8502Sjsg 	struct dc_context *ctx;
1247fb4d8502Sjsg 
1248fb4d8502Sjsg 	/* HACK: Workaround for forcing full reprogramming under some conditions */
1249fb4d8502Sjsg 	bool force_full_update;
1250fb4d8502Sjsg 
12511bb76ff1Sjsg 	bool is_phantom; // TODO: Change mall_stream_config into mall_plane_config instead
12521bb76ff1Sjsg 
1253fb4d8502Sjsg 	/* private to dc_surface.c */
1254fb4d8502Sjsg 	enum dc_irq_source irq_source;
1255fb4d8502Sjsg 	struct kref refcount;
12561bb76ff1Sjsg 	struct tg_color visual_confirm_color;
12571bb76ff1Sjsg 
12581bb76ff1Sjsg 	bool is_statically_allocated;
1259fb4d8502Sjsg };
1260fb4d8502Sjsg 
1261fb4d8502Sjsg struct dc_plane_info {
1262c349dbc7Sjsg 	struct plane_size plane_size;
1263fb4d8502Sjsg 	union dc_tiling_info tiling_info;
1264fb4d8502Sjsg 	struct dc_plane_dcc_param dcc;
1265fb4d8502Sjsg 	enum surface_pixel_format format;
1266fb4d8502Sjsg 	enum dc_rotation_angle rotation;
1267fb4d8502Sjsg 	enum plane_stereo_format stereo_format;
1268fb4d8502Sjsg 	enum dc_color_space color_space;
1269fb4d8502Sjsg 	bool horizontal_mirror;
1270fb4d8502Sjsg 	bool visible;
1271fb4d8502Sjsg 	bool per_pixel_alpha;
12721bb76ff1Sjsg 	bool pre_multiplied_alpha;
1273c349dbc7Sjsg 	bool global_alpha;
1274c349dbc7Sjsg 	int  global_alpha_value;
1275fb4d8502Sjsg 	bool input_csc_enabled;
1276c349dbc7Sjsg 	int layer_index;
1277fb4d8502Sjsg };
1278fb4d8502Sjsg 
1279fb4d8502Sjsg struct dc_scaling_info {
1280fb4d8502Sjsg 	struct rect src_rect;
1281fb4d8502Sjsg 	struct rect dst_rect;
1282fb4d8502Sjsg 	struct rect clip_rect;
1283fb4d8502Sjsg 	struct scaling_taps scaling_quality;
1284fb4d8502Sjsg };
1285fb4d8502Sjsg 
1286f005ef32Sjsg struct dc_fast_update {
1287f005ef32Sjsg 	const struct dc_flip_addrs *flip_addr;
1288f005ef32Sjsg 	const struct dc_gamma *gamma;
1289f005ef32Sjsg 	const struct colorspace_transform *gamut_remap_matrix;
1290f005ef32Sjsg 	const struct dc_csc_transform *input_csc_color_matrix;
1291f005ef32Sjsg 	const struct fixed31_32 *coeff_reduction_factor;
1292f005ef32Sjsg 	struct dc_transfer_func *out_transfer_func;
1293f005ef32Sjsg 	struct dc_csc_transform *output_csc_transform;
1294f005ef32Sjsg };
1295f005ef32Sjsg 
1296fb4d8502Sjsg struct dc_surface_update {
1297fb4d8502Sjsg 	struct dc_plane_state *surface;
1298fb4d8502Sjsg 
1299fb4d8502Sjsg 	/* isr safe update parameters.  null means no updates */
1300fb4d8502Sjsg 	const struct dc_flip_addrs *flip_addr;
1301fb4d8502Sjsg 	const struct dc_plane_info *plane_info;
1302fb4d8502Sjsg 	const struct dc_scaling_info *scaling_info;
1303c349dbc7Sjsg 	struct fixed31_32 hdr_mult;
1304fb4d8502Sjsg 	/* following updates require alloc/sleep/spin that is not isr safe,
1305fb4d8502Sjsg 	 * null means no updates
1306fb4d8502Sjsg 	 */
1307fb4d8502Sjsg 	const struct dc_gamma *gamma;
1308fb4d8502Sjsg 	const struct dc_transfer_func *in_transfer_func;
1309fb4d8502Sjsg 
1310fb4d8502Sjsg 	const struct dc_csc_transform *input_csc_color_matrix;
1311fb4d8502Sjsg 	const struct fixed31_32 *coeff_reduction_factor;
1312c349dbc7Sjsg 	const struct dc_transfer_func *func_shaper;
1313c349dbc7Sjsg 	const struct dc_3dlut *lut3d_func;
1314c349dbc7Sjsg 	const struct dc_transfer_func *blend_tf;
1315c349dbc7Sjsg 	const struct colorspace_transform *gamut_remap_matrix;
1316fb4d8502Sjsg };
1317fb4d8502Sjsg 
1318fb4d8502Sjsg /*
1319fb4d8502Sjsg  * Create a new surface with default parameters;
1320fb4d8502Sjsg  */
1321fb4d8502Sjsg struct dc_plane_state *dc_create_plane_state(struct dc *dc);
1322fb4d8502Sjsg const struct dc_plane_status *dc_plane_get_status(
1323fb4d8502Sjsg 		const struct dc_plane_state *plane_state);
1324fb4d8502Sjsg 
1325fb4d8502Sjsg void dc_plane_state_retain(struct dc_plane_state *plane_state);
1326fb4d8502Sjsg void dc_plane_state_release(struct dc_plane_state *plane_state);
1327fb4d8502Sjsg 
1328fb4d8502Sjsg void dc_gamma_retain(struct dc_gamma *dc_gamma);
1329fb4d8502Sjsg void dc_gamma_release(struct dc_gamma **dc_gamma);
1330fb4d8502Sjsg struct dc_gamma *dc_create_gamma(void);
1331fb4d8502Sjsg 
1332fb4d8502Sjsg void dc_transfer_func_retain(struct dc_transfer_func *dc_tf);
1333fb4d8502Sjsg void dc_transfer_func_release(struct dc_transfer_func *dc_tf);
1334fb4d8502Sjsg struct dc_transfer_func *dc_create_transfer_func(void);
1335fb4d8502Sjsg 
1336c349dbc7Sjsg struct dc_3dlut *dc_create_3dlut_func(void);
1337c349dbc7Sjsg void dc_3dlut_func_release(struct dc_3dlut *lut);
1338c349dbc7Sjsg void dc_3dlut_func_retain(struct dc_3dlut *lut);
1339fb4d8502Sjsg 
13405ca02815Sjsg void dc_post_update_surfaces_to_stream(
1341fb4d8502Sjsg 		struct dc *dc);
1342fb4d8502Sjsg 
1343fb4d8502Sjsg #include "dc_stream.h"
1344fb4d8502Sjsg 
1345c5b64805Sjsg /**
1346c5b64805Sjsg  * struct dc_validation_set - Struct to store surface/stream associations for validation
1347fb4d8502Sjsg  */
1348fb4d8502Sjsg struct dc_validation_set {
1349c5b64805Sjsg 	/**
1350c5b64805Sjsg 	 * @stream: Stream state properties
1351c5b64805Sjsg 	 */
1352fb4d8502Sjsg 	struct dc_stream_state *stream;
1353c5b64805Sjsg 
1354c5b64805Sjsg 	/**
1355f005ef32Sjsg 	 * @plane_states: Surface state
1356c5b64805Sjsg 	 */
1357fb4d8502Sjsg 	struct dc_plane_state *plane_states[MAX_SURFACES];
1358c5b64805Sjsg 
1359c5b64805Sjsg 	/**
1360c5b64805Sjsg 	 * @plane_count: Total of active planes
1361c5b64805Sjsg 	 */
1362fb4d8502Sjsg 	uint8_t plane_count;
1363fb4d8502Sjsg };
1364fb4d8502Sjsg 
13651bb76ff1Sjsg bool dc_validate_boot_timing(const struct dc *dc,
1366c349dbc7Sjsg 				const struct dc_sink *sink,
1367c349dbc7Sjsg 				struct dc_crtc_timing *crtc_timing);
1368c349dbc7Sjsg 
1369fb4d8502Sjsg enum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state);
1370fb4d8502Sjsg 
1371c349dbc7Sjsg void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info);
1372c349dbc7Sjsg 
1373471e20e1Sjsg enum dc_status dc_validate_with_context(struct dc *dc,
1374471e20e1Sjsg 					const struct dc_validation_set set[],
1375471e20e1Sjsg 					int set_count,
1376471e20e1Sjsg 					struct dc_state *context,
1377471e20e1Sjsg 					bool fast_validate);
1378471e20e1Sjsg 
1379c349dbc7Sjsg bool dc_set_generic_gpio_for_stereo(bool enable,
1380c349dbc7Sjsg 		struct gpio_service *gpio_service);
1381c349dbc7Sjsg 
1382c349dbc7Sjsg /*
1383c349dbc7Sjsg  * fast_validate: we return after determining if we can support the new state,
1384c349dbc7Sjsg  * but before we populate the programming info
1385c349dbc7Sjsg  */
1386fb4d8502Sjsg enum dc_status dc_validate_global_state(
1387fb4d8502Sjsg 		struct dc *dc,
1388c349dbc7Sjsg 		struct dc_state *new_ctx,
1389c349dbc7Sjsg 		bool fast_validate);
1390fb4d8502Sjsg 
1391fb4d8502Sjsg 
1392fb4d8502Sjsg void dc_resource_state_construct(
1393fb4d8502Sjsg 		const struct dc *dc,
1394fb4d8502Sjsg 		struct dc_state *dst_ctx);
1395fb4d8502Sjsg 
1396ad8b1aafSjsg bool dc_acquire_release_mpc_3dlut(
1397ad8b1aafSjsg 		struct dc *dc, bool acquire,
1398ad8b1aafSjsg 		struct dc_stream_state *stream,
1399ad8b1aafSjsg 		struct dc_3dlut **lut,
1400ad8b1aafSjsg 		struct dc_transfer_func **shaper);
1401ad8b1aafSjsg 
1402fb4d8502Sjsg void dc_resource_state_copy_construct(
1403fb4d8502Sjsg 		const struct dc_state *src_ctx,
1404fb4d8502Sjsg 		struct dc_state *dst_ctx);
1405fb4d8502Sjsg 
1406fb4d8502Sjsg void dc_resource_state_copy_construct_current(
1407fb4d8502Sjsg 		const struct dc *dc,
1408fb4d8502Sjsg 		struct dc_state *dst_ctx);
1409fb4d8502Sjsg 
1410fb4d8502Sjsg void dc_resource_state_destruct(struct dc_state *context);
1411fb4d8502Sjsg 
1412c349dbc7Sjsg bool dc_resource_is_dsc_encoding_supported(const struct dc *dc);
1413c349dbc7Sjsg 
141439838cf1Sjsg enum dc_status dc_commit_streams(struct dc *dc,
141539838cf1Sjsg 				 struct dc_stream_state *streams[],
141639838cf1Sjsg 				 uint8_t stream_count);
1417f269b29fSjsg 
1418c349dbc7Sjsg struct dc_state *dc_create_state(struct dc *dc);
1419c349dbc7Sjsg struct dc_state *dc_copy_state(struct dc_state *src_ctx);
1420fb4d8502Sjsg void dc_retain_state(struct dc_state *context);
1421fb4d8502Sjsg void dc_release_state(struct dc_state *context);
1422fb4d8502Sjsg 
1423f005ef32Sjsg struct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
1424f005ef32Sjsg 		struct dc_stream_state *stream,
1425f005ef32Sjsg 		int mpcc_inst);
1426fb4d8502Sjsg 
1427fb4d8502Sjsg 
1428ad8b1aafSjsg uint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
1429ad8b1aafSjsg 
1430f005ef32Sjsg void dc_set_disable_128b_132b_stream_overhead(bool disable);
1431f005ef32Sjsg 
1432f005ef32Sjsg /* The function returns minimum bandwidth required to drive a given timing
1433f005ef32Sjsg  * return - minimum required timing bandwidth in kbps.
1434f005ef32Sjsg  */
1435f005ef32Sjsg uint32_t dc_bandwidth_in_kbps_from_timing(
1436f005ef32Sjsg 		const struct dc_crtc_timing *timing,
1437f005ef32Sjsg 		const enum dc_link_encoding_format link_encoding);
1438f005ef32Sjsg 
1439f005ef32Sjsg /* Link Interfaces */
1440f005ef32Sjsg /*
1441f005ef32Sjsg  * A link contains one or more sinks and their connected status.
1442f005ef32Sjsg  * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
1443f005ef32Sjsg  */
1444f005ef32Sjsg struct dc_link {
1445f005ef32Sjsg 	struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
1446f005ef32Sjsg 	unsigned int sink_count;
1447f005ef32Sjsg 	struct dc_sink *local_sink;
1448f005ef32Sjsg 	unsigned int link_index;
1449f005ef32Sjsg 	enum dc_connection_type type;
1450f005ef32Sjsg 	enum amd_signal_type connector_signal;
1451f005ef32Sjsg 	enum dc_irq_source irq_source_hpd;
1452f005ef32Sjsg 	enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse  */
1453f005ef32Sjsg 
1454f005ef32Sjsg 	bool is_hpd_filter_disabled;
1455f005ef32Sjsg 	bool dp_ss_off;
1456f005ef32Sjsg 
1457f005ef32Sjsg 	/**
1458f005ef32Sjsg 	 * @link_state_valid:
1459f005ef32Sjsg 	 *
1460f005ef32Sjsg 	 * If there is no link and local sink, this variable should be set to
1461f005ef32Sjsg 	 * false. Otherwise, it should be set to true; usually, the function
1462f005ef32Sjsg 	 * core_link_enable_stream sets this field to true.
1463f005ef32Sjsg 	 */
1464f005ef32Sjsg 	bool link_state_valid;
1465f005ef32Sjsg 	bool aux_access_disabled;
1466f005ef32Sjsg 	bool sync_lt_in_progress;
1467f005ef32Sjsg 	bool skip_stream_reenable;
1468f005ef32Sjsg 	bool is_internal_display;
1469f005ef32Sjsg 	/** @todo Rename. Flag an endpoint as having a programmable mapping to a DIG encoder. */
1470f005ef32Sjsg 	bool is_dig_mapping_flexible;
1471f005ef32Sjsg 	bool hpd_status; /* HPD status of link without physical HPD pin. */
1472f005ef32Sjsg 	bool is_hpd_pending; /* Indicates a new received hpd */
1473f005ef32Sjsg 	bool is_automated; /* Indicates automated testing */
1474f005ef32Sjsg 
1475f005ef32Sjsg 	bool edp_sink_present;
1476f005ef32Sjsg 
1477f005ef32Sjsg 	struct dp_trace dp_trace;
1478f005ef32Sjsg 
1479f005ef32Sjsg 	/* caps is the same as reported_link_cap. link_traing use
1480f005ef32Sjsg 	 * reported_link_cap. Will clean up.  TODO
1481f005ef32Sjsg 	 */
1482f005ef32Sjsg 	struct dc_link_settings reported_link_cap;
1483f005ef32Sjsg 	struct dc_link_settings verified_link_cap;
1484f005ef32Sjsg 	struct dc_link_settings cur_link_settings;
1485f005ef32Sjsg 	struct dc_lane_settings cur_lane_setting[LANE_COUNT_DP_MAX];
1486f005ef32Sjsg 	struct dc_link_settings preferred_link_setting;
1487f005ef32Sjsg 	/* preferred_training_settings are override values that
1488f005ef32Sjsg 	 * come from DM. DM is responsible for the memory
1489f005ef32Sjsg 	 * management of the override pointers.
1490f005ef32Sjsg 	 */
1491f005ef32Sjsg 	struct dc_link_training_overrides preferred_training_settings;
1492f005ef32Sjsg 	struct dp_audio_test_data audio_test_data;
1493f005ef32Sjsg 
1494f005ef32Sjsg 	uint8_t ddc_hw_inst;
1495f005ef32Sjsg 
1496f005ef32Sjsg 	uint8_t hpd_src;
1497f005ef32Sjsg 
1498f005ef32Sjsg 	uint8_t link_enc_hw_inst;
1499f005ef32Sjsg 	/* DIG link encoder ID. Used as index in link encoder resource pool.
1500f005ef32Sjsg 	 * For links with fixed mapping to DIG, this is not changed after dc_link
1501f005ef32Sjsg 	 * object creation.
1502f005ef32Sjsg 	 */
1503f005ef32Sjsg 	enum engine_id eng_id;
1504f005ef32Sjsg 	enum engine_id dpia_preferred_eng_id;
1505f005ef32Sjsg 
1506f005ef32Sjsg 	bool test_pattern_enabled;
1507f005ef32Sjsg 	enum dp_test_pattern current_test_pattern;
1508f005ef32Sjsg 	union compliance_test_state compliance_test_state;
1509f005ef32Sjsg 
1510f005ef32Sjsg 	void *priv;
1511f005ef32Sjsg 
1512f005ef32Sjsg 	struct ddc_service *ddc;
1513f005ef32Sjsg 
1514f005ef32Sjsg 	enum dp_panel_mode panel_mode;
1515f005ef32Sjsg 	bool aux_mode;
1516f005ef32Sjsg 
1517f005ef32Sjsg 	/* Private to DC core */
1518f005ef32Sjsg 
1519f005ef32Sjsg 	const struct dc *dc;
1520f005ef32Sjsg 
1521f005ef32Sjsg 	struct dc_context *ctx;
1522f005ef32Sjsg 
1523f005ef32Sjsg 	struct panel_cntl *panel_cntl;
1524f005ef32Sjsg 	struct link_encoder *link_enc;
1525f005ef32Sjsg 	struct graphics_object_id link_id;
1526f005ef32Sjsg 	/* Endpoint type distinguishes display endpoints which do not have entries
1527f005ef32Sjsg 	 * in the BIOS connector table from those that do. Helps when tracking link
1528f005ef32Sjsg 	 * encoder to display endpoint assignments.
1529f005ef32Sjsg 	 */
1530f005ef32Sjsg 	enum display_endpoint_type ep_type;
1531f005ef32Sjsg 	union ddi_channel_mapping ddi_channel_mapping;
1532f005ef32Sjsg 	struct connector_device_tag_info device_tag;
1533f005ef32Sjsg 	struct dpcd_caps dpcd_caps;
1534f005ef32Sjsg 	uint32_t dongle_max_pix_clk;
1535f005ef32Sjsg 	unsigned short chip_caps;
1536f005ef32Sjsg 	unsigned int dpcd_sink_count;
1537f005ef32Sjsg 	struct hdcp_caps hdcp_caps;
1538f005ef32Sjsg 	enum edp_revision edp_revision;
1539f005ef32Sjsg 	union dpcd_sink_ext_caps dpcd_sink_ext_caps;
1540f005ef32Sjsg 
1541f005ef32Sjsg 	struct psr_settings psr_settings;
1542f005ef32Sjsg 
1543f005ef32Sjsg 	struct replay_settings replay_settings;
1544f005ef32Sjsg 
1545f005ef32Sjsg 	/* Drive settings read from integrated info table */
1546f005ef32Sjsg 	struct dc_lane_settings bios_forced_drive_settings;
1547f005ef32Sjsg 
1548f005ef32Sjsg 	/* Vendor specific LTTPR workaround variables */
1549f005ef32Sjsg 	uint8_t vendor_specific_lttpr_link_rate_wa;
1550f005ef32Sjsg 	bool apply_vendor_specific_lttpr_link_rate_wa;
1551f005ef32Sjsg 
1552f005ef32Sjsg 	/* MST record stream using this link */
1553f005ef32Sjsg 	struct link_flags {
1554f005ef32Sjsg 		bool dp_keep_receiver_powered;
1555f005ef32Sjsg 		bool dp_skip_DID2;
1556f005ef32Sjsg 		bool dp_skip_reset_segment;
1557f005ef32Sjsg 		bool dp_skip_fs_144hz;
1558f005ef32Sjsg 		bool dp_mot_reset_segment;
1559f005ef32Sjsg 		/* Some USB4 docks do not handle turning off MST DSC once it has been enabled. */
1560f005ef32Sjsg 		bool dpia_mst_dsc_always_on;
1561f005ef32Sjsg 		/* Forced DPIA into TBT3 compatibility mode. */
1562f005ef32Sjsg 		bool dpia_forced_tbt3_mode;
1563f005ef32Sjsg 		bool dongle_mode_timing_override;
1564f005ef32Sjsg 		bool blank_stream_on_ocs_change;
1565f005ef32Sjsg 		bool read_dpcd204h_on_irq_hpd;
1566f005ef32Sjsg 	} wa_flags;
1567f005ef32Sjsg 	struct link_mst_stream_allocation_table mst_stream_alloc_table;
1568f005ef32Sjsg 
1569f005ef32Sjsg 	struct dc_link_status link_status;
1570f005ef32Sjsg 	struct dprx_states dprx_states;
1571f005ef32Sjsg 
1572f005ef32Sjsg 	struct gpio *hpd_gpio;
1573f005ef32Sjsg 	enum dc_link_fec_state fec_state;
1574f005ef32Sjsg 	bool link_powered_externally;	// Used to bypass hardware sequencing delays when panel is powered down forcibly
1575f005ef32Sjsg 
1576f005ef32Sjsg 	struct dc_panel_config panel_config;
1577f005ef32Sjsg 	struct phy_state phy_state;
1578f005ef32Sjsg 	// BW ALLOCATON USB4 ONLY
1579f005ef32Sjsg 	struct dc_dpia_bw_alloc dpia_bw_alloc_config;
1580f005ef32Sjsg 	bool skip_implict_edp_power_control;
1581f005ef32Sjsg };
1582f005ef32Sjsg 
1583f005ef32Sjsg /* Return an enumerated dc_link.
1584f005ef32Sjsg  * dc_link order is constant and determined at
1585f005ef32Sjsg  * boot time.  They cannot be created or destroyed.
1586f005ef32Sjsg  * Use dc_get_caps() to get number of links.
1587f005ef32Sjsg  */
1588f005ef32Sjsg struct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index);
1589f005ef32Sjsg 
1590f005ef32Sjsg /* Return instance id of the edp link. Inst 0 is primary edp link. */
1591f005ef32Sjsg bool dc_get_edp_link_panel_inst(const struct dc *dc,
1592f005ef32Sjsg 		const struct dc_link *link,
1593f005ef32Sjsg 		unsigned int *inst_out);
1594f005ef32Sjsg 
1595f005ef32Sjsg /* Return an array of link pointers to edp links. */
1596f005ef32Sjsg void dc_get_edp_links(const struct dc *dc,
1597f005ef32Sjsg 		struct dc_link **edp_links,
1598f005ef32Sjsg 		int *edp_num);
1599f005ef32Sjsg 
1600f005ef32Sjsg void dc_set_edp_power(const struct dc *dc, struct dc_link *edp_link,
1601f005ef32Sjsg 				 bool powerOn);
1602f005ef32Sjsg 
1603f005ef32Sjsg /* The function initiates detection handshake over the given link. It first
1604f005ef32Sjsg  * determines if there are display connections over the link. If so it initiates
1605f005ef32Sjsg  * detection protocols supported by the connected receiver device. The function
1606f005ef32Sjsg  * contains protocol specific handshake sequences which are sometimes mandatory
1607f005ef32Sjsg  * to establish a proper connection between TX and RX. So it is always
1608f005ef32Sjsg  * recommended to call this function as the first link operation upon HPD event
1609f005ef32Sjsg  * or power up event. Upon completion, the function will update link structure
1610f005ef32Sjsg  * in place based on latest RX capabilities. The function may also cause dpms
1611f005ef32Sjsg  * to be reset to off for all currently enabled streams to the link. It is DM's
1612f005ef32Sjsg  * responsibility to serialize detection and DPMS updates.
1613f005ef32Sjsg  *
1614f005ef32Sjsg  * @reason - Indicate which event triggers this detection. dc may customize
1615f005ef32Sjsg  * detection flow depending on the triggering events.
1616f005ef32Sjsg  * return false - if detection is not fully completed. This could happen when
1617f005ef32Sjsg  * there is an unrecoverable error during detection or detection is partially
1618f005ef32Sjsg  * completed (detection has been delegated to dm mst manager ie.
1619f005ef32Sjsg  * link->connection_type == dc_connection_mst_branch when returning false).
1620f005ef32Sjsg  * return true - detection is completed, link has been fully updated with latest
1621f005ef32Sjsg  * detection result.
1622f005ef32Sjsg  */
1623f005ef32Sjsg bool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason);
1624f005ef32Sjsg 
1625f005ef32Sjsg struct dc_sink_init_data;
1626f005ef32Sjsg 
1627f005ef32Sjsg /* When link connection type is dc_connection_mst_branch, remote sink can be
1628f005ef32Sjsg  * added to the link. The interface creates a remote sink and associates it with
1629f005ef32Sjsg  * current link. The sink will be retained by link until remove remote sink is
1630f005ef32Sjsg  * called.
1631f005ef32Sjsg  *
1632f005ef32Sjsg  * @dc_link - link the remote sink will be added to.
1633f005ef32Sjsg  * @edid - byte array of EDID raw data.
1634f005ef32Sjsg  * @len - size of the edid in byte
1635f005ef32Sjsg  * @init_data -
1636f005ef32Sjsg  */
1637f005ef32Sjsg struct dc_sink *dc_link_add_remote_sink(
1638f005ef32Sjsg 		struct dc_link *dc_link,
1639f005ef32Sjsg 		const uint8_t *edid,
1640f005ef32Sjsg 		int len,
1641f005ef32Sjsg 		struct dc_sink_init_data *init_data);
1642f005ef32Sjsg 
1643f005ef32Sjsg /* Remove remote sink from a link with dc_connection_mst_branch connection type.
1644f005ef32Sjsg  * @link - link the sink should be removed from
1645f005ef32Sjsg  * @sink - sink to be removed.
1646f005ef32Sjsg  */
1647f005ef32Sjsg void dc_link_remove_remote_sink(
1648f005ef32Sjsg 	struct dc_link *link,
1649f005ef32Sjsg 	struct dc_sink *sink);
1650f005ef32Sjsg 
1651f005ef32Sjsg /* Enable HPD interrupt handler for a given link */
1652f005ef32Sjsg void dc_link_enable_hpd(const struct dc_link *link);
1653f005ef32Sjsg 
1654f005ef32Sjsg /* Disable HPD interrupt handler for a given link */
1655f005ef32Sjsg void dc_link_disable_hpd(const struct dc_link *link);
1656f005ef32Sjsg 
1657f005ef32Sjsg /* determine if there is a sink connected to the link
1658f005ef32Sjsg  *
1659f005ef32Sjsg  * @type - dc_connection_single if connected, dc_connection_none otherwise.
1660f005ef32Sjsg  * return - false if an unexpected error occurs, true otherwise.
1661f005ef32Sjsg  *
1662f005ef32Sjsg  * NOTE: This function doesn't detect downstream sink connections i.e
1663f005ef32Sjsg  * dc_connection_mst_branch, dc_connection_sst_branch. In this case, it will
1664f005ef32Sjsg  * return dc_connection_single if the branch device is connected despite of
1665f005ef32Sjsg  * downstream sink's connection status.
1666f005ef32Sjsg  */
1667f005ef32Sjsg bool dc_link_detect_connection_type(struct dc_link *link,
1668f005ef32Sjsg 		enum dc_connection_type *type);
1669f005ef32Sjsg 
1670f005ef32Sjsg /* query current hpd pin value
1671f005ef32Sjsg  * return - true HPD is asserted (HPD high), false otherwise (HPD low)
1672f005ef32Sjsg  *
1673f005ef32Sjsg  */
1674f005ef32Sjsg bool dc_link_get_hpd_state(struct dc_link *link);
1675f005ef32Sjsg 
1676f005ef32Sjsg /* Getter for cached link status from given link */
1677f005ef32Sjsg const struct dc_link_status *dc_link_get_status(const struct dc_link *link);
1678f005ef32Sjsg 
1679f005ef32Sjsg /* enable/disable hardware HPD filter.
1680f005ef32Sjsg  *
1681f005ef32Sjsg  * @link - The link the HPD pin is associated with.
1682f005ef32Sjsg  * @enable = true - enable hardware HPD filter. HPD event will only queued to irq
1683f005ef32Sjsg  * handler once after no HPD change has been detected within dc default HPD
1684f005ef32Sjsg  * filtering interval since last HPD event. i.e if display keeps toggling hpd
1685f005ef32Sjsg  * pulses within default HPD interval, no HPD event will be received until HPD
1686f005ef32Sjsg  * toggles have stopped. Then HPD event will be queued to irq handler once after
1687f005ef32Sjsg  * dc default HPD filtering interval since last HPD event.
1688f005ef32Sjsg  *
1689f005ef32Sjsg  * @enable = false - disable hardware HPD filter. HPD event will be queued
1690f005ef32Sjsg  * immediately to irq handler after no HPD change has been detected within
1691f005ef32Sjsg  * IRQ_HPD (aka HPD short pulse) interval (i.e 2ms).
1692f005ef32Sjsg  */
1693f005ef32Sjsg void dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
1694f005ef32Sjsg 
1695f005ef32Sjsg /* submit i2c read/write payloads through ddc channel
1696f005ef32Sjsg  * @link_index - index to a link with ddc in i2c mode
1697f005ef32Sjsg  * @cmd - i2c command structure
1698f005ef32Sjsg  * return - true if success, false otherwise.
1699f005ef32Sjsg  */
1700f005ef32Sjsg bool dc_submit_i2c(
1701f005ef32Sjsg 		struct dc *dc,
1702f005ef32Sjsg 		uint32_t link_index,
1703f005ef32Sjsg 		struct i2c_command *cmd);
1704f005ef32Sjsg 
1705f005ef32Sjsg /* submit i2c read/write payloads through oem channel
1706f005ef32Sjsg  * @link_index - index to a link with ddc in i2c mode
1707f005ef32Sjsg  * @cmd - i2c command structure
1708f005ef32Sjsg  * return - true if success, false otherwise.
1709f005ef32Sjsg  */
1710f005ef32Sjsg bool dc_submit_i2c_oem(
1711f005ef32Sjsg 		struct dc *dc,
1712f005ef32Sjsg 		struct i2c_command *cmd);
1713f005ef32Sjsg 
1714f005ef32Sjsg enum aux_return_code_type;
1715f005ef32Sjsg /* Attempt to transfer the given aux payload. This function does not perform
1716f005ef32Sjsg  * retries or handle error states. The reply is returned in the payload->reply
1717f005ef32Sjsg  * and the result through operation_result. Returns the number of bytes
1718f005ef32Sjsg  * transferred,or -1 on a failure.
1719f005ef32Sjsg  */
1720f005ef32Sjsg int dc_link_aux_transfer_raw(struct ddc_service *ddc,
1721f005ef32Sjsg 		struct aux_payload *payload,
1722f005ef32Sjsg 		enum aux_return_code_type *operation_result);
1723f005ef32Sjsg 
1724f005ef32Sjsg bool dc_is_oem_i2c_device_present(
1725f005ef32Sjsg 	struct dc *dc,
1726f005ef32Sjsg 	size_t slave_address
1727f005ef32Sjsg );
1728f005ef32Sjsg 
1729f005ef32Sjsg /* return true if the connected receiver supports the hdcp version */
1730f005ef32Sjsg bool dc_link_is_hdcp14(struct dc_link *link, enum amd_signal_type signal);
1731f005ef32Sjsg bool dc_link_is_hdcp22(struct dc_link *link, enum amd_signal_type signal);
1732f005ef32Sjsg 
1733f005ef32Sjsg /* Notify DC about DP RX Interrupt (aka DP IRQ_HPD).
1734f005ef32Sjsg  *
1735f005ef32Sjsg  * TODO - When defer_handling is true the function will have a different purpose.
1736f005ef32Sjsg  * It no longer does complete hpd rx irq handling. We should create a separate
1737f005ef32Sjsg  * interface specifically for this case.
1738f005ef32Sjsg  *
1739f005ef32Sjsg  * Return:
1740f005ef32Sjsg  * true - Downstream port status changed. DM should call DC to do the
1741f005ef32Sjsg  * detection.
1742f005ef32Sjsg  * false - no change in Downstream port status. No further action required
1743f005ef32Sjsg  * from DM.
1744f005ef32Sjsg  */
1745f005ef32Sjsg bool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
1746f005ef32Sjsg 		union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss,
1747f005ef32Sjsg 		bool defer_handling, bool *has_left_work);
1748f005ef32Sjsg /* handle DP specs define test automation sequence*/
1749f005ef32Sjsg void dc_link_dp_handle_automated_test(struct dc_link *link);
1750f005ef32Sjsg 
1751f005ef32Sjsg /* handle DP Link loss sequence and try to recover RX link loss with best
1752f005ef32Sjsg  * effort
1753f005ef32Sjsg  */
1754f005ef32Sjsg void dc_link_dp_handle_link_loss(struct dc_link *link);
1755f005ef32Sjsg 
1756f005ef32Sjsg /* Determine if hpd rx irq should be handled or ignored
1757f005ef32Sjsg  * return true - hpd rx irq should be handled.
1758f005ef32Sjsg  * return false - it is safe to ignore hpd rx irq event
1759f005ef32Sjsg  */
1760f005ef32Sjsg bool dc_link_dp_allow_hpd_rx_irq(const struct dc_link *link);
1761f005ef32Sjsg 
1762f005ef32Sjsg /* Determine if link loss is indicated with a given hpd_irq_dpcd_data.
1763f005ef32Sjsg  * @link - link the hpd irq data associated with
1764f005ef32Sjsg  * @hpd_irq_dpcd_data - input hpd irq data
1765f005ef32Sjsg  * return - true if hpd irq data indicates a link lost
1766f005ef32Sjsg  */
1767f005ef32Sjsg bool dc_link_check_link_loss_status(struct dc_link *link,
1768f005ef32Sjsg 		union hpd_irq_data *hpd_irq_dpcd_data);
1769f005ef32Sjsg 
1770f005ef32Sjsg /* Read hpd rx irq data from a given link
1771f005ef32Sjsg  * @link - link where the hpd irq data should be read from
1772f005ef32Sjsg  * @irq_data - output hpd irq data
1773f005ef32Sjsg  * return - DC_OK if hpd irq data is read successfully, otherwise hpd irq data
1774f005ef32Sjsg  * read has failed.
1775f005ef32Sjsg  */
1776f005ef32Sjsg enum dc_status dc_link_dp_read_hpd_rx_irq_data(
1777f005ef32Sjsg 	struct dc_link *link,
1778f005ef32Sjsg 	union hpd_irq_data *irq_data);
1779f005ef32Sjsg 
1780f005ef32Sjsg /* The function clears recorded DP RX states in the link. DM should call this
1781f005ef32Sjsg  * function when it is resuming from S3 power state to previously connected links.
1782f005ef32Sjsg  *
1783f005ef32Sjsg  * TODO - in the future we should consider to expand link resume interface to
1784f005ef32Sjsg  * support clearing previous rx states. So we don't have to rely on dm to call
1785f005ef32Sjsg  * this interface explicitly.
1786f005ef32Sjsg  */
1787f005ef32Sjsg void dc_link_clear_dprx_states(struct dc_link *link);
1788f005ef32Sjsg 
1789f005ef32Sjsg /* Destruct the mst topology of the link and reset the allocated payload table
1790f005ef32Sjsg  *
1791f005ef32Sjsg  * NOTE: this should only be called if DM chooses not to call dc_link_detect but
1792f005ef32Sjsg  * still wants to reset MST topology on an unplug event */
1793f005ef32Sjsg bool dc_link_reset_cur_dp_mst_topology(struct dc_link *link);
1794f005ef32Sjsg 
1795f005ef32Sjsg /* The function calculates effective DP link bandwidth when a given link is
1796f005ef32Sjsg  * using the given link settings.
1797f005ef32Sjsg  *
1798f005ef32Sjsg  * return - total effective link bandwidth in kbps.
1799f005ef32Sjsg  */
1800f005ef32Sjsg uint32_t dc_link_bandwidth_kbps(
1801f005ef32Sjsg 	const struct dc_link *link,
1802f005ef32Sjsg 	const struct dc_link_settings *link_setting);
1803f005ef32Sjsg 
1804f005ef32Sjsg /* The function takes a snapshot of current link resource allocation state
1805f005ef32Sjsg  * @dc: pointer to dc of the dm calling this
1806f005ef32Sjsg  * @map: a dc link resource snapshot defined internally to dc.
1807f005ef32Sjsg  *
1808f005ef32Sjsg  * DM needs to capture a snapshot of current link resource allocation mapping
1809f005ef32Sjsg  * and store it in its persistent storage.
1810f005ef32Sjsg  *
1811f005ef32Sjsg  * Some of the link resource is using first come first serve policy.
1812f005ef32Sjsg  * The allocation mapping depends on original hotplug order. This information
1813f005ef32Sjsg  * is lost after driver is loaded next time. The snapshot is used in order to
1814f005ef32Sjsg  * restore link resource to its previous state so user will get consistent
1815f005ef32Sjsg  * link capability allocation across reboot.
1816f005ef32Sjsg  *
1817f005ef32Sjsg  */
1818f005ef32Sjsg void dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map);
1819f005ef32Sjsg 
1820f005ef32Sjsg /* This function restores link resource allocation state from a snapshot
1821f005ef32Sjsg  * @dc: pointer to dc of the dm calling this
1822f005ef32Sjsg  * @map: a dc link resource snapshot defined internally to dc.
1823f005ef32Sjsg  *
1824f005ef32Sjsg  * DM needs to call this function after initial link detection on boot and
1825f005ef32Sjsg  * before first commit streams to restore link resource allocation state
1826f005ef32Sjsg  * from previous boot session.
1827f005ef32Sjsg  *
1828f005ef32Sjsg  * Some of the link resource is using first come first serve policy.
1829f005ef32Sjsg  * The allocation mapping depends on original hotplug order. This information
1830f005ef32Sjsg  * is lost after driver is loaded next time. The snapshot is used in order to
1831f005ef32Sjsg  * restore link resource to its previous state so user will get consistent
1832f005ef32Sjsg  * link capability allocation across reboot.
1833f005ef32Sjsg  *
1834f005ef32Sjsg  */
1835f005ef32Sjsg void dc_restore_link_res_map(const struct dc *dc, uint32_t *map);
1836f005ef32Sjsg 
1837f005ef32Sjsg /* TODO: this is not meant to be exposed to DM. Should switch to stream update
1838f005ef32Sjsg  * interface i.e stream_update->dsc_config
1839f005ef32Sjsg  */
1840f005ef32Sjsg bool dc_link_update_dsc_config(struct pipe_ctx *pipe_ctx);
1841f005ef32Sjsg 
1842f005ef32Sjsg /* translate a raw link rate data to bandwidth in kbps */
1843f005ef32Sjsg uint32_t dc_link_bw_kbps_from_raw_frl_link_rate_data(const struct dc *dc, uint8_t bw);
1844f005ef32Sjsg 
1845f005ef32Sjsg /* determine the optimal bandwidth given link and required bw.
1846f005ef32Sjsg  * @link - current detected link
1847f005ef32Sjsg  * @req_bw - requested bandwidth in kbps
1848f005ef32Sjsg  * @link_settings - returned most optimal link settings that can fit the
1849f005ef32Sjsg  * requested bandwidth
1850f005ef32Sjsg  * return - false if link can't support requested bandwidth, true if link
1851f005ef32Sjsg  * settings is found.
1852f005ef32Sjsg  */
1853f005ef32Sjsg bool dc_link_decide_edp_link_settings(struct dc_link *link,
1854f005ef32Sjsg 		struct dc_link_settings *link_settings,
1855f005ef32Sjsg 		uint32_t req_bw);
1856f005ef32Sjsg 
1857f005ef32Sjsg /* return the max dp link settings can be driven by the link without considering
1858f005ef32Sjsg  * connected RX device and its capability
1859f005ef32Sjsg  */
1860f005ef32Sjsg bool dc_link_dp_get_max_link_enc_cap(const struct dc_link *link,
1861f005ef32Sjsg 		struct dc_link_settings *max_link_enc_cap);
1862f005ef32Sjsg 
1863f005ef32Sjsg /* determine when the link is driving MST mode, what DP link channel coding
1864f005ef32Sjsg  * format will be used. The decision will remain unchanged until next HPD event.
1865f005ef32Sjsg  *
1866f005ef32Sjsg  * @link -  a link with DP RX connection
1867f005ef32Sjsg  * return - if stream is committed to this link with MST signal type, type of
1868f005ef32Sjsg  * channel coding format dc will choose.
1869f005ef32Sjsg  */
1870f005ef32Sjsg enum dp_link_encoding dc_link_dp_mst_decide_link_encoding_format(
1871f005ef32Sjsg 		const struct dc_link *link);
1872f005ef32Sjsg 
1873f005ef32Sjsg /* get max dp link settings the link can enable with all things considered. (i.e
1874f005ef32Sjsg  * TX/RX/Cable capabilities and dp override policies.
1875f005ef32Sjsg  *
1876f005ef32Sjsg  * @link - a link with DP RX connection
1877f005ef32Sjsg  * return - max dp link settings the link can enable.
1878f005ef32Sjsg  *
1879f005ef32Sjsg  */
1880f005ef32Sjsg const struct dc_link_settings *dc_link_get_link_cap(const struct dc_link *link);
1881f005ef32Sjsg 
1882f005ef32Sjsg /* Get the highest encoding format that the link supports; highest meaning the
1883f005ef32Sjsg  * encoding format which supports the maximum bandwidth.
1884f005ef32Sjsg  *
1885f005ef32Sjsg  * @link - a link with DP RX connection
1886f005ef32Sjsg  * return - highest encoding format link supports.
1887f005ef32Sjsg  */
1888f005ef32Sjsg enum dc_link_encoding_format dc_link_get_highest_encoding_format(const struct dc_link *link);
1889f005ef32Sjsg 
1890f005ef32Sjsg /* Check if a RX (ex. DP sink, MST hub, passive or active dongle) is connected
1891f005ef32Sjsg  * to a link with dp connector signal type.
1892f005ef32Sjsg  * @link - a link with dp connector signal type
1893f005ef32Sjsg  * return - true if connected, false otherwise
1894f005ef32Sjsg  */
1895f005ef32Sjsg bool dc_link_is_dp_sink_present(struct dc_link *link);
1896f005ef32Sjsg 
1897f005ef32Sjsg /* Force DP lane settings update to main-link video signal and notify the change
1898f005ef32Sjsg  * to DP RX via DPCD. This is a debug interface used for video signal integrity
1899f005ef32Sjsg  * tuning purpose. The interface assumes link has already been enabled with DP
1900f005ef32Sjsg  * signal.
1901f005ef32Sjsg  *
1902f005ef32Sjsg  * @lt_settings - a container structure with desired hw_lane_settings
1903f005ef32Sjsg  */
1904f005ef32Sjsg void dc_link_set_drive_settings(struct dc *dc,
1905f005ef32Sjsg 				struct link_training_settings *lt_settings,
1906f005ef32Sjsg 				struct dc_link *link);
1907f005ef32Sjsg 
1908f005ef32Sjsg /* Enable a test pattern in Link or PHY layer in an active link for compliance
1909f005ef32Sjsg  * test or debugging purpose. The test pattern will remain until next un-plug.
1910f005ef32Sjsg  *
1911f005ef32Sjsg  * @link - active link with DP signal output enabled.
1912f005ef32Sjsg  * @test_pattern - desired test pattern to output.
1913f005ef32Sjsg  * NOTE: set to DP_TEST_PATTERN_VIDEO_MODE to disable previous test pattern.
1914f005ef32Sjsg  * @test_pattern_color_space - for video test pattern choose a desired color
1915f005ef32Sjsg  * space.
1916f005ef32Sjsg  * @p_link_settings - For PHY pattern choose a desired link settings
1917f005ef32Sjsg  * @p_custom_pattern - some test pattern will require a custom input to
1918f005ef32Sjsg  * customize some pattern details. Otherwise keep it to NULL.
1919f005ef32Sjsg  * @cust_pattern_size - size of the custom pattern input.
1920f005ef32Sjsg  *
1921f005ef32Sjsg  */
1922f005ef32Sjsg bool dc_link_dp_set_test_pattern(
1923f005ef32Sjsg 	struct dc_link *link,
1924f005ef32Sjsg 	enum dp_test_pattern test_pattern,
1925f005ef32Sjsg 	enum dp_test_pattern_color_space test_pattern_color_space,
1926f005ef32Sjsg 	const struct link_training_settings *p_link_settings,
1927f005ef32Sjsg 	const unsigned char *p_custom_pattern,
1928f005ef32Sjsg 	unsigned int cust_pattern_size);
1929f005ef32Sjsg 
1930f005ef32Sjsg /* Force DP link settings to always use a specific value until reboot to a
1931f005ef32Sjsg  * specific link. If link has already been enabled, the interface will also
1932f005ef32Sjsg  * switch to desired link settings immediately. This is a debug interface to
1933f005ef32Sjsg  * generic dp issue trouble shooting.
1934f005ef32Sjsg  */
1935f005ef32Sjsg void dc_link_set_preferred_link_settings(struct dc *dc,
1936f005ef32Sjsg 		struct dc_link_settings *link_setting,
1937f005ef32Sjsg 		struct dc_link *link);
1938f005ef32Sjsg 
1939f005ef32Sjsg /* Force DP link to customize a specific link training behavior by overriding to
1940f005ef32Sjsg  * standard DP specs defined protocol. This is a debug interface to trouble shoot
1941f005ef32Sjsg  * display specific link training issues or apply some display specific
1942f005ef32Sjsg  * workaround in link training.
1943f005ef32Sjsg  *
1944f005ef32Sjsg  * @link_settings - if not NULL, force preferred link settings to the link.
1945f005ef32Sjsg  * @lt_override - a set of override pointers. If any pointer is none NULL, dc
1946f005ef32Sjsg  * will apply this particular override in future link training. If NULL is
1947f005ef32Sjsg  * passed in, dc resets previous overrides.
1948f005ef32Sjsg  * NOTE: DM must keep the memory from override pointers until DM resets preferred
1949f005ef32Sjsg  * training settings.
1950f005ef32Sjsg  */
1951f005ef32Sjsg void dc_link_set_preferred_training_settings(struct dc *dc,
1952f005ef32Sjsg 		struct dc_link_settings *link_setting,
1953f005ef32Sjsg 		struct dc_link_training_overrides *lt_overrides,
1954f005ef32Sjsg 		struct dc_link *link,
1955f005ef32Sjsg 		bool skip_immediate_retrain);
1956f005ef32Sjsg 
1957f005ef32Sjsg /* return - true if FEC is supported with connected DP RX, false otherwise */
1958f005ef32Sjsg bool dc_link_is_fec_supported(const struct dc_link *link);
1959f005ef32Sjsg 
1960f005ef32Sjsg /* query FEC enablement policy to determine if FEC will be enabled by dc during
1961f005ef32Sjsg  * link enablement.
1962f005ef32Sjsg  * return - true if FEC should be enabled, false otherwise.
1963f005ef32Sjsg  */
1964f005ef32Sjsg bool dc_link_should_enable_fec(const struct dc_link *link);
1965f005ef32Sjsg 
1966f005ef32Sjsg /* determine lttpr mode the current link should be enabled with a specific link
1967f005ef32Sjsg  * settings.
1968f005ef32Sjsg  */
1969f005ef32Sjsg enum lttpr_mode dc_link_decide_lttpr_mode(struct dc_link *link,
1970f005ef32Sjsg 		struct dc_link_settings *link_setting);
1971f005ef32Sjsg 
1972f005ef32Sjsg /* Force DP RX to update its power state.
1973f005ef32Sjsg  * NOTE: this interface doesn't update dp main-link. Calling this function will
1974f005ef32Sjsg  * cause DP TX main-link and DP RX power states out of sync. DM has to restore
1975f005ef32Sjsg  * RX power state back upon finish DM specific execution requiring DP RX in a
1976f005ef32Sjsg  * specific power state.
1977f005ef32Sjsg  * @on - true to set DP RX in D0 power state, false to set DP RX in D3 power
1978f005ef32Sjsg  * state.
1979f005ef32Sjsg  */
1980f005ef32Sjsg void dc_link_dp_receiver_power_ctrl(struct dc_link *link, bool on);
1981f005ef32Sjsg 
1982f005ef32Sjsg /* Force link to read base dp receiver caps from dpcd 000h - 00Fh and overwrite
1983f005ef32Sjsg  * current value read from extended receiver cap from 02200h - 0220Fh.
1984f005ef32Sjsg  * Some DP RX has problems of providing accurate DP receiver caps from extended
1985f005ef32Sjsg  * field, this interface is a workaround to revert link back to use base caps.
1986f005ef32Sjsg  */
1987f005ef32Sjsg void dc_link_overwrite_extended_receiver_cap(
1988f005ef32Sjsg 		struct dc_link *link);
1989f005ef32Sjsg 
1990f005ef32Sjsg void dc_link_edp_panel_backlight_power_on(struct dc_link *link,
1991f005ef32Sjsg 		bool wait_for_hpd);
1992f005ef32Sjsg 
1993f005ef32Sjsg /* Set backlight level of an embedded panel (eDP, LVDS).
1994f005ef32Sjsg  * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer
1995f005ef32Sjsg  * and 16 bit fractional, where 1.0 is max backlight value.
1996f005ef32Sjsg  */
1997f005ef32Sjsg bool dc_link_set_backlight_level(const struct dc_link *dc_link,
1998f005ef32Sjsg 		uint32_t backlight_pwm_u16_16,
1999f005ef32Sjsg 		uint32_t frame_ramp);
2000f005ef32Sjsg 
2001f005ef32Sjsg /* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */
2002f005ef32Sjsg bool dc_link_set_backlight_level_nits(struct dc_link *link,
2003f005ef32Sjsg 		bool isHDR,
2004f005ef32Sjsg 		uint32_t backlight_millinits,
2005f005ef32Sjsg 		uint32_t transition_time_in_ms);
2006f005ef32Sjsg 
2007f005ef32Sjsg bool dc_link_get_backlight_level_nits(struct dc_link *link,
2008f005ef32Sjsg 		uint32_t *backlight_millinits,
2009f005ef32Sjsg 		uint32_t *backlight_millinits_peak);
2010f005ef32Sjsg 
2011f005ef32Sjsg int dc_link_get_backlight_level(const struct dc_link *dc_link);
2012f005ef32Sjsg 
2013f005ef32Sjsg int dc_link_get_target_backlight_pwm(const struct dc_link *link);
2014f005ef32Sjsg 
2015f005ef32Sjsg bool dc_link_set_psr_allow_active(struct dc_link *dc_link, const bool *enable,
2016f005ef32Sjsg 		bool wait, bool force_static, const unsigned int *power_opts);
2017f005ef32Sjsg 
2018f005ef32Sjsg bool dc_link_get_psr_state(const struct dc_link *dc_link, enum dc_psr_state *state);
2019f005ef32Sjsg 
2020f005ef32Sjsg bool dc_link_setup_psr(struct dc_link *dc_link,
2021f005ef32Sjsg 		const struct dc_stream_state *stream, struct psr_config *psr_config,
2022f005ef32Sjsg 		struct psr_context *psr_context);
2023f005ef32Sjsg 
2024f005ef32Sjsg bool dc_link_get_replay_state(const struct dc_link *dc_link, uint64_t *state);
2025f005ef32Sjsg 
2026f005ef32Sjsg /* On eDP links this function call will stall until T12 has elapsed.
2027f005ef32Sjsg  * If the panel is not in power off state, this function will return
2028f005ef32Sjsg  * immediately.
2029f005ef32Sjsg  */
2030f005ef32Sjsg bool dc_link_wait_for_t12(struct dc_link *link);
2031f005ef32Sjsg 
2032f005ef32Sjsg /* Determine if dp trace has been initialized to reflect upto date result *
2033f005ef32Sjsg  * return - true if trace is initialized and has valid data. False dp trace
2034f005ef32Sjsg  * doesn't have valid result.
2035f005ef32Sjsg  */
2036f005ef32Sjsg bool dc_dp_trace_is_initialized(struct dc_link *link);
2037f005ef32Sjsg 
2038f005ef32Sjsg /* Query a dp trace flag to indicate if the current dp trace data has been
2039f005ef32Sjsg  * logged before
2040f005ef32Sjsg  */
2041f005ef32Sjsg bool dc_dp_trace_is_logged(struct dc_link *link,
2042f005ef32Sjsg 		bool in_detection);
2043f005ef32Sjsg 
2044f005ef32Sjsg /* Set dp trace flag to indicate whether DM has already logged the current dp
2045f005ef32Sjsg  * trace data. DM can set is_logged to true upon logging and check
2046f005ef32Sjsg  * dc_dp_trace_is_logged before logging to avoid logging the same result twice.
2047f005ef32Sjsg  */
2048f005ef32Sjsg void dc_dp_trace_set_is_logged_flag(struct dc_link *link,
2049f005ef32Sjsg 		bool in_detection,
2050f005ef32Sjsg 		bool is_logged);
2051f005ef32Sjsg 
2052f005ef32Sjsg /* Obtain driver time stamp for last dp link training end. The time stamp is
2053f005ef32Sjsg  * formatted based on dm_get_timestamp DM function.
2054f005ef32Sjsg  * @in_detection - true to get link training end time stamp of last link
2055f005ef32Sjsg  * training in detection sequence. false to get link training end time stamp
2056f005ef32Sjsg  * of last link training in commit (dpms) sequence
2057f005ef32Sjsg  */
2058f005ef32Sjsg unsigned long long dc_dp_trace_get_lt_end_timestamp(struct dc_link *link,
2059f005ef32Sjsg 		bool in_detection);
2060f005ef32Sjsg 
2061f005ef32Sjsg /* Get how many link training attempts dc has done with latest sequence.
2062f005ef32Sjsg  * @in_detection - true to get link training count of last link
2063f005ef32Sjsg  * training in detection sequence. false to get link training count of last link
2064f005ef32Sjsg  * training in commit (dpms) sequence
2065f005ef32Sjsg  */
2066f005ef32Sjsg const struct dp_trace_lt_counts *dc_dp_trace_get_lt_counts(struct dc_link *link,
2067f005ef32Sjsg 		bool in_detection);
2068f005ef32Sjsg 
2069f005ef32Sjsg /* Get how many link loss has happened since last link training attempts */
2070f005ef32Sjsg unsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link);
2071f005ef32Sjsg 
2072f005ef32Sjsg /*
2073f005ef32Sjsg  *  USB4 DPIA BW ALLOCATION PUBLIC FUNCTIONS
2074f005ef32Sjsg  */
2075f005ef32Sjsg /*
2076f005ef32Sjsg  * Send a request from DP-Tx requesting to allocate BW remotely after
2077f005ef32Sjsg  * allocating it locally. This will get processed by CM and a CB function
2078f005ef32Sjsg  * will be called.
2079f005ef32Sjsg  *
2080f005ef32Sjsg  * @link: pointer to the dc_link struct instance
2081f005ef32Sjsg  * @req_bw: The requested bw in Kbyte to allocated
2082f005ef32Sjsg  *
2083f005ef32Sjsg  * return: none
2084f005ef32Sjsg  */
2085f005ef32Sjsg void dc_link_set_usb4_req_bw_req(struct dc_link *link, int req_bw);
2086f005ef32Sjsg 
2087f005ef32Sjsg /*
2088f005ef32Sjsg  * Handle function for when the status of the Request above is complete.
2089f005ef32Sjsg  * We will find out the result of allocating on CM and update structs.
2090f005ef32Sjsg  *
2091f005ef32Sjsg  * @link: pointer to the dc_link struct instance
2092f005ef32Sjsg  * @bw: Allocated or Estimated BW depending on the result
2093f005ef32Sjsg  * @result: Response type
2094f005ef32Sjsg  *
2095f005ef32Sjsg  * return: none
2096f005ef32Sjsg  */
2097f005ef32Sjsg void dc_link_handle_usb4_bw_alloc_response(struct dc_link *link,
2098f005ef32Sjsg 		uint8_t bw, uint8_t result);
2099f005ef32Sjsg 
2100f005ef32Sjsg /*
2101f005ef32Sjsg  * Handle the USB4 BW Allocation related functionality here:
2102f005ef32Sjsg  * Plug => Try to allocate max bw from timing parameters supported by the sink
2103f005ef32Sjsg  * Unplug => de-allocate bw
2104f005ef32Sjsg  *
2105f005ef32Sjsg  * @link: pointer to the dc_link struct instance
2106f005ef32Sjsg  * @peak_bw: Peak bw used by the link/sink
2107f005ef32Sjsg  *
2108f005ef32Sjsg  * return: allocated bw else return 0
2109f005ef32Sjsg  */
2110f005ef32Sjsg int dc_link_dp_dpia_handle_usb4_bandwidth_allocation_for_link(
2111f005ef32Sjsg 		struct dc_link *link, int peak_bw);
2112f005ef32Sjsg 
2113f005ef32Sjsg /*
2114f005ef32Sjsg  * Validate the BW of all the valid DPIA links to make sure it doesn't exceed
2115f005ef32Sjsg  * available BW for each host router
2116f005ef32Sjsg  *
2117f005ef32Sjsg  * @dc: pointer to dc struct
2118f005ef32Sjsg  * @stream: pointer to all possible streams
2119*a0689bdcSjsg  * @count: number of valid DPIA streams
2120f005ef32Sjsg  *
2121f005ef32Sjsg  * return: TRUE if bw used by DPIAs doesn't exceed available BW else return FALSE
2122f005ef32Sjsg  */
2123*a0689bdcSjsg bool dc_link_dp_dpia_validate(struct dc *dc, const struct dc_stream_state *streams,
2124f005ef32Sjsg 		const unsigned int count);
2125f005ef32Sjsg 
2126539d1f6aSjsg /* Sink Interfaces - A sink corresponds to a display output device */
2127fb4d8502Sjsg 
2128fb4d8502Sjsg struct dc_container_id {
2129fb4d8502Sjsg 	// 128bit GUID in binary form
2130fb4d8502Sjsg 	unsigned char  guid[16];
2131fb4d8502Sjsg 	// 8 byte port ID -> ELD.PortID
2132fb4d8502Sjsg 	unsigned int   portId[2];
2133fb4d8502Sjsg 	// 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
2134fb4d8502Sjsg 	unsigned short manufacturerName;
2135fb4d8502Sjsg 	// 2 byte product code -> ELD.ProductCode
2136fb4d8502Sjsg 	unsigned short productCode;
2137fb4d8502Sjsg };
2138fb4d8502Sjsg 
2139fb4d8502Sjsg 
2140c349dbc7Sjsg struct dc_sink_dsc_caps {
2141c349dbc7Sjsg 	// 'true' if these are virtual DPCD's DSC caps (immediately upstream of sink in MST topology),
2142c349dbc7Sjsg 	// 'false' if they are sink's DSC caps
2143c349dbc7Sjsg 	bool is_virtual_dpcd_dsc;
2144f005ef32Sjsg #if defined(CONFIG_DRM_AMD_DC_FP)
21451bb76ff1Sjsg 	// 'true' if MST topology supports DSC passthrough for sink
21461bb76ff1Sjsg 	// 'false' if MST topology does not support DSC passthrough
21471bb76ff1Sjsg 	bool is_dsc_passthrough_supported;
21481bb76ff1Sjsg #endif
2149c349dbc7Sjsg 	struct dsc_dec_dpcd_caps dsc_dec_caps;
2150c349dbc7Sjsg };
2151c349dbc7Sjsg 
2152c349dbc7Sjsg struct dc_sink_fec_caps {
2153c349dbc7Sjsg 	bool is_rx_fec_supported;
2154c349dbc7Sjsg 	bool is_topology_fec_supported;
2155c349dbc7Sjsg };
2156fb4d8502Sjsg 
2157f005ef32Sjsg struct scdc_caps {
2158f005ef32Sjsg 	union hdmi_scdc_manufacturer_OUI_data manufacturer_OUI;
2159f005ef32Sjsg 	union hdmi_scdc_device_id_data device_id;
2160f005ef32Sjsg };
2161f005ef32Sjsg 
2162fb4d8502Sjsg /*
2163fb4d8502Sjsg  * The sink structure contains EDID and other display device properties
2164fb4d8502Sjsg  */
2165fb4d8502Sjsg struct dc_sink {
2166fb4d8502Sjsg 	enum amd_signal_type sink_signal;
2167fb4d8502Sjsg 	struct dc_edid dc_edid; /* raw edid */
2168fb4d8502Sjsg 	struct dc_edid_caps edid_caps; /* parse display caps */
2169fb4d8502Sjsg 	struct dc_container_id *dc_container_id;
2170fb4d8502Sjsg 	uint32_t dongle_max_pix_clk;
2171fb4d8502Sjsg 	void *priv;
2172fb4d8502Sjsg 	struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
2173fb4d8502Sjsg 	bool converter_disable_audio;
21745ca02815Sjsg 
2175f005ef32Sjsg 	struct scdc_caps scdc_caps;
2176c349dbc7Sjsg 	struct dc_sink_dsc_caps dsc_caps;
2177c349dbc7Sjsg 	struct dc_sink_fec_caps fec_caps;
2178c349dbc7Sjsg 
2179c349dbc7Sjsg 	bool is_vsc_sdp_colorimetry_supported;
2180c349dbc7Sjsg 
2181fb4d8502Sjsg 	/* private to DC core */
2182fb4d8502Sjsg 	struct dc_link *link;
2183fb4d8502Sjsg 	struct dc_context *ctx;
2184fb4d8502Sjsg 
2185fb4d8502Sjsg 	uint32_t sink_id;
2186fb4d8502Sjsg 
2187fb4d8502Sjsg 	/* private to dc_sink.c */
2188fb4d8502Sjsg 	// refcount must be the last member in dc_sink, since we want the
2189fb4d8502Sjsg 	// sink structure to be logically cloneable up to (but not including)
2190fb4d8502Sjsg 	// refcount
2191fb4d8502Sjsg 	struct kref refcount;
2192fb4d8502Sjsg };
2193fb4d8502Sjsg 
2194fb4d8502Sjsg void dc_sink_retain(struct dc_sink *sink);
2195fb4d8502Sjsg void dc_sink_release(struct dc_sink *sink);
2196fb4d8502Sjsg 
2197fb4d8502Sjsg struct dc_sink_init_data {
2198fb4d8502Sjsg 	enum amd_signal_type sink_signal;
2199fb4d8502Sjsg 	struct dc_link *link;
2200fb4d8502Sjsg 	uint32_t dongle_max_pix_clk;
2201fb4d8502Sjsg 	bool converter_disable_audio;
2202fb4d8502Sjsg };
2203fb4d8502Sjsg 
2204fb4d8502Sjsg struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
2205fb4d8502Sjsg 
2206fb4d8502Sjsg /* Newer interfaces  */
2207fb4d8502Sjsg struct dc_cursor {
2208fb4d8502Sjsg 	struct dc_plane_address address;
2209fb4d8502Sjsg 	struct dc_cursor_attributes attributes;
2210fb4d8502Sjsg };
2211fb4d8502Sjsg 
2212fb4d8502Sjsg 
2213539d1f6aSjsg /* Interrupt interfaces */
2214fb4d8502Sjsg enum dc_irq_source dc_interrupt_to_irq_source(
2215fb4d8502Sjsg 		struct dc *dc,
2216fb4d8502Sjsg 		uint32_t src_id,
2217fb4d8502Sjsg 		uint32_t ext_id);
2218fb4d8502Sjsg bool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable);
2219fb4d8502Sjsg void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
2220fb4d8502Sjsg enum dc_irq_source dc_get_hpd_irq_source_at_index(
2221fb4d8502Sjsg 		struct dc *dc, uint32_t link_index);
2222fb4d8502Sjsg 
22231bb76ff1Sjsg void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable);
22241bb76ff1Sjsg 
2225539d1f6aSjsg /* Power Interfaces */
2226fb4d8502Sjsg 
2227fb4d8502Sjsg void dc_set_power_state(
2228fb4d8502Sjsg 		struct dc *dc,
2229fb4d8502Sjsg 		enum dc_acpi_cm_power_state power_state);
2230fb4d8502Sjsg void dc_resume(struct dc *dc);
2231fb4d8502Sjsg 
2232ad8b1aafSjsg void dc_power_down_on_boot(struct dc *dc);
2233ad8b1aafSjsg 
2234ad8b1aafSjsg /*
2235ad8b1aafSjsg  * HDCP Interfaces
2236ad8b1aafSjsg  */
2237ad8b1aafSjsg enum hdcp_message_status dc_process_hdcp_msg(
2238ad8b1aafSjsg 		enum amd_signal_type signal,
2239ad8b1aafSjsg 		struct dc_link *link,
2240ad8b1aafSjsg 		struct hdcp_protection_message *message_info);
2241c349dbc7Sjsg bool dc_is_dmcu_initialized(struct dc *dc);
2242c349dbc7Sjsg 
2243c349dbc7Sjsg enum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping);
2244c349dbc7Sjsg void dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg);
2245ad8b1aafSjsg 
22465ca02815Sjsg bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc, struct dc_plane_state *plane,
22475ca02815Sjsg 				struct dc_cursor_attributes *cursor_attr);
2248ad8b1aafSjsg 
2249ad8b1aafSjsg void dc_allow_idle_optimizations(struct dc *dc, bool allow);
2250ad8b1aafSjsg 
22511bb76ff1Sjsg /* set min and max memory clock to lowest and highest DPM level, respectively */
2252ad8b1aafSjsg void dc_unlock_memory_clock_frequency(struct dc *dc);
2253ad8b1aafSjsg 
22541bb76ff1Sjsg /* set min memory clock to the min required for current mode, max to maxDPM */
2255ad8b1aafSjsg void dc_lock_memory_clock_frequency(struct dc *dc);
2256ad8b1aafSjsg 
22571bb76ff1Sjsg /* set soft max for memclk, to be used for AC/DC switching clock limitations */
22581bb76ff1Sjsg void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable);
22591bb76ff1Sjsg 
22605ca02815Sjsg /* cleanup on driver unload */
22615ca02815Sjsg void dc_hardware_release(struct dc *dc);
22625ca02815Sjsg 
22631bb76ff1Sjsg /* disables fw based mclk switch */
22641bb76ff1Sjsg void dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(struct dc *dc);
2265ad8b1aafSjsg 
2266ad8b1aafSjsg bool dc_set_psr_allow_active(struct dc *dc, bool enable);
22671bb76ff1Sjsg void dc_z10_restore(const struct dc *dc);
22685ca02815Sjsg void dc_z10_save_init(struct dc *dc);
22695ca02815Sjsg 
22701bb76ff1Sjsg bool dc_is_dmub_outbox_supported(struct dc *dc);
22715ca02815Sjsg bool dc_enable_dmub_notifications(struct dc *dc);
22725ca02815Sjsg 
2273f005ef32Sjsg bool dc_abm_save_restore(
2274f005ef32Sjsg 		struct dc *dc,
2275f005ef32Sjsg 		struct dc_stream_state *stream,
2276f005ef32Sjsg 		struct abm_save_restore *pData);
2277f005ef32Sjsg 
22781bb76ff1Sjsg void dc_enable_dmub_outbox(struct dc *dc);
22791bb76ff1Sjsg 
22805ca02815Sjsg bool dc_process_dmub_aux_transfer_async(struct dc *dc,
22815ca02815Sjsg 				uint32_t link_index,
22825ca02815Sjsg 				struct aux_payload *payload);
2283ad8b1aafSjsg 
22841bb76ff1Sjsg /* Get dc link index from dpia port index */
22851bb76ff1Sjsg uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,
22861bb76ff1Sjsg 				uint8_t dpia_port_index);
22871bb76ff1Sjsg 
22881bb76ff1Sjsg bool dc_process_dmub_set_config_async(struct dc *dc,
22891bb76ff1Sjsg 				uint32_t link_index,
22901bb76ff1Sjsg 				struct set_config_cmd_payload *payload,
22911bb76ff1Sjsg 				struct dmub_notification *notify);
22921bb76ff1Sjsg 
22931bb76ff1Sjsg enum dc_status dc_process_dmub_set_mst_slots(const struct dc *dc,
22941bb76ff1Sjsg 				uint32_t link_index,
22951bb76ff1Sjsg 				uint8_t mst_alloc_slots,
22961bb76ff1Sjsg 				uint8_t *mst_slots_in_use);
22971bb76ff1Sjsg 
22981bb76ff1Sjsg void dc_process_dmub_dpia_hpd_int_enable(const struct dc *dc,
22991bb76ff1Sjsg 				uint32_t hpd_int_enable);
23001bb76ff1Sjsg 
2301f005ef32Sjsg void dc_print_dmub_diagnostic_data(const struct dc *dc);
2302f005ef32Sjsg 
2303f005ef32Sjsg void dc_query_current_properties(struct dc *dc, struct dc_current_properties *properties);
2304f005ef32Sjsg 
2305539d1f6aSjsg /* DSC Interfaces */
2306c349dbc7Sjsg #include "dc_dsc.h"
23075ca02815Sjsg 
2308539d1f6aSjsg /* Disable acc mode Interfaces */
23095ca02815Sjsg void dc_disable_accelerated_mode(struct dc *dc);
23105ca02815Sjsg 
2311f005ef32Sjsg bool dc_is_timing_changed(struct dc_stream_state *cur_stream,
2312f005ef32Sjsg 		       struct dc_stream_state *new_stream);
2313f005ef32Sjsg 
2314fb4d8502Sjsg #endif /* DC_INTERFACE_H_ */
2315