drm/amd/display: Update link encoder object creation
authorJimmy Kizito <Jimmy.Kizito@amd.com>
Tue, 5 Jan 2021 15:17:05 +0000 (10:17 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 2 Mar 2021 19:05:52 +0000 (14:05 -0500)
[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 <daniel.wheeler@amd.com>
Signed-off-by: Jimmy Kizito <Jimmy.Kizito@amd.com>
Reviewed-by: Jun Lei <Jun.Lei@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/dc/core/dc_link.c
drivers/gpu/drm/amd/display/dc/dc_link.h
drivers/gpu/drm/amd/display/dc/inc/core_types.h
drivers/gpu/drm/amd/display/dc/inc/hw/hw_shared.h
drivers/gpu/drm/amd/display/dc/inc/resource.h

index 81ad546..fa9a62d 100644 (file)
@@ -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++) {
index e189f16..df6ab33 100644 (file)
@@ -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
index 8efa1b8..c5f4832 100644 (file)
@@ -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];
index 43e33f4..31a1713 100644 (file)
@@ -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 {
index 3d97078..fe1e583 100644 (file)
@@ -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;
 };