Commit 753b7e62 authored by Mustapha Ghaddar's avatar Mustapha Ghaddar Committed by Alex Deucher

drm/amd/display: Add DPIA Link Encoder Assignment Fix

For DPIA we should have preferred DIG assignment based on DPIA selected
as per the ASIC design.
Reviewed-by: default avatarGeorge Shen <george.shen@amd.com>
Acked-by: default avatarHamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: default avatarMustapha Ghaddar <mghaddar@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 15e6b396
...@@ -169,11 +169,23 @@ static void add_link_enc_assignment( ...@@ -169,11 +169,23 @@ static void add_link_enc_assignment(
/* Return first available DIG link encoder. */ /* Return first available DIG link encoder. */
static enum engine_id find_first_avail_link_enc( static enum engine_id find_first_avail_link_enc(
const struct dc_context *ctx, const struct dc_context *ctx,
const struct dc_state *state) const struct dc_state *state,
enum engine_id eng_id_requested)
{ {
enum engine_id eng_id = ENGINE_ID_UNKNOWN; enum engine_id eng_id = ENGINE_ID_UNKNOWN;
int i; int i;
if (eng_id_requested != ENGINE_ID_UNKNOWN) {
for (i = 0; i < ctx->dc->res_pool->res_cap->num_dig_link_enc; i++) {
eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i];
if (eng_id == eng_id_requested)
return eng_id;
}
}
eng_id = ENGINE_ID_UNKNOWN;
for (i = 0; i < ctx->dc->res_pool->res_cap->num_dig_link_enc; i++) { for (i = 0; i < ctx->dc->res_pool->res_cap->num_dig_link_enc; i++) {
eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i]; eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i];
if (eng_id != ENGINE_ID_UNKNOWN) if (eng_id != ENGINE_ID_UNKNOWN)
...@@ -287,7 +299,7 @@ void link_enc_cfg_link_encs_assign( ...@@ -287,7 +299,7 @@ void link_enc_cfg_link_encs_assign(
struct dc_stream_state *streams[], struct dc_stream_state *streams[],
uint8_t stream_count) uint8_t stream_count)
{ {
enum engine_id eng_id = ENGINE_ID_UNKNOWN; enum engine_id eng_id = ENGINE_ID_UNKNOWN, eng_id_req = ENGINE_ID_UNKNOWN;
int i; int i;
int j; int j;
...@@ -377,8 +389,15 @@ void link_enc_cfg_link_encs_assign( ...@@ -377,8 +389,15 @@ void link_enc_cfg_link_encs_assign(
* assigned to that endpoint. * assigned to that endpoint.
*/ */
link_enc = get_link_enc_used_by_link(state, stream->link); link_enc = get_link_enc_used_by_link(state, stream->link);
if (link_enc == NULL) if (link_enc == NULL) {
eng_id = find_first_avail_link_enc(stream->ctx, state);
if (stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA &&
stream->link->dpia_preferred_eng_id != ENGINE_ID_UNKNOWN)
eng_id_req = stream->link->dpia_preferred_eng_id;
if (eng_id == ENGINE_ID_UNKNOWN)
eng_id = find_first_avail_link_enc(stream->ctx, state, eng_id_req);
}
else else
eng_id = link_enc->preferred_engine; eng_id = link_enc->preferred_engine;
...@@ -402,7 +421,9 @@ void link_enc_cfg_link_encs_assign( ...@@ -402,7 +421,9 @@ void link_enc_cfg_link_encs_assign(
DC_LOG_DEBUG("%s: CUR %s(%d) - enc_id(%d)\n", DC_LOG_DEBUG("%s: CUR %s(%d) - enc_id(%d)\n",
__func__, __func__,
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA", assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA",
assignment.ep_id.link_id.enum_id - 1, assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ?
assignment.ep_id.link_id.enum_id :
assignment.ep_id.link_id.enum_id - 1,
assignment.eng_id); assignment.eng_id);
} }
for (i = 0; i < MAX_PIPES; i++) { for (i = 0; i < MAX_PIPES; i++) {
...@@ -413,7 +434,9 @@ void link_enc_cfg_link_encs_assign( ...@@ -413,7 +434,9 @@ void link_enc_cfg_link_encs_assign(
DC_LOG_DEBUG("%s: NEW %s(%d) - enc_id(%d)\n", DC_LOG_DEBUG("%s: NEW %s(%d) - enc_id(%d)\n",
__func__, __func__,
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA", assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA",
assignment.ep_id.link_id.enum_id - 1, assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ?
assignment.ep_id.link_id.enum_id :
assignment.ep_id.link_id.enum_id - 1,
assignment.eng_id); assignment.eng_id);
} }
......
...@@ -1496,6 +1496,7 @@ struct dc_link { ...@@ -1496,6 +1496,7 @@ struct dc_link {
* object creation. * object creation.
*/ */
enum engine_id eng_id; enum engine_id eng_id;
enum engine_id dpia_preferred_eng_id;
bool test_pattern_enabled; bool test_pattern_enabled;
enum dp_test_pattern current_test_pattern; enum dp_test_pattern current_test_pattern;
......
...@@ -1032,6 +1032,28 @@ static const struct dce_i2c_mask i2c_masks = { ...@@ -1032,6 +1032,28 @@ static const struct dce_i2c_mask i2c_masks = {
I2C_COMMON_MASK_SH_LIST_DCN30(_MASK) I2C_COMMON_MASK_SH_LIST_DCN30(_MASK)
}; };
/* ========================================================== */
/*
* DPIA index | Preferred Encoder | Host Router
* 0 | C | 0
* 1 | First Available | 0
* 2 | D | 1
* 3 | First Available | 1
*/
/* ========================================================== */
static const enum engine_id dpia_to_preferred_enc_id_table[] = {
ENGINE_ID_DIGC,
ENGINE_ID_DIGC,
ENGINE_ID_DIGD,
ENGINE_ID_DIGD
};
static enum engine_id dcn314_get_preferred_eng_id_dpia(unsigned int dpia_index)
{
return dpia_to_preferred_enc_id_table[dpia_index];
}
static struct dce_i2c_hw *dcn31_i2c_hw_create( static struct dce_i2c_hw *dcn31_i2c_hw_create(
struct dc_context *ctx, struct dc_context *ctx,
uint32_t inst) uint32_t inst)
...@@ -1785,6 +1807,7 @@ static struct resource_funcs dcn314_res_pool_funcs = { ...@@ -1785,6 +1807,7 @@ static struct resource_funcs dcn314_res_pool_funcs = {
.update_bw_bounding_box = dcn314_update_bw_bounding_box, .update_bw_bounding_box = dcn314_update_bw_bounding_box,
.patch_unknown_plane_state = dcn20_patch_unknown_plane_state, .patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
.get_panel_config_defaults = dcn314_get_panel_config_defaults, .get_panel_config_defaults = dcn314_get_panel_config_defaults,
.get_preferred_eng_id_dpia = dcn314_get_preferred_eng_id_dpia,
}; };
static struct clock_source *dcn30_clock_source_create( static struct clock_source *dcn30_clock_source_create(
......
...@@ -65,6 +65,7 @@ struct resource_context; ...@@ -65,6 +65,7 @@ struct resource_context;
struct clk_bw_params; struct clk_bw_params;
struct resource_funcs { struct resource_funcs {
enum engine_id (*get_preferred_eng_id_dpia)(unsigned int dpia_index);
void (*destroy)(struct resource_pool **pool); void (*destroy)(struct resource_pool **pool);
void (*link_init)(struct dc_link *link); void (*link_init)(struct dc_link *link);
struct panel_cntl*(*panel_cntl_create)( struct panel_cntl*(*panel_cntl_create)(
......
...@@ -792,6 +792,10 @@ static bool construct_dpia(struct dc_link *link, ...@@ -792,6 +792,10 @@ static bool construct_dpia(struct dc_link *link,
/* Set dpia port index : 0 to number of dpia ports */ /* Set dpia port index : 0 to number of dpia ports */
link->ddc_hw_inst = init_params->connector_index; link->ddc_hw_inst = init_params->connector_index;
// Assign Dpia preferred eng_id
if (link->dc->res_pool->funcs->get_preferred_eng_id_dpia)
link->dpia_preferred_eng_id = link->dc->res_pool->funcs->get_preferred_eng_id_dpia(link->ddc_hw_inst);
/* TODO: Create link encoder */ /* TODO: Create link encoder */
link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED; link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment