#include "dm_services.h"
#include "amdgpu.h"
#include "dc.h"
#include "core_status.h"
#include "core_types.h"
#include "hw_sequencer.h"
#include "dce/dce_hwseq.h"
#include "resource.h"
#include "dc_state.h"
#include "dc_state_priv.h"
#include "dc_plane_priv.h"
#include "gpio_service_interface.h"
#include "clk_mgr.h"
#include "clock_source.h"
#include "dc_bios_types.h"
#include "bios_parser_interface.h"
#include "bios/bios_parser_helper.h"
#include "include/irq_service_interface.h"
#include "transform.h"
#include "dmcu.h"
#include "dpp.h"
#include "timing_generator.h"
#include "abm.h"
#include "virtual/virtual_link_encoder.h"
#include "hubp.h"
#include "link_hwss.h"
#include "link_encoder.h"
#include "link_enc_cfg.h"
#include "link.h"
#include "dm_helpers.h"
#include "mem_input.h"
#include "dc_dmub_srv.h"
#include "dsc.h"
#include "vm_helper.h"
#include "dce/dce_i2c.h"
#include "dmub/dmub_srv.h"
#include "dce/dmub_psr.h"
#include "dce/dmub_hw_lock_mgr.h"
#include "dc_trace.h"
#include "hw_sequencer_private.h"
#if defined(CONFIG_DRM_AMD_DC_FP)
#include "dml2/dml2_internal_types.h"
#endif
#include "dce/dmub_outbox.h"
#define CTX …
#define DC_LOGGER …
static const char DC_BUILD_ID[] = …;
static inline void elevate_update_type(enum surface_update_type *original, enum surface_update_type new)
{ … }
static void destroy_links(struct dc *dc)
{ … }
static uint32_t get_num_of_internal_disp(struct dc_link **links, uint32_t num_links)
{ … }
static int get_seamless_boot_stream_count(struct dc_state *ctx)
{ … }
static bool create_links(
struct dc *dc,
uint32_t num_virtual_links)
{ … }
static bool create_link_encoders(struct dc *dc)
{ … }
static void destroy_link_encoders(struct dc *dc)
{ … }
static struct dc_perf_trace *dc_perf_trace_create(void)
{ … }
static void dc_perf_trace_destroy(struct dc_perf_trace **perf_trace)
{ … }
static bool set_long_vtotal(struct dc *dc, struct dc_stream_state *stream, struct dc_crtc_timing_adjust *adjust)
{ … }
bool dc_stream_adjust_vmin_vmax(struct dc *dc,
struct dc_stream_state *stream,
struct dc_crtc_timing_adjust *adjust)
{ … }
bool dc_stream_get_last_used_drr_vtotal(struct dc *dc,
struct dc_stream_state *stream,
uint32_t *refresh_rate)
{ … }
bool dc_stream_get_crtc_position(struct dc *dc,
struct dc_stream_state **streams, int num_streams,
unsigned int *v_pos, unsigned int *nom_v_pos)
{ … }
#if defined(CONFIG_DRM_AMD_SECURE_DISPLAY)
static inline void
dc_stream_forward_dmub_crc_window(struct dc_dmub_srv *dmub_srv,
struct rect *rect, struct otg_phy_mux *mux_mapping, bool is_stop)
{ … }
static inline void
dc_stream_forward_dmcu_crc_window(struct dmcu *dmcu,
struct rect *rect, struct otg_phy_mux *mux_mapping, bool is_stop)
{ … }
bool
dc_stream_forward_crc_window(struct dc_stream_state *stream,
struct rect *rect, bool is_stop)
{ … }
#endif
bool dc_stream_configure_crc(struct dc *dc, struct dc_stream_state *stream,
struct crc_params *crc_window, bool enable, bool continuous)
{ … }
bool dc_stream_get_crc(struct dc *dc, struct dc_stream_state *stream,
uint32_t *r_cr, uint32_t *g_y, uint32_t *b_cb)
{ … }
void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream,
enum dc_dynamic_expansion option)
{ … }
void dc_stream_set_dither_option(struct dc_stream_state *stream,
enum dc_dither_option option)
{ … }
bool dc_stream_set_gamut_remap(struct dc *dc, const struct dc_stream_state *stream)
{ … }
bool dc_stream_program_csc_matrix(struct dc *dc, struct dc_stream_state *stream)
{ … }
void dc_stream_set_static_screen_params(struct dc *dc,
struct dc_stream_state **streams,
int num_streams,
const struct dc_static_screen_params *params)
{ … }
static void dc_destruct(struct dc *dc)
{ … }
static bool dc_construct_ctx(struct dc *dc,
const struct dc_init_data *init_params)
{ … }
static bool dc_construct(struct dc *dc,
const struct dc_init_data *init_params)
{ … }
static void disable_all_writeback_pipes_for_stream(
const struct dc *dc,
struct dc_stream_state *stream,
struct dc_state *context)
{ … }
static void apply_ctx_interdependent_lock(struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream,
bool lock)
{ … }
static void dc_update_visual_confirm_color(struct dc *dc, struct dc_state *context, struct pipe_ctx *pipe_ctx)
{ … }
static void disable_dangling_plane(struct dc *dc, struct dc_state *context)
{ … }
static void disable_vbios_mode_if_required(
struct dc *dc,
struct dc_state *context)
{ … }
static void wait_for_blank_complete(struct dc *dc,
struct dc_state *context)
{ … }
static void wait_for_odm_update_pending_complete(struct dc *dc, struct dc_state *context)
{ … }
static void wait_for_no_pipes_pending(struct dc *dc, struct dc_state *context)
{ … }
struct dc *dc_create(const struct dc_init_data *init_params)
{ … }
static void detect_edp_presence(struct dc *dc)
{ … }
void dc_hardware_init(struct dc *dc)
{ … }
void dc_init_callbacks(struct dc *dc,
const struct dc_callback_init *init_params)
{ … }
void dc_deinit_callbacks(struct dc *dc)
{ … }
void dc_destroy(struct dc **dc)
{ … }
static void enable_timing_multisync(
struct dc *dc,
struct dc_state *ctx)
{ … }
static void program_timing_sync(
struct dc *dc,
struct dc_state *ctx)
{ … }
static bool streams_changed(struct dc *dc,
struct dc_stream_state *streams[],
uint8_t stream_count)
{ … }
bool dc_validate_boot_timing(const struct dc *dc,
const struct dc_sink *sink,
struct dc_crtc_timing *crtc_timing)
{ … }
static inline bool should_update_pipe_for_stream(
struct dc_state *context,
struct pipe_ctx *pipe_ctx,
struct dc_stream_state *stream)
{ … }
static inline bool should_update_pipe_for_plane(
struct dc_state *context,
struct pipe_ctx *pipe_ctx,
struct dc_plane_state *plane_state)
{ … }
void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
struct dc_stream_state *streams[],
uint8_t stream_count)
{ … }
void dc_trigger_sync(struct dc *dc, struct dc_state *context)
{ … }
static uint8_t get_stream_mask(struct dc *dc, struct dc_state *context)
{ … }
void dc_z10_restore(const struct dc *dc)
{ … }
void dc_z10_save_init(struct dc *dc)
{ … }
static enum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *context)
{ … }
static bool commit_minimal_transition_state(struct dc *dc,
struct dc_state *transition_base_context);
enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params *params)
{ … }
bool dc_acquire_release_mpc_3dlut(
struct dc *dc, bool acquire,
struct dc_stream_state *stream,
struct dc_3dlut **lut,
struct dc_transfer_func **shaper)
{ … }
static bool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context)
{ … }
static void process_deferred_updates(struct dc *dc)
{ … }
void dc_post_update_surfaces_to_stream(struct dc *dc)
{ … }
bool dc_set_generic_gpio_for_stereo(bool enable,
struct gpio_service *gpio_service)
{ … }
static bool is_surface_in_context(
const struct dc_state *context,
const struct dc_plane_state *plane_state)
{ … }
static enum surface_update_type get_plane_info_update_type(const struct dc_surface_update *u)
{ … }
static enum surface_update_type get_scaling_info_update_type(
const struct dc *dc,
const struct dc_surface_update *u)
{ … }
static enum surface_update_type det_surface_update(const struct dc *dc,
const struct dc_surface_update *u)
{ … }
static enum surface_update_type check_update_surfaces_for_stream(
struct dc *dc,
struct dc_surface_update *updates,
int surface_count,
struct dc_stream_update *stream_update,
const struct dc_stream_status *stream_status)
{ … }
enum surface_update_type dc_check_update_surfaces_for_stream(
struct dc *dc,
struct dc_surface_update *updates,
int surface_count,
struct dc_stream_update *stream_update,
const struct dc_stream_status *stream_status)
{ … }
static struct dc_stream_status *stream_get_status(
struct dc_state *ctx,
struct dc_stream_state *stream)
{ … }
static const enum surface_update_type update_surface_trace_level = …;
static void copy_surface_update_to_plane(
struct dc_plane_state *surface,
struct dc_surface_update *srf_update)
{ … }
static void copy_stream_update_to_stream(struct dc *dc,
struct dc_state *context,
struct dc_stream_state *stream,
struct dc_stream_update *update)
{ … }
static void backup_planes_and_stream_state(
struct dc_scratch_space *scratch,
struct dc_stream_state *stream)
{ … }
static void restore_planes_and_stream_state(
struct dc_scratch_space *scratch,
struct dc_stream_state *stream)
{ … }
static void update_seamless_boot_flags(struct dc *dc,
struct dc_state *context,
int surface_count,
struct dc_stream_state *stream)
{ … }
static bool update_planes_and_stream_state(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type *new_update_type,
struct dc_state **new_context)
{ … }
static void commit_planes_do_stream_update(struct dc *dc,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type update_type,
struct dc_state *context)
{ … }
static bool dc_dmub_should_send_dirty_rect_cmd(struct dc *dc, struct dc_stream_state *stream)
{ … }
void dc_dmub_update_dirty_rect(struct dc *dc,
int surface_count,
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates,
struct dc_state *context)
{ … }
static void build_dmub_update_dirty_rect(
struct dc *dc,
int surface_count,
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates,
struct dc_state *context,
struct dc_dmub_cmd dc_dmub_cmd[],
unsigned int *dmub_cmd_count)
{ … }
static bool check_address_only_update(union surface_update_flags update_flags)
{ … }
static void build_dmub_cmd_list(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_state *stream,
struct dc_state *context,
struct dc_dmub_cmd dc_dmub_cmd[],
unsigned int *dmub_cmd_count)
{ … }
static void commit_plane_for_stream_offload_fams2_flip(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_state *stream,
struct dc_state *context)
{ … }
static void commit_planes_for_stream_fast(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type update_type,
struct dc_state *context)
{ … }
static void wait_for_outstanding_hw_updates(struct dc *dc, struct dc_state *dc_context)
{ … }
static void commit_planes_for_stream(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type update_type,
struct dc_state *context)
{ … }
static bool could_mpcc_tree_change_for_active_pipes(struct dc *dc,
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates,
int surface_count,
bool *is_plane_addition)
{ … }
struct pipe_split_policy_backup { … };
static void backup_and_set_minimal_pipe_split_policy(struct dc *dc,
struct dc_state *context,
struct pipe_split_policy_backup *policy)
{ … }
static void restore_minimal_pipe_split_policy(struct dc *dc,
struct dc_state *context,
struct pipe_split_policy_backup *policy)
{ … }
static void release_minimal_transition_state(struct dc *dc,
struct dc_state *minimal_transition_context,
struct dc_state *base_context,
struct pipe_split_policy_backup *policy)
{ … }
static void force_vsync_flip_in_minimal_transition_context(struct dc_state *context)
{ … }
static struct dc_state *create_minimal_transition_state(struct dc *dc,
struct dc_state *base_context, struct pipe_split_policy_backup *policy)
{ … }
static bool is_pipe_topology_transition_seamless_with_intermediate_step(
struct dc *dc,
struct dc_state *initial_state,
struct dc_state *intermediate_state,
struct dc_state *final_state)
{ … }
static void swap_and_release_current_context(struct dc *dc,
struct dc_state *new_context, struct dc_stream_state *stream)
{ … }
static int initialize_empty_surface_updates(
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates)
{ … }
static bool commit_minimal_transition_based_on_new_context(struct dc *dc,
struct dc_state *new_context,
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates,
int surface_count)
{ … }
static bool commit_minimal_transition_based_on_current_context(struct dc *dc,
struct dc_state *new_context, struct dc_stream_state *stream)
{ … }
static bool commit_minimal_transition_state_in_dc_update(struct dc *dc,
struct dc_state *new_context,
struct dc_stream_state *stream,
struct dc_surface_update *srf_updates,
int surface_count)
{ … }
static bool commit_minimal_transition_state(struct dc *dc,
struct dc_state *transition_base_context)
{ … }
static void populate_fast_updates(struct dc_fast_update *fast_update,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_update *stream_update)
{ … }
static bool fast_updates_exist(struct dc_fast_update *fast_update, int surface_count)
{ … }
static bool full_update_required(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_update *stream_update,
struct dc_stream_state *stream)
{ … }
static bool fast_update_only(struct dc *dc,
struct dc_fast_update *fast_update,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_update *stream_update,
struct dc_stream_state *stream)
{ … }
static bool update_planes_and_stream_v1(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
struct dc_state *state)
{ … }
static bool update_planes_and_stream_v2(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update)
{ … }
static void commit_planes_and_stream_update_on_current_context(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type update_type)
{ … }
static void commit_planes_and_stream_update_with_new_context(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
enum surface_update_type update_type,
struct dc_state *new_context)
{ … }
static bool update_planes_and_stream_v3(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update)
{ … }
bool dc_update_planes_and_stream(struct dc *dc,
struct dc_surface_update *srf_updates, int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update)
{ … }
void dc_commit_updates_for_stream(struct dc *dc,
struct dc_surface_update *srf_updates,
int surface_count,
struct dc_stream_state *stream,
struct dc_stream_update *stream_update,
struct dc_state *state)
{ … }
uint8_t dc_get_current_stream_count(struct dc *dc)
{ … }
struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i)
{ … }
enum dc_irq_source dc_interrupt_to_irq_source(
struct dc *dc,
uint32_t src_id,
uint32_t ext_id)
{ … }
bool dc_interrupt_set(struct dc *dc, enum dc_irq_source src, bool enable)
{ … }
void dc_interrupt_ack(struct dc *dc, enum dc_irq_source src)
{ … }
void dc_power_down_on_boot(struct dc *dc)
{ … }
void dc_set_power_state(struct dc *dc, enum dc_acpi_cm_power_state power_state)
{ … }
void dc_resume(struct dc *dc)
{ … }
bool dc_is_dmcu_initialized(struct dc *dc)
{ … }
void get_clock_requirements_for_state(struct dc_state *state, struct AsicStateEx *info)
{ … }
enum dc_status dc_set_clock(struct dc *dc, enum dc_clock_type clock_type, uint32_t clk_khz, uint32_t stepping)
{ … }
void dc_get_clock(struct dc *dc, enum dc_clock_type clock_type, struct dc_clock_config *clock_cfg)
{ … }
bool dc_set_psr_allow_active(struct dc *dc, bool enable)
{ … }
bool dc_set_replay_allow_active(struct dc *dc, bool active)
{ … }
bool dc_set_ips_disable(struct dc *dc, unsigned int disable_ips)
{ … }
void dc_allow_idle_optimizations_internal(struct dc *dc, bool allow, char const *caller_name)
{ … }
void dc_exit_ips_for_hw_access_internal(struct dc *dc, const char *caller_name)
{ … }
bool dc_dmub_is_ips_idle_state(struct dc *dc)
{ … }
void dc_unlock_memory_clock_frequency(struct dc *dc)
{ … }
void dc_lock_memory_clock_frequency(struct dc *dc)
{ … }
static void blank_and_force_memclk(struct dc *dc, bool apply, unsigned int memclk_mhz)
{ … }
void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable)
{ … }
bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc,
unsigned int pitch,
unsigned int height,
enum surface_pixel_format format,
struct dc_cursor_attributes *cursor_attr)
{ … }
void dc_hardware_release(struct dc *dc)
{ … }
void dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(struct dc *dc)
{ … }
bool dc_is_dmub_outbox_supported(struct dc *dc)
{ … }
bool dc_enable_dmub_notifications(struct dc *dc)
{ … }
void dc_enable_dmub_outbox(struct dc *dc)
{ … }
bool dc_process_dmub_aux_transfer_async(struct dc *dc,
uint32_t link_index,
struct aux_payload *payload)
{ … }
uint8_t get_link_index_from_dpia_port_index(const struct dc *dc,
uint8_t dpia_port_index)
{ … }
bool dc_process_dmub_set_config_async(struct dc *dc,
uint32_t link_index,
struct set_config_cmd_payload *payload,
struct dmub_notification *notify)
{ … }
enum dc_status dc_process_dmub_set_mst_slots(const struct dc *dc,
uint32_t link_index,
uint8_t mst_alloc_slots,
uint8_t *mst_slots_in_use)
{ … }
void dc_process_dmub_dpia_hpd_int_enable(const struct dc *dc,
uint32_t hpd_int_enable)
{ … }
void dc_print_dmub_diagnostic_data(const struct dc *dc)
{ … }
void dc_disable_accelerated_mode(struct dc *dc)
{ … }
void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable)
{ … }
bool dc_abm_save_restore(
struct dc *dc,
struct dc_stream_state *stream,
struct abm_save_restore *pData)
{ … }
void dc_query_current_properties(struct dc *dc, struct dc_current_properties *properties)
{ … }
void dc_set_edp_power(const struct dc *dc, struct dc_link *edp_link,
bool powerOn)
{ … }
struct dc_power_profile dc_get_power_profile_for_dc_state(const struct dc_state *context)
{ … }