Skip to content

Commit 64be47b

Browse files
Mustapha Ghaddaralexdeucher
authored andcommitted
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: George Shen <[email protected]> Acked-by: Hamza Mahfooz <[email protected]> Signed-off-by: Mustapha Ghaddar <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent db5494a commit 64be47b

File tree

5 files changed

+58
-6
lines changed

5 files changed

+58
-6
lines changed

drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,23 @@ static void add_link_enc_assignment(
169169
/* Return first available DIG link encoder. */
170170
static enum engine_id find_first_avail_link_enc(
171171
const struct dc_context *ctx,
172-
const struct dc_state *state)
172+
const struct dc_state *state,
173+
enum engine_id eng_id_requested)
173174
{
174175
enum engine_id eng_id = ENGINE_ID_UNKNOWN;
175176
int i;
176177

178+
if (eng_id_requested != ENGINE_ID_UNKNOWN) {
179+
180+
for (i = 0; i < ctx->dc->res_pool->res_cap->num_dig_link_enc; i++) {
181+
eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i];
182+
if (eng_id == eng_id_requested)
183+
return eng_id;
184+
}
185+
}
186+
187+
eng_id = ENGINE_ID_UNKNOWN;
188+
177189
for (i = 0; i < ctx->dc->res_pool->res_cap->num_dig_link_enc; i++) {
178190
eng_id = state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i];
179191
if (eng_id != ENGINE_ID_UNKNOWN)
@@ -287,7 +299,7 @@ void link_enc_cfg_link_encs_assign(
287299
struct dc_stream_state *streams[],
288300
uint8_t stream_count)
289301
{
290-
enum engine_id eng_id = ENGINE_ID_UNKNOWN;
302+
enum engine_id eng_id = ENGINE_ID_UNKNOWN, eng_id_req = ENGINE_ID_UNKNOWN;
291303
int i;
292304
int j;
293305

@@ -377,8 +389,15 @@ void link_enc_cfg_link_encs_assign(
377389
* assigned to that endpoint.
378390
*/
379391
link_enc = get_link_enc_used_by_link(state, stream->link);
380-
if (link_enc == NULL)
381-
eng_id = find_first_avail_link_enc(stream->ctx, state);
392+
if (link_enc == NULL) {
393+
394+
if (stream->link->ep_type == DISPLAY_ENDPOINT_USB4_DPIA &&
395+
stream->link->dpia_preferred_eng_id != ENGINE_ID_UNKNOWN)
396+
eng_id_req = stream->link->dpia_preferred_eng_id;
397+
398+
if (eng_id == ENGINE_ID_UNKNOWN)
399+
eng_id = find_first_avail_link_enc(stream->ctx, state, eng_id_req);
400+
}
382401
else
383402
eng_id = link_enc->preferred_engine;
384403

@@ -402,7 +421,9 @@ void link_enc_cfg_link_encs_assign(
402421
DC_LOG_DEBUG("%s: CUR %s(%d) - enc_id(%d)\n",
403422
__func__,
404423
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA",
405-
assignment.ep_id.link_id.enum_id - 1,
424+
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ?
425+
assignment.ep_id.link_id.enum_id :
426+
assignment.ep_id.link_id.enum_id - 1,
406427
assignment.eng_id);
407428
}
408429
for (i = 0; i < MAX_PIPES; i++) {
@@ -413,7 +434,9 @@ void link_enc_cfg_link_encs_assign(
413434
DC_LOG_DEBUG("%s: NEW %s(%d) - enc_id(%d)\n",
414435
__func__,
415436
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ? "PHY" : "DPIA",
416-
assignment.ep_id.link_id.enum_id - 1,
437+
assignment.ep_id.ep_type == DISPLAY_ENDPOINT_PHY ?
438+
assignment.ep_id.link_id.enum_id :
439+
assignment.ep_id.link_id.enum_id - 1,
417440
assignment.eng_id);
418441
}
419442

drivers/gpu/drm/amd/display/dc/dc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,6 +1496,7 @@ struct dc_link {
14961496
* object creation.
14971497
*/
14981498
enum engine_id eng_id;
1499+
enum engine_id dpia_preferred_eng_id;
14991500

15001501
bool test_pattern_enabled;
15011502
enum dp_test_pattern current_test_pattern;

drivers/gpu/drm/amd/display/dc/dcn314/dcn314_resource.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,28 @@ static const struct dce_i2c_mask i2c_masks = {
10321032
I2C_COMMON_MASK_SH_LIST_DCN30(_MASK)
10331033
};
10341034

1035+
/* ========================================================== */
1036+
1037+
/*
1038+
* DPIA index | Preferred Encoder | Host Router
1039+
* 0 | C | 0
1040+
* 1 | First Available | 0
1041+
* 2 | D | 1
1042+
* 3 | First Available | 1
1043+
*/
1044+
/* ========================================================== */
1045+
static const enum engine_id dpia_to_preferred_enc_id_table[] = {
1046+
ENGINE_ID_DIGC,
1047+
ENGINE_ID_DIGC,
1048+
ENGINE_ID_DIGD,
1049+
ENGINE_ID_DIGD
1050+
};
1051+
1052+
static enum engine_id dcn314_get_preferred_eng_id_dpia(unsigned int dpia_index)
1053+
{
1054+
return dpia_to_preferred_enc_id_table[dpia_index];
1055+
}
1056+
10351057
static struct dce_i2c_hw *dcn31_i2c_hw_create(
10361058
struct dc_context *ctx,
10371059
uint32_t inst)
@@ -1785,6 +1807,7 @@ static struct resource_funcs dcn314_res_pool_funcs = {
17851807
.update_bw_bounding_box = dcn314_update_bw_bounding_box,
17861808
.patch_unknown_plane_state = dcn20_patch_unknown_plane_state,
17871809
.get_panel_config_defaults = dcn314_get_panel_config_defaults,
1810+
.get_preferred_eng_id_dpia = dcn314_get_preferred_eng_id_dpia,
17881811
};
17891812

17901813
static struct clock_source *dcn30_clock_source_create(

drivers/gpu/drm/amd/display/dc/inc/core_types.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ struct resource_context;
6565
struct clk_bw_params;
6666

6767
struct resource_funcs {
68+
enum engine_id (*get_preferred_eng_id_dpia)(unsigned int dpia_index);
6869
void (*destroy)(struct resource_pool **pool);
6970
void (*link_init)(struct dc_link *link);
7071
struct panel_cntl*(*panel_cntl_create)(

drivers/gpu/drm/amd/display/dc/link/link_factory.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,10 @@ static bool construct_dpia(struct dc_link *link,
791791
/* Set dpia port index : 0 to number of dpia ports */
792792
link->ddc_hw_inst = init_params->connector_index;
793793

794+
// Assign Dpia preferred eng_id
795+
if (link->dc->res_pool->funcs->get_preferred_eng_id_dpia)
796+
link->dpia_preferred_eng_id = link->dc->res_pool->funcs->get_preferred_eng_id_dpia(link->ddc_hw_inst);
797+
794798
/* TODO: Create link encoder */
795799

796800
link->psr_settings.psr_version = DC_PSR_VERSION_UNSUPPORTED;

0 commit comments

Comments
 (0)