162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * Copyright 2012-2023 Advanced Micro Devices, Inc.
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
562306a36Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
662306a36Sopenharmony_ci * to deal in the Software without restriction, including without limitation
762306a36Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense,
862306a36Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the
962306a36Sopenharmony_ci * Software is furnished to do so, subject to the following conditions:
1062306a36Sopenharmony_ci *
1162306a36Sopenharmony_ci * The above copyright notice and this permission notice shall be included in
1262306a36Sopenharmony_ci * all copies or substantial portions of the Software.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1562306a36Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1662306a36Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1762306a36Sopenharmony_ci * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
1862306a36Sopenharmony_ci * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
1962306a36Sopenharmony_ci * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
2062306a36Sopenharmony_ci * OTHER DEALINGS IN THE SOFTWARE.
2162306a36Sopenharmony_ci *
2262306a36Sopenharmony_ci * Authors: AMD
2362306a36Sopenharmony_ci *
2462306a36Sopenharmony_ci */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#ifndef DC_INTERFACE_H_
2762306a36Sopenharmony_ci#define DC_INTERFACE_H_
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci#include "dc_types.h"
3062306a36Sopenharmony_ci#include "grph_object_defs.h"
3162306a36Sopenharmony_ci#include "logger_types.h"
3262306a36Sopenharmony_ci#include "hdcp_msg_types.h"
3362306a36Sopenharmony_ci#include "gpio_types.h"
3462306a36Sopenharmony_ci#include "link_service_types.h"
3562306a36Sopenharmony_ci#include "grph_object_ctrl_defs.h"
3662306a36Sopenharmony_ci#include <inc/hw/opp.h>
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ci#include "inc/hw_sequencer.h"
3962306a36Sopenharmony_ci#include "inc/compressor.h"
4062306a36Sopenharmony_ci#include "inc/hw/dmcu.h"
4162306a36Sopenharmony_ci#include "dml/display_mode_lib.h"
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_cistruct abm_save_restore;
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci/* forward declaration */
4662306a36Sopenharmony_cistruct aux_payload;
4762306a36Sopenharmony_cistruct set_config_cmd_payload;
4862306a36Sopenharmony_cistruct dmub_notification;
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci#define DC_VER "3.2.247"
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define MAX_SURFACES 3
5362306a36Sopenharmony_ci#define MAX_PLANES 6
5462306a36Sopenharmony_ci#define MAX_STREAMS 6
5562306a36Sopenharmony_ci#define MIN_VIEWPORT_SIZE 12
5662306a36Sopenharmony_ci#define MAX_NUM_EDP 2
5762306a36Sopenharmony_ci
5862306a36Sopenharmony_ci/* Display Core Interfaces */
5962306a36Sopenharmony_cistruct dc_versions {
6062306a36Sopenharmony_ci	const char *dc_ver;
6162306a36Sopenharmony_ci	struct dmcu_version dmcu_version;
6262306a36Sopenharmony_ci};
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_cienum dp_protocol_version {
6562306a36Sopenharmony_ci	DP_VERSION_1_4 = 0,
6662306a36Sopenharmony_ci	DP_VERSION_2_1,
6762306a36Sopenharmony_ci	DP_VERSION_UNKNOWN,
6862306a36Sopenharmony_ci};
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_cienum dc_plane_type {
7162306a36Sopenharmony_ci	DC_PLANE_TYPE_INVALID,
7262306a36Sopenharmony_ci	DC_PLANE_TYPE_DCE_RGB,
7362306a36Sopenharmony_ci	DC_PLANE_TYPE_DCE_UNDERLAY,
7462306a36Sopenharmony_ci	DC_PLANE_TYPE_DCN_UNIVERSAL,
7562306a36Sopenharmony_ci};
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci// Sizes defined as multiples of 64KB
7862306a36Sopenharmony_cienum det_size {
7962306a36Sopenharmony_ci	DET_SIZE_DEFAULT = 0,
8062306a36Sopenharmony_ci	DET_SIZE_192KB = 3,
8162306a36Sopenharmony_ci	DET_SIZE_256KB = 4,
8262306a36Sopenharmony_ci	DET_SIZE_320KB = 5,
8362306a36Sopenharmony_ci	DET_SIZE_384KB = 6
8462306a36Sopenharmony_ci};
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_cistruct dc_plane_cap {
8862306a36Sopenharmony_ci	enum dc_plane_type type;
8962306a36Sopenharmony_ci	uint32_t per_pixel_alpha : 1;
9062306a36Sopenharmony_ci	struct {
9162306a36Sopenharmony_ci		uint32_t argb8888 : 1;
9262306a36Sopenharmony_ci		uint32_t nv12 : 1;
9362306a36Sopenharmony_ci		uint32_t fp16 : 1;
9462306a36Sopenharmony_ci		uint32_t p010 : 1;
9562306a36Sopenharmony_ci		uint32_t ayuv : 1;
9662306a36Sopenharmony_ci	} pixel_format_support;
9762306a36Sopenharmony_ci	// max upscaling factor x1000
9862306a36Sopenharmony_ci	// upscaling factors are always >= 1
9962306a36Sopenharmony_ci	// for example, 1080p -> 8K is 4.0, or 4000 raw value
10062306a36Sopenharmony_ci	struct {
10162306a36Sopenharmony_ci		uint32_t argb8888;
10262306a36Sopenharmony_ci		uint32_t nv12;
10362306a36Sopenharmony_ci		uint32_t fp16;
10462306a36Sopenharmony_ci	} max_upscale_factor;
10562306a36Sopenharmony_ci	// max downscale factor x1000
10662306a36Sopenharmony_ci	// downscale factors are always <= 1
10762306a36Sopenharmony_ci	// for example, 8K -> 1080p is 0.25, or 250 raw value
10862306a36Sopenharmony_ci	struct {
10962306a36Sopenharmony_ci		uint32_t argb8888;
11062306a36Sopenharmony_ci		uint32_t nv12;
11162306a36Sopenharmony_ci		uint32_t fp16;
11262306a36Sopenharmony_ci	} max_downscale_factor;
11362306a36Sopenharmony_ci	// minimal width/height
11462306a36Sopenharmony_ci	uint32_t min_width;
11562306a36Sopenharmony_ci	uint32_t min_height;
11662306a36Sopenharmony_ci};
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/**
11962306a36Sopenharmony_ci * DOC: color-management-caps
12062306a36Sopenharmony_ci *
12162306a36Sopenharmony_ci * **Color management caps (DPP and MPC)**
12262306a36Sopenharmony_ci *
12362306a36Sopenharmony_ci * Modules/color calculates various color operations which are translated to
12462306a36Sopenharmony_ci * abstracted HW. DCE 5-12 had almost no important changes, but starting with
12562306a36Sopenharmony_ci * DCN1, every new generation comes with fairly major differences in color
12662306a36Sopenharmony_ci * pipeline. Therefore, we abstract color pipe capabilities so modules/DM can
12762306a36Sopenharmony_ci * decide mapping to HW block based on logical capabilities.
12862306a36Sopenharmony_ci */
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci/**
13162306a36Sopenharmony_ci * struct rom_curve_caps - predefined transfer function caps for degamma and regamma
13262306a36Sopenharmony_ci * @srgb: RGB color space transfer func
13362306a36Sopenharmony_ci * @bt2020: BT.2020 transfer func
13462306a36Sopenharmony_ci * @gamma2_2: standard gamma
13562306a36Sopenharmony_ci * @pq: perceptual quantizer transfer function
13662306a36Sopenharmony_ci * @hlg: hybrid log–gamma transfer function
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_cistruct rom_curve_caps {
13962306a36Sopenharmony_ci	uint16_t srgb : 1;
14062306a36Sopenharmony_ci	uint16_t bt2020 : 1;
14162306a36Sopenharmony_ci	uint16_t gamma2_2 : 1;
14262306a36Sopenharmony_ci	uint16_t pq : 1;
14362306a36Sopenharmony_ci	uint16_t hlg : 1;
14462306a36Sopenharmony_ci};
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci/**
14762306a36Sopenharmony_ci * struct dpp_color_caps - color pipeline capabilities for display pipe and
14862306a36Sopenharmony_ci * plane blocks
14962306a36Sopenharmony_ci *
15062306a36Sopenharmony_ci * @dcn_arch: all DCE generations treated the same
15162306a36Sopenharmony_ci * @input_lut_shared: shared with DGAM. Input LUT is different than most LUTs,
15262306a36Sopenharmony_ci * just plain 256-entry lookup
15362306a36Sopenharmony_ci * @icsc: input color space conversion
15462306a36Sopenharmony_ci * @dgam_ram: programmable degamma LUT
15562306a36Sopenharmony_ci * @post_csc: post color space conversion, before gamut remap
15662306a36Sopenharmony_ci * @gamma_corr: degamma correction
15762306a36Sopenharmony_ci * @hw_3d_lut: 3D LUT support. It implies a shaper LUT before. It may be shared
15862306a36Sopenharmony_ci * with MPC by setting mpc:shared_3d_lut flag
15962306a36Sopenharmony_ci * @ogam_ram: programmable out/blend gamma LUT
16062306a36Sopenharmony_ci * @ocsc: output color space conversion
16162306a36Sopenharmony_ci * @dgam_rom_for_yuv: pre-defined degamma LUT for YUV planes
16262306a36Sopenharmony_ci * @dgam_rom_caps: pre-definied curve caps for degamma 1D LUT
16362306a36Sopenharmony_ci * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
16462306a36Sopenharmony_ci *
16562306a36Sopenharmony_ci * Note: hdr_mult and gamut remap (CTM) are always available in DPP (in that order)
16662306a36Sopenharmony_ci */
16762306a36Sopenharmony_cistruct dpp_color_caps {
16862306a36Sopenharmony_ci	uint16_t dcn_arch : 1;
16962306a36Sopenharmony_ci	uint16_t input_lut_shared : 1;
17062306a36Sopenharmony_ci	uint16_t icsc : 1;
17162306a36Sopenharmony_ci	uint16_t dgam_ram : 1;
17262306a36Sopenharmony_ci	uint16_t post_csc : 1;
17362306a36Sopenharmony_ci	uint16_t gamma_corr : 1;
17462306a36Sopenharmony_ci	uint16_t hw_3d_lut : 1;
17562306a36Sopenharmony_ci	uint16_t ogam_ram : 1;
17662306a36Sopenharmony_ci	uint16_t ocsc : 1;
17762306a36Sopenharmony_ci	uint16_t dgam_rom_for_yuv : 1;
17862306a36Sopenharmony_ci	struct rom_curve_caps dgam_rom_caps;
17962306a36Sopenharmony_ci	struct rom_curve_caps ogam_rom_caps;
18062306a36Sopenharmony_ci};
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci/**
18362306a36Sopenharmony_ci * struct mpc_color_caps - color pipeline capabilities for multiple pipe and
18462306a36Sopenharmony_ci * plane combined blocks
18562306a36Sopenharmony_ci *
18662306a36Sopenharmony_ci * @gamut_remap: color transformation matrix
18762306a36Sopenharmony_ci * @ogam_ram: programmable out gamma LUT
18862306a36Sopenharmony_ci * @ocsc: output color space conversion matrix
18962306a36Sopenharmony_ci * @num_3dluts: MPC 3D LUT; always assumes a preceding shaper LUT
19062306a36Sopenharmony_ci * @shared_3d_lut: shared 3D LUT flag. Can be either DPP or MPC, but single
19162306a36Sopenharmony_ci * instance
19262306a36Sopenharmony_ci * @ogam_rom_caps: pre-definied curve caps for regamma 1D LUT
19362306a36Sopenharmony_ci */
19462306a36Sopenharmony_cistruct mpc_color_caps {
19562306a36Sopenharmony_ci	uint16_t gamut_remap : 1;
19662306a36Sopenharmony_ci	uint16_t ogam_ram : 1;
19762306a36Sopenharmony_ci	uint16_t ocsc : 1;
19862306a36Sopenharmony_ci	uint16_t num_3dluts : 3;
19962306a36Sopenharmony_ci	uint16_t shared_3d_lut:1;
20062306a36Sopenharmony_ci	struct rom_curve_caps ogam_rom_caps;
20162306a36Sopenharmony_ci};
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci/**
20462306a36Sopenharmony_ci * struct dc_color_caps - color pipes capabilities for DPP and MPC hw blocks
20562306a36Sopenharmony_ci * @dpp: color pipes caps for DPP
20662306a36Sopenharmony_ci * @mpc: color pipes caps for MPC
20762306a36Sopenharmony_ci */
20862306a36Sopenharmony_cistruct dc_color_caps {
20962306a36Sopenharmony_ci	struct dpp_color_caps dpp;
21062306a36Sopenharmony_ci	struct mpc_color_caps mpc;
21162306a36Sopenharmony_ci};
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_cistruct dc_dmub_caps {
21462306a36Sopenharmony_ci	bool psr;
21562306a36Sopenharmony_ci	bool mclk_sw;
21662306a36Sopenharmony_ci	bool subvp_psr;
21762306a36Sopenharmony_ci	bool gecc_enable;
21862306a36Sopenharmony_ci};
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_cistruct dc_caps {
22162306a36Sopenharmony_ci	uint32_t max_streams;
22262306a36Sopenharmony_ci	uint32_t max_links;
22362306a36Sopenharmony_ci	uint32_t max_audios;
22462306a36Sopenharmony_ci	uint32_t max_slave_planes;
22562306a36Sopenharmony_ci	uint32_t max_slave_yuv_planes;
22662306a36Sopenharmony_ci	uint32_t max_slave_rgb_planes;
22762306a36Sopenharmony_ci	uint32_t max_planes;
22862306a36Sopenharmony_ci	uint32_t max_downscale_ratio;
22962306a36Sopenharmony_ci	uint32_t i2c_speed_in_khz;
23062306a36Sopenharmony_ci	uint32_t i2c_speed_in_khz_hdcp;
23162306a36Sopenharmony_ci	uint32_t dmdata_alloc_size;
23262306a36Sopenharmony_ci	unsigned int max_cursor_size;
23362306a36Sopenharmony_ci	unsigned int max_video_width;
23462306a36Sopenharmony_ci	/*
23562306a36Sopenharmony_ci	 * max video plane width that can be safely assumed to be always
23662306a36Sopenharmony_ci	 * supported by single DPP pipe.
23762306a36Sopenharmony_ci	 */
23862306a36Sopenharmony_ci	unsigned int max_optimizable_video_width;
23962306a36Sopenharmony_ci	unsigned int min_horizontal_blanking_period;
24062306a36Sopenharmony_ci	int linear_pitch_alignment;
24162306a36Sopenharmony_ci	bool dcc_const_color;
24262306a36Sopenharmony_ci	bool dynamic_audio;
24362306a36Sopenharmony_ci	bool is_apu;
24462306a36Sopenharmony_ci	bool dual_link_dvi;
24562306a36Sopenharmony_ci	bool post_blend_color_processing;
24662306a36Sopenharmony_ci	bool force_dp_tps4_for_cp2520;
24762306a36Sopenharmony_ci	bool disable_dp_clk_share;
24862306a36Sopenharmony_ci	bool psp_setup_panel_mode;
24962306a36Sopenharmony_ci	bool extended_aux_timeout_support;
25062306a36Sopenharmony_ci	bool dmcub_support;
25162306a36Sopenharmony_ci	bool zstate_support;
25262306a36Sopenharmony_ci	uint32_t num_of_internal_disp;
25362306a36Sopenharmony_ci	enum dp_protocol_version max_dp_protocol_version;
25462306a36Sopenharmony_ci	unsigned int mall_size_per_mem_channel;
25562306a36Sopenharmony_ci	unsigned int mall_size_total;
25662306a36Sopenharmony_ci	unsigned int cursor_cache_size;
25762306a36Sopenharmony_ci	struct dc_plane_cap planes[MAX_PLANES];
25862306a36Sopenharmony_ci	struct dc_color_caps color;
25962306a36Sopenharmony_ci	struct dc_dmub_caps dmub_caps;
26062306a36Sopenharmony_ci	bool dp_hpo;
26162306a36Sopenharmony_ci	bool dp_hdmi21_pcon_support;
26262306a36Sopenharmony_ci	bool edp_dsc_support;
26362306a36Sopenharmony_ci	bool vbios_lttpr_aware;
26462306a36Sopenharmony_ci	bool vbios_lttpr_enable;
26562306a36Sopenharmony_ci	uint32_t max_otg_num;
26662306a36Sopenharmony_ci	uint32_t max_cab_allocation_bytes;
26762306a36Sopenharmony_ci	uint32_t cache_line_size;
26862306a36Sopenharmony_ci	uint32_t cache_num_ways;
26962306a36Sopenharmony_ci	uint16_t subvp_fw_processing_delay_us;
27062306a36Sopenharmony_ci	uint8_t subvp_drr_max_vblank_margin_us;
27162306a36Sopenharmony_ci	uint16_t subvp_prefetch_end_to_mall_start_us;
27262306a36Sopenharmony_ci	uint8_t subvp_swath_height_margin_lines; // subvp start line must be aligned to 2 x swath height
27362306a36Sopenharmony_ci	uint16_t subvp_pstate_allow_width_us;
27462306a36Sopenharmony_ci	uint16_t subvp_vertical_int_margin_us;
27562306a36Sopenharmony_ci	bool seamless_odm;
27662306a36Sopenharmony_ci	uint32_t max_v_total;
27762306a36Sopenharmony_ci	uint8_t subvp_drr_vblank_start_margin_us;
27862306a36Sopenharmony_ci};
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_cistruct dc_bug_wa {
28162306a36Sopenharmony_ci	bool no_connect_phy_config;
28262306a36Sopenharmony_ci	bool dedcn20_305_wa;
28362306a36Sopenharmony_ci	bool skip_clock_update;
28462306a36Sopenharmony_ci	bool lt_early_cr_pattern;
28562306a36Sopenharmony_ci	struct {
28662306a36Sopenharmony_ci		uint8_t uclk : 1;
28762306a36Sopenharmony_ci		uint8_t fclk : 1;
28862306a36Sopenharmony_ci		uint8_t dcfclk : 1;
28962306a36Sopenharmony_ci		uint8_t dcfclk_ds: 1;
29062306a36Sopenharmony_ci	} clock_update_disable_mask;
29162306a36Sopenharmony_ci};
29262306a36Sopenharmony_cistruct dc_dcc_surface_param {
29362306a36Sopenharmony_ci	struct dc_size surface_size;
29462306a36Sopenharmony_ci	enum surface_pixel_format format;
29562306a36Sopenharmony_ci	enum swizzle_mode_values swizzle_mode;
29662306a36Sopenharmony_ci	enum dc_scan_direction scan;
29762306a36Sopenharmony_ci};
29862306a36Sopenharmony_ci
29962306a36Sopenharmony_cistruct dc_dcc_setting {
30062306a36Sopenharmony_ci	unsigned int max_compressed_blk_size;
30162306a36Sopenharmony_ci	unsigned int max_uncompressed_blk_size;
30262306a36Sopenharmony_ci	bool independent_64b_blks;
30362306a36Sopenharmony_ci	//These bitfields to be used starting with DCN
30462306a36Sopenharmony_ci	struct {
30562306a36Sopenharmony_ci		uint32_t dcc_256_64_64 : 1;//available in ASICs before DCN (the worst compression case)
30662306a36Sopenharmony_ci		uint32_t dcc_128_128_uncontrained : 1;  //available in ASICs before DCN
30762306a36Sopenharmony_ci		uint32_t dcc_256_128_128 : 1;		//available starting with DCN
30862306a36Sopenharmony_ci		uint32_t dcc_256_256_unconstrained : 1;  //available in ASICs before DCN (the best compression case)
30962306a36Sopenharmony_ci	} dcc_controls;
31062306a36Sopenharmony_ci};
31162306a36Sopenharmony_ci
31262306a36Sopenharmony_cistruct dc_surface_dcc_cap {
31362306a36Sopenharmony_ci	union {
31462306a36Sopenharmony_ci		struct {
31562306a36Sopenharmony_ci			struct dc_dcc_setting rgb;
31662306a36Sopenharmony_ci		} grph;
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci		struct {
31962306a36Sopenharmony_ci			struct dc_dcc_setting luma;
32062306a36Sopenharmony_ci			struct dc_dcc_setting chroma;
32162306a36Sopenharmony_ci		} video;
32262306a36Sopenharmony_ci	};
32362306a36Sopenharmony_ci
32462306a36Sopenharmony_ci	bool capable;
32562306a36Sopenharmony_ci	bool const_color_support;
32662306a36Sopenharmony_ci};
32762306a36Sopenharmony_ci
32862306a36Sopenharmony_cistruct dc_static_screen_params {
32962306a36Sopenharmony_ci	struct {
33062306a36Sopenharmony_ci		bool force_trigger;
33162306a36Sopenharmony_ci		bool cursor_update;
33262306a36Sopenharmony_ci		bool surface_update;
33362306a36Sopenharmony_ci		bool overlay_update;
33462306a36Sopenharmony_ci	} triggers;
33562306a36Sopenharmony_ci	unsigned int num_frames;
33662306a36Sopenharmony_ci};
33762306a36Sopenharmony_ci
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ci/* Surface update type is used by dc_update_surfaces_and_stream
34062306a36Sopenharmony_ci * The update type is determined at the very beginning of the function based
34162306a36Sopenharmony_ci * on parameters passed in and decides how much programming (or updating) is
34262306a36Sopenharmony_ci * going to be done during the call.
34362306a36Sopenharmony_ci *
34462306a36Sopenharmony_ci * UPDATE_TYPE_FAST is used for really fast updates that do not require much
34562306a36Sopenharmony_ci * logical calculations or hardware register programming. This update MUST be
34662306a36Sopenharmony_ci * ISR safe on windows. Currently fast update will only be used to flip surface
34762306a36Sopenharmony_ci * address.
34862306a36Sopenharmony_ci *
34962306a36Sopenharmony_ci * UPDATE_TYPE_MED is used for slower updates which require significant hw
35062306a36Sopenharmony_ci * re-programming however do not affect bandwidth consumption or clock
35162306a36Sopenharmony_ci * requirements. At present, this is the level at which front end updates
35262306a36Sopenharmony_ci * that do not require us to run bw_calcs happen. These are in/out transfer func
35362306a36Sopenharmony_ci * updates, viewport offset changes, recout size changes and pixel depth changes.
35462306a36Sopenharmony_ci * This update can be done at ISR, but we want to minimize how often this happens.
35562306a36Sopenharmony_ci *
35662306a36Sopenharmony_ci * UPDATE_TYPE_FULL is slow. Really slow. This requires us to recalculate our
35762306a36Sopenharmony_ci * bandwidth and clocks, possibly rearrange some pipes and reprogram anything front
35862306a36Sopenharmony_ci * end related. Any time viewport dimensions, recout dimensions, scaling ratios or
35962306a36Sopenharmony_ci * gamma need to be adjusted or pipe needs to be turned on (or disconnected) we do
36062306a36Sopenharmony_ci * a full update. This cannot be done at ISR level and should be a rare event.
36162306a36Sopenharmony_ci * Unless someone is stress testing mpo enter/exit, playing with colour or adjusting
36262306a36Sopenharmony_ci * underscan we don't expect to see this call at all.
36362306a36Sopenharmony_ci */
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_cienum surface_update_type {
36662306a36Sopenharmony_ci	UPDATE_TYPE_FAST, /* super fast, safe to execute in isr */
36762306a36Sopenharmony_ci	UPDATE_TYPE_MED,  /* ISR safe, most of programming needed, no bw/clk change*/
36862306a36Sopenharmony_ci	UPDATE_TYPE_FULL, /* may need to shuffle resources */
36962306a36Sopenharmony_ci};
37062306a36Sopenharmony_ci
37162306a36Sopenharmony_ci/* Forward declaration*/
37262306a36Sopenharmony_cistruct dc;
37362306a36Sopenharmony_cistruct dc_plane_state;
37462306a36Sopenharmony_cistruct dc_state;
37562306a36Sopenharmony_ci
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_cistruct dc_cap_funcs {
37862306a36Sopenharmony_ci	bool (*get_dcc_compression_cap)(const struct dc *dc,
37962306a36Sopenharmony_ci			const struct dc_dcc_surface_param *input,
38062306a36Sopenharmony_ci			struct dc_surface_dcc_cap *output);
38162306a36Sopenharmony_ci};
38262306a36Sopenharmony_ci
38362306a36Sopenharmony_cistruct link_training_settings;
38462306a36Sopenharmony_ci
38562306a36Sopenharmony_ciunion allow_lttpr_non_transparent_mode {
38662306a36Sopenharmony_ci	struct {
38762306a36Sopenharmony_ci		bool DP1_4A : 1;
38862306a36Sopenharmony_ci		bool DP2_0 : 1;
38962306a36Sopenharmony_ci	} bits;
39062306a36Sopenharmony_ci	unsigned char raw;
39162306a36Sopenharmony_ci};
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci/* Structure to hold configuration flags set by dm at dc creation. */
39462306a36Sopenharmony_cistruct dc_config {
39562306a36Sopenharmony_ci	bool gpu_vm_support;
39662306a36Sopenharmony_ci	bool disable_disp_pll_sharing;
39762306a36Sopenharmony_ci	bool fbc_support;
39862306a36Sopenharmony_ci	bool disable_fractional_pwm;
39962306a36Sopenharmony_ci	bool allow_seamless_boot_optimization;
40062306a36Sopenharmony_ci	bool seamless_boot_edp_requested;
40162306a36Sopenharmony_ci	bool edp_not_connected;
40262306a36Sopenharmony_ci	bool edp_no_power_sequencing;
40362306a36Sopenharmony_ci	bool force_enum_edp;
40462306a36Sopenharmony_ci	bool forced_clocks;
40562306a36Sopenharmony_ci	union allow_lttpr_non_transparent_mode allow_lttpr_non_transparent_mode;
40662306a36Sopenharmony_ci	bool multi_mon_pp_mclk_switch;
40762306a36Sopenharmony_ci	bool disable_dmcu;
40862306a36Sopenharmony_ci	bool enable_4to1MPC;
40962306a36Sopenharmony_ci	bool enable_windowed_mpo_odm;
41062306a36Sopenharmony_ci	bool forceHBR2CP2520; // Used for switching between test patterns TPS4 and CP2520
41162306a36Sopenharmony_ci	uint32_t allow_edp_hotplug_detection;
41262306a36Sopenharmony_ci	bool clamp_min_dcfclk;
41362306a36Sopenharmony_ci	uint64_t vblank_alignment_dto_params;
41462306a36Sopenharmony_ci	uint8_t  vblank_alignment_max_frame_time_diff;
41562306a36Sopenharmony_ci	bool is_asymmetric_memory;
41662306a36Sopenharmony_ci	bool is_single_rank_dimm;
41762306a36Sopenharmony_ci	bool is_vmin_only_asic;
41862306a36Sopenharmony_ci	bool use_pipe_ctx_sync_logic;
41962306a36Sopenharmony_ci	bool ignore_dpref_ss;
42062306a36Sopenharmony_ci	bool enable_mipi_converter_optimization;
42162306a36Sopenharmony_ci	bool use_default_clock_table;
42262306a36Sopenharmony_ci	bool force_bios_enable_lttpr;
42362306a36Sopenharmony_ci	uint8_t force_bios_fixed_vs;
42462306a36Sopenharmony_ci	int sdpif_request_limit_words_per_umc;
42562306a36Sopenharmony_ci	bool use_old_fixed_vs_sequence;
42662306a36Sopenharmony_ci	bool dc_mode_clk_limit_support;
42762306a36Sopenharmony_ci};
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_cienum visual_confirm {
43062306a36Sopenharmony_ci	VISUAL_CONFIRM_DISABLE = 0,
43162306a36Sopenharmony_ci	VISUAL_CONFIRM_SURFACE = 1,
43262306a36Sopenharmony_ci	VISUAL_CONFIRM_HDR = 2,
43362306a36Sopenharmony_ci	VISUAL_CONFIRM_MPCTREE = 4,
43462306a36Sopenharmony_ci	VISUAL_CONFIRM_PSR = 5,
43562306a36Sopenharmony_ci	VISUAL_CONFIRM_SWAPCHAIN = 6,
43662306a36Sopenharmony_ci	VISUAL_CONFIRM_FAMS = 7,
43762306a36Sopenharmony_ci	VISUAL_CONFIRM_SWIZZLE = 9,
43862306a36Sopenharmony_ci	VISUAL_CONFIRM_REPLAY = 12,
43962306a36Sopenharmony_ci	VISUAL_CONFIRM_SUBVP = 14,
44062306a36Sopenharmony_ci	VISUAL_CONFIRM_MCLK_SWITCH = 16,
44162306a36Sopenharmony_ci};
44262306a36Sopenharmony_ci
44362306a36Sopenharmony_cienum dc_psr_power_opts {
44462306a36Sopenharmony_ci	psr_power_opt_invalid = 0x0,
44562306a36Sopenharmony_ci	psr_power_opt_smu_opt_static_screen = 0x1,
44662306a36Sopenharmony_ci	psr_power_opt_z10_static_screen = 0x10,
44762306a36Sopenharmony_ci	psr_power_opt_ds_disable_allow = 0x100,
44862306a36Sopenharmony_ci};
44962306a36Sopenharmony_ci
45062306a36Sopenharmony_cienum dml_hostvm_override_opts {
45162306a36Sopenharmony_ci	DML_HOSTVM_NO_OVERRIDE = 0x0,
45262306a36Sopenharmony_ci	DML_HOSTVM_OVERRIDE_FALSE = 0x1,
45362306a36Sopenharmony_ci	DML_HOSTVM_OVERRIDE_TRUE = 0x2,
45462306a36Sopenharmony_ci};
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_cienum dcc_option {
45762306a36Sopenharmony_ci	DCC_ENABLE = 0,
45862306a36Sopenharmony_ci	DCC_DISABLE = 1,
45962306a36Sopenharmony_ci	DCC_HALF_REQ_DISALBE = 2,
46062306a36Sopenharmony_ci};
46162306a36Sopenharmony_ci
46262306a36Sopenharmony_ci/**
46362306a36Sopenharmony_ci * enum pipe_split_policy - Pipe split strategy supported by DCN
46462306a36Sopenharmony_ci *
46562306a36Sopenharmony_ci * This enum is used to define the pipe split policy supported by DCN. By
46662306a36Sopenharmony_ci * default, DC favors MPC_SPLIT_DYNAMIC.
46762306a36Sopenharmony_ci */
46862306a36Sopenharmony_cienum pipe_split_policy {
46962306a36Sopenharmony_ci	/**
47062306a36Sopenharmony_ci	 * @MPC_SPLIT_DYNAMIC: DC will automatically decide how to split the
47162306a36Sopenharmony_ci	 * pipe in order to bring the best trade-off between performance and
47262306a36Sopenharmony_ci	 * power consumption. This is the recommended option.
47362306a36Sopenharmony_ci	 */
47462306a36Sopenharmony_ci	MPC_SPLIT_DYNAMIC = 0,
47562306a36Sopenharmony_ci
47662306a36Sopenharmony_ci	/**
47762306a36Sopenharmony_ci	 * @MPC_SPLIT_AVOID: Avoid pipe split, which means that DC will not
47862306a36Sopenharmony_ci	 * try any sort of split optimization.
47962306a36Sopenharmony_ci	 */
48062306a36Sopenharmony_ci	MPC_SPLIT_AVOID = 1,
48162306a36Sopenharmony_ci
48262306a36Sopenharmony_ci	/**
48362306a36Sopenharmony_ci	 * @MPC_SPLIT_AVOID_MULT_DISP: With this option, DC will only try to
48462306a36Sopenharmony_ci	 * optimize the pipe utilization when using a single display; if the
48562306a36Sopenharmony_ci	 * user connects to a second display, DC will avoid pipe split.
48662306a36Sopenharmony_ci	 */
48762306a36Sopenharmony_ci	MPC_SPLIT_AVOID_MULT_DISP = 2,
48862306a36Sopenharmony_ci};
48962306a36Sopenharmony_ci
49062306a36Sopenharmony_cienum wm_report_mode {
49162306a36Sopenharmony_ci	WM_REPORT_DEFAULT = 0,
49262306a36Sopenharmony_ci	WM_REPORT_OVERRIDE = 1,
49362306a36Sopenharmony_ci};
49462306a36Sopenharmony_cienum dtm_pstate{
49562306a36Sopenharmony_ci	dtm_level_p0 = 0,/*highest voltage*/
49662306a36Sopenharmony_ci	dtm_level_p1,
49762306a36Sopenharmony_ci	dtm_level_p2,
49862306a36Sopenharmony_ci	dtm_level_p3,
49962306a36Sopenharmony_ci	dtm_level_p4,/*when active_display_count = 0*/
50062306a36Sopenharmony_ci};
50162306a36Sopenharmony_ci
50262306a36Sopenharmony_cienum dcn_pwr_state {
50362306a36Sopenharmony_ci	DCN_PWR_STATE_UNKNOWN = -1,
50462306a36Sopenharmony_ci	DCN_PWR_STATE_MISSION_MODE = 0,
50562306a36Sopenharmony_ci	DCN_PWR_STATE_LOW_POWER = 3,
50662306a36Sopenharmony_ci};
50762306a36Sopenharmony_ci
50862306a36Sopenharmony_cienum dcn_zstate_support_state {
50962306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_UNKNOWN,
51062306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_ALLOW,
51162306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_ALLOW_Z8_ONLY,
51262306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_ALLOW_Z8_Z10_ONLY,
51362306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_ALLOW_Z10_ONLY,
51462306a36Sopenharmony_ci	DCN_ZSTATE_SUPPORT_DISALLOW,
51562306a36Sopenharmony_ci};
51662306a36Sopenharmony_ci
51762306a36Sopenharmony_ci/*
51862306a36Sopenharmony_ci * struct dc_clocks - DC pipe clocks
51962306a36Sopenharmony_ci *
52062306a36Sopenharmony_ci * For any clocks that may differ per pipe only the max is stored in this
52162306a36Sopenharmony_ci * structure
52262306a36Sopenharmony_ci */
52362306a36Sopenharmony_cistruct dc_clocks {
52462306a36Sopenharmony_ci	int dispclk_khz;
52562306a36Sopenharmony_ci	int actual_dispclk_khz;
52662306a36Sopenharmony_ci	int dppclk_khz;
52762306a36Sopenharmony_ci	int actual_dppclk_khz;
52862306a36Sopenharmony_ci	int disp_dpp_voltage_level_khz;
52962306a36Sopenharmony_ci	int dcfclk_khz;
53062306a36Sopenharmony_ci	int socclk_khz;
53162306a36Sopenharmony_ci	int dcfclk_deep_sleep_khz;
53262306a36Sopenharmony_ci	int fclk_khz;
53362306a36Sopenharmony_ci	int phyclk_khz;
53462306a36Sopenharmony_ci	int dramclk_khz;
53562306a36Sopenharmony_ci	bool p_state_change_support;
53662306a36Sopenharmony_ci	enum dcn_zstate_support_state zstate_support;
53762306a36Sopenharmony_ci	bool dtbclk_en;
53862306a36Sopenharmony_ci	int ref_dtbclk_khz;
53962306a36Sopenharmony_ci	bool fclk_p_state_change_support;
54062306a36Sopenharmony_ci	enum dcn_pwr_state pwr_state;
54162306a36Sopenharmony_ci	/*
54262306a36Sopenharmony_ci	 * Elements below are not compared for the purposes of
54362306a36Sopenharmony_ci	 * optimization required
54462306a36Sopenharmony_ci	 */
54562306a36Sopenharmony_ci	bool prev_p_state_change_support;
54662306a36Sopenharmony_ci	bool fclk_prev_p_state_change_support;
54762306a36Sopenharmony_ci	int num_ways;
54862306a36Sopenharmony_ci
54962306a36Sopenharmony_ci	/*
55062306a36Sopenharmony_ci	 * @fw_based_mclk_switching
55162306a36Sopenharmony_ci	 *
55262306a36Sopenharmony_ci	 * DC has a mechanism that leverage the variable refresh rate to switch
55362306a36Sopenharmony_ci	 * memory clock in cases that we have a large latency to achieve the
55462306a36Sopenharmony_ci	 * memory clock change and a short vblank window. DC has some
55562306a36Sopenharmony_ci	 * requirements to enable this feature, and this field describes if the
55662306a36Sopenharmony_ci	 * system support or not such a feature.
55762306a36Sopenharmony_ci	 */
55862306a36Sopenharmony_ci	bool fw_based_mclk_switching;
55962306a36Sopenharmony_ci	bool fw_based_mclk_switching_shut_down;
56062306a36Sopenharmony_ci	int prev_num_ways;
56162306a36Sopenharmony_ci	enum dtm_pstate dtm_level;
56262306a36Sopenharmony_ci	int max_supported_dppclk_khz;
56362306a36Sopenharmony_ci	int max_supported_dispclk_khz;
56462306a36Sopenharmony_ci	int bw_dppclk_khz; /*a copy of dppclk_khz*/
56562306a36Sopenharmony_ci	int bw_dispclk_khz;
56662306a36Sopenharmony_ci};
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_cistruct dc_bw_validation_profile {
56962306a36Sopenharmony_ci	bool enable;
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci	unsigned long long total_ticks;
57262306a36Sopenharmony_ci	unsigned long long voltage_level_ticks;
57362306a36Sopenharmony_ci	unsigned long long watermark_ticks;
57462306a36Sopenharmony_ci	unsigned long long rq_dlg_ticks;
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_ci	unsigned long long total_count;
57762306a36Sopenharmony_ci	unsigned long long skip_fast_count;
57862306a36Sopenharmony_ci	unsigned long long skip_pass_count;
57962306a36Sopenharmony_ci	unsigned long long skip_fail_count;
58062306a36Sopenharmony_ci};
58162306a36Sopenharmony_ci
58262306a36Sopenharmony_ci#define BW_VAL_TRACE_SETUP() \
58362306a36Sopenharmony_ci		unsigned long long end_tick = 0; \
58462306a36Sopenharmony_ci		unsigned long long voltage_level_tick = 0; \
58562306a36Sopenharmony_ci		unsigned long long watermark_tick = 0; \
58662306a36Sopenharmony_ci		unsigned long long start_tick = dc->debug.bw_val_profile.enable ? \
58762306a36Sopenharmony_ci				dm_get_timestamp(dc->ctx) : 0
58862306a36Sopenharmony_ci
58962306a36Sopenharmony_ci#define BW_VAL_TRACE_COUNT() \
59062306a36Sopenharmony_ci		if (dc->debug.bw_val_profile.enable) \
59162306a36Sopenharmony_ci			dc->debug.bw_val_profile.total_count++
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_ci#define BW_VAL_TRACE_SKIP(status) \
59462306a36Sopenharmony_ci		if (dc->debug.bw_val_profile.enable) { \
59562306a36Sopenharmony_ci			if (!voltage_level_tick) \
59662306a36Sopenharmony_ci				voltage_level_tick = dm_get_timestamp(dc->ctx); \
59762306a36Sopenharmony_ci			dc->debug.bw_val_profile.skip_ ## status ## _count++; \
59862306a36Sopenharmony_ci		}
59962306a36Sopenharmony_ci
60062306a36Sopenharmony_ci#define BW_VAL_TRACE_END_VOLTAGE_LEVEL() \
60162306a36Sopenharmony_ci		if (dc->debug.bw_val_profile.enable) \
60262306a36Sopenharmony_ci			voltage_level_tick = dm_get_timestamp(dc->ctx)
60362306a36Sopenharmony_ci
60462306a36Sopenharmony_ci#define BW_VAL_TRACE_END_WATERMARKS() \
60562306a36Sopenharmony_ci		if (dc->debug.bw_val_profile.enable) \
60662306a36Sopenharmony_ci			watermark_tick = dm_get_timestamp(dc->ctx)
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ci#define BW_VAL_TRACE_FINISH() \
60962306a36Sopenharmony_ci		if (dc->debug.bw_val_profile.enable) { \
61062306a36Sopenharmony_ci			end_tick = dm_get_timestamp(dc->ctx); \
61162306a36Sopenharmony_ci			dc->debug.bw_val_profile.total_ticks += end_tick - start_tick; \
61262306a36Sopenharmony_ci			dc->debug.bw_val_profile.voltage_level_ticks += voltage_level_tick - start_tick; \
61362306a36Sopenharmony_ci			if (watermark_tick) { \
61462306a36Sopenharmony_ci				dc->debug.bw_val_profile.watermark_ticks += watermark_tick - voltage_level_tick; \
61562306a36Sopenharmony_ci				dc->debug.bw_val_profile.rq_dlg_ticks += end_tick - watermark_tick; \
61662306a36Sopenharmony_ci			} \
61762306a36Sopenharmony_ci		}
61862306a36Sopenharmony_ci
61962306a36Sopenharmony_ciunion mem_low_power_enable_options {
62062306a36Sopenharmony_ci	struct {
62162306a36Sopenharmony_ci		bool vga: 1;
62262306a36Sopenharmony_ci		bool i2c: 1;
62362306a36Sopenharmony_ci		bool dmcu: 1;
62462306a36Sopenharmony_ci		bool dscl: 1;
62562306a36Sopenharmony_ci		bool cm: 1;
62662306a36Sopenharmony_ci		bool mpc: 1;
62762306a36Sopenharmony_ci		bool optc: 1;
62862306a36Sopenharmony_ci		bool vpg: 1;
62962306a36Sopenharmony_ci		bool afmt: 1;
63062306a36Sopenharmony_ci	} bits;
63162306a36Sopenharmony_ci	uint32_t u32All;
63262306a36Sopenharmony_ci};
63362306a36Sopenharmony_ci
63462306a36Sopenharmony_ciunion root_clock_optimization_options {
63562306a36Sopenharmony_ci	struct {
63662306a36Sopenharmony_ci		bool dpp: 1;
63762306a36Sopenharmony_ci		bool dsc: 1;
63862306a36Sopenharmony_ci		bool hdmistream: 1;
63962306a36Sopenharmony_ci		bool hdmichar: 1;
64062306a36Sopenharmony_ci		bool dpstream: 1;
64162306a36Sopenharmony_ci		bool symclk32_se: 1;
64262306a36Sopenharmony_ci		bool symclk32_le: 1;
64362306a36Sopenharmony_ci		bool symclk_fe: 1;
64462306a36Sopenharmony_ci		bool physymclk: 1;
64562306a36Sopenharmony_ci		bool dpiasymclk: 1;
64662306a36Sopenharmony_ci		uint32_t reserved: 22;
64762306a36Sopenharmony_ci	} bits;
64862306a36Sopenharmony_ci	uint32_t u32All;
64962306a36Sopenharmony_ci};
65062306a36Sopenharmony_ci
65162306a36Sopenharmony_ciunion dpia_debug_options {
65262306a36Sopenharmony_ci	struct {
65362306a36Sopenharmony_ci		uint32_t disable_dpia:1; /* bit 0 */
65462306a36Sopenharmony_ci		uint32_t force_non_lttpr:1; /* bit 1 */
65562306a36Sopenharmony_ci		uint32_t extend_aux_rd_interval:1; /* bit 2 */
65662306a36Sopenharmony_ci		uint32_t disable_mst_dsc_work_around:1; /* bit 3 */
65762306a36Sopenharmony_ci		uint32_t enable_force_tbt3_work_around:1; /* bit 4 */
65862306a36Sopenharmony_ci		uint32_t reserved:27;
65962306a36Sopenharmony_ci	} bits;
66062306a36Sopenharmony_ci	uint32_t raw;
66162306a36Sopenharmony_ci};
66262306a36Sopenharmony_ci
66362306a36Sopenharmony_ci/* AUX wake work around options
66462306a36Sopenharmony_ci * 0: enable/disable work around
66562306a36Sopenharmony_ci * 1: use default timeout LINK_AUX_WAKE_TIMEOUT_MS
66662306a36Sopenharmony_ci * 15-2: reserved
66762306a36Sopenharmony_ci * 31-16: timeout in ms
66862306a36Sopenharmony_ci */
66962306a36Sopenharmony_ciunion aux_wake_wa_options {
67062306a36Sopenharmony_ci	struct {
67162306a36Sopenharmony_ci		uint32_t enable_wa : 1;
67262306a36Sopenharmony_ci		uint32_t use_default_timeout : 1;
67362306a36Sopenharmony_ci		uint32_t rsvd: 14;
67462306a36Sopenharmony_ci		uint32_t timeout_ms : 16;
67562306a36Sopenharmony_ci	} bits;
67662306a36Sopenharmony_ci	uint32_t raw;
67762306a36Sopenharmony_ci};
67862306a36Sopenharmony_ci
67962306a36Sopenharmony_cistruct dc_debug_data {
68062306a36Sopenharmony_ci	uint32_t ltFailCount;
68162306a36Sopenharmony_ci	uint32_t i2cErrorCount;
68262306a36Sopenharmony_ci	uint32_t auxErrorCount;
68362306a36Sopenharmony_ci};
68462306a36Sopenharmony_ci
68562306a36Sopenharmony_cistruct dc_phy_addr_space_config {
68662306a36Sopenharmony_ci	struct {
68762306a36Sopenharmony_ci		uint64_t start_addr;
68862306a36Sopenharmony_ci		uint64_t end_addr;
68962306a36Sopenharmony_ci		uint64_t fb_top;
69062306a36Sopenharmony_ci		uint64_t fb_offset;
69162306a36Sopenharmony_ci		uint64_t fb_base;
69262306a36Sopenharmony_ci		uint64_t agp_top;
69362306a36Sopenharmony_ci		uint64_t agp_bot;
69462306a36Sopenharmony_ci		uint64_t agp_base;
69562306a36Sopenharmony_ci	} system_aperture;
69662306a36Sopenharmony_ci
69762306a36Sopenharmony_ci	struct {
69862306a36Sopenharmony_ci		uint64_t page_table_start_addr;
69962306a36Sopenharmony_ci		uint64_t page_table_end_addr;
70062306a36Sopenharmony_ci		uint64_t page_table_base_addr;
70162306a36Sopenharmony_ci		bool base_addr_is_mc_addr;
70262306a36Sopenharmony_ci	} gart_config;
70362306a36Sopenharmony_ci
70462306a36Sopenharmony_ci	bool valid;
70562306a36Sopenharmony_ci	bool is_hvm_enabled;
70662306a36Sopenharmony_ci	uint64_t page_table_default_page_addr;
70762306a36Sopenharmony_ci};
70862306a36Sopenharmony_ci
70962306a36Sopenharmony_cistruct dc_virtual_addr_space_config {
71062306a36Sopenharmony_ci	uint64_t	page_table_base_addr;
71162306a36Sopenharmony_ci	uint64_t	page_table_start_addr;
71262306a36Sopenharmony_ci	uint64_t	page_table_end_addr;
71362306a36Sopenharmony_ci	uint32_t	page_table_block_size_in_bytes;
71462306a36Sopenharmony_ci	uint8_t		page_table_depth; // 1 = 1 level, 2 = 2 level, etc.  0 = invalid
71562306a36Sopenharmony_ci};
71662306a36Sopenharmony_ci
71762306a36Sopenharmony_cistruct dc_bounding_box_overrides {
71862306a36Sopenharmony_ci	int sr_exit_time_ns;
71962306a36Sopenharmony_ci	int sr_enter_plus_exit_time_ns;
72062306a36Sopenharmony_ci	int sr_exit_z8_time_ns;
72162306a36Sopenharmony_ci	int sr_enter_plus_exit_z8_time_ns;
72262306a36Sopenharmony_ci	int urgent_latency_ns;
72362306a36Sopenharmony_ci	int percent_of_ideal_drambw;
72462306a36Sopenharmony_ci	int dram_clock_change_latency_ns;
72562306a36Sopenharmony_ci	int dummy_clock_change_latency_ns;
72662306a36Sopenharmony_ci	int fclk_clock_change_latency_ns;
72762306a36Sopenharmony_ci	/* This forces a hard min on the DCFCLK we use
72862306a36Sopenharmony_ci	 * for DML.  Unlike the debug option for forcing
72962306a36Sopenharmony_ci	 * DCFCLK, this override affects watermark calculations
73062306a36Sopenharmony_ci	 */
73162306a36Sopenharmony_ci	int min_dcfclk_mhz;
73262306a36Sopenharmony_ci};
73362306a36Sopenharmony_ci
73462306a36Sopenharmony_cistruct dc_state;
73562306a36Sopenharmony_cistruct resource_pool;
73662306a36Sopenharmony_cistruct dce_hwseq;
73762306a36Sopenharmony_cistruct link_service;
73862306a36Sopenharmony_ci
73962306a36Sopenharmony_ci/*
74062306a36Sopenharmony_ci * struct dc_debug_options - DC debug struct
74162306a36Sopenharmony_ci *
74262306a36Sopenharmony_ci * This struct provides a simple mechanism for developers to change some
74362306a36Sopenharmony_ci * configurations, enable/disable features, and activate extra debug options.
74462306a36Sopenharmony_ci * This can be very handy to narrow down whether some specific feature is
74562306a36Sopenharmony_ci * causing an issue or not.
74662306a36Sopenharmony_ci */
74762306a36Sopenharmony_cistruct dc_debug_options {
74862306a36Sopenharmony_ci	bool native422_support;
74962306a36Sopenharmony_ci	bool disable_dsc;
75062306a36Sopenharmony_ci	enum visual_confirm visual_confirm;
75162306a36Sopenharmony_ci	int visual_confirm_rect_height;
75262306a36Sopenharmony_ci
75362306a36Sopenharmony_ci	bool sanity_checks;
75462306a36Sopenharmony_ci	bool max_disp_clk;
75562306a36Sopenharmony_ci	bool surface_trace;
75662306a36Sopenharmony_ci	bool timing_trace;
75762306a36Sopenharmony_ci	bool clock_trace;
75862306a36Sopenharmony_ci	bool validation_trace;
75962306a36Sopenharmony_ci	bool bandwidth_calcs_trace;
76062306a36Sopenharmony_ci	int max_downscale_src_width;
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_ci	/* stutter efficiency related */
76362306a36Sopenharmony_ci	bool disable_stutter;
76462306a36Sopenharmony_ci	bool use_max_lb;
76562306a36Sopenharmony_ci	enum dcc_option disable_dcc;
76662306a36Sopenharmony_ci
76762306a36Sopenharmony_ci	/*
76862306a36Sopenharmony_ci	 * @pipe_split_policy: Define which pipe split policy is used by the
76962306a36Sopenharmony_ci	 * display core.
77062306a36Sopenharmony_ci	 */
77162306a36Sopenharmony_ci	enum pipe_split_policy pipe_split_policy;
77262306a36Sopenharmony_ci	bool force_single_disp_pipe_split;
77362306a36Sopenharmony_ci	bool voltage_align_fclk;
77462306a36Sopenharmony_ci	bool disable_min_fclk;
77562306a36Sopenharmony_ci
77662306a36Sopenharmony_ci	bool disable_dfs_bypass;
77762306a36Sopenharmony_ci	bool disable_dpp_power_gate;
77862306a36Sopenharmony_ci	bool disable_hubp_power_gate;
77962306a36Sopenharmony_ci	bool disable_dsc_power_gate;
78062306a36Sopenharmony_ci	int dsc_min_slice_height_override;
78162306a36Sopenharmony_ci	int dsc_bpp_increment_div;
78262306a36Sopenharmony_ci	bool disable_pplib_wm_range;
78362306a36Sopenharmony_ci	enum wm_report_mode pplib_wm_report_mode;
78462306a36Sopenharmony_ci	unsigned int min_disp_clk_khz;
78562306a36Sopenharmony_ci	unsigned int min_dpp_clk_khz;
78662306a36Sopenharmony_ci	unsigned int min_dram_clk_khz;
78762306a36Sopenharmony_ci	int sr_exit_time_dpm0_ns;
78862306a36Sopenharmony_ci	int sr_enter_plus_exit_time_dpm0_ns;
78962306a36Sopenharmony_ci	int sr_exit_time_ns;
79062306a36Sopenharmony_ci	int sr_enter_plus_exit_time_ns;
79162306a36Sopenharmony_ci	int sr_exit_z8_time_ns;
79262306a36Sopenharmony_ci	int sr_enter_plus_exit_z8_time_ns;
79362306a36Sopenharmony_ci	int urgent_latency_ns;
79462306a36Sopenharmony_ci	uint32_t underflow_assert_delay_us;
79562306a36Sopenharmony_ci	int percent_of_ideal_drambw;
79662306a36Sopenharmony_ci	int dram_clock_change_latency_ns;
79762306a36Sopenharmony_ci	bool optimized_watermark;
79862306a36Sopenharmony_ci	int always_scale;
79962306a36Sopenharmony_ci	bool disable_pplib_clock_request;
80062306a36Sopenharmony_ci	bool disable_clock_gate;
80162306a36Sopenharmony_ci	bool disable_mem_low_power;
80262306a36Sopenharmony_ci	bool pstate_enabled;
80362306a36Sopenharmony_ci	bool disable_dmcu;
80462306a36Sopenharmony_ci	bool force_abm_enable;
80562306a36Sopenharmony_ci	bool disable_stereo_support;
80662306a36Sopenharmony_ci	bool vsr_support;
80762306a36Sopenharmony_ci	bool performance_trace;
80862306a36Sopenharmony_ci	bool az_endpoint_mute_only;
80962306a36Sopenharmony_ci	bool always_use_regamma;
81062306a36Sopenharmony_ci	bool recovery_enabled;
81162306a36Sopenharmony_ci	bool avoid_vbios_exec_table;
81262306a36Sopenharmony_ci	bool scl_reset_length10;
81362306a36Sopenharmony_ci	bool hdmi20_disable;
81462306a36Sopenharmony_ci	bool skip_detection_link_training;
81562306a36Sopenharmony_ci	uint32_t edid_read_retry_times;
81662306a36Sopenharmony_ci	unsigned int force_odm_combine; //bit vector based on otg inst
81762306a36Sopenharmony_ci	unsigned int seamless_boot_odm_combine;
81862306a36Sopenharmony_ci	unsigned int force_odm_combine_4to1; //bit vector based on otg inst
81962306a36Sopenharmony_ci	int minimum_z8_residency_time;
82062306a36Sopenharmony_ci	bool disable_z9_mpc;
82162306a36Sopenharmony_ci	unsigned int force_fclk_khz;
82262306a36Sopenharmony_ci	bool enable_tri_buf;
82362306a36Sopenharmony_ci	bool dmub_offload_enabled;
82462306a36Sopenharmony_ci	bool dmcub_emulation;
82562306a36Sopenharmony_ci	bool disable_idle_power_optimizations;
82662306a36Sopenharmony_ci	unsigned int mall_size_override;
82762306a36Sopenharmony_ci	unsigned int mall_additional_timer_percent;
82862306a36Sopenharmony_ci	bool mall_error_as_fatal;
82962306a36Sopenharmony_ci	bool dmub_command_table; /* for testing only */
83062306a36Sopenharmony_ci	struct dc_bw_validation_profile bw_val_profile;
83162306a36Sopenharmony_ci	bool disable_fec;
83262306a36Sopenharmony_ci	bool disable_48mhz_pwrdwn;
83362306a36Sopenharmony_ci	/* This forces a hard min on the DCFCLK requested to SMU/PP
83462306a36Sopenharmony_ci	 * watermarks are not affected.
83562306a36Sopenharmony_ci	 */
83662306a36Sopenharmony_ci	unsigned int force_min_dcfclk_mhz;
83762306a36Sopenharmony_ci	int dwb_fi_phase;
83862306a36Sopenharmony_ci	bool disable_timing_sync;
83962306a36Sopenharmony_ci	bool cm_in_bypass;
84062306a36Sopenharmony_ci	int force_clock_mode;/*every mode change.*/
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_ci	bool disable_dram_clock_change_vactive_support;
84362306a36Sopenharmony_ci	bool validate_dml_output;
84462306a36Sopenharmony_ci	bool enable_dmcub_surface_flip;
84562306a36Sopenharmony_ci	bool usbc_combo_phy_reset_wa;
84662306a36Sopenharmony_ci	bool enable_dram_clock_change_one_display_vactive;
84762306a36Sopenharmony_ci	/* TODO - remove once tested */
84862306a36Sopenharmony_ci	bool legacy_dp2_lt;
84962306a36Sopenharmony_ci	bool set_mst_en_for_sst;
85062306a36Sopenharmony_ci	bool disable_uhbr;
85162306a36Sopenharmony_ci	bool force_dp2_lt_fallback_method;
85262306a36Sopenharmony_ci	bool ignore_cable_id;
85362306a36Sopenharmony_ci	union mem_low_power_enable_options enable_mem_low_power;
85462306a36Sopenharmony_ci	union root_clock_optimization_options root_clock_optimization;
85562306a36Sopenharmony_ci	bool hpo_optimization;
85662306a36Sopenharmony_ci	bool force_vblank_alignment;
85762306a36Sopenharmony_ci
85862306a36Sopenharmony_ci	/* Enable dmub aux for legacy ddc */
85962306a36Sopenharmony_ci	bool enable_dmub_aux_for_legacy_ddc;
86062306a36Sopenharmony_ci	bool disable_fams;
86162306a36Sopenharmony_ci	bool disable_fams_gaming;
86262306a36Sopenharmony_ci	/* FEC/PSR1 sequence enable delay in 100us */
86362306a36Sopenharmony_ci	uint8_t fec_enable_delay_in100us;
86462306a36Sopenharmony_ci	bool enable_driver_sequence_debug;
86562306a36Sopenharmony_ci	enum det_size crb_alloc_policy;
86662306a36Sopenharmony_ci	int crb_alloc_policy_min_disp_count;
86762306a36Sopenharmony_ci	bool disable_z10;
86862306a36Sopenharmony_ci	bool enable_z9_disable_interface;
86962306a36Sopenharmony_ci	bool psr_skip_crtc_disable;
87062306a36Sopenharmony_ci	union dpia_debug_options dpia_debug;
87162306a36Sopenharmony_ci	bool disable_fixed_vs_aux_timeout_wa;
87262306a36Sopenharmony_ci	uint32_t fixed_vs_aux_delay_config_wa;
87362306a36Sopenharmony_ci	bool force_disable_subvp;
87462306a36Sopenharmony_ci	bool force_subvp_mclk_switch;
87562306a36Sopenharmony_ci	bool allow_sw_cursor_fallback;
87662306a36Sopenharmony_ci	unsigned int force_subvp_num_ways;
87762306a36Sopenharmony_ci	unsigned int force_mall_ss_num_ways;
87862306a36Sopenharmony_ci	bool alloc_extra_way_for_cursor;
87962306a36Sopenharmony_ci	uint32_t subvp_extra_lines;
88062306a36Sopenharmony_ci	bool force_usr_allow;
88162306a36Sopenharmony_ci	/* uses value at boot and disables switch */
88262306a36Sopenharmony_ci	bool disable_dtb_ref_clk_switch;
88362306a36Sopenharmony_ci	bool extended_blank_optimization;
88462306a36Sopenharmony_ci	union aux_wake_wa_options aux_wake_wa;
88562306a36Sopenharmony_ci	uint32_t mst_start_top_delay;
88662306a36Sopenharmony_ci	uint8_t psr_power_use_phy_fsm;
88762306a36Sopenharmony_ci	enum dml_hostvm_override_opts dml_hostvm_override;
88862306a36Sopenharmony_ci	bool dml_disallow_alternate_prefetch_modes;
88962306a36Sopenharmony_ci	bool use_legacy_soc_bb_mechanism;
89062306a36Sopenharmony_ci	bool exit_idle_opt_for_cursor_updates;
89162306a36Sopenharmony_ci	bool enable_single_display_2to1_odm_policy;
89262306a36Sopenharmony_ci	bool enable_double_buffered_dsc_pg_support;
89362306a36Sopenharmony_ci	bool enable_dp_dig_pixel_rate_div_policy;
89462306a36Sopenharmony_ci	enum lttpr_mode lttpr_mode_override;
89562306a36Sopenharmony_ci	unsigned int dsc_delay_factor_wa_x1000;
89662306a36Sopenharmony_ci	unsigned int min_prefetch_in_strobe_ns;
89762306a36Sopenharmony_ci	bool disable_unbounded_requesting;
89862306a36Sopenharmony_ci	bool dig_fifo_off_in_blank;
89962306a36Sopenharmony_ci	bool temp_mst_deallocation_sequence;
90062306a36Sopenharmony_ci	bool override_dispclk_programming;
90162306a36Sopenharmony_ci	bool disable_fpo_optimizations;
90262306a36Sopenharmony_ci	bool support_eDP1_5;
90362306a36Sopenharmony_ci	uint32_t fpo_vactive_margin_us;
90462306a36Sopenharmony_ci	bool disable_fpo_vactive;
90562306a36Sopenharmony_ci	bool disable_boot_optimizations;
90662306a36Sopenharmony_ci	bool override_odm_optimization;
90762306a36Sopenharmony_ci	bool minimize_dispclk_using_odm;
90862306a36Sopenharmony_ci	bool disable_subvp_high_refresh;
90962306a36Sopenharmony_ci	bool disable_dp_plus_plus_wa;
91062306a36Sopenharmony_ci	uint32_t fpo_vactive_min_active_margin_us;
91162306a36Sopenharmony_ci	uint32_t fpo_vactive_max_blank_us;
91262306a36Sopenharmony_ci	bool enable_legacy_fast_update;
91362306a36Sopenharmony_ci	bool disable_dc_mode_overwrite;
91462306a36Sopenharmony_ci	bool replay_skip_crtc_disabled;
91562306a36Sopenharmony_ci};
91662306a36Sopenharmony_ci
91762306a36Sopenharmony_cistruct gpu_info_soc_bounding_box_v1_0;
91862306a36Sopenharmony_ci
91962306a36Sopenharmony_ci/* Generic structure that can be used to query properties of DC. More fields
92062306a36Sopenharmony_ci * can be added as required.
92162306a36Sopenharmony_ci */
92262306a36Sopenharmony_cistruct dc_current_properties {
92362306a36Sopenharmony_ci	unsigned int cursor_size_limit;
92462306a36Sopenharmony_ci};
92562306a36Sopenharmony_ci
92662306a36Sopenharmony_cistruct dc {
92762306a36Sopenharmony_ci	struct dc_debug_options debug;
92862306a36Sopenharmony_ci	struct dc_versions versions;
92962306a36Sopenharmony_ci	struct dc_caps caps;
93062306a36Sopenharmony_ci	struct dc_cap_funcs cap_funcs;
93162306a36Sopenharmony_ci	struct dc_config config;
93262306a36Sopenharmony_ci	struct dc_bounding_box_overrides bb_overrides;
93362306a36Sopenharmony_ci	struct dc_bug_wa work_arounds;
93462306a36Sopenharmony_ci	struct dc_context *ctx;
93562306a36Sopenharmony_ci	struct dc_phy_addr_space_config vm_pa_config;
93662306a36Sopenharmony_ci
93762306a36Sopenharmony_ci	uint8_t link_count;
93862306a36Sopenharmony_ci	struct dc_link *links[MAX_PIPES * 2];
93962306a36Sopenharmony_ci	struct link_service *link_srv;
94062306a36Sopenharmony_ci
94162306a36Sopenharmony_ci	struct dc_state *current_state;
94262306a36Sopenharmony_ci	struct resource_pool *res_pool;
94362306a36Sopenharmony_ci
94462306a36Sopenharmony_ci	struct clk_mgr *clk_mgr;
94562306a36Sopenharmony_ci
94662306a36Sopenharmony_ci	/* Display Engine Clock levels */
94762306a36Sopenharmony_ci	struct dm_pp_clock_levels sclk_lvls;
94862306a36Sopenharmony_ci
94962306a36Sopenharmony_ci	/* Inputs into BW and WM calculations. */
95062306a36Sopenharmony_ci	struct bw_calcs_dceip *bw_dceip;
95162306a36Sopenharmony_ci	struct bw_calcs_vbios *bw_vbios;
95262306a36Sopenharmony_ci	struct dcn_soc_bounding_box *dcn_soc;
95362306a36Sopenharmony_ci	struct dcn_ip_params *dcn_ip;
95462306a36Sopenharmony_ci	struct display_mode_lib dml;
95562306a36Sopenharmony_ci
95662306a36Sopenharmony_ci	/* HW functions */
95762306a36Sopenharmony_ci	struct hw_sequencer_funcs hwss;
95862306a36Sopenharmony_ci	struct dce_hwseq *hwseq;
95962306a36Sopenharmony_ci
96062306a36Sopenharmony_ci	/* Require to optimize clocks and bandwidth for added/removed planes */
96162306a36Sopenharmony_ci	bool optimized_required;
96262306a36Sopenharmony_ci	bool wm_optimized_required;
96362306a36Sopenharmony_ci	bool idle_optimizations_allowed;
96462306a36Sopenharmony_ci	bool enable_c20_dtm_b0;
96562306a36Sopenharmony_ci
96662306a36Sopenharmony_ci	/* Require to maintain clocks and bandwidth for UEFI enabled HW */
96762306a36Sopenharmony_ci
96862306a36Sopenharmony_ci	/* FBC compressor */
96962306a36Sopenharmony_ci	struct compressor *fbc_compressor;
97062306a36Sopenharmony_ci
97162306a36Sopenharmony_ci	struct dc_debug_data debug_data;
97262306a36Sopenharmony_ci	struct dpcd_vendor_signature vendor_signature;
97362306a36Sopenharmony_ci
97462306a36Sopenharmony_ci	const char *build_id;
97562306a36Sopenharmony_ci	struct vm_helper *vm_helper;
97662306a36Sopenharmony_ci
97762306a36Sopenharmony_ci	uint32_t *dcn_reg_offsets;
97862306a36Sopenharmony_ci	uint32_t *nbio_reg_offsets;
97962306a36Sopenharmony_ci
98062306a36Sopenharmony_ci	/* Scratch memory */
98162306a36Sopenharmony_ci	struct {
98262306a36Sopenharmony_ci		struct {
98362306a36Sopenharmony_ci			/*
98462306a36Sopenharmony_ci			 * For matching clock_limits table in driver with table
98562306a36Sopenharmony_ci			 * from PMFW.
98662306a36Sopenharmony_ci			 */
98762306a36Sopenharmony_ci			struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES];
98862306a36Sopenharmony_ci		} update_bw_bounding_box;
98962306a36Sopenharmony_ci	} scratch;
99062306a36Sopenharmony_ci};
99162306a36Sopenharmony_ci
99262306a36Sopenharmony_cienum frame_buffer_mode {
99362306a36Sopenharmony_ci	FRAME_BUFFER_MODE_LOCAL_ONLY = 0,
99462306a36Sopenharmony_ci	FRAME_BUFFER_MODE_ZFB_ONLY,
99562306a36Sopenharmony_ci	FRAME_BUFFER_MODE_MIXED_ZFB_AND_LOCAL,
99662306a36Sopenharmony_ci} ;
99762306a36Sopenharmony_ci
99862306a36Sopenharmony_cistruct dchub_init_data {
99962306a36Sopenharmony_ci	int64_t zfb_phys_addr_base;
100062306a36Sopenharmony_ci	int64_t zfb_mc_base_addr;
100162306a36Sopenharmony_ci	uint64_t zfb_size_in_byte;
100262306a36Sopenharmony_ci	enum frame_buffer_mode fb_mode;
100362306a36Sopenharmony_ci	bool dchub_initialzied;
100462306a36Sopenharmony_ci	bool dchub_info_valid;
100562306a36Sopenharmony_ci};
100662306a36Sopenharmony_ci
100762306a36Sopenharmony_cistruct dc_init_data {
100862306a36Sopenharmony_ci	struct hw_asic_id asic_id;
100962306a36Sopenharmony_ci	void *driver; /* ctx */
101062306a36Sopenharmony_ci	struct cgs_device *cgs_device;
101162306a36Sopenharmony_ci	struct dc_bounding_box_overrides bb_overrides;
101262306a36Sopenharmony_ci
101362306a36Sopenharmony_ci	int num_virtual_links;
101462306a36Sopenharmony_ci	/*
101562306a36Sopenharmony_ci	 * If 'vbios_override' not NULL, it will be called instead
101662306a36Sopenharmony_ci	 * of the real VBIOS. Intended use is Diagnostics on FPGA.
101762306a36Sopenharmony_ci	 */
101862306a36Sopenharmony_ci	struct dc_bios *vbios_override;
101962306a36Sopenharmony_ci	enum dce_environment dce_environment;
102062306a36Sopenharmony_ci
102162306a36Sopenharmony_ci	struct dmub_offload_funcs *dmub_if;
102262306a36Sopenharmony_ci	struct dc_reg_helper_state *dmub_offload;
102362306a36Sopenharmony_ci
102462306a36Sopenharmony_ci	struct dc_config flags;
102562306a36Sopenharmony_ci	uint64_t log_mask;
102662306a36Sopenharmony_ci
102762306a36Sopenharmony_ci	struct dpcd_vendor_signature vendor_signature;
102862306a36Sopenharmony_ci	bool force_smu_not_present;
102962306a36Sopenharmony_ci	/*
103062306a36Sopenharmony_ci	 * IP offset for run time initializaion of register addresses
103162306a36Sopenharmony_ci	 *
103262306a36Sopenharmony_ci	 * DCN3.5+ will fail dc_create() if these fields are null for them. They are
103362306a36Sopenharmony_ci	 * applicable starting with DCN32/321 and are not used for ASICs upstreamed
103462306a36Sopenharmony_ci	 * before them.
103562306a36Sopenharmony_ci	 */
103662306a36Sopenharmony_ci	uint32_t *dcn_reg_offsets;
103762306a36Sopenharmony_ci	uint32_t *nbio_reg_offsets;
103862306a36Sopenharmony_ci};
103962306a36Sopenharmony_ci
104062306a36Sopenharmony_cistruct dc_callback_init {
104162306a36Sopenharmony_ci	struct cp_psp cp_psp;
104262306a36Sopenharmony_ci};
104362306a36Sopenharmony_ci
104462306a36Sopenharmony_cistruct dc *dc_create(const struct dc_init_data *init_params);
104562306a36Sopenharmony_civoid dc_hardware_init(struct dc *dc);
104662306a36Sopenharmony_ci
104762306a36Sopenharmony_ciint dc_get_vmid_use_vector(struct dc *dc);
104862306a36Sopenharmony_civoid dc_setup_vm_context(struct dc *dc, struct dc_virtual_addr_space_config *va_config, int vmid);
104962306a36Sopenharmony_ci/* Returns the number of vmids supported */
105062306a36Sopenharmony_ciint dc_setup_system_context(struct dc *dc, struct dc_phy_addr_space_config *pa_config);
105162306a36Sopenharmony_civoid dc_init_callbacks(struct dc *dc,
105262306a36Sopenharmony_ci		const struct dc_callback_init *init_params);
105362306a36Sopenharmony_civoid dc_deinit_callbacks(struct dc *dc);
105462306a36Sopenharmony_civoid dc_destroy(struct dc **dc);
105562306a36Sopenharmony_ci
105662306a36Sopenharmony_ci/* Surface Interfaces */
105762306a36Sopenharmony_ci
105862306a36Sopenharmony_cienum {
105962306a36Sopenharmony_ci	TRANSFER_FUNC_POINTS = 1025
106062306a36Sopenharmony_ci};
106162306a36Sopenharmony_ci
106262306a36Sopenharmony_cistruct dc_hdr_static_metadata {
106362306a36Sopenharmony_ci	/* display chromaticities and white point in units of 0.00001 */
106462306a36Sopenharmony_ci	unsigned int chromaticity_green_x;
106562306a36Sopenharmony_ci	unsigned int chromaticity_green_y;
106662306a36Sopenharmony_ci	unsigned int chromaticity_blue_x;
106762306a36Sopenharmony_ci	unsigned int chromaticity_blue_y;
106862306a36Sopenharmony_ci	unsigned int chromaticity_red_x;
106962306a36Sopenharmony_ci	unsigned int chromaticity_red_y;
107062306a36Sopenharmony_ci	unsigned int chromaticity_white_point_x;
107162306a36Sopenharmony_ci	unsigned int chromaticity_white_point_y;
107262306a36Sopenharmony_ci
107362306a36Sopenharmony_ci	uint32_t min_luminance;
107462306a36Sopenharmony_ci	uint32_t max_luminance;
107562306a36Sopenharmony_ci	uint32_t maximum_content_light_level;
107662306a36Sopenharmony_ci	uint32_t maximum_frame_average_light_level;
107762306a36Sopenharmony_ci};
107862306a36Sopenharmony_ci
107962306a36Sopenharmony_cienum dc_transfer_func_type {
108062306a36Sopenharmony_ci	TF_TYPE_PREDEFINED,
108162306a36Sopenharmony_ci	TF_TYPE_DISTRIBUTED_POINTS,
108262306a36Sopenharmony_ci	TF_TYPE_BYPASS,
108362306a36Sopenharmony_ci	TF_TYPE_HWPWL
108462306a36Sopenharmony_ci};
108562306a36Sopenharmony_ci
108662306a36Sopenharmony_cistruct dc_transfer_func_distributed_points {
108762306a36Sopenharmony_ci	struct fixed31_32 red[TRANSFER_FUNC_POINTS];
108862306a36Sopenharmony_ci	struct fixed31_32 green[TRANSFER_FUNC_POINTS];
108962306a36Sopenharmony_ci	struct fixed31_32 blue[TRANSFER_FUNC_POINTS];
109062306a36Sopenharmony_ci
109162306a36Sopenharmony_ci	uint16_t end_exponent;
109262306a36Sopenharmony_ci	uint16_t x_point_at_y1_red;
109362306a36Sopenharmony_ci	uint16_t x_point_at_y1_green;
109462306a36Sopenharmony_ci	uint16_t x_point_at_y1_blue;
109562306a36Sopenharmony_ci};
109662306a36Sopenharmony_ci
109762306a36Sopenharmony_cienum dc_transfer_func_predefined {
109862306a36Sopenharmony_ci	TRANSFER_FUNCTION_SRGB,
109962306a36Sopenharmony_ci	TRANSFER_FUNCTION_BT709,
110062306a36Sopenharmony_ci	TRANSFER_FUNCTION_PQ,
110162306a36Sopenharmony_ci	TRANSFER_FUNCTION_LINEAR,
110262306a36Sopenharmony_ci	TRANSFER_FUNCTION_UNITY,
110362306a36Sopenharmony_ci	TRANSFER_FUNCTION_HLG,
110462306a36Sopenharmony_ci	TRANSFER_FUNCTION_HLG12,
110562306a36Sopenharmony_ci	TRANSFER_FUNCTION_GAMMA22,
110662306a36Sopenharmony_ci	TRANSFER_FUNCTION_GAMMA24,
110762306a36Sopenharmony_ci	TRANSFER_FUNCTION_GAMMA26
110862306a36Sopenharmony_ci};
110962306a36Sopenharmony_ci
111062306a36Sopenharmony_ci
111162306a36Sopenharmony_cistruct dc_transfer_func {
111262306a36Sopenharmony_ci	struct kref refcount;
111362306a36Sopenharmony_ci	enum dc_transfer_func_type type;
111462306a36Sopenharmony_ci	enum dc_transfer_func_predefined tf;
111562306a36Sopenharmony_ci	/* FP16 1.0 reference level in nits, default is 80 nits, only for PQ*/
111662306a36Sopenharmony_ci	uint32_t sdr_ref_white_level;
111762306a36Sopenharmony_ci	union {
111862306a36Sopenharmony_ci		struct pwl_params pwl;
111962306a36Sopenharmony_ci		struct dc_transfer_func_distributed_points tf_pts;
112062306a36Sopenharmony_ci	};
112162306a36Sopenharmony_ci};
112262306a36Sopenharmony_ci
112362306a36Sopenharmony_ci
112462306a36Sopenharmony_ciunion dc_3dlut_state {
112562306a36Sopenharmony_ci	struct {
112662306a36Sopenharmony_ci		uint32_t initialized:1;		/*if 3dlut is went through color module for initialization */
112762306a36Sopenharmony_ci		uint32_t rmu_idx_valid:1;	/*if mux settings are valid*/
112862306a36Sopenharmony_ci		uint32_t rmu_mux_num:3;		/*index of mux to use*/
112962306a36Sopenharmony_ci		uint32_t mpc_rmu0_mux:4;	/*select mpcc on mux, one of the following : mpcc0, mpcc1, mpcc2, mpcc3*/
113062306a36Sopenharmony_ci		uint32_t mpc_rmu1_mux:4;
113162306a36Sopenharmony_ci		uint32_t mpc_rmu2_mux:4;
113262306a36Sopenharmony_ci		uint32_t reserved:15;
113362306a36Sopenharmony_ci	} bits;
113462306a36Sopenharmony_ci	uint32_t raw;
113562306a36Sopenharmony_ci};
113662306a36Sopenharmony_ci
113762306a36Sopenharmony_ci
113862306a36Sopenharmony_cistruct dc_3dlut {
113962306a36Sopenharmony_ci	struct kref refcount;
114062306a36Sopenharmony_ci	struct tetrahedral_params lut_3d;
114162306a36Sopenharmony_ci	struct fixed31_32 hdr_multiplier;
114262306a36Sopenharmony_ci	union dc_3dlut_state state;
114362306a36Sopenharmony_ci};
114462306a36Sopenharmony_ci/*
114562306a36Sopenharmony_ci * This structure is filled in by dc_surface_get_status and contains
114662306a36Sopenharmony_ci * the last requested address and the currently active address so the called
114762306a36Sopenharmony_ci * can determine if there are any outstanding flips
114862306a36Sopenharmony_ci */
114962306a36Sopenharmony_cistruct dc_plane_status {
115062306a36Sopenharmony_ci	struct dc_plane_address requested_address;
115162306a36Sopenharmony_ci	struct dc_plane_address current_address;
115262306a36Sopenharmony_ci	bool is_flip_pending;
115362306a36Sopenharmony_ci	bool is_right_eye;
115462306a36Sopenharmony_ci};
115562306a36Sopenharmony_ci
115662306a36Sopenharmony_ciunion surface_update_flags {
115762306a36Sopenharmony_ci
115862306a36Sopenharmony_ci	struct {
115962306a36Sopenharmony_ci		uint32_t addr_update:1;
116062306a36Sopenharmony_ci		/* Medium updates */
116162306a36Sopenharmony_ci		uint32_t dcc_change:1;
116262306a36Sopenharmony_ci		uint32_t color_space_change:1;
116362306a36Sopenharmony_ci		uint32_t horizontal_mirror_change:1;
116462306a36Sopenharmony_ci		uint32_t per_pixel_alpha_change:1;
116562306a36Sopenharmony_ci		uint32_t global_alpha_change:1;
116662306a36Sopenharmony_ci		uint32_t hdr_mult:1;
116762306a36Sopenharmony_ci		uint32_t rotation_change:1;
116862306a36Sopenharmony_ci		uint32_t swizzle_change:1;
116962306a36Sopenharmony_ci		uint32_t scaling_change:1;
117062306a36Sopenharmony_ci		uint32_t position_change:1;
117162306a36Sopenharmony_ci		uint32_t in_transfer_func_change:1;
117262306a36Sopenharmony_ci		uint32_t input_csc_change:1;
117362306a36Sopenharmony_ci		uint32_t coeff_reduction_change:1;
117462306a36Sopenharmony_ci		uint32_t output_tf_change:1;
117562306a36Sopenharmony_ci		uint32_t pixel_format_change:1;
117662306a36Sopenharmony_ci		uint32_t plane_size_change:1;
117762306a36Sopenharmony_ci		uint32_t gamut_remap_change:1;
117862306a36Sopenharmony_ci
117962306a36Sopenharmony_ci		/* Full updates */
118062306a36Sopenharmony_ci		uint32_t new_plane:1;
118162306a36Sopenharmony_ci		uint32_t bpp_change:1;
118262306a36Sopenharmony_ci		uint32_t gamma_change:1;
118362306a36Sopenharmony_ci		uint32_t bandwidth_change:1;
118462306a36Sopenharmony_ci		uint32_t clock_change:1;
118562306a36Sopenharmony_ci		uint32_t stereo_format_change:1;
118662306a36Sopenharmony_ci		uint32_t lut_3d:1;
118762306a36Sopenharmony_ci		uint32_t tmz_changed:1;
118862306a36Sopenharmony_ci		uint32_t full_update:1;
118962306a36Sopenharmony_ci	} bits;
119062306a36Sopenharmony_ci
119162306a36Sopenharmony_ci	uint32_t raw;
119262306a36Sopenharmony_ci};
119362306a36Sopenharmony_ci
119462306a36Sopenharmony_cistruct dc_plane_state {
119562306a36Sopenharmony_ci	struct dc_plane_address address;
119662306a36Sopenharmony_ci	struct dc_plane_flip_time time;
119762306a36Sopenharmony_ci	bool triplebuffer_flips;
119862306a36Sopenharmony_ci	struct scaling_taps scaling_quality;
119962306a36Sopenharmony_ci	struct rect src_rect;
120062306a36Sopenharmony_ci	struct rect dst_rect;
120162306a36Sopenharmony_ci	struct rect clip_rect;
120262306a36Sopenharmony_ci
120362306a36Sopenharmony_ci	struct plane_size plane_size;
120462306a36Sopenharmony_ci	union dc_tiling_info tiling_info;
120562306a36Sopenharmony_ci
120662306a36Sopenharmony_ci	struct dc_plane_dcc_param dcc;
120762306a36Sopenharmony_ci
120862306a36Sopenharmony_ci	struct dc_gamma *gamma_correction;
120962306a36Sopenharmony_ci	struct dc_transfer_func *in_transfer_func;
121062306a36Sopenharmony_ci	struct dc_bias_and_scale *bias_and_scale;
121162306a36Sopenharmony_ci	struct dc_csc_transform input_csc_color_matrix;
121262306a36Sopenharmony_ci	struct fixed31_32 coeff_reduction_factor;
121362306a36Sopenharmony_ci	struct fixed31_32 hdr_mult;
121462306a36Sopenharmony_ci	struct colorspace_transform gamut_remap_matrix;
121562306a36Sopenharmony_ci
121662306a36Sopenharmony_ci	// TODO: No longer used, remove
121762306a36Sopenharmony_ci	struct dc_hdr_static_metadata hdr_static_ctx;
121862306a36Sopenharmony_ci
121962306a36Sopenharmony_ci	enum dc_color_space color_space;
122062306a36Sopenharmony_ci
122162306a36Sopenharmony_ci	struct dc_3dlut *lut3d_func;
122262306a36Sopenharmony_ci	struct dc_transfer_func *in_shaper_func;
122362306a36Sopenharmony_ci	struct dc_transfer_func *blend_tf;
122462306a36Sopenharmony_ci
122562306a36Sopenharmony_ci	struct dc_transfer_func *gamcor_tf;
122662306a36Sopenharmony_ci	enum surface_pixel_format format;
122762306a36Sopenharmony_ci	enum dc_rotation_angle rotation;
122862306a36Sopenharmony_ci	enum plane_stereo_format stereo_format;
122962306a36Sopenharmony_ci
123062306a36Sopenharmony_ci	bool is_tiling_rotated;
123162306a36Sopenharmony_ci	bool per_pixel_alpha;
123262306a36Sopenharmony_ci	bool pre_multiplied_alpha;
123362306a36Sopenharmony_ci	bool global_alpha;
123462306a36Sopenharmony_ci	int  global_alpha_value;
123562306a36Sopenharmony_ci	bool visible;
123662306a36Sopenharmony_ci	bool flip_immediate;
123762306a36Sopenharmony_ci	bool horizontal_mirror;
123862306a36Sopenharmony_ci	int layer_index;
123962306a36Sopenharmony_ci
124062306a36Sopenharmony_ci	union surface_update_flags update_flags;
124162306a36Sopenharmony_ci	bool flip_int_enabled;
124262306a36Sopenharmony_ci	bool skip_manual_trigger;
124362306a36Sopenharmony_ci
124462306a36Sopenharmony_ci	/* private to DC core */
124562306a36Sopenharmony_ci	struct dc_plane_status status;
124662306a36Sopenharmony_ci	struct dc_context *ctx;
124762306a36Sopenharmony_ci
124862306a36Sopenharmony_ci	/* HACK: Workaround for forcing full reprogramming under some conditions */
124962306a36Sopenharmony_ci	bool force_full_update;
125062306a36Sopenharmony_ci
125162306a36Sopenharmony_ci	bool is_phantom; // TODO: Change mall_stream_config into mall_plane_config instead
125262306a36Sopenharmony_ci
125362306a36Sopenharmony_ci	/* private to dc_surface.c */
125462306a36Sopenharmony_ci	enum dc_irq_source irq_source;
125562306a36Sopenharmony_ci	struct kref refcount;
125662306a36Sopenharmony_ci	struct tg_color visual_confirm_color;
125762306a36Sopenharmony_ci
125862306a36Sopenharmony_ci	bool is_statically_allocated;
125962306a36Sopenharmony_ci};
126062306a36Sopenharmony_ci
126162306a36Sopenharmony_cistruct dc_plane_info {
126262306a36Sopenharmony_ci	struct plane_size plane_size;
126362306a36Sopenharmony_ci	union dc_tiling_info tiling_info;
126462306a36Sopenharmony_ci	struct dc_plane_dcc_param dcc;
126562306a36Sopenharmony_ci	enum surface_pixel_format format;
126662306a36Sopenharmony_ci	enum dc_rotation_angle rotation;
126762306a36Sopenharmony_ci	enum plane_stereo_format stereo_format;
126862306a36Sopenharmony_ci	enum dc_color_space color_space;
126962306a36Sopenharmony_ci	bool horizontal_mirror;
127062306a36Sopenharmony_ci	bool visible;
127162306a36Sopenharmony_ci	bool per_pixel_alpha;
127262306a36Sopenharmony_ci	bool pre_multiplied_alpha;
127362306a36Sopenharmony_ci	bool global_alpha;
127462306a36Sopenharmony_ci	int  global_alpha_value;
127562306a36Sopenharmony_ci	bool input_csc_enabled;
127662306a36Sopenharmony_ci	int layer_index;
127762306a36Sopenharmony_ci};
127862306a36Sopenharmony_ci
127962306a36Sopenharmony_cistruct dc_scaling_info {
128062306a36Sopenharmony_ci	struct rect src_rect;
128162306a36Sopenharmony_ci	struct rect dst_rect;
128262306a36Sopenharmony_ci	struct rect clip_rect;
128362306a36Sopenharmony_ci	struct scaling_taps scaling_quality;
128462306a36Sopenharmony_ci};
128562306a36Sopenharmony_ci
128662306a36Sopenharmony_cistruct dc_fast_update {
128762306a36Sopenharmony_ci	const struct dc_flip_addrs *flip_addr;
128862306a36Sopenharmony_ci	const struct dc_gamma *gamma;
128962306a36Sopenharmony_ci	const struct colorspace_transform *gamut_remap_matrix;
129062306a36Sopenharmony_ci	const struct dc_csc_transform *input_csc_color_matrix;
129162306a36Sopenharmony_ci	const struct fixed31_32 *coeff_reduction_factor;
129262306a36Sopenharmony_ci	struct dc_transfer_func *out_transfer_func;
129362306a36Sopenharmony_ci	struct dc_csc_transform *output_csc_transform;
129462306a36Sopenharmony_ci};
129562306a36Sopenharmony_ci
129662306a36Sopenharmony_cistruct dc_surface_update {
129762306a36Sopenharmony_ci	struct dc_plane_state *surface;
129862306a36Sopenharmony_ci
129962306a36Sopenharmony_ci	/* isr safe update parameters.  null means no updates */
130062306a36Sopenharmony_ci	const struct dc_flip_addrs *flip_addr;
130162306a36Sopenharmony_ci	const struct dc_plane_info *plane_info;
130262306a36Sopenharmony_ci	const struct dc_scaling_info *scaling_info;
130362306a36Sopenharmony_ci	struct fixed31_32 hdr_mult;
130462306a36Sopenharmony_ci	/* following updates require alloc/sleep/spin that is not isr safe,
130562306a36Sopenharmony_ci	 * null means no updates
130662306a36Sopenharmony_ci	 */
130762306a36Sopenharmony_ci	const struct dc_gamma *gamma;
130862306a36Sopenharmony_ci	const struct dc_transfer_func *in_transfer_func;
130962306a36Sopenharmony_ci
131062306a36Sopenharmony_ci	const struct dc_csc_transform *input_csc_color_matrix;
131162306a36Sopenharmony_ci	const struct fixed31_32 *coeff_reduction_factor;
131262306a36Sopenharmony_ci	const struct dc_transfer_func *func_shaper;
131362306a36Sopenharmony_ci	const struct dc_3dlut *lut3d_func;
131462306a36Sopenharmony_ci	const struct dc_transfer_func *blend_tf;
131562306a36Sopenharmony_ci	const struct colorspace_transform *gamut_remap_matrix;
131662306a36Sopenharmony_ci};
131762306a36Sopenharmony_ci
131862306a36Sopenharmony_ci/*
131962306a36Sopenharmony_ci * Create a new surface with default parameters;
132062306a36Sopenharmony_ci */
132162306a36Sopenharmony_cistruct dc_plane_state *dc_create_plane_state(struct dc *dc);
132262306a36Sopenharmony_ciconst struct dc_plane_status *dc_plane_get_status(
132362306a36Sopenharmony_ci		const struct dc_plane_state *plane_state);
132462306a36Sopenharmony_ci
132562306a36Sopenharmony_civoid dc_plane_state_retain(struct dc_plane_state *plane_state);
132662306a36Sopenharmony_civoid dc_plane_state_release(struct dc_plane_state *plane_state);
132762306a36Sopenharmony_ci
132862306a36Sopenharmony_civoid dc_gamma_retain(struct dc_gamma *dc_gamma);
132962306a36Sopenharmony_civoid dc_gamma_release(struct dc_gamma **dc_gamma);
133062306a36Sopenharmony_cistruct dc_gamma *dc_create_gamma(void);
133162306a36Sopenharmony_ci
133262306a36Sopenharmony_civoid dc_transfer_func_retain(struct dc_transfer_func *dc_tf);
133362306a36Sopenharmony_civoid dc_transfer_func_release(struct dc_transfer_func *dc_tf);
133462306a36Sopenharmony_cistruct dc_transfer_func *dc_create_transfer_func(void);
133562306a36Sopenharmony_ci
133662306a36Sopenharmony_cistruct dc_3dlut *dc_create_3dlut_func(void);
133762306a36Sopenharmony_civoid dc_3dlut_func_release(struct dc_3dlut *lut);
133862306a36Sopenharmony_civoid dc_3dlut_func_retain(struct dc_3dlut *lut);
133962306a36Sopenharmony_ci
134062306a36Sopenharmony_civoid dc_post_update_surfaces_to_stream(
134162306a36Sopenharmony_ci		struct dc *dc);
134262306a36Sopenharmony_ci
134362306a36Sopenharmony_ci#include "dc_stream.h"
134462306a36Sopenharmony_ci
134562306a36Sopenharmony_ci/**
134662306a36Sopenharmony_ci * struct dc_validation_set - Struct to store surface/stream associations for validation
134762306a36Sopenharmony_ci */
134862306a36Sopenharmony_cistruct dc_validation_set {
134962306a36Sopenharmony_ci	/**
135062306a36Sopenharmony_ci	 * @stream: Stream state properties
135162306a36Sopenharmony_ci	 */
135262306a36Sopenharmony_ci	struct dc_stream_state *stream;
135362306a36Sopenharmony_ci
135462306a36Sopenharmony_ci	/**
135562306a36Sopenharmony_ci	 * @plane_states: Surface state
135662306a36Sopenharmony_ci	 */
135762306a36Sopenharmony_ci	struct dc_plane_state *plane_states[MAX_SURFACES];
135862306a36Sopenharmony_ci
135962306a36Sopenharmony_ci	/**
136062306a36Sopenharmony_ci	 * @plane_count: Total of active planes
136162306a36Sopenharmony_ci	 */
136262306a36Sopenharmony_ci	uint8_t plane_count;
136362306a36Sopenharmony_ci};
136462306a36Sopenharmony_ci
136562306a36Sopenharmony_cibool dc_validate_boot_timing(const struct dc *dc,
136662306a36Sopenharmony_ci				const struct dc_sink *sink,
136762306a36Sopenharmony_ci				struct dc_crtc_timing *crtc_timing);
136862306a36Sopenharmony_ci
136962306a36Sopenharmony_cienum dc_status dc_validate_plane(struct dc *dc, const struct dc_plane_state *plane_state);
137062306a36Sopenharmony_ci
137162306a36Sopenharmony_civoid get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info);
137262306a36Sopenharmony_ci
137362306a36Sopenharmony_cienum dc_status dc_validate_with_context(struct dc *dc,
137462306a36Sopenharmony_ci					const struct dc_validation_set set[],
137562306a36Sopenharmony_ci					int set_count,
137662306a36Sopenharmony_ci					struct dc_state *context,
137762306a36Sopenharmony_ci					bool fast_validate);
137862306a36Sopenharmony_ci
137962306a36Sopenharmony_cibool dc_set_generic_gpio_for_stereo(bool enable,
138062306a36Sopenharmony_ci		struct gpio_service *gpio_service);
138162306a36Sopenharmony_ci
138262306a36Sopenharmony_ci/*
138362306a36Sopenharmony_ci * fast_validate: we return after determining if we can support the new state,
138462306a36Sopenharmony_ci * but before we populate the programming info
138562306a36Sopenharmony_ci */
138662306a36Sopenharmony_cienum dc_status dc_validate_global_state(
138762306a36Sopenharmony_ci		struct dc *dc,
138862306a36Sopenharmony_ci		struct dc_state *new_ctx,
138962306a36Sopenharmony_ci		bool fast_validate);
139062306a36Sopenharmony_ci
139162306a36Sopenharmony_ci
139262306a36Sopenharmony_civoid dc_resource_state_construct(
139362306a36Sopenharmony_ci		const struct dc *dc,
139462306a36Sopenharmony_ci		struct dc_state *dst_ctx);
139562306a36Sopenharmony_ci
139662306a36Sopenharmony_cibool dc_acquire_release_mpc_3dlut(
139762306a36Sopenharmony_ci		struct dc *dc, bool acquire,
139862306a36Sopenharmony_ci		struct dc_stream_state *stream,
139962306a36Sopenharmony_ci		struct dc_3dlut **lut,
140062306a36Sopenharmony_ci		struct dc_transfer_func **shaper);
140162306a36Sopenharmony_ci
140262306a36Sopenharmony_civoid dc_resource_state_copy_construct(
140362306a36Sopenharmony_ci		const struct dc_state *src_ctx,
140462306a36Sopenharmony_ci		struct dc_state *dst_ctx);
140562306a36Sopenharmony_ci
140662306a36Sopenharmony_civoid dc_resource_state_copy_construct_current(
140762306a36Sopenharmony_ci		const struct dc *dc,
140862306a36Sopenharmony_ci		struct dc_state *dst_ctx);
140962306a36Sopenharmony_ci
141062306a36Sopenharmony_civoid dc_resource_state_destruct(struct dc_state *context);
141162306a36Sopenharmony_ci
141262306a36Sopenharmony_cibool dc_resource_is_dsc_encoding_supported(const struct dc *dc);
141362306a36Sopenharmony_ci
141462306a36Sopenharmony_cienum dc_status dc_commit_streams(struct dc *dc,
141562306a36Sopenharmony_ci				 struct dc_stream_state *streams[],
141662306a36Sopenharmony_ci				 uint8_t stream_count);
141762306a36Sopenharmony_ci
141862306a36Sopenharmony_cistruct dc_state *dc_create_state(struct dc *dc);
141962306a36Sopenharmony_cistruct dc_state *dc_copy_state(struct dc_state *src_ctx);
142062306a36Sopenharmony_civoid dc_retain_state(struct dc_state *context);
142162306a36Sopenharmony_civoid dc_release_state(struct dc_state *context);
142262306a36Sopenharmony_ci
142362306a36Sopenharmony_cistruct dc_plane_state *dc_get_surface_for_mpcc(struct dc *dc,
142462306a36Sopenharmony_ci		struct dc_stream_state *stream,
142562306a36Sopenharmony_ci		int mpcc_inst);
142662306a36Sopenharmony_ci
142762306a36Sopenharmony_ci
142862306a36Sopenharmony_ciuint32_t dc_get_opp_for_plane(struct dc *dc, struct dc_plane_state *plane);
142962306a36Sopenharmony_ci
143062306a36Sopenharmony_civoid dc_set_disable_128b_132b_stream_overhead(bool disable);
143162306a36Sopenharmony_ci
143262306a36Sopenharmony_ci/* The function returns minimum bandwidth required to drive a given timing
143362306a36Sopenharmony_ci * return - minimum required timing bandwidth in kbps.
143462306a36Sopenharmony_ci */
143562306a36Sopenharmony_ciuint32_t dc_bandwidth_in_kbps_from_timing(
143662306a36Sopenharmony_ci		const struct dc_crtc_timing *timing,
143762306a36Sopenharmony_ci		const enum dc_link_encoding_format link_encoding);
143862306a36Sopenharmony_ci
143962306a36Sopenharmony_ci/* Link Interfaces */
144062306a36Sopenharmony_ci/*
144162306a36Sopenharmony_ci * A link contains one or more sinks and their connected status.
144262306a36Sopenharmony_ci * The currently active signal type (HDMI, DP-SST, DP-MST) is also reported.
144362306a36Sopenharmony_ci */
144462306a36Sopenharmony_cistruct dc_link {
144562306a36Sopenharmony_ci	struct dc_sink *remote_sinks[MAX_SINKS_PER_LINK];
144662306a36Sopenharmony_ci	unsigned int sink_count;
144762306a36Sopenharmony_ci	struct dc_sink *local_sink;
144862306a36Sopenharmony_ci	unsigned int link_index;
144962306a36Sopenharmony_ci	enum dc_connection_type type;
145062306a36Sopenharmony_ci	enum signal_type connector_signal;
145162306a36Sopenharmony_ci	enum dc_irq_source irq_source_hpd;
145262306a36Sopenharmony_ci	enum dc_irq_source irq_source_hpd_rx;/* aka DP Short Pulse  */
145362306a36Sopenharmony_ci
145462306a36Sopenharmony_ci	bool is_hpd_filter_disabled;
145562306a36Sopenharmony_ci	bool dp_ss_off;
145662306a36Sopenharmony_ci
145762306a36Sopenharmony_ci	/**
145862306a36Sopenharmony_ci	 * @link_state_valid:
145962306a36Sopenharmony_ci	 *
146062306a36Sopenharmony_ci	 * If there is no link and local sink, this variable should be set to
146162306a36Sopenharmony_ci	 * false. Otherwise, it should be set to true; usually, the function
146262306a36Sopenharmony_ci	 * core_link_enable_stream sets this field to true.
146362306a36Sopenharmony_ci	 */
146462306a36Sopenharmony_ci	bool link_state_valid;
146562306a36Sopenharmony_ci	bool aux_access_disabled;
146662306a36Sopenharmony_ci	bool sync_lt_in_progress;
146762306a36Sopenharmony_ci	bool skip_stream_reenable;
146862306a36Sopenharmony_ci	bool is_internal_display;
146962306a36Sopenharmony_ci	/** @todo Rename. Flag an endpoint as having a programmable mapping to a DIG encoder. */
147062306a36Sopenharmony_ci	bool is_dig_mapping_flexible;
147162306a36Sopenharmony_ci	bool hpd_status; /* HPD status of link without physical HPD pin. */
147262306a36Sopenharmony_ci	bool is_hpd_pending; /* Indicates a new received hpd */
147362306a36Sopenharmony_ci	bool is_automated; /* Indicates automated testing */
147462306a36Sopenharmony_ci
147562306a36Sopenharmony_ci	bool edp_sink_present;
147662306a36Sopenharmony_ci
147762306a36Sopenharmony_ci	struct dp_trace dp_trace;
147862306a36Sopenharmony_ci
147962306a36Sopenharmony_ci	/* caps is the same as reported_link_cap. link_traing use
148062306a36Sopenharmony_ci	 * reported_link_cap. Will clean up.  TODO
148162306a36Sopenharmony_ci	 */
148262306a36Sopenharmony_ci	struct dc_link_settings reported_link_cap;
148362306a36Sopenharmony_ci	struct dc_link_settings verified_link_cap;
148462306a36Sopenharmony_ci	struct dc_link_settings cur_link_settings;
148562306a36Sopenharmony_ci	struct dc_lane_settings cur_lane_setting[LANE_COUNT_DP_MAX];
148662306a36Sopenharmony_ci	struct dc_link_settings preferred_link_setting;
148762306a36Sopenharmony_ci	/* preferred_training_settings are override values that
148862306a36Sopenharmony_ci	 * come from DM. DM is responsible for the memory
148962306a36Sopenharmony_ci	 * management of the override pointers.
149062306a36Sopenharmony_ci	 */
149162306a36Sopenharmony_ci	struct dc_link_training_overrides preferred_training_settings;
149262306a36Sopenharmony_ci	struct dp_audio_test_data audio_test_data;
149362306a36Sopenharmony_ci
149462306a36Sopenharmony_ci	uint8_t ddc_hw_inst;
149562306a36Sopenharmony_ci
149662306a36Sopenharmony_ci	uint8_t hpd_src;
149762306a36Sopenharmony_ci
149862306a36Sopenharmony_ci	uint8_t link_enc_hw_inst;
149962306a36Sopenharmony_ci	/* DIG link encoder ID. Used as index in link encoder resource pool.
150062306a36Sopenharmony_ci	 * For links with fixed mapping to DIG, this is not changed after dc_link
150162306a36Sopenharmony_ci	 * object creation.
150262306a36Sopenharmony_ci	 */
150362306a36Sopenharmony_ci	enum engine_id eng_id;
150462306a36Sopenharmony_ci	enum engine_id dpia_preferred_eng_id;
150562306a36Sopenharmony_ci
150662306a36Sopenharmony_ci	bool test_pattern_enabled;
150762306a36Sopenharmony_ci	enum dp_test_pattern current_test_pattern;
150862306a36Sopenharmony_ci	union compliance_test_state compliance_test_state;
150962306a36Sopenharmony_ci
151062306a36Sopenharmony_ci	void *priv;
151162306a36Sopenharmony_ci
151262306a36Sopenharmony_ci	struct ddc_service *ddc;
151362306a36Sopenharmony_ci
151462306a36Sopenharmony_ci	enum dp_panel_mode panel_mode;
151562306a36Sopenharmony_ci	bool aux_mode;
151662306a36Sopenharmony_ci
151762306a36Sopenharmony_ci	/* Private to DC core */
151862306a36Sopenharmony_ci
151962306a36Sopenharmony_ci	const struct dc *dc;
152062306a36Sopenharmony_ci
152162306a36Sopenharmony_ci	struct dc_context *ctx;
152262306a36Sopenharmony_ci
152362306a36Sopenharmony_ci	struct panel_cntl *panel_cntl;
152462306a36Sopenharmony_ci	struct link_encoder *link_enc;
152562306a36Sopenharmony_ci	struct graphics_object_id link_id;
152662306a36Sopenharmony_ci	/* Endpoint type distinguishes display endpoints which do not have entries
152762306a36Sopenharmony_ci	 * in the BIOS connector table from those that do. Helps when tracking link
152862306a36Sopenharmony_ci	 * encoder to display endpoint assignments.
152962306a36Sopenharmony_ci	 */
153062306a36Sopenharmony_ci	enum display_endpoint_type ep_type;
153162306a36Sopenharmony_ci	union ddi_channel_mapping ddi_channel_mapping;
153262306a36Sopenharmony_ci	struct connector_device_tag_info device_tag;
153362306a36Sopenharmony_ci	struct dpcd_caps dpcd_caps;
153462306a36Sopenharmony_ci	uint32_t dongle_max_pix_clk;
153562306a36Sopenharmony_ci	unsigned short chip_caps;
153662306a36Sopenharmony_ci	unsigned int dpcd_sink_count;
153762306a36Sopenharmony_ci	struct hdcp_caps hdcp_caps;
153862306a36Sopenharmony_ci	enum edp_revision edp_revision;
153962306a36Sopenharmony_ci	union dpcd_sink_ext_caps dpcd_sink_ext_caps;
154062306a36Sopenharmony_ci
154162306a36Sopenharmony_ci	struct psr_settings psr_settings;
154262306a36Sopenharmony_ci
154362306a36Sopenharmony_ci	struct replay_settings replay_settings;
154462306a36Sopenharmony_ci
154562306a36Sopenharmony_ci	/* Drive settings read from integrated info table */
154662306a36Sopenharmony_ci	struct dc_lane_settings bios_forced_drive_settings;
154762306a36Sopenharmony_ci
154862306a36Sopenharmony_ci	/* Vendor specific LTTPR workaround variables */
154962306a36Sopenharmony_ci	uint8_t vendor_specific_lttpr_link_rate_wa;
155062306a36Sopenharmony_ci	bool apply_vendor_specific_lttpr_link_rate_wa;
155162306a36Sopenharmony_ci
155262306a36Sopenharmony_ci	/* MST record stream using this link */
155362306a36Sopenharmony_ci	struct link_flags {
155462306a36Sopenharmony_ci		bool dp_keep_receiver_powered;
155562306a36Sopenharmony_ci		bool dp_skip_DID2;
155662306a36Sopenharmony_ci		bool dp_skip_reset_segment;
155762306a36Sopenharmony_ci		bool dp_skip_fs_144hz;
155862306a36Sopenharmony_ci		bool dp_mot_reset_segment;
155962306a36Sopenharmony_ci		/* Some USB4 docks do not handle turning off MST DSC once it has been enabled. */
156062306a36Sopenharmony_ci		bool dpia_mst_dsc_always_on;
156162306a36Sopenharmony_ci		/* Forced DPIA into TBT3 compatibility mode. */
156262306a36Sopenharmony_ci		bool dpia_forced_tbt3_mode;
156362306a36Sopenharmony_ci		bool dongle_mode_timing_override;
156462306a36Sopenharmony_ci		bool blank_stream_on_ocs_change;
156562306a36Sopenharmony_ci		bool read_dpcd204h_on_irq_hpd;
156662306a36Sopenharmony_ci	} wa_flags;
156762306a36Sopenharmony_ci	struct link_mst_stream_allocation_table mst_stream_alloc_table;
156862306a36Sopenharmony_ci
156962306a36Sopenharmony_ci	struct dc_link_status link_status;
157062306a36Sopenharmony_ci	struct dprx_states dprx_states;
157162306a36Sopenharmony_ci
157262306a36Sopenharmony_ci	struct gpio *hpd_gpio;
157362306a36Sopenharmony_ci	enum dc_link_fec_state fec_state;
157462306a36Sopenharmony_ci	bool link_powered_externally;	// Used to bypass hardware sequencing delays when panel is powered down forcibly
157562306a36Sopenharmony_ci
157662306a36Sopenharmony_ci	struct dc_panel_config panel_config;
157762306a36Sopenharmony_ci	struct phy_state phy_state;
157862306a36Sopenharmony_ci	// BW ALLOCATON USB4 ONLY
157962306a36Sopenharmony_ci	struct dc_dpia_bw_alloc dpia_bw_alloc_config;
158062306a36Sopenharmony_ci	bool skip_implict_edp_power_control;
158162306a36Sopenharmony_ci};
158262306a36Sopenharmony_ci
158362306a36Sopenharmony_ci/* Return an enumerated dc_link.
158462306a36Sopenharmony_ci * dc_link order is constant and determined at
158562306a36Sopenharmony_ci * boot time.  They cannot be created or destroyed.
158662306a36Sopenharmony_ci * Use dc_get_caps() to get number of links.
158762306a36Sopenharmony_ci */
158862306a36Sopenharmony_cistruct dc_link *dc_get_link_at_index(struct dc *dc, uint32_t link_index);
158962306a36Sopenharmony_ci
159062306a36Sopenharmony_ci/* Return instance id of the edp link. Inst 0 is primary edp link. */
159162306a36Sopenharmony_cibool dc_get_edp_link_panel_inst(const struct dc *dc,
159262306a36Sopenharmony_ci		const struct dc_link *link,
159362306a36Sopenharmony_ci		unsigned int *inst_out);
159462306a36Sopenharmony_ci
159562306a36Sopenharmony_ci/* Return an array of link pointers to edp links. */
159662306a36Sopenharmony_civoid dc_get_edp_links(const struct dc *dc,
159762306a36Sopenharmony_ci		struct dc_link **edp_links,
159862306a36Sopenharmony_ci		int *edp_num);
159962306a36Sopenharmony_ci
160062306a36Sopenharmony_civoid dc_set_edp_power(const struct dc *dc, struct dc_link *edp_link,
160162306a36Sopenharmony_ci				 bool powerOn);
160262306a36Sopenharmony_ci
160362306a36Sopenharmony_ci/* The function initiates detection handshake over the given link. It first
160462306a36Sopenharmony_ci * determines if there are display connections over the link. If so it initiates
160562306a36Sopenharmony_ci * detection protocols supported by the connected receiver device. The function
160662306a36Sopenharmony_ci * contains protocol specific handshake sequences which are sometimes mandatory
160762306a36Sopenharmony_ci * to establish a proper connection between TX and RX. So it is always
160862306a36Sopenharmony_ci * recommended to call this function as the first link operation upon HPD event
160962306a36Sopenharmony_ci * or power up event. Upon completion, the function will update link structure
161062306a36Sopenharmony_ci * in place based on latest RX capabilities. The function may also cause dpms
161162306a36Sopenharmony_ci * to be reset to off for all currently enabled streams to the link. It is DM's
161262306a36Sopenharmony_ci * responsibility to serialize detection and DPMS updates.
161362306a36Sopenharmony_ci *
161462306a36Sopenharmony_ci * @reason - Indicate which event triggers this detection. dc may customize
161562306a36Sopenharmony_ci * detection flow depending on the triggering events.
161662306a36Sopenharmony_ci * return false - if detection is not fully completed. This could happen when
161762306a36Sopenharmony_ci * there is an unrecoverable error during detection or detection is partially
161862306a36Sopenharmony_ci * completed (detection has been delegated to dm mst manager ie.
161962306a36Sopenharmony_ci * link->connection_type == dc_connection_mst_branch when returning false).
162062306a36Sopenharmony_ci * return true - detection is completed, link has been fully updated with latest
162162306a36Sopenharmony_ci * detection result.
162262306a36Sopenharmony_ci */
162362306a36Sopenharmony_cibool dc_link_detect(struct dc_link *link, enum dc_detect_reason reason);
162462306a36Sopenharmony_ci
162562306a36Sopenharmony_cistruct dc_sink_init_data;
162662306a36Sopenharmony_ci
162762306a36Sopenharmony_ci/* When link connection type is dc_connection_mst_branch, remote sink can be
162862306a36Sopenharmony_ci * added to the link. The interface creates a remote sink and associates it with
162962306a36Sopenharmony_ci * current link. The sink will be retained by link until remove remote sink is
163062306a36Sopenharmony_ci * called.
163162306a36Sopenharmony_ci *
163262306a36Sopenharmony_ci * @dc_link - link the remote sink will be added to.
163362306a36Sopenharmony_ci * @edid - byte array of EDID raw data.
163462306a36Sopenharmony_ci * @len - size of the edid in byte
163562306a36Sopenharmony_ci * @init_data -
163662306a36Sopenharmony_ci */
163762306a36Sopenharmony_cistruct dc_sink *dc_link_add_remote_sink(
163862306a36Sopenharmony_ci		struct dc_link *dc_link,
163962306a36Sopenharmony_ci		const uint8_t *edid,
164062306a36Sopenharmony_ci		int len,
164162306a36Sopenharmony_ci		struct dc_sink_init_data *init_data);
164262306a36Sopenharmony_ci
164362306a36Sopenharmony_ci/* Remove remote sink from a link with dc_connection_mst_branch connection type.
164462306a36Sopenharmony_ci * @link - link the sink should be removed from
164562306a36Sopenharmony_ci * @sink - sink to be removed.
164662306a36Sopenharmony_ci */
164762306a36Sopenharmony_civoid dc_link_remove_remote_sink(
164862306a36Sopenharmony_ci	struct dc_link *link,
164962306a36Sopenharmony_ci	struct dc_sink *sink);
165062306a36Sopenharmony_ci
165162306a36Sopenharmony_ci/* Enable HPD interrupt handler for a given link */
165262306a36Sopenharmony_civoid dc_link_enable_hpd(const struct dc_link *link);
165362306a36Sopenharmony_ci
165462306a36Sopenharmony_ci/* Disable HPD interrupt handler for a given link */
165562306a36Sopenharmony_civoid dc_link_disable_hpd(const struct dc_link *link);
165662306a36Sopenharmony_ci
165762306a36Sopenharmony_ci/* determine if there is a sink connected to the link
165862306a36Sopenharmony_ci *
165962306a36Sopenharmony_ci * @type - dc_connection_single if connected, dc_connection_none otherwise.
166062306a36Sopenharmony_ci * return - false if an unexpected error occurs, true otherwise.
166162306a36Sopenharmony_ci *
166262306a36Sopenharmony_ci * NOTE: This function doesn't detect downstream sink connections i.e
166362306a36Sopenharmony_ci * dc_connection_mst_branch, dc_connection_sst_branch. In this case, it will
166462306a36Sopenharmony_ci * return dc_connection_single if the branch device is connected despite of
166562306a36Sopenharmony_ci * downstream sink's connection status.
166662306a36Sopenharmony_ci */
166762306a36Sopenharmony_cibool dc_link_detect_connection_type(struct dc_link *link,
166862306a36Sopenharmony_ci		enum dc_connection_type *type);
166962306a36Sopenharmony_ci
167062306a36Sopenharmony_ci/* query current hpd pin value
167162306a36Sopenharmony_ci * return - true HPD is asserted (HPD high), false otherwise (HPD low)
167262306a36Sopenharmony_ci *
167362306a36Sopenharmony_ci */
167462306a36Sopenharmony_cibool dc_link_get_hpd_state(struct dc_link *link);
167562306a36Sopenharmony_ci
167662306a36Sopenharmony_ci/* Getter for cached link status from given link */
167762306a36Sopenharmony_ciconst struct dc_link_status *dc_link_get_status(const struct dc_link *link);
167862306a36Sopenharmony_ci
167962306a36Sopenharmony_ci/* enable/disable hardware HPD filter.
168062306a36Sopenharmony_ci *
168162306a36Sopenharmony_ci * @link - The link the HPD pin is associated with.
168262306a36Sopenharmony_ci * @enable = true - enable hardware HPD filter. HPD event will only queued to irq
168362306a36Sopenharmony_ci * handler once after no HPD change has been detected within dc default HPD
168462306a36Sopenharmony_ci * filtering interval since last HPD event. i.e if display keeps toggling hpd
168562306a36Sopenharmony_ci * pulses within default HPD interval, no HPD event will be received until HPD
168662306a36Sopenharmony_ci * toggles have stopped. Then HPD event will be queued to irq handler once after
168762306a36Sopenharmony_ci * dc default HPD filtering interval since last HPD event.
168862306a36Sopenharmony_ci *
168962306a36Sopenharmony_ci * @enable = false - disable hardware HPD filter. HPD event will be queued
169062306a36Sopenharmony_ci * immediately to irq handler after no HPD change has been detected within
169162306a36Sopenharmony_ci * IRQ_HPD (aka HPD short pulse) interval (i.e 2ms).
169262306a36Sopenharmony_ci */
169362306a36Sopenharmony_civoid dc_link_enable_hpd_filter(struct dc_link *link, bool enable);
169462306a36Sopenharmony_ci
169562306a36Sopenharmony_ci/* submit i2c read/write payloads through ddc channel
169662306a36Sopenharmony_ci * @link_index - index to a link with ddc in i2c mode
169762306a36Sopenharmony_ci * @cmd - i2c command structure
169862306a36Sopenharmony_ci * return - true if success, false otherwise.
169962306a36Sopenharmony_ci */
170062306a36Sopenharmony_cibool dc_submit_i2c(
170162306a36Sopenharmony_ci		struct dc *dc,
170262306a36Sopenharmony_ci		uint32_t link_index,
170362306a36Sopenharmony_ci		struct i2c_command *cmd);
170462306a36Sopenharmony_ci
170562306a36Sopenharmony_ci/* submit i2c read/write payloads through oem channel
170662306a36Sopenharmony_ci * @link_index - index to a link with ddc in i2c mode
170762306a36Sopenharmony_ci * @cmd - i2c command structure
170862306a36Sopenharmony_ci * return - true if success, false otherwise.
170962306a36Sopenharmony_ci */
171062306a36Sopenharmony_cibool dc_submit_i2c_oem(
171162306a36Sopenharmony_ci		struct dc *dc,
171262306a36Sopenharmony_ci		struct i2c_command *cmd);
171362306a36Sopenharmony_ci
171462306a36Sopenharmony_cienum aux_return_code_type;
171562306a36Sopenharmony_ci/* Attempt to transfer the given aux payload. This function does not perform
171662306a36Sopenharmony_ci * retries or handle error states. The reply is returned in the payload->reply
171762306a36Sopenharmony_ci * and the result through operation_result. Returns the number of bytes
171862306a36Sopenharmony_ci * transferred,or -1 on a failure.
171962306a36Sopenharmony_ci */
172062306a36Sopenharmony_ciint dc_link_aux_transfer_raw(struct ddc_service *ddc,
172162306a36Sopenharmony_ci		struct aux_payload *payload,
172262306a36Sopenharmony_ci		enum aux_return_code_type *operation_result);
172362306a36Sopenharmony_ci
172462306a36Sopenharmony_cibool dc_is_oem_i2c_device_present(
172562306a36Sopenharmony_ci	struct dc *dc,
172662306a36Sopenharmony_ci	size_t slave_address
172762306a36Sopenharmony_ci);
172862306a36Sopenharmony_ci
172962306a36Sopenharmony_ci/* return true if the connected receiver supports the hdcp version */
173062306a36Sopenharmony_cibool dc_link_is_hdcp14(struct dc_link *link, enum signal_type signal);
173162306a36Sopenharmony_cibool dc_link_is_hdcp22(struct dc_link *link, enum signal_type signal);
173262306a36Sopenharmony_ci
173362306a36Sopenharmony_ci/* Notify DC about DP RX Interrupt (aka DP IRQ_HPD).
173462306a36Sopenharmony_ci *
173562306a36Sopenharmony_ci * TODO - When defer_handling is true the function will have a different purpose.
173662306a36Sopenharmony_ci * It no longer does complete hpd rx irq handling. We should create a separate
173762306a36Sopenharmony_ci * interface specifically for this case.
173862306a36Sopenharmony_ci *
173962306a36Sopenharmony_ci * Return:
174062306a36Sopenharmony_ci * true - Downstream port status changed. DM should call DC to do the
174162306a36Sopenharmony_ci * detection.
174262306a36Sopenharmony_ci * false - no change in Downstream port status. No further action required
174362306a36Sopenharmony_ci * from DM.
174462306a36Sopenharmony_ci */
174562306a36Sopenharmony_cibool dc_link_handle_hpd_rx_irq(struct dc_link *dc_link,
174662306a36Sopenharmony_ci		union hpd_irq_data *hpd_irq_dpcd_data, bool *out_link_loss,
174762306a36Sopenharmony_ci		bool defer_handling, bool *has_left_work);
174862306a36Sopenharmony_ci/* handle DP specs define test automation sequence*/
174962306a36Sopenharmony_civoid dc_link_dp_handle_automated_test(struct dc_link *link);
175062306a36Sopenharmony_ci
175162306a36Sopenharmony_ci/* handle DP Link loss sequence and try to recover RX link loss with best
175262306a36Sopenharmony_ci * effort
175362306a36Sopenharmony_ci */
175462306a36Sopenharmony_civoid dc_link_dp_handle_link_loss(struct dc_link *link);
175562306a36Sopenharmony_ci
175662306a36Sopenharmony_ci/* Determine if hpd rx irq should be handled or ignored
175762306a36Sopenharmony_ci * return true - hpd rx irq should be handled.
175862306a36Sopenharmony_ci * return false - it is safe to ignore hpd rx irq event
175962306a36Sopenharmony_ci */
176062306a36Sopenharmony_cibool dc_link_dp_allow_hpd_rx_irq(const struct dc_link *link);
176162306a36Sopenharmony_ci
176262306a36Sopenharmony_ci/* Determine if link loss is indicated with a given hpd_irq_dpcd_data.
176362306a36Sopenharmony_ci * @link - link the hpd irq data associated with
176462306a36Sopenharmony_ci * @hpd_irq_dpcd_data - input hpd irq data
176562306a36Sopenharmony_ci * return - true if hpd irq data indicates a link lost
176662306a36Sopenharmony_ci */
176762306a36Sopenharmony_cibool dc_link_check_link_loss_status(struct dc_link *link,
176862306a36Sopenharmony_ci		union hpd_irq_data *hpd_irq_dpcd_data);
176962306a36Sopenharmony_ci
177062306a36Sopenharmony_ci/* Read hpd rx irq data from a given link
177162306a36Sopenharmony_ci * @link - link where the hpd irq data should be read from
177262306a36Sopenharmony_ci * @irq_data - output hpd irq data
177362306a36Sopenharmony_ci * return - DC_OK if hpd irq data is read successfully, otherwise hpd irq data
177462306a36Sopenharmony_ci * read has failed.
177562306a36Sopenharmony_ci */
177662306a36Sopenharmony_cienum dc_status dc_link_dp_read_hpd_rx_irq_data(
177762306a36Sopenharmony_ci	struct dc_link *link,
177862306a36Sopenharmony_ci	union hpd_irq_data *irq_data);
177962306a36Sopenharmony_ci
178062306a36Sopenharmony_ci/* The function clears recorded DP RX states in the link. DM should call this
178162306a36Sopenharmony_ci * function when it is resuming from S3 power state to previously connected links.
178262306a36Sopenharmony_ci *
178362306a36Sopenharmony_ci * TODO - in the future we should consider to expand link resume interface to
178462306a36Sopenharmony_ci * support clearing previous rx states. So we don't have to rely on dm to call
178562306a36Sopenharmony_ci * this interface explicitly.
178662306a36Sopenharmony_ci */
178762306a36Sopenharmony_civoid dc_link_clear_dprx_states(struct dc_link *link);
178862306a36Sopenharmony_ci
178962306a36Sopenharmony_ci/* Destruct the mst topology of the link and reset the allocated payload table
179062306a36Sopenharmony_ci *
179162306a36Sopenharmony_ci * NOTE: this should only be called if DM chooses not to call dc_link_detect but
179262306a36Sopenharmony_ci * still wants to reset MST topology on an unplug event */
179362306a36Sopenharmony_cibool dc_link_reset_cur_dp_mst_topology(struct dc_link *link);
179462306a36Sopenharmony_ci
179562306a36Sopenharmony_ci/* The function calculates effective DP link bandwidth when a given link is
179662306a36Sopenharmony_ci * using the given link settings.
179762306a36Sopenharmony_ci *
179862306a36Sopenharmony_ci * return - total effective link bandwidth in kbps.
179962306a36Sopenharmony_ci */
180062306a36Sopenharmony_ciuint32_t dc_link_bandwidth_kbps(
180162306a36Sopenharmony_ci	const struct dc_link *link,
180262306a36Sopenharmony_ci	const struct dc_link_settings *link_setting);
180362306a36Sopenharmony_ci
180462306a36Sopenharmony_ci/* The function takes a snapshot of current link resource allocation state
180562306a36Sopenharmony_ci * @dc: pointer to dc of the dm calling this
180662306a36Sopenharmony_ci * @map: a dc link resource snapshot defined internally to dc.
180762306a36Sopenharmony_ci *
180862306a36Sopenharmony_ci * DM needs to capture a snapshot of current link resource allocation mapping
180962306a36Sopenharmony_ci * and store it in its persistent storage.
181062306a36Sopenharmony_ci *
181162306a36Sopenharmony_ci * Some of the link resource is using first come first serve policy.
181262306a36Sopenharmony_ci * The allocation mapping depends on original hotplug order. This information
181362306a36Sopenharmony_ci * is lost after driver is loaded next time. The snapshot is used in order to
181462306a36Sopenharmony_ci * restore link resource to its previous state so user will get consistent
181562306a36Sopenharmony_ci * link capability allocation across reboot.
181662306a36Sopenharmony_ci *
181762306a36Sopenharmony_ci */
181862306a36Sopenharmony_civoid dc_get_cur_link_res_map(const struct dc *dc, uint32_t *map);
181962306a36Sopenharmony_ci
182062306a36Sopenharmony_ci/* This function restores link resource allocation state from a snapshot
182162306a36Sopenharmony_ci * @dc: pointer to dc of the dm calling this
182262306a36Sopenharmony_ci * @map: a dc link resource snapshot defined internally to dc.
182362306a36Sopenharmony_ci *
182462306a36Sopenharmony_ci * DM needs to call this function after initial link detection on boot and
182562306a36Sopenharmony_ci * before first commit streams to restore link resource allocation state
182662306a36Sopenharmony_ci * from previous boot session.
182762306a36Sopenharmony_ci *
182862306a36Sopenharmony_ci * Some of the link resource is using first come first serve policy.
182962306a36Sopenharmony_ci * The allocation mapping depends on original hotplug order. This information
183062306a36Sopenharmony_ci * is lost after driver is loaded next time. The snapshot is used in order to
183162306a36Sopenharmony_ci * restore link resource to its previous state so user will get consistent
183262306a36Sopenharmony_ci * link capability allocation across reboot.
183362306a36Sopenharmony_ci *
183462306a36Sopenharmony_ci */
183562306a36Sopenharmony_civoid dc_restore_link_res_map(const struct dc *dc, uint32_t *map);
183662306a36Sopenharmony_ci
183762306a36Sopenharmony_ci/* TODO: this is not meant to be exposed to DM. Should switch to stream update
183862306a36Sopenharmony_ci * interface i.e stream_update->dsc_config
183962306a36Sopenharmony_ci */
184062306a36Sopenharmony_cibool dc_link_update_dsc_config(struct pipe_ctx *pipe_ctx);
184162306a36Sopenharmony_ci
184262306a36Sopenharmony_ci/* translate a raw link rate data to bandwidth in kbps */
184362306a36Sopenharmony_ciuint32_t dc_link_bw_kbps_from_raw_frl_link_rate_data(const struct dc *dc, uint8_t bw);
184462306a36Sopenharmony_ci
184562306a36Sopenharmony_ci/* determine the optimal bandwidth given link and required bw.
184662306a36Sopenharmony_ci * @link - current detected link
184762306a36Sopenharmony_ci * @req_bw - requested bandwidth in kbps
184862306a36Sopenharmony_ci * @link_settings - returned most optimal link settings that can fit the
184962306a36Sopenharmony_ci * requested bandwidth
185062306a36Sopenharmony_ci * return - false if link can't support requested bandwidth, true if link
185162306a36Sopenharmony_ci * settings is found.
185262306a36Sopenharmony_ci */
185362306a36Sopenharmony_cibool dc_link_decide_edp_link_settings(struct dc_link *link,
185462306a36Sopenharmony_ci		struct dc_link_settings *link_settings,
185562306a36Sopenharmony_ci		uint32_t req_bw);
185662306a36Sopenharmony_ci
185762306a36Sopenharmony_ci/* return the max dp link settings can be driven by the link without considering
185862306a36Sopenharmony_ci * connected RX device and its capability
185962306a36Sopenharmony_ci */
186062306a36Sopenharmony_cibool dc_link_dp_get_max_link_enc_cap(const struct dc_link *link,
186162306a36Sopenharmony_ci		struct dc_link_settings *max_link_enc_cap);
186262306a36Sopenharmony_ci
186362306a36Sopenharmony_ci/* determine when the link is driving MST mode, what DP link channel coding
186462306a36Sopenharmony_ci * format will be used. The decision will remain unchanged until next HPD event.
186562306a36Sopenharmony_ci *
186662306a36Sopenharmony_ci * @link -  a link with DP RX connection
186762306a36Sopenharmony_ci * return - if stream is committed to this link with MST signal type, type of
186862306a36Sopenharmony_ci * channel coding format dc will choose.
186962306a36Sopenharmony_ci */
187062306a36Sopenharmony_cienum dp_link_encoding dc_link_dp_mst_decide_link_encoding_format(
187162306a36Sopenharmony_ci		const struct dc_link *link);
187262306a36Sopenharmony_ci
187362306a36Sopenharmony_ci/* get max dp link settings the link can enable with all things considered. (i.e
187462306a36Sopenharmony_ci * TX/RX/Cable capabilities and dp override policies.
187562306a36Sopenharmony_ci *
187662306a36Sopenharmony_ci * @link - a link with DP RX connection
187762306a36Sopenharmony_ci * return - max dp link settings the link can enable.
187862306a36Sopenharmony_ci *
187962306a36Sopenharmony_ci */
188062306a36Sopenharmony_ciconst struct dc_link_settings *dc_link_get_link_cap(const struct dc_link *link);
188162306a36Sopenharmony_ci
188262306a36Sopenharmony_ci/* Get the highest encoding format that the link supports; highest meaning the
188362306a36Sopenharmony_ci * encoding format which supports the maximum bandwidth.
188462306a36Sopenharmony_ci *
188562306a36Sopenharmony_ci * @link - a link with DP RX connection
188662306a36Sopenharmony_ci * return - highest encoding format link supports.
188762306a36Sopenharmony_ci */
188862306a36Sopenharmony_cienum dc_link_encoding_format dc_link_get_highest_encoding_format(const struct dc_link *link);
188962306a36Sopenharmony_ci
189062306a36Sopenharmony_ci/* Check if a RX (ex. DP sink, MST hub, passive or active dongle) is connected
189162306a36Sopenharmony_ci * to a link with dp connector signal type.
189262306a36Sopenharmony_ci * @link - a link with dp connector signal type
189362306a36Sopenharmony_ci * return - true if connected, false otherwise
189462306a36Sopenharmony_ci */
189562306a36Sopenharmony_cibool dc_link_is_dp_sink_present(struct dc_link *link);
189662306a36Sopenharmony_ci
189762306a36Sopenharmony_ci/* Force DP lane settings update to main-link video signal and notify the change
189862306a36Sopenharmony_ci * to DP RX via DPCD. This is a debug interface used for video signal integrity
189962306a36Sopenharmony_ci * tuning purpose. The interface assumes link has already been enabled with DP
190062306a36Sopenharmony_ci * signal.
190162306a36Sopenharmony_ci *
190262306a36Sopenharmony_ci * @lt_settings - a container structure with desired hw_lane_settings
190362306a36Sopenharmony_ci */
190462306a36Sopenharmony_civoid dc_link_set_drive_settings(struct dc *dc,
190562306a36Sopenharmony_ci				struct link_training_settings *lt_settings,
190662306a36Sopenharmony_ci				struct dc_link *link);
190762306a36Sopenharmony_ci
190862306a36Sopenharmony_ci/* Enable a test pattern in Link or PHY layer in an active link for compliance
190962306a36Sopenharmony_ci * test or debugging purpose. The test pattern will remain until next un-plug.
191062306a36Sopenharmony_ci *
191162306a36Sopenharmony_ci * @link - active link with DP signal output enabled.
191262306a36Sopenharmony_ci * @test_pattern - desired test pattern to output.
191362306a36Sopenharmony_ci * NOTE: set to DP_TEST_PATTERN_VIDEO_MODE to disable previous test pattern.
191462306a36Sopenharmony_ci * @test_pattern_color_space - for video test pattern choose a desired color
191562306a36Sopenharmony_ci * space.
191662306a36Sopenharmony_ci * @p_link_settings - For PHY pattern choose a desired link settings
191762306a36Sopenharmony_ci * @p_custom_pattern - some test pattern will require a custom input to
191862306a36Sopenharmony_ci * customize some pattern details. Otherwise keep it to NULL.
191962306a36Sopenharmony_ci * @cust_pattern_size - size of the custom pattern input.
192062306a36Sopenharmony_ci *
192162306a36Sopenharmony_ci */
192262306a36Sopenharmony_cibool dc_link_dp_set_test_pattern(
192362306a36Sopenharmony_ci	struct dc_link *link,
192462306a36Sopenharmony_ci	enum dp_test_pattern test_pattern,
192562306a36Sopenharmony_ci	enum dp_test_pattern_color_space test_pattern_color_space,
192662306a36Sopenharmony_ci	const struct link_training_settings *p_link_settings,
192762306a36Sopenharmony_ci	const unsigned char *p_custom_pattern,
192862306a36Sopenharmony_ci	unsigned int cust_pattern_size);
192962306a36Sopenharmony_ci
193062306a36Sopenharmony_ci/* Force DP link settings to always use a specific value until reboot to a
193162306a36Sopenharmony_ci * specific link. If link has already been enabled, the interface will also
193262306a36Sopenharmony_ci * switch to desired link settings immediately. This is a debug interface to
193362306a36Sopenharmony_ci * generic dp issue trouble shooting.
193462306a36Sopenharmony_ci */
193562306a36Sopenharmony_civoid dc_link_set_preferred_link_settings(struct dc *dc,
193662306a36Sopenharmony_ci		struct dc_link_settings *link_setting,
193762306a36Sopenharmony_ci		struct dc_link *link);
193862306a36Sopenharmony_ci
193962306a36Sopenharmony_ci/* Force DP link to customize a specific link training behavior by overriding to
194062306a36Sopenharmony_ci * standard DP specs defined protocol. This is a debug interface to trouble shoot
194162306a36Sopenharmony_ci * display specific link training issues or apply some display specific
194262306a36Sopenharmony_ci * workaround in link training.
194362306a36Sopenharmony_ci *
194462306a36Sopenharmony_ci * @link_settings - if not NULL, force preferred link settings to the link.
194562306a36Sopenharmony_ci * @lt_override - a set of override pointers. If any pointer is none NULL, dc
194662306a36Sopenharmony_ci * will apply this particular override in future link training. If NULL is
194762306a36Sopenharmony_ci * passed in, dc resets previous overrides.
194862306a36Sopenharmony_ci * NOTE: DM must keep the memory from override pointers until DM resets preferred
194962306a36Sopenharmony_ci * training settings.
195062306a36Sopenharmony_ci */
195162306a36Sopenharmony_civoid dc_link_set_preferred_training_settings(struct dc *dc,
195262306a36Sopenharmony_ci		struct dc_link_settings *link_setting,
195362306a36Sopenharmony_ci		struct dc_link_training_overrides *lt_overrides,
195462306a36Sopenharmony_ci		struct dc_link *link,
195562306a36Sopenharmony_ci		bool skip_immediate_retrain);
195662306a36Sopenharmony_ci
195762306a36Sopenharmony_ci/* return - true if FEC is supported with connected DP RX, false otherwise */
195862306a36Sopenharmony_cibool dc_link_is_fec_supported(const struct dc_link *link);
195962306a36Sopenharmony_ci
196062306a36Sopenharmony_ci/* query FEC enablement policy to determine if FEC will be enabled by dc during
196162306a36Sopenharmony_ci * link enablement.
196262306a36Sopenharmony_ci * return - true if FEC should be enabled, false otherwise.
196362306a36Sopenharmony_ci */
196462306a36Sopenharmony_cibool dc_link_should_enable_fec(const struct dc_link *link);
196562306a36Sopenharmony_ci
196662306a36Sopenharmony_ci/* determine lttpr mode the current link should be enabled with a specific link
196762306a36Sopenharmony_ci * settings.
196862306a36Sopenharmony_ci */
196962306a36Sopenharmony_cienum lttpr_mode dc_link_decide_lttpr_mode(struct dc_link *link,
197062306a36Sopenharmony_ci		struct dc_link_settings *link_setting);
197162306a36Sopenharmony_ci
197262306a36Sopenharmony_ci/* Force DP RX to update its power state.
197362306a36Sopenharmony_ci * NOTE: this interface doesn't update dp main-link. Calling this function will
197462306a36Sopenharmony_ci * cause DP TX main-link and DP RX power states out of sync. DM has to restore
197562306a36Sopenharmony_ci * RX power state back upon finish DM specific execution requiring DP RX in a
197662306a36Sopenharmony_ci * specific power state.
197762306a36Sopenharmony_ci * @on - true to set DP RX in D0 power state, false to set DP RX in D3 power
197862306a36Sopenharmony_ci * state.
197962306a36Sopenharmony_ci */
198062306a36Sopenharmony_civoid dc_link_dp_receiver_power_ctrl(struct dc_link *link, bool on);
198162306a36Sopenharmony_ci
198262306a36Sopenharmony_ci/* Force link to read base dp receiver caps from dpcd 000h - 00Fh and overwrite
198362306a36Sopenharmony_ci * current value read from extended receiver cap from 02200h - 0220Fh.
198462306a36Sopenharmony_ci * Some DP RX has problems of providing accurate DP receiver caps from extended
198562306a36Sopenharmony_ci * field, this interface is a workaround to revert link back to use base caps.
198662306a36Sopenharmony_ci */
198762306a36Sopenharmony_civoid dc_link_overwrite_extended_receiver_cap(
198862306a36Sopenharmony_ci		struct dc_link *link);
198962306a36Sopenharmony_ci
199062306a36Sopenharmony_civoid dc_link_edp_panel_backlight_power_on(struct dc_link *link,
199162306a36Sopenharmony_ci		bool wait_for_hpd);
199262306a36Sopenharmony_ci
199362306a36Sopenharmony_ci/* Set backlight level of an embedded panel (eDP, LVDS).
199462306a36Sopenharmony_ci * backlight_pwm_u16_16 is unsigned 32 bit with 16 bit integer
199562306a36Sopenharmony_ci * and 16 bit fractional, where 1.0 is max backlight value.
199662306a36Sopenharmony_ci */
199762306a36Sopenharmony_cibool dc_link_set_backlight_level(const struct dc_link *dc_link,
199862306a36Sopenharmony_ci		uint32_t backlight_pwm_u16_16,
199962306a36Sopenharmony_ci		uint32_t frame_ramp);
200062306a36Sopenharmony_ci
200162306a36Sopenharmony_ci/* Set/get nits-based backlight level of an embedded panel (eDP, LVDS). */
200262306a36Sopenharmony_cibool dc_link_set_backlight_level_nits(struct dc_link *link,
200362306a36Sopenharmony_ci		bool isHDR,
200462306a36Sopenharmony_ci		uint32_t backlight_millinits,
200562306a36Sopenharmony_ci		uint32_t transition_time_in_ms);
200662306a36Sopenharmony_ci
200762306a36Sopenharmony_cibool dc_link_get_backlight_level_nits(struct dc_link *link,
200862306a36Sopenharmony_ci		uint32_t *backlight_millinits,
200962306a36Sopenharmony_ci		uint32_t *backlight_millinits_peak);
201062306a36Sopenharmony_ci
201162306a36Sopenharmony_ciint dc_link_get_backlight_level(const struct dc_link *dc_link);
201262306a36Sopenharmony_ci
201362306a36Sopenharmony_ciint dc_link_get_target_backlight_pwm(const struct dc_link *link);
201462306a36Sopenharmony_ci
201562306a36Sopenharmony_cibool dc_link_set_psr_allow_active(struct dc_link *dc_link, const bool *enable,
201662306a36Sopenharmony_ci		bool wait, bool force_static, const unsigned int *power_opts);
201762306a36Sopenharmony_ci
201862306a36Sopenharmony_cibool dc_link_get_psr_state(const struct dc_link *dc_link, enum dc_psr_state *state);
201962306a36Sopenharmony_ci
202062306a36Sopenharmony_cibool dc_link_setup_psr(struct dc_link *dc_link,
202162306a36Sopenharmony_ci		const struct dc_stream_state *stream, struct psr_config *psr_config,
202262306a36Sopenharmony_ci		struct psr_context *psr_context);
202362306a36Sopenharmony_ci
202462306a36Sopenharmony_cibool dc_link_get_replay_state(const struct dc_link *dc_link, uint64_t *state);
202562306a36Sopenharmony_ci
202662306a36Sopenharmony_ci/* On eDP links this function call will stall until T12 has elapsed.
202762306a36Sopenharmony_ci * If the panel is not in power off state, this function will return
202862306a36Sopenharmony_ci * immediately.
202962306a36Sopenharmony_ci */
203062306a36Sopenharmony_cibool dc_link_wait_for_t12(struct dc_link *link);
203162306a36Sopenharmony_ci
203262306a36Sopenharmony_ci/* Determine if dp trace has been initialized to reflect upto date result *
203362306a36Sopenharmony_ci * return - true if trace is initialized and has valid data. False dp trace
203462306a36Sopenharmony_ci * doesn't have valid result.
203562306a36Sopenharmony_ci */
203662306a36Sopenharmony_cibool dc_dp_trace_is_initialized(struct dc_link *link);
203762306a36Sopenharmony_ci
203862306a36Sopenharmony_ci/* Query a dp trace flag to indicate if the current dp trace data has been
203962306a36Sopenharmony_ci * logged before
204062306a36Sopenharmony_ci */
204162306a36Sopenharmony_cibool dc_dp_trace_is_logged(struct dc_link *link,
204262306a36Sopenharmony_ci		bool in_detection);
204362306a36Sopenharmony_ci
204462306a36Sopenharmony_ci/* Set dp trace flag to indicate whether DM has already logged the current dp
204562306a36Sopenharmony_ci * trace data. DM can set is_logged to true upon logging and check
204662306a36Sopenharmony_ci * dc_dp_trace_is_logged before logging to avoid logging the same result twice.
204762306a36Sopenharmony_ci */
204862306a36Sopenharmony_civoid dc_dp_trace_set_is_logged_flag(struct dc_link *link,
204962306a36Sopenharmony_ci		bool in_detection,
205062306a36Sopenharmony_ci		bool is_logged);
205162306a36Sopenharmony_ci
205262306a36Sopenharmony_ci/* Obtain driver time stamp for last dp link training end. The time stamp is
205362306a36Sopenharmony_ci * formatted based on dm_get_timestamp DM function.
205462306a36Sopenharmony_ci * @in_detection - true to get link training end time stamp of last link
205562306a36Sopenharmony_ci * training in detection sequence. false to get link training end time stamp
205662306a36Sopenharmony_ci * of last link training in commit (dpms) sequence
205762306a36Sopenharmony_ci */
205862306a36Sopenharmony_ciunsigned long long dc_dp_trace_get_lt_end_timestamp(struct dc_link *link,
205962306a36Sopenharmony_ci		bool in_detection);
206062306a36Sopenharmony_ci
206162306a36Sopenharmony_ci/* Get how many link training attempts dc has done with latest sequence.
206262306a36Sopenharmony_ci * @in_detection - true to get link training count of last link
206362306a36Sopenharmony_ci * training in detection sequence. false to get link training count of last link
206462306a36Sopenharmony_ci * training in commit (dpms) sequence
206562306a36Sopenharmony_ci */
206662306a36Sopenharmony_ciconst struct dp_trace_lt_counts *dc_dp_trace_get_lt_counts(struct dc_link *link,
206762306a36Sopenharmony_ci		bool in_detection);
206862306a36Sopenharmony_ci
206962306a36Sopenharmony_ci/* Get how many link loss has happened since last link training attempts */
207062306a36Sopenharmony_ciunsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link);
207162306a36Sopenharmony_ci
207262306a36Sopenharmony_ci/*
207362306a36Sopenharmony_ci *  USB4 DPIA BW ALLOCATION PUBLIC FUNCTIONS
207462306a36Sopenharmony_ci */
207562306a36Sopenharmony_ci/*
207662306a36Sopenharmony_ci * Send a request from DP-Tx requesting to allocate BW remotely after
207762306a36Sopenharmony_ci * allocating it locally. This will get processed by CM and a CB function
207862306a36Sopenharmony_ci * will be called.
207962306a36Sopenharmony_ci *
208062306a36Sopenharmony_ci * @link: pointer to the dc_link struct instance
208162306a36Sopenharmony_ci * @req_bw: The requested bw in Kbyte to allocated
208262306a36Sopenharmony_ci *
208362306a36Sopenharmony_ci * return: none
208462306a36Sopenharmony_ci */
208562306a36Sopenharmony_civoid dc_link_set_usb4_req_bw_req(struct dc_link *link, int req_bw);
208662306a36Sopenharmony_ci
208762306a36Sopenharmony_ci/*
208862306a36Sopenharmony_ci * Handle function for when the status of the Request above is complete.
208962306a36Sopenharmony_ci * We will find out the result of allocating on CM and update structs.
209062306a36Sopenharmony_ci *
209162306a36Sopenharmony_ci * @link: pointer to the dc_link struct instance
209262306a36Sopenharmony_ci * @bw: Allocated or Estimated BW depending on the result
209362306a36Sopenharmony_ci * @result: Response type
209462306a36Sopenharmony_ci *
209562306a36Sopenharmony_ci * return: none
209662306a36Sopenharmony_ci */
209762306a36Sopenharmony_civoid dc_link_handle_usb4_bw_alloc_response(struct dc_link *link,
209862306a36Sopenharmony_ci		uint8_t bw, uint8_t result);
209962306a36Sopenharmony_ci
210062306a36Sopenharmony_ci/*
210162306a36Sopenharmony_ci * Handle the USB4 BW Allocation related functionality here:
210262306a36Sopenharmony_ci * Plug => Try to allocate max bw from timing parameters supported by the sink
210362306a36Sopenharmony_ci * Unplug => de-allocate bw
210462306a36Sopenharmony_ci *
210562306a36Sopenharmony_ci * @link: pointer to the dc_link struct instance
210662306a36Sopenharmony_ci * @peak_bw: Peak bw used by the link/sink
210762306a36Sopenharmony_ci *
210862306a36Sopenharmony_ci * return: allocated bw else return 0
210962306a36Sopenharmony_ci */
211062306a36Sopenharmony_ciint dc_link_dp_dpia_handle_usb4_bandwidth_allocation_for_link(
211162306a36Sopenharmony_ci		struct dc_link *link, int peak_bw);
211262306a36Sopenharmony_ci
211362306a36Sopenharmony_ci/*
211462306a36Sopenharmony_ci * Validate the BW of all the valid DPIA links to make sure it doesn't exceed
211562306a36Sopenharmony_ci * available BW for each host router
211662306a36Sopenharmony_ci *
211762306a36Sopenharmony_ci * @dc: pointer to dc struct
211862306a36Sopenharmony_ci * @stream: pointer to all possible streams
211962306a36Sopenharmony_ci * @count: number of valid DPIA streams
212062306a36Sopenharmony_ci *
212162306a36Sopenharmony_ci * return: TRUE if bw used by DPIAs doesn't exceed available BW else return FALSE
212262306a36Sopenharmony_ci */
212362306a36Sopenharmony_cibool dc_link_dp_dpia_validate(struct dc *dc, const struct dc_stream_state *streams,
212462306a36Sopenharmony_ci		const unsigned int count);
212562306a36Sopenharmony_ci
212662306a36Sopenharmony_ci/* Sink Interfaces - A sink corresponds to a display output device */
212762306a36Sopenharmony_ci
212862306a36Sopenharmony_cistruct dc_container_id {
212962306a36Sopenharmony_ci	// 128bit GUID in binary form
213062306a36Sopenharmony_ci	unsigned char  guid[16];
213162306a36Sopenharmony_ci	// 8 byte port ID -> ELD.PortID
213262306a36Sopenharmony_ci	unsigned int   portId[2];
213362306a36Sopenharmony_ci	// 128bit GUID in binary formufacturer name -> ELD.ManufacturerName
213462306a36Sopenharmony_ci	unsigned short manufacturerName;
213562306a36Sopenharmony_ci	// 2 byte product code -> ELD.ProductCode
213662306a36Sopenharmony_ci	unsigned short productCode;
213762306a36Sopenharmony_ci};
213862306a36Sopenharmony_ci
213962306a36Sopenharmony_ci
214062306a36Sopenharmony_cistruct dc_sink_dsc_caps {
214162306a36Sopenharmony_ci	// 'true' if these are virtual DPCD's DSC caps (immediately upstream of sink in MST topology),
214262306a36Sopenharmony_ci	// 'false' if they are sink's DSC caps
214362306a36Sopenharmony_ci	bool is_virtual_dpcd_dsc;
214462306a36Sopenharmony_ci#if defined(CONFIG_DRM_AMD_DC_FP)
214562306a36Sopenharmony_ci	// 'true' if MST topology supports DSC passthrough for sink
214662306a36Sopenharmony_ci	// 'false' if MST topology does not support DSC passthrough
214762306a36Sopenharmony_ci	bool is_dsc_passthrough_supported;
214862306a36Sopenharmony_ci#endif
214962306a36Sopenharmony_ci	struct dsc_dec_dpcd_caps dsc_dec_caps;
215062306a36Sopenharmony_ci};
215162306a36Sopenharmony_ci
215262306a36Sopenharmony_cistruct dc_sink_fec_caps {
215362306a36Sopenharmony_ci	bool is_rx_fec_supported;
215462306a36Sopenharmony_ci	bool is_topology_fec_supported;
215562306a36Sopenharmony_ci};
215662306a36Sopenharmony_ci
215762306a36Sopenharmony_cistruct scdc_caps {
215862306a36Sopenharmony_ci	union hdmi_scdc_manufacturer_OUI_data manufacturer_OUI;
215962306a36Sopenharmony_ci	union hdmi_scdc_device_id_data device_id;
216062306a36Sopenharmony_ci};
216162306a36Sopenharmony_ci
216262306a36Sopenharmony_ci/*
216362306a36Sopenharmony_ci * The sink structure contains EDID and other display device properties
216462306a36Sopenharmony_ci */
216562306a36Sopenharmony_cistruct dc_sink {
216662306a36Sopenharmony_ci	enum signal_type sink_signal;
216762306a36Sopenharmony_ci	struct dc_edid dc_edid; /* raw edid */
216862306a36Sopenharmony_ci	struct dc_edid_caps edid_caps; /* parse display caps */
216962306a36Sopenharmony_ci	struct dc_container_id *dc_container_id;
217062306a36Sopenharmony_ci	uint32_t dongle_max_pix_clk;
217162306a36Sopenharmony_ci	void *priv;
217262306a36Sopenharmony_ci	struct stereo_3d_features features_3d[TIMING_3D_FORMAT_MAX];
217362306a36Sopenharmony_ci	bool converter_disable_audio;
217462306a36Sopenharmony_ci
217562306a36Sopenharmony_ci	struct scdc_caps scdc_caps;
217662306a36Sopenharmony_ci	struct dc_sink_dsc_caps dsc_caps;
217762306a36Sopenharmony_ci	struct dc_sink_fec_caps fec_caps;
217862306a36Sopenharmony_ci
217962306a36Sopenharmony_ci	bool is_vsc_sdp_colorimetry_supported;
218062306a36Sopenharmony_ci
218162306a36Sopenharmony_ci	/* private to DC core */
218262306a36Sopenharmony_ci	struct dc_link *link;
218362306a36Sopenharmony_ci	struct dc_context *ctx;
218462306a36Sopenharmony_ci
218562306a36Sopenharmony_ci	uint32_t sink_id;
218662306a36Sopenharmony_ci
218762306a36Sopenharmony_ci	/* private to dc_sink.c */
218862306a36Sopenharmony_ci	// refcount must be the last member in dc_sink, since we want the
218962306a36Sopenharmony_ci	// sink structure to be logically cloneable up to (but not including)
219062306a36Sopenharmony_ci	// refcount
219162306a36Sopenharmony_ci	struct kref refcount;
219262306a36Sopenharmony_ci};
219362306a36Sopenharmony_ci
219462306a36Sopenharmony_civoid dc_sink_retain(struct dc_sink *sink);
219562306a36Sopenharmony_civoid dc_sink_release(struct dc_sink *sink);
219662306a36Sopenharmony_ci
219762306a36Sopenharmony_cistruct dc_sink_init_data {
219862306a36Sopenharmony_ci	enum signal_type sink_signal;
219962306a36Sopenharmony_ci	struct dc_link *link;
220062306a36Sopenharmony_ci	uint32_t dongle_max_pix_clk;
220162306a36Sopenharmony_ci	bool converter_disable_audio;
220262306a36Sopenharmony_ci};
220362306a36Sopenharmony_ci
220462306a36Sopenharmony_cistruct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params);
220562306a36Sopenharmony_ci
220662306a36Sopenharmony_ci/* Newer interfaces  */
220762306a36Sopenharmony_cistruct dc_cursor {
220862306a36Sopenharmony_ci	struct dc_plane_address address;
220962306a36Sopenharmony_ci	struct dc_cursor_attributes attributes;
221062306a36Sopenharmony_ci};
221162306a36Sopenharmony_ci
221262306a36Sopenharmony_ci
221362306a36Sopenharmony_ci/* Interrupt interfaces */
221462306a36Sopenharmony_cienum dc_irq_source dc_interrupt_to_irq_source(
221562306a36Sopenharmony_ci		struct dc *dc,
221662306a36Sopenharmony_ci		uint32_t src_id,
221762306a36Sopenharmony_ci		uint32_t ext_id);
221862306a36Sopenharmony_cibool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable);
221962306a36Sopenharmony_civoid dc_interrupt_ack(struct dc *dc, enum dc_irq_source src);
222062306a36Sopenharmony_cienum dc_irq_source dc_get_hpd_irq_source_at_index(
222162306a36Sopenharmony_ci		struct dc *dc, uint32_t link_index);
222262306a36Sopenharmony_ci
222362306a36Sopenharmony_civoid dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable);
222462306a36Sopenharmony_ci
222562306a36Sopenharmony_ci/* Power Interfaces */
222662306a36Sopenharmony_ci
222762306a36Sopenharmony_civoid dc_set_power_state(
222862306a36Sopenharmony_ci		struct dc *dc,
222962306a36Sopenharmony_ci		enum dc_acpi_cm_power_state power_state);
223062306a36Sopenharmony_civoid dc_resume(struct dc *dc);
223162306a36Sopenharmony_ci
223262306a36Sopenharmony_civoid dc_power_down_on_boot(struct dc *dc);
223362306a36Sopenharmony_ci
223462306a36Sopenharmony_ci/*
223562306a36Sopenharmony_ci * HDCP Interfaces
223662306a36Sopenharmony_ci */
223762306a36Sopenharmony_cienum hdcp_message_status dc_process_hdcp_msg(
223862306a36Sopenharmony_ci		enum signal_type signal,
223962306a36Sopenharmony_ci		struct dc_link *link,
224062306a36Sopenharmony_ci		struct hdcp_protection_message *message_info);
224162306a36Sopenharmony_cibool dc_is_dmcu_initialized(struct dc *dc);
224262306a36Sopenharmony_ci
224362306a36Sopenharmony_cienum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping);
224462306a36Sopenharmony_civoid dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg);
224562306a36Sopenharmony_ci
224662306a36Sopenharmony_cibool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc, struct dc_plane_state *plane,
224762306a36Sopenharmony_ci				struct dc_cursor_attributes *cursor_attr);
224862306a36Sopenharmony_ci
224962306a36Sopenharmony_civoid dc_allow_idle_optimizations(struct dc *dc, bool allow);
225062306a36Sopenharmony_ci
225162306a36Sopenharmony_ci/* set min and max memory clock to lowest and highest DPM level, respectively */
225262306a36Sopenharmony_civoid dc_unlock_memory_clock_frequency(struct dc *dc);
225362306a36Sopenharmony_ci
225462306a36Sopenharmony_ci/* set min memory clock to the min required for current mode, max to maxDPM */
225562306a36Sopenharmony_civoid dc_lock_memory_clock_frequency(struct dc *dc);
225662306a36Sopenharmony_ci
225762306a36Sopenharmony_ci/* set soft max for memclk, to be used for AC/DC switching clock limitations */
225862306a36Sopenharmony_civoid dc_enable_dcmode_clk_limit(struct dc *dc, bool enable);
225962306a36Sopenharmony_ci
226062306a36Sopenharmony_ci/* cleanup on driver unload */
226162306a36Sopenharmony_civoid dc_hardware_release(struct dc *dc);
226262306a36Sopenharmony_ci
226362306a36Sopenharmony_ci/* disables fw based mclk switch */
226462306a36Sopenharmony_civoid dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(struct dc *dc);
226562306a36Sopenharmony_ci
226662306a36Sopenharmony_cibool dc_set_psr_allow_active(struct dc *dc, bool enable);
226762306a36Sopenharmony_civoid dc_z10_restore(const struct dc *dc);
226862306a36Sopenharmony_civoid dc_z10_save_init(struct dc *dc);
226962306a36Sopenharmony_ci
227062306a36Sopenharmony_cibool dc_is_dmub_outbox_supported(struct dc *dc);
227162306a36Sopenharmony_cibool dc_enable_dmub_notifications(struct dc *dc);
227262306a36Sopenharmony_ci
227362306a36Sopenharmony_cibool dc_abm_save_restore(
227462306a36Sopenharmony_ci		struct dc *dc,
227562306a36Sopenharmony_ci		struct dc_stream_state *stream,
227662306a36Sopenharmony_ci		struct abm_save_restore *pData);
227762306a36Sopenharmony_ci
227862306a36Sopenharmony_civoid dc_enable_dmub_outbox(struct dc *dc);
227962306a36Sopenharmony_ci
228062306a36Sopenharmony_cibool dc_process_dmub_aux_transfer_async(struct dc *dc,
228162306a36Sopenharmony_ci				uint32_t link_index,
228262306a36Sopenharmony_ci				struct aux_payload *payload);
228362306a36Sopenharmony_ci
228462306a36Sopenharmony_ci/* Get dc link index from dpia port index */
228562306a36Sopenharmony_ciuint8_t get_link_index_from_dpia_port_index(const struct dc *dc,
228662306a36Sopenharmony_ci				uint8_t dpia_port_index);
228762306a36Sopenharmony_ci
228862306a36Sopenharmony_cibool dc_process_dmub_set_config_async(struct dc *dc,
228962306a36Sopenharmony_ci				uint32_t link_index,
229062306a36Sopenharmony_ci				struct set_config_cmd_payload *payload,
229162306a36Sopenharmony_ci				struct dmub_notification *notify);
229262306a36Sopenharmony_ci
229362306a36Sopenharmony_cienum dc_status dc_process_dmub_set_mst_slots(const struct dc *dc,
229462306a36Sopenharmony_ci				uint32_t link_index,
229562306a36Sopenharmony_ci				uint8_t mst_alloc_slots,
229662306a36Sopenharmony_ci				uint8_t *mst_slots_in_use);
229762306a36Sopenharmony_ci
229862306a36Sopenharmony_civoid dc_process_dmub_dpia_hpd_int_enable(const struct dc *dc,
229962306a36Sopenharmony_ci				uint32_t hpd_int_enable);
230062306a36Sopenharmony_ci
230162306a36Sopenharmony_civoid dc_print_dmub_diagnostic_data(const struct dc *dc);
230262306a36Sopenharmony_ci
230362306a36Sopenharmony_civoid dc_query_current_properties(struct dc *dc, struct dc_current_properties *properties);
230462306a36Sopenharmony_ci
230562306a36Sopenharmony_ci/* DSC Interfaces */
230662306a36Sopenharmony_ci#include "dc_dsc.h"
230762306a36Sopenharmony_ci
230862306a36Sopenharmony_ci/* Disable acc mode Interfaces */
230962306a36Sopenharmony_civoid dc_disable_accelerated_mode(struct dc *dc);
231062306a36Sopenharmony_ci
231162306a36Sopenharmony_cibool dc_is_timing_changed(struct dc_stream_state *cur_stream,
231262306a36Sopenharmony_ci		       struct dc_stream_state *new_stream);
231362306a36Sopenharmony_ci
231462306a36Sopenharmony_ci#endif /* DC_INTERFACE_H_ */
2315