From e1f4328f22c0c2c4401326123f05d6ab60e5ff09 Mon Sep 17 00:00:00 2001 From: Jimmy Kizito Date: Tue, 5 Jan 2021 10:17:05 -0500 Subject: [PATCH] drm/amd/display: Update link encoder object creation [Why] Currently the creation of link encoder objects is tightly coupled to the creation of link objects. Decoupling link encoder object creation is a preliminary step in the process of allowing link encoders to be dynamically assigned to links. [How] Add "minimal" link encoder objects which are not associated with any link until required. Tested-by: Daniel Wheeler Signed-off-by: Jimmy Kizito Reviewed-by: Jun Lei Acked-by: Rodrigo Siqueira Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_link.c | 14 +++++++++++++- drivers/gpu/drm/amd/display/dc/dc_link.h | 4 ++++ drivers/gpu/drm/amd/display/dc/inc/core_types.h | 13 +++++++++++++ drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h | 1 + drivers/gpu/drm/amd/display/dc/inc/resource.h | 1 + 5 files changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c index 81ad546b..fa9a62d 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c @@ -91,8 +91,14 @@ static void dc_link_destruct(struct dc_link *link) if (link->panel_cntl) link->panel_cntl->funcs->destroy(&link->panel_cntl); - if (link->link_enc) + if (link->link_enc) { + /* Update link encoder tracking variables. These are used for the dynamic + * assignment of link encoders to streams. + */ + link->dc->res_pool->link_encoders[link->link_enc->preferred_engine] = NULL; + link->dc->res_pool->dig_link_enc_count--; link->link_enc->funcs->destroy(&link->link_enc); + } if (link->local_sink) dc_sink_release(link->local_sink); @@ -1532,6 +1538,12 @@ static bool dc_link_construct(struct dc_link *link, DC_LOG_DC("BIOS object table - DP_IS_USB_C: %d", link->link_enc->features.flags.bits.DP_IS_USB_C); + /* Update link encoder tracking variables. These are used for the dynamic + * assignment of link encoders to streams. + */ + link->dc->res_pool->link_encoders[link->link_enc->preferred_engine] = link->link_enc; + link->dc->res_pool->dig_link_enc_count++; + link->link_enc_hw_inst = link->link_enc->transmitter; for (i = 0; i < 4; i++) { diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h b/drivers/gpu/drm/amd/display/dc/dc_link.h index e189f16..df6ab33 100644 --- a/drivers/gpu/drm/amd/display/dc/dc_link.h +++ b/drivers/gpu/drm/amd/display/dc/dc_link.h @@ -103,6 +103,10 @@ struct dc_link { bool lttpr_non_transparent_mode; bool is_internal_display; + /* TODO: Rename. Flag an endpoint as having a programmable mapping to a + * DIG encoder. */ + bool is_dig_mapping_flexible; + bool edp_sink_present; /* caps is the same as reported_link_cap. link_traing use diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h index 8efa1b8..c5f4832 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h +++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h @@ -97,6 +97,10 @@ struct resource_funcs { const struct panel_cntl_init_data *panel_cntl_init_data); struct link_encoder *(*link_enc_create)( const struct encoder_init_data *init); + /* Create a minimal link encoder object with no dc_link object + * associated with it. */ + struct link_encoder *(*link_enc_create_minimal)(struct dc_context *ctx, enum engine_id eng_id); + bool (*validate_bandwidth)( struct dc *dc, struct dc_state *context, @@ -210,6 +214,15 @@ struct resource_pool { unsigned int underlay_pipe_index; unsigned int stream_enc_count; + /* An array for accessing the link encoder objects that have been created. + * Index in array corresponds to engine ID - viz. 0: ENGINE_ID_DIGA + */ + struct link_encoder *link_encoders[MAX_DIG_LINK_ENCODERS]; + /* Number of DIG link encoder objects created - i.e. number of valid + * entries in link_encoders array. + */ + unsigned int dig_link_enc_count; + #if defined(CONFIG_DRM_AMD_DC_DCN) struct dc_3dlut *mpc_lut[MAX_PIPES]; struct dc_transfer_func *mpc_shaper[MAX_PIPES]; diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h b/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h index 43e33f4..31a1713b 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h +++ b/drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h @@ -36,6 +36,7 @@ #define MAX_AUDIOS 7 #define MAX_PIPES 6 +#define MAX_DIG_LINK_ENCODERS 7 #define MAX_DWB_PIPES 1 struct gamma_curve { diff --git a/drivers/gpu/drm/amd/display/dc/inc/resource.h b/drivers/gpu/drm/amd/display/dc/inc/resource.h index 3d97078..fe1e583 100644 --- a/drivers/gpu/drm/amd/display/dc/inc/resource.h +++ b/drivers/gpu/drm/amd/display/dc/inc/resource.h @@ -48,6 +48,7 @@ struct resource_caps { int num_ddc; int num_vmid; int num_dsc; + unsigned int num_dig_link_enc; // Total number of DIGs (digital encoders) in DIO (Display Input/Output). int num_mpc_3dlut; }; -- 2.7.4