Resguardo inicial

This commit is contained in:
lastdragon
2026-09-06 12:53:21 -06:00
parent 662efe3c2a
commit ad2088d178
94853 changed files with 43200404 additions and 0 deletions
@@ -0,0 +1,166 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef BW_FIXED_H_
#define BW_FIXED_H_
#define BW_FIXED_BITS_PER_FRACTIONAL_PART 24
#define BW_FIXED_GET_INTEGER_PART(x) ((x) >> BW_FIXED_BITS_PER_FRACTIONAL_PART)
struct bw_fixed {
int64_t value;
};
#define BW_FIXED_MIN_I32 \
(int64_t)(-(1LL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART)))
#define BW_FIXED_MAX_I32 \
(int64_t)((1ULL << (63 - BW_FIXED_BITS_PER_FRACTIONAL_PART)) - 1)
static inline struct bw_fixed bw_min2(const struct bw_fixed arg1,
const struct bw_fixed arg2)
{
return (arg1.value <= arg2.value) ? arg1 : arg2;
}
static inline struct bw_fixed bw_max2(const struct bw_fixed arg1,
const struct bw_fixed arg2)
{
return (arg2.value <= arg1.value) ? arg1 : arg2;
}
static inline struct bw_fixed bw_min3(struct bw_fixed v1,
struct bw_fixed v2,
struct bw_fixed v3)
{
return bw_min2(bw_min2(v1, v2), v3);
}
static inline struct bw_fixed bw_max3(struct bw_fixed v1,
struct bw_fixed v2,
struct bw_fixed v3)
{
return bw_max2(bw_max2(v1, v2), v3);
}
struct bw_fixed bw_int_to_fixed_nonconst(int64_t value);
static inline struct bw_fixed bw_int_to_fixed(int64_t value)
{
if (__builtin_constant_p(value)) {
struct bw_fixed res;
BUILD_BUG_ON(value > BW_FIXED_MAX_I32 || value < BW_FIXED_MIN_I32);
res.value = value << BW_FIXED_BITS_PER_FRACTIONAL_PART;
return res;
} else
return bw_int_to_fixed_nonconst(value);
}
static inline int32_t bw_fixed_to_int(struct bw_fixed value)
{
return (int32_t)BW_FIXED_GET_INTEGER_PART(value.value);
}
struct bw_fixed bw_frc_to_fixed(int64_t num, int64_t denum);
static inline struct bw_fixed fixed31_32_to_bw_fixed(int64_t raw)
{
struct bw_fixed result = { 0 };
if (raw < 0) {
raw = -raw;
result.value = -(raw >> (32 - BW_FIXED_BITS_PER_FRACTIONAL_PART));
} else {
result.value = raw >> (32 - BW_FIXED_BITS_PER_FRACTIONAL_PART);
}
return result;
}
static inline struct bw_fixed bw_add(const struct bw_fixed arg1,
const struct bw_fixed arg2)
{
struct bw_fixed res;
res.value = arg1.value + arg2.value;
return res;
}
static inline struct bw_fixed bw_sub(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
struct bw_fixed res;
res.value = arg1.value - arg2.value;
return res;
}
struct bw_fixed bw_mul(const struct bw_fixed arg1, const struct bw_fixed arg2);
static inline struct bw_fixed bw_div(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return bw_frc_to_fixed(arg1.value, arg2.value);
}
static inline struct bw_fixed bw_mod(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
struct bw_fixed res;
div64_u64_rem((uint64_t)arg1.value, (uint64_t)arg2.value, (uint64_t *)&res.value);
return res;
}
struct bw_fixed bw_floor2(const struct bw_fixed arg, const struct bw_fixed significance);
struct bw_fixed bw_ceil2(const struct bw_fixed arg, const struct bw_fixed significance);
static inline bool bw_equ(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value == arg2.value;
}
static inline bool bw_neq(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value != arg2.value;
}
static inline bool bw_leq(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value <= arg2.value;
}
static inline bool bw_meq(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value >= arg2.value;
}
static inline bool bw_ltn(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value < arg2.value;
}
static inline bool bw_mtn(const struct bw_fixed arg1, const struct bw_fixed arg2)
{
return arg1.value > arg2.value;
}
#endif //BW_FIXED_H_
@@ -0,0 +1,191 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_CLOCK_SOURCE_H__
#define __DC_CLOCK_SOURCE_H__
#include "dc_types.h"
#include "include/grph_object_id.h"
#include "include/bios_parser_types.h"
struct clock_source;
struct spread_spectrum_data {
uint32_t percentage; /*> In unit of 0.01% or 0.001%*/
uint32_t percentage_divider; /*> 100 or 1000 */
uint32_t freq_range_khz;
uint32_t modulation_freq_hz;
struct spread_spectrum_flags flags;
};
struct delta_sigma_data {
uint32_t feedback_amount;
uint32_t nfrac_amount;
uint32_t ds_frac_size;
uint32_t ds_frac_amount;
};
/**
* Pixel Clock Parameters structure
* These parameters are required as input
* when calculating Pixel Clock Dividers for requested Pixel Clock
*/
struct pixel_clk_flags {
uint32_t ENABLE_SS:1;
uint32_t DISPLAY_BLANKED:1;
uint32_t PROGRAM_PIXEL_CLOCK:1;
uint32_t PROGRAM_ID_CLOCK:1;
uint32_t SUPPORT_YCBCR420:1;
};
/**
* Display Port HW De spread of Reference Clock related Parameters structure
* Store it once at boot for later usage
*/
struct csdp_ref_clk_ds_params {
bool hw_dso_n_dp_ref_clk;
/* Flag for HW De Spread enabled (if enabled SS on DP Reference Clock)*/
uint32_t avg_dp_ref_clk_khz;
/* Average DP Reference clock (in KHz)*/
uint32_t ss_percentage_on_dp_ref_clk;
/* DP Reference clock SS percentage
* (not to be mixed with DP IDCLK SS from PLL Settings)*/
uint32_t ss_percentage_divider;
/* DP Reference clock SS percentage divider */
};
struct pixel_clk_params {
uint32_t requested_pix_clk_100hz;
/*> Requested Pixel Clock
* (based on Video Timing standard used for requested mode)*/
uint32_t requested_sym_clk; /* in KHz */
/*> Requested Sym Clock (relevant only for display port)*/
uint32_t dp_ref_clk; /* in KHz */
/*> DP reference clock - calculated only for DP signal for specific cases*/
struct graphics_object_id encoder_object_id;
/*> Encoder object Id - needed by VBIOS Exec table*/
enum signal_type signal_type;
/*> signalType -> Encoder Mode - needed by VBIOS Exec table*/
enum controller_id controller_id;
/*> ControllerId - which controller using this PLL*/
enum dc_color_depth color_depth;
struct csdp_ref_clk_ds_params de_spread_params;
/*> de-spread info, relevant only for on-the-fly tune-up pixel rate*/
enum dc_pixel_encoding pixel_encoding;
struct pixel_clk_flags flags;
uint32_t dio_se_pix_per_cycle;
};
/**
* Pixel Clock Dividers structure with desired Pixel Clock
* (adjusted after VBIOS exec table),
* with actually calculated Clock and reference Crystal frequency
*/
struct pll_settings {
uint32_t actual_pix_clk_100hz;
uint32_t adjusted_pix_clk_100hz;
uint32_t calculated_pix_clk_100hz;
uint32_t vco_freq;
uint32_t reference_freq;
uint32_t reference_divider;
uint32_t feedback_divider;
uint32_t fract_feedback_divider;
uint32_t pix_clk_post_divider;
uint32_t ss_percentage;
bool use_external_clk;
};
struct calc_pll_clock_source_init_data {
struct dc_bios *bp;
uint32_t min_pix_clk_pll_post_divider;
uint32_t max_pix_clk_pll_post_divider;
uint32_t min_pll_ref_divider;
uint32_t max_pll_ref_divider;
uint32_t min_override_input_pxl_clk_pll_freq_khz;
/* if not 0, override the firmware info */
uint32_t max_override_input_pxl_clk_pll_freq_khz;
/* if not 0, override the firmware info */
uint32_t num_fract_fb_divider_decimal_point;
/* number of decimal point for fractional feedback divider value */
uint32_t num_fract_fb_divider_decimal_point_precision;
/* number of decimal point to round off for fractional feedback divider value*/
struct dc_context *ctx;
};
struct calc_pll_clock_source {
uint32_t ref_freq_khz;
uint32_t min_pix_clock_pll_post_divider;
uint32_t max_pix_clock_pll_post_divider;
uint32_t min_pll_ref_divider;
uint32_t max_pll_ref_divider;
uint32_t max_vco_khz;
uint32_t min_vco_khz;
uint32_t min_pll_input_freq_khz;
uint32_t max_pll_input_freq_khz;
uint32_t fract_fb_divider_decimal_points_num;
uint32_t fract_fb_divider_factor;
uint32_t fract_fb_divider_precision;
uint32_t fract_fb_divider_precision_factor;
struct dc_context *ctx;
};
struct clock_source_funcs {
bool (*cs_power_down)(
struct clock_source *);
bool (*program_pix_clk)(
struct clock_source *,
struct pixel_clk_params *,
enum dp_link_encoding encoding,
struct pll_settings *);
uint32_t (*get_pix_clk_dividers)(
struct clock_source *,
struct pixel_clk_params *,
struct pll_settings *);
bool (*get_dp_dto_frequency_100hz)(
const struct clock_source *clock_source,
unsigned int inst,
unsigned int *pixel_clk_100hz);
bool (*override_dp_pix_clk)(
struct clock_source *clock_source,
unsigned int inst,
unsigned int pixel_clk,
unsigned int ref_clk);
};
struct clock_source {
const struct clock_source_funcs *funcs;
struct dc_context *ctx;
enum clock_source_id id;
bool dp_clk_src;
};
#endif
@@ -0,0 +1,137 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_COMPRESSOR_H__
#define __DAL_COMPRESSOR_H__
#include "include/grph_object_id.h"
#include "bios_parser_interface.h"
enum fbc_compress_ratio {
FBC_COMPRESS_RATIO_INVALID = 0,
FBC_COMPRESS_RATIO_1TO1 = 1,
FBC_COMPRESS_RATIO_2TO1 = 2,
FBC_COMPRESS_RATIO_4TO1 = 4,
FBC_COMPRESS_RATIO_8TO1 = 8,
};
union fbc_physical_address {
struct {
uint32_t low_part;
int32_t high_part;
} addr;
uint64_t quad_part;
};
struct compr_addr_and_pitch_params {
/* enum controller_id controller_id; */
uint32_t inst;
uint32_t source_view_width;
uint32_t source_view_height;
};
enum fbc_hw_max_resolution_supported {
FBC_MAX_X = 3840,
FBC_MAX_Y = 2400,
FBC_MAX_X_SG = 1920,
FBC_MAX_Y_SG = 1080,
};
struct compressor;
struct compressor_funcs {
void (*power_up_fbc)(struct compressor *cp);
void (*enable_fbc)(struct compressor *cp,
struct compr_addr_and_pitch_params *params);
void (*disable_fbc)(struct compressor *cp);
void (*set_fbc_invalidation_triggers)(struct compressor *cp,
uint32_t fbc_trigger);
void (*surface_address_and_pitch)(
struct compressor *cp,
struct compr_addr_and_pitch_params *params);
bool (*is_fbc_enabled_in_hw)(struct compressor *cp,
uint32_t *fbc_mapped_crtc_id);
};
struct compressor {
struct dc_context *ctx;
/* CONTROLLER_ID_D0 + instance, CONTROLLER_ID_UNDEFINED = 0 */
uint32_t attached_inst;
bool is_enabled;
const struct compressor_funcs *funcs;
union {
uint32_t raw;
struct {
uint32_t FBC_SUPPORT:1;
uint32_t FB_POOL:1;
uint32_t DYNAMIC_ALLOC:1;
uint32_t LPT_SUPPORT:1;
uint32_t LPT_MC_CONFIG:1;
uint32_t DUMMY_BACKEND:1;
uint32_t CLK_GATING_DISABLED:1;
} bits;
} options;
union fbc_physical_address compr_surface_address;
uint32_t embedded_panel_h_size;
uint32_t embedded_panel_v_size;
uint32_t memory_bus_width;
uint32_t banks_num;
uint32_t raw_size;
uint32_t channel_interleave_size;
uint32_t dram_channels_num;
uint32_t allocated_size;
uint32_t preferred_requested_size;
uint32_t lpt_channels_num;
enum fbc_compress_ratio min_compress_ratio;
};
struct fbc_input_info {
bool dynamic_fbc_buffer_alloc;
unsigned int source_view_width;
unsigned int source_view_height;
unsigned int num_of_active_targets;
};
struct fbc_requested_compressed_size {
unsigned int preferred_size;
unsigned int preferred_size_alignment;
unsigned int min_size;
unsigned int min_size_alignment;
union {
struct {
/* Above preferedSize must be allocated in FB pool */
unsigned int preferred_must_be_framebuffer_pool : 1;
/* Above minSize must be allocated in FB pool */
unsigned int min_must_be_framebuffer_pool : 1;
} bits;
unsigned int flags;
};
};
#endif
@@ -0,0 +1,72 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef _CORE_STATUS_H_
#define _CORE_STATUS_H_
#include "dc_hw_types.h"
enum dc_status {
DC_OK = 1,
DC_NO_CONTROLLER_RESOURCE = 2,
DC_NO_STREAM_ENC_RESOURCE = 3,
DC_NO_CLOCK_SOURCE_RESOURCE = 4,
DC_FAIL_CONTROLLER_VALIDATE = 5,
DC_FAIL_ENC_VALIDATE = 6,
DC_FAIL_ATTACH_SURFACES = 7,
DC_FAIL_DETACH_SURFACES = 8,
DC_FAIL_SURFACE_VALIDATE = 9,
DC_NO_DP_LINK_BANDWIDTH = 10,
DC_EXCEED_DONGLE_CAP = 11,
DC_SURFACE_PIXEL_FORMAT_UNSUPPORTED = 12,
DC_FAIL_BANDWIDTH_VALIDATE = 13, /* BW and Watermark validation */
DC_FAIL_SCALING = 14,
DC_FAIL_DP_LINK_TRAINING = 15,
DC_FAIL_DSC_VALIDATE = 16,
DC_NO_DSC_RESOURCE = 17,
DC_FAIL_UNSUPPORTED_1 = 18,
DC_FAIL_HDMI_FRL_LINK_TRAINING = 19,
DC_NO_HDMI_FRL_LINK_BANDWIDTH = 20,
DC_FAIL_CLK_EXCEED_MAX = 21,
DC_FAIL_CLK_BELOW_MIN = 22, /*THIS IS MIN PER IP*/
DC_FAIL_CLK_BELOW_CFG_REQUIRED = 23, /*THIS IS hard_min in PPLIB*/
DC_NOT_SUPPORTED = 24,
DC_UNSUPPORTED_VALUE = 25,
DC_NO_LINK_ENC_RESOURCE = 26,
DC_FAIL_DP_PAYLOAD_ALLOCATION = 27,
DC_FAIL_DP_LINK_BANDWIDTH = 28,
DC_FAIL_HW_CURSOR_SUPPORT = 29,
DC_FAIL_DP_TUNNEL_BW_VALIDATE = 30,
DC_ERROR_UNEXPECTED = -1
};
char *dc_status_to_str(enum dc_status status);
char *dc_pixel_encoding_to_str(enum dc_pixel_encoding pixel_encoding);
char *dc_color_depth_to_str(enum dc_color_depth color_depth);
#endif /* _CORE_STATUS_H_ */
@@ -0,0 +1,738 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef _CORE_TYPES_H_
#define _CORE_TYPES_H_
#include "dc.h"
#include "dce_calcs.h"
#include "dcn_calcs.h"
#include "ddc_service_types.h"
#include "dc_bios_types.h"
#include "mem_input.h"
#include "hubp.h"
#include "mpc.h"
#include "dwb.h"
#include "hw/dio.h"
#include "mcif_wb.h"
#include "panel_cntl.h"
#include "dmub/inc/dmub_cmd.h"
#include "pg_cntl.h"
#include "sspl/dc_spl.h"
#define MAX_CLOCK_SOURCES 7
#define MAX_SVP_PHANTOM_STREAMS 2
#define MAX_SVP_PHANTOM_PLANES 2
#include "grph_object_id.h"
#include "link_encoder.h"
#include "stream_encoder.h"
#include "clock_source.h"
#include "audio.h"
#include "dm_pp_smu.h"
#include "dm_cp_psp.h"
#include "link_hwss.h"
/********** DAL Core*********************/
#include "transform.h"
#include "dpp.h"
#include "dml2_0/dml21/inc/dml_top_dchub_registers.h"
#include "dml2_0/dml21/inc/dml_top_types.h"
struct resource_pool;
struct dc_state;
struct resource_context;
struct clk_bw_params;
struct dc_mcache_params;
#define MAX_RMCM_INST 2
struct resource_funcs {
enum engine_id (*get_preferred_eng_id_dpia)(unsigned int dpia_index);
void (*destroy)(struct resource_pool **pool);
void (*link_init)(struct dc_link *link);
struct panel_cntl*(*panel_cntl_create)(
const struct panel_cntl_init_data *panel_cntl_init_data);
struct link_encoder *(*link_enc_create)(
struct dc_context *ctx,
const struct encoder_init_data *init);
/* Create a minimal link encoder object with no dc_link object
* associated with it. */
struct link_encoder *(*link_enc_create_minimal)(struct dc_context *ctx, enum engine_id eng_id);
struct hpo_frl_link_encoder *(*hpo_frl_link_enc_create)(
enum engine_id eng_id,
struct dc_context *ctx);
enum dc_status (*validate_bandwidth)(
struct dc *dc,
struct dc_state *context,
enum dc_validate_mode validate_mode);
void (*calculate_wm_and_dlg)(
struct dc *dc, struct dc_state *context,
display_e2e_pipe_params_st *pipes,
int pipe_cnt,
int vlevel);
void (*update_soc_for_wm_a)(
struct dc *dc, struct dc_state *context);
unsigned int (*calculate_mall_ways_from_bytes)(
const struct dc *dc,
unsigned int total_size_in_mall_bytes);
void (*prepare_mcache_programming)(
struct dc *dc,
struct dc_state *context);
/**
* @populate_dml_pipes - Populate pipe data struct
*
* Returns:
* Total of pipes available in the specific ASIC.
*/
int (*populate_dml_pipes)(
struct dc *dc,
struct dc_state *context,
display_e2e_pipe_params_st *pipes,
enum dc_validate_mode validate_mode);
/*
* Algorithm for assigning available link encoders to links.
*
* Update link_enc_assignments table and link_enc_avail list accordingly in
* struct resource_context.
*/
void (*link_encs_assign)(
struct dc *dc,
struct dc_state *state,
struct dc_stream_state *streams[],
uint8_t stream_count);
/*
* Unassign a link encoder from a stream.
*
* Update link_enc_assignments table and link_enc_avail list accordingly in
* struct resource_context.
*/
void (*link_enc_unassign)(
struct dc_state *state,
struct dc_stream_state *stream);
enum dc_status (*validate_global)(
struct dc *dc,
struct dc_state *context);
struct pipe_ctx *(*acquire_free_pipe_as_secondary_dpp_pipe)(
const struct dc_state *cur_ctx,
struct dc_state *new_ctx,
const struct resource_pool *pool,
const struct pipe_ctx *opp_head_pipe);
struct pipe_ctx *(*acquire_free_pipe_as_secondary_opp_head)(
const struct dc_state *cur_ctx,
struct dc_state *new_ctx,
const struct resource_pool *pool,
const struct pipe_ctx *otg_master);
void (*release_pipe)(struct dc_state *context,
struct pipe_ctx *pipe,
const struct resource_pool *pool);
enum dc_status (*validate_plane)(
const struct dc_plane_state *plane_state,
struct dc_caps *caps);
enum dc_status (*add_stream_to_ctx)(
struct dc *dc,
struct dc_state *new_ctx,
struct dc_stream_state *dc_stream);
enum dc_status (*remove_stream_from_ctx)(
struct dc *dc,
struct dc_state *new_ctx,
struct dc_stream_state *stream);
enum dc_status (*patch_unknown_plane_state)(
struct dc_plane_state *plane_state);
struct stream_encoder *(*find_first_free_match_stream_enc_for_link)(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream);
void (*populate_dml_writeback_from_context)(
struct dc *dc,
struct resource_context *res_ctx,
display_e2e_pipe_params_st *pipes);
void (*set_mcif_arb_params)(
struct dc *dc,
struct dc_state *context,
display_e2e_pipe_params_st *pipes,
int pipe_cnt);
void (*update_bw_bounding_box)(
struct dc *dc,
struct clk_bw_params *bw_params);
bool (*acquire_post_bldn_3dlut)(
struct resource_context *res_ctx,
const struct resource_pool *pool,
int mpcc_id,
struct dc_3dlut **lut,
struct dc_transfer_func **shaper);
bool (*release_post_bldn_3dlut)(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct dc_3dlut **lut,
struct dc_transfer_func **shaper);
enum dc_status (*add_dsc_to_stream_resource)(
struct dc *dc, struct dc_state *state,
struct dc_stream_state *stream);
void (*add_phantom_pipes)(
struct dc *dc,
struct dc_state *context,
display_e2e_pipe_params_st *pipes,
unsigned int pipe_cnt,
unsigned int index);
void (*get_panel_config_defaults)(struct dc_panel_config *panel_config);
void (*get_default_tiling_info)(struct dc_tiling_info *tiling_info);
void (*build_pipe_pix_clk_params)(struct pipe_ctx *pipe_ctx);
/*
* Get indicator of power from a context that went through full validation
*/
int (*get_power_profile)(const struct dc_state *context);
unsigned int (*get_det_buffer_size)(const struct dc_state *context);
unsigned int (*get_vstartup_for_pipe)(struct pipe_ctx *pipe_ctx);
unsigned int (*get_max_hw_cursor_size)(const struct dc *dc,
struct dc_state *state,
const struct dc_stream_state *stream);
bool (*program_mcache_pipe_config)(struct dc_state *context,
const struct dc_mcache_params *mcache_params);
enum dc_status (*update_dc_state_for_encoder_switch)(struct dc_link *link,
struct dc_link_settings *link_setting,
uint8_t pipe_count,
struct pipe_ctx *pipes,
struct audio_output *audio_output);
};
struct audio_support{
bool dp_audio;
bool hdmi_audio_on_dongle;
bool hdmi_audio_native;
};
#define NO_UNDERLAY_PIPE -1
struct resource_pool {
struct mem_input *mis[MAX_PIPES];
struct hubp *hubps[MAX_PIPES];
struct input_pixel_processor *ipps[MAX_PIPES];
struct transform *transforms[MAX_PIPES];
struct dpp *dpps[MAX_PIPES];
struct output_pixel_processor *opps[MAX_PIPES];
struct timing_generator *timing_generators[MAX_PIPES];
struct stream_encoder *stream_enc[MAX_PIPES * 2];
struct hubbub *hubbub;
struct dio *dio;
struct mpc *mpc;
struct pp_smu_funcs *pp_smu;
struct dce_aux *engines[MAX_PIPES];
struct dce_i2c_hw *hw_i2cs[MAX_PIPES];
struct dce_i2c_sw *sw_i2cs[MAX_PIPES];
bool i2c_hw_buffer_in_use;
struct dwbc *dwbc[MAX_DWB_PIPES];
struct mcif_wb *mcif_wb[MAX_DWB_PIPES];
struct {
unsigned int gsl_0:1;
unsigned int gsl_1:1;
unsigned int gsl_2:1;
} gsl_groups;
struct display_stream_compressor *dscs[MAX_PIPES];
unsigned int pipe_count;
unsigned int underlay_pipe_index;
unsigned int stream_enc_count;
/* An array for accessing the link encoder objects that have been created.
* Index in array corresponds to engine ID - viz. 0: ENGINE_ID_DIGA
*/
struct link_encoder *link_encoders[MAX_LINK_ENCODERS];
/* Number of DIG link encoder objects created - i.e. number of valid
* entries in link_encoders array.
*/
unsigned int dig_link_enc_count;
/* Number of USB4 DPIA (DisplayPort Input Adapter) link objects created.*/
unsigned int usb4_dpia_count;
unsigned int hpo_frl_stream_enc_count;
struct hpo_frl_stream_encoder *hpo_frl_stream_enc[MAX_HDMI_FRL_ENCODERS];
unsigned int hpo_frl_link_enc_count;
struct hpo_frl_link_encoder *hpo_frl_link_enc[MAX_HDMI_FRL_ENCODERS];
unsigned int hpo_dp_stream_enc_count;
struct hpo_dp_stream_encoder *hpo_dp_stream_enc[MAX_HPO_DP2_ENCODERS];
unsigned int hpo_dp_link_enc_count;
struct hpo_dp_link_encoder *hpo_dp_link_enc[MAX_HPO_DP2_LINK_ENCODERS];
struct dc_3dlut *mpc_lut[MAX_PIPES];
struct dc_transfer_func *mpc_shaper[MAX_PIPES];
struct dc_rmcm_3dlut rmcm_3dlut[MAX_RMCM_INST];
struct {
unsigned int xtalin_clock_inKhz;
unsigned int dccg_ref_clock_inKhz;
unsigned int dchub_ref_clock_inKhz;
} ref_clocks;
unsigned int timing_generator_count;
unsigned int mpcc_count;
unsigned int writeback_pipe_count;
/*
* reserved clock source for DP
*/
struct clock_source *dp_clock_source;
struct clock_source *clock_sources[MAX_CLOCK_SOURCES];
unsigned int clk_src_count;
struct audio *audios[MAX_AUDIOS];
unsigned int audio_count;
struct audio_support audio_support;
struct dccg *dccg;
struct pg_cntl *pg_cntl;
struct irq_service *irqs;
struct abm *abm;
struct dmcu *dmcu;
struct dmub_psr *psr;
struct dmub_replay *replay;
struct abm *multiple_abms[MAX_PIPES];
const struct resource_funcs *funcs;
const struct resource_caps *res_cap;
struct ddc_service *oem_device;
};
struct dcn_fe_bandwidth {
int dppclk_khz;
};
/* Parameters needed to call set_disp_pattern_generator */
struct test_pattern_params {
enum controller_dp_test_pattern test_pattern;
enum controller_dp_color_space color_space;
enum dc_color_depth color_depth;
int width;
int height;
int offset;
};
struct stream_resource {
struct output_pixel_processor *opp;
struct display_stream_compressor *dsc;
struct timing_generator *tg;
struct stream_encoder *stream_enc;
struct hpo_frl_stream_encoder *hpo_frl_stream_enc;
struct hpo_dp_stream_encoder *hpo_dp_stream_enc;
struct audio *audio;
struct pixel_clk_params pix_clk_params;
struct encoder_info_frame encoder_info_frame;
struct abm *abm;
/* There are only (num_pipes+1)/2 groups. 0 means unassigned,
* otherwise it's using group number 'gsl_group-1'
*/
uint8_t gsl_group;
struct test_pattern_params test_pattern_params;
};
struct plane_resource {
/* scl_data is scratch space required to program a plane */
struct scaler_data scl_data;
/* Below pointers to hw objects are required to enable the plane */
/* spl_in and spl_out are the input and output structures for SPL
* which are required when using Scaler Programming Library
* these are scratch spaces needed when programming a plane
*/
struct spl_in spl_in;
struct spl_out spl_out;
/* Below pointers to hw objects are required to enable the plane */
struct hubp *hubp;
struct mem_input *mi;
struct input_pixel_processor *ipp;
struct transform *xfm;
struct dpp *dpp;
uint8_t mpcc_inst;
struct dcn_fe_bandwidth bw;
};
#define LINK_RES_HPO_DP_REC_MAP__MASK 0xFFFF
#define LINK_RES_HPO_DP_REC_MAP__SHIFT 0
/* all mappable hardware resources used to enable a link */
struct link_resource {
struct link_encoder *dio_link_enc;
struct hpo_dp_link_encoder *hpo_dp_link_enc;
struct hpo_frl_link_encoder *hpo_frl_link_enc;
};
struct link_config {
struct dc_link_settings dp_link_settings;
struct dc_tunnel_settings dp_tunnel_settings;
};
union pipe_update_flags {
struct {
uint32_t enable : 1;
uint32_t disable : 1;
uint32_t odm : 1;
uint32_t global_sync : 1;
uint32_t opp_changed : 1;
uint32_t tg_changed : 1;
uint32_t mpcc : 1;
uint32_t dppclk : 1;
uint32_t hubp_interdependent : 1;
uint32_t hubp_rq_dlg_ttu : 1;
uint32_t gamut_remap : 1;
uint32_t scaler : 1;
uint32_t viewport : 1;
uint32_t plane_changed : 1;
uint32_t det_size : 1;
uint32_t unbounded_req : 1;
uint32_t test_pattern_changed : 1;
} bits;
uint32_t raw;
};
struct pixel_rate_divider {
uint32_t div_factor1;
uint32_t div_factor2;
};
enum p_state_switch_method {
P_STATE_UNKNOWN = 0,
P_STATE_V_BLANK = 1,
P_STATE_FPO,
P_STATE_V_ACTIVE,
P_STATE_SUB_VP,
P_STATE_DRR_SUB_VP,
P_STATE_V_BLANK_SUB_VP,
};
struct dsc_padding_params {
/* pixels borrowed from hblank to hactive */
uint8_t dsc_hactive_padding;
uint32_t dsc_htotal_padding;
uint32_t dsc_pix_clk_100hz;
};
struct pipe_ctx {
struct dc_plane_state *plane_state;
struct dc_stream_state *stream;
struct plane_resource plane_res;
/**
* @stream_res: Reference to DCN resource components such OPP and DSC.
*/
struct stream_resource stream_res;
struct link_resource link_res;
struct clock_source *clock_source;
struct pll_settings pll_settings;
/**
* @link_config:
*
* link config records software decision for what link config should be
* enabled given current link capability and stream during hw resource
* mapping. This is to decouple the dependency on link capability during
* dc commit or update.
*/
struct link_config link_config;
uint8_t pipe_idx;
uint8_t pipe_idx_syncd;
struct pipe_ctx *top_pipe;
struct pipe_ctx *bottom_pipe;
struct pipe_ctx *next_odm_pipe;
struct pipe_ctx *prev_odm_pipe;
struct _vcs_dpi_display_dlg_regs_st dlg_regs;
struct _vcs_dpi_display_ttu_regs_st ttu_regs;
struct _vcs_dpi_display_rq_regs_st rq_regs;
struct _vcs_dpi_display_pipe_dest_params_st pipe_dlg_param;
struct _vcs_dpi_display_rq_params_st dml_rq_param;
struct _vcs_dpi_display_dlg_sys_params_st dml_dlg_sys_param;
struct _vcs_dpi_display_e2e_pipe_params_st dml_input;
int det_buffer_size_kb;
bool unbounded_req;
unsigned int surface_size_in_mall_bytes;
struct dml2_dchub_per_pipe_register_set hubp_regs;
struct dml2_hubp_pipe_mcache_regs mcache_regs;
union dml2_global_sync_programming global_sync;
struct dwbc *dwbc;
struct mcif_wb *mcif_wb;
union pipe_update_flags update_flags;
enum p_state_switch_method p_state_type;
struct tg_color visual_confirm_color;
bool has_vactive_margin;
/* subvp_index: only valid if the pipe is a SUBVP_MAIN*/
uint8_t subvp_index;
struct pixel_rate_divider pixel_rate_divider;
struct dsc_padding_params dsc_padding_params;
/* next vupdate */
uint32_t next_vupdate;
uint32_t wait_frame_count;
bool wait_is_required;
};
/* Data used for dynamic link encoder assignment.
* Tracks current and future assignments; available link encoders;
* and mode of operation (whether to use current or future assignments).
*/
struct link_enc_cfg_context {
enum link_enc_cfg_mode mode;
struct link_enc_assignment link_enc_assignments[MAX_PIPES];
enum engine_id link_enc_avail[MAX_LINK_ENCODERS];
struct link_enc_assignment transient_assignments[MAX_PIPES];
};
struct resource_context {
struct pipe_ctx pipe_ctx[MAX_PIPES];
bool is_stream_enc_acquired[MAX_PIPES * 2];
bool is_audio_acquired[MAX_PIPES];
uint8_t clock_source_ref_count[MAX_CLOCK_SOURCES];
uint8_t dp_clock_source_ref_count;
bool is_dsc_acquired[MAX_PIPES];
struct link_enc_cfg_context link_enc_cfg_ctx;
unsigned int dio_link_enc_to_link_idx[MAX_LINK_ENCODERS];
int dio_link_enc_ref_cnts[MAX_LINK_ENCODERS];
bool is_hpo_frl_stream_enc_acquired[MAX_HDMI_FRL_ENCODERS];
unsigned int hpo_frl_link_enc_to_link_idx[MAX_HDMI_FRL_ENCODERS];
int hpo_frl_link_enc_ref_cnts[MAX_HDMI_FRL_ENCODERS];
bool is_hpo_dp_stream_enc_acquired[MAX_HPO_DP2_ENCODERS];
unsigned int hpo_dp_link_enc_to_link_idx[MAX_HPO_DP2_LINK_ENCODERS];
int hpo_dp_link_enc_ref_cnts[MAX_HPO_DP2_LINK_ENCODERS];
bool is_mpc_3dlut_acquired[MAX_PIPES];
/* used to build scalar data in dml2 and for edp backlight programming */
struct pipe_ctx temp_pipe;
};
struct dce_bw_output {
bool cpuc_state_change_enable;
bool cpup_state_change_enable;
bool stutter_mode_enable;
bool nbp_state_change_enable;
bool all_displays_in_sync;
struct dce_watermarks urgent_wm_ns[MAX_PIPES];
struct dce_watermarks stutter_exit_wm_ns[MAX_PIPES];
struct dce_watermarks stutter_entry_wm_ns[MAX_PIPES];
struct dce_watermarks nbp_state_change_wm_ns[MAX_PIPES];
int sclk_khz;
int sclk_deep_sleep_khz;
int yclk_khz;
int dispclk_khz;
int blackout_recovery_time_us;
};
struct dcn_bw_writeback {
struct mcif_arb_params mcif_wb_arb[MAX_DWB_PIPES];
};
struct dcn_bw_output {
struct dc_clocks clk;
union dcn_watermark_set watermarks;
struct dcn_bw_writeback bw_writeback;
int compbuf_size_kb;
unsigned int mall_ss_size_bytes;
unsigned int mall_ss_psr_active_size_bytes;
unsigned int mall_subvp_size_bytes;
unsigned int legacy_svp_drr_stream_index;
bool legacy_svp_drr_stream_index_valid;
struct dml2_mcache_surface_allocation mcache_allocations[DML2_MAX_PLANES];
struct dmub_cmd_fams2_global_config fams2_global_config;
union dmub_cmd_fams2_config fams2_stream_base_params[DML2_MAX_PLANES];
union {
union dmub_cmd_fams2_config fams2_stream_sub_params[DML2_MAX_PLANES];
union dmub_fams2_stream_static_sub_state_v2 fams2_stream_sub_params_v2[DML2_MAX_PLANES];
};
struct dml2_display_arb_regs arb_regs;
};
union bw_output {
struct dcn_bw_output dcn;
struct dce_bw_output dce;
};
struct bw_context {
union bw_output bw;
struct display_mode_lib dml;
struct dml2_context *dml2;
struct dml2_context *dml2_dc_power_source;
};
struct dc_dmub_cmd {
union dmub_rb_cmd dmub_cmd;
enum dm_dmub_wait_type wait_type;
};
/**
* struct dc_state - The full description of a state requested by users
*/
struct dc_state {
/**
* @streams: Stream state properties
*/
struct dc_stream_state *streams[MAX_PIPES];
/**
* @stream_status: Planes status on a given stream
*/
struct dc_stream_status stream_status[MAX_PIPES];
/**
* @phantom_streams: Stream state properties for phantoms
*/
struct dc_stream_state *phantom_streams[MAX_PHANTOM_PIPES];
/**
* @phantom_planes: Planes state properties for phantoms
*/
struct dc_plane_state *phantom_planes[MAX_PHANTOM_PIPES];
/**
* @stream_count: Total of streams in use
*/
uint8_t stream_count;
uint8_t stream_mask;
/**
* @stream_count: Total phantom streams in use
*/
uint8_t phantom_stream_count;
/**
* @stream_count: Total phantom planes in use
*/
uint8_t phantom_plane_count;
/**
* @res_ctx: Persistent state of resources
*/
struct resource_context res_ctx;
/**
* @pp_display_cfg: PowerPlay clocks and settings
* Note: this is a big struct, do *not* put on stack!
*/
struct dm_pp_display_configuration pp_display_cfg;
/**
* @dcn_bw_vars: non-stack memory to support bandwidth calculations
* Note: this is a big struct, do *not* put on stack!
*/
struct dcn_bw_internal_vars dcn_bw_vars;
struct clk_mgr *clk_mgr;
/**
* @bw_ctx: The output from bandwidth and watermark calculations and the DML
*
* Each context must have its own instance of VBA, and in order to
* initialize and obtain IP and SOC, the base DML instance from DC is
* initially copied into every context.
*/
struct bw_context bw_ctx;
struct block_sequence block_sequence[MAX_HWSS_BLOCK_SEQUENCE_SIZE];
unsigned int block_sequence_steps;
struct dc_dmub_cmd dc_dmub_cmd[10];
unsigned int dmub_cmd_count;
/**
* @refcount: refcount reference
*
* Notice that dc_state is used around the code to capture the current
* context, so we need to pass it everywhere. That's why we want to use
* kref in this struct.
*/
struct kref refcount;
struct {
unsigned int stutter_period_us;
} perf_params;
enum dc_power_source_type power_source;
};
struct replay_context {
/* ddc line */
enum channel_id aux_inst;
/* Transmitter id */
enum transmitter digbe_inst;
/* Engine Id is used for Dig Be source select */
enum engine_id digfe_inst;
/* Controller Id used for Dig Fe source select */
enum controller_id controllerId;
unsigned int line_time_in_ns;
bool os_request_force_ffu;
};
enum dc_replay_enable {
DC_REPLAY_DISABLE = 0,
DC_REPLAY_ENABLE = 1,
};
struct dc_bounding_box_max_clk {
int max_dcfclk_mhz;
int max_dispclk_mhz;
int max_dppclk_mhz;
int max_phyclk_mhz;
};
struct dc_measured_memory_qos {
uint32_t peak_bw_mbps;
uint32_t avg_bw_mbps;
uint32_t max_latency_ns;
uint32_t min_latency_ns;
uint32_t avg_latency_ns;
};
struct dc_requested_memory_qos {
uint32_t bandwidth_lb_in_mbps;
uint32_t calculated_avg_bw_in_mbps;
uint32_t max_latency_ub_in_ns;
uint32_t avg_latency_ub_in_ns;
uint32_t max_bw_budget_in_mbps;
};
#endif /* _CORE_TYPES_H_ */
@@ -0,0 +1,40 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef CUSTOM_FLOAT_H_
#define CUSTOM_FLOAT_H_
#include "bw_fixed.h"
#include "hw_shared.h"
#include "opp.h"
bool convert_to_custom_float_format(
struct fixed31_32 value,
const struct custom_float_format *format,
uint32_t *result);
#endif //CUSTOM_FLOAT_H_
@@ -0,0 +1,489 @@
/*
* Copyright 2015-2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
/**
* Bandwidth and Watermark calculations interface.
* (Refer to "DCEx_mode_support.xlsm" from Perforce.)
*/
#ifndef __DCE_CALCS_H__
#define __DCE_CALCS_H__
#include "bw_fixed.h"
struct pipe_ctx;
struct dc;
struct dc_state;
struct dce_bw_output;
enum bw_calcs_version {
BW_CALCS_VERSION_INVALID,
BW_CALCS_VERSION_CARRIZO,
BW_CALCS_VERSION_POLARIS10,
BW_CALCS_VERSION_POLARIS11,
BW_CALCS_VERSION_POLARIS12,
BW_CALCS_VERSION_VEGAM,
BW_CALCS_VERSION_STONEY,
BW_CALCS_VERSION_VEGA10
};
/*******************************************************************************
* There are three types of input into Calculations:
* 1. per-DCE static values - these are "hardcoded" properties of the DCEIP
* 2. board-level values - these are generally coming from VBIOS parser
* 3. mode/configuration values - depending Mode, Scaling number of Displays etc.
******************************************************************************/
enum bw_defines {
//Common
bw_def_no = 0,
bw_def_none = 0,
bw_def_yes = 1,
bw_def_ok = 1,
bw_def_high = 2,
bw_def_mid = 1,
bw_def_low = 0,
//Internal
bw_defs_start = 255,
bw_def_underlay422,
bw_def_underlay420_luma,
bw_def_underlay420_chroma,
bw_def_underlay444,
bw_def_graphics,
bw_def_display_write_back420_luma,
bw_def_display_write_back420_chroma,
bw_def_portrait,
bw_def_hsr_mtn_4,
bw_def_hsr_mtn_h_taps,
bw_def_ceiling__h_taps_div_4___meq_hsr,
bw_def_invalid_linear_or_stereo_mode,
bw_def_invalid_rotation_or_bpp_or_stereo,
bw_def_vsr_mtn_v_taps,
bw_def_vsr_mtn_4,
bw_def_auto,
bw_def_manual,
bw_def_exceeded_allowed_maximum_sclk,
bw_def_exceeded_allowed_page_close_open,
bw_def_exceeded_allowed_outstanding_pte_req_queue_size,
bw_def_exceeded_allowed_maximum_bw,
bw_def_landscape,
//Panning and bezel
bw_def_any_lines,
//Underlay mode
bw_def_underlay_only,
bw_def_blended,
bw_def_blend,
//Stereo mode
bw_def_mono,
bw_def_side_by_side,
bw_def_top_bottom,
//Underlay surface type
bw_def_420,
bw_def_422,
bw_def_444,
//Tiling mode
bw_def_linear,
bw_def_tiled,
bw_def_array_linear_general,
bw_def_array_linear_aligned,
bw_def_rotated_micro_tiling,
bw_def_display_micro_tiling,
//Memory type
bw_def_gddr5,
bw_def_hbm,
//Voltage
bw_def_high_no_nbp_state_change,
bw_def_0_72,
bw_def_0_8,
bw_def_0_9,
bw_def_notok = -1,
bw_def_na = -1
};
struct bw_calcs_dceip {
enum bw_calcs_version version;
uint32_t percent_of_ideal_port_bw_received_after_urgent_latency;
uint32_t max_average_percent_of_ideal_port_bw_display_can_use_in_normal_system_operation;
uint32_t max_average_percent_of_ideal_drambw_display_can_use_in_normal_system_operation;
bool large_cursor;
uint32_t cursor_max_outstanding_group_num;
bool dmif_pipe_en_fbc_chunk_tracker;
struct bw_fixed dmif_request_buffer_size;
uint32_t lines_interleaved_into_lb;
uint32_t low_power_tiling_mode;
uint32_t chunk_width;
uint32_t number_of_graphics_pipes;
uint32_t number_of_underlay_pipes;
bool display_write_back_supported;
bool argb_compression_support;
struct bw_fixed underlay_vscaler_efficiency6_bit_per_component;
struct bw_fixed underlay_vscaler_efficiency8_bit_per_component;
struct bw_fixed underlay_vscaler_efficiency10_bit_per_component;
struct bw_fixed underlay_vscaler_efficiency12_bit_per_component;
struct bw_fixed graphics_vscaler_efficiency6_bit_per_component;
struct bw_fixed graphics_vscaler_efficiency8_bit_per_component;
struct bw_fixed graphics_vscaler_efficiency10_bit_per_component;
struct bw_fixed graphics_vscaler_efficiency12_bit_per_component;
struct bw_fixed alpha_vscaler_efficiency;
uint32_t max_dmif_buffer_allocated;
uint32_t graphics_dmif_size;
uint32_t underlay_luma_dmif_size;
uint32_t underlay_chroma_dmif_size;
bool pre_downscaler_enabled;
bool underlay_downscale_prefetch_enabled;
struct bw_fixed lb_write_pixels_per_dispclk;
struct bw_fixed lb_size_per_component444;
bool graphics_lb_nodownscaling_multi_line_prefetching;
struct bw_fixed stutter_and_dram_clock_state_change_gated_before_cursor;
struct bw_fixed underlay420_luma_lb_size_per_component;
struct bw_fixed underlay420_chroma_lb_size_per_component;
struct bw_fixed underlay422_lb_size_per_component;
struct bw_fixed cursor_chunk_width;
struct bw_fixed cursor_dcp_buffer_lines;
struct bw_fixed underlay_maximum_width_efficient_for_tiling;
struct bw_fixed underlay_maximum_height_efficient_for_tiling;
struct bw_fixed peak_pte_request_to_eviction_ratio_limiting_multiple_displays_or_single_rotated_display;
struct bw_fixed peak_pte_request_to_eviction_ratio_limiting_single_display_no_rotation;
struct bw_fixed minimum_outstanding_pte_request_limit;
struct bw_fixed maximum_total_outstanding_pte_requests_allowed_by_saw;
bool limit_excessive_outstanding_dmif_requests;
struct bw_fixed linear_mode_line_request_alternation_slice;
uint32_t scatter_gather_lines_of_pte_prefetching_in_linear_mode;
uint32_t display_write_back420_luma_mcifwr_buffer_size;
uint32_t display_write_back420_chroma_mcifwr_buffer_size;
struct bw_fixed request_efficiency;
struct bw_fixed dispclk_per_request;
struct bw_fixed dispclk_ramping_factor;
struct bw_fixed display_pipe_throughput_factor;
uint32_t scatter_gather_pte_request_rows_in_tiling_mode;
struct bw_fixed mcifwr_all_surfaces_burst_time;
};
struct bw_calcs_vbios {
enum bw_defines memory_type;
uint32_t dram_channel_width_in_bits;
uint32_t number_of_dram_channels;
uint32_t number_of_dram_banks;
struct bw_fixed low_yclk; /*m_hz*/
struct bw_fixed mid_yclk; /*m_hz*/
struct bw_fixed high_yclk; /*m_hz*/
struct bw_fixed low_sclk; /*m_hz*/
struct bw_fixed mid1_sclk; /*m_hz*/
struct bw_fixed mid2_sclk; /*m_hz*/
struct bw_fixed mid3_sclk; /*m_hz*/
struct bw_fixed mid4_sclk; /*m_hz*/
struct bw_fixed mid5_sclk; /*m_hz*/
struct bw_fixed mid6_sclk; /*m_hz*/
struct bw_fixed high_sclk; /*m_hz*/
struct bw_fixed low_voltage_max_dispclk; /*m_hz*/
struct bw_fixed mid_voltage_max_dispclk; /*m_hz*/
struct bw_fixed high_voltage_max_dispclk; /*m_hz*/
struct bw_fixed low_voltage_max_phyclk;
struct bw_fixed mid_voltage_max_phyclk;
struct bw_fixed high_voltage_max_phyclk;
struct bw_fixed data_return_bus_width;
struct bw_fixed trc;
struct bw_fixed dmifmc_urgent_latency;
struct bw_fixed stutter_self_refresh_exit_latency;
struct bw_fixed stutter_self_refresh_entry_latency;
struct bw_fixed nbp_state_change_latency;
struct bw_fixed mcifwrmc_urgent_latency;
bool scatter_gather_enable;
struct bw_fixed down_spread_percentage;
uint32_t cursor_width;
uint32_t average_compression_rate;
uint32_t number_of_request_slots_gmc_reserves_for_dmif_per_channel;
struct bw_fixed blackout_duration;
struct bw_fixed maximum_blackout_recovery_time;
};
/*******************************************************************************
* Temporary data structure(s).
******************************************************************************/
#define maximum_number_of_surfaces 12
/*Units : MHz, us */
struct bw_calcs_data {
/* data for all displays */
bool display_synchronization_enabled;
uint32_t number_of_displays;
enum bw_defines underlay_surface_type;
enum bw_defines panning_and_bezel_adjustment;
enum bw_defines graphics_tiling_mode;
uint32_t graphics_lb_bpc;
uint32_t underlay_lb_bpc;
enum bw_defines underlay_tiling_mode;
enum bw_defines d0_underlay_mode;
bool d1_display_write_back_dwb_enable;
enum bw_defines d1_underlay_mode;
bool increase_voltage_to_support_mclk_switch;
bool cpup_state_change_enable;
bool cpuc_state_change_enable;
bool nbp_state_change_enable;
bool stutter_mode_enable;
uint32_t y_clk_level;
uint32_t sclk_level;
uint32_t number_of_underlay_surfaces;
uint32_t number_of_dram_wrchannels;
uint32_t chunk_request_delay;
uint32_t number_of_dram_channels;
enum bw_defines underlay_micro_tile_mode;
enum bw_defines graphics_micro_tile_mode;
struct bw_fixed max_phyclk;
struct bw_fixed dram_efficiency;
struct bw_fixed src_width_after_surface_type;
struct bw_fixed src_height_after_surface_type;
struct bw_fixed hsr_after_surface_type;
struct bw_fixed vsr_after_surface_type;
struct bw_fixed src_width_after_rotation;
struct bw_fixed src_height_after_rotation;
struct bw_fixed hsr_after_rotation;
struct bw_fixed vsr_after_rotation;
struct bw_fixed source_height_pixels;
struct bw_fixed hsr_after_stereo;
struct bw_fixed vsr_after_stereo;
struct bw_fixed source_width_in_lb;
struct bw_fixed lb_line_pitch;
struct bw_fixed underlay_maximum_source_efficient_for_tiling;
struct bw_fixed num_lines_at_frame_start;
struct bw_fixed min_dmif_size_in_time;
struct bw_fixed min_mcifwr_size_in_time;
struct bw_fixed total_requests_for_dmif_size;
struct bw_fixed peak_pte_request_to_eviction_ratio_limiting;
struct bw_fixed useful_pte_per_pte_request;
struct bw_fixed scatter_gather_pte_request_rows;
struct bw_fixed scatter_gather_row_height;
struct bw_fixed scatter_gather_pte_requests_in_vblank;
struct bw_fixed inefficient_linear_pitch_in_bytes;
struct bw_fixed cursor_total_data;
struct bw_fixed cursor_total_request_groups;
struct bw_fixed scatter_gather_total_pte_requests;
struct bw_fixed scatter_gather_total_pte_request_groups;
struct bw_fixed tile_width_in_pixels;
struct bw_fixed dmif_total_number_of_data_request_page_close_open;
struct bw_fixed mcifwr_total_number_of_data_request_page_close_open;
struct bw_fixed bytes_per_page_close_open;
struct bw_fixed mcifwr_total_page_close_open_time;
struct bw_fixed total_requests_for_adjusted_dmif_size;
struct bw_fixed total_dmifmc_urgent_trips;
struct bw_fixed total_dmifmc_urgent_latency;
struct bw_fixed total_display_reads_required_data;
struct bw_fixed total_display_reads_required_dram_access_data;
struct bw_fixed total_display_writes_required_data;
struct bw_fixed total_display_writes_required_dram_access_data;
struct bw_fixed display_reads_required_data;
struct bw_fixed display_reads_required_dram_access_data;
struct bw_fixed dmif_total_page_close_open_time;
struct bw_fixed min_cursor_memory_interface_buffer_size_in_time;
struct bw_fixed min_read_buffer_size_in_time;
struct bw_fixed display_reads_time_for_data_transfer;
struct bw_fixed display_writes_time_for_data_transfer;
struct bw_fixed dmif_required_dram_bandwidth;
struct bw_fixed mcifwr_required_dram_bandwidth;
struct bw_fixed required_dmifmc_urgent_latency_for_page_close_open;
struct bw_fixed required_mcifmcwr_urgent_latency;
struct bw_fixed required_dram_bandwidth_gbyte_per_second;
struct bw_fixed dram_bandwidth;
struct bw_fixed dmif_required_sclk;
struct bw_fixed mcifwr_required_sclk;
struct bw_fixed required_sclk;
struct bw_fixed downspread_factor;
struct bw_fixed v_scaler_efficiency;
struct bw_fixed scaler_limits_factor;
struct bw_fixed display_pipe_pixel_throughput;
struct bw_fixed total_dispclk_required_with_ramping;
struct bw_fixed total_dispclk_required_without_ramping;
struct bw_fixed total_read_request_bandwidth;
struct bw_fixed total_write_request_bandwidth;
struct bw_fixed dispclk_required_for_total_read_request_bandwidth;
struct bw_fixed total_dispclk_required_with_ramping_with_request_bandwidth;
struct bw_fixed total_dispclk_required_without_ramping_with_request_bandwidth;
struct bw_fixed dispclk;
struct bw_fixed blackout_recovery_time;
struct bw_fixed min_pixels_per_data_fifo_entry;
struct bw_fixed sclk_deep_sleep;
struct bw_fixed chunk_request_time;
struct bw_fixed cursor_request_time;
struct bw_fixed line_source_pixels_transfer_time;
struct bw_fixed dmifdram_access_efficiency;
struct bw_fixed mcifwrdram_access_efficiency;
struct bw_fixed total_average_bandwidth_no_compression;
struct bw_fixed total_average_bandwidth;
struct bw_fixed total_stutter_cycle_duration;
struct bw_fixed stutter_burst_time;
struct bw_fixed time_in_self_refresh;
struct bw_fixed stutter_efficiency;
struct bw_fixed worst_number_of_trips_to_memory;
struct bw_fixed immediate_flip_time;
struct bw_fixed latency_for_non_dmif_clients;
struct bw_fixed latency_for_non_mcifwr_clients;
struct bw_fixed dmifmc_urgent_latency_supported_in_high_sclk_and_yclk;
struct bw_fixed nbp_state_dram_speed_change_margin;
struct bw_fixed display_reads_time_for_data_transfer_and_urgent_latency;
struct bw_fixed dram_speed_change_margin;
struct bw_fixed min_vblank_dram_speed_change_margin;
struct bw_fixed min_stutter_refresh_duration;
uint32_t total_stutter_dmif_buffer_size;
uint32_t total_bytes_requested;
uint32_t min_stutter_dmif_buffer_size;
uint32_t num_stutter_bursts;
struct bw_fixed v_blank_nbp_state_dram_speed_change_latency_supported;
struct bw_fixed nbp_state_dram_speed_change_latency_supported;
bool fbc_en[maximum_number_of_surfaces];
bool lpt_en[maximum_number_of_surfaces];
bool displays_match_flag[maximum_number_of_surfaces];
bool use_alpha[maximum_number_of_surfaces];
bool orthogonal_rotation[maximum_number_of_surfaces];
bool enable[maximum_number_of_surfaces];
bool access_one_channel_only[maximum_number_of_surfaces];
bool scatter_gather_enable_for_pipe[maximum_number_of_surfaces];
bool interlace_mode[maximum_number_of_surfaces];
bool display_pstate_change_enable[maximum_number_of_surfaces];
bool line_buffer_prefetch[maximum_number_of_surfaces];
uint32_t bytes_per_pixel[maximum_number_of_surfaces];
uint32_t max_chunks_non_fbc_mode[maximum_number_of_surfaces];
uint32_t lb_bpc[maximum_number_of_surfaces];
uint32_t output_bpphdmi[maximum_number_of_surfaces];
uint32_t output_bppdp4_lane_hbr[maximum_number_of_surfaces];
uint32_t output_bppdp4_lane_hbr2[maximum_number_of_surfaces];
uint32_t output_bppdp4_lane_hbr3[maximum_number_of_surfaces];
enum bw_defines stereo_mode[maximum_number_of_surfaces];
struct bw_fixed dmif_buffer_transfer_time[maximum_number_of_surfaces];
struct bw_fixed displays_with_same_mode[maximum_number_of_surfaces];
struct bw_fixed stutter_dmif_buffer_size[maximum_number_of_surfaces];
struct bw_fixed stutter_refresh_duration[maximum_number_of_surfaces];
struct bw_fixed stutter_exit_watermark[maximum_number_of_surfaces];
struct bw_fixed stutter_entry_watermark[maximum_number_of_surfaces];
struct bw_fixed h_total[maximum_number_of_surfaces];
struct bw_fixed v_total[maximum_number_of_surfaces];
struct bw_fixed pixel_rate[maximum_number_of_surfaces];
struct bw_fixed src_width[maximum_number_of_surfaces];
struct bw_fixed pitch_in_pixels[maximum_number_of_surfaces];
struct bw_fixed pitch_in_pixels_after_surface_type[maximum_number_of_surfaces];
struct bw_fixed src_height[maximum_number_of_surfaces];
struct bw_fixed scale_ratio[maximum_number_of_surfaces];
struct bw_fixed h_taps[maximum_number_of_surfaces];
struct bw_fixed v_taps[maximum_number_of_surfaces];
struct bw_fixed h_scale_ratio[maximum_number_of_surfaces];
struct bw_fixed v_scale_ratio[maximum_number_of_surfaces];
struct bw_fixed rotation_angle[maximum_number_of_surfaces];
struct bw_fixed compression_rate[maximum_number_of_surfaces];
struct bw_fixed hsr[maximum_number_of_surfaces];
struct bw_fixed vsr[maximum_number_of_surfaces];
struct bw_fixed source_width_rounded_up_to_chunks[maximum_number_of_surfaces];
struct bw_fixed source_width_pixels[maximum_number_of_surfaces];
struct bw_fixed source_height_rounded_up_to_chunks[maximum_number_of_surfaces];
struct bw_fixed display_bandwidth[maximum_number_of_surfaces];
struct bw_fixed request_bandwidth[maximum_number_of_surfaces];
struct bw_fixed bytes_per_request[maximum_number_of_surfaces];
struct bw_fixed useful_bytes_per_request[maximum_number_of_surfaces];
struct bw_fixed lines_interleaved_in_mem_access[maximum_number_of_surfaces];
struct bw_fixed latency_hiding_lines[maximum_number_of_surfaces];
struct bw_fixed lb_partitions[maximum_number_of_surfaces];
struct bw_fixed lb_partitions_max[maximum_number_of_surfaces];
struct bw_fixed dispclk_required_with_ramping[maximum_number_of_surfaces];
struct bw_fixed dispclk_required_without_ramping[maximum_number_of_surfaces];
struct bw_fixed data_buffer_size[maximum_number_of_surfaces];
struct bw_fixed outstanding_chunk_request_limit[maximum_number_of_surfaces];
struct bw_fixed urgent_watermark[maximum_number_of_surfaces];
struct bw_fixed nbp_state_change_watermark[maximum_number_of_surfaces];
struct bw_fixed v_filter_init[maximum_number_of_surfaces];
struct bw_fixed stutter_cycle_duration[maximum_number_of_surfaces];
struct bw_fixed average_bandwidth[maximum_number_of_surfaces];
struct bw_fixed average_bandwidth_no_compression[maximum_number_of_surfaces];
struct bw_fixed scatter_gather_pte_request_limit[maximum_number_of_surfaces];
struct bw_fixed lb_size_per_component[maximum_number_of_surfaces];
struct bw_fixed memory_chunk_size_in_bytes[maximum_number_of_surfaces];
struct bw_fixed pipe_chunk_size_in_bytes[maximum_number_of_surfaces];
struct bw_fixed number_of_trips_to_memory_for_getting_apte_row[maximum_number_of_surfaces];
struct bw_fixed adjusted_data_buffer_size[maximum_number_of_surfaces];
struct bw_fixed adjusted_data_buffer_size_in_memory[maximum_number_of_surfaces];
struct bw_fixed pixels_per_data_fifo_entry[maximum_number_of_surfaces];
struct bw_fixed scatter_gather_pte_requests_in_row[maximum_number_of_surfaces];
struct bw_fixed pte_request_per_chunk[maximum_number_of_surfaces];
struct bw_fixed scatter_gather_page_width[maximum_number_of_surfaces];
struct bw_fixed scatter_gather_page_height[maximum_number_of_surfaces];
struct bw_fixed lb_lines_in_per_line_out_in_beginning_of_frame[maximum_number_of_surfaces];
struct bw_fixed lb_lines_in_per_line_out_in_middle_of_frame[maximum_number_of_surfaces];
struct bw_fixed cursor_width_pixels[maximum_number_of_surfaces];
struct bw_fixed minimum_latency_hiding[maximum_number_of_surfaces];
struct bw_fixed maximum_latency_hiding[maximum_number_of_surfaces];
struct bw_fixed minimum_latency_hiding_with_cursor[maximum_number_of_surfaces];
struct bw_fixed maximum_latency_hiding_with_cursor[maximum_number_of_surfaces];
struct bw_fixed src_pixels_for_first_output_pixel[maximum_number_of_surfaces];
struct bw_fixed src_pixels_for_last_output_pixel[maximum_number_of_surfaces];
struct bw_fixed src_data_for_first_output_pixel[maximum_number_of_surfaces];
struct bw_fixed src_data_for_last_output_pixel[maximum_number_of_surfaces];
struct bw_fixed active_time[maximum_number_of_surfaces];
struct bw_fixed horizontal_blank_and_chunk_granularity_factor[maximum_number_of_surfaces];
struct bw_fixed cursor_latency_hiding[maximum_number_of_surfaces];
struct bw_fixed v_blank_dram_speed_change_margin[maximum_number_of_surfaces];
uint32_t num_displays_with_margin[3][8];
struct bw_fixed dmif_burst_time[3][8];
struct bw_fixed mcifwr_burst_time[3][8];
struct bw_fixed line_source_transfer_time[maximum_number_of_surfaces][3][8];
struct bw_fixed dram_speed_change_line_source_transfer_time[maximum_number_of_surfaces][3][8];
struct bw_fixed min_dram_speed_change_margin[3][8];
struct bw_fixed dispclk_required_for_dram_speed_change[3][8];
struct bw_fixed dispclk_required_for_dram_speed_change_pipe[3][8];
struct bw_fixed blackout_duration_margin[3][8];
struct bw_fixed dispclk_required_for_blackout_duration[3][8];
struct bw_fixed dispclk_required_for_blackout_recovery[3][8];
struct bw_fixed dmif_required_sclk_for_urgent_latency[6];
};
/**
* Initialize structures with data which will NOT change at runtime.
*/
void bw_calcs_init(
struct bw_calcs_dceip *bw_dceip,
struct bw_calcs_vbios *bw_vbios,
struct hw_asic_id asic_id);
/**
* Return:
* true - Display(s) configuration supported.
* In this case 'calcs_output' contains data for HW programming
* false - Display(s) configuration not supported (not enough bandwidth).
*/
bool bw_calcs(
struct dc_context *ctx,
const struct bw_calcs_dceip *dceip,
const struct bw_calcs_vbios *vbios,
const struct pipe_ctx *pipe,
int pipe_count,
struct dce_bw_output *calcs_output);
#endif /* __BANDWIDTH_CALCS_H__ */
@@ -0,0 +1,43 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef _DCN_CALC_MATH_H_
#define _DCN_CALC_MATH_H_
float dcn_bw_mod(const float arg1, const float arg2);
float dcn_bw_min2(const float arg1, const float arg2);
unsigned int dcn_bw_max(const unsigned int arg1, const unsigned int arg2);
float dcn_bw_max2(const float arg1, const float arg2);
float dcn_bw_floor2(const float arg, const float significance);
float dcn_bw_floor(const float arg);
float dcn_bw_ceil2(const float arg, const float significance);
float dcn_bw_ceil(const float arg);
float dcn_bw_max3(float v1, float v2, float v3);
float dcn_bw_max5(float v1, float v2, float v3, float v4, float v5);
float dcn_bw_pow(float a, float exp);
float dcn_bw_log(float a, float b);
double dcn_bw_fabs(double a);
#endif /* _DCN_CALC_MATH_H_ */
@@ -0,0 +1,649 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
/**
* Bandwidth and Watermark calculations interface.
* (Refer to "DCEx_mode_support.xlsm" from Perforce.)
*/
#ifndef __DCN_CALCS_H__
#define __DCN_CALCS_H__
#include "bw_fixed.h"
#include "dml/display_mode_lib.h"
struct dc;
struct dc_state;
/*******************************************************************************
* DCN data structures.
******************************************************************************/
#define number_of_planes 6
#define number_of_planes_minus_one 5
#define number_of_states 4
#define number_of_states_plus_one 5
#define ddr4_dram_width 64
#define ddr4_dram_factor_single_Channel 16
enum dcn_bw_defs {
dcn_bw_v_min0p65,
dcn_bw_v_mid0p72,
dcn_bw_v_nom0p8,
dcn_bw_v_max0p9,
dcn_bw_v_max0p91,
dcn_bw_no_support = 5,
dcn_bw_yes,
dcn_bw_hor,
dcn_bw_vert,
dcn_bw_override,
dcn_bw_rgb_sub_64,
dcn_bw_rgb_sub_32,
dcn_bw_rgb_sub_16,
dcn_bw_no,
dcn_bw_sw_linear,
dcn_bw_sw_4_kb_d,
dcn_bw_sw_4_kb_d_x,
dcn_bw_sw_64_kb_d,
dcn_bw_sw_64_kb_d_t,
dcn_bw_sw_64_kb_d_x,
dcn_bw_sw_var_d,
dcn_bw_sw_var_d_x,
dcn_bw_yuv420_sub_8,
dcn_bw_sw_4_kb_s,
dcn_bw_sw_4_kb_s_x,
dcn_bw_sw_64_kb_s,
dcn_bw_sw_64_kb_s_t,
dcn_bw_sw_64_kb_s_x,
dcn_bw_writeback,
dcn_bw_444,
dcn_bw_dp,
dcn_bw_420,
dcn_bw_hdmi,
dcn_bw_sw_var_s,
dcn_bw_sw_var_s_x,
dcn_bw_yuv420_sub_10,
dcn_bw_supported_in_v_active,
dcn_bw_supported_in_v_blank,
dcn_bw_not_supported,
dcn_bw_na,
dcn_bw_encoder_8bpc,
dcn_bw_encoder_10bpc,
dcn_bw_encoder_12bpc,
dcn_bw_encoder_16bpc,
};
/*bounding box parameters*/
/*mode parameters*/
/*system configuration*/
/* display configuration*/
struct dcn_bw_internal_vars {
float voltage[number_of_states_plus_one + 1];
float max_dispclk[number_of_states_plus_one + 1];
float max_dppclk[number_of_states_plus_one + 1];
float dcfclk_per_state[number_of_states_plus_one + 1];
float phyclk_per_state[number_of_states_plus_one + 1];
float fabric_and_dram_bandwidth_per_state[number_of_states_plus_one + 1];
float sr_exit_time;
float sr_enter_plus_exit_time;
float dram_clock_change_latency;
float urgent_latency;
float write_back_latency;
float percent_of_ideal_drambw_received_after_urg_latency;
float dcfclkv_max0p9;
float dcfclkv_nom0p8;
float dcfclkv_mid0p72;
float dcfclkv_min0p65;
float max_dispclk_vmax0p9;
float max_dppclk_vmax0p9;
float max_dispclk_vnom0p8;
float max_dppclk_vnom0p8;
float max_dispclk_vmid0p72;
float max_dppclk_vmid0p72;
float max_dispclk_vmin0p65;
float max_dppclk_vmin0p65;
float socclk;
float fabric_and_dram_bandwidth_vmax0p9;
float fabric_and_dram_bandwidth_vnom0p8;
float fabric_and_dram_bandwidth_vmid0p72;
float fabric_and_dram_bandwidth_vmin0p65;
float round_trip_ping_latency_cycles;
float urgent_out_of_order_return_per_channel;
float number_of_channels;
float vmm_page_size;
float return_bus_width;
float rob_buffer_size_in_kbyte;
float det_buffer_size_in_kbyte;
float dpp_output_buffer_pixels;
float opp_output_buffer_lines;
float pixel_chunk_size_in_kbyte;
float pte_chunk_size;
float meta_chunk_size;
float writeback_chunk_size;
enum dcn_bw_defs odm_capability;
enum dcn_bw_defs dsc_capability;
float line_buffer_size;
enum dcn_bw_defs is_line_buffer_bpp_fixed;
float line_buffer_fixed_bpp;
float max_line_buffer_lines;
float writeback_luma_buffer_size;
float writeback_chroma_buffer_size;
float max_num_dpp;
float max_num_writeback;
float max_dchub_topscl_throughput;
float max_pscl_tolb_throughput;
float max_lb_tovscl_throughput;
float max_vscl_tohscl_throughput;
float max_hscl_ratio;
float max_vscl_ratio;
float max_hscl_taps;
float max_vscl_taps;
float under_scan_factor;
float phyclkv_max0p9;
float phyclkv_nom0p8;
float phyclkv_mid0p72;
float phyclkv_min0p65;
float pte_buffer_size_in_requests;
float dispclk_ramping_margin;
float downspreading;
float max_inter_dcn_tile_repeaters;
enum dcn_bw_defs can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one;
enum dcn_bw_defs bug_forcing_luma_and_chroma_request_to_same_size_fixed;
int mode;
float viewport_width[number_of_planes_minus_one + 1];
float htotal[number_of_planes_minus_one + 1];
float vtotal[number_of_planes_minus_one + 1];
float v_sync_plus_back_porch[number_of_planes_minus_one + 1];
float vactive[number_of_planes_minus_one + 1];
float pixel_clock[number_of_planes_minus_one + 1]; /*MHz*/
float viewport_height[number_of_planes_minus_one + 1];
enum dcn_bw_defs dcc_enable[number_of_planes_minus_one + 1];
float dcc_rate[number_of_planes_minus_one + 1];
enum dcn_bw_defs source_scan[number_of_planes_minus_one + 1];
float lb_bit_per_pixel[number_of_planes_minus_one + 1];
enum dcn_bw_defs source_pixel_format[number_of_planes_minus_one + 1];
enum dcn_bw_defs source_surface_mode[number_of_planes_minus_one + 1];
enum dcn_bw_defs output_format[number_of_planes_minus_one + 1];
enum dcn_bw_defs output_deep_color[number_of_planes_minus_one + 1];
enum dcn_bw_defs output[number_of_planes_minus_one + 1];
float scaler_rec_out_width[number_of_planes_minus_one + 1];
float scaler_recout_height[number_of_planes_minus_one + 1];
float underscan_output[number_of_planes_minus_one + 1];
float interlace_output[number_of_planes_minus_one + 1];
float override_hta_ps[number_of_planes_minus_one + 1];
float override_vta_ps[number_of_planes_minus_one + 1];
float override_hta_pschroma[number_of_planes_minus_one + 1];
float override_vta_pschroma[number_of_planes_minus_one + 1];
float urgent_latency_support_us[number_of_planes_minus_one + 1];
float h_ratio[number_of_planes_minus_one + 1];
float v_ratio[number_of_planes_minus_one + 1];
float htaps[number_of_planes_minus_one + 1];
float vtaps[number_of_planes_minus_one + 1];
float hta_pschroma[number_of_planes_minus_one + 1];
float vta_pschroma[number_of_planes_minus_one + 1];
enum dcn_bw_defs pte_enable;
enum dcn_bw_defs synchronized_vblank;
enum dcn_bw_defs ta_pscalculation;
int voltage_override_level;
int number_of_active_planes;
int voltage_level;
enum dcn_bw_defs immediate_flip_supported;
float dcfclk;
float max_phyclk;
float fabric_and_dram_bandwidth;
float dpp_per_plane_per_ratio[1 + 1][number_of_planes_minus_one + 1];
enum dcn_bw_defs dispclk_dppclk_support_per_ratio[1 + 1];
float required_dispclk_per_ratio[1 + 1];
enum dcn_bw_defs error_message[1 + 1];
int dispclk_dppclk_ratio;
float dpp_per_plane[number_of_planes_minus_one + 1];
float det_buffer_size_y[number_of_planes_minus_one + 1];
float det_buffer_size_c[number_of_planes_minus_one + 1];
float swath_height_y[number_of_planes_minus_one + 1];
float swath_height_c[number_of_planes_minus_one + 1];
enum dcn_bw_defs final_error_message;
float frequency;
float header_line;
float header;
enum dcn_bw_defs voltage_override;
enum dcn_bw_defs allow_different_hratio_vratio;
float acceptable_quality_hta_ps;
float acceptable_quality_vta_ps;
float no_of_dpp[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float swath_width_yper_state[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float swath_height_yper_state[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float swath_height_cper_state[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float urgent_latency_support_us_per_state[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float v_ratio_pre_ywith_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float v_ratio_pre_cwith_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float required_prefetch_pixel_data_bw_with_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float v_ratio_pre_ywithout_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float v_ratio_pre_cwithout_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
float required_prefetch_pixel_data_bw_without_immediate_flip[number_of_states_plus_one + 1][1 + 1][number_of_planes_minus_one + 1];
enum dcn_bw_defs prefetch_supported_with_immediate_flip[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs prefetch_supported_without_immediate_flip[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs v_ratio_in_prefetch_supported_with_immediate_flip[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs v_ratio_in_prefetch_supported_without_immediate_flip[number_of_states_plus_one + 1][1 + 1];
float required_dispclk[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs dispclk_dppclk_support[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs total_available_pipes_support[number_of_states_plus_one + 1][1 + 1];
float total_number_of_active_dpp[number_of_states_plus_one + 1][1 + 1];
float total_number_of_dcc_active_dpp[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs urgent_latency_support[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs mode_support_with_immediate_flip[number_of_states_plus_one + 1][1 + 1];
enum dcn_bw_defs mode_support_without_immediate_flip[number_of_states_plus_one + 1][1 + 1];
float return_bw_per_state[number_of_states_plus_one + 1];
enum dcn_bw_defs dio_support[number_of_states_plus_one + 1];
float urgent_round_trip_and_out_of_order_latency_per_state[number_of_states_plus_one + 1];
enum dcn_bw_defs rob_support[number_of_states_plus_one + 1];
enum dcn_bw_defs bandwidth_support[number_of_states_plus_one + 1];
float prefetch_bw[number_of_planes_minus_one + 1];
float meta_pte_bytes_per_frame[number_of_planes_minus_one + 1];
float meta_row_bytes[number_of_planes_minus_one + 1];
float dpte_bytes_per_row[number_of_planes_minus_one + 1];
float prefetch_lines_y[number_of_planes_minus_one + 1];
float prefetch_lines_c[number_of_planes_minus_one + 1];
float max_num_sw_y[number_of_planes_minus_one + 1];
float max_num_sw_c[number_of_planes_minus_one + 1];
float line_times_for_prefetch[number_of_planes_minus_one + 1];
float lines_for_meta_pte_with_immediate_flip[number_of_planes_minus_one + 1];
float lines_for_meta_pte_without_immediate_flip[number_of_planes_minus_one + 1];
float lines_for_meta_and_dpte_row_with_immediate_flip[number_of_planes_minus_one + 1];
float lines_for_meta_and_dpte_row_without_immediate_flip[number_of_planes_minus_one + 1];
float min_dppclk_using_single_dpp[number_of_planes_minus_one + 1];
float swath_width_ysingle_dpp[number_of_planes_minus_one + 1];
float byte_per_pixel_in_dety[number_of_planes_minus_one + 1];
float byte_per_pixel_in_detc[number_of_planes_minus_one + 1];
float number_of_dpp_required_for_det_and_lb_size[number_of_planes_minus_one + 1];
float required_phyclk[number_of_planes_minus_one + 1];
float read256_block_height_y[number_of_planes_minus_one + 1];
float read256_block_width_y[number_of_planes_minus_one + 1];
float read256_block_height_c[number_of_planes_minus_one + 1];
float read256_block_width_c[number_of_planes_minus_one + 1];
float max_swath_height_y[number_of_planes_minus_one + 1];
float max_swath_height_c[number_of_planes_minus_one + 1];
float min_swath_height_y[number_of_planes_minus_one + 1];
float min_swath_height_c[number_of_planes_minus_one + 1];
float read_bandwidth[number_of_planes_minus_one + 1];
float write_bandwidth[number_of_planes_minus_one + 1];
float pscl_factor[number_of_planes_minus_one + 1];
float pscl_factor_chroma[number_of_planes_minus_one + 1];
enum dcn_bw_defs scale_ratio_support;
enum dcn_bw_defs source_format_pixel_and_scan_support;
float total_read_bandwidth_consumed_gbyte_per_second;
float total_write_bandwidth_consumed_gbyte_per_second;
float total_bandwidth_consumed_gbyte_per_second;
enum dcn_bw_defs dcc_enabled_in_any_plane;
float return_bw_todcn_per_state;
float critical_point;
enum dcn_bw_defs writeback_latency_support;
float required_output_bw;
float total_number_of_active_writeback;
enum dcn_bw_defs total_available_writeback_support;
float maximum_swath_width;
float number_of_dpp_required_for_det_size;
float number_of_dpp_required_for_lb_size;
float min_dispclk_using_single_dpp;
float min_dispclk_using_dual_dpp;
enum dcn_bw_defs viewport_size_support;
float swath_width_granularity_y;
float rounded_up_max_swath_size_bytes_y;
float swath_width_granularity_c;
float rounded_up_max_swath_size_bytes_c;
float lines_in_det_luma;
float lines_in_det_chroma;
float effective_lb_latency_hiding_source_lines_luma;
float effective_lb_latency_hiding_source_lines_chroma;
float effective_detlb_lines_luma;
float effective_detlb_lines_chroma;
float projected_dcfclk_deep_sleep;
float meta_req_height_y;
float meta_req_width_y;
float meta_surface_width_y;
float meta_surface_height_y;
float meta_pte_bytes_per_frame_y;
float meta_row_bytes_y;
float macro_tile_block_size_bytes_y;
float macro_tile_block_height_y;
float data_pte_req_height_y;
float data_pte_req_width_y;
float dpte_bytes_per_row_y;
float meta_req_height_c;
float meta_req_width_c;
float meta_surface_width_c;
float meta_surface_height_c;
float meta_pte_bytes_per_frame_c;
float meta_row_bytes_c;
float macro_tile_block_size_bytes_c;
float macro_tile_block_height_c;
float macro_tile_block_width_c;
float data_pte_req_height_c;
float data_pte_req_width_c;
float dpte_bytes_per_row_c;
float v_init_y;
float max_partial_sw_y;
float v_init_c;
float max_partial_sw_c;
float dst_x_after_scaler;
float dst_y_after_scaler;
float time_calc;
float v_update_offset[number_of_planes_minus_one + 1][2];
float total_repeater_delay;
float v_update_width[number_of_planes_minus_one + 1][2];
float v_ready_offset[number_of_planes_minus_one + 1][2];
float time_setup;
float extra_latency;
float maximum_vstartup;
float bw_available_for_immediate_flip;
float total_immediate_flip_bytes[number_of_planes_minus_one + 1];
float time_for_meta_pte_with_immediate_flip;
float time_for_meta_pte_without_immediate_flip;
float time_for_meta_and_dpte_row_with_immediate_flip;
float time_for_meta_and_dpte_row_without_immediate_flip;
float line_times_to_request_prefetch_pixel_data_with_immediate_flip;
float line_times_to_request_prefetch_pixel_data_without_immediate_flip;
float maximum_read_bandwidth_with_prefetch_with_immediate_flip;
float maximum_read_bandwidth_with_prefetch_without_immediate_flip;
float voltage_level_with_immediate_flip;
float voltage_level_without_immediate_flip;
float total_number_of_active_dpp_per_ratio[1 + 1];
float byte_per_pix_dety;
float byte_per_pix_detc;
float read256_bytes_block_height_y;
float read256_bytes_block_width_y;
float read256_bytes_block_height_c;
float read256_bytes_block_width_c;
float maximum_swath_height_y;
float maximum_swath_height_c;
float minimum_swath_height_y;
float minimum_swath_height_c;
float swath_width;
float prefetch_bandwidth[number_of_planes_minus_one + 1];
float v_init_pre_fill_y[number_of_planes_minus_one + 1];
float v_init_pre_fill_c[number_of_planes_minus_one + 1];
float max_num_swath_y[number_of_planes_minus_one + 1];
float max_num_swath_c[number_of_planes_minus_one + 1];
float prefill_y[number_of_planes_minus_one + 1];
float prefill_c[number_of_planes_minus_one + 1];
float v_startup[number_of_planes_minus_one + 1];
enum dcn_bw_defs allow_dram_clock_change_during_vblank[number_of_planes_minus_one + 1];
float allow_dram_self_refresh_during_vblank[number_of_planes_minus_one + 1];
float v_ratio_prefetch_y[number_of_planes_minus_one + 1];
float v_ratio_prefetch_c[number_of_planes_minus_one + 1];
float destination_lines_for_prefetch[number_of_planes_minus_one + 1];
float destination_lines_to_request_vm_inv_blank[number_of_planes_minus_one + 1];
float destination_lines_to_request_row_in_vblank[number_of_planes_minus_one + 1];
float min_ttuv_blank[number_of_planes_minus_one + 1];
float byte_per_pixel_dety[number_of_planes_minus_one + 1];
float byte_per_pixel_detc[number_of_planes_minus_one + 1];
float swath_width_y[number_of_planes_minus_one + 1];
float lines_in_dety[number_of_planes_minus_one + 1];
float lines_in_dety_rounded_down_to_swath[number_of_planes_minus_one + 1];
float lines_in_detc[number_of_planes_minus_one + 1];
float lines_in_detc_rounded_down_to_swath[number_of_planes_minus_one + 1];
float full_det_buffering_time_y[number_of_planes_minus_one + 1];
float full_det_buffering_time_c[number_of_planes_minus_one + 1];
float active_dram_clock_change_latency_margin[number_of_planes_minus_one + 1];
float v_blank_dram_clock_change_latency_margin[number_of_planes_minus_one + 1];
float dcfclk_deep_sleep_per_plane[number_of_planes_minus_one + 1];
float read_bandwidth_plane_luma[number_of_planes_minus_one + 1];
float read_bandwidth_plane_chroma[number_of_planes_minus_one + 1];
float display_pipe_line_delivery_time_luma[number_of_planes_minus_one + 1];
float display_pipe_line_delivery_time_chroma[number_of_planes_minus_one + 1];
float display_pipe_line_delivery_time_luma_prefetch[number_of_planes_minus_one + 1];
float display_pipe_line_delivery_time_chroma_prefetch[number_of_planes_minus_one + 1];
float pixel_pte_bytes_per_row[number_of_planes_minus_one + 1];
float meta_pte_bytes_frame[number_of_planes_minus_one + 1];
float meta_row_byte[number_of_planes_minus_one + 1];
float prefetch_source_lines_y[number_of_planes_minus_one + 1];
float prefetch_source_lines_c[number_of_planes_minus_one + 1];
float pscl_throughput[number_of_planes_minus_one + 1];
float pscl_throughput_chroma[number_of_planes_minus_one + 1];
float output_bpphdmi[number_of_planes_minus_one + 1];
float output_bppdp4_lane_hbr[number_of_planes_minus_one + 1];
float output_bppdp4_lane_hbr2[number_of_planes_minus_one + 1];
float output_bppdp4_lane_hbr3[number_of_planes_minus_one + 1];
float max_vstartup_lines[number_of_planes_minus_one + 1];
float dispclk_with_ramping;
float dispclk_without_ramping;
float dppclk_using_single_dpp_luma;
float dppclk_using_single_dpp;
float dppclk_using_single_dpp_chroma;
enum dcn_bw_defs odm_capable;
float dispclk;
float dppclk;
float return_bandwidth_to_dcn;
enum dcn_bw_defs dcc_enabled_any_plane;
float return_bw;
float critical_compression;
float total_data_read_bandwidth;
float total_active_dpp;
float total_dcc_active_dpp;
float urgent_round_trip_and_out_of_order_latency;
float last_pixel_of_line_extra_watermark;
float data_fabric_line_delivery_time_luma;
float data_fabric_line_delivery_time_chroma;
float urgent_extra_latency;
float urgent_watermark;
float ptemeta_urgent_watermark;
float dram_clock_change_watermark;
float total_active_writeback;
float writeback_dram_clock_change_watermark;
float min_full_det_buffering_time;
float frame_time_for_min_full_det_buffering_time;
float average_read_bandwidth_gbyte_per_second;
float part_of_burst_that_fits_in_rob;
float stutter_burst_time;
float stutter_efficiency_not_including_vblank;
float smallest_vblank;
float v_blank_time;
float stutter_efficiency;
float dcf_clk_deep_sleep;
float stutter_exit_watermark;
float stutter_enter_plus_exit_watermark;
float effective_det_plus_lb_lines_luma;
float urgent_latency_support_us_luma;
float effective_det_plus_lb_lines_chroma;
float urgent_latency_support_us_chroma;
float min_urgent_latency_support_us;
float non_urgent_latency_tolerance;
float block_height256_bytes_y;
float block_height256_bytes_c;
float meta_request_width_y;
float meta_surf_width_y;
float meta_surf_height_y;
float meta_pte_bytes_frame_y;
float meta_row_byte_y;
float macro_tile_size_byte_y;
float macro_tile_height_y;
float pixel_pte_req_height_y;
float pixel_pte_req_width_y;
float pixel_pte_bytes_per_row_y;
float meta_request_width_c;
float meta_surf_width_c;
float meta_surf_height_c;
float meta_pte_bytes_frame_c;
float meta_row_byte_c;
float macro_tile_size_bytes_c;
float macro_tile_height_c;
float pixel_pte_req_height_c;
float pixel_pte_req_width_c;
float pixel_pte_bytes_per_row_c;
float max_partial_swath_y;
float max_partial_swath_c;
float t_calc;
float next_prefetch_mode;
float v_startup_lines;
enum dcn_bw_defs planes_with_room_to_increase_vstartup_prefetch_bw_less_than_active_bw;
enum dcn_bw_defs planes_with_room_to_increase_vstartup_vratio_prefetch_more_than4;
enum dcn_bw_defs planes_with_room_to_increase_vstartup_destination_line_times_for_prefetch_less_than2;
enum dcn_bw_defs v_ratio_prefetch_more_than4;
enum dcn_bw_defs destination_line_times_for_prefetch_less_than2;
float prefetch_mode;
float dstx_after_scaler;
float dsty_after_scaler;
float v_update_offset_pix[number_of_planes_minus_one + 1];
float total_repeater_delay_time;
float v_update_width_pix[number_of_planes_minus_one + 1];
float v_ready_offset_pix[number_of_planes_minus_one + 1];
float t_setup;
float t_wait;
float bandwidth_available_for_immediate_flip;
float tot_immediate_flip_bytes;
float max_rd_bandwidth;
float time_for_fetching_meta_pte;
float time_for_fetching_row_in_vblank;
float lines_to_request_prefetch_pixel_data;
float required_prefetch_pix_data_bw;
enum dcn_bw_defs prefetch_mode_supported;
float active_dp_ps;
float lb_latency_hiding_source_lines_y;
float lb_latency_hiding_source_lines_c;
float effective_lb_latency_hiding_y;
float effective_lb_latency_hiding_c;
float dpp_output_buffer_lines_y;
float dpp_output_buffer_lines_c;
float dppopp_buffering_y;
float max_det_buffering_time_y;
float active_dram_clock_change_latency_margin_y;
float dppopp_buffering_c;
float max_det_buffering_time_c;
float active_dram_clock_change_latency_margin_c;
float writeback_dram_clock_change_latency_margin;
float min_active_dram_clock_change_margin;
float v_blank_of_min_active_dram_clock_change_margin;
float second_min_active_dram_clock_change_margin;
float min_vblank_dram_clock_change_margin;
float dram_clock_change_margin;
float dram_clock_change_support;
float wr_bandwidth;
float max_used_bw;
};
struct dcn_soc_bounding_box {
float sr_exit_time; /*us*/
float sr_enter_plus_exit_time; /*us*/
float urgent_latency; /*us*/
float write_back_latency; /*us*/
float percent_of_ideal_drambw_received_after_urg_latency; /*%*/
int max_request_size; /*bytes*/
float dcfclkv_max0p9; /*MHz*/
float dcfclkv_nom0p8; /*MHz*/
float dcfclkv_mid0p72; /*MHz*/
float dcfclkv_min0p65; /*MHz*/
float max_dispclk_vmax0p9; /*MHz*/
float max_dispclk_vmid0p72; /*MHz*/
float max_dispclk_vnom0p8; /*MHz*/
float max_dispclk_vmin0p65; /*MHz*/
float max_dppclk_vmax0p9; /*MHz*/
float max_dppclk_vnom0p8; /*MHz*/
float max_dppclk_vmid0p72; /*MHz*/
float max_dppclk_vmin0p65; /*MHz*/
float socclk; /*MHz*/
float fabric_and_dram_bandwidth_vmax0p9; /*GB/s*/
float fabric_and_dram_bandwidth_vnom0p8; /*GB/s*/
float fabric_and_dram_bandwidth_vmid0p72; /*GB/s*/
float fabric_and_dram_bandwidth_vmin0p65; /*GB/s*/
float phyclkv_max0p9; /*MHz*/
float phyclkv_nom0p8; /*MHz*/
float phyclkv_mid0p72; /*MHz*/
float phyclkv_min0p65; /*MHz*/
float downspreading; /*%*/
int round_trip_ping_latency_cycles; /*DCFCLK Cycles*/
int urgent_out_of_order_return_per_channel; /*bytes*/
int number_of_channels;
int vmm_page_size; /*bytes*/
float dram_clock_change_latency; /*us*/
int return_bus_width; /*bytes*/
float percent_disp_bw_limit; /*%*/
};
extern const struct dcn_soc_bounding_box dcn10_soc_defaults;
struct dcn_ip_params {
float rob_buffer_size_in_kbyte;
float det_buffer_size_in_kbyte;
float dpp_output_buffer_pixels;
float opp_output_buffer_lines;
float pixel_chunk_size_in_kbyte;
enum dcn_bw_defs pte_enable;
int pte_chunk_size; /*kbytes*/
int meta_chunk_size; /*kbytes*/
int writeback_chunk_size; /*kbytes*/
enum dcn_bw_defs odm_capability;
enum dcn_bw_defs dsc_capability;
int line_buffer_size; /*bit*/
int max_line_buffer_lines;
enum dcn_bw_defs is_line_buffer_bpp_fixed;
int line_buffer_fixed_bpp;
int writeback_luma_buffer_size; /*kbytes*/
int writeback_chroma_buffer_size; /*kbytes*/
int max_num_dpp;
int max_num_writeback;
int max_dchub_topscl_throughput; /*pixels/dppclk*/
int max_pscl_tolb_throughput; /*pixels/dppclk*/
int max_lb_tovscl_throughput; /*pixels/dppclk*/
int max_vscl_tohscl_throughput; /*pixels/dppclk*/
float max_hscl_ratio;
float max_vscl_ratio;
int max_hscl_taps;
int max_vscl_taps;
int pte_buffer_size_in_requests;
float dispclk_ramping_margin; /*%*/
float under_scan_factor;
int max_inter_dcn_tile_repeaters;
enum dcn_bw_defs can_vstartup_lines_exceed_vsync_plus_back_porch_lines_minus_one;
enum dcn_bw_defs bug_forcing_luma_and_chroma_request_to_same_size_fixed;
int dcfclk_cstate_latency;
};
extern const struct dcn_ip_params dcn10_ip_defaults;
bool dcn_validate_bandwidth(
struct dc *dc,
struct dc_state *context,
enum dc_validate_mode validate_mode);
void dcn_get_soc_clks(
struct dc *dc,
int *min_fclk_khz,
int *min_dcfclk_khz,
int *socclk_khz);
void dcn_bw_update_from_pplib_fclks(
struct dc *dc,
struct dm_pp_clock_levels_with_voltage *fclks);
void dcn_bw_update_from_pplib_dcfclks(
struct dc *dc,
struct dm_pp_clock_levels_with_voltage *dcfclks);
void dcn_bw_notify_pplib_of_wm_ranges(
struct dc *dc,
int min_fclk_khz,
int min_dcfclk_khz,
int socclk_khz);
void dcn_bw_sync_calcs_and_dml(struct dc *dc);
enum source_macro_tile_size swizzle_mode_to_macro_tile_size(enum swizzle_mode_values sw_mode);
#endif /* __DCN_CALCS_H__ */
@@ -0,0 +1,71 @@
/* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_ABM_H__
#define __DC_ABM_H__
#include "dm_services_types.h"
struct abm_save_restore;
struct abm {
struct dc_context *ctx;
const struct abm_funcs *funcs;
bool dmcu_is_running;
};
struct abm_funcs {
void (*abm_init)(struct abm *abm, uint32_t back_light, uint32_t user_level);
bool (*set_abm_level)(struct abm *abm, unsigned int abm_level);
bool (*set_abm_immediate_disable)(struct abm *abm, unsigned int panel_inst);
bool (*set_pipe)(struct abm *abm, unsigned int controller_id, unsigned int panel_inst);
/* backlight_pwm_u16_16 is unsigned 32 bit,
* 16 bit integer + 16 fractional, where 1.0 is max backlight value.
*/
bool (*set_backlight_level_pwm)(struct abm *abm,
unsigned int backlight_pwm_u16_16,
unsigned int frame_ramp,
unsigned int controller_id,
unsigned int panel_inst);
unsigned int (*get_current_backlight)(struct abm *abm);
unsigned int (*get_target_backlight)(struct abm *abm);
bool (*init_abm_config)(struct abm *abm,
const char *src,
unsigned int bytes,
unsigned int inst);
bool (*set_abm_pause)(struct abm *abm, bool pause, unsigned int panel_inst, unsigned int otg_inst);
bool (*save_restore)(
struct abm *abm,
unsigned int panel_inst,
struct abm_save_restore *pData);
bool (*set_pipe_ex)(struct abm *abm,
unsigned int otg_inst,
unsigned int option,
unsigned int panel_inst,
unsigned int pwrseq_inst);
};
#endif
@@ -0,0 +1,66 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_AUDIO_H__
#define __DAL_AUDIO_H__
#include "audio_types.h"
struct audio;
struct audio_funcs {
bool (*endpoint_valid)(struct audio *audio);
void (*hw_init)(struct audio *audio);
void (*az_enable)(struct audio *audio);
void (*az_disable)(struct audio *audio);
void (*az_configure)(struct audio *audio,
enum signal_type signal,
const struct audio_crtc_info *crtc_info,
const struct audio_info *audio_info,
const struct audio_dp_link_info *dp_link_info);
void (*az_disable_hbr_audio)(struct audio *audio);
void (*wall_dto_setup)(struct audio *audio,
enum signal_type signal,
const struct audio_crtc_info *crtc_info,
const struct audio_pll_info *pll_info);
void (*destroy)(struct audio **audio);
};
struct audio {
const struct audio_funcs *funcs;
struct dc_context *ctx;
unsigned int inst;
bool enabled;
};
#endif /* __DAL_AUDIO__ */
@@ -0,0 +1,187 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_AUX_ENGINE_H__
#define __DAL_AUX_ENGINE_H__
#include "dc_ddc_types.h"
enum aux_return_code_type;
enum i2caux_transaction_operation {
I2CAUX_TRANSACTION_READ,
I2CAUX_TRANSACTION_WRITE
};
enum i2caux_transaction_address_space {
I2CAUX_TRANSACTION_ADDRESS_SPACE_I2C = 1,
I2CAUX_TRANSACTION_ADDRESS_SPACE_DPCD
};
struct i2caux_transaction_payload {
enum i2caux_transaction_address_space address_space;
uint32_t address;
uint32_t length;
uint8_t *data;
};
enum i2caux_transaction_status {
I2CAUX_TRANSACTION_STATUS_UNKNOWN = (-1L),
I2CAUX_TRANSACTION_STATUS_SUCCEEDED,
I2CAUX_TRANSACTION_STATUS_FAILED_CHANNEL_BUSY,
I2CAUX_TRANSACTION_STATUS_FAILED_TIMEOUT,
I2CAUX_TRANSACTION_STATUS_FAILED_PROTOCOL_ERROR,
I2CAUX_TRANSACTION_STATUS_FAILED_NACK,
I2CAUX_TRANSACTION_STATUS_FAILED_INCOMPLETE,
I2CAUX_TRANSACTION_STATUS_FAILED_OPERATION,
I2CAUX_TRANSACTION_STATUS_FAILED_INVALID_OPERATION,
I2CAUX_TRANSACTION_STATUS_FAILED_BUFFER_OVERFLOW,
I2CAUX_TRANSACTION_STATUS_FAILED_HPD_DISCON
};
struct i2caux_transaction_request {
enum i2caux_transaction_operation operation;
struct i2caux_transaction_payload payload;
enum i2caux_transaction_status status;
};
enum i2caux_engine_type {
I2CAUX_ENGINE_TYPE_UNKNOWN = (-1L),
I2CAUX_ENGINE_TYPE_AUX,
I2CAUX_ENGINE_TYPE_I2C_DDC_HW,
I2CAUX_ENGINE_TYPE_I2C_GENERIC_HW,
I2CAUX_ENGINE_TYPE_I2C_SW
};
enum i2c_default_speed {
I2CAUX_DEFAULT_I2C_HW_SPEED = 50,
I2CAUX_DEFAULT_I2C_SW_SPEED = 50
};
union aux_config {
struct {
uint32_t ALLOW_AUX_WHEN_HPD_LOW:1;
} bits;
uint32_t raw;
};
struct aux_engine {
uint32_t inst;
struct ddc *ddc;
struct dc_context *ctx;
const struct aux_engine_funcs *funcs;
/* following values are expressed in milliseconds */
uint32_t delay;
uint32_t max_defer_write_retry;
bool acquire_reset;
};
struct read_command_context {
uint8_t *buffer;
uint32_t current_read_length;
uint32_t offset;
enum i2caux_transaction_status status;
struct aux_request_transaction_data request;
struct aux_reply_transaction_data reply;
uint8_t returned_byte;
uint32_t timed_out_retry_aux;
uint32_t invalid_reply_retry_aux;
uint32_t defer_retry_aux;
uint32_t defer_retry_i2c;
uint32_t invalid_reply_retry_aux_on_ack;
bool transaction_complete;
bool operation_succeeded;
};
struct write_command_context {
bool mot;
uint8_t *buffer;
uint32_t current_write_length;
enum i2caux_transaction_status status;
struct aux_request_transaction_data request;
struct aux_reply_transaction_data reply;
uint8_t returned_byte;
uint32_t timed_out_retry_aux;
uint32_t invalid_reply_retry_aux;
uint32_t defer_retry_aux;
uint32_t defer_retry_i2c;
uint32_t max_defer_retry;
uint32_t ack_m_retry;
uint8_t reply_data[DEFAULT_AUX_MAX_DATA_SIZE];
bool transaction_complete;
bool operation_succeeded;
};
struct aux_engine_funcs {
bool (*configure_timeout)(
struct ddc_service *ddc,
uint32_t timeout);
void (*destroy)(
struct aux_engine **ptr);
bool (*acquire_engine)(
struct aux_engine *engine);
void (*configure)(
struct aux_engine *engine,
union aux_config cfg);
void (*submit_channel_request)(
struct aux_engine *engine,
struct aux_request_transaction_data *request);
void (*process_channel_reply)(
struct aux_engine *engine,
struct aux_reply_transaction_data *reply);
int (*read_channel_reply)(
struct aux_engine *engine,
uint32_t size,
uint8_t *buffer,
uint8_t *reply_result,
uint32_t *sw_status);
enum aux_return_code_type (*get_channel_status)(
struct aux_engine *engine,
uint8_t *returned_bytes);
bool (*is_engine_available)(struct aux_engine *engine);
bool (*acquire)(
struct aux_engine *engine,
struct ddc *ddc);
bool (*submit_request)(
struct aux_engine *engine,
struct i2caux_transaction_request *request,
bool middle_of_transaction);
void (*release_engine)(
struct aux_engine *engine);
void (*destroy_engine)(
struct aux_engine **engine);
};
#endif
@@ -0,0 +1,436 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright 2012-2026 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_CLK_MGR_H__
#define __DAL_CLK_MGR_H__
#include "dc.h"
#include "core_types.h"
#include "dm_pp_smu.h"
/* Constants */
#define DDR4_DRAM_WIDTH 64
#define WM_A 0
#define WM_B 1
#define WM_C 2
#define WM_D 3
#define WM_SET_COUNT 4
#define WM_1A 2
#define WM_1B 3
#define DCN_MINIMUM_DISPCLK_Khz 100000
#define DCN_MINIMUM_DPPCLK_Khz 100000
struct dcn3_clk_internal {
int dummy;
// TODO:
uint32_t CLK1_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK1_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK1_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK1_CLK3_CURRENT_CNT; //dcfclk
uint32_t CLK1_CLK4_CURRENT_CNT;
uint32_t CLK1_CLK3_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK1_CLK3_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK1_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK1_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK1_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK1_CLK3_BYPASS_CNTL; //dcfclk bypass
uint32_t CLK4_CLK0_CURRENT_CNT; //fclk
};
struct dcn35_clk_internal {
int dummy;
uint32_t CLK1_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK1_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK1_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK1_CLK3_CURRENT_CNT; //dcfclk
uint32_t CLK1_CLK4_CURRENT_CNT; //dtbclk
//uint32_t CLK1_CLK5_CURRENT_CNT; //dpiaclk
//uint32_t CLK1_CLK6_CURRENT_CNT; //srdbgclk
uint32_t CLK1_CLK3_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK1_CLK3_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK1_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK1_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK1_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK1_CLK3_BYPASS_CNTL; //dcfclk bypass
uint32_t CLK1_CLK4_BYPASS_CNTL; //dtbclk bypass
};
struct dcn301_clk_internal {
int dummy;
uint32_t CLK1_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK1_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK1_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK1_CLK3_CURRENT_CNT; //dcfclk
uint32_t CLK1_CLK3_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK1_CLK3_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK1_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK1_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK1_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK1_CLK3_BYPASS_CNTL; //dcfclk bypass
};
struct dcn42_clk_internal {
int dummy;
uint32_t CLK8_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK8_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK8_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK8_CLK3_CURRENT_CNT; //dcfclk
uint32_t CLK8_CLK4_CURRENT_CNT; //dtbclk
uint32_t CLK8_CLK0_DS_CNTL; //dispclk deep_sleep_divider
uint32_t CLK8_CLK1_DS_CNTL; //dppclk deep_sleep_divider
uint32_t CLK8_CLK2_DS_CNTL; //dprefclk deep_sleep_divider
uint32_t CLK8_CLK3_DS_CNTL; //dcfclk deep_sleep_divider
uint32_t CLK8_CLK4_DS_CNTL; //dtbclk deep_sleep_divider
uint32_t CLK8_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK8_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK8_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK8_CLK3_BYPASS_CNTL; //dcfclk bypass
uint32_t CLK8_CLK4_BYPASS_CNTL; //dtbclk bypass
uint32_t CLK8_CLK_TICK_CNT__TIMER_THRESHOLD;
};
struct dcn42b_clk_internal {
int dummy;
uint32_t CLK5_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK5_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK5_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK5_CLK3_CURRENT_CNT; //dcfclk
//uint32_t CLK5_CLK4_CURRENT_CNT; //dtbclk
uint32_t CLK5_CLK0_DS_CNTL; //dispclk deep_sleep_divider
uint32_t CLK5_CLK1_DS_CNTL; //dppclk deep_sleep_divider
uint32_t CLK5_CLK2_DS_CNTL; //dprefclk deep_sleep_divider
uint32_t CLK5_CLK3_DS_CNTL; //dcfclk deep_sleep_divider
uint32_t CLK5_CLK3_ALLOW_DS; //dcf_deep_sleep_allow
//uint32_t CLK8_CLK4_DS_CNTL; //dtbclk deep_sleep_divider
uint32_t CLK5_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK5_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK5_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK5_CLK3_BYPASS_CNTL; //dcfclk bypass
//uint32_t CLK5_CLK4_BYPASS_CNTL; //dtbclk bypass
uint32_t CLK5_CLK_TICK_CNT__TIMER_THRESHOLD;
};
/* Will these bw structures be ASIC specific? */
#define MAX_NUM_DPM_LVL 8
#define WM_SET_COUNT 4
enum clk_type {
CLK_TYPE_DCFCLK,
CLK_TYPE_FCLK,
CLK_TYPE_MCLK,
CLK_TYPE_SOCCLK,
CLK_TYPE_DTBCLK,
CLK_TYPE_DISPCLK,
CLK_TYPE_DPPCLK,
CLK_TYPE_DSCCLK,
CLK_TYPE_COUNT
};
struct clk_limit_table_entry {
unsigned int voltage; /* milivolts withh 2 fractional bits */
unsigned int dcfclk_mhz;
unsigned int fclk_mhz;
unsigned int memclk_mhz;
unsigned int socclk_mhz;
unsigned int dtbclk_mhz;
unsigned int dispclk_mhz;
unsigned int dppclk_mhz;
unsigned int phyclk_mhz;
unsigned int phyclk_d18_mhz;
unsigned int wck_ratio;
};
struct clk_limit_num_entries {
unsigned int num_dcfclk_levels;
unsigned int num_fclk_levels;
unsigned int num_memclk_levels;
unsigned int num_socclk_levels;
unsigned int num_dtbclk_levels;
unsigned int num_dispclk_levels;
unsigned int num_dppclk_levels;
unsigned int num_phyclk_levels;
unsigned int num_phyclk_d18_levels;
};
/* This table is contiguous */
struct clk_limit_table {
struct clk_limit_table_entry entries[MAX_NUM_DPM_LVL];
struct clk_limit_num_entries num_entries_per_clk;
unsigned int num_entries; /* highest populated dpm level for back compatibility */
};
struct wm_range_table_entry {
unsigned int wm_inst;
unsigned int wm_type;
double pstate_latency_us;
double sr_exit_time_us;
double sr_enter_plus_exit_time_us;
bool valid;
};
struct nv_wm_range_entry {
bool valid;
struct {
uint8_t wm_type;
uint16_t min_dcfclk;
uint16_t max_dcfclk;
uint16_t min_uclk;
uint16_t max_uclk;
} pmfw_breakdown;
struct {
double pstate_latency_us;
double sr_exit_time_us;
double sr_enter_plus_exit_time_us;
double fclk_change_latency_us;
} dml_input;
};
struct clk_log_info {
bool enabled;
char *pBuf;
unsigned int bufSize;
unsigned int *sum_chars_printed;
};
struct clk_state_registers_and_bypass {
uint32_t dcfclk;
uint32_t dcf_deep_sleep_divider;
uint32_t dcf_deep_sleep_allow;
uint32_t dprefclk;
uint32_t dispclk;
uint32_t dppclk;
uint32_t dtbclk;
uint32_t fclk;
uint32_t dppclk_bypass;
uint32_t dcfclk_bypass;
uint32_t dprefclk_bypass;
uint32_t dispclk_bypass;
uint32_t timer_threshold;
};
struct rv1_clk_internal {
uint32_t CLK0_CLK8_CURRENT_CNT; //dcfclk
uint32_t CLK0_CLK8_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK0_CLK8_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK0_CLK10_CURRENT_CNT; //dprefclk
uint32_t CLK0_CLK11_CURRENT_CNT; //dispclk
uint32_t CLK0_CLK8_BYPASS_CNTL; //dcfclk bypass
uint32_t CLK0_CLK10_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK0_CLK11_BYPASS_CNTL; //dispclk bypass
};
struct rn_clk_internal {
uint32_t CLK1_CLK0_CURRENT_CNT; //dispclk
uint32_t CLK1_CLK1_CURRENT_CNT; //dppclk
uint32_t CLK1_CLK2_CURRENT_CNT; //dprefclk
uint32_t CLK1_CLK3_CURRENT_CNT; //dcfclk
uint32_t CLK1_CLK3_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK1_CLK3_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK1_CLK0_BYPASS_CNTL; //dispclk bypass
uint32_t CLK1_CLK1_BYPASS_CNTL; //dppclk bypass
uint32_t CLK1_CLK2_BYPASS_CNTL; //dprefclk bypass
uint32_t CLK1_CLK3_BYPASS_CNTL; //dcfclk bypass
};
/* For dtn logging and debugging */
struct clk_state_registers {
uint32_t CLK0_CLK8_CURRENT_CNT; //dcfclk
uint32_t CLK0_CLK8_DS_CNTL; //dcf_deep_sleep_divider
uint32_t CLK0_CLK8_ALLOW_DS; //dcf_deep_sleep_allow
uint32_t CLK0_CLK10_CURRENT_CNT; //dprefclk
uint32_t CLK0_CLK11_CURRENT_CNT; //dispclk
};
/* TODO: combine this with the above */
struct clk_bypass {
uint32_t dcfclk_bypass;
uint32_t dispclk_pypass;
uint32_t dprefclk_bypass;
};
/*
* This table is not contiguous, can have holes, each
* entry correspond to one set of WM. For example if
* we have 2 DPM and LPDDR, we will WM set A, B and
* D occupied, C will be emptry.
*/
struct wm_table {
union {
struct nv_wm_range_entry nv_entries[WM_SET_COUNT];
struct wm_range_table_entry entries[WM_SET_COUNT];
};
};
struct dummy_pstate_entry {
unsigned int dram_speed_mts;
unsigned int dummy_pstate_latency_us;
};
struct clk_bw_params {
unsigned int vram_type;
unsigned int num_channels;
unsigned int dram_channel_width_bytes;
unsigned int dispclk_vco_khz;
unsigned int dc_mode_softmax_memclk;
unsigned int max_memclk_mhz;
struct clk_limit_table clk_table;
struct wm_table wm_table;
struct dummy_pstate_entry dummy_pstate_table[4];
struct clk_limit_table_entry dc_mode_limit;
};
/* Public interfaces */
struct clk_states {
uint32_t dprefclk_khz;
};
struct clk_mgr_funcs {
/*
* This function should set new clocks based on the input "safe_to_lower".
* If safe_to_lower == false, then only clocks which are to be increased
* should changed.
* If safe_to_lower == true, then only clocks which are to be decreased
* should be changed.
*/
void (*update_clocks)(struct clk_mgr *clk_mgr,
struct dc_state *context,
bool safe_to_lower);
int (*get_dp_ref_clk_frequency)(struct clk_mgr *clk_mgr);
int (*get_dtb_ref_clk_frequency)(struct clk_mgr *clk_mgr);
void (*set_low_power_state)(struct clk_mgr *clk_mgr);
void (*exit_low_power_state)(struct clk_mgr *clk_mgr);
bool (*is_ips_supported)(struct clk_mgr *clk_mgr);
void (*init_clocks)(struct clk_mgr *clk_mgr);
void (*dump_clk_registers)(struct clk_state_registers_and_bypass *regs_and_bypass,
struct clk_mgr *clk_mgr_base, struct clk_log_info *log_info);
void (*enable_pme_wa) (struct clk_mgr *clk_mgr);
void (*get_clock)(struct clk_mgr *clk_mgr,
struct dc_state *context,
enum dc_clock_type clock_type,
struct dc_clock_config *clock_cfg);
bool (*are_clock_states_equal) (struct dc_clocks *a,
struct dc_clocks *b);
void (*notify_wm_ranges)(struct clk_mgr *clk_mgr);
/* Notify clk_mgr of a change in link rate, update phyclk frequency if necessary */
void (*notify_link_rate_change)(struct clk_mgr *clk_mgr, struct dc_link *link);
/*
* Send message to PMFW to set hard min memclk frequency
* When current_mode = false, set DPM0
* When current_mode = true, set required clock for current mode
*/
void (*set_hard_min_memclk)(struct clk_mgr *clk_mgr, bool current_mode);
int (*get_hard_min_memclk)(struct clk_mgr *clk_mgr);
int (*get_hard_min_fclk)(struct clk_mgr *clk_mgr);
/* Send message to PMFW to set hard max memclk frequency to highest DPM */
void (*set_hard_max_memclk)(struct clk_mgr *clk_mgr);
/* Custom set a memclk freq range*/
void (*set_max_memclk)(struct clk_mgr *clk_mgr, unsigned int memclk_mhz);
void (*set_min_memclk)(struct clk_mgr *clk_mgr, unsigned int memclk_mhz);
/* Get current memclk states from PMFW, update relevant structures */
void (*get_memclk_states_from_smu)(struct clk_mgr *clk_mgr);
/* Get SMU present */
bool (*is_smu_present)(struct clk_mgr *clk_mgr);
int (*get_dispclk_from_dentist)(struct clk_mgr *clk_mgr_base);
bool (*is_dc_mode_present)(struct clk_mgr *clk_mgr);
uint32_t (*set_smartmux_switch)(struct clk_mgr *clk_mgr, uint32_t pins_to_set);
unsigned int (*get_max_clock_khz)(struct clk_mgr *clk_mgr_base, enum clk_type clk_type);
/**
* override_memory_bandwidth_request - Override the DCN nominal memory
* bandwidth request sent to PMFW, independent of the current display
* mode. For debug use only.
* @clk_mgr: clock manager instance
* @bw_kbps: requested bandwidth in kbps; 0 clears the override
*
* Return: capped bandwidth value actually applied (kbps)
*/
unsigned int (*override_memory_bandwidth_request)(
struct clk_mgr *clk_mgr,
unsigned int bw_kbps);
/**
* get_requested_memory_qos - Retrieve current QoS request from the clock manager's
* current clock state, reflecting any active bandwidth overrides.
* @clk_mgr: clock manager instance
* @qos: pointer to dc_requested_memory_qos structure to populate
*/
void (*get_requested_memory_qos)(
struct clk_mgr *clk_mgr,
struct dc_requested_memory_qos *qos);
};
struct clk_mgr {
struct dc_context *ctx;
struct clk_mgr_funcs *funcs;
struct dc_clocks clks;
bool psr_allow_active_cache;
bool force_smu_not_present;
bool dc_mode_softmax_enabled;
int dprefclk_khz; // Used by program pixel clock in clock source funcs, need to figureout where this goes
int dp_dto_source_clock_in_khz; // Used to program DP DTO with ss adjustment on DCN314
int dentist_vco_freq_khz;
struct clk_state_registers_and_bypass boot_snapshot;
struct clk_bw_params *bw_params;
struct pp_smu_wm_range_sets ranges;
};
/* forward declarations */
struct dccg;
struct clk_mgr *dc_clk_mgr_create(struct dc_context *ctx, struct pp_smu_funcs *pp_smu, struct dccg *dccg);
void dc_destroy_clk_mgr(struct clk_mgr *clk_mgr);
void clk_mgr_exit_optimized_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr);
void clk_mgr_optimize_pwr_state(const struct dc *dc, struct clk_mgr *clk_mgr);
#endif /* __DAL_CLK_MGR_H__ */
@@ -0,0 +1,576 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright 2018-2026 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_CLK_MGR_INTERNAL_H__
#define __DAL_CLK_MGR_INTERNAL_H__
#include "clk_mgr.h"
#include "dc.h"
/*
* only thing needed from here is MEMORY_TYPE_MULTIPLIER_CZ, which is also
* used in resource, perhaps this should be defined somewhere more common.
*/
#include "resource.h"
/* Starting DID for each range */
enum dentist_base_divider_id {
DENTIST_BASE_DID_1 = 0x08,
DENTIST_BASE_DID_2 = 0x40,
DENTIST_BASE_DID_3 = 0x60,
DENTIST_BASE_DID_4 = 0x7e,
DENTIST_MAX_DID = 0x7f
};
/* Starting point and step size for each divider range.*/
enum dentist_divider_range {
DENTIST_DIVIDER_RANGE_1_START = 8, /* 2.00 */
DENTIST_DIVIDER_RANGE_1_STEP = 1, /* 0.25 */
DENTIST_DIVIDER_RANGE_2_START = 64, /* 16.00 */
DENTIST_DIVIDER_RANGE_2_STEP = 2, /* 0.50 */
DENTIST_DIVIDER_RANGE_3_START = 128, /* 32.00 */
DENTIST_DIVIDER_RANGE_3_STEP = 4, /* 1.00 */
DENTIST_DIVIDER_RANGE_4_START = 248, /* 62.00 */
DENTIST_DIVIDER_RANGE_4_STEP = 264, /* 66.00 */
DENTIST_DIVIDER_RANGE_SCALE_FACTOR = 4
};
/*
***************************************************************************************
****************** Clock Manager Private Macros and Defines ***************************
***************************************************************************************
*/
/* Macros */
#define TO_CLK_MGR_INTERNAL(clk_mgr)\
container_of(clk_mgr, struct clk_mgr_internal, base)
#define CTX \
clk_mgr->base.ctx
#define DC_LOGGER \
dc->ctx->logger
#define CLK_BASE(inst) \
CLK_BASE_INNER(inst)
#define CLK_SRI(reg_name, block, inst)\
.reg_name = CLK_BASE(mm ## block ## _ ## inst ## _ ## reg_name ## _BASE_IDX) + \
mm ## block ## _ ## inst ## _ ## reg_name
#define CLK_COMMON_REG_LIST_DCE_BASE() \
.DPREFCLK_CNTL = mmDPREFCLK_CNTL, \
.DENTIST_DISPCLK_CNTL = mmDENTIST_DISPCLK_CNTL
#define CLK_COMMON_REG_LIST_DCN_BASE() \
SR(DENTIST_DISPCLK_CNTL)
#define CLK_COMMON_REG_LIST_DCN_201() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SRI(CLK4_CLK_PLL_REQ, CLK4, 0), \
CLK_SRI(CLK4_CLK2_CURRENT_CNT, CLK4, 0)
#define CLK_REG_LIST_NV10() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SRI(CLK3_CLK_PLL_REQ, CLK3, 0), \
CLK_SRI(CLK3_CLK2_DFS_CNTL, CLK3, 0)
#define CLK_REG_LIST_DCN3() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SRI(CLK0_CLK_PLL_REQ, CLK02, 0), \
CLK_SRI(CLK0_CLK2_DFS_CNTL, CLK02, 0)
#define CLK_SF(reg_name, field_name, post_fix)\
.field_name = reg_name ## __ ## field_name ## post_fix
#define CLK_COMMON_MASK_SH_LIST_DCE_COMMON_BASE(mask_sh) \
CLK_SF(DPREFCLK_CNTL, DPREFCLK_SRC_SEL, mask_sh), \
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPREFCLK_WDIVIDER, mask_sh)
#define CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh) \
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_WDIVIDER, mask_sh),\
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, mask_sh)
#define CLK_MASK_SH_LIST_RV1(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh),\
CLK_SF(MP1_SMN_C2PMSG_67, CONTENT, mask_sh),\
CLK_SF(MP1_SMN_C2PMSG_83, CONTENT, mask_sh),\
CLK_SF(MP1_SMN_C2PMSG_91, CONTENT, mask_sh),
#define CLK_COMMON_MASK_SH_LIST_DCN20_BASE(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh),\
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, mask_sh),\
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_CHG_DONE, mask_sh)
#define CLK_MASK_SH_LIST_NV10(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN20_BASE(mask_sh),\
CLK_SF(CLK3_0_CLK3_CLK_PLL_REQ, FbMult_int, mask_sh),\
CLK_SF(CLK3_0_CLK3_CLK_PLL_REQ, FbMult_frac, mask_sh)
#define CLK_COMMON_MASK_SH_LIST_DCN201_BASE(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN_COMMON_BASE(mask_sh),\
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_WDIVIDER, mask_sh),\
CLK_SF(DENTIST_DISPCLK_CNTL, DENTIST_DPPCLK_CHG_DONE, mask_sh),\
CLK_SF(CLK4_0_CLK4_CLK_PLL_REQ, FbMult_int, mask_sh)
#define CLK_REG_LIST_DCN32() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SR_DCN32(CLK1_CLK_PLL_REQ), \
CLK_SR_DCN32(CLK1_CLK0_DFS_CNTL), \
CLK_SR_DCN32(CLK1_CLK1_DFS_CNTL), \
CLK_SR_DCN32(CLK1_CLK2_DFS_CNTL), \
CLK_SR_DCN32(CLK1_CLK3_DFS_CNTL), \
CLK_SR_DCN32(CLK1_CLK4_DFS_CNTL), \
CLK_SR_DCN32(CLK1_CLK0_CURRENT_CNT), \
CLK_SR_DCN32(CLK1_CLK1_CURRENT_CNT), \
CLK_SR_DCN32(CLK1_CLK2_CURRENT_CNT), \
CLK_SR_DCN32(CLK1_CLK3_CURRENT_CNT), \
CLK_SR_DCN32(CLK1_CLK4_CURRENT_CNT), \
CLK_SR_DCN32(CLK4_CLK0_CURRENT_CNT)
#define CLK_REG_LIST_DCN35() \
CLK_SR_DCN35(CLK1_CLK_PLL_REQ), \
CLK_SR_DCN35(CLK1_CLK0_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK1_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK2_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK3_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK4_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK5_DFS_CNTL), \
CLK_SR_DCN35(CLK1_CLK0_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK1_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK2_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK3_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK4_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK5_CURRENT_CNT), \
CLK_SR_DCN35(CLK1_CLK0_BYPASS_CNTL), \
CLK_SR_DCN35(CLK1_CLK1_BYPASS_CNTL), \
CLK_SR_DCN35(CLK1_CLK2_BYPASS_CNTL), \
CLK_SR_DCN35(CLK1_CLK3_BYPASS_CNTL), \
CLK_SR_DCN35(CLK1_CLK4_BYPASS_CNTL),\
CLK_SR_DCN35(CLK1_CLK5_BYPASS_CNTL), \
CLK_SR_DCN35(CLK1_CLK0_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK1_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK2_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK3_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK4_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK5_DS_CNTL), \
CLK_SR_DCN35(CLK1_CLK0_ALLOW_DS), \
CLK_SR_DCN35(CLK1_CLK1_ALLOW_DS), \
CLK_SR_DCN35(CLK1_CLK2_ALLOW_DS), \
CLK_SR_DCN35(CLK1_CLK3_ALLOW_DS), \
CLK_SR_DCN35(CLK1_CLK4_ALLOW_DS), \
CLK_SR_DCN35(CLK1_CLK5_ALLOW_DS), \
CLK_SR_DCN35(CLK5_spll_field_8), \
CLK_SR_DCN35(CLK6_spll_field_8), \
SR(DENTIST_DISPCLK_CNTL), \
#define CLK_COMMON_MASK_SH_LIST_DCN32(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN20_BASE(mask_sh),\
CLK_SF(CLK1_CLK_PLL_REQ, FbMult_int, mask_sh),\
CLK_SF(CLK1_CLK_PLL_REQ, FbMult_frac, mask_sh)
#define CLK_REG_LIST_DCN321() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SR_DCN321(CLK0_CLK_PLL_REQ, CLK01, 0), \
CLK_SR_DCN321(CLK0_CLK0_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN321(CLK0_CLK1_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN321(CLK0_CLK2_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN321(CLK0_CLK3_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN321(CLK0_CLK4_DFS_CNTL, CLK01, 0)
#define CLK_COMMON_MASK_SH_LIST_DCN321(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN20_BASE(mask_sh),\
CLK_SF(CLK0_CLK_PLL_REQ, FbMult_int, mask_sh),\
CLK_SF(CLK0_CLK_PLL_REQ, FbMult_frac, mask_sh)
#define CLK_REG_LIST_DCN401() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SR_DCN401(CLK0_CLK_PLL_REQ, CLK01, 0), \
CLK_SR_DCN401(CLK0_CLK0_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN401(CLK0_CLK1_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN401(CLK0_CLK2_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN401(CLK0_CLK3_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN401(CLK0_CLK4_DFS_CNTL, CLK01, 0), \
CLK_SR_DCN401(CLK2_CLK2_DFS_CNTL, CLK20, 0)
#define CLK_COMMON_MASK_SH_LIST_DCN401(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN321(mask_sh)
#define CLK_REG_LIST_DCN42() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SR_DCN42(CLK8_CLK_TICK_CNT_CONFIG_REG), \
CLK_SR_DCN42(CLK8_CLK0_CURRENT_CNT), \
CLK_SR_DCN42(CLK8_CLK1_CURRENT_CNT), \
CLK_SR_DCN42(CLK8_CLK2_CURRENT_CNT), \
CLK_SR_DCN42(CLK8_CLK3_CURRENT_CNT), \
CLK_SR_DCN42(CLK8_CLK4_CURRENT_CNT), \
CLK_SR_DCN42(CLK8_CLK0_BYPASS_CNTL), \
CLK_SR_DCN42(CLK8_CLK1_BYPASS_CNTL), \
CLK_SR_DCN42(CLK8_CLK2_BYPASS_CNTL), \
CLK_SR_DCN42(CLK8_CLK3_BYPASS_CNTL), \
CLK_SR_DCN42(CLK8_CLK4_BYPASS_CNTL), \
CLK_SR_DCN42(CLK8_CLK0_DS_CNTL), \
CLK_SR_DCN42(CLK8_CLK1_DS_CNTL), \
CLK_SR_DCN42(CLK8_CLK2_DS_CNTL), \
CLK_SR_DCN42(CLK8_CLK3_DS_CNTL), \
CLK_SR_DCN42(CLK8_CLK4_DS_CNTL)
#define CLK_COMMON_MASK_SH_LIST_DCN42(mask_sh) \
CLK_SF(CLK8_CLK_TICK_CNT_CONFIG_REG, TIMER_THRESHOLD, mask_sh), \
CLK_SF(CLK8_CLK0_BYPASS_CNTL, CLK0_BYPASS_SEL, mask_sh), \
CLK_SF(CLK8_CLK1_BYPASS_CNTL, CLK1_BYPASS_SEL, mask_sh), \
CLK_SF(CLK8_CLK2_BYPASS_CNTL, CLK2_BYPASS_SEL, mask_sh), \
CLK_SF(CLK8_CLK3_BYPASS_CNTL, CLK3_BYPASS_SEL, mask_sh), \
CLK_SF(CLK8_CLK4_BYPASS_CNTL, CLK4_BYPASS_SEL, mask_sh), \
CLK_SF(CLK8_CLK0_DS_CNTL, CLK0_DS_DIV_ID, mask_sh), \
CLK_SF(CLK8_CLK1_DS_CNTL, CLK1_DS_DIV_ID, mask_sh), \
CLK_SF(CLK8_CLK2_DS_CNTL, CLK2_DS_DIV_ID, mask_sh), \
CLK_SF(CLK8_CLK3_DS_CNTL, CLK3_DS_DIV_ID, mask_sh), \
CLK_SF(CLK8_CLK4_DS_CNTL, CLK4_DS_DIV_ID, mask_sh), \
CLK_SF(CLK8_CLK0_DS_CNTL, CLK0_ALLOW_DS, mask_sh), \
CLK_SF(CLK8_CLK1_DS_CNTL, CLK1_ALLOW_DS, mask_sh), \
CLK_SF(CLK8_CLK2_DS_CNTL, CLK2_ALLOW_DS, mask_sh), \
CLK_SF(CLK8_CLK3_DS_CNTL, CLK3_ALLOW_DS, mask_sh), \
CLK_SF(CLK8_CLK4_DS_CNTL, CLK4_ALLOW_DS, mask_sh), \
#define CLK_REG_LIST_DCN42B() \
SR(DENTIST_DISPCLK_CNTL), \
CLK_SR_DCN42B(CLK5_CLK_TICK_CNT_CONFIG_REG), \
CLK_SR_DCN42B(CLK5_CLK0_CURRENT_CNT), \
CLK_SR_DCN42B(CLK5_CLK1_CURRENT_CNT), \
CLK_SR_DCN42B(CLK5_CLK2_CURRENT_CNT), \
CLK_SR_DCN42B(CLK5_CLK3_CURRENT_CNT), \
CLK_SR_DCN42B(CLK5_CLK0_DS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK1_DS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK2_DS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK3_DS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK0_BYPASS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK1_BYPASS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK2_BYPASS_CNTL), \
CLK_SR_DCN42B(CLK5_CLK3_BYPASS_CNTL)
#define CLK_COMMON_MASK_SH_LIST_DCN42B(mask_sh) \
CLK_COMMON_MASK_SH_LIST_DCN20_BASE(mask_sh),\
CLK_SF(CLK5_CLK_TICK_CNT_CONFIG_REG, TIMER_THRESHOLD, mask_sh), \
CLK_SF(CLK5_CLK0_BYPASS_CNTL, CLK0_BYPASS_SEL, mask_sh), \
CLK_SF(CLK5_CLK1_BYPASS_CNTL, CLK1_BYPASS_SEL, mask_sh), \
CLK_SF(CLK5_CLK2_BYPASS_CNTL, CLK2_BYPASS_SEL, mask_sh), \
CLK_SF(CLK5_CLK3_BYPASS_CNTL, CLK3_BYPASS_SEL, mask_sh), \
CLK_SF(CLK5_CLK0_DS_CNTL, CLK0_DS_DIV_ID, mask_sh), \
CLK_SF(CLK5_CLK1_DS_CNTL, CLK1_DS_DIV_ID, mask_sh), \
CLK_SF(CLK5_CLK2_DS_CNTL, CLK2_DS_DIV_ID, mask_sh), \
CLK_SF(CLK5_CLK3_DS_CNTL, CLK3_DS_DIV_ID, mask_sh), \
CLK_SF(CLK5_CLK0_DS_CNTL, CLK0_ALLOW_DS, mask_sh), \
CLK_SF(CLK5_CLK1_DS_CNTL, CLK1_ALLOW_DS, mask_sh), \
CLK_SF(CLK5_CLK2_DS_CNTL, CLK2_ALLOW_DS, mask_sh), \
CLK_SF(CLK5_CLK3_DS_CNTL, CLK3_ALLOW_DS, mask_sh)
#define CLK_REG_FIELD_LIST(type) \
type DPREFCLK_SRC_SEL; \
type DENTIST_DPREFCLK_WDIVIDER; \
type DENTIST_DISPCLK_WDIVIDER; \
type DENTIST_DISPCLK_CHG_DONE;
#define CLK20_REG_FIELD_LIST(type) \
type DENTIST_DPPCLK_WDIVIDER; \
type DENTIST_DPPCLK_CHG_DONE; \
type FbMult_int; \
type FbMult_frac;
#define CLK42_REG_LIST(clkip_num, type) \
type CLK ## clkip_num ## _CLK_TICK_CNT_CONFIG_REG; \
type CLK ## clkip_num ## _CLK0_CURRENT_CNT; \
type CLK ## clkip_num ## _CLK1_CURRENT_CNT; \
type CLK ## clkip_num ## _CLK2_CURRENT_CNT; \
type CLK ## clkip_num ## _CLK3_CURRENT_CNT; \
type CLK ## clkip_num ## _CLK4_CURRENT_CNT; \
type CLK ## clkip_num ## _CLK0_BYPASS_CNTL; \
type CLK ## clkip_num ## _CLK1_BYPASS_CNTL; \
type CLK ## clkip_num ## _CLK2_BYPASS_CNTL; \
type CLK ## clkip_num ## _CLK3_BYPASS_CNTL; \
type CLK ## clkip_num ## _CLK4_BYPASS_CNTL; \
type CLK ## clkip_num ## _CLK0_DS_CNTL; \
type CLK ## clkip_num ## _CLK1_DS_CNTL; \
type CLK ## clkip_num ## _CLK2_DS_CNTL; \
type CLK ## clkip_num ## _CLK3_DS_CNTL; \
type CLK ## clkip_num ## _CLK4_DS_CNTL;
#define CLK42_REG_FIELD_LIST(type) \
type TIMER_THRESHOLD; \
type CLK0_BYPASS_SEL; \
type CLK1_BYPASS_SEL; \
type CLK2_BYPASS_SEL; \
type CLK3_BYPASS_SEL; \
type CLK4_BYPASS_SEL; \
type CLK0_DS_DIV_ID; \
type CLK1_DS_DIV_ID; \
type CLK2_DS_DIV_ID; \
type CLK3_DS_DIV_ID; \
type CLK4_DS_DIV_ID; \
type CLK0_ALLOW_DS; \
type CLK1_ALLOW_DS; \
type CLK2_ALLOW_DS; \
type CLK3_ALLOW_DS; \
type CLK4_ALLOW_DS;
/*
***************************************************************************************
****************** Clock Manager Private Structures ***********************************
***************************************************************************************
*/
struct clk_mgr_registers {
uint32_t DPREFCLK_CNTL;
uint32_t DENTIST_DISPCLK_CNTL;
uint32_t CLK4_CLK2_CURRENT_CNT;
uint32_t CLK4_CLK_PLL_REQ;
uint32_t CLK4_CLK0_CURRENT_CNT;
uint32_t CLK3_CLK2_DFS_CNTL;
uint32_t CLK3_CLK_PLL_REQ;
uint32_t CLK0_CLK2_DFS_CNTL;
uint32_t CLK0_CLK_PLL_REQ;
uint32_t CLK1_CLK_PLL_REQ;
uint32_t CLK1_CLK0_DFS_CNTL;
uint32_t CLK1_CLK1_DFS_CNTL;
uint32_t CLK1_CLK2_DFS_CNTL;
uint32_t CLK1_CLK3_DFS_CNTL;
uint32_t CLK1_CLK4_DFS_CNTL;
uint32_t CLK1_CLK5_DFS_CNTL;
uint32_t CLK2_CLK2_DFS_CNTL;
uint32_t CLK1_CLK0_CURRENT_CNT;
uint32_t CLK1_CLK1_CURRENT_CNT;
uint32_t CLK1_CLK2_CURRENT_CNT;
uint32_t CLK1_CLK3_CURRENT_CNT;
uint32_t CLK1_CLK4_CURRENT_CNT;
uint32_t CLK1_CLK5_CURRENT_CNT;
uint32_t CLK0_CLK0_DFS_CNTL;
uint32_t CLK0_CLK1_DFS_CNTL;
uint32_t CLK0_CLK3_DFS_CNTL;
uint32_t CLK0_CLK4_DFS_CNTL;
uint32_t CLK1_CLK0_BYPASS_CNTL;
uint32_t CLK1_CLK1_BYPASS_CNTL;
uint32_t CLK1_CLK2_BYPASS_CNTL;
uint32_t CLK1_CLK3_BYPASS_CNTL;
uint32_t CLK1_CLK4_BYPASS_CNTL;
uint32_t CLK1_CLK5_BYPASS_CNTL;
uint32_t CLK1_CLK0_DS_CNTL;
uint32_t CLK1_CLK1_DS_CNTL;
uint32_t CLK1_CLK2_DS_CNTL;
uint32_t CLK1_CLK3_DS_CNTL;
uint32_t CLK1_CLK4_DS_CNTL;
uint32_t CLK1_CLK5_DS_CNTL;
uint32_t CLK1_CLK0_ALLOW_DS;
uint32_t CLK1_CLK1_ALLOW_DS;
uint32_t CLK1_CLK2_ALLOW_DS;
uint32_t CLK1_CLK3_ALLOW_DS;
uint32_t CLK1_CLK4_ALLOW_DS;
uint32_t CLK1_CLK5_ALLOW_DS;
uint32_t CLK5_spll_field_8;
uint32_t CLK6_spll_field_8;
CLK42_REG_LIST(8, uint32_t)
CLK42_REG_LIST(5, uint32_t)
};
struct clk_mgr_shift {
CLK_REG_FIELD_LIST(uint8_t)
CLK20_REG_FIELD_LIST(uint8_t)
CLK42_REG_FIELD_LIST(uint8_t)
};
struct clk_mgr_mask {
CLK_REG_FIELD_LIST(uint32_t)
CLK20_REG_FIELD_LIST(uint32_t)
CLK42_REG_FIELD_LIST(uint32_t)
};
enum clock_type {
clock_type_dispclk = 1,
clock_type_dcfclk,
clock_type_socclk,
clock_type_pixelclk,
clock_type_phyclk,
clock_type_dppclk,
clock_type_fclk,
clock_type_dcfdsclk,
clock_type_dscclk,
clock_type_uclk,
clock_type_dramclk,
clock_type_dprefclk,
clock_type_dtbclk,
};
struct clk_mgr_internal {
struct clk_mgr base;
int smu_ver;
struct pp_smu_funcs *pp_smu;
struct clk_mgr_internal_funcs *funcs;
struct dccg *dccg;
/*
* For backwards compatbility with previous implementation
* TODO: remove these after everything transitions to new pattern
* Rationale is that clk registers change a lot across DCE versions
* and a shared data structure doesn't really make sense.
*/
const struct clk_mgr_registers *regs;
const struct clk_mgr_shift *clk_mgr_shift;
const struct clk_mgr_mask *clk_mgr_mask;
/*TODO: figure out which of the below fields should be here vs in asic specific portion */
/* Cache the status of DFS-bypass feature*/
bool dfs_bypass_enabled;
/* True if the DFS-bypass feature is enabled and active. */
bool dfs_bypass_active;
uint32_t dfs_ref_freq_khz;
/*
* Cache the display clock returned by VBIOS if DFS-bypass is enabled.
* This is basically "Crystal Frequency In KHz" (XTALIN) frequency
*/
int dfs_bypass_disp_clk;
/**
* @ss_on_dprefclk:
*
* True if spread spectrum is enabled on the DP ref clock.
*/
bool ss_on_dprefclk;
/**
* @xgmi_enabled:
*
* True if xGMI is enabled. On VG20, both audio and display clocks need
* to be adjusted with the WAFL link's SS info if xGMI is enabled.
*/
bool xgmi_enabled;
/**
* @dprefclk_ss_percentage:
*
* DPREFCLK SS percentage (if down-spread enabled).
*
* Note that if XGMI is enabled, the SS info (percentage and divider)
* from the WAFL link is used instead. This is decided during
* dce_clk_mgr initialization.
*/
int dprefclk_ss_percentage;
/**
* @dprefclk_ss_divider:
*
* DPREFCLK SS percentage Divider (100 or 1000).
*/
int dprefclk_ss_divider;
bool periodic_retraining_disabled;
unsigned int cur_phyclk_req_table[MAX_LINKS];
bool smu_present;
void *wm_range_table;
long long wm_range_table_addr;
/**
* @dal_init_table:
*
* GPU-accessible DRAM buffer for the DAL init table transferred
* from PMFW via DALSMC_MSG_TransferTableSmu2Dram(TABLE_DAL_INIT).
* Contains all static PMFW data needed at init: DPM clock tables,
* UTM QoS parameters, and memory configuration.
*/
const void *dal_init_table;
long long dal_init_table_addr;
bool dpm_present;
bool pme_trigger_pending;
};
struct clk_mgr_internal_funcs {
int (*set_dispclk)(struct clk_mgr_internal *clk_mgr, int requested_dispclk_khz);
int (*set_dprefclk)(struct clk_mgr_internal *clk_mgr);
};
/*
***************************************************************************************
****************** Clock Manager Level Helper functions *******************************
***************************************************************************************
*/
static inline bool should_set_clock(bool safe_to_lower, int calc_clk, int cur_clk)
{
return ((safe_to_lower && calc_clk < cur_clk) || calc_clk > cur_clk);
}
static inline bool should_update_pstate_support(bool safe_to_lower, bool calc_support, bool cur_support)
{
if (cur_support != calc_support) {
if (calc_support && safe_to_lower)
return true;
else if (!calc_support && !safe_to_lower)
return true;
}
return false;
}
static inline int khz_to_mhz_ceil(int khz)
{
return (khz + 999) / 1000;
}
static inline int khz_to_mhz_floor(int khz)
{
return khz / 1000;
}
int clk_mgr_helper_get_active_display_cnt(
struct dc *dc,
struct dc_state *context);
int clk_mgr_helper_get_active_plane_cnt(
struct dc *dc,
struct dc_state *context);
#endif //__DAL_CLK_MGR_INTERNAL_H__
@@ -0,0 +1,121 @@
/* SPDX-License-Identifier: MIT */
/* Copyright © 2022 Advanced Micro Devices, Inc. All rights reserved. */
#ifndef __DAL_CURSOR_CACHE_H__
#define __DAL_CURSOR_CACHE_H__
union reg_cursor_control_cfg {
struct {
uint32_t cur_enable: 1;
uint32_t reser0: 3;
uint32_t cur_2x_magnify: 1;
uint32_t reser1: 3;
uint32_t mode: 3;
uint32_t reser2: 5;
uint32_t pitch: 2;
uint32_t reser3: 6;
uint32_t line_per_chunk: 5;
uint32_t reser4: 3;
} bits;
uint32_t raw;
};
struct cursor_position_cache_hubp {
union reg_cursor_control_cfg cur_ctl;
union reg_position_cfg {
struct {
uint32_t x_pos: 16;
uint32_t y_pos: 16;
} bits;
uint32_t raw;
} position;
union reg_hot_spot_cfg {
struct {
uint32_t x_hot: 16;
uint32_t y_hot: 16;
} bits;
uint32_t raw;
} hot_spot;
union reg_dst_offset_cfg {
struct {
uint32_t dst_x_offset: 13;
uint32_t reserved: 19;
} bits;
uint32_t raw;
} dst_offset;
};
struct cursor_attribute_cache_hubp {
uint32_t SURFACE_ADDR_HIGH;
uint32_t SURFACE_ADDR;
union reg_cursor_control_cfg cur_ctl;
union reg_cursor_size_cfg {
struct {
uint32_t width: 16;
uint32_t height: 16;
} bits;
uint32_t raw;
} size;
union reg_cursor_settings_cfg {
struct {
uint32_t dst_y_offset: 8;
uint32_t chunk_hdl_adjust: 2;
uint32_t reserved: 22;
} bits;
uint32_t raw;
} settings;
};
struct cursor_rect {
uint32_t x;
uint32_t y;
uint32_t w;
uint32_t h;
};
union reg_cur0_control_cfg {
struct {
uint32_t cur0_enable: 1;
uint32_t expansion_mode: 1;
uint32_t reser0: 1;
uint32_t cur0_rom_en: 1;
uint32_t mode: 3;
uint32_t reserved: 25;
} bits;
uint32_t raw;
};
struct cursor_position_cache_dpp {
union reg_cur0_control_cfg cur0_ctl;
};
struct cursor_attribute_cache_dpp {
union reg_cur0_control_cfg cur0_ctl;
union reg_cur0_fp_scale_bias {
struct {
uint32_t fp_bias: 16;
uint32_t fp_scale: 16;
} bits;
uint32_t raw;
} fp_scale_bias;
union reg_cur0_fp_scale_bias_g_y {
struct {
uint32_t fp_bias_g_y: 16;
uint32_t fp_scale_g_y: 16;
} bits;
uint32_t raw;
} fp_scale_bias_g_y;
union reg_cur0_fp_scale_bias_rb_crcb {
struct {
uint32_t fp_bias_rb_crcb: 16;
uint32_t fp_scale_rb_crcb: 16;
} bits;
uint32_t raw;
} fp_scale_bias_rb_crcb;
};
struct cursor_attributes_cfg {
struct cursor_attribute_cache_hubp aHubp;
struct cursor_attribute_cache_dpp aDpp;
};
#endif
@@ -0,0 +1,353 @@
/*
* Copyright 2018 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_DCCG_H__
#define __DAL_DCCG_H__
#include "dc_types.h"
#include "hw_shared.h"
enum phyd32clk_clock_source {
PHYD32CLKA,
PHYD32CLKB,
PHYD32CLKC,
PHYD32CLKD,
PHYD32CLKE,
PHYD32CLKF,
PHYD32CLKG,
};
enum physymclk_clock_source {
PHYSYMCLK_FORCE_SRC_SYMCLK, // Select symclk as source of clock which is output to PHY through DCIO.
PHYSYMCLK_FORCE_SRC_PHYD18CLK, // Select phyd18clk as the source of clock which is output to PHY through DCIO.
PHYSYMCLK_FORCE_SRC_PHYD32CLK, // Select phyd32clk as the source of clock which is output to PHY through DCIO.
};
enum streamclk_source {
REFCLK, // Selects REFCLK as source for hdmistreamclk.
DTBCLK0, // Selects DTBCLK0 as source for hdmistreamclk.
DPREFCLK, // Selects DPREFCLK as source for hdmistreamclk
};
enum dentist_dispclk_change_mode {
DISPCLK_CHANGE_MODE_IMMEDIATE,
DISPCLK_CHANGE_MODE_RAMPING,
};
struct dp_dto_params {
int otg_inst;
enum signal_type signal;
enum streamclk_source clk_src;
uint64_t pixclk_hz;
uint64_t refclk_hz;
};
enum pixel_rate_div {
PIXEL_RATE_DIV_BY_1 = 0,
PIXEL_RATE_DIV_BY_2 = 1,
PIXEL_RATE_DIV_BY_4 = 3,
PIXEL_RATE_DIV_NA = 0xF
};
struct dcn_dccg_reg_state {
uint32_t dc_mem_global_pwr_req_cntl;
uint32_t dccg_audio_dtbclk_dto_modulo;
uint32_t dccg_audio_dtbclk_dto_phase;
uint32_t dccg_audio_dto_source;
uint32_t dccg_audio_dto0_module;
uint32_t dccg_audio_dto0_phase;
uint32_t dccg_audio_dto1_module;
uint32_t dccg_audio_dto1_phase;
uint32_t dccg_cac_status;
uint32_t dccg_cac_status2;
uint32_t dccg_disp_cntl_reg;
uint32_t dccg_ds_cntl;
uint32_t dccg_ds_dto_incr;
uint32_t dccg_ds_dto_modulo;
uint32_t dccg_ds_hw_cal_interval;
uint32_t dccg_gate_disable_cntl;
uint32_t dccg_gate_disable_cntl2;
uint32_t dccg_gate_disable_cntl3;
uint32_t dccg_gate_disable_cntl4;
uint32_t dccg_gate_disable_cntl5;
uint32_t dccg_gate_disable_cntl6;
uint32_t dccg_global_fgcg_rep_cntl;
uint32_t dccg_gtc_cntl;
uint32_t dccg_gtc_current;
uint32_t dccg_gtc_dto_incr;
uint32_t dccg_gtc_dto_modulo;
uint32_t dccg_perfmon_cntl;
uint32_t dccg_perfmon_cntl2;
uint32_t dccg_soft_reset;
uint32_t dccg_test_clk_sel;
uint32_t dccg_vsync_cnt_ctrl;
uint32_t dccg_vsync_cnt_int_ctrl;
uint32_t dccg_vsync_otg0_latch_value;
uint32_t dccg_vsync_otg1_latch_value;
uint32_t dccg_vsync_otg2_latch_value;
uint32_t dccg_vsync_otg3_latch_value;
uint32_t dccg_vsync_otg4_latch_value;
uint32_t dccg_vsync_otg5_latch_value;
uint32_t dispclk_cgtt_blk_ctrl_reg;
uint32_t dispclk_freq_change_cntl;
uint32_t dp_dto_dbuf_en;
uint32_t dp_dto0_modulo;
uint32_t dp_dto0_phase;
uint32_t dp_dto1_modulo;
uint32_t dp_dto1_phase;
uint32_t dp_dto2_modulo;
uint32_t dp_dto2_phase;
uint32_t dp_dto3_modulo;
uint32_t dp_dto3_phase;
uint32_t dpiaclk_540m_dto_modulo;
uint32_t dpiaclk_540m_dto_phase;
uint32_t dpiaclk_810m_dto_modulo;
uint32_t dpiaclk_810m_dto_phase;
uint32_t dpiaclk_dto_cntl;
uint32_t dpiasymclk_cntl;
uint32_t dppclk_cgtt_blk_ctrl_reg;
uint32_t dppclk_ctrl;
uint32_t dppclk_dto_ctrl;
uint32_t dppclk0_dto_param;
uint32_t dppclk1_dto_param;
uint32_t dppclk2_dto_param;
uint32_t dppclk3_dto_param;
uint32_t dprefclk_cgtt_blk_ctrl_reg;
uint32_t dprefclk_cntl;
uint32_t dpstreamclk_cntl;
uint32_t dscclk_dto_ctrl;
uint32_t dscclk0_dto_param;
uint32_t dscclk1_dto_param;
uint32_t dscclk2_dto_param;
uint32_t dscclk3_dto_param;
uint32_t dtbclk_dto_dbuf_en;
uint32_t dtbclk_dto0_modulo;
uint32_t dtbclk_dto0_phase;
uint32_t dtbclk_dto1_modulo;
uint32_t dtbclk_dto1_phase;
uint32_t dtbclk_dto2_modulo;
uint32_t dtbclk_dto2_phase;
uint32_t dtbclk_dto3_modulo;
uint32_t dtbclk_dto3_phase;
uint32_t dtbclk_p_cntl;
uint32_t force_symclk_disable;
uint32_t hdmicharclk0_clock_cntl;
uint32_t hdmistreamclk_cntl;
uint32_t hdmistreamclk0_dto_param;
uint32_t microsecond_time_base_div;
uint32_t millisecond_time_base_div;
uint32_t otg_pixel_rate_div;
uint32_t otg0_phypll_pixel_rate_cntl;
uint32_t otg0_pixel_rate_cntl;
uint32_t otg1_phypll_pixel_rate_cntl;
uint32_t otg1_pixel_rate_cntl;
uint32_t otg2_phypll_pixel_rate_cntl;
uint32_t otg2_pixel_rate_cntl;
uint32_t otg3_phypll_pixel_rate_cntl;
uint32_t otg3_pixel_rate_cntl;
uint32_t phyasymclk_clock_cntl;
uint32_t phybsymclk_clock_cntl;
uint32_t phycsymclk_clock_cntl;
uint32_t phydsymclk_clock_cntl;
uint32_t phyesymclk_clock_cntl;
uint32_t phyplla_pixclk_resync_cntl;
uint32_t phypllb_pixclk_resync_cntl;
uint32_t phypllc_pixclk_resync_cntl;
uint32_t phyplld_pixclk_resync_cntl;
uint32_t phyplle_pixclk_resync_cntl;
uint32_t refclk_cgtt_blk_ctrl_reg;
uint32_t socclk_cgtt_blk_ctrl_reg;
uint32_t symclk_cgtt_blk_ctrl_reg;
uint32_t symclk_psp_cntl;
uint32_t symclk32_le_cntl;
uint32_t symclk32_se_cntl;
uint32_t symclka_clock_enable;
uint32_t symclkb_clock_enable;
uint32_t symclkc_clock_enable;
uint32_t symclkd_clock_enable;
uint32_t symclke_clock_enable;
};
struct dccg {
struct dc_context *ctx;
const struct dccg_funcs *funcs;
int pipe_dppclk_khz[MAX_PIPES];
int ref_dppclk;
bool dpp_clock_gated[MAX_PIPES];
//int dtbclk_khz[MAX_PIPES];/* TODO needs to be removed */
//int audio_dtbclk_khz;/* TODO needs to be removed */
//int ref_dtbclk_khz;/* TODO needs to be removed */
};
struct dtbclk_dto_params {
const struct dc_crtc_timing *timing;
int otg_inst;
int pixclk_khz;
int req_audio_dtbclk_khz;
int num_odm_segments;
int ref_dtbclk_khz;
bool is_hdmi;
};
struct dccg_funcs {
void (*update_dpp_dto)(struct dccg *dccg,
int dpp_inst,
int req_dppclk);
void (*get_dccg_ref_freq)(struct dccg *dccg,
unsigned int xtalin_freq_inKhz,
unsigned int *dccg_ref_freq_inKhz);
void (*set_fifo_errdet_ovr_en)(struct dccg *dccg,
bool en);
void (*otg_add_pixel)(struct dccg *dccg,
uint32_t otg_inst);
void (*otg_drop_pixel)(struct dccg *dccg,
uint32_t otg_inst);
void (*dccg_init)(struct dccg *dccg);
void (*refclk_setup)(struct dccg *dccg); /* Deprecated - for backward compatibility only */
void (*allow_clock_gating)(struct dccg *dccg, bool allow);
void (*enable_memory_low_power)(struct dccg *dccg, bool enable);
bool (*is_s0i3_golden_init_wa_done)(struct dccg *dccg);
void (*enable_hdmicharclk)(struct dccg *dccg, int hpo_inst, int phypll_inst);
void (*disable_hdmicharclk)(struct dccg *dccg, int hpo_inst);
void (*set_hdmistreamclk)(
struct dccg *dccg,
enum streamclk_source src,
uint32_t otg_inst);
void (*set_hdmistreamclk_root_clock_gating)(
struct dccg *dccg,
bool enable);
void (*set_dpstreamclk_root_clock_gating)(
struct dccg *dccg,
int dp_hpo_inst,
bool enable);
void (*set_dpstreamclk)(
struct dccg *dccg,
enum streamclk_source src,
int otg_inst,
int dp_hpo_inst);
void (*enable_symclk32_se)(
struct dccg *dccg,
int hpo_se_inst,
enum phyd32clk_clock_source phyd32clk);
void (*disable_symclk32_se)(
struct dccg *dccg,
int hpo_se_inst);
void (*enable_symclk32_le)(
struct dccg *dccg,
int hpo_le_inst,
enum phyd32clk_clock_source phyd32clk);
void (*disable_symclk32_le)(
struct dccg *dccg,
int hpo_le_inst);
void (*set_symclk32_le_root_clock_gating)(
struct dccg *dccg,
int hpo_le_inst,
bool enable);
void (*set_physymclk)(
struct dccg *dccg,
int phy_inst,
enum physymclk_clock_source clk_src,
bool force_enable);
void (*set_physymclk_root_clock_gating)(
struct dccg *dccg,
int phy_inst,
bool enable);
void (*set_dtbclk_dto)(
struct dccg *dccg,
const struct dtbclk_dto_params *params);
void (*set_audio_dtbclk_dto)(
struct dccg *dccg,
const struct dtbclk_dto_params *params);
void (*set_dispclk_change_mode)(
struct dccg *dccg,
enum dentist_dispclk_change_mode change_mode);
void (*disable_dsc)(
struct dccg *dccg,
int inst);
void (*enable_dsc)(
struct dccg *dccg,
int inst);
void (*set_pixel_rate_div)(struct dccg *dccg,
uint32_t otg_inst,
enum pixel_rate_div k1,
enum pixel_rate_div k2);
void (*get_pixel_rate_div)(struct dccg *dccg,
uint32_t otg_inst,
uint32_t *div_factor1,
uint32_t *div_factor2);
void (*set_valid_pixel_rate)(
struct dccg *dccg,
int ref_dtbclk_khz,
int otg_inst,
int pixclk_khz);
void (*trigger_dio_fifo_resync)(
struct dccg *dccg);
void (*dpp_root_clock_control)(
struct dccg *dccg,
unsigned int dpp_inst,
bool clock_on);
void (*enable_symclk_se)(
struct dccg *dccg,
uint32_t stream_enc_inst,
uint32_t link_enc_inst);
void (*disable_symclk_se)(
struct dccg *dccg,
uint32_t stream_enc_inst,
uint32_t link_enc_inst);
void (*set_dp_dto)(
struct dccg *dccg,
const struct dp_dto_params *params);
void (*set_dtbclk_p_src)(
struct dccg *dccg,
enum streamclk_source src,
uint32_t otg_inst);
void (*set_dto_dscclk)(struct dccg *dccg, uint32_t dsc_inst, uint32_t num_slices_h);
void (*set_ref_dscclk)(struct dccg *dccg, uint32_t dsc_inst);
void (*dccg_root_gate_disable_control)(struct dccg *dccg, uint32_t pipe_idx, uint32_t disable_clock_gating);
void (*dccg_read_reg_state)(struct dccg *dccg, struct dcn_dccg_reg_state *dccg_reg_state);
void (*dccg_enable_global_fgcg)(struct dccg *dccg, bool enable);
};
#endif //__DAL_DCCG_H__
@@ -0,0 +1,304 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_DCHUBBUB_H__
#define __DAL_DCHUBBUB_H__
/**
* DOC: overview
*
* There is only one common DCHUBBUB. It contains the common request and return
* blocks for the Data Fabric Interface that are not clock/power gated.
*/
#include "dc/dc_hw_types.h"
enum dcc_control {
dcc_control__256_256_xxx,
dcc_control__128_128_xxx,
dcc_control__256_64_64,
dcc_control__256_128_128,
dcc_control__256_256,
dcc_control__256_128,
dcc_control__256_64,
};
enum segment_order {
segment_order__na,
segment_order__contiguous,
segment_order__non_contiguous,
};
struct dcn_hubbub_wm_set {
uint32_t wm_set;
uint32_t data_urgent;
uint32_t pte_meta_urgent;
uint32_t sr_enter;
uint32_t sr_exit;
uint32_t dram_clk_change;
uint32_t usr_retrain;
uint32_t fclk_pstate_change;
uint32_t sr_enter_exit_Z8;
uint32_t sr_enter_Z8;
};
struct dcn_hubbub_wm {
struct dcn_hubbub_wm_set sets[4];
};
enum dcn_hubbub_page_table_depth {
DCN_PAGE_TABLE_DEPTH_1_LEVEL,
DCN_PAGE_TABLE_DEPTH_2_LEVEL,
DCN_PAGE_TABLE_DEPTH_3_LEVEL,
DCN_PAGE_TABLE_DEPTH_4_LEVEL
};
enum dcn_hubbub_page_table_block_size {
DCN_PAGE_TABLE_BLOCK_SIZE_4KB = 0,
DCN_PAGE_TABLE_BLOCK_SIZE_8KB = 1,
DCN_PAGE_TABLE_BLOCK_SIZE_16KB = 2,
DCN_PAGE_TABLE_BLOCK_SIZE_32KB = 3,
DCN_PAGE_TABLE_BLOCK_SIZE_64KB = 4,
DCN_PAGE_TABLE_BLOCK_SIZE_128KB = 5,
DCN_PAGE_TABLE_BLOCK_SIZE_256KB = 6,
DCN_PAGE_TABLE_BLOCK_SIZE_512KB = 7,
DCN_PAGE_TABLE_BLOCK_SIZE_1024KB = 8,
DCN_PAGE_TABLE_BLOCK_SIZE_2048KB = 9
};
struct dcn_hubbub_phys_addr_config {
struct {
uint64_t fb_top;
uint64_t fb_offset;
uint64_t fb_base;
uint64_t agp_top;
uint64_t agp_bot;
uint64_t agp_base;
} system_aperture;
struct {
uint64_t page_table_start_addr;
uint64_t page_table_end_addr;
uint64_t page_table_base_addr;
} gart_config;
uint64_t page_table_default_page_addr;
};
struct dcn_hubbub_virt_addr_config {
uint64_t page_table_start_addr;
uint64_t page_table_end_addr;
enum dcn_hubbub_page_table_block_size page_table_block_size;
enum dcn_hubbub_page_table_depth page_table_depth;
uint64_t page_table_base_addr;
};
struct hubbub_addr_config {
struct dcn_hubbub_phys_addr_config pa_config;
struct dcn_hubbub_virt_addr_config va_config;
struct {
uint64_t aperture_check_fault;
uint64_t generic_fault;
} default_addrs;
};
struct dcn_hubbub_state {
uint32_t vm_fault_addr_msb;
uint32_t vm_fault_addr_lsb;
uint32_t vm_error_status;
uint32_t vm_error_vmid;
uint32_t vm_error_pipe;
uint32_t vm_error_mode;
uint32_t test_debug_data;
uint32_t watermark_change_cntl;
uint32_t dram_state_cntl;
};
struct dcn_hubbub_reg_state {
uint32_t det0_ctrl;
uint32_t det1_ctrl;
uint32_t det2_ctrl;
uint32_t det3_ctrl;
uint32_t compbuf_ctrl;
};
struct hubbub_system_latencies {
uint32_t max_latency_ns;
uint32_t avg_latency_ns;
uint32_t min_latency_ns;
};
struct hubbub_urgent_latency_params {
uint32_t refclk_mhz;
uint32_t t_win_ns;
uint32_t bandwidth_mbps;
uint32_t bw_factor_x1000;
};
struct hubbub_funcs {
void (*update_dchub)(
struct hubbub *hubbub,
struct dchub_init_data *dh_data);
int (*init_dchub_sys_ctx)(
struct hubbub *hubbub,
struct dcn_hubbub_phys_addr_config *pa_config);
void (*init_vm_ctx)(
struct hubbub *hubbub,
struct dcn_hubbub_virt_addr_config *va_config,
int vmid);
bool (*get_dcc_compression_cap)(struct hubbub *hubbub,
const struct dc_dcc_surface_param *input,
struct dc_surface_dcc_cap *output);
bool (*dcc_support_swizzle)(
enum swizzle_mode_values swizzle,
unsigned int bytes_per_element,
enum segment_order *segment_order_horz,
enum segment_order *segment_order_vert);
bool (*dcc_support_swizzle_addr3)(
enum swizzle_mode_addr3_values swizzle,
unsigned int plane_pitch,
unsigned int bytes_per_element,
enum segment_order *segment_order_horz,
enum segment_order *segment_order_vert);
bool (*dcc_support_pixel_format_plane0_plane1)(
enum surface_pixel_format format,
unsigned int *plane0_bpe,
unsigned int *plane1_bpe);
bool (*dcc_support_pixel_format)(
enum surface_pixel_format format,
unsigned int *bytes_per_element);
void (*wm_read_state)(struct hubbub *hubbub,
struct dcn_hubbub_wm *wm);
void (*get_dchub_ref_freq)(struct hubbub *hubbub,
unsigned int dccg_ref_freq_inKhz,
unsigned int *dchub_ref_freq_inKhz);
bool (*program_watermarks)(
struct hubbub *hubbub,
union dcn_watermark_set *watermarks,
unsigned int refclk_mhz,
bool safe_to_lower);
bool (*is_allow_self_refresh_enabled)(struct hubbub *hubbub);
void (*allow_self_refresh_control)(struct hubbub *hubbub, bool allow);
bool (*verify_allow_pstate_change_high)(struct hubbub *hubbub);
void (*apply_DEDCN21_147_wa)(struct hubbub *hubbub);
void (*force_wm_propagate_to_pipes)(struct hubbub *hubbub);
void (*hubbub_read_state)(struct hubbub *hubbub, struct dcn_hubbub_state *hubbub_state);
void (*force_pstate_change_control)(struct hubbub *hubbub, bool force, bool allow);
void (*init_watermarks)(struct hubbub *hubbub);
void (*hubbub_read_reg_state)(struct hubbub *hubbub, struct dcn_hubbub_reg_state *hubbub_reg_state);
/**
* @program_det_size:
*
* DE-Tile buffers (DET) is a memory that is used to convert the tiled
* data into linear, which the rest of the display can use to generate
* the graphics output. One of the main features of this component is
* that each pipe has a configurable DET buffer which means that when a
* pipe is not enabled, the device can assign the memory to other
* enabled pipes to try to be more efficient.
*
* DET logic is handled by dchubbub. Some ASICs provide a feature named
* Configurable Return Buffer (CRB) segments which can be allocated to
* compressed or detiled buffers.
*/
void (*program_det_size)(struct hubbub *hubbub, int hubp_inst, unsigned det_buffer_size_in_kbyte);
void (*wait_for_det_apply)(struct hubbub *hubbub, int hubp_inst);
void (*program_compbuf_size)(struct hubbub *hubbub, unsigned compbuf_size_kb, bool safe_to_increase);
void (*init_crb)(struct hubbub *hubbub);
void (*force_usr_retraining_allow)(struct hubbub *hubbub, bool allow);
void (*set_request_limit)(struct hubbub *hubbub, int memory_channel_count, int words_per_channel);
void (*dchubbub_init)(struct hubbub *hubbub);
void (*get_mall_en)(struct hubbub *hubbub, unsigned int *mall_in_use);
void (*program_det_segments)(struct hubbub *hubbub, int hubp_inst, unsigned det_buffer_size_seg);
void (*program_compbuf_segments)(struct hubbub *hubbub, unsigned compbuf_size_seg, bool safe_to_increase);
void (*wait_for_det_update)(struct hubbub *hubbub, int hubp_inst);
bool (*program_arbiter)(struct hubbub *hubbub, struct dml2_display_arb_regs *arb_regs, bool safe_to_lower);
void (*dchvm_init)(struct hubbub *hubbub);
/* Performance monitoring related functions */
struct hubbub_perfmon_funcs {
void (*reset)(struct hubbub *hubbub);
void (*start_measuring_memory_latencies)(
struct hubbub *hubbub);
uint32_t (*get_memory_latencies_ns)(struct hubbub *hubbub,
uint32_t refclk_mhz, uint32_t *min_latency_ns,
uint32_t *max_latency_ns, uint32_t *avg_latency_ns);
void (*start_measuring_urgent_assertion_count)(
struct hubbub *hubbub);
bool (*get_urgent_assertion_count)(struct hubbub *hubbub,
uint32_t refclk_mhz,
uint32_t *assertion_count,
uint32_t *deassertion_count,
uint32_t *timestamp_us);
void (*start_measuring_urgent_ramp_latency)(
struct hubbub *hubbub,
const struct hubbub_urgent_latency_params *params);
uint32_t (*get_urgent_ramp_latency_ns)(struct hubbub *hubbub,
uint32_t refclk_mhz);
void (*start_measuring_unbounded_bandwidth)(
struct hubbub *hubbub);
uint32_t (*get_unbounded_bandwidth_mbps)(struct hubbub *hubbub,
uint32_t refclk_mhz, uint32_t *duration_ns);
void (*start_measuring_in_order_bandwidth)(
struct hubbub *hubbub);
uint32_t (*get_in_order_bandwidth_mbps)(struct hubbub *hubbub,
uint32_t refclk_mhz, uint32_t min_duration_ns,
uint32_t *duration_ns);
void (*start_measuring_prefetch_data_size)(
struct hubbub *hubbub);
uint32_t (*get_prefetch_data_size)(struct hubbub *hubbub);
} perfmon;
struct hubbub_qos_funcs {
void (*force_display_nominal_profile)(struct hubbub *hubbub);
void (*force_display_urgent_profile)(struct hubbub *hubbub);
void (*reset_display_qos_profile)(struct hubbub *hubbub);
} qos;
};
struct hubbub {
const struct hubbub_funcs *funcs;
struct dc_context *ctx;
bool riommu_active;
};
#endif
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: MIT
//
// Copyright 2025 Advanced Micro Devices, Inc.
#ifndef __DC_DIO_H__
#define __DC_DIO_H__
#include "dc_types.h"
struct dc_context;
struct dio;
struct dio_funcs {
void (*mem_pwr_ctrl)(struct dio *dio, bool enable_i2c_light_sleep);
};
struct dio {
const struct dio_funcs *funcs;
struct dc_context *ctx;
};
#endif /* __DC_DIO_H__ */
@@ -0,0 +1,96 @@
/* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_DMCU_H__
#define __DC_DMCU_H__
#include "dm_services_types.h"
/* If HW itself ever powered down it will be 0.
* fwDmcuInit will write to 1.
* Driver will only call MCP init if current state is 1,
* and the MCP command will transition this to 2.
*/
enum dmcu_state {
DMCU_UNLOADED = 0,
DMCU_LOADED_UNINITIALIZED = 1,
DMCU_RUNNING = 2,
};
struct dmcu_version {
unsigned int interface_version;
unsigned int abm_version;
unsigned int psr_version;
unsigned int build_version;
};
struct dmcu {
struct dc_context *ctx;
const struct dmcu_funcs *funcs;
enum dmcu_state dmcu_state;
struct dmcu_version dmcu_version;
unsigned int cached_wait_loop_number;
uint32_t psp_version;
bool auto_load_dmcu;
};
struct dmcu_funcs {
bool (*dmcu_init)(struct dmcu *dmcu);
bool (*load_iram)(struct dmcu *dmcu,
unsigned int start_offset,
const char *src,
unsigned int bytes);
void (*set_psr_enable)(struct dmcu *dmcu, bool enable, bool wait);
bool (*setup_psr)(struct dmcu *dmcu,
struct dc_link *link,
struct psr_context *psr_context);
void (*get_psr_state)(struct dmcu *dmcu, enum dc_psr_state *dc_psr_state);
void (*set_psr_wait_loop)(struct dmcu *dmcu,
unsigned int wait_loop_number);
void (*get_psr_wait_loop)(struct dmcu *dmcu,
unsigned int *psr_wait_loop_number);
bool (*is_dmcu_initialized)(struct dmcu *dmcu);
bool (*lock_phy)(struct dmcu *dmcu);
bool (*unlock_phy)(struct dmcu *dmcu);
bool (*send_edid_cea)(struct dmcu *dmcu,
int offset,
int total_length,
uint8_t *data,
int length);
bool (*recv_amd_vsdb)(struct dmcu *dmcu,
int *version,
int *min_frame_rate,
int *max_frame_rate);
bool (*recv_edid_cea_ack)(struct dmcu *dmcu, int *offset);
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
void (*forward_crc_window)(struct dmcu *dmcu,
struct rect *rect,
struct otg_phy_mux *mux_mapping);
void (*stop_crc_win_update)(struct dmcu *dmcu,
struct otg_phy_mux *mux_mapping);
#endif
};
#endif
@@ -0,0 +1,382 @@
/*
* Copyright 2012-2026 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_DPP_H__
#define __DAL_DPP_H__
/**
* DOC: overview
*
* The DPP (Display Pipe and Plane) block is the unified display data
* processing engine in DCN for processing graphic or video data on per DPP
* rectangle base. This rectangle can be a part of SLS (Single Large Surface),
* or a layer to be blended with other DPP, or a rectangle associated with a
* display tile.
*
* It provides various functions including:
* - graphic color keyer
* - graphic cursor compositing
* - graphic or video image source to destination scaling
* - image sharping
* - video format conversion from 4:2:0 or 4:2:2 to 4:4:4
* - Color Space Conversion
* - Host LUT gamma adjustment
* - Color Gamut Remap
* - brightness and contrast adjustment.
*
* DPP pipe consists of Converter and Cursor (CNVC), Scaler (DSCL), Color
* Management (CM), Output Buffer (OBUF) and Digital Bypass (DPB) module
* connected in a video/graphics pipeline.
*/
#include "transform.h"
#include "cursor_reg_cache.h"
union defer_reg_writes {
struct {
bool disable_blnd_lut:1;
bool disable_3dlut:1;
bool disable_shaper:1;
bool disable_gamcor:1;
bool disable_dscl:1;
} bits;
uint32_t raw;
};
struct dpp {
const struct dpp_funcs *funcs;
struct dc_context *ctx;
/**
* @inst:
*
* inst stands for "instance," and it is an id number that references a
* specific DPP.
*/
int inst;
struct dpp_caps *caps;
struct pwl_params regamma_params;
struct pwl_params degamma_params;
struct dpp_cursor_attributes cur_attr;
union defer_reg_writes deferred_reg_writes;
struct pwl_params shaper_params;
bool cm_bypass_mode;
bool cursor_offload;
struct cursor_position_cache_dpp pos;
struct cursor_attribute_cache_dpp att;
};
struct dpp_input_csc_matrix {
enum dc_color_space color_space;
uint16_t regval[12];
};
static const struct dpp_input_csc_matrix __maybe_unused dpp_input_csc_matrix[] = {
{ COLOR_SPACE_SRGB,
{ 0x2000, 0, 0, 0,
0, 0x2000, 0, 0,
0, 0, 0x2000, 0 } },
{ COLOR_SPACE_SRGB_LIMITED,
{ 0x2000, 0, 0, 0,
0, 0x2000, 0, 0,
0, 0, 0x2000, 0 } },
{ COLOR_SPACE_YCBCR601,
{ 0x2cdd, 0x2000, 0, 0xe991,
0xe926, 0x2000, 0xf4fd, 0x10ef,
0, 0x2000, 0x38b4, 0xe3a6 } },
{ COLOR_SPACE_YCBCR601_LIMITED,
{ 0x3353, 0x2568, 0, 0xe400,
0xe5dc, 0x2568, 0xf367, 0x1108,
0, 0x2568, 0x40de, 0xdd3a } },
{ COLOR_SPACE_YCBCR709,
{ 0x3265, 0x2000, 0, 0xe6ce,
0xf105, 0x2000, 0xfa01, 0xa7d,
0, 0x2000, 0x3b61, 0xe24f } },
{ COLOR_SPACE_YCBCR709_LIMITED,
{ 0x39a6, 0x2568, 0, 0xe0d6,
0xeedd, 0x2568, 0xf925, 0x9a8,
0, 0x2568, 0x43ee, 0xdbb2 } },
{ COLOR_SPACE_2020_YCBCR_FULL,
{ 0x2F30, 0x2000, 0, 0xE869,
0xEDB7, 0x2000, 0xFABC, 0xBC6,
0, 0x2000, 0x3C34, 0xE1E6 } },
{ COLOR_SPACE_2020_YCBCR_LIMITED,
{ 0x35B9, 0x2543, 0, 0xE2B2,
0xEB2F, 0x2543, 0xFA01, 0x0B1F,
0, 0x2543, 0x4489, 0xDB42 } },
{ COLOR_SPACE_2020_RGB_LIMITEDRANGE,
{ 0x35E0, 0x255F, 0, 0xE2B3,
0xEB20, 0x255F, 0xF9FD, 0xB1E,
0, 0x255F, 0x44BD, 0xDB43 } }
};
struct dpp_grph_csc_adjustment {
struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
enum graphics_gamut_adjust_type gamut_adjust_type;
};
struct cnv_color_keyer_params {
int color_keyer_en;
int color_keyer_mode;
int color_keyer_alpha_low;
int color_keyer_alpha_high;
int color_keyer_red_low;
int color_keyer_red_high;
int color_keyer_green_low;
int color_keyer_green_high;
int color_keyer_blue_low;
int color_keyer_blue_high;
};
/**
* struct cnv_alpha_2bit_lut - Set the 8bit alpha values based on the 2 bit alpha
*/
struct cnv_alpha_2bit_lut {
/**
* @lut0: ALPHA_2BIT_LUT. ALPHA_2BIT_LUT0. Default: 0b00000000
*/
int lut0;
/**
* @lut1: ALPHA_2BIT_LUT. ALPHA_2BIT_LUT1. Default: 0b01010101
*/
int lut1;
/**
* @lut2: ALPHA_2BIT_LUT. ALPHA_2BIT_LUT2. Default: 0b10101010
*/
int lut2;
/**
* @lut3: ALPHA_2BIT_LUT. ALPHA_2BIT_LUT3. Default: 0b11111111
*/
int lut3;
};
struct dcn_dpp_state {
uint32_t is_enabled;
uint32_t igam_lut_mode;
uint32_t igam_input_format;
uint32_t dgam_lut_mode;
uint32_t rgam_lut_mode;
// gamut_remap data for dcn10_get_cm_states()
uint32_t gamut_remap_mode;
uint32_t gamut_remap_c11_c12;
uint32_t gamut_remap_c13_c14;
uint32_t gamut_remap_c21_c22;
uint32_t gamut_remap_c23_c24;
uint32_t gamut_remap_c31_c32;
uint32_t gamut_remap_c33_c34;
// gamut_remap data for dcn*_log_color_state()
struct dpp_grph_csc_adjustment gamut_remap;
uint32_t shaper_lut_mode;
uint32_t lut3d_mode;
uint32_t lut3d_bit_depth;
uint32_t lut3d_size;
uint32_t blnd_lut_mode;
uint32_t pre_dgam_mode;
uint32_t pre_dgam_select;
uint32_t gamcor_mode;
};
struct dcn_dpp_reg_state {
uint32_t recout_start;
uint32_t recout_size;
uint32_t scl_horz_filter_scale_ratio;
uint32_t scl_vert_filter_scale_ratio;
uint32_t scl_mode;
uint32_t cm_control;
uint32_t dpp_control;
uint32_t dscl_control;
uint32_t obuf_control;
uint32_t mpc_size;
};
struct CM_bias_params {
uint32_t cm_bias_cr_r;
uint32_t cm_bias_y_g;
uint32_t cm_bias_cb_b;
uint32_t cm_bias_format;
};
struct dpp_funcs {
bool (*dpp_program_gamcor_lut)(
struct dpp *dpp_base, const struct pwl_params *params);
void (*dpp_set_pre_degam)(struct dpp *dpp_base,
enum dc_transfer_func_predefined tr);
void (*dpp_program_cm_dealpha)(struct dpp *dpp_base,
uint32_t enable, uint32_t additive_blending);
void (*dpp_program_cm_bias)(
struct dpp *dpp_base,
struct CM_bias_params *bias_params);
void (*dpp_read_state)(struct dpp *dpp, struct dcn_dpp_state *s);
void (*dpp_read_reg_state)(struct dpp *dpp, struct dcn_dpp_reg_state *dpp_reg_state);
void (*dpp_reset)(struct dpp *dpp);
void (*dpp_set_scaler)(struct dpp *dpp,
const struct scaler_data *scl_data);
void (*dpp_set_pixel_storage_depth)(
struct dpp *dpp,
enum lb_pixel_depth depth,
const struct bit_depth_reduction_params *bit_depth_params);
bool (*dpp_get_optimal_number_of_taps)(
struct dpp *dpp,
struct scaler_data *scl_data,
const struct scaling_taps *in_taps);
void (*dpp_set_gamut_remap)(
struct dpp *dpp,
const struct dpp_grph_csc_adjustment *adjust);
void (*dpp_set_csc_default)(
struct dpp *dpp,
enum dc_color_space colorspace);
void (*dpp_set_csc_adjustment)(
struct dpp *dpp,
const uint16_t *regval);
void (*dpp_power_on_regamma_lut)(
struct dpp *dpp,
bool power_on);
void (*dpp_program_regamma_lut)(
struct dpp *dpp,
const struct pwl_result_data *rgb,
uint32_t num);
void (*dpp_configure_regamma_lut)(
struct dpp *dpp,
bool is_ram_a);
void (*dpp_program_regamma_lutb_settings)(
struct dpp *dpp,
const struct pwl_params *params);
void (*dpp_program_regamma_luta_settings)(
struct dpp *dpp,
const struct pwl_params *params);
void (*dpp_program_regamma_pwl)(
struct dpp *dpp,
const struct pwl_params *params,
enum opp_regamma mode);
void (*dpp_program_bias_and_scale)(
struct dpp *dpp,
struct dc_bias_and_scale *params);
void (*dpp_set_degamma)(
struct dpp *dpp_base,
enum ipp_degamma_mode mode);
void (*dpp_program_input_lut)(
struct dpp *dpp_base,
const struct dc_gamma *gamma);
void (*dpp_program_degamma_pwl)(struct dpp *dpp_base,
const struct pwl_params *params);
void (*dpp_setup)(
struct dpp *dpp_base,
enum surface_pixel_format format,
enum expansion_mode mode,
struct dc_csc_transform input_csc_color_matrix,
enum dc_color_space input_color_space,
struct cnv_alpha_2bit_lut *alpha_2bit_lut);
void (*dpp_full_bypass)(struct dpp *dpp_base);
void (*set_cursor_attributes)(
struct dpp *dpp_base,
struct dc_cursor_attributes *cursor_attributes);
void (*set_cursor_position)(
struct dpp *dpp_base,
const struct dc_cursor_position *pos,
const struct dc_cursor_mi_param *param,
uint32_t width,
uint32_t height
);
void (*dpp_set_hdr_multiplier)(
struct dpp *dpp_base,
uint32_t multiplier);
void (*set_optional_cursor_attributes)(
struct dpp *dpp_base,
struct dpp_cursor_attributes *attr);
void (*dpp_dppclk_control)(
struct dpp *dpp_base,
bool dppclk_div,
bool enable);
void (*dpp_deferred_update)(
struct dpp *dpp);
bool (*dpp_program_blnd_lut)(
struct dpp *dpp,
const struct pwl_params *params);
bool (*dpp_program_shaper_lut)(
struct dpp *dpp,
const struct pwl_params *params);
bool (*dpp_program_3dlut)(
struct dpp *dpp,
const struct tetrahedral_params *params);
void (*dpp_cnv_set_alpha_keyer)(
struct dpp *dpp_base,
struct cnv_color_keyer_params *color_keyer);
void (*dpp_get_gamut_remap)(struct dpp *dpp_base,
struct dpp_grph_csc_adjustment *adjust);
void (*set_cursor_matrix)(
struct dpp *dpp_base,
enum dc_color_space color_space,
struct dc_csc_transform cursor_csc_color_matrix);
void (*dpp_force_disable_cursor)(struct dpp *dpp_base);
void (*dpp_cm_hist_control)(
struct dpp *dpp_base,
struct cm_hist_control cm_hist_control,
enum dc_color_space color_space);
bool (*dpp_cm_hist_read)(
struct dpp *dpp_base,
struct cm_hist *cm_hist);
};
#endif
@@ -0,0 +1,240 @@
/* Copyright 2012-17 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_DWBC_H__
#define __DC_DWBC_H__
#include "dal_types.h"
#include "dc_hw_types.h"
#define DWB_SW_V2 1
#define DWB_MCIF_BUF_COUNT 4
/* forward declaration of mcif_wb struct */
struct mcif_wb;
enum dwb_sw_version {
dwb_ver_1_0 = 1,
dwb_ver_2_0 = 2,
};
enum dwb_source {
dwb_src_scl = 0, /* for DCE7x/9x, DCN won't support. */
dwb_src_blnd, /* for DCE7x/9x */
dwb_src_fmt, /* for DCE7x/9x */
dwb_src_otg0 = 0x100, /* for DCN1.x/DCN2.x, register: mmDWB_SOURCE_SELECT */
dwb_src_otg1, /* for DCN1.x/DCN2.x */
dwb_src_otg2, /* for DCN1.x/DCN2.x */
dwb_src_otg3, /* for DCN1.x/DCN2.x */
};
/* DCN1.x, DCN2.x support 2 pipes */
enum dwb_pipe {
dwb_pipe0 = 0,
dwb_pipe1,
dwb_pipe_max_num,
};
enum dwb_frame_capture_enable {
DWB_FRAME_CAPTURE_DISABLE = 0,
DWB_FRAME_CAPTURE_ENABLE = 1,
};
enum wbscl_coef_filter_type_sel {
WBSCL_COEF_LUMA_VERT_FILTER = 0,
WBSCL_COEF_CHROMA_VERT_FILTER = 1,
WBSCL_COEF_LUMA_HORZ_FILTER = 2,
WBSCL_COEF_CHROMA_HORZ_FILTER = 3
};
enum dwb_boundary_mode {
DWBSCL_BOUNDARY_MODE_EDGE = 0,
DWBSCL_BOUNDARY_MODE_BLACK = 1
};
enum dwb_output_csc_mode {
DWB_OUTPUT_CSC_DISABLE = 0,
DWB_OUTPUT_CSC_COEF_A = 1,
DWB_OUTPUT_CSC_COEF_B = 2
};
enum dwb_ogam_lut_mode {
DWB_OGAM_MODE_BYPASS,
DWB_OGAM_RAMA_LUT,
DWB_OGAM_RAMB_LUT
};
enum dwb_color_volume {
DWB_SRGB_BT709 = 0, //SDR
DWB_PQ = 1, //HDR
DWB_HLG = 2, //HDR
};
enum dwb_color_space {
DWB_SRGB = 0, //SDR
DWB_BT709 = 1, //SDR
DWB_BT2020 = 2, //HDR
};
struct dwb_efc_hdr_metadata {
/*display chromaticities and white point in units of 0.00001 */
unsigned int chromaticity_green_x;
unsigned int chromaticity_green_y;
unsigned int chromaticity_blue_x;
unsigned int chromaticity_blue_y;
unsigned int chromaticity_red_x;
unsigned int chromaticity_red_y;
unsigned int chromaticity_white_point_x;
unsigned int chromaticity_white_point_y;
/*in units of candelas per square meter */
unsigned int min_luminance;
unsigned int max_luminance;
/*in units of nits */
unsigned int maximum_content_light_level;
unsigned int maximum_frame_average_light_level;
};
struct dwb_efc_display_settings {
unsigned int inputColorVolume;
unsigned int inputColorSpace;
unsigned int inputBitDepthMinus8;
struct dwb_efc_hdr_metadata hdr_metadata;
unsigned int dwbOutputBlack; // 0 - Normal, 1 - Output Black
};
struct dwb_warmup_params {
bool warmup_en; /* false: normal mode, true: enable pattern generator */
bool warmup_mode; /* false: 420, true: 444 */
bool warmup_depth; /* false: 8bit, true: 10bit */
int warmup_data; /* Data to be sent by pattern generator (same for each pixel component) */
int warmup_width; /* Pattern width (pixels) */
int warmup_height; /* Pattern height (lines) */
};
struct dwb_caps {
enum dce_version hw_version; /* DCN engine version. */
enum dwb_sw_version sw_version; /* DWB sw implementation version. */
unsigned int reserved[6]; /* Reserved for future use, MUST BE 0. */
unsigned int adapter_id;
unsigned int num_pipes; /* number of DWB pipes */
struct {
unsigned int support_dwb :1;
unsigned int support_ogam :1;
unsigned int support_wbscl :1;
unsigned int support_ocsc :1;
unsigned int support_stereo :1;
unsigned int support_4k_120p :1;
} caps;
unsigned int reserved2[10]; /* Reserved for future use, MUST BE 0. */
};
struct dwbc {
const struct dwbc_funcs *funcs;
struct dc_context *ctx;
int inst;
struct mcif_wb *mcif;
bool status;
int inputSrcSelect;
bool dwb_output_black;
enum dc_transfer_func_predefined tf;
enum dc_color_space output_color_space;
bool dwb_is_efc_transition;
bool dwb_is_drc;
int wb_src_plane_inst;/*hubp, mpcc, inst*/
uint32_t mask_id;
int otg_inst;
bool mvc_cfg;
struct dc_dwb_params params;
};
struct dwbc_funcs {
bool (*get_caps)(
struct dwbc *dwbc,
struct dwb_caps *caps);
bool (*enable)(
struct dwbc *dwbc,
struct dc_dwb_params *params);
bool (*disable)(struct dwbc *dwbc);
bool (*update)(
struct dwbc *dwbc,
struct dc_dwb_params *params);
bool (*is_enabled)(
struct dwbc *dwbc);
void (*set_fc_enable)(
struct dwbc *dwbc,
enum dwb_frame_capture_enable enable);
void (*dwb_set_scaler)(
struct dwbc *dwbc,
struct dc_dwb_params *params);
void (*set_stereo)(
struct dwbc *dwbc,
struct dwb_stereo_params *stereo_params);
void (*set_new_content)(
struct dwbc *dwbc,
bool is_new_content);
void (*set_warmup)(
struct dwbc *dwbc,
struct dwb_warmup_params *warmup_params);
bool (*dwb_get_mcifbuf_line)(
struct dwbc *dwbc, unsigned int *buf_idx,
unsigned int *cur_line,
unsigned int *over_run);
#if defined(CONFIG_DRM_AMD_DC_FP)
void (*dwb_program_output_csc)(
struct dwbc *dwbc,
enum dc_color_space color_space,
enum dwb_output_csc_mode mode);
bool (*dwb_ogam_set_output_transfer_func)(
struct dwbc *dwbc,
const struct dc_transfer_func *in_transfer_func_dwb_ogam);
#endif
//TODO: merge with output_transfer_func?
bool (*dwb_ogam_set_input_transfer_func)(
struct dwbc *dwbc,
const struct dc_transfer_func *in_transfer_func_dwb_ogam);
void (*get_drr_time_stamp)(
struct dwbc *dwbc, uint32_t *time_stamp);
bool (*get_dwb_status)(
struct dwbc *dwbc);
};
#endif
@@ -0,0 +1,96 @@
/*
* Copyright 2012-16 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_GPIO_H__
#define __DAL_GPIO_H__
#include "gpio_types.h"
union gpio_hw_container {
struct hw_ddc *ddc;
struct hw_generic *generic;
struct hw_hpd *hpd;
};
struct gpio {
struct gpio_service *service;
struct hw_gpio_pin *pin;
enum gpio_id id;
uint32_t en;
union gpio_hw_container hw_container;
enum gpio_mode mode;
/* when GPIO comes from VBIOS, it has defined output state */
enum gpio_pin_output_state output_state;
};
#if 0
struct gpio_funcs {
struct hw_gpio_pin *(*create_ddc_data)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_ddc_clock)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_generic)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_hpd)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_gpio_pad)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_sync)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
struct hw_gpio_pin *(*create_gsl)(
struct dc_context *ctx,
enum gpio_id id,
uint32_t en);
/* HW translation */
bool (*offset_to_id)(
uint32_t offset,
uint32_t mask,
enum gpio_id *id,
uint32_t *en);
bool (*id_to_offset)(
enum gpio_id id,
uint32_t en,
struct gpio_pin_info *info);
};
#endif
#endif /* __DAL_GPIO__ */
@@ -0,0 +1,315 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_HUBP_H__
#define __DAL_HUBP_H__
/**
* DOC: overview
*
* Display Controller Hub (DCHUB) is the gateway between the Scalable Data Port
* (SDP) and DCN. This component has multiple features, such as memory
* arbitration, rotation, and cursor manipulation.
*
* There is one HUBP allocated per pipe, which fetches data and converts
* different pixel formats (i.e. ARGB8888, NV12, etc) into linear, interleaved
* and fixed-depth streams of pixel data.
*/
#include "mem_input.h"
#include "cursor_reg_cache.h"
#include "dml2_0/dml21/inc/dml_top_dchub_registers.h"
#include "dml2_0/dml21/inc/dml_top_types.h"
#define OPP_ID_INVALID 0xf
#define MAX_TTU 0xffffff
enum cursor_pitch {
CURSOR_PITCH_64_PIXELS = 0,
CURSOR_PITCH_128_PIXELS,
CURSOR_PITCH_256_PIXELS
};
enum cursor_lines_per_chunk {
CURSOR_LINE_PER_CHUNK_1 = 0, /* new for DCN2 */
CURSOR_LINE_PER_CHUNK_2 = 1,
CURSOR_LINE_PER_CHUNK_4,
CURSOR_LINE_PER_CHUNK_8,
CURSOR_LINE_PER_CHUNK_16
};
enum hubp_ind_block_size {
hubp_ind_block_unconstrained = 0,
hubp_ind_block_64b,
hubp_ind_block_128b,
hubp_ind_block_64b_no_128bcl,
};
enum hubp_3dlut_fl_mode {
hubp_3dlut_fl_mode_disable = 0,
hubp_3dlut_fl_mode_native_1 = 1,
hubp_3dlut_fl_mode_native_2 = 2,
hubp_3dlut_fl_mode_transform = 3
};
enum hubp_3dlut_fl_format {
hubp_3dlut_fl_format_unorm_12msb_bitslice = 0,
hubp_3dlut_fl_format_unorm_12lsb_bitslice = 1,
hubp_3dlut_fl_format_float_fp1_5_10 = 2
};
enum hubp_3dlut_fl_addressing_mode {
hubp_3dlut_fl_addressing_mode_sw_linear = 0,
hubp_3dlut_fl_addressing_mode_simple_linear = 1
};
enum hubp_3dlut_fl_width {
hubp_3dlut_fl_width_17 = 17,
hubp_3dlut_fl_width_33 = 33,
hubp_3dlut_fl_width_transformed = 4916, //mpc default
};
enum hubp_3dlut_fl_crossbar_bit_slice {
hubp_3dlut_fl_crossbar_bit_slice_0_15 = 0,
hubp_3dlut_fl_crossbar_bit_slice_16_31 = 1,
hubp_3dlut_fl_crossbar_bit_slice_32_47 = 2,
hubp_3dlut_fl_crossbar_bit_slice_48_63 = 3
};
struct hubp_fl_3dlut_config {
bool enabled;
enum hubp_3dlut_fl_width width;
enum hubp_3dlut_fl_mode mode;
enum hubp_3dlut_fl_format format;
uint16_t bias;
uint16_t scale;
struct dc_plane_address address;
enum hubp_3dlut_fl_addressing_mode addr_mode;
enum dc_cm2_gpu_mem_layout layout;
uint8_t protection_bits;
enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_y_g;
enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cb_b;
enum hubp_3dlut_fl_crossbar_bit_slice crossbar_bit_slice_cr_r;
};
struct hubp {
const struct hubp_funcs *funcs;
struct dc_context *ctx;
struct dc_plane_address request_address;
int inst;
/* run time states */
int opp_id;
int mpcc_id;
struct dc_cursor_attributes curs_attr;
struct dc_cursor_position curs_pos;
bool cursor_offload;
bool power_gated;
struct cursor_position_cache_hubp pos;
struct cursor_attribute_cache_hubp att;
struct cursor_rect cur_rect;
bool use_mall_for_cursor;
};
struct surface_flip_registers {
uint32_t DCSURF_SURFACE_CONTROL;
uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH;
uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS;
uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH;
uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS;
uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_HIGH_C;
uint32_t DCSURF_PRIMARY_META_SURFACE_ADDRESS_C;
uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_HIGH_C;
uint32_t DCSURF_PRIMARY_SURFACE_ADDRESS_C;
uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS_HIGH;
uint32_t DCSURF_SECONDARY_META_SURFACE_ADDRESS;
uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS_HIGH;
uint32_t DCSURF_SECONDARY_SURFACE_ADDRESS;
uint8_t tmz_surface;
bool immediate;
uint8_t vmid;
bool grph_stereo;
};
struct hubp_funcs {
void (*hubp_setup)(
struct hubp *hubp,
struct _vcs_dpi_display_dlg_regs_st *dlg_regs,
struct _vcs_dpi_display_ttu_regs_st *ttu_regs,
struct _vcs_dpi_display_rq_regs_st *rq_regs,
struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest);
void (*hubp_setup2)(
struct hubp *hubp,
struct dml2_dchub_per_pipe_register_set *pipe_regs,
union dml2_global_sync_programming *pipe_global_sync,
struct dc_crtc_timing *timing);
void (*hubp_setup_interdependent)(
struct hubp *hubp,
struct _vcs_dpi_display_dlg_regs_st *dlg_regs,
struct _vcs_dpi_display_ttu_regs_st *ttu_regs);
void (*hubp_setup_interdependent2)(
struct hubp *hubp,
struct dml2_dchub_per_pipe_register_set *pipe_regs);
void (*dcc_control)(struct hubp *hubp, bool enable,
enum hubp_ind_block_size blk_size);
void (*hubp_reset)(struct hubp *hubp);
void (*mem_program_viewport)(
struct hubp *hubp,
const struct rect *viewport,
const struct rect *viewport_c);
bool (*hubp_program_surface_flip_and_addr)(
struct hubp *hubp,
const struct dc_plane_address *address,
bool flip_immediate);
void (*hubp_program_pte_vm)(
struct hubp *hubp,
enum surface_pixel_format format,
struct dc_tiling_info *tiling_info,
enum dc_rotation_angle rotation);
void (*hubp_set_vm_system_aperture_settings)(
struct hubp *hubp,
struct vm_system_aperture_param *apt);
void (*hubp_set_vm_context0_settings)(
struct hubp *hubp,
const struct vm_context0_param *vm0);
void (*hubp_program_surface_config)(
struct hubp *hubp,
enum surface_pixel_format format,
struct dc_tiling_info *tiling_info,
struct plane_size *plane_size,
enum dc_rotation_angle rotation,
struct dc_plane_dcc_param *dcc,
bool horizontal_mirror,
unsigned int compa_level);
bool (*hubp_is_flip_pending)(struct hubp *hubp);
void (*set_blank)(struct hubp *hubp, bool blank);
void (*set_blank_regs)(struct hubp *hubp, bool blank);
void (*phantom_hubp_post_enable)(struct hubp *hubp);
void (*set_hubp_blank_en)(struct hubp *hubp, bool blank);
void (*set_cursor_attributes)(
struct hubp *hubp,
const struct dc_cursor_attributes *attr);
void (*set_cursor_position)(
struct hubp *hubp,
const struct dc_cursor_position *pos,
const struct dc_cursor_mi_param *param);
void (*hubp_disconnect)(struct hubp *hubp);
void (*hubp_clk_cntl)(struct hubp *hubp, bool enable);
void (*hubp_vtg_sel)(struct hubp *hubp, uint32_t otg_inst);
void (*hubp_read_state)(struct hubp *hubp);
void (*hubp_read_reg_state)(struct hubp *hubp, struct dcn_hubp_reg_state *reg_state);
void (*hubp_clear_underflow)(struct hubp *hubp);
void (*hubp_disable_control)(struct hubp *hubp, bool disable_hubp);
unsigned int (*hubp_get_underflow_status)(struct hubp *hubp);
void (*hubp_init)(struct hubp *hubp);
void (*dmdata_set_attributes)(
struct hubp *hubp,
const struct dc_dmdata_attributes *attr);
void (*dmdata_load)(
struct hubp *hubp,
uint32_t dmdata_sw_size,
const uint32_t *dmdata_sw_data);
bool (*dmdata_status_done)(struct hubp *hubp);
void (*hubp_enable_tripleBuffer)(
struct hubp *hubp,
bool enable);
bool (*hubp_is_triplebuffer_enabled)(
struct hubp *hubp);
void (*hubp_set_flip_control_surface_gsl)(
struct hubp *hubp,
bool enable);
void (*validate_dml_output)(
struct hubp *hubp,
struct dc_context *ctx,
struct _vcs_dpi_display_rq_regs_st *dml_rq_regs,
struct _vcs_dpi_display_dlg_regs_st *dml_dlg_attr,
struct _vcs_dpi_display_ttu_regs_st *dml_ttu_attr);
void (*set_unbounded_requesting)(
struct hubp *hubp,
bool enable);
bool (*hubp_in_blank)(struct hubp *hubp);
void (*hubp_soft_reset)(struct hubp *hubp, bool reset);
void (*hubp_set_flip_int)(struct hubp *hubp);
void (*hubp_update_force_pstate_disallow)(struct hubp *hubp, bool allow);
void (*hubp_update_force_cursor_pstate_disallow)(struct hubp *hubp, bool allow);
void (*hubp_update_mall_sel)(struct hubp *hubp, uint32_t mall_sel, bool c_cursor);
void (*hubp_prepare_subvp_buffering)(struct hubp *hubp, bool enable);
void (*hubp_surface_update_lock)(struct hubp *hubp,
bool lock);
void (*program_extended_blank)(struct hubp *hubp,
unsigned int min_dst_y_next_start_optimized);
void (*hubp_wait_pipe_read_start)(struct hubp *hubp);
void (*hubp_program_mcache_id_and_split_coordinate)(struct hubp *hubp, struct dml2_hubp_pipe_mcache_regs *mcache_regs);
void (*hubp_update_3dlut_fl_bias_scale)(struct hubp *hubp, uint16_t bias, uint16_t scale);
void (*hubp_program_3dlut_fl_mode)(struct hubp *hubp,
enum hubp_3dlut_fl_mode mode);
void (*hubp_program_3dlut_fl_format)(struct hubp *hubp,
enum hubp_3dlut_fl_format format);
void (*hubp_program_3dlut_fl_addr)(struct hubp *hubp,
const struct dc_plane_address address);
void (*hubp_program_3dlut_fl_dlg_param)(struct hubp *hubp, int refcyc_per_3dlut_group);
void (*hubp_enable_3dlut_fl)(struct hubp *hubp, bool enable);
void (*hubp_program_3dlut_fl_addressing_mode)(struct hubp *hubp, enum hubp_3dlut_fl_addressing_mode addr_mode);
void (*hubp_program_3dlut_fl_width)(struct hubp *hubp, enum hubp_3dlut_fl_width width);
void (*hubp_program_3dlut_fl_tmz_protected)(struct hubp *hubp, uint8_t protection_bits);
void (*hubp_program_3dlut_fl_crossbar)(struct hubp *hubp,
enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_y_g,
enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cb_b,
enum hubp_3dlut_fl_crossbar_bit_slice bit_slice_cr_r);
uint32_t (*hubp_get_3dlut_fl_done)(struct hubp *hubp);
void (*hubp_program_3dlut_fl_config)(struct hubp *hubp, struct hubp_fl_3dlut_config *cfg);
void (*hubp_clear_tiling)(struct hubp *hubp);
uint32_t (*hubp_get_current_read_line)(struct hubp *hubp);
uint32_t (*hubp_get_det_config_error)(struct hubp *hubp);
};
#endif
@@ -0,0 +1,436 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_HW_SHARED_H__
#define __DAL_HW_SHARED_H__
#include "os_types.h"
#include "fixed31_32.h"
#include "dc_hw_types.h"
/******************************************************************************
* Data types shared between different Virtual HW blocks
******************************************************************************/
#define MAX_AUDIOS 7
/**
* @MAX_PIPES:
*
* Every ASIC support a fixed number of pipes; MAX_PIPES defines a large number
* to be used inside loops and for determining array sizes.
*/
#define MAX_PIPES 6
#define MAX_PHANTOM_PIPES (MAX_PIPES / 2)
#define MAX_DPIA 6
#define MAX_CONNECTOR 6
#define MAX_VIRTUAL_LINKS 4
#define MAX_LINKS (MAX_DPIA + MAX_CONNECTOR + MAX_VIRTUAL_LINKS)
/**
* define MAX_DIG_LINK_ENCODERS - maximum number of digital encoders
*
* Digital encoders are ENGINE_ID_DIGA...G, there are at most 7,
* although not every GPU may have that many.
*/
#define MAX_DIG_LINK_ENCODERS 7
/**
* define MAX_DAC_LINK_ENCODERS - maximum number of analog link encoders
*
* Analog encoders are ENGINE_ID_DACA/B, there are at most 2,
* although not every GPU may have that many. Modern GPUs typically
* don't have analog encoders.
*/
#define MAX_DAC_LINK_ENCODERS 2
/**
* define MAX_LINK_ENCODERS - maximum number link encoders in total
*
* This includes both analog and digital encoders.
*/
#define MAX_LINK_ENCODERS (MAX_DIG_LINK_ENCODERS + MAX_DAC_LINK_ENCODERS)
#define MAX_DWB_PIPES 1
#define MAX_HDMI_FRL_ENCODERS 2
#define MAX_HPO_DP2_ENCODERS 4
#define MAX_HPO_DP2_LINK_ENCODERS 4
/* Pipe topology snapshot structures */
#define MAX_TOPOLOGY_SNAPSHOTS 4
struct pipe_topology_line {
bool is_phantom_pipe;
int plane_idx;
int slice_idx;
int stream_idx;
int dpp_inst;
int opp_inst;
int tg_inst;
};
struct pipe_topology_snapshot {
struct pipe_topology_line pipe_log_lines[MAX_PIPES];
int line_count;
uint64_t timestamp_us;
int stream_count;
int phantom_stream_count;
};
struct pipe_topology_history {
struct pipe_topology_snapshot snapshots[MAX_TOPOLOGY_SNAPSHOTS];
int current_snapshot_index;
};
struct gamma_curve {
uint32_t offset;
uint32_t segments_num;
};
struct curve_points {
struct fixed31_32 x;
struct fixed31_32 y;
struct fixed31_32 offset;
struct fixed31_32 slope;
uint32_t custom_float_x;
uint32_t custom_float_y;
uint32_t custom_float_offset;
uint32_t custom_float_slope;
};
struct curve_points3 {
struct curve_points red;
struct curve_points green;
struct curve_points blue;
};
struct pwl_result_data {
struct fixed31_32 red;
struct fixed31_32 green;
struct fixed31_32 blue;
struct fixed31_32 delta_red;
struct fixed31_32 delta_green;
struct fixed31_32 delta_blue;
uint32_t red_reg;
uint32_t green_reg;
uint32_t blue_reg;
uint32_t delta_red_reg;
uint32_t delta_green_reg;
uint32_t delta_blue_reg;
};
struct dc_rgb {
uint32_t red;
uint32_t green;
uint32_t blue;
};
struct tetrahedral_33x33x33 {
struct dc_rgb lut0[8985];
struct dc_rgb lut1[8984];
struct dc_rgb lut2[8984];
struct dc_rgb lut3[8984];
};
struct tetrahedral_17x17x17 {
struct dc_rgb lut0[1229];
struct dc_rgb lut1[1228];
struct dc_rgb lut2[1228];
struct dc_rgb lut3[1228];
};
struct tetrahedral_9x9x9 {
struct dc_rgb lut0[183];
struct dc_rgb lut1[182];
struct dc_rgb lut2[182];
struct dc_rgb lut3[182];
};
enum lut_dimension {
LUT_DIM_INVALID = 0,
LUT_DIM_9 = 9,
LUT_DIM_17 = 17,
LUT_DIM_33 = 33,
};
struct tetrahedral_params {
union {
//TODO: Uncomment when in use.
// struct tetrahedral_33x33x33 tetrahedral_33;
struct tetrahedral_17x17x17 tetrahedral_17;
struct tetrahedral_9x9x9 tetrahedral_9;
};
bool use_tetrahedral_9;
bool use_12bits;
enum lut_dimension lut_dim;
};
/* arr_curve_points - regamma regions/segments specification
* arr_points - beginning and end point specified separately (only one on DCE)
* corner_points - beginning and end point for all 3 colors (DCN)
* rgb_resulted - final curve
*/
struct pwl_params {
struct gamma_curve arr_curve_points[34];
union {
struct curve_points arr_points[2];
struct curve_points3 corner_points[2];
};
struct pwl_result_data rgb_resulted[256 + 3];
uint32_t hw_points_num;
};
/* move to dpp
* while we are moving functionality out of opp to dpp to align
* HW programming to HW IP, we define these struct in hw_shared
* so we can still compile while refactoring
*/
enum lb_pixel_depth {
/* do not change the values because it is used as bit vector */
LB_PIXEL_DEPTH_18BPP = 1,
LB_PIXEL_DEPTH_24BPP = 2,
LB_PIXEL_DEPTH_30BPP = 4,
LB_PIXEL_DEPTH_36BPP = 8
};
enum graphics_csc_adjust_type {
GRAPHICS_CSC_ADJUST_TYPE_BYPASS = 0,
GRAPHICS_CSC_ADJUST_TYPE_HW, /* without adjustments */
GRAPHICS_CSC_ADJUST_TYPE_SW /*use adjustments */
};
enum ipp_degamma_mode {
IPP_DEGAMMA_MODE_BYPASS,
IPP_DEGAMMA_MODE_HW_sRGB,
IPP_DEGAMMA_MODE_HW_xvYCC,
IPP_DEGAMMA_MODE_USER_PWL
};
enum gamcor_mode {
GAMCOR_MODE_BYPASS,
GAMCOR_MODE_RESERVED_1,
GAMCOR_MODE_USER_PWL,
GAMCOR_MODE_RESERVED_3
};
enum ipp_output_format {
IPP_OUTPUT_FORMAT_12_BIT_FIX,
IPP_OUTPUT_FORMAT_16_BIT_BYPASS,
IPP_OUTPUT_FORMAT_FLOAT
};
enum expansion_mode {
EXPANSION_MODE_DYNAMIC,
EXPANSION_MODE_ZERO
};
struct default_adjustment {
enum lb_pixel_depth lb_color_depth;
enum dc_color_space out_color_space;
enum dc_color_space in_color_space;
enum dc_color_depth color_depth;
enum dc_pixel_format surface_pixel_format;
enum graphics_csc_adjust_type csc_adjust_type;
bool force_hw_default;
};
struct out_csc_color_matrix {
enum dc_color_space color_space;
uint16_t regval[12];
};
enum gamut_remap_select {
GAMUT_REMAP_BYPASS = 0,
GAMUT_REMAP_COEFF,
GAMUT_REMAP_COMA_COEFF,
GAMUT_REMAP_COMB_COEFF
};
enum opp_regamma {
OPP_REGAMMA_BYPASS = 0,
OPP_REGAMMA_SRGB,
OPP_REGAMMA_XVYCC,
OPP_REGAMMA_USER
};
enum optc_dsc_mode {
OPTC_DSC_DISABLED = 0,
OPTC_DSC_ENABLED_444 = 1, /* 'RGB 444' or 'Simple YCbCr 4:2:2' (4:2:2 upsampled to 4:4:4) */
OPTC_DSC_ENABLED_NATIVE_SUBSAMPLED = 2 /* Native 4:2:2 or 4:2:0 */
};
struct dc_bias_and_scale {
uint32_t scale_red;
uint32_t bias_red;
uint32_t scale_green;
uint32_t bias_green;
uint32_t scale_blue;
uint32_t bias_blue;
bool bias_and_scale_valid;
};
enum test_pattern_dyn_range {
TEST_PATTERN_DYN_RANGE_VESA = 0,
TEST_PATTERN_DYN_RANGE_CEA
};
enum test_pattern_mode {
TEST_PATTERN_MODE_COLORSQUARES_RGB = 0,
TEST_PATTERN_MODE_COLORSQUARES_YCBCR601,
TEST_PATTERN_MODE_COLORSQUARES_YCBCR709,
TEST_PATTERN_MODE_VERTICALBARS,
TEST_PATTERN_MODE_HORIZONTALBARS,
TEST_PATTERN_MODE_SINGLERAMP_RGB,
TEST_PATTERN_MODE_DUALRAMP_RGB,
TEST_PATTERN_MODE_XR_BIAS_RGB
};
enum test_pattern_color_format {
TEST_PATTERN_COLOR_FORMAT_BPC_6 = 0,
TEST_PATTERN_COLOR_FORMAT_BPC_8,
TEST_PATTERN_COLOR_FORMAT_BPC_10,
TEST_PATTERN_COLOR_FORMAT_BPC_12
};
enum controller_dp_test_pattern {
CONTROLLER_DP_TEST_PATTERN_D102 = 0,
CONTROLLER_DP_TEST_PATTERN_SYMBOLERROR,
CONTROLLER_DP_TEST_PATTERN_PRBS7,
CONTROLLER_DP_TEST_PATTERN_COLORSQUARES,
CONTROLLER_DP_TEST_PATTERN_VERTICALBARS,
CONTROLLER_DP_TEST_PATTERN_HORIZONTALBARS,
CONTROLLER_DP_TEST_PATTERN_COLORRAMP,
CONTROLLER_DP_TEST_PATTERN_VIDEOMODE,
CONTROLLER_DP_TEST_PATTERN_RESERVED_8,
CONTROLLER_DP_TEST_PATTERN_RESERVED_9,
CONTROLLER_DP_TEST_PATTERN_RESERVED_A,
CONTROLLER_DP_TEST_PATTERN_COLORSQUARES_CEA,
CONTROLLER_DP_TEST_PATTERN_SOLID_COLOR
};
enum controller_dp_color_space {
CONTROLLER_DP_COLOR_SPACE_RGB,
CONTROLLER_DP_COLOR_SPACE_YCBCR601,
CONTROLLER_DP_COLOR_SPACE_YCBCR709,
CONTROLLER_DP_COLOR_SPACE_UDEFINED
};
enum dc_lut_mode {
LUT_BYPASS,
LUT_RAM_A,
LUT_RAM_B
};
/**
* speakersToChannels
*
* @brief
* translate speakers to channels
*
* FL - Front Left
* FR - Front Right
* RL - Rear Left
* RR - Rear Right
* RC - Rear Center
* FC - Front Center
* FLC - Front Left Center
* FRC - Front Right Center
* RLC - Rear Left Center
* RRC - Rear Right Center
* LFE - Low Freq Effect
*
* FC
* FLC FRC
* FL FR
*
* LFE
* ()
*
*
* RL RR
* RLC RRC
* RC
*
* ch 8 7 6 5 4 3 2 1
* 0b00000011 - - - - - - FR FL
* 0b00000111 - - - - - LFE FR FL
* 0b00001011 - - - - FC - FR FL
* 0b00001111 - - - - FC LFE FR FL
* 0b00010011 - - - RC - - FR FL
* 0b00010111 - - - RC - LFE FR FL
* 0b00011011 - - - RC FC - FR FL
* 0b00011111 - - - RC FC LFE FR FL
* 0b00110011 - - RR RL - - FR FL
* 0b00110111 - - RR RL - LFE FR FL
* 0b00111011 - - RR RL FC - FR FL
* 0b00111111 - - RR RL FC LFE FR FL
* 0b01110011 - RC RR RL - - FR FL
* 0b01110111 - RC RR RL - LFE FR FL
* 0b01111011 - RC RR RL FC - FR FL
* 0b01111111 - RC RR RL FC LFE FR FL
* 0b11110011 RRC RLC RR RL - - FR FL
* 0b11110111 RRC RLC RR RL - LFE FR FL
* 0b11111011 RRC RLC RR RL FC - FR FL
* 0b11111111 RRC RLC RR RL FC LFE FR FL
* 0b11000011 FRC FLC - - - - FR FL
* 0b11000111 FRC FLC - - - LFE FR FL
* 0b11001011 FRC FLC - - FC - FR FL
* 0b11001111 FRC FLC - - FC LFE FR FL
* 0b11010011 FRC FLC - RC - - FR FL
* 0b11010111 FRC FLC - RC - LFE FR FL
* 0b11011011 FRC FLC - RC FC - FR FL
* 0b11011111 FRC FLC - RC FC LFE FR FL
* 0b11110011 FRC FLC RR RL - - FR FL
* 0b11110111 FRC FLC RR RL - LFE FR FL
* 0b11111011 FRC FLC RR RL FC - FR FL
* 0b11111111 FRC FLC RR RL FC LFE FR FL
*
* @param
* speakers - speaker information as it comes from CEA audio block
*/
/* translate speakers to channels */
union audio_cea_channels {
uint8_t all;
struct audio_cea_channels_bits {
uint32_t FL:1;
uint32_t FR:1;
uint32_t LFE:1;
uint32_t FC:1;
uint32_t RL_RC:1;
uint32_t RR:1;
uint32_t RC_RLC_FLC:1;
uint32_t RRC_FRC:1;
} channels;
};
#endif /* __DAL_HW_SHARED_H__ */
@@ -0,0 +1,114 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_IPP_H__
#define __DAL_IPP_H__
#include "hw_shared.h"
#include "dc_hw_types.h"
#define MAXTRIX_COEFFICIENTS_NUMBER 12
#define MAXTRIX_COEFFICIENTS_WRAP_NUMBER (MAXTRIX_COEFFICIENTS_NUMBER + 4)
#define MAX_OVL_MATRIX_COUNT 12
/* IPP RELATED */
struct input_pixel_processor {
struct dc_context *ctx;
unsigned int inst;
const struct ipp_funcs *funcs;
};
enum ipp_prescale_mode {
IPP_PRESCALE_MODE_BYPASS,
IPP_PRESCALE_MODE_FIXED_SIGNED,
IPP_PRESCALE_MODE_FLOAT_SIGNED,
IPP_PRESCALE_MODE_FIXED_UNSIGNED,
IPP_PRESCALE_MODE_FLOAT_UNSIGNED
};
struct ipp_prescale_params {
enum ipp_prescale_mode mode;
uint16_t bias;
uint16_t scale;
};
enum ovl_color_space {
OVL_COLOR_SPACE_UNKNOWN = 0,
OVL_COLOR_SPACE_RGB,
OVL_COLOR_SPACE_YUV601,
OVL_COLOR_SPACE_YUV709
};
struct ipp_funcs {
/*** cursor ***/
void (*ipp_cursor_set_position)(
struct input_pixel_processor *ipp,
const struct dc_cursor_position *position,
const struct dc_cursor_mi_param *param);
void (*ipp_cursor_set_attributes)(
struct input_pixel_processor *ipp,
const struct dc_cursor_attributes *attributes);
/*** setup input pixel processing ***/
/* put the entire pixel processor to bypass */
void (*ipp_full_bypass)(
struct input_pixel_processor *ipp);
/* setup ipp to expand/convert input to pixel processor internal format */
void (*ipp_setup)(
struct input_pixel_processor *ipp,
enum surface_pixel_format format,
enum expansion_mode mode,
struct dc_csc_transform input_csc_color_matrix,
enum dc_color_space input_color_space);
/* DCE function to setup IPP. TODO: see if we can consolidate to setup */
void (*ipp_program_prescale)(
struct input_pixel_processor *ipp,
struct ipp_prescale_params *params);
void (*ipp_program_input_lut)(
struct input_pixel_processor *ipp,
const struct dc_gamma *gamma);
/*** DEGAMMA RELATED ***/
void (*ipp_set_degamma)(
struct input_pixel_processor *ipp,
enum ipp_degamma_mode mode);
void (*ipp_program_degamma_pwl)(
struct input_pixel_processor *ipp,
const struct pwl_params *params);
void (*ipp_destroy)(struct input_pixel_processor **ipp);
};
#endif /* __DAL_IPP_H__ */
@@ -0,0 +1,472 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* link_encoder.h
*
* Created on: Oct 6, 2015
* Author: yonsun
*/
#ifndef LINK_ENCODER_H_
#define LINK_ENCODER_H_
#include "grph_object_defs.h"
#include "signal_types.h"
#include "dc_types.h"
struct dc_context;
struct encoder_set_dp_phy_pattern_param;
struct link_mst_stream_allocation_table;
struct dc_link_settings;
struct link_training_settings;
struct pipe_ctx;
struct encoder_init_data {
enum channel_id channel;
struct graphics_object_id connector;
struct gpio *hpd_gpio;
enum hpd_source_id hpd_source;
/* TODO: in DAL2, here was pointer to EventManagerInterface */
struct graphics_object_id encoder;
struct graphics_object_id analog_encoder;
enum engine_id analog_engine;
struct dc_context *ctx;
enum transmitter transmitter;
};
struct encoder_feature_support {
union {
struct {
uint32_t IS_HBR2_CAPABLE:1;
uint32_t IS_HBR3_CAPABLE:1;
uint32_t IS_TPS3_CAPABLE:1;
uint32_t IS_TPS4_CAPABLE:1;
uint32_t HDMI_6GB_EN:1;
uint32_t IS_DP2_CAPABLE:1;
uint32_t IS_UHBR10_CAPABLE:1;
uint32_t IS_UHBR13_5_CAPABLE:1;
uint32_t IS_UHBR20_CAPABLE:1;
uint32_t DP_IS_USB_C:1;
uint32_t IS_HDMI_FRL_CAPABLE:1;
uint32_t IS_FRL_8G_CAPABLE:1;
uint32_t IS_FRL_10G_CAPABLE:1;
uint32_t IS_FRL_12G_CAPABLE:1;
uint32_t IS_FRL_16G_CAPABLE:1;
uint32_t IS_FRL_20G_CAPABLE:1;
uint32_t IS_FRL_24G_CAPABLE:1;
} bits;
uint32_t raw;
} flags;
enum dc_color_depth max_hdmi_deep_color;
unsigned int max_hdmi_pixel_clock;
bool hdmi_ycbcr420_supported;
bool dp_ycbcr420_supported;
bool fec_supported;
};
enum phy_source_select {
PHY_SOURCE_DIG,
PHY_SOURCE_HPO
};
struct link_encoder {
const struct link_encoder_funcs *funcs;
int32_t aux_channel_offset;
struct dc_context *ctx;
struct graphics_object_id id;
struct graphics_object_id analog_id;
struct graphics_object_id connector;
uint32_t output_signals;
enum engine_id preferred_engine;
enum engine_id analog_engine;
struct encoder_feature_support features;
enum transmitter transmitter;
struct gpio *hpd_gpio;
enum hpd_source_id hpd_source;
bool usbc_combo_phy;
uint8_t txffe_state;
};
struct link_enc_state {
uint32_t dphy_fec_en;
uint32_t dphy_fec_ready_shadow;
uint32_t dphy_fec_active_status;
uint32_t dp_link_training_complete;
};
struct frl_txffe {
uint32_t amplitude[4];
uint32_t pre_emphasis[4];
uint32_t post_emphasis[4];
};
enum encoder_type_select {
ENCODER_TYPE_DIG = 0,
ENCODER_TYPE_HDMI_FRL = 1,
ENCODER_TYPE_DP_128B132B = 2
};
struct link_encoder_funcs {
void (*read_state)(
struct link_encoder *enc, struct link_enc_state *s);
bool (*validate_output_with_stream)(
struct link_encoder *enc, const struct dc_stream_state *stream);
void (*hw_init)(struct link_encoder *enc);
void (*setup)(struct link_encoder *enc,
enum signal_type signal);
void (*enable_tmds_output)(struct link_encoder *enc,
enum clock_source_id clock_source,
enum dc_color_depth color_depth,
enum signal_type signal,
uint32_t pixel_clock);
void (*enable_dp_output)(struct link_encoder *enc,
const struct dc_link_settings *link_settings,
enum clock_source_id clock_source);
void (*enable_dp_mst_output)(struct link_encoder *enc,
const struct dc_link_settings *link_settings,
enum clock_source_id clock_source);
void (*enable_lvds_output)(struct link_encoder *enc,
enum clock_source_id clock_source,
uint32_t pixel_clock);
void (*enable_analog_output)(struct link_encoder *enc,
uint32_t pixel_clock);
void (*disable_output)(struct link_encoder *link_enc,
enum signal_type signal);
void (*dp_set_lane_settings)(struct link_encoder *enc,
const struct dc_link_settings *link_settings,
const struct dc_lane_settings lane_settings[LANE_COUNT_DP_MAX]);
void (*dp_set_phy_pattern)(struct link_encoder *enc,
const struct encoder_set_dp_phy_pattern_param *para);
void (*update_mst_stream_allocation_table)(
struct link_encoder *enc,
const struct link_mst_stream_allocation_table *table);
void (*psr_program_dp_dphy_fast_training)(struct link_encoder *enc,
bool exit_link_training_required);
void (*psr_program_secondary_packet)(struct link_encoder *enc,
unsigned int sdp_transmit_line_num_deadline);
void (*connect_dig_be_to_fe)(struct link_encoder *enc,
enum engine_id engine,
bool connect);
void (*enable_hpd)(struct link_encoder *enc);
void (*disable_hpd)(struct link_encoder *enc);
bool (*is_dig_enabled)(struct link_encoder *enc);
unsigned int (*get_dig_frontend)(struct link_encoder *enc);
void (*destroy)(struct link_encoder **enc);
void (*fec_set_enable)(struct link_encoder *enc,
bool enable);
void (*fec_set_ready)(struct link_encoder *enc,
bool ready);
bool (*fec_is_active)(struct link_encoder *enc);
bool (*is_in_alt_mode) (struct link_encoder *enc);
void (*get_max_link_cap)(struct link_encoder *enc,
struct dc_link_settings *link_settings);
enum signal_type (*get_dig_mode)(
struct link_encoder *enc);
void (*dpcstx_set_order_invert_18_bit)(
struct link_encoder *enc,
bool invert);
void (*set_phy_source)(
struct link_encoder *enc,
enum phy_source_select src_sel,
uint32_t hpo_inst);
void (*dpcs_initialize_phy)(
struct link_encoder *enc,
uint32_t hpo_inst,
enum hdmi_frl_link_rate frl_link_rate);
void (*dpcs_configure_phypll)(
struct link_encoder *enc,
uint32_t hpo_inst,
enum hdmi_frl_link_rate frl_link_rate);
void (*dpcs_configure_dpcs)(
struct link_encoder *enc);
void (*dpcs_enable_dpcs)(
struct link_encoder *enc);
void (*prog_eq_setting)(
struct link_encoder *enc,
uint8_t FFE_Level,
bool de_emphasis_only,
bool pre_shoot_only,
bool no_ffe,
const struct dc_hdmi_frl_link_settings *link_settings);
void (*get_txffe)(
struct link_encoder *enc,
struct frl_txffe *lane_settings);
void (*set_txffe)(
struct link_encoder *enc,
struct frl_txffe *lane_settings);
void (*set_dio_phy_mux)(
struct link_encoder *enc,
enum encoder_type_select sel,
uint32_t hpo_inst);
void (*enable_dpia_output)(struct link_encoder *enc,
const struct dc_link_settings *link_settings,
uint8_t dpia_id,
uint8_t digmode,
uint8_t fec_rdy);
void (*disable_dpia_output)(struct link_encoder *link_enc,
uint8_t dpia_id,
uint8_t digmode);
bool (*get_hpd_state)(struct link_encoder *enc);
bool (*program_hpd_filter)(struct link_encoder *enc, int delay_on_connect_in_ms, int delay_on_disconnect_in_ms);
};
/*
* Used to track assignments of links (display endpoints) to link encoders.
*
* Entry in link_enc_assignments table in struct resource_context.
* Entries only marked valid once encoder assigned to a link and invalidated once unassigned.
* Uses engine ID as identifier since PHY ID not relevant for USB4 DPIA endpoint.
*/
struct link_enc_assignment {
bool valid;
struct display_endpoint_id ep_id;
enum engine_id eng_id;
struct dc_stream_state *stream;
};
enum link_enc_cfg_mode {
LINK_ENC_CFG_STEADY, /* Normal operation - use current_state. */
LINK_ENC_CFG_TRANSIENT /* During commit state - use state to be committed. */
};
struct hpo_frl_link_encoder {
const struct hpo_frl_link_encoder_funcs *funcs;
struct dc_context *ctx;
int inst;
};
/**
* @hpo_frl_link_enc_state - FRL data from the device
*
* This struct is used to store FRL information retrieved from the hardware.
* This is used as a parameter for the read_state function.
*/
struct hpo_frl_link_enc_state {
/**
* @link_enc_enabled: 0 means disable and 1 enabled.
*/
uint32_t link_enc_enabled;
/**
* @link_active:
*
* If link training is enable this field should be set to 1.
*/
uint32_t link_active;
/**
* @lane_count: FRL lane count.
*/
uint32_t lane_count;
};
/***
* @hpo_frl_link_encoder_funcs - FRL encoder functions
*
* DC handles FRL as an encoder; each ASIC may have some peculiarities in
* setting FRL. Thus, this struct, adds all the necessary callbacks that each
* DCN version must implement.
*/
struct hpo_frl_link_encoder_funcs {
/**
* @setup_link_encoder:
*
* This function is responsible for setup the ASIC to use FRL, i.e., it
* contains a register configuration. This function implementation
* expects the enablement of the link clock, lane count configuration,
* any reset/cleanup, and, finally, the enablement of the link.
*/
void (*setup_link_encoder)(struct hpo_frl_link_encoder *enc,
int lane_count);
/**
* @disable_link_encoder:
*
* Disable the FRL link. Note that this function must do the reverse of
* the setup_link_encoder.
*/
void (*disable_link_encoder)(struct hpo_frl_link_encoder *enc);
/**
* @set_hdmi_training_pattern:
*
* Register level configuration for each lane.
*/
void (*set_hdmi_training_pattern)(struct hpo_frl_link_encoder *enc,
uint32_t lane0_pattern,
uint32_t lane1_pattern,
uint32_t lane2_pattern,
uint32_t lane3_pattern);
/**
* @get_hdmi_training_pattern:
*
* Retrieve from the registers each of the lane pattern configurations.
*/
void (*get_hdmi_training_pattern)(struct hpo_frl_link_encoder *enc,
uint32_t *lane0_pattern,
uint32_t *lane1_pattern,
uint32_t *lane2_pattern,
uint32_t *lane3_pattern);
/**
* @enable_frl_phy_output:
*
* Based on the parameters, this function should fill out the
* bp_transmitter_control struct and use it to enable the FRL PHY link
* via VBIOS.
*/
void (*enable_frl_phy_output)(struct hpo_frl_link_encoder *hpo_enc,
struct link_encoder *enc,
enum clock_source_id clock_source,
enum hdmi_frl_link_rate frl_link_rate);
/**
* @enable_output:
*
* Enable FRL by sending the enable packet training.
*/
void (*enable_output)(struct hpo_frl_link_encoder *enc);
/**
* @read_state:
*
* Get the FRL information from registers and fill it out in the
* hpo_frl_link_enc_state struct.
*/
void (*read_state)(struct hpo_frl_link_encoder *enc,
struct hpo_frl_link_enc_state *state);
/**
* @destroy:
*
* Destroy encoder object.
*/
void (*destroy)(struct hpo_frl_link_encoder **enc);
void (*apply_vsdb_rcc_wa)(
struct hpo_frl_link_encoder *enc);
};
enum dp2_link_mode {
DP2_LINK_TRAINING_TPS1,
DP2_LINK_TRAINING_TPS2,
DP2_LINK_ACTIVE,
DP2_TEST_PATTERN
};
enum dp2_phy_tp_select {
DP_DPHY_TP_SELECT_TPS1,
DP_DPHY_TP_SELECT_TPS2,
DP_DPHY_TP_SELECT_PRBS,
DP_DPHY_TP_SELECT_CUSTOM,
DP_DPHY_TP_SELECT_SQUARE
};
enum dp2_phy_tp_prbs {
DP_DPHY_TP_PRBS7,
DP_DPHY_TP_PRBS9,
DP_DPHY_TP_PRBS11,
DP_DPHY_TP_PRBS15,
DP_DPHY_TP_PRBS23,
DP_DPHY_TP_PRBS31
};
struct hpo_dp_link_enc_state {
uint32_t link_enc_enabled;
uint32_t link_mode;
uint32_t lane_count;
uint32_t slot_count[4];
uint32_t stream_src[4];
uint32_t vc_rate_x[4];
uint32_t vc_rate_y[4];
};
struct hpo_dp_link_encoder {
const struct hpo_dp_link_encoder_funcs *funcs;
struct dc_context *ctx;
int inst;
enum engine_id preferred_engine;
enum transmitter transmitter;
enum hpd_source_id hpd_source;
};
struct hpo_dp_link_encoder_funcs {
void (*enable_link_phy)(struct hpo_dp_link_encoder *enc,
const struct dc_link_settings *link_settings,
enum transmitter transmitter,
enum hpd_source_id hpd_source);
void (*disable_link_phy)(struct hpo_dp_link_encoder *link_enc,
enum signal_type signal);
void (*link_enable)(
struct hpo_dp_link_encoder *enc,
enum dc_lane_count num_lanes);
void (*link_disable)(
struct hpo_dp_link_encoder *enc);
void (*set_link_test_pattern)(
struct hpo_dp_link_encoder *enc,
struct encoder_set_dp_phy_pattern_param *tp_params);
void (*update_stream_allocation_table)(
struct hpo_dp_link_encoder *enc,
const struct link_mst_stream_allocation_table *table);
void (*set_throttled_vcp_size)(
struct hpo_dp_link_encoder *enc,
uint32_t stream_encoder_inst,
struct fixed31_32 avg_time_slots_per_mtp);
bool (*is_in_alt_mode) (
struct hpo_dp_link_encoder *enc);
void (*read_state)(
struct hpo_dp_link_encoder *enc,
struct hpo_dp_link_enc_state *state);
void (*set_ffe)(
struct hpo_dp_link_encoder *enc,
const struct dc_link_settings *link_settings,
uint8_t ffe_preset);
};
#endif /* LINK_ENCODER_H_ */
@@ -0,0 +1,109 @@
/* Copyright 2012-17 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_MCIF_WB_H__
#define __DC_MCIF_WB_H__
#include "dc_hw_types.h"
enum mmhubbub_wbif_mode {
PACKED_444 = 0,
PACKED_444_FP16 = 1,
PLANAR_420_8BPC = 2,
PLANAR_420_10BPC = 3
};
struct mcif_arb_params {
unsigned int time_per_pixel;
unsigned int cli_watermark[4];
unsigned int pstate_watermark[4];
unsigned int arbitration_slice;
unsigned int slice_lines;
unsigned int max_scaled_time;
unsigned int dram_speed_change_duration;
};
struct mcif_irq_params {
unsigned int sw_int_en;
unsigned int sw_slice_int_en;
unsigned int sw_overrun_int_en;
unsigned int vce_int_en;
unsigned int vce_slice_int_en;
};
/* / - mcif_wb_frame_dump_info is the info of the dumping WB data */
struct mcif_wb_frame_dump_info {
unsigned int size;
unsigned int width;
unsigned int height;
unsigned int luma_pitch;
unsigned int chroma_pitch;
enum dwb_scaler_mode format;
};
struct mcif_wb {
const struct mcif_wb_funcs *funcs;
struct dc_context *ctx;
int inst;
};
struct mcif_wb_funcs {
void (*warmup_mcif)(
struct mcif_wb *mcif_wb,
struct mcif_warmup_params *params);
void (*enable_mcif)(struct mcif_wb *mcif_wb);
void (*disable_mcif)(struct mcif_wb *mcif_wb);
void (*config_mcif_buf)(
struct mcif_wb *mcif_wb,
struct mcif_buf_params *params,
unsigned int dest_height);
void (*config_mcif_arb)(
struct mcif_wb *mcif_wb,
struct mcif_arb_params *params);
void (*config_mcif_irq)(
struct mcif_wb *mcif_wb,
struct mcif_irq_params *params);
void (*dump_frame)(
struct mcif_wb *mcif_wb,
struct mcif_buf_params *mcif_params,
enum dwb_scaler_mode out_format,
unsigned int dest_width,
unsigned int dest_height,
struct mcif_wb_frame_dump_info *dump_info,
unsigned char *luma_buffer,
unsigned char *chroma_buffer,
unsigned char *dest_luma_buffer,
unsigned char *dest_chroma_buffer);
};
#endif
@@ -0,0 +1,194 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_MEM_INPUT_H__
#define __DAL_MEM_INPUT_H__
#include "dc.h"
#include "include/grph_object_id.h"
#include "dml/display_mode_structs.h"
#include "dml2_0/dml21/inc/dml_top_dchub_registers.h"
struct dchub_init_data;
struct cstate_pstate_watermarks_st {
uint32_t cstate_exit_ns;
uint32_t cstate_exit_z8_ns;
uint32_t cstate_enter_plus_exit_z8_ns;
uint32_t cstate_enter_plus_exit_ns;
uint32_t pstate_change_ns;
uint32_t fclk_pstate_change_ns;
};
struct dcn_watermarks {
uint32_t pte_meta_urgent_ns;
uint32_t urgent_ns;
uint32_t frac_urg_bw_nom;
uint32_t frac_urg_bw_flip;
uint32_t urgent_latency_ns;
struct cstate_pstate_watermarks_st cstate_pstate;
uint32_t usr_retraining_ns;
};
union dcn_watermark_set {
struct {
struct dcn_watermarks a;
struct dcn_watermarks b;
struct dcn_watermarks c;
struct dcn_watermarks d;
}; // legacy
struct {
struct dml2_dchub_watermark_regs a;
struct dml2_dchub_watermark_regs b;
struct dml2_dchub_watermark_regs c;
struct dml2_dchub_watermark_regs d;
} dcn4x; //dcn4+
};
struct dce_watermarks {
int a_mark;
int b_mark;
int c_mark;
int d_mark;
};
struct stutter_modes {
bool enhanced;
bool quad_dmif_buffer;
bool watermark_nb_pstate;
};
struct mem_input {
const struct mem_input_funcs *funcs;
struct dc_context *ctx;
struct dc_plane_address request_address;
struct dc_plane_address current_address;
int inst;
struct stutter_modes stutter_mode;
};
struct vm_system_aperture_param {
PHYSICAL_ADDRESS_LOC sys_default;
PHYSICAL_ADDRESS_LOC sys_low;
PHYSICAL_ADDRESS_LOC sys_high;
};
struct vm_context0_param {
PHYSICAL_ADDRESS_LOC pte_base;
PHYSICAL_ADDRESS_LOC pte_start;
PHYSICAL_ADDRESS_LOC pte_end;
PHYSICAL_ADDRESS_LOC fault_default;
};
struct mem_input_funcs {
void (*mem_input_setup)(
struct mem_input *mem_input,
struct _vcs_dpi_display_dlg_regs_st *dlg_regs,
struct _vcs_dpi_display_ttu_regs_st *ttu_regs,
struct _vcs_dpi_display_rq_regs_st *rq_regs,
struct _vcs_dpi_display_pipe_dest_params_st *pipe_dest);
void (*dcc_control)(struct mem_input *mem_input, bool enable,
bool independent_64b_blks);
void (*mem_program_viewport)(
struct mem_input *mem_input,
const struct rect *viewport,
const struct rect *viewport_c);
void (*mem_input_program_display_marks)(
struct mem_input *mem_input,
struct dce_watermarks nbp,
struct dce_watermarks stutter,
struct dce_watermarks stutter_enter,
struct dce_watermarks urgent,
uint32_t total_dest_line_time_ns);
void (*mem_input_program_chroma_display_marks)(
struct mem_input *mem_input,
struct dce_watermarks nbp,
struct dce_watermarks stutter,
struct dce_watermarks urgent,
uint32_t total_dest_line_time_ns);
void (*allocate_mem_input)(
struct mem_input *mem_input,
uint32_t h_total,/* for current target */
uint32_t v_total,/* for current target */
uint32_t pix_clk_khz,/* for current target */
uint32_t total_streams_num);
void (*free_mem_input)(
struct mem_input *mem_input,
uint32_t paths_num);
bool (*mem_input_program_surface_flip_and_addr)(
struct mem_input *mem_input,
const struct dc_plane_address *address,
bool flip_immediate);
void (*mem_input_program_pte_vm)(
struct mem_input *mem_input,
enum surface_pixel_format format,
struct dc_tiling_info *tiling_info,
enum dc_rotation_angle rotation);
void (*mem_input_set_vm_system_aperture_settings)(
struct mem_input *mem_input,
struct vm_system_aperture_param *apt);
void (*mem_input_set_vm_context0_settings)(
struct mem_input *mem_input,
const struct vm_context0_param *vm0);
void (*mem_input_program_surface_config)(
struct mem_input *mem_input,
enum surface_pixel_format format,
struct dc_tiling_info *tiling_info,
struct plane_size *plane_size,
enum dc_rotation_angle rotation,
struct dc_plane_dcc_param *dcc,
bool horizontal_mirror);
bool (*mem_input_is_flip_pending)(struct mem_input *mem_input);
void (*mem_input_update_dchub)(struct mem_input *mem_input,
struct dchub_init_data *dh_data);
void (*set_blank)(struct mem_input *mi, bool blank);
void (*set_hubp_blank_en)(struct mem_input *mi, bool blank);
void (*set_cursor_attributes)(
struct mem_input *mem_input,
const struct dc_cursor_attributes *attr);
void (*set_cursor_position)(
struct mem_input *mem_input,
const struct dc_cursor_position *pos,
const struct dc_cursor_mi_param *param);
void (*mem_input_clear_tiling)(
struct mem_input *mem_input);
};
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,386 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
/**
* DOC: overview
*
* The Output Plane Processor (OPP) block groups have functions that format
* pixel streams such that they are suitable for display at the display device.
* The key functions contained in the OPP are:
*
* - Adaptive Backlight Modulation (ABM)
* - Formatter (FMT) which provide pixel-by-pixel operations for format the
* incoming pixel stream.
* - Output Buffer that provide pixel replication, and overlapping.
* - Interface between MPC and OPTC.
* - Clock and reset generation.
* - CRC generation.
*/
#ifndef __DAL_OPP_H__
#define __DAL_OPP_H__
#include "hw_shared.h"
#include "dc_hw_types.h"
#include "transform.h"
#include "mpc.h"
struct fixed31_32;
/* TODO: Need cleanup */
enum clamping_range {
CLAMPING_FULL_RANGE = 0, /* No Clamping */
CLAMPING_LIMITED_RANGE_8BPC, /* 8 bpc: Clamping 1 to FE */
CLAMPING_LIMITED_RANGE_10BPC, /* 10 bpc: Clamping 4 to 3FB */
CLAMPING_LIMITED_RANGE_12BPC, /* 12 bpc: Clamping 10 to FEF */
/* Use programmable clampping value on FMT_CLAMP_COMPONENT_R/G/B. */
CLAMPING_LIMITED_RANGE_PROGRAMMABLE
};
struct clamping_and_pixel_encoding_params {
enum dc_pixel_encoding pixel_encoding; /* Pixel Encoding */
enum clamping_range clamping_level; /* Clamping identifier */
enum dc_color_depth c_depth; /* Deep color use. */
};
struct bit_depth_reduction_params {
struct {
/* truncate/round */
/* trunc/round enabled*/
uint32_t TRUNCATE_ENABLED:1;
/* 2 bits: 0=6 bpc, 1=8 bpc, 2 = 10bpc*/
uint32_t TRUNCATE_DEPTH:2;
/* truncate or round*/
uint32_t TRUNCATE_MODE:1;
/* spatial dither */
/* Spatial Bit Depth Reduction enabled*/
uint32_t SPATIAL_DITHER_ENABLED:1;
/* 2 bits: 0=6 bpc, 1 = 8 bpc, 2 = 10bpc*/
uint32_t SPATIAL_DITHER_DEPTH:2;
/* 0-3 to select patterns*/
uint32_t SPATIAL_DITHER_MODE:2;
/* Enable RGB random dithering*/
uint32_t RGB_RANDOM:1;
/* Enable Frame random dithering*/
uint32_t FRAME_RANDOM:1;
/* Enable HighPass random dithering*/
uint32_t HIGHPASS_RANDOM:1;
/* temporal dither*/
/* frame modulation enabled*/
uint32_t FRAME_MODULATION_ENABLED:1;
/* same as for trunc/spatial*/
uint32_t FRAME_MODULATION_DEPTH:2;
/* 2/4 gray levels*/
uint32_t TEMPORAL_LEVEL:1;
uint32_t FRC25:2;
uint32_t FRC50:2;
uint32_t FRC75:2;
} flags;
uint32_t r_seed_value;
uint32_t b_seed_value;
uint32_t g_seed_value;
enum dc_pixel_encoding pixel_encoding;
};
enum wide_gamut_regamma_mode {
/* 0x0 - BITS2:0 Bypass */
WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_BYPASS,
/* 0x1 - Fixed curve sRGB 2.4 */
WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_SRGB24,
/* 0x2 - Fixed curve xvYCC 2.22 */
WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_XYYCC22,
/* 0x3 - Programmable control A */
WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_A,
/* 0x4 - Programmable control B */
WIDE_GAMUT_REGAMMA_MODE_GRAPHICS_MATRIX_B,
/* 0x0 - BITS6:4 Bypass */
WIDE_GAMUT_REGAMMA_MODE_OVL_BYPASS,
/* 0x1 - Fixed curve sRGB 2.4 */
WIDE_GAMUT_REGAMMA_MODE_OVL_SRGB24,
/* 0x2 - Fixed curve xvYCC 2.22 */
WIDE_GAMUT_REGAMMA_MODE_OVL_XYYCC22,
/* 0x3 - Programmable control A */
WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_A,
/* 0x4 - Programmable control B */
WIDE_GAMUT_REGAMMA_MODE_OVL_MATRIX_B
};
struct gamma_pixel {
struct fixed31_32 r;
struct fixed31_32 g;
struct fixed31_32 b;
};
enum channel_name {
CHANNEL_NAME_RED,
CHANNEL_NAME_GREEN,
CHANNEL_NAME_BLUE
};
struct custom_float_format {
uint32_t mantissa_bits;
uint32_t exponenta_bits;
bool sign;
};
struct custom_float_value {
uint32_t mantissa;
uint32_t exponenta;
uint32_t value;
bool negative;
};
struct hw_x_point {
uint32_t custom_float_x;
struct fixed31_32 x;
struct fixed31_32 regamma_y_red;
struct fixed31_32 regamma_y_green;
struct fixed31_32 regamma_y_blue;
};
struct pwl_float_data_ex {
struct fixed31_32 r;
struct fixed31_32 g;
struct fixed31_32 b;
struct fixed31_32 delta_r;
struct fixed31_32 delta_g;
struct fixed31_32 delta_b;
};
enum hw_point_position {
/* hw point sits between left and right sw points */
HW_POINT_POSITION_MIDDLE,
/* hw point lays left from left (smaller) sw point */
HW_POINT_POSITION_LEFT,
/* hw point lays stays from right (bigger) sw point */
HW_POINT_POSITION_RIGHT
};
struct gamma_point {
int32_t left_index;
int32_t right_index;
enum hw_point_position pos;
struct fixed31_32 coeff;
};
struct pixel_gamma_point {
struct gamma_point r;
struct gamma_point g;
struct gamma_point b;
};
struct gamma_coefficients {
struct fixed31_32 a0[3];
struct fixed31_32 a1[3];
struct fixed31_32 a2[3];
struct fixed31_32 a3[3];
struct fixed31_32 user_gamma[3];
struct fixed31_32 user_contrast;
struct fixed31_32 user_brightness;
};
/**
* struct pwl_float_data - Fixed point RGB color
*/
struct pwl_float_data {
/**
* @r: Component Red.
*/
struct fixed31_32 r;
/**
* @g: Component Green.
*/
struct fixed31_32 g;
/**
* @b: Component Blue.
*/
struct fixed31_32 b;
};
struct mpc_tree_cfg {
int num_pipes;
int dpp[MAX_PIPES];
int mpcc[MAX_PIPES];
};
struct output_pixel_processor {
struct dc_context *ctx;
uint32_t inst;
struct pwl_params regamma_params;
struct mpc_tree mpc_tree_params;
bool mpcc_disconnect_pending[MAX_PIPES];
const struct opp_funcs *funcs;
uint32_t dyn_expansion;
};
enum fmt_stereo_action {
FMT_STEREO_ACTION_ENABLE = 0,
FMT_STEREO_ACTION_DISABLE,
FMT_STEREO_ACTION_UPDATE_POLARITY
};
struct opp_grph_csc_adjustment {
//enum grph_color_adjust_option color_adjust_option;
enum dc_color_space c_space;
enum dc_color_depth color_depth; /* clean up to uint32_t */
enum graphics_csc_adjust_type csc_adjust_type;
int32_t adjust_divider;
int32_t grph_cont;
int32_t grph_sat;
int32_t grph_bright;
int32_t grph_hue;
};
/* Underlay related types */
struct hw_adjustment_range {
int32_t hw_default;
int32_t min;
int32_t max;
int32_t step;
uint32_t divider; /* (actually HW range is min/divider; divider !=0) */
};
enum ovl_csc_adjust_item {
OVERLAY_BRIGHTNESS = 0,
OVERLAY_GAMMA,
OVERLAY_CONTRAST,
OVERLAY_SATURATION,
OVERLAY_HUE,
OVERLAY_ALPHA,
OVERLAY_ALPHA_PER_PIX,
OVERLAY_COLOR_TEMPERATURE
};
enum oppbuf_display_segmentation {
OPPBUF_DISPLAY_SEGMENTATION_1_SEGMENT = 0,
OPPBUF_DISPLAY_SEGMENTATION_2_SEGMENT = 1,
OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT = 2,
OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_LEFT = 3,
OPPBUF_DISPLAY_SEGMENTATION_4_SEGMENT_SPLIT_RIGHT = 4
};
struct oppbuf_params {
uint32_t active_width;
enum oppbuf_display_segmentation mso_segmentation;
uint32_t mso_overlap_pixel_num;
uint32_t pixel_repetition;
uint32_t num_segment_padded_pixels;
};
struct dcn_opp_reg_state {
uint32_t dpg_control;
uint32_t fmt_control;
uint32_t oppbuf_control;
uint32_t opp_pipe_control;
uint32_t opp_pipe_crc_control;
uint32_t opp_abm_control;
uint32_t dscrm_dsc_forward_config;
};
struct opp_funcs {
/* FORMATTER RELATED */
void (*opp_program_fmt)(
struct output_pixel_processor *opp,
struct bit_depth_reduction_params *fmt_bit_depth,
struct clamping_and_pixel_encoding_params *clamping);
void (*opp_set_dyn_expansion)(
struct output_pixel_processor *opp,
enum dc_color_space color_sp,
enum dc_color_depth color_dpth,
enum signal_type signal);
void (*opp_program_bit_depth_reduction)(
struct output_pixel_processor *opp,
const struct bit_depth_reduction_params *params);
/* underlay related */
void (*opp_get_underlay_adjustment_range)(
struct output_pixel_processor *opp,
enum ovl_csc_adjust_item overlay_adjust_item,
struct hw_adjustment_range *range);
void (*opp_destroy)(struct output_pixel_processor **opp);
void (*opp_program_stereo)(
struct output_pixel_processor *opp,
bool enable,
const struct dc_crtc_timing *timing);
void (*opp_pipe_clock_control)(
struct output_pixel_processor *opp,
bool enable);
void (*opp_set_disp_pattern_generator)(
struct output_pixel_processor *opp,
enum controller_dp_test_pattern test_pattern,
enum controller_dp_color_space color_space,
enum dc_color_depth color_depth,
const struct tg_color *solid_color,
int width,
int height,
int offset);
void (*opp_program_dpg_dimensions)(
struct output_pixel_processor *opp,
uint32_t width,
uint32_t height);
bool (*dpg_is_blanked)(
struct output_pixel_processor *opp);
bool (*dpg_is_pending)(struct output_pixel_processor *opp);
void (*opp_dpg_set_blank_color)(
struct output_pixel_processor *opp,
const struct tg_color *color);
void (*opp_program_left_edge_extra_pixel)(
struct output_pixel_processor *opp,
enum dc_pixel_encoding pixel_encoding,
bool is_primary);
uint32_t (*opp_get_left_edge_extra_pixel_count)(
struct output_pixel_processor *opp,
enum dc_pixel_encoding pixel_encoding,
bool is_primary);
void (*opp_read_reg_state)(
struct output_pixel_processor *opp, struct dcn_opp_reg_state *opp_reg_state);
};
#endif
@@ -0,0 +1,196 @@
/* SPDX-License-Identifier: MIT */
/*
* Copyright 2023 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
/**
* DOC: overview
*
* Output Pipe Timing Combiner (OPTC) includes two major functional blocks:
* Output Data Mapper (ODM) and Output Timing Generator (OTG).
*
* - ODM: It is Output Data Mapping block. It can combine input data from
* multiple OPP data pipes into one single data stream or split data from one
* OPP data pipe into multiple data streams or just bypass OPP data to DIO.
* - OTG: It is Output Timing Generator. It generates display timing signals to
* drive the display output.
*/
#ifndef __DC_OPTC_H__
#define __DC_OPTC_H__
#include "timing_generator.h"
struct optc {
struct timing_generator base;
const struct dcn_optc_registers *tg_regs;
const struct dcn_optc_shift *tg_shift;
const struct dcn_optc_mask *tg_mask;
int opp_count;
uint32_t max_h_total;
uint32_t max_v_total;
uint32_t min_h_blank;
uint32_t min_h_sync_width;
uint32_t min_v_sync_width;
uint32_t min_v_blank;
uint32_t min_v_blank_interlace;
int vstartup_start;
int vupdate_offset;
int vupdate_width;
int vready_offset;
int pstate_keepout;
struct dc_crtc_timing orginal_patched_timing;
enum signal_type signal;
};
void optc1_read_otg_state(struct timing_generator *optc, struct dcn_otg_state *s);
bool optc1_get_hw_timing(struct timing_generator *tg, struct dc_crtc_timing *hw_crtc_timing);
bool optc1_validate_timing(struct timing_generator *optc,
const struct dc_crtc_timing *timing);
void optc1_program_timing(struct timing_generator *optc,
const struct dc_crtc_timing *dc_crtc_timing,
int vready_offset,
int vstartup_start,
int vupdate_offset,
int vupdate_width,
int pstate_keepout,
const enum signal_type signal,
bool use_vbios);
void optc1_setup_vertical_interrupt0(struct timing_generator *optc,
uint32_t start_line,
uint32_t end_line);
void optc1_setup_vertical_interrupt1(struct timing_generator *optc,
uint32_t start_line);
void optc1_setup_vertical_interrupt2(struct timing_generator *optc,
uint32_t start_line);
void optc1_program_global_sync(struct timing_generator *optc,
int vready_offset,
int vstartup_start,
int vupdate_offset,
int vupdate_width,
int pstate_keepout);
bool optc1_disable_crtc(struct timing_generator *optc);
bool optc1_is_counter_moving(struct timing_generator *optc);
void optc1_get_position(struct timing_generator *optc,
struct crtc_position *position);
uint32_t optc1_get_vblank_counter(struct timing_generator *optc);
void optc1_get_crtc_scanoutpos(struct timing_generator *optc,
uint32_t *v_blank_start,
uint32_t *v_blank_end,
uint32_t *h_position,
uint32_t *v_position);
void optc1_set_early_control(struct timing_generator *optc,
uint32_t early_cntl);
void optc1_wait_for_state(struct timing_generator *optc,
enum crtc_state state);
void optc1_set_blank(struct timing_generator *optc,
bool enable_blanking);
bool optc1_is_blanked(struct timing_generator *optc);
void optc1_program_blank_color(struct timing_generator *optc,
const struct tg_color *black_color);
bool optc1_did_triggered_reset_occur(struct timing_generator *optc);
void optc1_enable_reset_trigger(struct timing_generator *optc, int source_tg_inst);
void optc1_disable_reset_trigger(struct timing_generator *optc);
void optc1_lock(struct timing_generator *optc);
void optc1_unlock(struct timing_generator *optc);
void optc1_enable_optc_clock(struct timing_generator *optc, bool enable);
void optc1_set_drr(struct timing_generator *optc,
const struct drr_params *params);
void optc1_set_vtotal_min_max(struct timing_generator *optc, int vtotal_min, int vtotal_max);
void optc1_set_static_screen_control(struct timing_generator *optc,
uint32_t event_triggers,
uint32_t num_frames);
void optc1_program_stereo(struct timing_generator *optc,
const struct dc_crtc_timing *timing,
struct crtc_stereo_flags *flags);
bool optc1_is_stereo_left_eye(struct timing_generator *optc);
void optc1_clear_optc_underflow(struct timing_generator *optc);
void optc1_tg_init(struct timing_generator *optc);
bool optc1_is_tg_enabled(struct timing_generator *optc);
bool optc1_is_optc_underflow_occurred(struct timing_generator *optc);
void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable);
void optc1_set_timing_double_buffer(struct timing_generator *optc, bool enable);
bool optc1_get_otg_active_size(struct timing_generator *optc,
uint32_t *otg_active_width,
uint32_t *otg_active_height);
void optc1_enable_crtc_reset(struct timing_generator *optc,
int source_tg_inst,
struct crtc_trigger_info *crtc_tp);
bool optc1_configure_crc(struct timing_generator *optc, const struct crc_params *params);
bool optc1_get_crc(struct timing_generator *optc, uint8_t idx,
uint32_t *r_cr,
uint32_t *g_y,
uint32_t *b_cb);
void optc1_set_vtg_params(struct timing_generator *optc,
const struct dc_crtc_timing *dc_crtc_timing,
bool program_fp2);
bool optc1_is_two_pixels_per_container(const struct dc_crtc_timing *timing);
#endif
@@ -0,0 +1,72 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* panel_cntl.h
*
* Created on: Oct 6, 2015
* Author: yonsun
*/
#ifndef DC_PANEL_CNTL_H_
#define DC_PANEL_CNTL_H_
#include "dc_types.h"
#define MAX_BACKLIGHT_LEVEL 0xFFFF
struct panel_cntl_backlight_registers {
unsigned int BL_PWM_CNTL;
unsigned int BL_PWM_CNTL2;
unsigned int BL_PWM_PERIOD_CNTL;
unsigned int LVTMA_PWRSEQ_REF_DIV_BL_PWM_REF_DIV;
unsigned int PANEL_PWRSEQ_REF_DIV2;
unsigned int USER_LEVEL;
};
struct panel_cntl_funcs {
void (*destroy)(struct panel_cntl **panel_cntl);
uint32_t (*hw_init)(struct panel_cntl *panel_cntl);
bool (*is_panel_backlight_on)(struct panel_cntl *panel_cntl);
bool (*is_panel_powered_on)(struct panel_cntl *panel_cntl);
void (*store_backlight_level)(struct panel_cntl *panel_cntl);
void (*driver_set_backlight)(struct panel_cntl *panel_cntl,
uint32_t backlight_pwm_u16_16);
uint32_t (*get_current_backlight)(struct panel_cntl *panel_cntl);
};
struct panel_cntl_init_data {
struct dc_context *ctx;
uint32_t inst;
uint32_t eng_id;
};
struct panel_cntl {
const struct panel_cntl_funcs *funcs;
struct dc_context *ctx;
uint32_t inst;
uint32_t pwrseq_inst;
/* registers setting needs to be saved and restored at InitBacklight */
struct panel_cntl_backlight_registers stored_backlight_registers;
};
#endif /* DC_PANEL_CNTL_H_ */
@@ -0,0 +1,55 @@
/* Copyright 2023 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_PG_CNTL_H__
#define __DC_PG_CNTL_H__
#include "dc.h"
#include "dc_types.h"
#include "hw_shared.h"
struct pg_cntl {
struct dc_context *ctx;
const struct pg_cntl_funcs *funcs;
bool pg_pipe_res_enable[PG_HW_PIPE_RESOURCES_NUM_ELEMENT][MAX_PIPES];
bool pg_res_enable[PG_HW_RESOURCES_NUM_ELEMENT];
};
struct pg_cntl_funcs {
void (*dsc_pg_control)(struct pg_cntl *pg_cntl, unsigned int dsc_inst, bool power_on);
void (*hubp_dpp_pg_control)(struct pg_cntl *pg_cntl, unsigned int hubp_dpp_inst, bool power_on);
void (*hpo_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*io_clk_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*plane_otg_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*mpcc_pg_control)(struct pg_cntl *pg_cntl, unsigned int mpcc_inst, bool power_on);
void (*opp_pg_control)(struct pg_cntl *pg_cntl, unsigned int opp_inst, bool power_on);
void (*optc_pg_control)(struct pg_cntl *pg_cntl, unsigned int optc_inst, bool power_on);
void (*dwb_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*mem_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*dio_pg_control)(struct pg_cntl *pg_cntl, bool power_on);
void (*init_pg_status)(struct pg_cntl *pg_cntl);
void (*print_pg_status)(struct pg_cntl *pg_cntl, const char *debug_func, const char *debug_log);
};
#endif //__DC_PG_CNTL_H__
@@ -0,0 +1,597 @@
/*
* Copyright 2017 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
*/
/*
* stream_encoder.h
*
*/
#ifndef STREAM_ENCODER_H_
#define STREAM_ENCODER_H_
#include "audio_types.h"
#include "hw_shared.h"
struct dc_bios;
struct dc_context;
struct dc_crtc_timing;
enum dp_pixel_encoding_type {
DP_PIXEL_ENCODING_TYPE_RGB444 = 0x00000000,
DP_PIXEL_ENCODING_TYPE_YCBCR422 = 0x00000001,
DP_PIXEL_ENCODING_TYPE_YCBCR444 = 0x00000002,
DP_PIXEL_ENCODING_TYPE_RGB_WIDE_GAMUT = 0x00000003,
DP_PIXEL_ENCODING_TYPE_Y_ONLY = 0x00000004,
DP_PIXEL_ENCODING_TYPE_YCBCR420 = 0x00000005
};
enum dp_component_depth {
DP_COMPONENT_PIXEL_DEPTH_6BPC = 0x00000000,
DP_COMPONENT_PIXEL_DEPTH_8BPC = 0x00000001,
DP_COMPONENT_PIXEL_DEPTH_10BPC = 0x00000002,
DP_COMPONENT_PIXEL_DEPTH_12BPC = 0x00000003,
DP_COMPONENT_PIXEL_DEPTH_16BPC = 0x00000004
};
struct audio_clock_info {
/* pixel clock frequency*/
uint32_t pixel_clock_in_10khz;
/* N - 32KHz audio */
uint32_t n_32khz;
/* CTS - 32KHz audio*/
uint32_t cts_32khz;
uint32_t n_44khz;
uint32_t cts_44khz;
uint32_t n_48khz;
uint32_t cts_48khz;
};
enum dynamic_metadata_mode {
dmdata_dp,
dmdata_hdmi,
dmdata_dolby_vision
};
struct frl_audio_clock_info {
uint32_t frl_character_clock_kHz;
uint32_t n_32khz;
uint32_t cts_32khz;
uint32_t n_44khz;
uint32_t cts_44khz;
uint32_t n_48khz;
uint32_t cts_48khz;
};
struct enc_sdp_line_num {
/* Adaptive Sync SDP */
bool adaptive_sync_line_num_valid;
uint32_t adaptive_sync_line_num;
};
struct encoder_info_frame {
/* auxiliary video information */
struct dc_info_packet avi;
struct dc_info_packet gamut;
struct dc_info_packet vendor;
struct dc_info_packet hfvsif;
struct dc_info_packet vtem;
/* source product description */
struct dc_info_packet spd;
/* video stream configuration */
struct dc_info_packet vsc;
/* HDR Static MetaData */
struct dc_info_packet hdrsmd;
/* Adaptive Sync SDP*/
struct dc_info_packet adaptive_sync;
struct enc_sdp_line_num sdp_line_num;
bool firmware_controlled_hdr_info_packet;
};
struct encoder_unblank_param {
struct dc_link_settings link_settings;
struct dc_crtc_timing timing;
int opp_cnt;
uint32_t pix_per_cycle;
};
struct encoder_set_dp_phy_pattern_param {
enum dp_test_pattern dp_phy_pattern;
const uint8_t *custom_pattern;
uint32_t custom_pattern_size;
enum dp_panel_mode dp_panel_mode;
};
struct stream_encoder {
const struct stream_encoder_funcs *funcs;
struct dc_context *ctx;
struct dc_bios *bp;
enum engine_id id;
uint32_t stream_enc_inst;
struct vpg *vpg;
struct afmt *afmt;
struct apg *apg;
};
struct enc_state {
uint32_t dsc_mode; // DISABLED 0; 1 or 2 indicate enabled state.
uint32_t dsc_slice_width;
uint32_t sec_gsp_pps_line_num;
uint32_t vbid6_line_reference;
uint32_t vbid6_line_num;
uint32_t sec_gsp_pps_enable;
uint32_t sec_stream_enable;
};
struct stream_encoder_funcs {
void (*dp_set_stream_attribute)(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
enum dc_color_space output_color_space,
bool use_vsc_sdp_for_colorimetry,
uint32_t enable_sdp_splitting);
void (*hdmi_set_stream_attribute)(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
int actual_pix_clk_khz,
bool enable_audio);
void (*dvi_set_stream_attribute)(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
bool is_dual_link);
void (*lvds_set_stream_attribute)(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing);
void (*set_throttled_vcp_size)(
struct stream_encoder *enc,
struct fixed31_32 avg_time_slots_per_mtp);
void (*update_hdmi_info_packets)(
struct stream_encoder *enc,
const struct encoder_info_frame *info_frame);
void (*stop_hdmi_info_packets)(
struct stream_encoder *enc);
void (*update_dp_info_packets_sdp_line_num)(
struct stream_encoder *enc,
struct encoder_info_frame *info_frame);
void (*update_dp_info_packets)(
struct stream_encoder *enc,
const struct encoder_info_frame *info_frame);
void (*send_immediate_sdp_message)(
struct stream_encoder *enc,
const uint8_t *custom_sdp_message,
unsigned int sdp_message_size);
void (*stop_dp_info_packets)(
struct stream_encoder *enc);
void (*dp_blank)(
struct dc_link *link,
struct stream_encoder *enc);
void (*dp_unblank)(
struct dc_link *link,
struct stream_encoder *enc,
const struct encoder_unblank_param *param);
void (*audio_mute_control)(
struct stream_encoder *enc, bool mute);
void (*dp_audio_setup)(
struct stream_encoder *enc,
unsigned int az_inst,
struct audio_info *info);
void (*dp_audio_enable) (
struct stream_encoder *enc);
void (*dp_audio_disable) (
struct stream_encoder *enc);
void (*hdmi_audio_setup)(
struct stream_encoder *enc,
unsigned int az_inst,
struct audio_info *info,
struct audio_crtc_info *audio_crtc_info);
void (*hdmi_audio_disable) (
struct stream_encoder *enc);
void (*setup_stereo_sync) (
struct stream_encoder *enc,
int tg_inst,
bool enable);
void (*set_avmute)(
struct stream_encoder *enc, bool enable);
void (*dig_connect_to_otg)(
struct stream_encoder *enc,
int tg_inst);
void (*enable_stream)(
struct stream_encoder *enc,
enum signal_type signal,
bool enable);
void (*hdmi_reset_stream_attribute)(
struct stream_encoder *enc);
unsigned int (*dig_source_otg)(
struct stream_encoder *enc);
bool (*dp_get_pixel_format)(
struct stream_encoder *enc,
enum dc_pixel_encoding *encoding,
enum dc_color_depth *depth);
void (*enc_read_state)(struct stream_encoder *enc, struct enc_state *s);
void (*dp_set_dsc_config)(
struct stream_encoder *enc,
enum optc_dsc_mode dsc_mode,
uint32_t dsc_bytes_per_pixel,
uint32_t dsc_slice_width);
void (*dp_set_dsc_pps_info_packet)(struct stream_encoder *enc,
bool enable,
uint8_t *dsc_packed_pps,
bool immediate_update);
void (*set_dynamic_metadata)(struct stream_encoder *enc,
bool enable,
uint32_t hubp_requestor_id,
enum dynamic_metadata_mode dmdata_mode);
/**
* @dp_set_odm_combine: Sets up DP stream encoder for ODM.
*/
void (*dp_set_odm_combine)(
struct stream_encoder *enc,
bool odm_combine);
uint32_t (*get_fifo_cal_average_level)(
struct stream_encoder *enc);
void (*set_input_mode)(
struct stream_encoder *enc, unsigned int pix_per_container);
void (*enable_fifo)(struct stream_encoder *enc);
void (*disable_fifo)(struct stream_encoder *enc);
bool (*is_fifo_enabled)(struct stream_encoder *enc);
void (*map_stream_to_link)(struct stream_encoder *enc, uint32_t stream_enc_inst, uint32_t link_enc_inst);
uint32_t (*get_pixels_per_cycle)(struct stream_encoder *enc);
};
/**
* @hpo_frl_stream_encoder_state - Stream encoder parameters
*/
struct hpo_frl_stream_encoder_state {
uint32_t stream_enc_enabled;
uint32_t otg_inst;
uint32_t color_depth;
uint32_t num_odm_segments;
uint32_t h_active;
uint32_t h_blank;
uint32_t borrow_mode;
enum dc_pixel_encoding pixel_format;
};
/**
* @hpo_frl_stream_encoder - Encoder stream instance
*
* This struct keeps the reference to the struct with the FRL stream encoder
* callbacks. Additionally, it has other references that simplify the stream
* configuration.
*/
struct hpo_frl_stream_encoder {
/**
* @funcs: callback functions for using FRL stream encoder.
*/
const struct hpo_frl_stream_encoder_funcs *funcs;
/**
* @stream_enc_inst: Instance ID reference.
*/
uint32_t stream_enc_inst;
/**
* @ctx: DC context.
*/
struct dc_context *ctx;
/**
* @bp: Bios parser reference.
*/
struct dc_bios *bp;
/**
* @id: ID to the Engine object type.
*/
enum engine_id id;
/**
* @afmt:
*
* Audio Formatter (AFMT) reference used for select the correct audio
* reference.
*/
struct afmt *afmt;
/**
* @vpg:
*
* The VBI Packet Generator (VPG) reference which is used for
* generating the HDMI data island packet headers for ISRC1 and generic
* packages.
*/
struct vpg *vpg;
/**
* @afmt:
*
* Audio Pattern Generator (APG) reference used for select the correct audio
* reference.
*/
struct apg *apg;
};
/**
* @hpo_frl_stream_encoder_funcs - FRL stream encoder functions callbacks
*
* DC must set up the FRL encoder and the stream encoder; however, each ASIC
* may have some quirks in setting FRL. Thus, this struct, adds all the encoder
* stream interfaces for setup the FRL stream encoder.
*/
struct hpo_frl_stream_encoder_funcs {
void (*hdmi_frl_set_dsc_config)(
struct hpo_frl_stream_encoder *enc,
struct dc_crtc_timing *timing,
uint8_t *dsc_packed_pps);
/**
* @hdmi_frl_enable:
*
* This callback initializes a new FRL stream by enabling HDMI Dispclk,
* SOCCLK, and HDMI stream clock. Additionally, this callback is also
* used to initialize some debug options, such as the CRC validation.
* Finally, it must setup the OTG instance.
*/
void (*hdmi_frl_enable)(struct hpo_frl_stream_encoder *enc,
int otg_inst);
/**
* @hdmi_frl_unblank:
*
* Ensure that the FIFO video stream is active, reset the necessary
* FIFO registers, enable HDMI tribyte encoder, and finally, adjust the
* clock ramp registers for FIFO. Notice that all the configuration
* made by this function it is at the register level.
*/
void (*hdmi_frl_unblank)(struct hpo_frl_stream_encoder *enc,
int otg_inst);
/**
* @hdmi_frl_blank:
*
* This callback is a register-level configuration that must disable
* the clock ramp adjuster FIFO, disable the HDMI Tribyte encoder, and
* disable the stream clocks (dispclk, socclk, and hdmistreamclk).
*/
void (*hdmi_frl_blank)(struct hpo_frl_stream_encoder *enc);
/**
* @hdmi_frl_fifo_odm_enabled:
*
* This callback checks if the FIFO ODM Combine mode is enabled
*/
bool (*hdmi_frl_fifo_odm_enabled)(struct hpo_frl_stream_encoder *enc);
/**
* @hdmi_frl_set_stream_attribute:
*
* This callback should be invoked only after the link is trained. The
* implementation should configure the pixel encode, color depth, ODM
* mode, configure horizontal blank/active size, configure borrow
* parameters, enable general control packet, enable/setup audio, and
* AVMute.
*/
void (*hdmi_frl_set_stream_attribute)(struct hpo_frl_stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
struct frl_borrow_params *borrow_params,
int odm_combine_num_segments);
/**
* @update_hdmi_info_packets:
*
* Update the HDMI packet control option.
*/
void (*update_hdmi_info_packets)(struct hpo_frl_stream_encoder *enc,
const struct encoder_info_frame *info_frame);
/**
* @stop_hdmi_info_packets:
*
* Update HDMI info packet (avi, vendoer, gamut, spd, hdrsmd, hfvsif,
* vtem, etc).
*/
void (*stop_hdmi_info_packets)(struct hpo_frl_stream_encoder *enc);
/**
* @audio_mute_control:
*
* Just mute the audio.
*/
void (*audio_mute_control)(struct hpo_frl_stream_encoder *enc,
bool mute);
/**
* @hdmi_audio_setup:
*
* Setup HDMI audio based on the Azila info.
*/
void (*hdmi_audio_setup)(struct hpo_frl_stream_encoder *enc,
unsigned int az_inst,
struct audio_info *info,
struct audio_crtc_info *audio_crtc_info);
/**
* @hdmi_audio_disable:
*
* Disable audio.
*/
void (*hdmi_audio_disable)(struct hpo_frl_stream_encoder *enc);
/**
* @set_avmute:
*
* Disable AVmute at the register-level.
*/
void (*set_avmute)(struct hpo_frl_stream_encoder *enc, bool enable);
/**
* @validate_hdmi_frl_output:
*
* Validate FRL inputs, DSC, audio parameters, FRL capacity, and borrow
* parameters.
*/
bool (*validate_hdmi_frl_output)(struct hpo_frl_stream_encoder *enc,
const struct dc_crtc_timing *timing,
const struct audio_check *audio,
struct dc_hdmi_frl_link_settings *frl_link_settings,
unsigned int dsc_max_rate);
/**
* @read_state:
*
* Fill out the hpo_frl_stream_encoder_state with the info retrieved
* from ASIC registers.
*/
void (*read_state)(struct hpo_frl_stream_encoder *enc,
struct hpo_frl_stream_encoder_state *state);
/**
* @set_dynamic_metadata:
*
* Metadata configuration that sets:
* - Using Enfine or disable DME.
* - HUBP setup for the physical instance that has the DME enabled.
* - Metadata packet type.
* - Ensure OTG master update locks in the changing DME configuration.
*/
void (*set_dynamic_metadata)(struct hpo_frl_stream_encoder *enc,
bool enable_dme,
uint32_t hubp_requestor_id,
enum dynamic_metadata_mode dmdata_mode);
};
struct hpo_dp_stream_encoder_state {
uint32_t stream_enc_enabled;
uint32_t vid_stream_enabled;
uint32_t otg_inst;
uint32_t pixel_encoding;
uint32_t component_depth;
uint32_t compressed_format;
uint32_t sdp_enabled;
uint32_t mapped_to_link_enc;
};
struct hpo_dp_stream_encoder {
const struct hpo_dp_stream_encoder_funcs *funcs;
struct dc_context *ctx;
struct dc_bios *bp;
uint32_t inst;
enum engine_id id;
struct vpg *vpg;
struct apg *apg;
};
struct hpo_dp_stream_encoder_funcs {
void (*enable_stream)(
struct hpo_dp_stream_encoder *enc);
void (*dp_unblank)(
struct hpo_dp_stream_encoder *enc,
uint32_t stream_source);
void (*dp_blank)(
struct hpo_dp_stream_encoder *enc);
void (*disable)(
struct hpo_dp_stream_encoder *enc);
void (*set_stream_attribute)(
struct hpo_dp_stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
enum dc_color_space output_color_space,
bool use_vsc_sdp_for_colorimetry,
bool compressed_format,
bool double_buffer_en);
void (*update_dp_info_packets_sdp_line_num)(
struct hpo_dp_stream_encoder *enc,
struct encoder_info_frame *info_frame);
void (*update_dp_info_packets)(
struct hpo_dp_stream_encoder *enc,
const struct encoder_info_frame *info_frame);
void (*stop_dp_info_packets)(
struct hpo_dp_stream_encoder *enc);
void (*dp_set_dsc_pps_info_packet)(
struct hpo_dp_stream_encoder *enc,
bool enable,
uint8_t *dsc_packed_pps,
bool immediate_update);
void (*map_stream_to_link)(
struct hpo_dp_stream_encoder *enc,
uint32_t stream_enc_inst,
uint32_t link_enc_inst);
void (*dp_audio_setup)(
struct hpo_dp_stream_encoder *enc,
unsigned int az_inst,
struct audio_info *info);
void (*dp_audio_enable)(
struct hpo_dp_stream_encoder *enc);
void (*dp_audio_disable)(
struct hpo_dp_stream_encoder *enc);
void (*read_state)(
struct hpo_dp_stream_encoder *enc,
struct hpo_dp_stream_encoder_state *state);
void (*set_hblank_min_symbol_width)(
struct hpo_dp_stream_encoder *enc,
uint16_t width);
};
#endif /* STREAM_ENCODER_H_ */
@@ -0,0 +1,530 @@
/*
* Copyright 2012-2026 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_TIMING_GENERATOR_TYPES_H__
#define __DAL_TIMING_GENERATOR_TYPES_H__
#include "hw_shared.h"
struct dc_bios;
/* Contains CRTC vertical/horizontal pixel counters */
struct crtc_position {
uint32_t vertical_count;
uint32_t horizontal_count;
uint32_t nominal_vcount;
};
struct dcp_gsl_params {
int gsl_group;
int gsl_master;
};
struct gsl_params {
int gsl0_en;
int gsl1_en;
int gsl2_en;
int gsl_master_en;
int gsl_master_mode;
int master_update_lock_gsl_en;
int gsl_window_start_x;
int gsl_window_end_x;
int gsl_window_start_y;
int gsl_window_end_y;
};
/* define the structure of Dynamic Refresh Mode */
struct drr_params {
uint32_t vertical_total_min;
uint32_t vertical_total_max;
uint32_t vertical_total_mid;
uint32_t vertical_total_mid_frame_num;
bool immediate_flip;
};
struct long_vtotal_params {
uint32_t vertical_total_min;
uint32_t vertical_total_max;
uint32_t vertical_blank_start;
};
#define LEFT_EYE_3D_PRIMARY_SURFACE 1
#define RIGHT_EYE_3D_PRIMARY_SURFACE 0
enum crtc_state {
CRTC_STATE_VBLANK = 0,
CRTC_STATE_VACTIVE
};
struct vupdate_keepout_params {
int start_offset;
int end_offset;
int enable;
};
struct crtc_stereo_flags {
uint8_t PROGRAM_STEREO : 1;
uint8_t PROGRAM_POLARITY : 1;
uint8_t RIGHT_EYE_POLARITY : 1;
uint8_t FRAME_PACKED : 1;
uint8_t DISABLE_STEREO_DP_SYNC : 1;
};
enum crc_selection {
/* Order must match values expected by hardware */
UNION_WINDOW_A_B = 0,
UNION_WINDOW_A_NOT_B,
UNION_WINDOW_NOT_A_B,
UNION_WINDOW_NOT_A_NOT_B,
INTERSECT_WINDOW_A_B,
INTERSECT_WINDOW_A_NOT_B,
INTERSECT_WINDOW_NOT_A_B,
INTERSECT_WINDOW_NOT_A_NOT_B,
};
enum otg_out_mux_dest {
OUT_MUX_DIO = 0,
OUT_MUX_HPO_FRL = 1,
OUT_MUX_HPO_DP = 2,
};
enum h_timing_div_mode {
H_TIMING_NO_DIV,
H_TIMING_DIV_BY2,
H_TIMING_RESERVED,
H_TIMING_DIV_BY4,
};
enum timing_synchronization_type {
NOT_SYNCHRONIZABLE,
TIMING_SYNCHRONIZABLE,
VBLANK_SYNCHRONIZABLE
};
enum crc_poly_mode {
CRC_POLY_MODE_16,
CRC_POLY_MODE_32,
CRC_POLY_MODE_MAX,
};
struct crc_params {
/* Regions used to calculate CRC*/
uint16_t windowa_x_start;
uint16_t windowa_x_end;
uint16_t windowa_y_start;
uint16_t windowa_y_end;
uint16_t windowb_x_start;
uint16_t windowb_x_end;
uint16_t windowb_y_start;
uint16_t windowb_y_end;
enum crc_selection selection;
uint8_t dsc_mode;
uint8_t odm_mode;
bool continuous_mode;
bool enable;
uint8_t crc_eng_inst;
bool reset;
enum crc_poly_mode crc_poly_mode;
};
struct dcn_otg_state {
uint32_t v_blank_start;
uint32_t v_blank_end;
uint32_t v_sync_a_pol;
uint32_t v_total;
uint32_t v_total_max;
uint32_t v_total_min;
uint32_t v_total_min_sel;
uint32_t v_total_max_sel;
uint32_t v_sync_a_start;
uint32_t v_sync_a_end;
uint32_t h_blank_start;
uint32_t h_blank_end;
uint32_t h_sync_a_start;
uint32_t h_sync_a_end;
uint32_t h_sync_a_pol;
uint32_t h_total;
uint32_t underflow_occurred_status;
uint32_t otg_enabled;
uint32_t blank_enabled;
uint32_t vertical_interrupt1_en;
uint32_t vertical_interrupt1_line;
uint32_t vertical_interrupt2_en;
uint32_t vertical_interrupt2_line;
uint32_t vertical_interrupt2_dest;
uint32_t otg_master_update_lock;
uint32_t otg_double_buffer_control;
};
struct dcn_optc_reg_state {
uint32_t optc_bytes_per_pixel;
uint32_t optc_data_format_control;
uint32_t optc_data_source_select;
uint32_t optc_input_clock_control;
uint32_t optc_input_global_control;
uint32_t optc_input_spare_register;
uint32_t optc_memory_config;
uint32_t optc_rsmu_underflow;
uint32_t optc_underflow_threshold;
uint32_t optc_width_control;
uint32_t otg_3d_structure_control;
uint32_t otg_clock_control;
uint32_t otg_control;
uint32_t otg_count_control;
uint32_t otg_count_reset;
uint32_t otg_crc_cntl;
uint32_t otg_crc_sig_blue_control_mask;
uint32_t otg_crc_sig_red_green_mask;
uint32_t otg_crc0_data_b;
uint32_t otg_crc0_data_rg;
uint32_t otg_crc0_windowa_x_control;
uint32_t otg_crc0_windowa_x_control_readback;
uint32_t otg_crc0_windowa_y_control;
uint32_t otg_crc0_windowa_y_control_readback;
uint32_t otg_crc0_windowb_x_control;
uint32_t otg_crc0_windowb_x_control_readback;
uint32_t otg_crc0_windowb_y_control;
uint32_t otg_crc0_windowb_y_control_readback;
uint32_t otg_crc1_data_b;
uint32_t otg_crc1_data_rg;
uint32_t otg_crc1_windowa_x_control;
uint32_t otg_crc1_windowa_x_control_readback;
uint32_t otg_crc1_windowa_y_control;
uint32_t otg_crc1_windowa_y_control_readback;
uint32_t otg_crc1_windowb_x_control;
uint32_t otg_crc1_windowb_x_control_readback;
uint32_t otg_crc1_windowb_y_control;
uint32_t otg_crc1_windowb_y_control_readback;
uint32_t otg_crc2_data_b;
uint32_t otg_crc2_data_rg;
uint32_t otg_crc3_data_b;
uint32_t otg_crc3_data_rg;
uint32_t otg_dlpc_control;
uint32_t otg_double_buffer_control;
uint32_t otg_drr_control2;
uint32_t otg_drr_control;
uint32_t otg_drr_timing_int_status;
uint32_t otg_drr_trigger_window;
uint32_t otg_drr_v_total_change;
uint32_t otg_drr_v_total_reach_range;
uint32_t otg_dsc_start_position;
uint32_t otg_force_count_now_cntl;
uint32_t otg_global_control0;
uint32_t otg_global_control1;
uint32_t otg_global_control2;
uint32_t otg_global_control3;
uint32_t otg_global_control4;
uint32_t otg_global_sync_status;
uint32_t otg_gsl_control;
uint32_t otg_gsl_vsync_gap;
uint32_t otg_gsl_window_x;
uint32_t otg_gsl_window_y;
uint32_t otg_h_blank_start_end;
uint32_t otg_h_sync_a;
uint32_t otg_h_sync_a_cntl;
uint32_t otg_h_timing_cntl;
uint32_t otg_h_total;
uint32_t otg_interlace_control;
uint32_t otg_interlace_status;
uint32_t otg_interrupt_control;
uint32_t otg_long_vblank_status;
uint32_t otg_m_const_dto0;
uint32_t otg_m_const_dto1;
uint32_t otg_manual_force_vsync_next_line;
uint32_t otg_master_en;
uint32_t otg_master_update_lock;
uint32_t otg_master_update_mode;
uint32_t otg_nom_vert_position;
uint32_t otg_pipe_update_status;
uint32_t otg_pixel_data_readback0;
uint32_t otg_pixel_data_readback1;
uint32_t otg_request_control;
uint32_t otg_snapshot_control;
uint32_t otg_snapshot_frame;
uint32_t otg_snapshot_position;
uint32_t otg_snapshot_status;
uint32_t otg_spare_register;
uint32_t otg_static_screen_control;
uint32_t otg_status;
uint32_t otg_status_frame_count;
uint32_t otg_status_hv_count;
uint32_t otg_status_position;
uint32_t otg_status_vf_count;
uint32_t otg_stereo_control;
uint32_t otg_stereo_force_next_eye;
uint32_t otg_stereo_status;
uint32_t otg_trig_manual_control;
uint32_t otg_triga_cntl;
uint32_t otg_triga_manual_trig;
uint32_t otg_trigb_cntl;
uint32_t otg_trigb_manual_trig;
uint32_t otg_update_lock;
uint32_t otg_v_blank_start_end;
uint32_t otg_v_count_stop_control;
uint32_t otg_v_count_stop_control2;
uint32_t otg_v_sync_a;
uint32_t otg_v_sync_a_cntl;
uint32_t otg_v_total;
uint32_t otg_v_total_control;
uint32_t otg_v_total_int_status;
uint32_t otg_v_total_max;
uint32_t otg_v_total_mid;
uint32_t otg_v_total_min;
uint32_t otg_vert_sync_control;
uint32_t otg_vertical_interrupt0_control;
uint32_t otg_vertical_interrupt0_position;
uint32_t otg_vertical_interrupt1_control;
uint32_t otg_vertical_interrupt1_position;
uint32_t otg_vertical_interrupt2_control;
uint32_t otg_vertical_interrupt2_position;
uint32_t otg_vready_param;
uint32_t otg_vstartup_param;
uint32_t otg_vsync_nom_int_status;
uint32_t otg_vupdate_keepout;
uint32_t otg_vupdate_param;
};
/**
* struct timing_generator - Entry point to Output Timing Generator feature.
*/
struct timing_generator {
/**
* @funcs: Timing generator control functions
*/
const struct timing_generator_funcs *funcs;
struct dc_bios *bp;
struct dc_context *ctx;
uint32_t inst;
};
struct dc_crtc_timing;
struct drr_params;
/**
* struct timing_generator_funcs - Control timing generator on a given device.
*/
struct timing_generator_funcs {
bool (*validate_timing)(struct timing_generator *tg,
const struct dc_crtc_timing *timing);
void (*program_timing)(struct timing_generator *tg,
const struct dc_crtc_timing *timing,
int vready_offset,
int vstartup_start,
int vupdate_offset,
int vupdate_width,
int pstate_keepout,
const enum signal_type signal,
bool use_vbios
);
void (*setup_vertical_interrupt0)(
struct timing_generator *optc,
uint32_t start_line,
uint32_t end_line);
void (*setup_vertical_interrupt1)(
struct timing_generator *optc,
uint32_t start_line);
void (*setup_vertical_interrupt2)(
struct timing_generator *optc,
uint32_t start_line);
bool (*enable_crtc)(struct timing_generator *tg);
bool (*disable_crtc)(struct timing_generator *tg);
void (*phantom_crtc_post_enable)(struct timing_generator *tg);
void (*disable_phantom_crtc)(struct timing_generator *tg);
bool (*immediate_disable_crtc)(struct timing_generator *tg);
bool (*is_counter_moving)(struct timing_generator *tg);
void (*get_position)(struct timing_generator *tg,
struct crtc_position *position);
uint32_t (*get_frame_count)(struct timing_generator *tg);
void (*get_scanoutpos)(
struct timing_generator *tg,
uint32_t *v_blank_start,
uint32_t *v_blank_end,
uint32_t *h_position,
uint32_t *v_position);
bool (*get_otg_active_size)(struct timing_generator *optc,
uint32_t *otg_active_width,
uint32_t *otg_active_height);
bool (*is_matching_timing)(struct timing_generator *tg,
const struct dc_crtc_timing *otg_timing);
void (*set_early_control)(struct timing_generator *tg,
uint32_t early_cntl);
void (*wait_for_state)(struct timing_generator *tg,
enum crtc_state state);
void (*set_blank)(struct timing_generator *tg,
bool enable_blanking);
bool (*is_blanked)(struct timing_generator *tg);
void (*set_overscan_blank_color) (struct timing_generator *tg, const struct tg_color *color);
void (*set_blank_color)(struct timing_generator *tg, const struct tg_color *color);
void (*set_colors)(struct timing_generator *tg,
const struct tg_color *blank_color,
const struct tg_color *overscan_color);
void (*disable_vga)(struct timing_generator *tg);
bool (*did_triggered_reset_occur)(struct timing_generator *tg);
void (*setup_global_swap_lock)(struct timing_generator *tg,
const struct dcp_gsl_params *gsl_params);
void (*unlock)(struct timing_generator *tg);
void (*lock)(struct timing_generator *tg);
void (*lock_doublebuffer_disable)(struct timing_generator *tg);
void (*lock_doublebuffer_enable)(struct timing_generator *tg);
void(*triplebuffer_unlock)(struct timing_generator *tg);
void(*triplebuffer_lock)(struct timing_generator *tg);
void (*enable_reset_trigger)(struct timing_generator *tg,
int source_tg_inst);
void (*enable_crtc_reset)(struct timing_generator *tg,
int source_tg_inst,
struct crtc_trigger_info *crtc_tp);
void (*disable_reset_trigger)(struct timing_generator *tg);
void (*tear_down_global_swap_lock)(struct timing_generator *tg);
void (*enable_advanced_request)(struct timing_generator *tg,
bool enable, const struct dc_crtc_timing *timing);
void (*set_drr)(struct timing_generator *tg, const struct drr_params *params);
void (*set_vtotal_min_max)(struct timing_generator *optc, int vtotal_min, int vtotal_max);
void (*get_last_used_drr_vtotal)(struct timing_generator *optc, uint32_t *refresh_rate);
void (*set_static_screen_control)(struct timing_generator *tg,
uint32_t event_triggers,
uint32_t num_frames);
void (*set_test_pattern)(
struct timing_generator *tg,
enum controller_dp_test_pattern test_pattern,
enum dc_color_depth color_depth);
bool (*arm_vert_intr)(struct timing_generator *tg, uint8_t width);
void (*program_global_sync)(struct timing_generator *tg,
int vready_offset,
int vstartup_start,
int vupdate_offset,
int vupdate_width,
int pstate_keepout);
void (*enable_optc_clock)(struct timing_generator *tg, bool enable);
void (*program_stereo)(struct timing_generator *tg,
const struct dc_crtc_timing *timing, struct crtc_stereo_flags *flags);
bool (*is_stereo_left_eye)(struct timing_generator *tg);
void (*set_blank_data_double_buffer)(struct timing_generator *tg, bool enable);
void (*tg_init)(struct timing_generator *tg);
bool (*is_tg_enabled)(struct timing_generator *tg);
bool (*is_optc_underflow_occurred)(struct timing_generator *tg);
void (*clear_optc_underflow)(struct timing_generator *tg);
void (*set_dwb_source)(struct timing_generator *optc,
uint32_t dwb_pipe_inst);
void (*get_optc_source)(struct timing_generator *optc,
uint32_t *num_of_input_segments,
uint32_t *seg0_src_sel,
uint32_t *seg1_src_sel);
bool (*is_two_pixels_per_container)(const struct dc_crtc_timing *timing);
/**
* Configure CRCs for the given timing generator. Return false if TG is
* not on.
*/
bool (*configure_crc)(struct timing_generator *tg,
const struct crc_params *params);
/**
* @get_crc: Get CRCs for the given timing generator. Return false if
* CRCs are not enabled (via configure_crc).
*/
bool (*get_crc)(struct timing_generator *tg, uint8_t idx,
uint32_t *r_cr, uint32_t *g_y, uint32_t *b_cb);
void (*program_manual_trigger)(struct timing_generator *optc);
void (*setup_manual_trigger)(struct timing_generator *optc);
bool (*get_hw_timing)(struct timing_generator *optc,
struct dc_crtc_timing *hw_crtc_timing);
void (*set_vtg_params)(struct timing_generator *optc,
const struct dc_crtc_timing *dc_crtc_timing, bool program_fp2);
void (*set_dsc_config)(struct timing_generator *optc,
enum optc_dsc_mode dsc_mode,
uint32_t dsc_bytes_per_pixel,
uint32_t dsc_slice_width);
void (*get_dsc_status)(struct timing_generator *optc,
uint32_t *dsc_mode);
void (*set_odm_bypass)(struct timing_generator *optc, const struct dc_crtc_timing *dc_crtc_timing);
/**
* @set_odm_combine: Set up the ODM block to read from the correct
* OPP(s) and turn on/off ODM memory.
*/
void (*set_odm_combine)(struct timing_generator *optc, int *opp_id, int opp_cnt,
int segment_width, int last_segment_width);
void (*get_odm_combine_segments)(struct timing_generator *tg, int *odm_segments);
void (*set_h_timing_div_manual_mode)(struct timing_generator *optc, bool manual_mode);
void (*set_gsl)(struct timing_generator *optc, const struct gsl_params *params);
void (*set_gsl_source_select)(struct timing_generator *optc,
int group_idx,
uint32_t gsl_ready_signal);
void (*set_out_mux)(struct timing_generator *tg, enum otg_out_mux_dest dest);
void (*set_drr_trigger_window)(struct timing_generator *optc,
uint32_t window_start, uint32_t window_end);
int (*set_fva_factor)(struct timing_generator *optc, struct fva_adj *fva_adj);
int (*get_max_hw_supported_fva_factor)(struct timing_generator *optc,
struct dc_crtc_timing *timing,
unsigned int max_pixclk_100hz);
void (*set_vtotal_change_limit)(struct timing_generator *optc,
uint32_t limit);
void (*align_vblanks)(struct timing_generator *master_optc,
struct timing_generator *slave_optc,
uint32_t master_pixel_clock_100Hz,
uint32_t slave_pixel_clock_100Hz,
uint8_t master_clock_divider,
uint8_t slave_clock_divider);
bool (*validate_vmin_vmax)(struct timing_generator *optc,
int vmin, int vmax);
bool (*validate_vtotal_change_limit)(struct timing_generator *optc,
uint32_t vtotal_change_limit);
void (*init_odm)(struct timing_generator *tg);
void (*wait_drr_doublebuffer_pending_clear)(struct timing_generator *tg);
void (*set_long_vtotal)(struct timing_generator *optc, const struct long_vtotal_params *params);
void (*wait_odm_doublebuffer_pending_clear)(struct timing_generator *tg);
void (*wait_otg_disable)(struct timing_generator *optc);
bool (*get_optc_double_buffer_pending)(struct timing_generator *tg);
bool (*get_otg_double_buffer_pending)(struct timing_generator *tg);
bool (*get_pipe_update_pending)(struct timing_generator *tg);
void (*set_vupdate_keepout)(struct timing_generator *tg, bool enable);
bool (*wait_update_lock_status)(struct timing_generator *tg, bool locked);
void (*read_otg_state)(struct timing_generator *tg, struct dcn_otg_state *s);
void (*optc_read_reg_state)(struct timing_generator *tg, struct dcn_optc_reg_state *optc_reg_state);
void (*enable_otg_pwa)(struct timing_generator *tg, struct otc_pwa_frame_sync *pwa_param);
void (*disable_otg_pwa)(struct timing_generator *tg);
};
#endif
@@ -0,0 +1,293 @@
/*
* Copyright 2012-15 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DAL_TRANSFORM_H__
#define __DAL_TRANSFORM_H__
#include "hw_shared.h"
#include "dc_hw_types.h"
#include "fixed31_32.h"
#include "sspl/dc_spl_types.h"
#define CSC_TEMPERATURE_MATRIX_SIZE 12
struct bit_depth_reduction_params;
struct transform {
const struct transform_funcs *funcs;
struct dc_context *ctx;
int inst;
struct dpp_caps *caps;
struct pwl_params regamma_params;
};
/* Colorimetry */
enum colorimetry {
COLORIMETRY_NO_DATA = 0,
COLORIMETRY_ITU601 = 1,
COLORIMETRY_ITU709 = 2,
COLORIMETRY_EXTENDED = 3
};
enum colorimetry_ext {
COLORIMETRYEX_XVYCC601 = 0,
COLORIMETRYEX_XVYCC709 = 1,
COLORIMETRYEX_SYCC601 = 2,
COLORIMETRYEX_ADOBEYCC601 = 3,
COLORIMETRYEX_ADOBERGB = 4,
COLORIMETRYEX_BT2020YCC = 5,
COLORIMETRYEX_BT2020RGBYCBCR = 6,
COLORIMETRYEX_RESERVED = 7
};
enum active_format_info {
ACTIVE_FORMAT_NO_DATA = 0,
ACTIVE_FORMAT_VALID = 1
};
/* Active format aspect ratio */
enum active_format_aspect_ratio {
ACTIVE_FORMAT_ASPECT_RATIO_SAME_AS_PICTURE = 8,
ACTIVE_FORMAT_ASPECT_RATIO_4_3 = 9,
ACTIVE_FORMAT_ASPECT_RATIO_16_9 = 0XA,
ACTIVE_FORMAT_ASPECT_RATIO_14_9 = 0XB
};
enum bar_info {
BAR_INFO_NOT_VALID = 0,
BAR_INFO_VERTICAL_VALID = 1,
BAR_INFO_HORIZONTAL_VALID = 2,
BAR_INFO_BOTH_VALID = 3
};
enum picture_scaling {
PICTURE_SCALING_UNIFORM = 0,
PICTURE_SCALING_HORIZONTAL = 1,
PICTURE_SCALING_VERTICAL = 2,
PICTURE_SCALING_BOTH = 3
};
/* RGB quantization range */
enum rgb_quantization_range {
RGB_QUANTIZATION_DEFAULT_RANGE = 0,
RGB_QUANTIZATION_LIMITED_RANGE = 1,
RGB_QUANTIZATION_FULL_RANGE = 2,
RGB_QUANTIZATION_RESERVED = 3
};
/* YYC quantization range */
enum yyc_quantization_range {
YYC_QUANTIZATION_LIMITED_RANGE = 0,
YYC_QUANTIZATION_FULL_RANGE = 1,
YYC_QUANTIZATION_RESERVED2 = 2,
YYC_QUANTIZATION_RESERVED3 = 3
};
enum graphics_gamut_adjust_type {
GRAPHICS_GAMUT_ADJUST_TYPE_BYPASS = 0,
GRAPHICS_GAMUT_ADJUST_TYPE_HW, /* without adjustments */
GRAPHICS_GAMUT_ADJUST_TYPE_SW /* use adjustments */
};
struct xfm_grph_csc_adjustment {
struct fixed31_32 temperature_matrix[CSC_TEMPERATURE_MATRIX_SIZE];
enum graphics_gamut_adjust_type gamut_adjust_type;
};
struct overscan_info {
int left;
int right;
int top;
int bottom;
};
struct scaling_ratios {
struct fixed31_32 horz;
struct fixed31_32 vert;
struct fixed31_32 horz_c;
struct fixed31_32 vert_c;
};
struct sharpness_adj {
int horz;
int vert;
};
struct line_buffer_params {
bool alpha_en;
bool pixel_expan_mode;
bool interleave_en;
int dynamic_pixel_depth;
enum lb_pixel_depth depth;
};
struct scl_inits {
struct fixed31_32 h;
struct fixed31_32 h_c;
struct fixed31_32 v;
struct fixed31_32 v_c;
};
struct scaler_data {
int h_active;
int v_active;
struct scaling_taps taps;
struct rect viewport;
struct rect viewport_c;
struct rect recout;
struct scaling_ratios ratios;
struct scl_inits inits;
struct sharpness_adj sharpness;
enum dc_pixel_format format;
struct line_buffer_params lb_params;
// Below struct holds the scaler values to program hw registers
struct dscl_prog_data dscl_prog_data;
};
struct transform_funcs {
void (*transform_reset)(struct transform *xfm);
void (*transform_set_scaler)(struct transform *xfm,
const struct scaler_data *scl_data);
void (*transform_set_pixel_storage_depth)(
struct transform *xfm,
enum lb_pixel_depth depth,
const struct bit_depth_reduction_params *bit_depth_params);
bool (*transform_get_optimal_number_of_taps)(
struct transform *xfm,
struct scaler_data *scl_data,
const struct scaling_taps *in_taps);
void (*transform_set_gamut_remap)(
struct transform *xfm,
const struct xfm_grph_csc_adjustment *adjust);
void (*opp_set_csc_default)(
struct transform *xfm,
const struct default_adjustment *default_adjust);
void (*opp_set_csc_adjustment)(
struct transform *xfm,
const struct out_csc_color_matrix *tbl_entry);
void (*opp_power_on_regamma_lut)(
struct transform *xfm,
bool power_on);
void (*opp_program_regamma_lut)(
struct transform *xfm,
const struct pwl_result_data *rgb,
uint32_t num);
void (*opp_configure_regamma_lut)(
struct transform *xfm,
bool is_ram_a);
void (*opp_program_regamma_lutb_settings)(
struct transform *xfm,
const struct pwl_params *params);
void (*opp_program_regamma_luta_settings)(
struct transform *xfm,
const struct pwl_params *params);
void (*opp_program_regamma_pwl)(
struct transform *xfm, const struct pwl_params *params);
void (*opp_set_regamma_mode)(
struct transform *xfm_base,
enum opp_regamma mode);
void (*ipp_set_degamma)(
struct transform *xfm_base,
enum ipp_degamma_mode mode);
void (*ipp_program_input_lut)(
struct transform *xfm_base,
const struct dc_gamma *gamma);
void (*ipp_program_degamma_pwl)(struct transform *xfm_base,
const struct pwl_params *params);
void (*ipp_setup)(
struct transform *xfm_base,
enum surface_pixel_format format,
enum expansion_mode mode,
struct dc_csc_transform input_csc_color_matrix,
enum dc_color_space input_color_space);
void (*ipp_full_bypass)(struct transform *xfm_base);
void (*set_cursor_attributes)(
struct transform *xfm_base,
const struct dc_cursor_attributes *attr);
};
const uint16_t *get_filter_2tap_16p(void);
const uint16_t *get_filter_2tap_64p(void);
const uint16_t *get_filter_3tap_16p(struct fixed31_32 ratio);
const uint16_t *get_filter_3tap_64p(struct fixed31_32 ratio);
const uint16_t *get_filter_4tap_16p(struct fixed31_32 ratio);
const uint16_t *get_filter_4tap_64p(struct fixed31_32 ratio);
const uint16_t *get_filter_5tap_64p(struct fixed31_32 ratio);
const uint16_t *get_filter_6tap_64p(struct fixed31_32 ratio);
const uint16_t *get_filter_7tap_64p(struct fixed31_32 ratio);
const uint16_t *get_filter_8tap_64p(struct fixed31_32 ratio);
/* Defines the pixel processing capability of the DSCL */
enum dscl_data_processing_format {
DSCL_DATA_PRCESSING_FIXED_FORMAT, /* The DSCL processes pixel data in fixed format */
DSCL_DATA_PRCESSING_FLOAT_FORMAT, /* The DSCL processes pixel data in float format */
};
/*
* The DPP capabilities structure contains enumerations to specify the
* HW processing features and an associated function pointers to
* provide the function interface that can be overloaded for implementations
* based on different capabilities
*/
struct dpp_caps {
/* DSCL processing pixel data in fixed or float format */
enum dscl_data_processing_format dscl_data_proc_format;
/* max LB partitions */
unsigned int max_lb_partitions;
/* Calculates the number of partitions in the line buffer.
* The implementation of this function is overloaded for
* different versions of DSCL LB.
*/
void (*dscl_calc_lb_num_partitions)(
const struct scaler_data *scl_data,
enum lb_memory_config lb_config,
int *num_part_y,
int *num_part_c);
};
#endif
@@ -0,0 +1,50 @@
/*
* Copyright 2018 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef DAL_DC_INC_HW_VMID_H_
#define DAL_DC_INC_HW_VMID_H_
#include "core_types.h"
#include "dchubbub.h"
struct dcn_vmid_registers {
uint32_t CNTL;
uint32_t PAGE_TABLE_BASE_ADDR_HI32;
uint32_t PAGE_TABLE_BASE_ADDR_LO32;
uint32_t PAGE_TABLE_START_ADDR_HI32;
uint32_t PAGE_TABLE_START_ADDR_LO32;
uint32_t PAGE_TABLE_END_ADDR_HI32;
uint32_t PAGE_TABLE_END_ADDR_LO32;
};
struct dcn_vmid_page_table_config {
uint64_t page_table_start_addr;
uint64_t page_table_end_addr;
enum dcn_hubbub_page_table_depth depth;
enum dcn_hubbub_page_table_block_size block_size;
uint64_t page_table_base_addr;
};
#endif /* DAL_DC_INC_HW_VMID_H_ */
@@ -0,0 +1,53 @@
/*
* Copyright 2024 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*/
#ifndef __DC_VPG_H__
#define __DC_VPG_H__
struct dc_context;
struct dc_info_packet;
struct vpg;
struct vpg_funcs {
void (*update_generic_info_packet)(
struct vpg *vpg,
uint32_t packet_index,
const struct dc_info_packet *info_packet,
bool immediate_update);
void (*vpg_poweron)(
struct vpg *vpg);
void (*vpg_powerdown)(
struct vpg *vpg);
};
struct vpg {
const struct vpg_funcs *funcs;
struct dc_context *ctx;
int inst;
};
#endif /* DC_INC_VPG_H_ */
@@ -0,0 +1,120 @@
/*
* Copyright 2021 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef DC_INC_LINK_ENC_CFG_H_
#define DC_INC_LINK_ENC_CFG_H_
/* This module implements functionality for dynamically assigning DIG link
* encoder resources to display endpoints (links).
*/
#include "core_types.h"
/*
* Initialise link encoder resource tracking.
*/
void link_enc_cfg_init(
const struct dc *dc,
struct dc_state *state);
/*
* Copies a link encoder assignment from another state.
*/
void link_enc_cfg_copy(const struct dc_state *src_ctx, struct dc_state *dst_ctx);
/*
* Algorithm for assigning available DIG link encoders to streams.
*
* Update link_enc_assignments table and link_enc_avail list accordingly in
* struct resource_context.
*
* Loop over all streams twice:
* a) First assign encoders to unmappable endpoints.
* b) Then assign encoders to mappable endpoints.
*/
void link_enc_cfg_link_encs_assign(
struct dc *dc,
struct dc_state *state,
struct dc_stream_state *streams[],
uint8_t stream_count);
/*
* Unassign a link encoder from a stream.
*
* Update link_enc_assignments table and link_enc_avail list accordingly in
* struct resource_context.
*/
void link_enc_cfg_link_enc_unassign(
struct dc_state *state,
struct dc_stream_state *stream);
/*
* Check whether the transmitter driven by a link encoder is a mappable
* endpoint.
*/
bool link_enc_cfg_is_transmitter_mappable(
struct dc *dc,
struct link_encoder *link_enc);
/* Return stream using DIG link encoder resource. NULL if unused. */
struct dc_stream_state *link_enc_cfg_get_stream_using_link_enc(
struct dc *dc,
enum engine_id eng_id);
/* Return link using DIG link encoder resource. NULL if unused. */
struct dc_link *link_enc_cfg_get_link_using_link_enc(
struct dc *dc,
enum engine_id eng_id);
/* Return DIG link encoder used by link. NULL if unused. */
struct link_encoder *link_enc_cfg_get_link_enc_used_by_link(
struct dc *dc,
const struct dc_link *link);
/* Return next available DIG link encoder. NULL if none available. */
struct link_encoder *link_enc_cfg_get_next_avail_link_enc(struct dc *dc);
/* Return DIG link encoder. NULL if unused. */
struct link_encoder *link_enc_cfg_get_link_enc(const struct dc_link *link);
/* Return DIG link encoder used by stream in current/previous state. NULL if unused. */
struct link_encoder *link_enc_cfg_get_link_enc_used_by_stream_current(
struct dc *dc,
const struct dc_stream_state *stream);
/* Return true if encoder available to use. */
bool link_enc_cfg_is_link_enc_avail(struct dc *dc, enum engine_id eng_id, struct dc_link *link);
/* Returns true if encoder assignments in supplied state pass validity checks. */
bool link_enc_cfg_validate(struct dc *dc, struct dc_state *state);
/* Set the link encoder assignment mode for the current_state to LINK_ENC_CFG_TRANSIENT mode.
* This indicates that a new_state is in the process of being applied to hardware.
* During this transition, old and new encoder assignments should be accessible from the old_state.
* Only allow transition into transient mode if new encoder assignments are valid.
*/
void link_enc_cfg_set_transient_mode(struct dc *dc, struct dc_state *current_state, struct dc_state *new_state);
#endif /* DC_INC_LINK_ENC_CFG_H_ */
@@ -0,0 +1,89 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_LINK_HWSS_H__
#define __DC_LINK_HWSS_H__
/* include basic type headers only */
#include "dc_dp_types.h"
#include "signal_types.h"
#include "grph_object_id.h"
#include "fixed31_32.h"
/* forward declare dc core types */
struct dc_link;
struct link_resource;
struct pipe_ctx;
struct encoder_set_dp_phy_pattern_param;
struct link_mst_stream_allocation_table;
struct audio_output;
struct link_hwss_ext {
/* function pointers below may require to check for NULL if caller
* considers missing implementation as expected in some cases or none
* critical to be investigated immediately
* *********************************************************************
*/
void (*set_hblank_min_symbol_width)(struct pipe_ctx *pipe_ctx,
const struct dc_link_settings *link_settings,
struct fixed31_32 throttled_vcp_size);
void (*set_throttled_vcp_size)(struct pipe_ctx *pipe_ctx,
struct fixed31_32 throttled_vcp_size);
void (*enable_dp_link_output)(struct dc_link *link,
const struct link_resource *link_res,
enum signal_type signal,
enum clock_source_id clock_source,
const struct dc_link_settings *link_settings);
void (*set_dp_link_test_pattern)(struct dc_link *link,
const struct link_resource *link_res,
struct encoder_set_dp_phy_pattern_param *tp_params);
void (*set_dp_lane_settings)(struct dc_link *link,
const struct link_resource *link_res,
const struct dc_link_settings *link_settings,
const struct dc_lane_settings lane_settings[LANE_COUNT_DP_MAX]);
void (*update_stream_allocation_table)(struct dc_link *link,
const struct link_resource *link_res,
const struct link_mst_stream_allocation_table *table);
};
struct link_hwss {
struct link_hwss_ext ext;
/* function pointers below MUST be assigned to all types of link_hwss
* *********************************************************************
*/
void (*setup_stream_encoder)(struct pipe_ctx *pipe_ctx);
void (*reset_stream_encoder)(struct pipe_ctx *pipe_ctx);
void (*setup_stream_attribute)(struct pipe_ctx *pipe_ctx);
void (*disable_link_output)(struct dc_link *link,
const struct link_resource *link_res,
enum signal_type signal);
void (*setup_audio_output)(struct pipe_ctx *pipe_ctx,
struct audio_output *audio_output, uint32_t audio_inst);
void (*enable_audio_packet)(struct pipe_ctx *pipe_ctx);
void (*disable_audio_packet)(struct pipe_ctx *pipe_ctx);
};
#endif /* __DC_LINK_HWSS_H__ */
@@ -0,0 +1,366 @@
/*
* Copyright 2022 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef __DC_LINK_H__
#define __DC_LINK_H__
/* FILE POLICY AND INTENDED USAGE:
*
* This header defines link component function interfaces aka link_service.
* link_service provides the only entry point to link functions with function
* pointer style. This header is strictly private in dc and should never be
* included by DM because it exposes too much dc detail including all dc
* private types defined in core_types.h. Otherwise it will break DM - DC
* encapsulation and turn DM into a maintenance nightmare.
*
* The following shows a link component relation map.
*
* DM to DC:
* DM includes dc.h
* dc_link_exports.c or other dc files implement dc.h
*
* DC to Link:
* dc_link_exports.c or other dc files include link_service.h
* link_factory.c implements link_service.h
*
* Link sub-component to Link sub-component:
* link_factory.c includes --> link_xxx.h
* link_xxx.c implements link_xxx.h
* As you can see if you ever need to add a new dc link function and call it on
* DM/dc side, it is very difficult because you will need layers of translation.
* The most appropriate approach to implement new requirements on DM/dc side is
* to extend or generalize the functionality of existing link function
* interfaces so minimal modification is needed outside link component to
* achieve your new requirements. This approach reduces or even eliminates the
* effort needed outside link component to support a new link feature. This also
* reduces code discrepancy among DMs to support the same link feature. If we
* test full code path on one version of DM, and there is no feature specific
* modification required on other DMs, then we can have higher confidence that
* the feature will run on other DMs and produce the same result. The following
* are some good examples to start with:
*
* - detect_link --> to add new link detection or capability retrieval routines
*
* - validate_mode_timing --> to add new timing validation conditions
*
* - set_dpms_on/set_dpms_off --> to include new link enablement sequences
*
* If you must add new link functions, you will need to:
* 1. declare the function pointer here under the suitable commented category.
* 2. Implement your function in the suitable link_xxx.c file.
* 3. Assign the function to link_service in link_factory.c
* 4. NEVER include link_xxx.h headers outside link component.
* 5. NEVER include link_service.h on DM side.
*/
#include "core_types.h"
struct link_service *link_create_link_service(void);
void link_destroy_link_service(struct link_service **link_srv);
struct link_init_data {
const struct dc *dc;
struct dc_context *ctx; /* TODO: remove 'dal' when DC is complete. */
uint32_t connector_index; /* this will be mapped to the HPD pins */
uint32_t link_index; /* this is mapped to DAL display_index
TODO: remove it when DC is complete. */
bool is_dpia_link;
};
struct ddc_service_init_data {
struct graphics_object_id id;
struct dc_context *ctx;
struct dc_link *link;
bool is_dpia_link;
};
struct link_service {
/************************** Factory ***********************************/
struct dc_link *(*create_link)(
const struct link_init_data *init_params);
void (*destroy_link)(struct dc_link **link);
/************************** Detection *********************************/
bool (*detect_link)(struct dc_link *link, enum dc_detect_reason reason);
bool (*detect_connection_type)(struct dc_link *link,
enum dc_connection_type *type);
struct dc_sink *(*add_remote_sink)(
struct dc_link *link,
const uint8_t *edid,
unsigned int len,
struct dc_sink_init_data *init_data);
void (*remove_remote_sink)(struct dc_link *link, struct dc_sink *sink);
bool (*get_hpd_state)(struct dc_link *link);
void (*enable_hpd)(const struct dc_link *link);
void (*disable_hpd)(const struct dc_link *link);
void (*enable_hpd_filter)(struct dc_link *link, bool enable);
bool (*reset_cur_dp_mst_topology)(struct dc_link *link);
const struct dc_link_status *(*get_status)(const struct dc_link *link);
bool (*is_hdcp1x_supported)(struct dc_link *link,
enum signal_type signal);
bool (*is_hdcp2x_supported)(struct dc_link *link,
enum signal_type signal);
void (*clear_dprx_states)(struct dc_link *link);
/*************************** Resource *********************************/
void (*get_cur_res_map)(const struct dc *dc, uint32_t *map);
void (*restore_res_map)(const struct dc *dc, uint32_t *map);
void (*get_cur_link_res)(const struct dc_link *link,
struct link_resource *link_res);
/*************************** Validation *******************************/
enum dc_status (*validate_mode_timing)(
const struct dc_stream_state *stream,
struct dc_link *link,
const struct dc_crtc_timing *timing);
uint32_t (*dp_link_bandwidth_kbps)(
const struct dc_link *link,
const struct dc_link_settings *link_settings);
enum dc_status (*validate_dp_tunnel_bandwidth)(
const struct dc *dc,
const struct dc_state *new_ctx);
uint32_t (*frl_link_bandwidth_kbps)(enum hdmi_frl_link_rate link_rate);
bool (*frl_margin_check_uncompressed_video)(
struct frl_cap_chk_params_fixed31_32 *params,
struct frl_cap_chk_intermediates_fixed31_32 *inter);
uint32_t (*dp_required_hblank_size_bytes)(
const struct dc_link *link,
struct dp_audio_bandwidth_params *audio_params);
/*************************** DPMS *************************************/
void (*set_dpms_on)(struct dc_state *state, struct pipe_ctx *pipe_ctx);
void (*set_dpms_off)(struct pipe_ctx *pipe_ctx);
void (*resume)(struct dc_link *link);
void (*blank_all_dp_displays)(struct dc *dc);
void (*blank_all_edp_displays)(struct dc *dc);
void (*blank_dp_stream)(struct dc_link *link, bool hw_init);
enum dc_status (*increase_mst_payload)(
struct pipe_ctx *pipe_ctx, uint32_t req_pbn);
enum dc_status (*reduce_mst_payload)(
struct pipe_ctx *pipe_ctx, uint32_t req_pbn);
void (*set_dsc_on_stream)(struct pipe_ctx *pipe_ctx, bool enable);
bool (*set_dsc_enable)(struct pipe_ctx *pipe_ctx, bool enable);
bool (*update_dsc_config)(struct pipe_ctx *pipe_ctx);
void (*wait_for_unlocked)(struct dc_link *link);
/*************************** DDC **************************************/
struct ddc_service *(*create_ddc_service)(
struct ddc_service_init_data *ddc_init_data);
void (*destroy_ddc_service)(struct ddc_service **ddc);
bool (*query_ddc_data)(
struct ddc_service *ddc,
uint32_t address,
uint8_t *write_buf,
uint32_t write_size,
uint8_t *read_buf,
uint32_t read_size);
int (*aux_transfer_raw)(struct ddc_service *ddc,
struct aux_payload *payload,
enum aux_return_code_type *operation_result);
bool (*configure_fixed_vs_pe_retimer)(
struct ddc_service *ddc,
const uint8_t *data,
uint32_t len);
bool (*aux_transfer_with_retries_no_mutex)(struct ddc_service *ddc,
struct aux_payload *payload);
bool (*is_in_aux_transaction_mode)(struct ddc_service *ddc);
uint32_t (*get_aux_defer_delay)(struct ddc_service *ddc);
/*************************** DP Capability ****************************/
bool (*dp_is_sink_present)(struct dc_link *link);
bool (*dp_is_fec_supported)(const struct dc_link *link);
bool (*dp_is_128b_132b_signal)(struct pipe_ctx *pipe_ctx);
bool (*dp_get_max_link_enc_cap)(const struct dc_link *link,
struct dc_link_settings *max_link_enc_cap);
const struct dc_link_settings *(*dp_get_verified_link_cap)(
const struct dc_link *link);
enum dp_link_encoding (*dp_get_encoding_format)(
const struct dc_link_settings *link_settings);
bool (*dp_should_enable_fec)(const struct dc_link *link);
bool (*dp_decide_link_settings)(
struct dc_stream_state *stream,
struct dc_link_settings *link_setting);
void (*dp_decide_tunnel_settings)(
struct dc_stream_state *stream,
struct dc_tunnel_settings *dp_tunnel_setting);
enum dp_link_encoding (*mst_decide_link_encoding_format)(
const struct dc_link *link);
bool (*edp_decide_link_settings)(struct dc_link *link,
struct dc_link_settings *link_setting, uint32_t req_bw);
uint32_t (*bw_kbps_from_raw_frl_link_rate_data)(uint8_t bw);
bool (*dp_overwrite_extended_receiver_cap)(struct dc_link *link);
enum lttpr_mode (*dp_decide_lttpr_mode)(struct dc_link *link,
struct dc_link_settings *link_setting);
uint8_t (*dp_get_lttpr_count)(struct dc_link *link);
void (*edp_get_alpm_support)(struct dc_link *link,
bool *auxless_support,
bool *auxwake_support);
/*************************** DP DPIA/PHY ******************************/
void (*dpia_handle_usb4_bandwidth_allocation_for_link)(
struct dc_link *link, int peak_bw);
void (*dp_set_drive_settings)(
struct dc_link *link,
const struct link_resource *link_res,
struct link_training_settings *lt_settings);
void (*dpcd_write_rx_power_ctrl)(struct dc_link *link, bool on);
/*************************** DP IRQ Handler ***************************/
bool (*dp_parse_link_loss_status)(
struct dc_link *link,
union hpd_irq_data *hpd_irq_dpcd_data);
bool (*dp_should_allow_hpd_rx_irq)(const struct dc_link *link);
void (*dp_handle_link_loss)(struct dc_link *link);
enum dc_status (*dp_read_hpd_rx_irq_data)(
struct dc_link *link,
union hpd_irq_data *irq_data);
bool (*dp_handle_hpd_rx_irq)(struct dc_link *link,
union hpd_irq_data *out_hpd_irq_dpcd_data,
bool *out_link_loss,
bool defer_handling, bool *has_left_work);
/*************************** eDP Panel Control ************************/
void (*edp_panel_backlight_power_on)(
struct dc_link *link, bool wait_for_hpd);
int (*edp_get_backlight_level)(const struct dc_link *link);
bool (*edp_get_backlight_level_nits)(struct dc_link *link,
uint32_t *backlight_millinits_avg,
uint32_t *backlight_millinits_peak);
bool (*edp_set_backlight_level)(const struct dc_link *link,
struct set_backlight_level_params *backlight_level_params);
bool (*edp_set_backlight_level_nits)(struct dc_link *link,
bool isHDR,
uint32_t backlight_millinits,
uint32_t transition_time_in_ms);
int (*edp_get_target_backlight_pwm)(const struct dc_link *link);
bool (*edp_get_psr_state)(
const struct dc_link *link, enum dc_psr_state *state);
bool (*edp_set_psr_allow_active)(
struct dc_link *link,
const bool *allow_active,
bool wait,
bool force_static,
const unsigned int *power_opts);
bool (*edp_setup_psr)(struct dc_link *link,
const struct dc_stream_state *stream,
struct psr_config *psr_config,
struct psr_context *psr_context);
bool (*edp_set_sink_vtotal_in_psr_active)(
const struct dc_link *link,
uint16_t psr_vtotal_idle,
uint16_t psr_vtotal_su);
void (*edp_get_psr_residency)(
const struct dc_link *link, uint32_t *residency, enum psr_residency_mode mode);
bool (*edp_get_replay_state)(
const struct dc_link *link, uint64_t *state);
bool (*edp_set_replay_allow_active)(struct dc_link *dc_link,
const bool *enable, bool wait, bool force_static,
const unsigned int *power_opts);
bool (*edp_send_replay_cmd)(struct dc_link *link,
enum replay_FW_Message_type msg,
union dmub_replay_cmd_set *cmd_data);
bool (*edp_set_coasting_vtotal)(
struct dc_link *link, uint32_t coasting_vtotal, uint16_t frame_skip_number);
bool (*edp_replay_residency)(const struct dc_link *link,
unsigned int *residency, const bool is_start,
const enum pr_residency_mode mode);
bool (*edp_set_replay_power_opt_and_coasting_vtotal)(struct dc_link *link,
const unsigned int *power_opts, uint32_t coasting_vtotal, uint16_t frame_skip_number);
bool (*edp_wait_for_t12)(struct dc_link *link);
bool (*edp_is_ilr_optimization_required)(struct dc_link *link,
struct dc_crtc_timing *crtc_timing);
bool (*edp_backlight_enable_aux)(struct dc_link *link, bool enable);
void (*edp_add_delay_for_T9)(struct dc_link *link);
bool (*edp_receiver_ready_T9)(struct dc_link *link);
bool (*edp_receiver_ready_T7)(struct dc_link *link);
bool (*edp_power_alpm_dpcd_enable)(struct dc_link *link, bool enable);
bool (*dp_setup_replay)(struct dc_link *link, const struct dc_stream_state *stream);
bool (*dp_pr_get_panel_inst)(const struct dc *dc, const struct dc_link *link, unsigned int *inst_out);
bool (*dp_pr_enable)(struct dc_link *link, bool enable);
bool (*dp_pr_update_state)(struct dc_link *link, struct dmub_cmd_pr_update_state_data *update_state_data);
bool (*dp_pr_set_general_cmd)(struct dc_link *link, struct dmub_cmd_pr_general_cmd_data *general_cmd_data);
bool (*dp_pr_get_state)(const struct dc_link *link, uint64_t *state);
void (*edp_set_panel_power)(struct dc_link *link, bool powerOn);
/*************************** HDMI FRL *********************************/
bool (*hdmi_frl_poll_status_flag)(struct dc_link *link);
struct dc_hdmi_frl_link_settings *(*hdmi_frl_get_verified_link_cap)(
struct dc_link *link);
void (*hdmi_frl_set_preferred_link_settings)(struct dc *dc,
struct dc_hdmi_frl_link_settings *link_setting,
struct dc_hdmi_frl_link_training_overrides *lt_overrides,
struct dc_link *link);
/*************************** DP CTS ************************************/
void (*dp_handle_automated_test)(struct dc_link *link);
bool (*dp_set_test_pattern)(
struct dc_link *link,
enum dp_test_pattern test_pattern,
enum dp_test_pattern_color_space test_pattern_color_space,
const struct link_training_settings *p_link_settings,
const unsigned char *p_custom_pattern,
unsigned int cust_pattern_size);
void (*dp_set_preferred_link_settings)(struct dc *dc,
struct dc_link_settings *link_setting,
struct dc_link *link);
void (*dp_set_preferred_training_settings)(struct dc *dc,
struct dc_link_settings *link_setting,
struct dc_link_training_overrides *lt_overrides,
struct dc_link *link,
bool skip_immediate_retrain);
/*************************** DP Trace *********************************/
bool (*dp_trace_is_initialized)(struct dc_link *link);
void (*dp_trace_set_is_logged_flag)(struct dc_link *link,
bool in_detection,
bool is_logged);
bool (*dp_trace_is_logged)(struct dc_link *link, bool in_detection);
unsigned long long (*dp_trace_get_lt_end_timestamp)(
struct dc_link *link, bool in_detection);
const struct dp_trace_lt_counts *(*dp_trace_get_lt_counts)(
struct dc_link *link, bool in_detection);
unsigned int (*dp_trace_get_link_loss_count)(struct dc_link *link);
void (*dp_trace_set_edp_power_timestamp)(struct dc_link *link,
bool power_up);
uint64_t (*dp_trace_get_edp_poweron_timestamp)(struct dc_link *link);
uint64_t (*dp_trace_get_edp_poweroff_timestamp)(struct dc_link *link);
void (*dp_trace_source_sequence)(
struct dc_link *link, uint8_t dp_test_mode);
};
#endif /* __DC_LINK_HPD_H__ */
@@ -0,0 +1,558 @@
/*
* Copyright 2016 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*/
#ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_REG_HELPER_H_
#define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_REG_HELPER_H_
#include "dm_services.h"
/* macro for register read/write
* user of macro need to define
*
* CTX ==> macro to ptr to dc_context
* eg. aud110->base.ctx
*
* REG ==> macro to location of register offset
* eg. aud110->regs->reg
*/
#define REG_READ(reg_name) \
dm_read_reg(CTX, REG(reg_name))
#define REG_WRITE(reg_name, value) \
dm_write_reg(CTX, REG(reg_name), value)
#ifdef REG_SET
#undef REG_SET
#endif
#ifdef REG_GET
#undef REG_GET
#endif
/* macro to set register fields. */
#define REG_SET_N(reg_name, n, initial_val, ...) \
generic_reg_set_ex(CTX, \
REG(reg_name), \
initial_val, \
n, __VA_ARGS__)
#define FN(reg_name, field) \
FD(reg_name##__##field)
#define REG_SET(reg_name, initial_val, field, val) \
REG_SET_N(reg_name, 1, initial_val, \
FN(reg_name, field), val)
#define REG_SET_2(reg, init_value, f1, v1, f2, v2) \
REG_SET_N(reg, 2, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2)
#define REG_SET_3(reg, init_value, f1, v1, f2, v2, f3, v3) \
REG_SET_N(reg, 3, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3)
#define REG_SET_4(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4) \
REG_SET_N(reg, 4, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3,\
FN(reg, f4), v4)
#define REG_SET_5(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, \
f5, v5) \
REG_SET_N(reg, 5, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3,\
FN(reg, f4), v4,\
FN(reg, f5), v5)
#define REG_SET_6(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, \
f5, v5, f6, v6) \
REG_SET_N(reg, 6, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3,\
FN(reg, f4), v4,\
FN(reg, f5), v5,\
FN(reg, f6), v6)
#define REG_SET_7(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, \
f5, v5, f6, v6, f7, v7) \
REG_SET_N(reg, 7, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3,\
FN(reg, f4), v4,\
FN(reg, f5), v5,\
FN(reg, f6), v6,\
FN(reg, f7), v7)
#define REG_SET_8(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, \
f5, v5, f6, v6, f7, v7, f8, v8) \
REG_SET_N(reg, 8, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2,\
FN(reg, f3), v3,\
FN(reg, f4), v4,\
FN(reg, f5), v5,\
FN(reg, f6), v6,\
FN(reg, f7), v7,\
FN(reg, f8), v8)
#define REG_SET_9(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, f5, \
v5, f6, v6, f7, v7, f8, v8, f9, v9) \
REG_SET_N(reg, 9, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9)
#define REG_SET_10(reg, init_value, f1, v1, f2, v2, f3, v3, f4, v4, f5, \
v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10) \
REG_SET_N(reg, 10, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9, \
FN(reg, f10), v10)
/* macro to get register fields
* read given register and fill in field value in output parameter */
#define REG_GET(reg_name, field, val) \
generic_reg_get(CTX, REG(reg_name), \
FN(reg_name, field), (uint32_t *)val)
#define REG_GET_2(reg_name, f1, v1, f2, v2) \
generic_reg_get2(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2)
#define REG_GET_3(reg_name, f1, v1, f2, v2, f3, v3) \
generic_reg_get3(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3)
#define REG_GET_4(reg_name, f1, v1, f2, v2, f3, v3, f4, v4) \
generic_reg_get4(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3, \
FN(reg_name, f4), (uint32_t *)v4)
#define REG_GET_5(reg_name, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) \
generic_reg_get5(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3, \
FN(reg_name, f4), (uint32_t *)v4, \
FN(reg_name, f5), (uint32_t *)v5)
#define REG_GET_6(reg_name, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) \
generic_reg_get6(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3, \
FN(reg_name, f4), (uint32_t *)v4, \
FN(reg_name, f5), (uint32_t *)v5, \
FN(reg_name, f6), (uint32_t *)v6)
#define REG_GET_7(reg_name, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) \
generic_reg_get7(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3, \
FN(reg_name, f4), (uint32_t *)v4, \
FN(reg_name, f5), (uint32_t *)v5, \
FN(reg_name, f6), (uint32_t *)v6, \
FN(reg_name, f7), (uint32_t *)v7)
#define REG_GET_8(reg_name, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) \
generic_reg_get8(CTX, REG(reg_name), \
FN(reg_name, f1), (uint32_t *)v1, \
FN(reg_name, f2), (uint32_t *)v2, \
FN(reg_name, f3), (uint32_t *)v3, \
FN(reg_name, f4), (uint32_t *)v4, \
FN(reg_name, f5), (uint32_t *)v5, \
FN(reg_name, f6), (uint32_t *)v6, \
FN(reg_name, f7), (uint32_t *)v7, \
FN(reg_name, f8), (uint32_t *)v8)
/* macro to poll and wait for a register field to read back given value */
#define REG_WAIT(reg_name, field, val, delay_between_poll_us, max_try) \
generic_reg_wait(CTX, \
REG(reg_name), FN(reg_name, field), val,\
delay_between_poll_us, max_try, __func__, __LINE__)
/* macro to update (read, modify, write) register fields
*/
#define REG_UPDATE_N(reg_name, n, ...) \
generic_reg_update_ex(CTX, \
REG(reg_name), \
n, __VA_ARGS__)
#define REG_UPDATE(reg_name, field, val) \
REG_UPDATE_N(reg_name, 1, \
FN(reg_name, field), val)
#define REG_UPDATE_2(reg, f1, v1, f2, v2) \
REG_UPDATE_N(reg, 2,\
FN(reg, f1), v1,\
FN(reg, f2), v2)
#define REG_UPDATE_3(reg, f1, v1, f2, v2, f3, v3) \
REG_UPDATE_N(reg, 3, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3)
#define REG_UPDATE_4(reg, f1, v1, f2, v2, f3, v3, f4, v4) \
REG_UPDATE_N(reg, 4, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4)
#define REG_UPDATE_5(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5) \
REG_UPDATE_N(reg, 5, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5)
#define REG_UPDATE_6(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6) \
REG_UPDATE_N(reg, 6, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6)
#define REG_UPDATE_7(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7) \
REG_UPDATE_N(reg, 7, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7)
#define REG_UPDATE_8(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8) \
REG_UPDATE_N(reg, 8, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8)
#define REG_UPDATE_9(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9) \
REG_UPDATE_N(reg, 9, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9)
#define REG_UPDATE_10(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10, v10)\
REG_UPDATE_N(reg, 10, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9, \
FN(reg, f10), v10)
#define REG_UPDATE_14(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10,\
v10, f11, v11, f12, v12, f13, v13, f14, v14)\
REG_UPDATE_N(reg, 14, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9, \
FN(reg, f10), v10, \
FN(reg, f11), v11, \
FN(reg, f12), v12, \
FN(reg, f13), v13, \
FN(reg, f14), v14)
#define REG_UPDATE_19(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10,\
v10, f11, v11, f12, v12, f13, v13, f14, v14, f15, v15, f16, v16, f17, v17, f18, v18, f19, v19)\
REG_UPDATE_N(reg, 19, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9, \
FN(reg, f10), v10, \
FN(reg, f11), v11, \
FN(reg, f12), v12, \
FN(reg, f13), v13, \
FN(reg, f14), v14, \
FN(reg, f15), v15, \
FN(reg, f16), v16, \
FN(reg, f17), v17, \
FN(reg, f18), v18, \
FN(reg, f19), v19)
#define REG_UPDATE_20(reg, f1, v1, f2, v2, f3, v3, f4, v4, f5, v5, f6, v6, f7, v7, f8, v8, f9, v9, f10,\
v10, f11, v11, f12, v12, f13, v13, f14, v14, f15, v15, f16, v16, f17, v17, f18, v18, f19, v19, f20, v20)\
REG_UPDATE_N(reg, 20, \
FN(reg, f1), v1,\
FN(reg, f2), v2, \
FN(reg, f3), v3, \
FN(reg, f4), v4, \
FN(reg, f5), v5, \
FN(reg, f6), v6, \
FN(reg, f7), v7, \
FN(reg, f8), v8, \
FN(reg, f9), v9, \
FN(reg, f10), v10, \
FN(reg, f11), v11, \
FN(reg, f12), v12, \
FN(reg, f13), v13, \
FN(reg, f14), v14, \
FN(reg, f15), v15, \
FN(reg, f16), v16, \
FN(reg, f17), v17, \
FN(reg, f18), v18, \
FN(reg, f19), v19, \
FN(reg, f20), v20)
/* macro to update a register field to specified values in given sequences.
* useful when toggling bits
*/
#define REG_UPDATE_SEQ_2(reg, f1, v1, f2, v2) \
{ uint32_t val = REG_UPDATE(reg, f1, v1); \
REG_SET(reg, val, f2, v2); }
#define REG_UPDATE_SEQ_3(reg, f1, v1, f2, v2, f3, v3) \
{ uint32_t val = REG_UPDATE(reg, f1, v1); \
val = REG_SET(reg, val, f2, v2); \
REG_SET(reg, val, f3, v3); }
uint32_t generic_reg_get(const struct dc_context *ctx, uint32_t addr,
uint8_t shift, uint32_t mask, uint32_t *field_value);
uint32_t generic_reg_get2(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2);
uint32_t generic_reg_get3(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3);
uint32_t generic_reg_get4(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3,
uint8_t shift4, uint32_t mask4, uint32_t *field_value4);
uint32_t generic_reg_get5(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3,
uint8_t shift4, uint32_t mask4, uint32_t *field_value4,
uint8_t shift5, uint32_t mask5, uint32_t *field_value5);
uint32_t generic_reg_get6(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3,
uint8_t shift4, uint32_t mask4, uint32_t *field_value4,
uint8_t shift5, uint32_t mask5, uint32_t *field_value5,
uint8_t shift6, uint32_t mask6, uint32_t *field_value6);
uint32_t generic_reg_get7(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3,
uint8_t shift4, uint32_t mask4, uint32_t *field_value4,
uint8_t shift5, uint32_t mask5, uint32_t *field_value5,
uint8_t shift6, uint32_t mask6, uint32_t *field_value6,
uint8_t shift7, uint32_t mask7, uint32_t *field_value7);
uint32_t generic_reg_get8(const struct dc_context *ctx, uint32_t addr,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
uint8_t shift2, uint32_t mask2, uint32_t *field_value2,
uint8_t shift3, uint32_t mask3, uint32_t *field_value3,
uint8_t shift4, uint32_t mask4, uint32_t *field_value4,
uint8_t shift5, uint32_t mask5, uint32_t *field_value5,
uint8_t shift6, uint32_t mask6, uint32_t *field_value6,
uint8_t shift7, uint32_t mask7, uint32_t *field_value7,
uint8_t shift8, uint32_t mask8, uint32_t *field_value8);
/* indirect register access */
#define IX_REG_SET_N(index_reg_name, data_reg_name, index, n, initial_val, ...) \
generic_indirect_reg_update_ex(CTX, \
REG(index_reg_name), REG(data_reg_name), IND_REG(index), \
initial_val, \
n, __VA_ARGS__)
#define IX_REG_SET_2(index_reg_name, data_reg_name, index, init_value, f1, v1, f2, v2) \
IX_REG_SET_N(index_reg_name, data_reg_name, index, 2, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2)
#define IX_REG_READ(index_reg_name, data_reg_name, index) \
generic_read_indirect_reg(CTX, REG(index_reg_name), REG(data_reg_name), IND_REG(index))
#define IX_REG_GET_N(index_reg_name, data_reg_name, index, n, ...) \
generic_indirect_reg_get(CTX, REG(index_reg_name), REG(data_reg_name), \
IND_REG(index), \
n, __VA_ARGS__)
#define IX_REG_GET(index_reg_name, data_reg_name, index, field, val) \
IX_REG_GET_N(index_reg_name, data_reg_name, index, 1, \
FN(data_reg_name, field), val)
#define IX_REG_UPDATE_N(index_reg_name, data_reg_name, index, n, ...) \
generic_indirect_reg_update_ex(CTX, \
REG(index_reg_name), REG(data_reg_name), IND_REG(index), \
IX_REG_READ(index_reg_name, data_reg_name, index), \
n, __VA_ARGS__)
#define IX_REG_UPDATE_2(index_reg_name, data_reg_name, index, f1, v1, f2, v2) \
IX_REG_UPDATE_N(index_reg_name, data_reg_name, index, 2,\
FN(reg, f1), v1,\
FN(reg, f2), v2)
void generic_write_indirect_reg(const struct dc_context *ctx,
uint32_t addr_index, uint32_t addr_data,
uint32_t index, uint32_t data);
uint32_t generic_read_indirect_reg(const struct dc_context *ctx,
uint32_t addr_index, uint32_t addr_data,
uint32_t index);
uint32_t generic_indirect_reg_get(const struct dc_context *ctx,
uint32_t addr_index, uint32_t addr_data,
uint32_t index, int n,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
...);
uint32_t generic_indirect_reg_update_ex(const struct dc_context *ctx,
uint32_t addr_index, uint32_t addr_data,
uint32_t index, uint32_t reg_val, int n,
uint8_t shift1, uint32_t mask1, uint32_t field_value1,
...);
/* indirect register access
* underlying implementation determines which index/data pair to be used
* in a synchronous way
*/
#define IX_REG_SET_N_SYNC(index, n, initial_val, ...) \
generic_indirect_reg_update_ex_sync(CTX, \
IND_REG(index), \
initial_val, \
n, __VA_ARGS__)
#define IX_REG_SET_SYNC(index, init_value, f1, v1) \
IX_REG_SET_N_SYNC(index, 1, init_value, \
FN(reg, f1), v1)
#define IX_REG_SET_2_SYNC(index, init_value, f1, v1, f2, v2) \
IX_REG_SET_N_SYNC(index, 2, init_value, \
FN(reg, f1), v1,\
FN(reg, f2), v2)
#define IX_REG_GET_N_SYNC(index, n, ...) \
generic_indirect_reg_get_sync(CTX, \
IND_REG(index), \
n, __VA_ARGS__)
#define IX_REG_GET_SYNC(index, field, val) \
IX_REG_GET_N_SYNC(index, 1, \
FN(data_reg_name, field), val)
uint32_t generic_indirect_reg_get_sync(const struct dc_context *ctx,
uint32_t index, int n,
uint8_t shift1, uint32_t mask1, uint32_t *field_value1,
...);
uint32_t generic_indirect_reg_update_ex_sync(const struct dc_context *ctx,
uint32_t index, uint32_t reg_val, int n,
uint8_t shift1, uint32_t mask1, uint32_t field_value1,
...);
/* register offload macros
*
* instead of MMIO to register directly, in some cases we want
* to gather register sequence and execute the register sequence
* from another thread so we optimize time required for lengthy ops
*/
/* start gathering register sequence */
#define REG_SEQ_START() \
reg_sequence_start_gather(CTX)
/* start execution of register sequence gathered since REG_SEQ_START */
#define REG_SEQ_SUBMIT() \
reg_sequence_start_execute(CTX)
/* wait for the last REG_SEQ_SUBMIT to finish */
#define REG_SEQ_WAIT_DONE() \
reg_sequence_wait_done(CTX)
#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_REG_HELPER_H_ */
@@ -0,0 +1,673 @@
/*
* Copyright 2015 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*/
#ifndef DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
#define DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_
#include "core_types.h"
#include "core_status.h"
#include "dal_asic_id.h"
#include "dm_pp_smu.h"
#define MEMORY_TYPE_MULTIPLIER_CZ 4
#define MEMORY_TYPE_HBM 2
#define MAX_MCACHES 8
#define IS_PIPE_SYNCD_VALID(pipe) ((((pipe)->pipe_idx_syncd) & 0x80)?1:0)
#define GET_PIPE_SYNCD_FROM_PIPE(pipe) ((pipe)->pipe_idx_syncd & 0x7F)
#define SET_PIPE_SYNCD_TO_PIPE(pipe, pipe_syncd) ((pipe)->pipe_idx_syncd = (0x80 | pipe_syncd))
enum dce_version resource_parse_asic_id(
struct hw_asic_id asic_id);
struct resource_caps {
int num_timing_generator;
int num_opp;
int num_dpp;
int num_video_plane;
int num_audio;
int num_stream_encoder;
int num_analog_stream_encoder;
int num_pll;
int num_dwb;
int num_ddc;
int num_vmid;
int num_dsc;
unsigned int num_dig_link_enc; // Total number of DIGs (digital encoders) in DIO (Display Input/Output).
unsigned int num_usb4_dpia; // Total number of USB4 DPIA (DisplayPort Input Adapters).
int num_hpo_frl;
int num_hpo_dp_stream_encoder;
int num_hpo_dp_link_encoder;
int num_mpc_3dlut;
int num_mpc;
int num_rmcm;
int num_aux;
};
struct resource_straps {
uint32_t hdmi_disable;
uint32_t dc_pinstraps_audio;
uint32_t audio_stream_number;
};
struct dc_mcache_allocations {
int global_mcache_ids_plane0[MAX_MCACHES + 1];
int global_mcache_ids_plane1[MAX_MCACHES + 1];
int global_mcache_ids_mall_plane0[MAX_MCACHES + 1];
int global_mcache_ids_mall_plane1[MAX_MCACHES + 1];
};
struct resource_create_funcs {
void (*read_dce_straps)(
struct dc_context *ctx, struct resource_straps *straps);
struct audio *(*create_audio)(
struct dc_context *ctx, unsigned int inst);
struct stream_encoder *(*create_stream_encoder)(
enum engine_id eng_id, struct dc_context *ctx);
struct hpo_frl_stream_encoder *(*create_hpo_frl_stream_encoder)(
enum engine_id eng_id, struct dc_context *ctx);
struct hpo_frl_link_encoder *(*create_hpo_frl_link_encoder)(
enum engine_id eng_id, struct dc_context *ctx);
struct hpo_dp_stream_encoder *(*create_hpo_dp_stream_encoder)(
enum engine_id eng_id, struct dc_context *ctx);
struct hpo_dp_link_encoder *(*create_hpo_dp_link_encoder)(
uint8_t inst,
struct dc_context *ctx);
struct dce_hwseq *(*create_hwseq)(
struct dc_context *ctx);
};
bool resource_construct(
unsigned int num_virtual_links,
struct dc *dc,
struct resource_pool *pool,
const struct resource_create_funcs *create_funcs);
struct resource_pool *dc_create_resource_pool(struct dc *dc,
const struct dc_init_data *init_data,
enum dce_version dc_version);
void dc_destroy_resource_pool(struct dc *dc);
enum dc_status resource_map_pool_resources(
const struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream);
void resource_build_test_pattern_params(
struct resource_context *res_ctx,
struct pipe_ctx *pipe_ctx);
bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx);
enum dc_status resource_build_scaling_params_for_context(
const struct dc *dc,
struct dc_state *context);
void resource_build_info_frame(struct pipe_ctx *pipe_ctx);
void resource_unreference_clock_source(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source);
void resource_reference_clock_source(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source);
int resource_get_clock_source_reference(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct clock_source *clock_source);
bool resource_are_streams_timing_synchronizable(
struct dc_stream_state *stream1,
struct dc_stream_state *stream2);
bool resource_are_vblanks_synchronizable(
struct dc_stream_state *stream1,
struct dc_stream_state *stream2);
struct clock_source *resource_find_used_clk_src_for_sharing(
struct resource_context *res_ctx,
struct pipe_ctx *pipe_ctx);
struct clock_source *dc_resource_find_first_free_pll(
struct resource_context *res_ctx,
const struct resource_pool *pool);
bool resource_attach_surfaces_to_context(
struct dc_plane_state *const *plane_state,
int surface_count,
struct dc_stream_state *dc_stream,
struct dc_state *context,
const struct resource_pool *pool);
bool resource_can_pipe_disable_cursor(struct pipe_ctx *pipe_ctx);
#define FREE_PIPE_INDEX_NOT_FOUND -1
/*
* pipe types are identified based on MUXes in DCN front end that are capable
* of taking input from one DCN pipeline to another DCN pipeline. The name is
* in a form of XXXX_YYYY, where XXXX is the DCN front end hardware block the
* pipeline ends with and YYYY is the rendering role that the pipe is in.
*
* For instance OTG_MASTER is a pipe ending with OTG hardware block in its
* pipeline and it is in a role of a master pipe for timing generation.
*
* For quick reference a diagram of each pipe type's areas of responsibility
* for outputting timings on the screen is shown below:
*
* Timing Active for Stream 0
* __________________________________________________
* |OTG master 0 (OPP head 0)|OPP head 2 (DPP pipe 2) |
* | (DPP pipe 0)| |
* | Top Plane 0 | |
* | ______________|____ |
* | |DPP pipe 1 |DPP | |
* | | |pipe| |
* | | Bottom |3 | |
* | | Plane 1 | | |
* | | | | |
* | |______________|____| |
* | | |
* | | |
* | ODM slice 0 | ODM slice 1 |
* |_________________________|________________________|
*
* Timing Active for Stream 1
* __________________________________________________
* |OTG master 4 (OPP head 4) |
* | |
* | |
* | |
* | |
* | |
* | Blank Pixel Data |
* | (generated by DPG4) |
* | |
* | |
* | |
* | |
* | |
* |__________________________________________________|
*
* Inter-pipe Relation
* __________________________________________________
* |PIPE IDX| DPP PIPES | OPP HEADS | OTG MASTER |
* | | plane 0 | slice 0 | |
* | 0 | -------------MPC---------ODM----------- |
* | | plane 1 | | | | |
* | 1 | ------------- | | | |
* | | plane 0 | slice 1 | | |
* | 2 | -------------MPC--------- | |
* | | plane 1 | | | |
* | 3 | ------------- | | |
* | | | blank | |
* | 4 | | ----------------------- |
* | | | | |
* | 5 | (FREE) | | |
* |________|_______________|___________|_____________|
*
* The following is a quick reference of the class relation:
*
* DC state ---1--------0..N--- streams
*
* stream ---1-----------1--- OTG Master pipe
*
* OTG Master pipe ---1--------1..N--- OPP Head pipes
*
* OPP Head pipe ---1--------0..N--- DPP pipes
*
* stream ---1--------0..N--- Planes
*
* Plane ---1--------1..N--- DPP pipes
*
*/
enum pipe_type {
/* free pipe - free pipe is an uninitialized pipe without a stream
* associated with it. It is a free DCN pipe resource. It can be
* acquired as any type of pipe.
*/
FREE_PIPE,
/* OTG master pipe - the master pipe of its OPP head pipes with a
* functional OTG. It merges all its OPP head pipes pixel data in ODM
* block and output to back end DIG. OTG master pipe is responsible for
* generating entire CRTC timing to back end DIG. An OTG master pipe may
* or may not have a plane. If it has a plane it blends it as the left
* most MPC slice of the top most layer. If it doesn't have a plane it
* can output pixel data from its OPP head pipes' test pattern
* generators (DPG) such as solid black pixel data to blank the screen.
*/
OTG_MASTER,
/* OPP head pipe - the head pipe of an MPC blending tree with a
* functional OPP outputting to an OTG. OPP head pipe is responsible for
* processing output pixels in its own ODM slice. It may or may not have
* a plane. If it has a plane it blends it as the top most layer within
* its own ODM slice. If it doesn't have a plane it can output pixel
* data from its DPG such as solid black pixel data to blank the pixel
* data in its own ODM slice. OTG master pipe is also an OPP head pipe
* but with more responsibility.
*/
OPP_HEAD,
/* DPP pipe - the pipe with a functional DPP outputting to an OPP head
* pipe's MPC. DPP pipe is responsible for processing pixel data from
* its own MPC slice of a plane. It must be connected to an OPP head
* pipe and it must have a plane associated with it.
*/
DPP_PIPE,
};
/*
* Determine if the input pipe_ctx is of a pipe type.
* return - true if pipe_ctx is of the input type.
*/
bool resource_is_pipe_type(const struct pipe_ctx *pipe_ctx, enum pipe_type type);
/*
* Acquire a pipe as OTG master pipe and allocate pipe resources required to
* enable stream output.
*/
enum dc_status resource_add_otg_master_for_stream_output(struct dc_state *new_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream);
/*
* Release pipe resources and the OTG master pipe associated with the stream
* The stream must have all planes removed and ODM/MPC slice counts are reset
* to 1 before invoking this interface.
*/
void resource_remove_otg_master_for_stream_output(struct dc_state *new_ctx,
const struct resource_pool *pool,
struct dc_stream_state *stream);
/*
* Add plane to the bottom most layer in plane composition and allocate DPP pipe
* resources as needed.
* return - true if plane is added in plane composition, false otherwise.
*/
bool resource_append_dpp_pipes_for_plane_composition(
struct dc_state *new_ctx,
struct dc_state *cur_ctx,
struct resource_pool *pool,
struct pipe_ctx *otg_master_pipe,
struct dc_plane_state *plane_state);
/*
* Add plane to the bottom most layer in plane composition and allocate DPP pipe
* resources as needed.
* return - true if plane is added in plane composition, false otherwise.
*/
void resource_remove_dpp_pipes_for_plane_composition(
struct dc_state *context,
const struct resource_pool *pool,
const struct dc_plane_state *plane_state);
/*
* Update ODM slice count by acquiring or releasing pipes. If new slices need
* to be added, it is going to add them to the last ODM index. If existing
* slices need to be removed, it is going to remove them from the last ODM
* index.
*
* return - true if ODM slices are updated and required pipes are acquired. All
* affected pipe parameters are updated.
*
* false if resource fails to complete this update. The function is not designed
* to recover the creation of invalid topologies. Returning false is typically
* an indication of insufficient validation in caller's stack. new_ctx will be
* invalid. Caller may attempt to restore new_ctx by calling this function
* again with original slice count.
*/
bool resource_update_pipes_for_stream_with_slice_count(
struct dc_state *new_ctx,
const struct dc_state *cur_ctx,
const struct resource_pool *pool,
const struct dc_stream_state *stream,
int new_slice_count);
/*
* Update MPC slice count by acquiring or releasing DPP pipes. If new slices
* need to be added it is going to add to the last MPC index. If existing
* slices need to be removed, it is going to remove them from the last MPC
* index.
*
* @dpp_pipe - top most dpp pipe for MPCC combine.
*
* return - true if MPC slices are updated and required pipes are acquired. All
* affected pipe parameters are updated.
*
* false if resource fails to complete this update. The function is not designed
* to recover the creation of invalid topologies. Returning false is typically
* an indication of insufficient validation in caller's stack. new_ctx will be
* invalid. Caller may attempt to restore new_ctx by calling this function
* again with original slice count.
*/
bool resource_update_pipes_for_plane_with_slice_count(
struct dc_state *new_ctx,
const struct dc_state *cur_ctx,
const struct resource_pool *pool,
const struct dc_plane_state *plane,
int slice_count);
/*
* Get the OTG master pipe in resource context associated with the stream.
* return - NULL if not found. Otherwise the OTG master pipe associated with the
* stream.
*/
struct pipe_ctx *resource_get_otg_master_for_stream(
struct resource_context *res_ctx,
const struct dc_stream_state *stream);
/*
* Get an array of OPP heads in opp_heads ordered with index low to high for OTG
* master pipe in res_ctx.
* return - number of OPP heads in the array. If otg_master passed in is not
* an OTG master, the function returns 0.
*/
int resource_get_opp_heads_for_otg_master(const struct pipe_ctx *otg_master,
struct resource_context *res_ctx,
struct pipe_ctx *opp_heads[MAX_PIPES]);
/*
* Get an array of DPP pipes in dpp_pipes ordered with index low to high for OPP
* head pipe in res_ctx.
* return - number of DPP pipes in the array. If opp_head passed in is not
* an OPP pipe, the function returns 0.
*/
int resource_get_dpp_pipes_for_opp_head(const struct pipe_ctx *opp_head,
struct resource_context *res_ctx,
struct pipe_ctx *dpp_pipes[MAX_PIPES]);
/*
* Get an array of DPP pipes in dpp_pipes ordered with index low to high for
* plane in res_ctx.
* return - number of DPP pipes in the array.
*/
int resource_get_dpp_pipes_for_plane(const struct dc_plane_state *plane,
struct resource_context *res_ctx,
struct pipe_ctx *dpp_pipes[MAX_PIPES]);
/*
* Get the OTG master pipe for the input pipe context.
* return - the OTG master pipe for the input pipe
* context.
*/
struct pipe_ctx *resource_get_otg_master(const struct pipe_ctx *pipe_ctx);
/*
* Get the OPP head pipe for the input pipe context.
* return - the OPP head pipe for the input pipe
* context.
*/
struct pipe_ctx *resource_get_opp_head(const struct pipe_ctx *pipe_ctx);
/*
* Get the DPP pipe allocated for MPC slice 0 and ODM slice 0 of the plane
* associated with dpp_pipe.
*/
struct pipe_ctx *resource_get_primary_dpp_pipe(const struct pipe_ctx *dpp_pipe);
/*
* Get the MPC slice index counting from 0 from left most slice
* For example, if a DPP pipe is used as a secondary pipe in MPCC combine, MPC
* split index is greater than 0.
*/
int resource_get_mpc_slice_index(const struct pipe_ctx *dpp_pipe);
/*
* Get the number of MPC slices associated with the pipe.
* The function returns 0 if the pipe is not associated with an MPC combine
* pipe topology.
*/
int resource_get_mpc_slice_count(const struct pipe_ctx *pipe);
/*
* Get the number of ODM slices associated with the pipe.
* The function returns 0 if the pipe is not associated with an ODM combine
* pipe topology.
*/
int resource_get_odm_slice_count(const struct pipe_ctx *pipe);
/* Get the ODM slice index counting from 0 from left most slice */
int resource_get_odm_slice_index(const struct pipe_ctx *opp_head);
/* Get ODM slice source rect in timing active as input to OPP block */
struct rect resource_get_odm_slice_src_rect(struct pipe_ctx *pipe_ctx);
/* Get ODM slice destination rect in timing active as output from OPP block */
struct rect resource_get_odm_slice_dst_rect(struct pipe_ctx *pipe_ctx);
/* Get ODM slice destination width in timing active as output from OPP block */
int resource_get_odm_slice_dst_width(struct pipe_ctx *otg_master,
bool is_last_segment);
/* determine if pipe topology is changed between state a and state b */
bool resource_is_pipe_topology_changed(const struct dc_state *state_a,
const struct dc_state *state_b);
/*
* determine if the two OTG master pipes have the same ODM topology
* return
* false - if pipes passed in are not OTG masters or ODM topology is
* changed.
* true - otherwise
*/
bool resource_is_odm_topology_changed(const struct pipe_ctx *otg_master_a,
const struct pipe_ctx *otg_master_b);
/* log the pipe topology update in state */
void resource_log_pipe_topology_update(struct dc *dc, struct dc_state *state);
/*
* Look for a free pipe in new resource context that is used as a secondary OPP
* head by cur_otg_master.
*
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int resource_find_free_pipe_used_as_sec_opp_head_by_cur_otg_master(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct pipe_ctx *cur_otg_master);
/*
* Look for a free pipe in new resource context that is used as a secondary DPP
* pipe in MPC blending tree associated with input OPP head pipe.
*
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int resource_find_free_pipe_used_in_cur_mpc_blending_tree(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct pipe_ctx *cur_opp_head);
/*
* Look for a free pipe in new resource context that is not used in current
* resource context.
*
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int recource_find_free_pipe_not_used_in_cur_res_ctx(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct resource_pool *pool);
/*
* Look for a free pipe in new resource context that is used in current resource
* context as an OTG master pipe.
*
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int recource_find_free_pipe_used_as_otg_master_in_cur_res_ctx(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct resource_pool *pool);
/*
* Look for a free pipe in new resource context that is used as a secondary DPP
* pipe in current resource context.
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int resource_find_free_pipe_used_as_cur_sec_dpp(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct resource_pool *pool);
/*
* Look for a free pipe in new resource context that is used as a secondary DPP
* pipe in any MPCC combine in current resource context.
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int resource_find_free_pipe_used_as_cur_sec_dpp_in_mpcc_combine(
const struct resource_context *cur_res_ctx,
struct resource_context *new_res_ctx,
const struct resource_pool *pool);
/*
* Look for any free pipe in new resource context.
* return - FREE_PIPE_INDEX_NOT_FOUND if free pipe is not found, otherwise
* pipe idx of the free pipe
*/
int resource_find_any_free_pipe(struct resource_context *new_res_ctx,
const struct resource_pool *pool);
/*
* Legacy find free secondary pipe logic deprecated for newer DCNs as it doesn't
* find the most optimal free pipe to prevent from time consuming hardware state
* transitions.
*/
struct pipe_ctx *resource_find_free_secondary_pipe_legacy(
struct resource_context *res_ctx,
const struct resource_pool *pool,
const struct pipe_ctx *primary_pipe);
bool resource_validate_attach_surfaces(
const struct dc_validation_set set[],
int set_count,
const struct dc_state *old_context,
struct dc_state *context,
const struct resource_pool *pool);
enum dc_status resource_map_clock_resources(
const struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream);
enum dc_status resource_map_phy_clock_resources(
const struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream);
bool pipe_need_reprogram(
struct pipe_ctx *pipe_ctx_old,
struct pipe_ctx *pipe_ctx);
void resource_build_bit_depth_reduction_params(struct dc_stream_state *stream,
struct bit_depth_reduction_params *fmt_bit_depth);
void update_audio_usage(
struct resource_context *res_ctx,
const struct resource_pool *pool,
struct audio *audio,
bool acquired);
unsigned int resource_pixel_format_to_bpp(enum surface_pixel_format format);
bool get_temp_dp_link_res(struct dc_link *link,
struct link_resource *link_res,
struct dc_link_settings *link_settings);
bool get_temp_frl_link_res(struct dc_link *link,
struct link_resource *link_res);
void reset_syncd_pipes_from_disabled_pipes(struct dc *dc,
struct dc_state *context);
void check_syncd_pipes_for_disabled_master_pipe(struct dc *dc,
struct dc_state *context,
uint8_t disabled_master_pipe_idx);
void reset_sync_context_for_pipe(const struct dc *dc,
struct dc_state *context,
uint8_t pipe_idx);
uint8_t resource_transmitter_to_phy_idx(const struct dc *dc, enum transmitter transmitter);
const struct link_hwss *get_link_hwss(const struct dc_link *link,
const struct link_resource *link_res);
bool is_h_timing_divisible_by_2(struct dc_stream_state *stream);
bool dc_resource_acquire_secondary_pipe_for_mpc_odm_legacy(
const struct dc *dc,
struct dc_state *state,
struct pipe_ctx *pri_pipe,
struct pipe_ctx *sec_pipe,
bool odm);
/* A test harness interface that modifies dp encoder resources in the given dc
* state and bypasses the need to revalidate. The interface assumes that the
* test harness interface is called with pre-validated link config stored in the
* pipe_ctx and updates dp encoder resources according to the link config.
*/
enum dc_status update_dp_encoder_resources_for_test_harness(const struct dc *dc,
struct dc_state *context,
struct pipe_ctx *pipe_ctx);
/* Get hw programming parameters container from pipe context
* @pipe_ctx: pipe context
* @dscl_prog_data: struct to hold programmable hw reg values
*/
struct dscl_prog_data *resource_get_dscl_prog_data(struct pipe_ctx *pipe_ctx);
/* Setup dc callbacks for dml2
* @dc: the display core structure
* @dml2_options: struct to hold callbacks
*/
void resource_init_common_dml2_callbacks(struct dc *dc, struct dml2_configuration_options *dml2_options);
/*
*Calculate total DET allocated for all pipes for a given OTG_MASTER pipe
*/
int resource_calculate_det_for_stream(struct dc_state *state, struct pipe_ctx *otg_master);
bool resource_is_hpo_acquired(struct dc_state *context);
struct link_encoder *get_temp_dio_link_enc(
const struct resource_context *res_ctx,
const struct resource_pool *const pool,
const struct dc_link *link);
#endif /* DRIVERS_GPU_DRM_AMD_DC_DEV_DC_INC_RESOURCE_H_ */
@@ -0,0 +1,41 @@
// SPDX-License-Identifier: MIT
//
// Copyright 2025 Advanced Micro Devices, Inc.
#ifndef __SOC_AND_IP_TRANSLATOR_H__
#define __SOC_AND_IP_TRANSLATOR_H__
#include "dc.h"
#include "dml_top_soc_parameter_types.h"
/* Forward declarations — callers that dereference these structs must include
* the full UTM model headers themselves. */
struct utm_qos_model;
struct utm_qos_model_dchub_v2;
struct soc_and_ip_translator_funcs {
void (*get_soc_bb)(
struct dml2_soc_bb *soc_bb,
const struct dc *dc,
const struct dml2_configuration_options *config);
void (*get_ip_caps)(struct dml2_ip_capabilities *dml_ip_caps);
/**
* get_utm_qos_model - Return the static UTM QoS model for this DCN
* generation. Caller provides storage for @qos_model and @dchub.
* @qos_model: output — populated with SoC bounding box and SOP table
* @dchub: output — populated with DCHUB client extension data
*/
void (*get_utm_qos_model)(
struct utm_qos_model *qos_model,
struct utm_qos_model_dchub_v2 *dchub);
};
struct soc_and_ip_translator {
const struct soc_and_ip_translator_funcs *translator_funcs;
};
struct soc_and_ip_translator *dc_create_soc_and_ip_translator(enum dce_version dc_version);
void dc_destroy_soc_and_ip_translator(struct soc_and_ip_translator **soc_and_ip_translator);
#endif // __SOC_AND_IP_TRANSLATOR_H__
@@ -0,0 +1,48 @@
/*
* Copyright 2018 Advanced Micro Devices, Inc.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors: AMD
*
*/
#ifndef DC_INC_VM_HELPER_H_
#define DC_INC_VM_HELPER_H_
#include "dc_types.h"
#define MAX_HUBP 6
struct vmid_usage {
int vmid_usage[2];
};
struct vm_helper {
unsigned int num_vmid;
struct vmid_usage hubp_vmid_usage[MAX_HUBP];
};
void vm_helper_mark_vmid_used(struct vm_helper *vm_helper, unsigned int pos, uint8_t hubp_idx);
void vm_helper_init(
struct vm_helper *vm_helper,
unsigned int num_vmid);
#endif /* DC_INC_VM_HELPER_H_ */