/* * 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
*/
/** * DOC: Overview * * DC is the OS-agnostic component of the amdgpu DC driver. * * DC maintains and validates a set of structs representing the state of the * driver and writes that state to AMD hardware * * Main DC HW structs: * * struct dc - The central struct. One per driver. Created on driver load, * destroyed on driver unload. * * struct dc_context - One per driver. * Used as a backpointer by most other structs in dc. * * struct dc_link - One per connector (the physical DP, HDMI, miniDP, or eDP * plugpoints). Created on driver load, destroyed on driver unload. * * struct dc_sink - One per display. Created on boot or hotplug. * Destroyed on shutdown or hotunplug. A dc_link can have a local sink * (the display directly attached). It may also have one or more remote * sinks (in the Multi-Stream Transport case) * * struct resource_pool - One per driver. Represents the hw blocks not in the * main pipeline. Not directly accessible by dm. * * Main dc state structs: * * These structs can be created and destroyed as needed. There is a full set of * these structs in dc->current_state representing the currently programmed state. * * struct dc_state - The global DC state to track global state information, * such as bandwidth values. * * struct dc_stream_state - Represents the hw configuration for the pipeline from * a framebuffer to a display. Maps one-to-one with dc_sink. * * struct dc_plane_state - Represents a framebuffer. Each stream has at least one, * and may have more in the Multi-Plane Overlay case. * * struct resource_context - Represents the programmable state of everything in * the resource_pool. Not directly accessible by dm. * * struct pipe_ctx - A member of struct resource_context. Represents the * internal hardware pipeline components. Each dc_plane_state has either * one or two (in the pipe-split case).
*/
/* Private functions */
staticinlinevoid elevate_update_type(enum surface_update_type *original, enum surface_update_type new)
{ if (new > *original)
*original = new;
}
staticvoid destroy_links(struct dc *dc)
{
uint32_t i;
for (i = 0; i < dc->link_count; i++) { if (NULL != dc->links[i])
dc->link_srv->destroy_link(&dc->links[i]);
}
}
/* When getting the number of connectors, the VBIOS reports the number of valid indices, * but it doesn't say which indices are valid, and not every index has an actual connector. * So, if we don't find a connector on an index, that is not an error. * * - There is no guarantee that the first N indices will be valid * - VBIOS may report a higher amount of valid indices than there are actual connectors * - Some VBIOS have valid configurations for more connectors than there actually are * on the card. This may be because the manufacturer used the same VBIOS for different * variants of the same card.
*/ for (i = 0; dc->link_count < connectors_num && i < MAX_LINKS; i++) { struct graphics_object_id connector_id = bios->funcs->get_connector_id(bios, i); struct link_init_data link_init_params = {0}; struct dc_link *link;
if (connector_id.id == CONNECTOR_ID_UNKNOWN) continue;
DC_LOG_DC("BIOS object table - printing link object info for connector number: %d, link_index: %d", i, dc->link_count);
/* Create a link for each usb4 dpia port */
dc->lowest_dpia_link_index = MAX_LINKS; for (i = 0; i < dc->res_pool->usb4_dpia_count; i++) { struct link_init_data link_init_params = {0}; struct dc_link *link;
link = dc->link_srv->create_link(&link_init_params); if (link) { if (dc->lowest_dpia_link_index > dc->link_count)
dc->lowest_dpia_link_index = dc->link_count;
/* Create additional DIG link encoder objects if fewer than the platform * supports were created during link construction. This can happen if the * number of physical connectors is less than the number of DIGs.
*/ staticbool create_link_encoders(struct dc *dc)
{ bool res = true; unsignedint num_usb4_dpia = dc->res_pool->res_cap->num_usb4_dpia; unsignedint num_dig_link_enc = dc->res_pool->res_cap->num_dig_link_enc; int i;
/* A platform without USB4 DPIA endpoints has a fixed mapping between DIG * link encoders and physical display endpoints and does not require * additional link encoder objects.
*/ if (num_usb4_dpia == 0) return res;
/* Create as many link encoder objects as the platform supports. DPIA * endpoints can be programmably mapped to any DIG.
*/ if (num_dig_link_enc > dc->res_pool->dig_link_enc_count) { for (i = 0; i < num_dig_link_enc; i++) { struct link_encoder *link_enc = dc->res_pool->link_encoders[i];
if (!link_enc && dc->res_pool->funcs->link_enc_create_minimal) {
link_enc = dc->res_pool->funcs->link_enc_create_minimal(dc->ctx,
(enum engine_id)(ENGINE_ID_DIGA + i)); if (link_enc) {
dc->res_pool->link_encoders[i] = link_enc;
dc->res_pool->dig_link_enc_count++;
} else {
res = false;
}
}
}
}
return res;
}
/* Destroy any additional DIG link encoder objects created by * create_link_encoders(). * NB: Must only be called after destroy_links().
*/ staticvoid destroy_link_encoders(struct dc *dc)
{ unsignedint num_usb4_dpia; unsignedint num_dig_link_enc; int i;
/* A platform without USB4 DPIA endpoints has a fixed mapping between DIG * link encoders and physical display endpoints and does not require * additional link encoder objects.
*/ if (num_usb4_dpia == 0) return;
for (i = 0; i < num_dig_link_enc; i++) { struct link_encoder *link_enc = dc->res_pool->link_encoders[i];
staticbool set_long_vtotal(struct dc *dc, struct dc_stream_state *stream, struct dc_crtc_timing_adjust *adjust)
{ if (!dc || !stream || !adjust) returnfalse;
if (!dc->current_state) returnfalse;
int i;
for (i = 0; i < MAX_PIPES; i++) { struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream && pipe->stream_res.tg) { if (dc->hwss.set_long_vtotal)
dc->hwss.set_long_vtotal(&pipe, 1, adjust->v_total_min, adjust->v_total_max);
returntrue;
}
}
returnfalse;
}
/** * dc_stream_adjust_vmin_vmax - look up pipe context & update parts of DRR * @dc: dc reference * @stream: Initial dc stream state * @adjust: Updated parameters for vertical_total_min and vertical_total_max * * Looks up the pipe context of dc_stream_state and updates the * vertical_total_min and vertical_total_max of the DRR, Dynamic Refresh * Rate, which is a power-saving feature that targets reducing panel * refresh rate while the screen is static * * Return: %true if the pipe context is found and adjusted; * %false if the pipe context is not found.
*/ bool dc_stream_adjust_vmin_vmax(struct dc *dc, struct dc_stream_state *stream, struct dc_crtc_timing_adjust *adjust)
{ int i;
/* * Don't adjust DRR while there's bandwidth optimizations pending to * avoid conflicting with firmware updates.
*/ if (dc->ctx->dce_version > DCE_VERSION_MAX) { if ((dc->optimized_required || dc->wm_optimized_required) &&
(stream->adjust.v_total_max != adjust->v_total_max ||
stream->adjust.v_total_min != adjust->v_total_min)) {
stream->adjust.timing_adjust_pending = true; returnfalse;
}
}
/** * dc_stream_get_last_used_drr_vtotal - Looks up the pipe context of * dc_stream_state and gets the last VTOTAL used by DRR (Dynamic Refresh Rate) * * @dc: [in] dc reference * @stream: [in] Initial dc stream state * @refresh_rate: [in] new refresh_rate * * Return: %true if the pipe context is found and there is an associated * timing_generator for the DC; * %false if the pipe context is not found or there is no * timing_generator for the DC.
*/ bool dc_stream_get_last_used_drr_vtotal(struct dc *dc, struct dc_stream_state *stream,
uint32_t *refresh_rate)
{ bool status = false;
int i = 0;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < MAX_PIPES; i++) { struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream && pipe->stream_res.tg) { /* Only execute if a function pointer has been defined for * the DC version in question
*/ if (pipe->stream_res.tg->funcs->get_last_used_drr_vtotal) {
pipe->stream_res.tg->funcs->get_last_used_drr_vtotal(pipe->stream_res.tg, refresh_rate);
status = true;
break;
}
}
}
return status;
}
#ifdefined(CONFIG_DRM_AMD_SECURE_DISPLAY) staticinlinevoid
dc_stream_forward_dmub_crc_window(struct dc_dmub_srv *dmub_srv, struct rect *rect, struct otg_phy_mux *mux_mapping, bool is_stop)
{ union dmub_rb_cmd cmd = {0};
/** * dc_stream_configure_crc() - Configure CRC capture for the given stream. * @dc: DC Object * @stream: The stream to configure CRC on. * @crc_window: CRC window (x/y start/end) information * @enable: Enable CRC if true, disable otherwise. * @continuous: Capture CRC on every frame if true. Otherwise, only capture * once. * @idx: Capture CRC on which CRC engine instance * @reset: Reset CRC engine before the configuration * * By default, the entire frame is used to calculate the CRC. * * Return: %false if the stream is not found or CRC capture is not supported; * %true if the stream has been configured.
*/ bool dc_stream_configure_crc(struct dc *dc, struct dc_stream_state *stream, struct crc_params *crc_window, bool enable, bool continuous,
uint8_t idx, bool reset)
{ struct pipe_ctx *pipe; struct crc_params param; struct timing_generator *tg;
/* Default to the union of both windows */
param.selection = UNION_WINDOW_A_B;
param.continuous_mode = continuous;
param.enable = enable;
param.crc_eng_inst = idx;
param.reset = reset;
tg = pipe->stream_res.tg;
/* Only call if supported */ if (tg->funcs->configure_crc) return tg->funcs->configure_crc(tg, ¶m);
DC_LOG_WARNING("CRC capture not supported."); returnfalse;
}
/** * dc_stream_get_crc() - Get CRC values for the given stream. * * @dc: DC object. * @stream: The DC stream state of the stream to get CRCs from. * @idx: index of crc engine to get CRC from * @r_cr: CRC value for the red component. * @g_y: CRC value for the green component. * @b_cb: CRC value for the blue component. * * dc_stream_configure_crc needs to be called beforehand to enable CRCs. * * Return: * %false if stream is not found, or if CRCs are not enabled.
*/ bool dc_stream_get_crc(struct dc *dc, struct dc_stream_state *stream, uint8_t idx,
uint32_t *r_cr, uint32_t *g_y, uint32_t *b_cb)
{ int i; struct pipe_ctx *pipe; struct timing_generator *tg;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < MAX_PIPES; i++) {
pipe = &dc->current_state->res_ctx.pipe_ctx[i]; if (pipe->stream == stream) break;
} /* Stream not found */ if (i == MAX_PIPES) returnfalse;
tg = pipe->stream_res.tg;
if (tg->funcs->get_crc) return tg->funcs->get_crc(tg, idx, r_cr, g_y, b_cb);
DC_LOG_WARNING("CRC capture not supported."); returnfalse;
}
void dc_stream_set_dyn_expansion(struct dc *dc, struct dc_stream_state *stream, enum dc_dynamic_expansion option)
{ /* OPP FMT dyn expansion updates*/ int i; struct pipe_ctx *pipe_ctx;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < MAX_PIPES; i++) { if (dc->current_state->res_ctx.pipe_ctx[i].stream
== stream) {
pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
pipe_ctx->stream_res.opp->dyn_expansion = option;
pipe_ctx->stream_res.opp->funcs->opp_set_dyn_expansion(
pipe_ctx->stream_res.opp,
COLOR_SPACE_YCBCR601,
stream->timing.display_color_depth,
stream->signal);
}
}
}
for (i = 0; i < MAX_PIPES; i++) { if (link->dc->current_state->res_ctx.pipe_ctx[i].stream ==
stream) {
pipes = &link->dc->current_state->res_ctx.pipe_ctx[i]; break;
}
}
if (!pipes) return; if (option > DITHER_OPTION_MAX) return;
bool dc_stream_set_gamut_remap(struct dc *dc, conststruct dc_stream_state *stream)
{ int i; bool ret = false; struct pipe_ctx *pipes;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < MAX_PIPES; i++) { if (dc->current_state->res_ctx.pipe_ctx[i].stream == stream) {
pipes = &dc->current_state->res_ctx.pipe_ctx[i];
dc->hwss.program_gamut_remap(pipes);
ret = true;
}
}
return ret;
}
bool dc_stream_program_csc_matrix(struct dc *dc, struct dc_stream_state *stream)
{ int i; bool ret = false; struct pipe_ctx *pipes;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < MAX_PIPES; i++) { if (dc->current_state->res_ctx.pipe_ctx[i].stream
== stream) {
void dc_stream_set_static_screen_params(struct dc *dc, struct dc_stream_state **streams, int num_streams, conststruct dc_static_screen_params *params)
{ int i, j; struct pipe_ctx *pipes_affected[MAX_PIPES]; int num_pipes_affected = 0;
dc_exit_ips_for_hw_access(dc);
for (i = 0; i < num_streams; i++) { struct dc_stream_state *stream = streams[i];
for (j = 0; j < MAX_PIPES; j++) { if (dc->current_state->res_ctx.pipe_ctx[j].stream
== stream) {
pipes_affected[num_pipes_affected++] =
&dc->current_state->res_ctx.pipe_ctx[j];
}
}
}
dc_dceip = kzalloc(sizeof(*dc_dceip), GFP_KERNEL); if (!dc_dceip) {
dm_error("%s: failed to create dceip\n", __func__); goto fail;
}
dc->bw_dceip = dc_dceip;
dc_vbios = kzalloc(sizeof(*dc_vbios), GFP_KERNEL); if (!dc_vbios) {
dm_error("%s: failed to create vbios\n", __func__); goto fail;
}
dc->bw_vbios = dc_vbios;
dcn_soc = kzalloc(sizeof(*dcn_soc), GFP_KERNEL); if (!dcn_soc) {
dm_error("%s: failed to create dcn_soc\n", __func__); goto fail;
}
dc->dcn_soc = dcn_soc;
dcn_ip = kzalloc(sizeof(*dcn_ip), GFP_KERNEL); if (!dcn_ip) {
dm_error("%s: failed to create dcn_ip\n", __func__); goto fail;
}
dc->dcn_ip = dcn_ip;
if (init_params->bb_from_dmub)
dc->dml2_options.bb_from_dmub = init_params->bb_from_dmub; else
dc->dml2_options.bb_from_dmub = NULL;
if (!dc_construct_ctx(dc, init_params)) {
dm_error("%s: failed to create ctx\n", __func__); goto fail;
}
dc_ctx = dc->ctx;
/* Resource should construct all asic specific resources. * This should be the only place where we need to parse the asic id
*/ if (init_params->vbios_override)
dc_ctx->dc_bios = init_params->vbios_override; else { /* Create BIOS parser */ struct bp_init_data bp_init_data;
if (!dc_ctx->gpio_service) {
ASSERT_CRITICAL(false); goto fail;
}
dc->res_pool = dc_create_resource_pool(dc, init_params, dc_ctx->dce_version); if (!dc->res_pool) goto fail;
/* set i2c speed if not done by the respective dcnxxx__resource.c */ if (dc->caps.i2c_speed_in_khz_hdcp == 0)
dc->caps.i2c_speed_in_khz_hdcp = dc->caps.i2c_speed_in_khz; if (dc->caps.max_optimizable_video_width == 0)
dc->caps.max_optimizable_video_width = 5120;
dc->clk_mgr = dc_clk_mgr_create(dc->ctx, dc->res_pool->pp_smu, dc->res_pool->dccg); if (!dc->clk_mgr) goto fail; #ifdef CONFIG_DRM_AMD_DC_FP
dc->clk_mgr->force_smu_not_present = init_params->force_smu_not_present;
if (dc->res_pool->funcs->update_bw_bounding_box) {
DC_FP_START();
dc->res_pool->funcs->update_bw_bounding_box(dc, dc->clk_mgr->bw_params);
DC_FP_END();
} #endif
if (!create_links(dc, init_params->num_virtual_links)) goto fail;
/* Create additional DIG link encoder objects if fewer than the platform * supports were created during link construction.
*/ if (!create_link_encoders(dc)) goto fail;
/* Creation of current_state must occur after dc->dml * is initialized in dc_create_resource_pool because * on creation it copies the contents of dc->dml
*/
dc->current_state = dc_state_create(dc, NULL);
if (!dc->current_state) {
dm_error("%s: failed to create validate ctx\n", __func__); goto fail;
}
returntrue;
fail: returnfalse;
}
staticvoid disable_all_writeback_pipes_for_stream( conststruct dc *dc, struct dc_stream_state *stream, struct dc_state *context)
{ int i;
for (i = 0; i < stream->num_wb_info; i++)
stream->writeback_info[i].wb_enabled = false;
}
staticvoid apply_ctx_interdependent_lock(struct dc *dc, struct dc_state *context, struct dc_stream_state *stream, bool lock)
{ int i;
/* Checks if interdependent update function pointer is NULL or not, takes care of DCE110 case */ if (dc->hwss.interdependent_update_lock)
dc->hwss.interdependent_update_lock(dc, context, lock); else { for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[i]; struct pipe_ctx *old_pipe_ctx = &dc->current_state->res_ctx.pipe_ctx[i];
// Copied conditions that were previously in dce110_apply_ctx_for_surface if (stream == pipe_ctx->stream) { if (resource_is_pipe_type(pipe_ctx, OPP_HEAD) &&
(pipe_ctx->plane_state || old_pipe_ctx->plane_state))
dc->hwss.pipe_control_lock(dc, pipe_ctx, lock);
}
}
}
}
switch (dc->debug.visual_confirm) { case VISUAL_CONFIRM_DISABLE: return; case VISUAL_CONFIRM_PSR: case VISUAL_CONFIRM_FAMS:
pipe_ctx = dc_stream_get_pipe_ctx(stream_state); if (!pipe_ctx) return;
dc_dmub_srv_get_visual_confirm_color_cmd(dc, pipe_ctx);
memcpy(color, &dc->ctx->dmub_srv->dmub->visual_confirm_color, sizeof(struct tg_color)); return;
default: /* find plane with highest layer_index */ for (i = 0; i < stream_status->plane_count; i++) { if (stream_status->plane_states[i]->visible)
plane_state = stream_status->plane_states[i];
} if (!plane_state) return; /* find pipe that contains plane with highest layer index */ for (i = 0; i < MAX_PIPES; i++) { struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (old_pipe->plane_state && !new_pipe->plane_state)
should_disable = true;
}
if (should_disable && old_stream) { bool is_phantom = dc_state_get_stream_subvp_type(dc->current_state, old_stream) == SUBVP_PHANTOM;
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
tg = pipe->stream_res.tg; /* When disabling plane for a phantom pipe, we must turn on the * phantom OTG so the disable programming gets the double buffer * update. Otherwise the pipe will be left in a partially disabled * state that can result in underflow or hang when enabling it * again for different use.
*/ if (is_phantom) { if (tg->funcs->enable_crtc) { if (dc->hwseq->funcs.blank_pixel_data)
dc->hwseq->funcs.blank_pixel_data(dc, pipe, true);
tg->funcs->enable_crtc(tg);
}
}
if (dc->res_pool->funcs->prepare_mcache_programming)
dc->res_pool->funcs->prepare_mcache_programming(dc, dangling_context); if (dc->hwss.program_front_end_for_ctx) {
dc->hwss.interdependent_update_lock(dc, dc->current_state, true);
dc->hwss.program_front_end_for_ctx(dc, dangling_context);
dc->hwss.interdependent_update_lock(dc, dc->current_state, false);
dc->hwss.post_unlock_program_front_end(dc, dangling_context);
} /* We need to put the phantom OTG back into it's default (disabled) state or we * can get corruption when transition from one SubVP config to a different one. * The OTG is set to disable on falling edge of VUPDATE so the plane disable * will still get it's double buffer update.
*/ if (is_phantom) { if (tg->funcs->disable_phantom_crtc)
tg->funcs->disable_phantom_crtc(tg);
}
}
}
staticvoid enable_timing_multisync( struct dc *dc, struct dc_state *ctx)
{ int i, multisync_count = 0; int pipe_count = dc->res_pool->pipe_count; struct pipe_ctx *multisync_pipes[MAX_PIPES] = { NULL };
for (i = 0; i < pipe_count; i++) { if (!ctx->res_ctx.pipe_ctx[i].stream ||
!ctx->res_ctx.pipe_ctx[i].stream->triggered_crtc_reset.enabled) continue; if (ctx->res_ctx.pipe_ctx[i].stream == ctx->res_ctx.pipe_ctx[i].stream->triggered_crtc_reset.event_source) continue;
multisync_pipes[multisync_count] = &ctx->res_ctx.pipe_ctx[i];
multisync_count++;
}
staticvoid program_timing_sync( struct dc *dc, struct dc_state *ctx)
{ int i, j, k; int group_index = 0; int num_group = 0; int pipe_count = dc->res_pool->pipe_count; struct pipe_ctx *unsynced_pipes[MAX_PIPES] = { NULL };
for (i = 0; i < pipe_count; i++) { if (!ctx->res_ctx.pipe_ctx[i].stream
|| ctx->res_ctx.pipe_ctx[i].top_pipe
|| ctx->res_ctx.pipe_ctx[i].prev_odm_pipe) continue;
unsynced_pipes[i] = &ctx->res_ctx.pipe_ctx[i];
}
for (i = 0; i < pipe_count; i++) { int group_size = 1; enum timing_synchronization_type sync_type = NOT_SYNCHRONIZABLE; struct pipe_ctx *pipe_set[MAX_PIPES];
/* Add tg to the set, search rest of the tg's for ones with * same timing, add all tgs with same timing to the group
*/ for (j = i + 1; j < pipe_count; j++) { if (!unsynced_pipes[j]) continue; if (sync_type != TIMING_SYNCHRONIZABLE &&
dc->hwss.enable_vblanks_synchronization &&
unsynced_pipes[j]->stream_res.tg->funcs->align_vblanks &&
resource_are_vblanks_synchronizable(
unsynced_pipes[j]->stream,
pipe_set[0]->stream)) {
sync_type = VBLANK_SYNCHRONIZABLE;
pipe_set[group_size] = unsynced_pipes[j];
unsynced_pipes[j] = NULL;
group_size++;
} else if (sync_type != VBLANK_SYNCHRONIZABLE &&
resource_are_streams_timing_synchronizable(
unsynced_pipes[j]->stream,
pipe_set[0]->stream)) {
sync_type = TIMING_SYNCHRONIZABLE;
pipe_set[group_size] = unsynced_pipes[j];
unsynced_pipes[j] = NULL;
group_size++;
}
}
/* set first unblanked pipe as master */ for (j = 0; j < group_size; j++) { bool is_blanked;
if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
is_blanked =
pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp); else
is_blanked =
pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg); if (!is_blanked) { if (j == 0) break;
swap(pipe_set[0], pipe_set[j]); break;
}
}
for (k = 0; k < group_size; k++) { struct dc_stream_status *status = dc_state_get_stream_status(ctx, pipe_set[k]->stream);
/* remove any other unblanked pipes as they have already been synced */ if (dc->config.use_pipe_ctx_sync_logic) { /* check pipe's syncd to decide which pipe to be removed */ for (j = 1; j < group_size; j++) { if (pipe_set[j]->pipe_idx_syncd == pipe_set[0]->pipe_idx_syncd) {
group_size--;
pipe_set[j] = pipe_set[group_size];
j--;
} else /* link slave pipe's syncd with master pipe */
pipe_set[j]->pipe_idx_syncd = pipe_set[0]->pipe_idx_syncd;
}
} else { /* remove any other pipes by checking valid plane */ for (j = j + 1; j < group_size; j++) { bool is_blanked;
if (pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked)
is_blanked =
pipe_set[j]->stream_res.opp->funcs->dpg_is_blanked(pipe_set[j]->stream_res.opp); else
is_blanked =
pipe_set[j]->stream_res.tg->funcs->is_blanked(pipe_set[j]->stream_res.tg); if (!is_blanked) {
group_size--;
pipe_set[j] = pipe_set[group_size];
j--;
}
}
}
if (stream_count != dc->current_state->stream_count) returntrue;
for (i = 0; i < dc->current_state->stream_count; i++) { if (dc->current_state->streams[i] != streams[i]) returntrue; if (!streams[i]->link->link_state_valid) returntrue;
}
/* Support seamless boot on EDP displays only */ if (sink->sink_signal != SIGNAL_TYPE_EDP) { returnfalse;
}
if (dc->debug.force_odm_combine) {
DC_LOG_DEBUG("boot timing validation failed due to force_odm_combine\n"); returnfalse;
}
/* Check for enabled DIG to identify enabled display */ if (!link->link_enc->funcs->is_dig_enabled(link->link_enc)) {
DC_LOG_DEBUG("boot timing validation failed due to disabled DIG\n"); returnfalse;
}
// tg_inst not found if (i == dc->res_pool->stream_enc_count) {
DC_LOG_DEBUG("boot timing validation failed due to timing generator instance not found\n"); returnfalse;
}
if (tg_inst >= dc->res_pool->timing_generator_count) {
DC_LOG_DEBUG("boot timing validation failed due to invalid timing generator count\n"); returnfalse;
}
if (tg_inst != link->link_enc->preferred_engine) {
DC_LOG_DEBUG("boot timing validation failed due to non-preferred timing generator\n"); returnfalse;
}
tg = dc->res_pool->timing_generators[tg_inst];
if (!tg->funcs->get_hw_timing) {
DC_LOG_DEBUG("boot timing validation failed due to missing get_hw_timing callback\n"); returnfalse;
}
if (!tg->funcs->get_hw_timing(tg, &hw_crtc_timing)) {
DC_LOG_DEBUG("boot timing validation failed due to failed get_hw_timing return\n"); returnfalse;
}
if (crtc_timing->h_total != hw_crtc_timing.h_total) {
DC_LOG_DEBUG("boot timing validation failed due to h_total mismatch\n"); returnfalse;
}
if (crtc_timing->h_border_left != hw_crtc_timing.h_border_left) {
DC_LOG_DEBUG("boot timing validation failed due to h_border_left mismatch\n"); returnfalse;
}
if (crtc_timing->h_addressable != hw_crtc_timing.h_addressable) {
DC_LOG_DEBUG("boot timing validation failed due to h_addressable mismatch\n"); returnfalse;
}
if (crtc_timing->h_border_right != hw_crtc_timing.h_border_right) {
DC_LOG_DEBUG("boot timing validation failed due to h_border_right mismatch\n"); returnfalse;
}
if (crtc_timing->h_front_porch != hw_crtc_timing.h_front_porch) {
DC_LOG_DEBUG("boot timing validation failed due to h_front_porch mismatch\n"); returnfalse;
}
if (crtc_timing->h_sync_width != hw_crtc_timing.h_sync_width) {
DC_LOG_DEBUG("boot timing validation failed due to h_sync_width mismatch\n"); returnfalse;
}
if (crtc_timing->v_total != hw_crtc_timing.v_total) {
DC_LOG_DEBUG("boot timing validation failed due to v_total mismatch\n"); returnfalse;
}
if (crtc_timing->v_border_top != hw_crtc_timing.v_border_top) {
DC_LOG_DEBUG("boot timing validation failed due to v_border_top mismatch\n"); returnfalse;
}
if (crtc_timing->v_addressable != hw_crtc_timing.v_addressable) {
DC_LOG_DEBUG("boot timing validation failed due to v_addressable mismatch\n"); returnfalse;
}
if (crtc_timing->v_border_bottom != hw_crtc_timing.v_border_bottom) {
DC_LOG_DEBUG("boot timing validation failed due to v_border_bottom mismatch\n"); returnfalse;
}
if (crtc_timing->v_front_porch != hw_crtc_timing.v_front_porch) {
DC_LOG_DEBUG("boot timing validation failed due to v_front_porch mismatch\n"); returnfalse;
}
if (crtc_timing->v_sync_width != hw_crtc_timing.v_sync_width) {
DC_LOG_DEBUG("boot timing validation failed due to v_sync_width mismatch\n"); returnfalse;
}
/* block DSC for now, as VBIOS does not currently support DSC timings */ if (crtc_timing->flags.DSC) {
DC_LOG_DEBUG("boot timing validation failed due to DSC\n"); returnfalse;
}
if (pixels_per_cycle != 1 && !dc->debug.enable_dp_dig_pixel_rate_div_policy) {
DC_LOG_DEBUG("boot timing validation failed due to pixels_per_cycle\n"); returnfalse;
}
pix_clk_100hz *= pixels_per_cycle;
}
// Note: In rare cases, HW pixclk may differ from crtc's pixclk // slightly due to rounding issues in 10 kHz units. if (crtc_timing->pix_clk_100hz != pix_clk_100hz) {
DC_LOG_DEBUG("boot timing validation failed due to pix_clk_100hz mismatch\n"); returnfalse;
}
if (!se || !se->funcs->dp_get_pixel_format) {
DC_LOG_DEBUG("boot timing validation failed due to missing dp_get_pixel_format\n"); returnfalse;
}
if (!se->funcs->dp_get_pixel_format(
se,
&hw_crtc_timing.pixel_encoding,
&hw_crtc_timing.display_color_depth)) {
DC_LOG_DEBUG("boot timing validation failed due to dp_get_pixel_format failure\n"); returnfalse;
}
if (hw_crtc_timing.display_color_depth != crtc_timing->display_color_depth) {
DC_LOG_DEBUG("boot timing validation failed due to display_color_depth mismatch\n"); returnfalse;
}
if (hw_crtc_timing.pixel_encoding != crtc_timing->pixel_encoding) {
DC_LOG_DEBUG("boot timing validation failed due to pixel_encoding mismatch\n"); returnfalse;
}
}
if (link->dpcd_caps.dprx_feature.bits.VSC_SDP_COLORIMETRY_SUPPORTED) {
DC_LOG_DEBUG("boot timing validation failed due to VSC SDP colorimetry\n"); returnfalse;
}
if (link->dpcd_caps.channel_coding_cap.bits.DP_128b_132b_SUPPORTED) {
DC_LOG_DEBUG("boot timing validation failed due to DP 128b/132b\n"); returnfalse;
}
if (dc->link_srv->edp_is_ilr_optimization_required(link, crtc_timing)) {
DC_LOG_EVENT_LINK_TRAINING("Seamless boot disabled to optimize eDP link rate\n"); returnfalse;
}
static uint8_t get_stream_mask(struct dc *dc, struct dc_state *context)
{ int i; unsignedint stream_mask = 0;
for (i = 0; i < dc->res_pool->pipe_count; i++) { if (context->res_ctx.pipe_ctx[i].stream)
stream_mask |= 1 << i;
}
return stream_mask;
}
void dc_z10_restore(conststruct dc *dc)
{ if (dc->hwss.z10_restore)
dc->hwss.z10_restore(dc);
}
void dc_z10_save_init(struct dc *dc)
{ if (dc->hwss.z10_save_init)
dc->hwss.z10_save_init(dc);
}
/* Set a pipe unlock order based on the change in DET allocation and stores it in dc scratch memory * Prevents over allocation of DET during unlock process * e.g. 2 pipe config with different streams with a max of 20 DET segments * Before: After: * - Pipe0: 10 DET segments - Pipe0: 12 DET segments * - Pipe1: 10 DET segments - Pipe1: 8 DET segments * If Pipe0 gets updated first, 22 DET segments will be allocated
*/ staticvoid determine_pipe_unlock_order(struct dc *dc, struct dc_state *context)
{ unsignedint i = 0; struct pipe_ctx *pipe = NULL; struct timing_generator *tg = NULL;
if (!dc->config.set_pipe_unlock_order) return;
memset(dc->scratch.pipes_to_unlock_first, 0, sizeof(dc->scratch.pipes_to_unlock_first)); for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &context->res_ctx.pipe_ctx[i];
tg = pipe->stream_res.tg;
/** * dc_commit_state_no_check - Apply context to the hardware * * @dc: DC object with the current status to be updated * @context: New state that will become the current status at the end of this function * * Applies given context to the hardware and copy it into current context. * It's up to the user to release the src context afterwards. * * Return: an enum dc_status result code for the operation
*/ staticenum dc_status dc_commit_state_no_check(struct dc *dc, struct dc_state *context)
{ struct dc_bios *dcb = dc->ctx->dc_bios; enum dc_status result = DC_ERROR_UNEXPECTED; struct pipe_ctx *pipe; int i, k, l; struct dc_stream_state *dc_streams[MAX_STREAMS] = {0}; struct dc_state *old_state; bool subvp_prev_use = false;
for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i];
/* Check old context for SubVP */
subvp_prev_use |= (dc_state_get_pipe_subvp_type(dc->current_state, old_pipe) == SUBVP_PHANTOM); if (subvp_prev_use) break;
}
for (i = 0; i < context->stream_count; i++)
dc_streams[i] = context->streams[i];
if (!dcb->funcs->is_accelerated_mode(dcb)) {
disable_vbios_mode_if_required(dc, context);
dc->hwss.enable_accelerated_mode(dc, context);
}
if (dc->hwseq->funcs.wait_for_pipe_update_if_needed) { for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &context->res_ctx.pipe_ctx[i]; //Only delay otg master for a given config if (resource_is_pipe_type(pipe, OTG_MASTER)) { //dc_commit_state_no_check is always a full update
dc->hwseq->funcs.wait_for_pipe_update_if_needed(dc, pipe, false); break;
}
}
}
if (context->stream_count > get_seamless_boot_stream_count(context) ||
context->stream_count == 0)
dc->hwss.prepare_bandwidth(dc, context);
/* When SubVP is active, all HW programming must be done while * SubVP lock is acquired
*/ if (dc->hwss.subvp_pipe_control_lock)
dc->hwss.subvp_pipe_control_lock(dc, context, true, true, NULL, subvp_prev_use); if (dc->hwss.fams2_global_control_lock)
dc->hwss.fams2_global_control_lock(dc, context, true);
if (dc->hwss.update_dsc_pg)
dc->hwss.update_dsc_pg(dc, context, false);
disable_dangling_plane(dc, context); /* re-program planes for existing stream, in case we need to * free up plane resource for later use
*/ if (dc->hwss.apply_ctx_for_surface) { for (i = 0; i < context->stream_count; i++) { if (context->streams[i]->mode_changed) continue;
apply_ctx_interdependent_lock(dc, context, context->streams[i], true);
dc->hwss.apply_ctx_for_surface(
dc, context->streams[i],
context->stream_status[i].plane_count,
context); /* use new pipe config in new context */
apply_ctx_interdependent_lock(dc, context, context->streams[i], false);
dc->hwss.post_unlock_program_front_end(dc, context);
}
}
/* Program hardware */ for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &context->res_ctx.pipe_ctx[i];
dc->hwss.wait_for_mpcc_disconnect(dc, dc->res_pool, pipe);
}
result = dc->hwss.apply_ctx_to_hw(dc, context);
if (result != DC_OK) { /* Application of dc_state to hardware stopped. */
dc->current_state->res_ctx.link_enc_cfg_ctx.mode = LINK_ENC_CFG_STEADY; return result;
}
dc_trigger_sync(dc, context);
/* Full update should unconditionally be triggered when dc_commit_state_no_check is called */ for (i = 0; i < context->stream_count; i++) {
uint32_t prev_dsc_changed = context->streams[i]->update_flags.bits.dsc_changed;
determine_pipe_unlock_order(dc, context); /* Program all planes within new context*/ if (dc->res_pool->funcs->prepare_mcache_programming)
dc->res_pool->funcs->prepare_mcache_programming(dc, context); if (dc->hwss.program_front_end_for_ctx) {
dc->hwss.interdependent_update_lock(dc, context, true);
dc->hwss.program_front_end_for_ctx(dc, context);
if (dc->hwseq->funcs.set_wait_for_update_needed_for_pipe) { for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &context->res_ctx.pipe_ctx[i];
dc->hwseq->funcs.set_wait_for_update_needed_for_pipe(dc, pipe);
}
}
/* * enable stereo * TODO rework dc_enable_stereo call to work with validation sets?
*/ for (k = 0; k < MAX_PIPES; k++) {
pipe = &context->res_ctx.pipe_ctx[k];
for (l = 0 ; pipe && l < context->stream_count; l++) { if (context->streams[l] &&
context->streams[l] == pipe->stream &&
dc->hwss.setup_stereo)
dc->hwss.setup_stereo(pipe, dc);
}
}
if (get_seamless_boot_stream_count(context) == 0 ||
context->stream_count == 0) { /* Must wait for no flips to be pending before doing optimize bw */
hwss_wait_for_no_pipes_pending(dc, context); /* * optimized dispclk depends on ODM setup. Need to wait for ODM * update pending complete before optimizing bandwidth.
*/
hwss_wait_for_odm_update_pending_complete(dc, context); /* pplib is notified if disp_num changed */
dc->hwss.optimize_bandwidth(dc, context); /* Need to do otg sync again as otg could be out of sync due to otg * workaround applied during clock update
*/
dc_trigger_sync(dc, context);
}
if (dc->hwss.update_dsc_pg)
dc->hwss.update_dsc_pg(dc, context, true);
if (dc->ctx->dce_version >= DCE_VERSION_MAX)
TRACE_DCN_CLOCK_STATE(&context->bw_ctx.bw.dcn.clk); else
TRACE_DCE_CLOCK_STATE(&context->bw_ctx.bw.dce);
if (context->stream_mask != dc->current_state->stream_mask)
dc_dmub_srv_notify_stream_mask(dc->ctx->dmub_srv, context->stream_mask);
for (i = 0; i < context->stream_count; i++)
context->streams[i]->mode_changed = false;
/* Clear update flags that were set earlier to avoid redundant programming */ for (i = 0; i < context->stream_count; i++) {
context->streams[i]->update_flags.raw = 0x0;
}
staticbool commit_minimal_transition_state(struct dc *dc, struct dc_state *transition_base_context);
/** * dc_commit_streams - Commit current stream state * * @dc: DC object with the commit state to be configured in the hardware * @params: Parameters for the commit, including the streams to be committed * * Function responsible for commit streams change to the hardware. * * Return: * Return DC_OK if everything work as expected, otherwise, return a dc_status * code.
*/ enum dc_status dc_commit_streams(struct dc *dc, struct dc_commit_streams_params *params)
{ int i, j; struct dc_state *context; enum dc_status res = DC_OK; struct dc_validation_set set[MAX_STREAMS] = {0}; struct pipe_ctx *pipe; bool handle_exit_odm2to1 = false;
if (!params) return DC_ERROR_UNEXPECTED;
if (dc->ctx->dce_environment == DCE_ENV_VIRTUAL_HW) return res;
if (!streams_changed(dc, params->streams, params->stream_count) &&
dc->current_state->power_source == params->power_source) return res;
for (i = 0; i < params->stream_count; i++) { struct dc_stream_state *stream = params->streams[i]; struct dc_stream_status *status = dc_stream_get_status(stream); struct dc_sink *sink = stream->sink;
/* revalidate streams */ if (!dc_is_virtual_signal(sink->sink_signal)) {
res = dc_validate_stream(dc, stream); if (res != DC_OK) return res;
}
dc_stream_log(dc, stream);
set[i].stream = stream;
if (status) {
set[i].plane_count = status->plane_count; for (j = 0; j < status->plane_count; j++)
set[i].plane_states[j] = status->plane_states[j];
}
}
/* ODM Combine 2:1 power optimization is only applied for single stream * scenario, it uses extra pipes than needed to reduce power consumption * We need to switch off this feature to make room for new streams.
*/ if (params->stream_count > dc->current_state->stream_count &&
dc->current_state->stream_count == 1) { for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &dc->current_state->res_ctx.pipe_ctx[i]; if (pipe->next_odm_pipe)
handle_exit_odm2to1 = true;
}
}
if (handle_exit_odm2to1)
res = commit_minimal_transition_state(dc, dc->current_state);
context = dc_state_create_current_copy(dc); if (!context) goto context_alloc_fail;
context->power_source = params->power_source;
res = dc_validate_with_context(dc, set, params->stream_count, context, DC_VALIDATE_MODE_AND_PROGRAMMING);
/* * Only update link encoder to stream assignment after bandwidth validation passed.
*/ if (res == DC_OK && dc->res_pool->funcs->link_encs_assign && !dc->config.unify_link_enc_assignment)
dc->res_pool->funcs->link_encs_assign(
dc, context, context->streams, context->stream_count);
if (res != DC_OK) {
BREAK_TO_DEBUGGER(); goto fail;
}
/* * If not already seamless, make transition seamless by inserting intermediate minimal transition
*/ if (dc->hwss.is_pipe_topology_transition_seamless &&
!dc->hwss.is_pipe_topology_transition_seamless(dc, dc->current_state, context)) {
res = commit_minimal_transition_state(dc, context); if (res != DC_OK) {
BREAK_TO_DEBUGGER(); goto fail;
}
}
res = dc_commit_state_no_check(dc, context);
for (i = 0; i < params->stream_count; i++) { for (j = 0; j < context->stream_count; j++) { if (params->streams[i]->stream_id == context->streams[j]->stream_id)
params->streams[i]->out.otg_offset = context->stream_status[j].primary_otg_inst;
if (dc_is_embedded_signal(params->streams[i]->signal)) { struct dc_stream_status *status = dc_state_get_stream_status(context, params->streams[i]);
if (pool && res_ctx) { if (acquire) { /*find pipe idx for the given stream*/ for (pipe_idx = 0; pipe_idx < pool->pipe_count; pipe_idx++) { if (res_ctx->pipe_ctx[pipe_idx].stream == stream) {
found_pipe_idx = true;
mpcc_id = res_ctx->pipe_ctx[pipe_idx].plane_res.hubp->inst; break;
}
}
} else
found_pipe_idx = true;/*for release pipe_idx is not required*/
if (found_pipe_idx) { if (acquire && pool->funcs->acquire_post_bldn_3dlut)
ret = pool->funcs->acquire_post_bldn_3dlut(res_ctx, pool, mpcc_id, lut, shaper); elseif (!acquire && pool->funcs->release_post_bldn_3dlut)
ret = pool->funcs->release_post_bldn_3dlut(res_ctx, pool, lut, shaper);
}
} return ret;
}
staticbool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context)
{ int i; struct pipe_ctx *pipe;
for (i = 0; i < MAX_PIPES; i++) {
pipe = &context->res_ctx.pipe_ctx[i];
// Don't check flip pending on phantom pipes if (!pipe->plane_state || (dc_state_get_pipe_subvp_type(context, pipe) == SUBVP_PHANTOM)) continue;
/* Must set to false to start with, due to OR in update function */
pipe->plane_state->status.is_flip_pending = false;
dc->hwss.update_pending_status(pipe); if (pipe->plane_state->status.is_flip_pending) returntrue;
} returnfalse;
}
/* Perform updates here which need to be deferred until next vupdate * * i.e. blnd lut, 3dlut, and shaper lut bypass regs are double buffered * but forcing lut memory to shutdown state is immediate. This causes * single frame corruption as lut gets disabled mid-frame unless shutdown * is deferred until after entering bypass.
*/ staticvoid process_deferred_updates(struct dc *dc)
{ int i = 0;
if (dc->debug.enable_mem_low_power.bits.cm) {
ASSERT(dc->dcn_ip->max_num_dpp); for (i = 0; i < dc->dcn_ip->max_num_dpp; i++) if (dc->res_pool->dpps[i]->funcs->dpp_deferred_update)
dc->res_pool->dpps[i]->funcs->dpp_deferred_update(dc->res_pool->dpps[i]);
}
}
void dc_post_update_surfaces_to_stream(struct dc *dc)
{ int i; struct dc_state *context = dc->current_state;
if ((!dc->optimized_required) || get_seamless_boot_stream_count(context) > 0) return;
post_surface_trace(dc);
/* * Only relevant for DCN behavior where we can guarantee the optimization * is safe to apply - retain the legacy behavior for DCE.
*/
if (dc->ctx->dce_version < DCE_VERSION_MAX)
TRACE_DCE_CLOCK_STATE(&context->bw_ctx.bw.dce); else {
TRACE_DCN_CLOCK_STATE(&context->bw_ctx.bw.dcn.clk);
if (is_flip_pending_in_pipes(dc, context)) return;
for (i = 0; i < dc->res_pool->pipe_count; i++) if (context->res_ctx.pipe_ctx[i].stream == NULL ||
context->res_ctx.pipe_ctx[i].plane_state == NULL) {
context->res_ctx.pipe_ctx[i].pipe_idx = i;
dc->hwss.disable_plane(dc, context, &context->res_ctx.pipe_ctx[i]);
}
process_deferred_updates(dc);
dc->hwss.optimize_bandwidth(dc, context);
if (dc->hwss.update_dsc_pg)
dc->hwss.update_dsc_pg(dc, context, true);
}
if (u->plane_info->dcc.enable != u->surface->dcc.enable
|| u->plane_info->dcc.dcc_ind_blk != u->surface->dcc.dcc_ind_blk
|| u->plane_info->dcc.meta_pitch != u->surface->dcc.meta_pitch) { /* During DCC on/off, stutter period is calculated before * DCC has fully transitioned. This results in incorrect * stutter period calculation. Triggering a full update will * recalculate stutter period.
*/
update_flags->bits.dcc_change = 1;
elevate_update_type(&update_type, UPDATE_TYPE_FULL);
}
if (resource_pixel_format_to_bpp(u->plane_info->format) !=
resource_pixel_format_to_bpp(u->surface->format)) { /* different bytes per element will require full bandwidth * and DML calculation
*/
update_flags->bits.bpp_change = 1;
elevate_update_type(&update_type, UPDATE_TYPE_FULL);
}
/* todo: below are HW dependent, we should add a hook to * DCE/N resource and validated there.
*/ if (!dc->debug.skip_full_updated_if_possible) { /* swizzled mode requires RQ to be setup properly, * thus need to run DML to calculate RQ settings
*/
update_flags->bits.bandwidth_change = 1;
elevate_update_type(&update_type, UPDATE_TYPE_FULL);
}
}
/* This should be UPDATE_TYPE_FAST if nothing has changed. */ return update_type;
}
staticenum surface_update_type get_scaling_info_update_type( conststruct dc *dc, conststruct dc_surface_update *u)
{ union surface_update_flags *update_flags = &u->surface->update_flags;
if (u->scaling_info->src_rect.width > u->surface->src_rect.width
|| u->scaling_info->src_rect.height > u->surface->src_rect.height) /* Making src rect bigger requires a bandwidth change */
update_flags->bits.clock_change = 1;
if ((u->scaling_info->dst_rect.width < u->surface->dst_rect.width
|| u->scaling_info->dst_rect.height < u->surface->dst_rect.height)
&& (u->scaling_info->dst_rect.width < u->surface->src_rect.width
|| u->scaling_info->dst_rect.height < u->surface->src_rect.height)) /* Making dst rect smaller requires a bandwidth change */
update_flags->bits.bandwidth_change = 1;
if (u->scaling_info->src_rect.width > dc->caps.max_optimizable_video_width &&
(u->scaling_info->clip_rect.width > u->surface->clip_rect.width ||
u->scaling_info->clip_rect.height > u->surface->clip_rect.height)) /* Changing clip size of a large surface may result in MPC slice count change */
update_flags->bits.bandwidth_change = 1;
}
/* process every update flag before returning */ if (update_flags->bits.clock_change
|| update_flags->bits.bandwidth_change
|| update_flags->bits.scaling_change) return UPDATE_TYPE_FULL;
if (update_flags->bits.position_change) return UPDATE_TYPE_MED;
type = get_plane_info_update_type(dc, u);
elevate_update_type(&overall_type, type);
type = get_scaling_info_update_type(dc, u);
elevate_update_type(&overall_type, type);
if (u->flip_addr) {
update_flags->bits.addr_update = 1; if (u->flip_addr->address.tmz_surface != u->surface->address.tmz_surface) {
update_flags->bits.tmz_changed = 1;
elevate_update_type(&overall_type, UPDATE_TYPE_FULL);
}
} if (u->in_transfer_func)
update_flags->bits.in_transfer_func_change = 1;
if (u->input_csc_color_matrix)
update_flags->bits.input_csc_change = 1;
if (u->coeff_reduction_factor)
update_flags->bits.coeff_reduction_change = 1;
if (u->gamut_remap_matrix)
update_flags->bits.gamut_remap_change = 1;
if (u->blend_tf)
update_flags->bits.gamma_change = 1;
if (u->gamma) { enum surface_pixel_format format = SURFACE_PIXEL_FORMAT_GRPH_BEGIN;
if (u->plane_info)
format = u->plane_info->format; else
format = u->surface->format;
if (dce_use_lut(format))
update_flags->bits.gamma_change = 1;
}
if (u->lut3d_func || u->func_shaper)
update_flags->bits.lut_3d = 1;
if (u->hdr_mult.value) if (u->hdr_mult.value != u->surface->hdr_mult.value) {
update_flags->bits.hdr_mult = 1;
elevate_update_type(&overall_type, UPDATE_TYPE_MED);
}
if (u->sdr_white_level_nits) if (u->sdr_white_level_nits != u->surface->sdr_white_level_nits) {
update_flags->bits.sdr_white_level_nits = 1;
elevate_update_type(&overall_type, UPDATE_TYPE_FULL);
}
if (u->cm2_params) { if ((u->cm2_params->component_settings.shaper_3dlut_setting
!= u->surface->mcm_shaper_3dlut_setting)
|| (u->cm2_params->component_settings.lut1d_enable
!= u->surface->mcm_lut1d_enable))
update_flags->bits.mcm_transfer_function_enable_change = 1; if (u->cm2_params->cm2_luts.lut3d_data.lut3d_src
!= u->surface->mcm_luts.lut3d_data.lut3d_src)
update_flags->bits.mcm_transfer_function_enable_change = 1;
} if (update_flags->bits.in_transfer_func_change) {
type = UPDATE_TYPE_MED;
elevate_update_type(&overall_type, type);
}
if (update_flags->bits.lut_3d &&
u->surface->mcm_luts.lut3d_data.lut3d_src != DC_CM2_TRANSFER_FUNC_SOURCE_VIDMEM) {
type = UPDATE_TYPE_FULL;
elevate_update_type(&overall_type, type);
} if (update_flags->bits.mcm_transfer_function_enable_change) {
type = UPDATE_TYPE_FULL;
elevate_update_type(&overall_type, type);
}
if (dc->debug.enable_legacy_fast_update &&
(update_flags->bits.gamma_change ||
update_flags->bits.gamut_remap_change ||
update_flags->bits.input_csc_change ||
update_flags->bits.coeff_reduction_change)) {
type = UPDATE_TYPE_FULL;
elevate_update_type(&overall_type, type);
} return overall_type;
}
/* May need to flip the desktop plane in cases where MPO plane receives a flip but desktop plane doesn't * while both planes are flip_immediate
*/ staticvoid force_immediate_gsl_plane_flip(struct dc *dc, struct dc_surface_update *updates, int surface_count)
{ bool has_flip_immediate_plane = false; int i;
for (i = 0; i < surface_count; i++) { if (updates[i].surface->flip_immediate) {
has_flip_immediate_plane = true; break;
}
}
if (has_flip_immediate_plane && surface_count > 1) { for (i = 0; i < surface_count; i++) { if (updates[i].surface->flip_immediate)
updates[i].surface->update_flags.bits.addr_update = 1;
}
}
}
staticenum 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, conststruct dc_stream_status *stream_status)
{ int i; enum surface_update_type overall_type = UPDATE_TYPE_FAST;
if (dc->idle_optimizations_allowed || dc_can_clear_cursor_limit(dc))
overall_type = UPDATE_TYPE_FULL;
if (stream_update->scaler_sharpener_update)
su_flags->bits.scaler_sharpener = 1;
if (stream_update->sharpening_required)
su_flags->bits.sharpening_required = 1;
if (stream_update->output_color_space)
su_flags->bits.out_csc = 1;
if (su_flags->raw != 0)
overall_type = UPDATE_TYPE_FULL;
if (stream_update->output_csc_transform)
su_flags->bits.out_csc = 1;
/* Output transfer function changes do not require bandwidth recalculation, * so don't trigger a full update
*/ if (!dc->debug.enable_legacy_fast_update && stream_update->out_transfer_func)
su_flags->bits.out_tf = 1;
}
for (i = 0 ; i < surface_count; i++) { enum surface_update_type type =
det_surface_update(dc, &updates[i]);
elevate_update_type(&overall_type, type);
}
return overall_type;
}
/* * dc_check_update_surfaces_for_stream() - Determine update type (fast, med, or full) * * See :c:type:`enum surface_update_type <surface_update_type>` for explanation of update types
*/ 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, conststruct dc_stream_status *stream_status)
{ int i; enum surface_update_type type;
if (stream_update)
stream_update->stream->update_flags.raw = 0; for (i = 0; i < surface_count; i++)
updates[i].surface->update_flags.raw = 0;
type = check_update_surfaces_for_stream(dc, updates, surface_count, stream_update, stream_status); if (type == UPDATE_TYPE_FULL) { if (stream_update) {
uint32_t dsc_changed = stream_update->stream->update_flags.bits.dsc_changed;
stream_update->stream->update_flags.raw = 0xFFFFFFFF;
stream_update->stream->update_flags.bits.dsc_changed = dsc_changed;
} for (i = 0; i < surface_count; i++)
updates[i].surface->update_flags.raw = 0xFFFFFFFF;
}
if (type == UPDATE_TYPE_FAST) { // If there's an available clock comparator, we use that. if (dc->clk_mgr->funcs->are_clock_states_equal) { if (!dc->clk_mgr->funcs->are_clock_states_equal(&dc->clk_mgr->clks, &dc->current_state->bw_ctx.bw.dcn.clk))
dc->optimized_required = true; // Else we fallback to mem compare.
} elseif (memcmp(&dc->current_state->bw_ctx.bw.dcn.clk, &dc->clk_mgr->clks, offsetof(struct dc_clocks, prev_p_state_change_support)) != 0) {
dc->optimized_required = true;
}
if (update->hdr_static_metadata)
stream->hdr_static_metadata = *update->hdr_static_metadata;
if (update->abm_level)
stream->abm_level = *update->abm_level;
if (update->periodic_interrupt)
stream->periodic_interrupt = *update->periodic_interrupt;
if (update->gamut_remap)
stream->gamut_remap_matrix = *update->gamut_remap;
/* Note: this being updated after mode set is currently not a use case * however if it arises OCSC would need to be reprogrammed at the * minimum
*/ if (update->output_color_space)
stream->output_color_space = *update->output_color_space;
if (update->output_csc_transform)
stream->csc_color_matrix = *update->output_csc_transform;
if (update->vrr_infopacket)
stream->vrr_infopacket = *update->vrr_infopacket;
if (update->hw_cursor_req)
stream->hw_cursor_req = *update->hw_cursor_req;
if (update->allow_freesync)
stream->allow_freesync = *update->allow_freesync;
if (update->vrr_active_variable)
stream->vrr_active_variable = *update->vrr_active_variable;
if (update->vrr_active_fixed)
stream->vrr_active_fixed = *update->vrr_active_fixed;
if (update->dpms_off)
stream->dpms_off = *update->dpms_off;
if (update->hfvsif_infopacket)
stream->hfvsif_infopacket = *update->hfvsif_infopacket;
if (update->vtem_infopacket)
stream->vtem_infopacket = *update->vtem_infopacket;
if (update->vsc_infopacket)
stream->vsc_infopacket = *update->vsc_infopacket;
if (update->vsp_infopacket)
stream->vsp_infopacket = *update->vsp_infopacket;
if (update->adaptive_sync_infopacket)
stream->adaptive_sync_infopacket = *update->adaptive_sync_infopacket;
if (update->avi_infopacket)
stream->avi_infopacket = *update->avi_infopacket;
if (update->dither_option)
stream->dither_option = *update->dither_option;
if (update->pending_test_pattern)
stream->test_pattern = *update->pending_test_pattern; /* update current stream with writeback info */ if (update->wb_update) { int i;
stream->num_wb_info = update->wb_update->num_wb_info;
ASSERT(stream->num_wb_info <= MAX_DWB_PIPES); for (i = 0; i < stream->num_wb_info; i++)
stream->writeback_info[i] =
update->wb_update->writeback_info[i];
} if (update->dsc_config) { struct dc_dsc_config old_dsc_cfg = stream->timing.dsc_cfg;
uint32_t old_dsc_enabled = stream->timing.flags.DSC;
uint32_t enable_dsc = (update->dsc_config->num_slices_h != 0 &&
update->dsc_config->num_slices_v != 0);
/* Use temporarry context for validating new DSC config */ struct dc_state *dsc_validate_context = dc_state_create_copy(dc->current_state);
for (i = 0; i < status->plane_count; i++) {
dc_plane_copy_config(status->plane_states[i], &scratch->plane_states[i]);
}
*stream = scratch->stream_state;
}
/** * update_seamless_boot_flags() - Helper function for updating seamless boot flags * * @dc: Current DC state * @context: New DC state to be programmed * @surface_count: Number of surfaces that have an updated * @stream: Corresponding stream to be updated in the current flip * * Updating seamless boot flags do not need to be part of the commit sequence. This * helper function will update the seamless boot flags on each flip (if required) * outside of the HW commit sequence (fast or slow). * * Return: void
*/ staticvoid update_seamless_boot_flags(struct dc *dc, struct dc_state *context, int surface_count, struct dc_stream_state *stream)
{ if (get_seamless_boot_stream_count(context) > 0 && (surface_count > 0 || stream->dpms_off)) { /* Optimize seamless boot flag keeps clocks and watermarks high until * first flip. After first flip, optimization is required to lower * bandwidth. Important to note that it is expected UEFI will * only light up a single display on POST, therefore we only expect * one stream with seamless boot flag set.
*/ if (stream->apply_seamless_boot_optimization) {
stream->apply_seamless_boot_optimization = false;
if (get_seamless_boot_stream_count(context) == 0)
dc->optimized_required = true;
}
}
}
/** * update_planes_and_stream_state() - The function takes planes and stream * updates as inputs and determines the appropriate update type. If update type * is FULL, the function allocates a new context, populates and validates it. * Otherwise, it updates current dc context. The function will return both * new_context and new_update_type back to the caller. The function also backs * up both current and new contexts into corresponding dc state scratch memory. * TODO: The function does too many things, and even conditionally allocates dc * context memory implicitly. We should consider to break it down. * * @dc: Current DC state * @srf_updates: an array of surface updates * @surface_count: surface update count * @stream: Corresponding stream to be updated * @stream_update: stream update * @new_update_type: [out] determined update type by the function * @new_context: [out] new context allocated and validated if update type is * FULL, reference to current context if update type is less than FULL. * * Return: true if a valid update is populated into new_context, false * otherwise.
*/ staticbool 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)
{ struct dc_state *context; int i, j; enum surface_update_type update_type; conststruct dc_stream_status *stream_status; struct dc_context *dc_ctx = dc->ctx;
stream_status = dc_stream_get_status(stream);
if (!stream_status) { if (surface_count) /* Only an error condition if surf_count non-zero*/
ASSERT(false);
returnfalse; /* Cannot commit surface to stream that is not committed */
}
context = dc->current_state;
update_type = dc_check_update_surfaces_for_stream(
dc, srf_updates, surface_count, stream_update, stream_status); /* It is possible to receive a flip for one plane while there are multiple flip_immediate planes in the same stream. * E.g. Desktop and MPO plane are flip_immediate but only the MPO plane received a flip * Force the other flip_immediate planes to flip so GSL doesn't wait for a flip that won't come.
*/
force_immediate_gsl_plane_flip(dc, srf_updates, surface_count); if (update_type == UPDATE_TYPE_FULL)
backup_planes_and_stream_state(&dc->scratch.current_state, stream);
/* update current stream with the new updates */
copy_stream_update_to_stream(dc, context, stream, stream_update);
/* do not perform surface update if surface has invalid dimensions * (all zero) and no scaling_info is provided
*/ if (surface_count > 0) { for (i = 0; i < surface_count; i++) { if ((srf_updates[i].surface->src_rect.width == 0 ||
srf_updates[i].surface->src_rect.height == 0 ||
srf_updates[i].surface->dst_rect.width == 0 ||
srf_updates[i].surface->dst_rect.height == 0) &&
(!srf_updates[i].scaling_info ||
srf_updates[i].scaling_info->src_rect.width == 0 ||
srf_updates[i].scaling_info->src_rect.height == 0 ||
srf_updates[i].scaling_info->dst_rect.width == 0 ||
srf_updates[i].scaling_info->dst_rect.height == 0)) {
DC_ERROR("Invalid src/dst rects in surface update!\n"); returnfalse;
}
}
}
if (update_type >= update_surface_trace_level)
update_surface_trace(dc, srf_updates, surface_count);
for (i = 0; i < surface_count; i++)
copy_surface_update_to_plane(srf_updates[i].surface, &srf_updates[i]);
if (update_type >= UPDATE_TYPE_FULL) { struct dc_plane_state *new_planes[MAX_SURFACES] = {0};
for (i = 0; i < surface_count; i++)
new_planes[i] = srf_updates[i].surface;
/* initialize scratch memory for building context */
context = dc_state_create_copy(dc->current_state); if (context == NULL) {
DC_ERROR("Failed to allocate new validate context!\n"); returnfalse;
}
/* For each full update, remove all existing phantom pipes first. * Ensures that we have enough pipes for newly added MPO planes
*/
dc_state_remove_phantom_streams_and_planes(dc, context);
dc_state_release_phantom_streams_and_planes(dc, context);
/*remove old surfaces from context */ if (!dc_state_rem_all_planes_for_stream(dc, stream, context)) {
BREAK_TO_DEBUGGER(); goto fail;
}
/* add surface to context */ if (!dc_state_add_all_planes_for_stream(dc, stream, new_planes, surface_count, context)) {
BREAK_TO_DEBUGGER(); goto fail;
}
}
/* save update parameters into surface */ for (i = 0; i < surface_count; i++) { struct dc_plane_state *surface = srf_updates[i].surface;
if (update_type != UPDATE_TYPE_MED) continue; if (surface->update_flags.bits.position_change) { for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
if (stream_update->cursor_attributes)
program_cursor_attributes(dc, stream);
if (stream_update->cursor_position)
program_cursor_position(dc, stream);
/* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue;
if (stream_update->dsc_config)
dc->link_srv->update_dsc_config(pipe_ctx);
if (stream_update->mst_bw_update) { if (stream_update->mst_bw_update->is_increase)
dc->link_srv->increase_mst_payload(pipe_ctx,
stream_update->mst_bw_update->mst_stream_bw); else
dc->link_srv->reduce_mst_payload(pipe_ctx,
stream_update->mst_bw_update->mst_stream_bw);
}
if (stream_update->pending_test_pattern) { /* * test pattern params depends on ODM topology * changes that we could be applying to front * end. Since at the current stage front end * changes are not yet applied. We can only * apply test pattern in hw based on current * state and populate the final test pattern * params in new state. If current and new test * pattern params are different as result of * different ODM topology being used, it will be * detected and handle during front end * programming update.
*/
dc->link_srv->dp_set_test_pattern(stream->link,
stream->test_pattern.type,
stream->test_pattern.color_space,
stream->test_pattern.p_link_settings,
stream->test_pattern.p_custom_pattern,
stream->test_pattern.cust_pattern_size);
resource_build_test_pattern_params(&context->res_ctx, pipe_ctx);
}
if (stream_update->dpms_off) { if (*stream_update->dpms_off) {
dc->link_srv->set_dpms_off(pipe_ctx); /* for dpms, keep acquired resources*/ if (pipe_ctx->stream_res.audio && !dc->debug.az_endpoint_mute_only)
pipe_ctx->stream_res.audio->funcs->az_disable(pipe_ctx->stream_res.audio);
dc->optimized_required = true;
} else { if (get_seamless_boot_stream_count(context) == 0)
dc->hwss.prepare_bandwidth(dc, dc->current_state);
dc->link_srv->set_dpms_on(dc->current_state, pipe_ctx);
}
} elseif (pipe_ctx->stream->link->wa_flags.blank_stream_on_ocs_change && stream_update->output_color_space
&& !stream->dpms_off && dc_is_dp_signal(pipe_ctx->stream->signal)) { /* * Workaround for firmware issue in some receivers where they don't pick up * correct output color space unless DP link is disabled/re-enabled
*/
dc->link_srv->set_dpms_on(dc->current_state, pipe_ctx);
}
if (stream_update->abm_level && pipe_ctx->stream_res.abm) { bool should_program_abm = true;
// if otg funcs defined check if blanked before programming if (pipe_ctx->stream_res.tg->funcs->is_blanked) if (pipe_ctx->stream_res.tg->funcs->is_blanked(pipe_ctx->stream_res.tg))
should_program_abm = false;
/** * build_dmub_cmd_list() - Build an array of DMCUB commands to be sent to DMCUB * * @dc: Current DC state * @srf_updates: Array of surface updates * @surface_count: Number of surfaces that have an updated * @stream: Corresponding stream to be updated in the current flip * @context: New DC state to be programmed * * @dc_dmub_cmd: Array of DMCUB commands to be sent to DMCUB * @dmub_cmd_count: Count indicating the number of DMCUB commands in dc_dmub_cmd array * * This function builds an array of DMCUB commands to be sent to DMCUB. This function is required * to build an array of commands and have them sent while the OTG lock is acquired. * * Return: void
*/ staticvoid 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[], unsignedint *dmub_cmd_count)
{ // Initialize cmd count to 0
*dmub_cmd_count = 0;
build_dmub_update_dirty_rect(dc, surface_count, stream, srf_updates, context, dc_dmub_cmd, dmub_cmd_count);
}
staticvoid 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)
{ int i, j;
/* update dirty rect for PSR */
dc_dmub_update_dirty_rect(dc, surface_count, stream,
srf_updates, context);
/* Perform requested Updates */ for (i = 0; i < surface_count; i++) { struct dc_plane_state *plane_state = srf_updates[i].surface;
if (should_lock_all_pipes)
determine_pipe_unlock_order(dc, context);
if (dc->debug.fams2_config.bits.enable &&
dc->debug.fams2_config.bits.enable_offload_flip &&
dc_state_is_fams2_in_use(dc, context)) { /* if not offloading to HWFQ, offload to FAMS2 if needed */
should_offload_fams2_flip = true; for (i = 0; i < surface_count; i++) { if (srf_updates[i].surface &&
srf_updates[i].surface->update_flags.raw &&
!check_address_only_update(srf_updates[i].surface->update_flags)) { /* more than address update, need to acquire FAMS2 lock */
should_offload_fams2_flip = false; break;
}
} if (stream_update) { /* more than address update, need to acquire FAMS2 lock */
should_offload_fams2_flip = false;
}
}
/* Clear update flags so next flip doesn't have redundant programming * (if there's no stream update, the update flags are not cleared). * Surface updates are cleared unconditionally at the beginning of each flip, * so no need to clear here.
*/ if (top_pipe_to_program->stream)
top_pipe_to_program->stream->update_flags.raw = 0;
}
if (should_lock_all_pipes)
determine_pipe_unlock_order(dc, context); // Once we apply the new subvp context to hardware it won't be in the // dc->current_state anymore, so we have to cache it before we apply // the new SubVP context
subvp_prev_use = false;
dc_exit_ips_for_hw_access(dc);
dc_z10_restore(dc); if (update_type == UPDATE_TYPE_FULL && dc->optimized_required)
hwss_process_outstanding_hw_updates(dc, dc->current_state);
if (update_type != UPDATE_TYPE_FAST && dc->res_pool->funcs->prepare_mcache_programming)
dc->res_pool->funcs->prepare_mcache_programming(dc, context);
for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *pipe = &context->res_ctx.pipe_ctx[i];
if (pipe->stream && pipe->plane_state) { if (!dc->debug.using_dml2)
set_p_state_switch_method(dc, context, pipe);
if (dc->debug.visual_confirm)
dc_update_visual_confirm_color(dc, context, pipe);
}
}
if (update_type == UPDATE_TYPE_FULL) {
dc_allow_idle_optimizations(dc, false);
if (get_seamless_boot_stream_count(context) == 0)
dc->hwss.prepare_bandwidth(dc, context);
if (dc->hwss.update_dsc_pg)
dc->hwss.update_dsc_pg(dc, context, false);
context_clock_trace(dc, context);
}
if (update_type == UPDATE_TYPE_FULL)
hwss_wait_for_outstanding_hw_updates(dc, dc->current_state);
if (dc->hwss.fams2_global_control_lock)
dc->hwss.fams2_global_control_lock(dc, context, true);
/* Lock the top pipe while updating plane addrs, since freesync requires * plane addr update event triggers to be synchronized. * top_pipe_to_program is expected to never be NULL
*/
dc->hwss.pipe_control_lock(dc, top_pipe_to_program, true);
}
// Stream updates if (stream_update)
commit_planes_do_stream_update(dc, stream, stream_update, update_type, context);
if (surface_count == 0) { /* * In case of turning off screen, no need to program front end a second time. * just return after program blank.
*/ if (dc->hwss.apply_ctx_for_surface)
dc->hwss.apply_ctx_for_surface(dc, stream, 0, context); if (dc->hwss.program_front_end_for_ctx)
dc->hwss.program_front_end_for_ctx(dc, context);
if (update_type != UPDATE_TYPE_FAST) if (dc->hwss.commit_subvp_config)
dc->hwss.commit_subvp_config(dc, context);
/* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup
*/ if (dc->hwss.subvp_pipe_control_lock)
dc->hwss.subvp_pipe_control_lock(dc, context, false, should_lock_all_pipes,
NULL, subvp_prev_use);
if (dc->hwss.fams2_global_control_lock)
dc->hwss.fams2_global_control_lock(dc, context, false);
return;
}
if (update_type != UPDATE_TYPE_FAST) { for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
if ((dc->debug.visual_confirm == VISUAL_CONFIRM_SUBVP ||
dc->debug.visual_confirm == VISUAL_CONFIRM_MCLK_SWITCH) &&
pipe_ctx->stream && pipe_ctx->plane_state) { /* Only update visual confirm for SUBVP and Mclk switching here. * The bar appears on all pipes, so we need to update the bar on all displays, * so the information doesn't get stale.
*/
dc->hwss.update_visual_confirm_color(dc, pipe_ctx,
pipe_ctx->plane_res.hubp->inst);
}
}
}
for (i = 0; i < surface_count; i++) { struct dc_plane_state *plane_state = srf_updates[i].surface;
/*set logical flag for lock/unlock use*/ for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j]; if (!pipe_ctx->plane_state) continue; if (!should_update_pipe_for_plane(context, pipe_ctx, plane_state)) continue;
pipe_ctx->plane_state->triplebuffer_flips = false; if (update_type == UPDATE_TYPE_FAST &&
dc->hwss.program_triplebuffer != NULL &&
!pipe_ctx->plane_state->flip_immediate && dc->debug.enable_tri_buf) { /*triple buffer for VUpdate only*/
pipe_ctx->plane_state->triplebuffer_flips = true;
}
} if (update_type == UPDATE_TYPE_FULL) { /* force vsync flip when reconfiguring pipes to prevent underflow */
plane_state->flip_immediate = false;
plane_state->triplebuffer_flips = false;
}
}
// Update Type FULL, Surface updates for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
/* Full fe update*/ if (update_type == UPDATE_TYPE_FAST) continue;
ASSERT(!pipe_ctx->plane_state->triplebuffer_flips); if (dc->hwss.program_triplebuffer != NULL && dc->debug.enable_tri_buf) { /*turn off triple buffer for full update*/
dc->hwss.program_triplebuffer(
dc, pipe_ctx, pipe_ctx->plane_state->triplebuffer_flips);
}
}
if (dc->hwss.program_front_end_for_ctx && update_type != UPDATE_TYPE_FAST) {
dc->hwss.program_front_end_for_ctx(dc, context);
//Pipe busy until some frame and line # if (dc->hwseq->funcs.set_wait_for_update_needed_for_pipe && update_type == UPDATE_TYPE_FULL) { for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
if (dc->debug.validate_dml_output) { for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *cur_pipe = &context->res_ctx.pipe_ctx[i]; if (cur_pipe->stream == NULL) continue;
// Update Type FAST, Surface updates if (update_type == UPDATE_TYPE_FAST) { if (dc->hwss.set_flip_control_gsl) for (i = 0; i < surface_count; i++) { struct dc_plane_state *plane_state = srf_updates[i].surface;
if (subvp_curr_use) { /* If enabling subvp or transitioning from subvp->subvp, enable the * phantom streams before we program front end for the phantom pipes.
*/ if (update_type != UPDATE_TYPE_FAST) { if (dc->hwss.enable_phantom_streams)
dc->hwss.enable_phantom_streams(dc, context);
}
}
if (update_type != UPDATE_TYPE_FAST)
dc->hwss.post_unlock_program_front_end(dc, context);
if (subvp_prev_use && !subvp_curr_use) { /* If disabling subvp, disable phantom streams after front end * programming has completed (we turn on phantom OTG in order * to complete the plane disable for phantom pipes).
*/
if (dc->hwss.disable_phantom_streams)
dc->hwss.disable_phantom_streams(dc, context);
}
if (update_type != UPDATE_TYPE_FAST) if (dc->hwss.commit_subvp_config)
dc->hwss.commit_subvp_config(dc, context); /* Since phantom pipe programming is moved to post_unlock_program_front_end, * move the SubVP lock to after the phantom pipes have been setup
*/ if (should_lock_all_pipes && dc->hwss.interdependent_update_lock) { if (dc->hwss.subvp_pipe_control_lock)
dc->hwss.subvp_pipe_control_lock(dc, context, false, should_lock_all_pipes, NULL, subvp_prev_use); if (dc->hwss.fams2_global_control_lock)
dc->hwss.fams2_global_control_lock(dc, context, false);
} else { if (dc->hwss.subvp_pipe_control_lock)
dc->hwss.subvp_pipe_control_lock(dc, context, false, should_lock_all_pipes, top_pipe_to_program, subvp_prev_use); if (dc->hwss.fams2_global_control_lock)
dc->hwss.fams2_global_control_lock(dc, context, false);
}
// Fire manual trigger only when bottom plane is flipped for (j = 0; j < dc->res_pool->pipe_count; j++) { struct pipe_ctx *pipe_ctx = &context->res_ctx.pipe_ctx[j];
/** * could_mpcc_tree_change_for_active_pipes - Check if an OPP associated with MPCC might change * * @dc: Used to get the current state status * @stream: Target stream, which we want to remove the attached planes * @srf_updates: Array of surface updates * @surface_count: Number of surface update * @is_plane_addition: [in] Fill out with true if it is a plane addition case * * DCN32x and newer support a feature named Dynamic ODM which can conflict with * the MPO if used simultaneously in some specific configurations (e.g., * 4k@144). This function checks if the incoming context requires applying a * transition state with unnecessary pipe splitting and ODM disabled to * circumvent our hardware limitations to prevent this edge case. If the OPP * associated with an MPCC might change due to plane additions, this function * returns true. * * Return: * Return true if OPP and MPCC might change, otherwise, return false.
*/ staticbool 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)
{
/* For SubVP when adding or removing planes we need to add a minimal transition * (even when disabling all planes). Whenever disabling a phantom pipe, we * must use the minimal transition path to disable the pipe correctly. * * We want to use the minimal transition whenever subvp is active, not only if * a plane is being added / removed from a subvp stream (MPO plane can be added * to a DRR pipe of SubVP + DRR config, in which case we still want to run through * a min transition to disable subvp.
*/ if (cur_stream_status && subvp_active) { /* determine if minimal transition is required due to SubVP*/ if (cur_stream_status->plane_count > surface_count) {
force_minimal_pipe_splitting = true;
} elseif (cur_stream_status->plane_count < surface_count) {
force_minimal_pipe_splitting = true;
*is_plane_addition = true;
}
}
int i; struct dc_state *old = dc->current_state; struct pipe_ctx *pipe_ctx;
/* Since memory free requires elevated IRQ, an interrupt * request is generated by mem free. If this happens * between freeing and reassigning the context, our vsync * interrupt will call into dc and cause a memory * corruption. Hence, we first reassign the context, * then free the old context.
*/
dc->current_state = new_context;
dc_state_release(old);
// clear any forced full updates for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe_ctx = &new_context->res_ctx.pipe_ctx[i];
/* * Both current and new contexts share the same stream and plane state * pointers. When new context is validated, stream and planes get * populated with new updates such as new plane addresses. This makes * the current context no longer valid because stream and planes are * modified from the original. We backup current stream and plane states * into scratch space whenever we are populating new context. So we can * restore the original values back by calling the restore function now. * This restores back the original stream and plane states associated * with the current state.
*/
restore_planes_and_stream_state(&dc->scratch.current_state, stream);
dc_state_retain(old_current_state);
intermediate_context = create_minimal_transition_state(dc,
old_current_state, &policy);
if (intermediate_context) { if (is_pipe_topology_transition_seamless_with_intermediate_step(
dc,
dc->current_state,
intermediate_context,
new_context)) {
DC_LOG_DC("commit minimal transition state: base = current state\n");
surface_count = initialize_empty_surface_updates(
stream, srf_updates);
commit_planes_for_stream(dc, srf_updates,
surface_count, stream, NULL,
UPDATE_TYPE_FULL, intermediate_context);
swap_and_release_current_context(
dc, intermediate_context, stream);
dc_state_retain(dc->current_state);
success = true;
}
release_minimal_transition_state(dc, intermediate_context,
old_current_state, &policy);
}
dc_state_release(old_current_state); /* * Restore stream and plane states back to the values associated with * new context.
*/
restore_planes_and_stream_state(&dc->scratch.new_state, stream); return success;
}
/** * commit_minimal_transition_state_in_dc_update - Commit a minimal state based * on current or new context * * @dc: DC structure, used to get the current state * @new_context: New context * @stream: Stream getting the update for the flip * @srf_updates: Surface updates * @surface_count: Number of surfaces * * The function takes in current state and new state and determine a minimal * transition state as the intermediate step which could make the transition * between current and new states seamless. If found, it will commit the minimal * transition state and update current state to this minimal transition state * and return true, if not, it will return false. * * Return: * Return True if the minimal transition succeeded, false otherwise
*/ staticbool 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)
{ bool success = commit_minimal_transition_based_on_new_context(
dc, new_context, stream, srf_updates,
surface_count); if (!success)
success = commit_minimal_transition_based_on_current_context(dc,
new_context, stream); if (!success)
DC_LOG_ERROR("Fail to commit a seamless minimal transition state between current and new states.\nThis pipe topology update is non-seamless!\n"); return success;
}
/** * commit_minimal_transition_state - Create a transition pipe split state * * @dc: Used to get the current state status * @transition_base_context: New transition state * * In some specific configurations, such as pipe split on multi-display with * MPO and/or Dynamic ODM, removing a plane may cause unsupported pipe * programming when moving to new planes. To mitigate those types of problems, * this function adds a transition state that minimizes pipe usage before * programming the new configuration. When adding a new plane, the current * state requires the least pipes, so it is applied without splitting. When * removing a plane, the new state requires the least pipes, so it is applied * without splitting. * * Return: * Return false if something is wrong in the transition state.
*/ staticbool commit_minimal_transition_state(struct dc *dc, struct dc_state *transition_base_context)
{ struct dc_state *transition_context; struct pipe_split_policy_backup policy; enum dc_status ret = DC_ERROR_UNEXPECTED; unsignedint i, j; unsignedint pipe_in_use = 0; bool subvp_in_use = false; bool odm_in_use = false;
/* check current pipes in use*/ for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *pipe = &transition_base_context->res_ctx.pipe_ctx[i];
if (pipe->plane_state)
pipe_in_use++;
}
/* If SubVP is enabled and we are adding or removing planes from any main subvp * pipe, we must use the minimal transition.
*/ for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *pipe = &dc->current_state->res_ctx.pipe_ctx[i];
/* If ODM is enabled and we are adding or removing planes from any ODM * pipe, we must use the minimal transition.
*/ for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *pipe = &transition_base_context->res_ctx.pipe_ctx[i];
/* When the OS add a new surface if we have been used all of pipes with odm combine * and mpc split feature, it need use commit_minimal_transition_state to transition safely. * After OS exit MPO, it will back to use odm and mpc split with all of pipes, we need * call it again. Otherwise return true to skip. * * Reduce the scenarios to use dc_commit_state_no_check in the stage of flip. Especially * enter/exit MPO when DCN still have enough resources.
*/ if (pipe_in_use != dc->res_pool->pipe_count && !subvp_in_use && !odm_in_use) returntrue;
DC_LOG_DC("%s base = %s state, reason = %s\n", __func__,
dc->current_state == transition_base_context ? "current" : "new",
subvp_in_use ? "Subvp In Use" :
odm_in_use ? "ODM in Use" :
dc->debug.pipe_split_policy != MPC_SPLIT_AVOID ? "MPC in Use" : "Unknown");
dc_state_retain(transition_base_context);
transition_context = create_minimal_transition_state(dc,
transition_base_context, &policy); if (transition_context) {
ret = dc_commit_state_no_check(dc, transition_context);
release_minimal_transition_state(dc, transition_context, transition_base_context, &policy);
}
dc_state_release(transition_base_context);
if (ret != DC_OK) { /* this should never happen */
BREAK_TO_DEBUGGER(); returnfalse;
}
/* force full surface update */ for (i = 0; i < dc->current_state->stream_count; i++) { for (j = 0; j < dc->current_state->stream_status[i].plane_count; j++) {
dc->current_state->stream_status[i].plane_states[j]->update_flags.raw = 0xFFFFFFFF;
}
}
returntrue;
}
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)
{ int i = 0;
update_type = dc_check_update_surfaces_for_stream(
dc, srf_updates, surface_count, stream_update, stream_status); /* It is possible to receive a flip for one plane while there are multiple flip_immediate planes in the same stream. * E.g. Desktop and MPO plane are flip_immediate but only the MPO plane received a flip * Force the other flip_immediate planes to flip so GSL doesn't wait for a flip that won't come.
*/
force_immediate_gsl_plane_flip(dc, srf_updates, surface_count);
if (update_type >= UPDATE_TYPE_FULL) {
/* initialize scratch memory for building context */
context = dc_state_create_copy(state); if (context == NULL) {
DC_ERROR("Failed to allocate new validate context!\n"); returnfalse;
}
for (i = 0; i < dc->res_pool->pipe_count; i++) { struct pipe_ctx *new_pipe = &context->res_ctx.pipe_ctx[i]; struct pipe_ctx *old_pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (new_pipe->plane_state && new_pipe->plane_state != old_pipe->plane_state)
new_pipe->plane_state->force_full_update = true;
}
} elseif (update_type == UPDATE_TYPE_FAST) { /* * Previous frame finished and HW is ready for optimization.
*/
dc_post_update_surfaces_to_stream(dc);
}
for (i = 0; i < surface_count; i++) { struct dc_plane_state *surface = srf_updates[i].surface;
/* In cases where MPO and split or ODM are used transitions can * cause underflow. Apply stream configuration with minimal pipe * split first to avoid unsupported transitions for active pipes.
*/ bool force_minimal_pipe_splitting = 0; bool is_plane_addition = 0; bool is_fast_update_only;
/* on plane addition, minimal state is the current one */ if (force_minimal_pipe_splitting && is_plane_addition &&
!commit_minimal_transition_state(dc, dc->current_state)) returnfalse;
if (!update_planes_and_stream_state(
dc,
srf_updates,
surface_count,
stream,
stream_update,
&update_type,
&context)) returnfalse;
/* on plane removal, minimal state is the new one */ if (force_minimal_pipe_splitting && !is_plane_addition) { if (!commit_minimal_transition_state(dc, context)) {
dc_state_release(context); returnfalse;
}
update_type = UPDATE_TYPE_FULL;
}
staticvoid 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)
{
ASSERT(update_type >= UPDATE_TYPE_FULL); if (!dc->hwss.is_pipe_topology_transition_seamless(dc,
dc->current_state, new_context)) /* * It is required by the feature design that all pipe topologies * using extra free pipes for power saving purposes such as * dynamic ODM or SubVp shall only be enabled when it can be * transitioned seamlessly to AND from its minimal transition * state. A minimal transition state is defined as the same dc * state but with all power saving features disabled. So it uses * the minimum pipe topology. When we can't seamlessly * transition from state A to state B, we will insert the * minimal transition state A' or B' in between so seamless * transition between A and B can be made possible.
*/
commit_minimal_transition_state_in_dc_update(dc, new_context,
stream, srf_updates, surface_count);
/* * When this function returns true and new_context is not equal to * current state, the function allocates and validates a new dc state * and assigns it to new_context. The function expects that the caller * is responsible to free this memory when new_context is no longer * used. We swap current with new context and free current instead. So * new_context's memory will live until the next full update after it is * replaced by a newer context. Refer to the use of * swap_and_free_current_context below.
*/ if (!update_planes_and_stream_state(dc, srf_updates, surface_count,
stream, stream_update, &update_type,
&new_context)) returnfalse;
staticvoid clear_update_flags(struct dc_surface_update *srf_updates, int surface_count, struct dc_stream_state *stream)
{ int i;
if (stream)
stream->update_flags.raw = 0;
for (i = 0; i < surface_count; i++) if (srf_updates[i].surface)
srf_updates[i].surface->update_flags.raw = 0;
}
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)
{ bool ret = false;
dc_exit_ips_for_hw_access(dc); /* * update planes and stream version 3 separates FULL and FAST updates * to their own sequences. It aims to clean up frequent checks for * update type resulting unnecessary branching in logic flow. It also * adds a new commit minimal transition sequence, which detects the need * for minimal transition based on the actual comparison of current and * new states instead of "predicting" it based on per feature software * policy.i.e could_mpcc_tree_change_for_active_pipes. The new commit * minimal transition sequence is made universal to any power saving * features that would use extra free pipes such as Dynamic ODM/MPC * Combine, MPO or SubVp. Therefore there is no longer a need to * specially handle compatibility problems with transitions among those * features as they are now transparent to the new sequence.
*/ if (dc->ctx->dce_version >= DCN_VERSION_4_01)
ret = update_planes_and_stream_v3(dc, srf_updates,
surface_count, stream, stream_update); else
ret = update_planes_and_stream_v2(dc, srf_updates,
surface_count, stream, stream_update); if (ret && (dc->ctx->dce_version >= DCN_VERSION_3_2 ||
dc->ctx->dce_version == DCN_VERSION_3_01))
clear_update_flags(srf_updates, surface_count, stream);
return ret;
}
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)
{ bool ret = false;
dc_exit_ips_for_hw_access(dc); /* TODO: Since change commit sequence can have a huge impact, * we decided to only enable it for DCN3x. However, as soon as * we get more confident about this change we'll need to enable * the new sequence for all ASICs.
*/ if (dc->ctx->dce_version >= DCN_VERSION_4_01) {
ret = update_planes_and_stream_v3(dc, srf_updates, surface_count,
stream, stream_update);
} elseif (dc->ctx->dce_version >= DCN_VERSION_3_2) {
ret = update_planes_and_stream_v2(dc, srf_updates, surface_count,
stream, stream_update);
} else
ret = update_planes_and_stream_v1(dc, srf_updates, surface_count, stream,
stream_update, state);
if (ret && dc->ctx->dce_version >= DCN_VERSION_3_2)
clear_update_flags(srf_updates, surface_count, stream);
}
uint8_t dc_get_current_stream_count(struct dc *dc)
{ return dc->current_state->stream_count;
}
struct dc_stream_state *dc_get_stream_at_index(struct dc *dc, uint8_t i)
{ if (i < dc->current_state->stream_count) return dc->current_state->streams[i]; return NULL;
}
// log idle clocks and sub vp pipe types at idle optimization time if (dc->clk_mgr != NULL && dc->clk_mgr->funcs->get_hard_min_fclk)
idle_fclk_khz = dc->clk_mgr->funcs->get_hard_min_fclk(dc->clk_mgr);
if (dc->clk_mgr != NULL && dc->clk_mgr->funcs->get_hard_min_memclk)
idle_dramclk_khz = dc->clk_mgr->funcs->get_hard_min_memclk(dc->clk_mgr);
if (dc->res_pool && context) { for (i = 0; i < dc->res_pool->pipe_count; i++) {
pipe = &context->res_ctx.pipe_ctx[i];
subvp_pipe_type[i] = dc_state_get_pipe_subvp_type(context, pipe);
}
}
void dc_exit_ips_for_hw_access_internal(struct dc *dc, constchar *caller_name)
{ if (dc->caps.ips_support)
dc_allow_idle_optimizations_internal(dc, false, caller_name);
}
bool dc_dmub_is_ips_idle_state(struct dc *dc)
{ if (dc->debug.disable_idle_power_optimizations) returnfalse;
if (!dc->caps.ips_support || (dc->config.disable_ips == DMUB_IPS_DISABLE_ALL)) returnfalse;
if (!dc->ctx->dmub_srv) returnfalse;
return dc->ctx->dmub_srv->idle_allowed;
}
/* set min and max memory clock to lowest and highest DPM level, respectively */ void dc_unlock_memory_clock_frequency(struct dc *dc)
{ if (dc->clk_mgr->funcs->set_hard_min_memclk)
dc->clk_mgr->funcs->set_hard_min_memclk(dc->clk_mgr, false);
if (dc->clk_mgr->funcs->set_hard_max_memclk)
dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
}
/* set min memory clock to the min required for current mode, max to maxDPM */ void dc_lock_memory_clock_frequency(struct dc *dc)
{ if (dc->clk_mgr->funcs->get_memclk_states_from_smu)
dc->clk_mgr->funcs->get_memclk_states_from_smu(dc->clk_mgr);
if (dc->clk_mgr->funcs->set_hard_min_memclk)
dc->clk_mgr->funcs->set_hard_min_memclk(dc->clk_mgr, true);
if (dc->clk_mgr->funcs->set_hard_max_memclk)
dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
}
/** * dc_enable_dcmode_clk_limit() - lower clocks in dc (battery) mode * @dc: pointer to dc of the dm calling this * @enable: True = transition to DC mode, false = transition back to AC mode * * Some SoCs define additional clock limits when in DC mode, DM should * invoke this function when the platform undergoes a power source transition * so DC can apply/unapply the limit. This interface may be disruptive to * the onscreen content. * * Context: Triggered by OS through DM interface, or manually by escape calls. * Need to hold a dclock when doing so. * * Return: none (void function) *
*/ void dc_enable_dcmode_clk_limit(struct dc *dc, bool enable)
{ unsignedint softMax = 0, maxDPM = 0, funcMin = 0, i; bool p_state_change_support;
if (!dc->config.dc_mode_clk_limit_support) return;
softMax = dc->clk_mgr->bw_params->dc_mode_softmax_memclk; for (i = 0; i < dc->clk_mgr->bw_params->clk_table.num_entries; i++) { if (dc->clk_mgr->bw_params->clk_table.entries[i].memclk_mhz > maxDPM)
maxDPM = dc->clk_mgr->bw_params->clk_table.entries[i].memclk_mhz;
}
funcMin = (dc->clk_mgr->clks.dramclk_khz + 999) / 1000;
p_state_change_support = dc->clk_mgr->clks.p_state_change_support;
if (enable && !dc->clk_mgr->dc_mode_softmax_enabled) { if (p_state_change_support) { if (funcMin <= softMax && dc->clk_mgr->funcs->set_max_memclk)
dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, softMax); // else: No-Op
} else { if (funcMin <= softMax)
blank_and_force_memclk(dc, true, softMax); // else: No-Op
}
} elseif (!enable && dc->clk_mgr->dc_mode_softmax_enabled) { if (p_state_change_support) { if (funcMin <= softMax && dc->clk_mgr->funcs->set_max_memclk)
dc->clk_mgr->funcs->set_max_memclk(dc->clk_mgr, maxDPM); // else: No-Op
} else { if (funcMin <= softMax)
blank_and_force_memclk(dc, true, maxDPM); // else: No-Op
}
}
dc->clk_mgr->dc_mode_softmax_enabled = enable;
} bool dc_is_plane_eligible_for_idle_optimizations(struct dc *dc, unsignedint pitch, unsignedint height, enum surface_pixel_format format, struct dc_cursor_attributes *cursor_attr)
{ if (dc->hwss.does_plane_fit_in_mall && dc->hwss.does_plane_fit_in_mall(dc, pitch, height, format, cursor_attr)) returntrue; returnfalse;
}
/* cleanup on driver unload */ void dc_hardware_release(struct dc *dc)
{
dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(dc);
if (dc->hwss.hardware_release)
dc->hwss.hardware_release(dc);
}
void dc_mclk_switch_using_fw_based_vblank_stretch_shut_down(struct dc *dc)
{ if (dc->current_state)
dc->current_state->bw_ctx.bw.dcn.clk.fw_based_mclk_switching_shut_down = true;
}
/** * dc_is_dmub_outbox_supported - Check if DMUB firmware support outbox notification * * @dc: [in] dc structure * * Checks whether DMUB FW supports outbox notifications, if supported DM * should register outbox interrupt prior to actually enabling interrupts * via dc_enable_dmub_outbox * * Return: * True if DMUB FW supports outbox notifications, False otherwise
*/ bool dc_is_dmub_outbox_supported(struct dc *dc)
{ if (!dc->caps.dmcub_support) returnfalse;
switch (dc->ctx->asic_id.chip_family) {
case FAMILY_YELLOW_CARP: /* DCN31 B0 USB4 DPIA needs dmub notifications for interrupts */ if (dc->ctx->asic_id.hw_internal_rev == YELLOW_CARP_B0 &&
!dc->debug.dpia_debug.bits.disable_dpia) returntrue; break;
case AMDGPU_FAMILY_GC_11_0_1: case AMDGPU_FAMILY_GC_11_5_0: if (!dc->debug.dpia_debug.bits.disable_dpia) returntrue; break;
default: break;
}
/* dmub aux needs dmub notifications to be enabled */ return dc->debug.enable_dmub_aux_for_legacy_ddc;
}
/** * dc_enable_dmub_notifications - Check if dmub fw supports outbox * * @dc: [in] dc structure * * Calls dc_is_dmub_outbox_supported to check if dmub fw supports outbox * notifications. All DMs shall switch to dc_is_dmub_outbox_supported. This * API shall be removed after switching. * * Return: * True if DMUB FW supports outbox notifications, False otherwise
*/ bool dc_enable_dmub_notifications(struct dc *dc)
{ return dc_is_dmub_outbox_supported(dc);
}
/** * dc_enable_dmub_outbox - Enables DMUB unsolicited notification * * @dc: [in] dc structure * * Enables DMUB unsolicited notifications to x86 via outbox.
*/ void dc_enable_dmub_outbox(struct dc *dc)
{ struct dc_context *dc_ctx = dc->ctx;
/** * dc_process_dmub_aux_transfer_async - Submits aux command to dmub via inbox message * Sets port index appropriately for legacy DDC * @dc: dc structure * @link_index: link index * @payload: aux payload * * Returns: True if successful, False if failure
*/ bool dc_process_dmub_aux_transfer_async(struct dc *dc,
uint32_t link_index, struct aux_payload *payload)
{
uint8_t action; union dmub_rb_cmd cmd = {0};
ASSERT(payload->length <= 16);
cmd.dp_aux_access.header.type = DMUB_CMD__DP_AUX_ACCESS;
cmd.dp_aux_access.header.payload_bytes = 0; /* For dpia, ddc_pin is set to NULL */ if (!dc->links[link_index]->ddc->ddc_pin)
cmd.dp_aux_access.aux_control.type = AUX_CHANNEL_DPIA; else
cmd.dp_aux_access.aux_control.type = AUX_CHANNEL_LEGACY_DDC;
for (index = 0; index < dc->link_count; index++) { /* ddc_hw_inst has dpia port index for dpia links * and ddc instance for legacy links
*/ if (!dc->links[index]->ddc->ddc_pin) { if (dc->links[index]->ddc_hw_inst == dpia_port_index) {
link_index = index; break;
}
}
}
ASSERT(link_index != 0xFF); return link_index;
}
/** * dc_process_dmub_set_config_async - Submits set_config command * * @dc: [in] dc structure * @link_index: [in] link_index: link index * @payload: [in] aux payload * @notify: [out] set_config immediate reply * * Submits set_config command to dmub via inbox message. * * Return: * True if successful, False if failure
*/ bool dc_process_dmub_set_config_async(struct dc *dc,
uint32_t link_index, struct set_config_cmd_payload *payload, struct dmub_notification *notify)
{ union dmub_rb_cmd cmd = {0}; bool is_cmd_complete = true;
if (!dc_wake_and_execute_dmub_cmd(dc->ctx, &cmd, DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY)) { /* command is not processed by dmub */
notify->sc_status = SET_CONFIG_UNKNOWN_ERROR; return is_cmd_complete;
}
/* command processed by dmub, if ret_status is 1, it is completed instantly */ if (cmd.set_config_access.header.ret_status == 1)
notify->sc_status = cmd.set_config_access.set_config_control.immed_status; else /* cmd pending, will receive notification via outbox */
is_cmd_complete = false;
return is_cmd_complete;
}
/** * dc_process_dmub_set_mst_slots - Submits MST solt allocation * * @dc: [in] dc structure * @link_index: [in] link index * @mst_alloc_slots: [in] mst slots to be allotted * @mst_slots_in_use: [out] mst slots in use returned in failure case * * Submits mst slot allocation command to dmub via inbox message * * Return: * DC_OK if successful, DC_ERROR if failure
*/ enum dc_status dc_process_dmub_set_mst_slots(conststruct dc *dc,
uint32_t link_index,
uint8_t mst_alloc_slots,
uint8_t *mst_slots_in_use)
{ union dmub_rb_cmd cmd = {0};
if (!dc_wake_and_execute_dmub_cmd(dc->ctx, &cmd, DM_DMUB_WAIT_TYPE_WAIT_WITH_REPLY)) /* command is not processed by dmub */ return DC_ERROR_UNEXPECTED;
/* command processed by dmub, if ret_status is 1 */ if (cmd.set_config_access.header.ret_status != 1) /* command processing error */ return DC_ERROR_UNEXPECTED;
/* command processed and we have a status of 2, mst not enabled in dpia */ if (cmd.set_mst_alloc_slots.mst_slots_control.immed_status == 2) return DC_FAIL_UNSUPPORTED_1;
/* previously configured mst alloc and used slots did not match */ if (cmd.set_mst_alloc_slots.mst_slots_control.immed_status == 3) {
*mst_slots_in_use = cmd.set_mst_alloc_slots.mst_slots_control.mst_slots_in_use; return DC_NOT_SUPPORTED;
}
return DC_OK;
}
/** * dc_process_dmub_dpia_set_tps_notification - Submits tps notification * * @dc: [in] dc structure * @link_index: [in] link index * @tps: [in] request tps * * Submits set_tps_notification command to dmub via inbox message
*/ void dc_process_dmub_dpia_set_tps_notification(conststruct dc *dc, uint32_t link_index, uint8_t tps)
{ union dmub_rb_cmd cmd = {0};
/** * dc_print_dmub_diagnostic_data - Print DMUB diagnostic data for debugging * * @dc: [in] dc structure * *
*/ void dc_print_dmub_diagnostic_data(conststruct dc *dc)
{
dc_dmub_srv_log_diagnostic_data(dc->ctx->dmub_srv);
}
/** * dc_disable_accelerated_mode - disable accelerated mode * @dc: dc structure
*/ void dc_disable_accelerated_mode(struct dc *dc)
{
bios_set_scratch_acc_mode_change(dc->ctx->dc_bios, 0);
}
/** * dc_notify_vsync_int_state - notifies vsync enable/disable state * @dc: dc structure * @stream: stream where vsync int state changed * @enable: whether vsync is enabled or disabled * * Called when vsync is enabled/disabled Will notify DMUB to start/stop ABM * interrupts after steady state is reached.
*/ void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, bool enable)
{ int i; int edp_num; struct pipe_ctx *pipe = NULL; struct dc_link *link = stream->sink->link; struct dc_link *edp_links[MAX_NUM_EDP];
if (link->psr_settings.psr_feature_enabled) return;
if (link->replay_settings.replay_feature_enabled) return;
/*find primary pipe associated with stream*/ for (i = 0; i < MAX_PIPES; i++) {
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream && pipe->stream_res.tg) break;
}
if (i == MAX_PIPES) {
ASSERT(0); return;
}
dc_get_edp_links(dc, edp_links, &edp_num);
/* Determine panel inst */ for (i = 0; i < edp_num; i++) { if (edp_links[i] == link) break;
}
if (i == edp_num) { return;
}
if (pipe->stream_res.abm && pipe->stream_res.abm->funcs->set_abm_pause)
pipe->stream_res.abm->funcs->set_abm_pause(pipe->stream_res.abm, !enable, i, pipe->stream_res.tg->inst);
}
/***************************************************************************** * dc_abm_save_restore() - Interface to DC for save+pause and restore+un-pause * ABM * @dc: dc structure * @stream: stream where vsync int state changed * @pData: abm hw states *
****************************************************************************/ bool dc_abm_save_restore( struct dc *dc, struct dc_stream_state *stream, struct abm_save_restore *pData)
{ int i; int edp_num; struct pipe_ctx *pipe = NULL; struct dc_link *link = stream->sink->link; struct dc_link *edp_links[MAX_NUM_EDP];
if (link->replay_settings.replay_feature_enabled) returnfalse;
/*find primary pipe associated with stream*/ for (i = 0; i < MAX_PIPES; i++) {
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
if (pipe->stream == stream && pipe->stream_res.tg) break;
}
if (i == MAX_PIPES) {
ASSERT(0); returnfalse;
}
dc_get_edp_links(dc, edp_links, &edp_num);
/* Determine panel inst */ for (i = 0; i < edp_num; i++) if (edp_links[i] == link) break;
if (i == edp_num) returnfalse;
if (pipe->stream_res.abm &&
pipe->stream_res.abm->funcs->save_restore) return pipe->stream_res.abm->funcs->save_restore(
pipe->stream_res.abm,
i,
pData); returnfalse;
}
if (dc->debug.allow_sw_cursor_fallback && dc->res_pool->funcs->get_max_hw_cursor_size) { for (i = 0; i < dc->current_state->stream_count; i++) {
stream_cursor_size = dc->res_pool->funcs->get_max_hw_cursor_size(dc,
dc->current_state,
dc->current_state->streams[i]);
/** * dc_set_edp_power() - DM controls eDP power to be ON/OFF * * Called when DM wants to power on/off eDP. * Only work on links with flag skip_implict_edp_power_control is set. * * @dc: Current DC state * @edp_link: a link with eDP connector signal type * @powerOn: power on/off eDP * * Return: void
*/ void dc_set_edp_power(conststruct dc *dc, struct dc_link *edp_link, bool powerOn)
{ if (edp_link->connector_signal != SIGNAL_TYPE_EDP) return;
if (edp_link->skip_implict_edp_power_control == false) return;
/** * dc_get_power_profile_for_dc_state() - extracts power profile from dc state * * Called when DM wants to make power policy decisions based on dc_state * * @context: Pointer to the dc_state from which the power profile is extracted. * * Return: The power profile structure containing the power level information.
*/ struct dc_power_profile dc_get_power_profile_for_dc_state(conststruct dc_state *context)
{ struct dc_power_profile profile = { 0 };
profile.power_level = !context->bw_ctx.bw.dcn.clk.p_state_change_support; if (!context->clk_mgr || !context->clk_mgr->ctx || !context->clk_mgr->ctx->dc) return profile; struct dc *dc = context->clk_mgr->ctx->dc;
if (dc->res_pool->funcs->get_power_profile)
profile.power_level = dc->res_pool->funcs->get_power_profile(context); return profile;
}
/** * dc_get_det_buffer_size_from_state() - extracts detile buffer size from dc state * * This function is called to log the detile buffer size from the dc_state. * * @context: a pointer to the dc_state from which the detile buffer size is extracted. * * Return: the size of the detile buffer, or 0 if not available.
*/ unsignedint dc_get_det_buffer_size_from_state(conststruct dc_state *context)
{ struct dc *dc = context->clk_mgr->ctx->dc;
if (dc->res_pool->funcs->get_det_buffer_size) return dc->res_pool->funcs->get_det_buffer_size(context); else return 0;
}
/** * dc_get_host_router_index: Get index of host router from a dpia link * * This function return a host router index of the target link. If the target link is dpia link. * * @link: Pointer to the target link (input) * @host_router_index: Pointer to store the host router index of the target link (output). * * Return: true if the host router index is found and valid. *
*/ bool dc_get_host_router_index(conststruct dc_link *link, unsignedint *host_router_index)
{ struct dc *dc;
if (!link || !host_router_index || link->ep_type != DISPLAY_ENDPOINT_USB4_DPIA) returnfalse;
dc = link->ctx->dc;
if (link->link_index < dc->lowest_dpia_link_index) returnfalse;
bool dc_is_cursor_limit_pending(struct dc *dc)
{
uint32_t i;
for (i = 0; i < dc->current_state->stream_count; i++) { if (dc_stream_is_cursor_limit_pending(dc, dc->current_state->streams[i])) returntrue;
}
returnfalse;
}
bool dc_can_clear_cursor_limit(struct dc *dc)
{
uint32_t i;
for (i = 0; i < dc->current_state->stream_count; i++) { if (dc_state_can_clear_stream_cursor_subvp_limit(dc->current_state->streams[i], dc->current_state)) returntrue;
}
returnfalse;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.107 Sekunden
(vorverarbeitet am 2026-04-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.